Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/CodeGen/include/Luau/ConditionA64.h
2727 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#pragma once
3
4
namespace Luau
5
{
6
namespace CodeGen
7
{
8
namespace A64
9
{
10
11
// See Table C1-1 on page C1-229 of Arm ARM for A-profile architecture
12
enum class ConditionA64
13
{
14
// EQ: integer (equal), floating-point (equal)
15
Equal,
16
// NE: integer (not equal), floating-point (not equal or unordered)
17
NotEqual,
18
19
// CS: integer (carry set), unsigned integer (greater than, equal), floating-point (greater than, equal or unordered)
20
CarrySet,
21
// CC: integer (carry clear), unsigned integer (less than), floating-point (less than)
22
CarryClear,
23
24
// MI: integer (negative), floating-point (less than)
25
Minus,
26
// PL: integer (positive or zero), floating-point (greater than, equal or unordered)
27
Plus,
28
29
// VS: integer (overflow), floating-point (unordered)
30
Overflow,
31
// VC: integer (no overflow), floating-point (ordered)
32
NoOverflow,
33
34
// HI: integer (unsigned higher), floating-point (greater than, or unordered)
35
UnsignedGreater,
36
// LS: integer (unsigned lower or same), floating-point (less than or equal)
37
UnsignedLessEqual,
38
39
// GE: integer (signed greater than or equal), floating-point (greater than or equal)
40
GreaterEqual,
41
// LT: integer (signed less than), floating-point (less than, or unordered)
42
Less,
43
44
// GT: integer (signed greater than), floating-point (greater than)
45
Greater,
46
// LE: integer (signed less than or equal), floating-point (less than, equal or unordered)
47
LessEqual,
48
49
// AL: always
50
Always,
51
52
Count,
53
54
UnsignedLess = CarryClear,
55
UnsignedGreaterEqual = CarrySet,
56
};
57
58
// Returns a condition that for 'a op b' will result in 'b op a'
59
// Only a subset of conditions is allowed
60
inline ConditionA64 getInverseCondition(ConditionA64 cond)
61
{
62
switch (cond)
63
{
64
case ConditionA64::Equal:
65
return ConditionA64::Equal;
66
case ConditionA64::NotEqual:
67
return ConditionA64::NotEqual;
68
case ConditionA64::UnsignedGreater:
69
return ConditionA64::UnsignedLess;
70
case ConditionA64::UnsignedLessEqual:
71
return ConditionA64::UnsignedGreaterEqual;
72
case ConditionA64::GreaterEqual:
73
return ConditionA64::LessEqual;
74
case ConditionA64::Less:
75
return ConditionA64::Greater;
76
case ConditionA64::Greater:
77
return ConditionA64::Less;
78
case ConditionA64::LessEqual:
79
return ConditionA64::GreaterEqual;
80
default:
81
CODEGEN_ASSERT(!"invalid ConditionA64 value for getInverseCondition");
82
}
83
84
return ConditionA64::Count;
85
}
86
87
} // namespace A64
88
} // namespace CodeGen
89
} // namespace Luau
90
91