Skip to content

Commit d575f80

Browse files
committed
MCFixup: Make MCFixupKind a type alias
The unscoped enumeration contains a fix generic kinds (e.g. FK_Data_). However, most fixup kinds are target-specific (including relocation code) and lead to a lot of casts. Make MCFixupKind a type alias instead.
1 parent 878ce21 commit d575f80

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

llvm/include/llvm/MC/MCFixup.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ namespace llvm {
1818
class MCExpr;
1919

2020
/// Extensible enumeration to represent the type of a fixup.
21-
enum MCFixupKind : uint16_t {
21+
using MCFixupKind = uint16_t;
22+
enum {
2223
// [0, FirstLiteralRelocationKind) encodes raw relocation types.
2324

2425
// [FirstLiteralRelocationKind, FK_NONE) encodes raw relocation types coming
@@ -67,7 +68,7 @@ class MCFixup {
6768

6869
/// The target dependent kind of fixup item this is. The kind is used to
6970
/// determine how the operand value should be encoded into the instruction.
70-
uint16_t Kind = FK_NONE;
71+
MCFixupKind Kind = FK_NONE;
7172

7273
/// True if this is a PC-relative fixup. The relocatable expression is
7374
/// typically resolved When SymB is nullptr and SymA is a local symbol defined
@@ -81,7 +82,7 @@ class MCFixup {
8182
/// Consider bit fields if we need more flags.
8283

8384
public:
84-
static MCFixup create(uint32_t Offset, const MCExpr *Value, uint16_t Kind,
85+
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind,
8586
bool PCRel = false) {
8687
MCFixup FI;
8788
FI.Value = Value;
@@ -90,13 +91,8 @@ class MCFixup {
9091
FI.PCRel = PCRel;
9192
return FI;
9293
}
93-
static MCFixup create(uint32_t Offset, const MCExpr *Value,
94-
MCFixupKind Kind) {
95-
return create(Offset, Value, unsigned(Kind));
96-
}
97-
98-
MCFixupKind getKind() const { return MCFixupKind(Kind); }
9994

95+
MCFixupKind getKind() const { return Kind; }
10096
unsigned getTargetKind() const { return Kind; }
10197

10298
uint32_t getOffset() const { return Offset; }

llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static unsigned getSize(unsigned Kind) {
135135
switch (Kind) {
136136
default:
137137
return 3;
138-
case MCFixupKind::FK_Data_4:
138+
case FK_Data_4:
139139
return 4;
140140
case Xtensa::fixup_xtensa_branch_6:
141141
return 2;

0 commit comments

Comments
 (0)