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