@@ -18,8 +18,17 @@ namespace llvm {
1818class MCExpr ;
1919
2020// / 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.
2332 FK_Data_1, // /< A one-byte fixup.
2433 FK_Data_2, // /< A two-byte fixup.
2534 FK_Data_4, // /< A four-byte fixup.
@@ -34,19 +43,7 @@ enum MCFixupKind {
3443 FK_SecRel_4, // /< A four-byte section relative fixup.
3544 FK_SecRel_8, // /< A eight-byte section relative fixup.
3645
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,
5047};
5148
5249// / Encode information on a single operation to perform on a byte
@@ -81,7 +78,6 @@ class MCFixup {
8178public:
8279 static MCFixup create (uint32_t Offset, const MCExpr *Value,
8380 MCFixupKind Kind, SMLoc Loc = SMLoc()) {
84- assert (Kind <= MaxFixupKind && " Kind out of range!" );
8581 MCFixup FI;
8682 FI.Value = Value;
8783 FI.Offset = Offset;
@@ -125,15 +121,13 @@ class MCFixup {
125121namespace mc {
126122// Check if the fixup kind is a relocation type. Return false if the fixup can
127123// 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; }
131125
132126// Check if the fixup kind represents a relocation type from a .reloc directive.
133127// In ELF, this skips STT_SECTION adjustment and STT_TLS symbol type setting for
134128// TLS relocations.
135129inline bool isRelocRelocation (MCFixupKind FixupKind) {
136- return FixupKind >= FirstLiteralRelocationKind ;
130+ return FirstLiteralRelocationKind <= FixupKind && FixupKind < FK_NONE ;
137131}
138132} // namespace mc
139133
0 commit comments