@@ -18,8 +18,17 @@ namespace llvm {
18
18
class MCExpr ;
19
19
20
20
// / Extensible enumeration to represent the type of a fixup.
21
- enum MCFixupKind {
22
- FK_NONE = 0 , // /< A no-op fixup.
21
+ enum MCFixupKind : uint16_t {
22
+ // [0, FirstLiteralRelocationKind) encodes raw relocation types.
23
+
24
+ // [FirstLiteralRelocationKind, FK_NONE) encodes raw relocation types coming
25
+ // from .reloc directives. Fixup kind
26
+ // FirstLiteralRelocationKind+t encodes relocation type t.
27
+ FirstLiteralRelocationKind = 2000 ,
28
+
29
+ // Other kinds indicate the fixup may resolve to a constant, allowing the
30
+ // assembler to update the instruction or data directly without a relocation.
31
+ FK_NONE = 4000 , // /< A no-op fixup.
23
32
FK_Data_1, // /< A one-byte fixup.
24
33
FK_Data_2, // /< A two-byte fixup.
25
34
FK_Data_4, // /< A four-byte fixup.
@@ -34,19 +43,7 @@ enum MCFixupKind {
34
43
FK_SecRel_4, // /< A four-byte section relative fixup.
35
44
FK_SecRel_8, // /< A eight-byte section relative fixup.
36
45
37
- FirstTargetFixupKind = 128 ,
38
-
39
- // / Targets can use FirstRelocationKind+t to encode relocation type t.
40
- FirstRelocationKind = 256 ,
41
-
42
- // / The range [FirstLiteralRelocationKind, MaxTargetFixupKind) is used for
43
- // / relocations coming from .reloc directive. Fixup kind
44
- // / FirstLiteralRelocationKind+V represents the relocation type with number V.
45
- FirstLiteralRelocationKind = 256 + 1032 + 32 ,
46
-
47
- // / Set limit to accommodate the highest reloc type in use for all Targets,
48
- // / currently R_AARCH64_IRELATIVE at 1032, including room for expansion.
49
- MaxFixupKind = FirstLiteralRelocationKind + 1032 + 32 ,
46
+ FirstTargetFixupKind,
50
47
};
51
48
52
49
// / Encode information on a single operation to perform on a byte
@@ -81,7 +78,6 @@ class MCFixup {
81
78
public:
82
79
static MCFixup create (uint32_t Offset, const MCExpr *Value,
83
80
MCFixupKind Kind, SMLoc Loc = SMLoc()) {
84
- assert (Kind <= MaxFixupKind && " Kind out of range!" );
85
81
MCFixup FI;
86
82
FI.Value = Value;
87
83
FI.Offset = Offset;
@@ -125,15 +121,13 @@ class MCFixup {
125
121
namespace mc {
126
122
// Check if the fixup kind is a relocation type. Return false if the fixup can
127
123
// be resolved without a relocation.
128
- inline bool isRelocation (MCFixupKind FixupKind) {
129
- return FixupKind >= FirstRelocationKind;
130
- }
124
+ inline bool isRelocation (MCFixupKind FixupKind) { return FixupKind < FK_NONE; }
131
125
132
126
// Check if the fixup kind represents a relocation type from a .reloc directive.
133
127
// In ELF, this skips STT_SECTION adjustment and STT_TLS symbol type setting for
134
128
// TLS relocations.
135
129
inline bool isRelocRelocation (MCFixupKind FixupKind) {
136
- return FixupKind >= FirstLiteralRelocationKind ;
130
+ return FirstLiteralRelocationKind <= FixupKind && FixupKind < FK_NONE ;
137
131
}
138
132
} // namespace mc
139
133
0 commit comments