Skip to content

Commit

Permalink
Revert "[MC] Make MCCFIInstruction smaller"
Browse files Browse the repository at this point in the history
This reverts commit 9abb574.
  • Loading branch information
kuhar committed Jul 9, 2024
1 parent 4a7695e commit fe82af3
Showing 1 changed file with 22 additions and 35 deletions.
57 changes: 22 additions & 35 deletions llvm/include/llvm/MC/MCDwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ class MCGenDwarfLabelEntry {

class MCCFIInstruction {
public:
enum OpType : uint8_t {
enum OpType {
OpSameValue,
OpRememberState,
OpRestoreState,
Expand All @@ -504,44 +504,35 @@ class MCCFIInstruction {
};

private:
OpType Operation;
MCSymbol *Label;
unsigned Register;
union {
struct {
unsigned Register;
int Offset;
} RI;
struct {
unsigned Register;
int Offset;
unsigned AddressSpace;
} RIA;
struct {
unsigned Register;
unsigned Register2;
} RR;
} U;
OpType Operation;
int Offset;
unsigned Register2;
};
unsigned AddressSpace = ~0u;
SMLoc Loc;
std::vector<char> Values;
std::string Comment;

MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, SMLoc Loc,
StringRef V = "", StringRef Comment = "")
: Label(L), Operation(Op), Loc(Loc), Values(V.begin(), V.end()),
Comment(Comment) {
: Operation(Op), Label(L), Register(R), Offset(O), Loc(Loc),
Values(V.begin(), V.end()), Comment(Comment) {
assert(Op != OpRegister && Op != OpLLVMDefAspaceCfa);
U.RI = {R, O};
}

MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R1, unsigned R2, SMLoc Loc)
: Label(L), Operation(Op), Loc(Loc) {
: Operation(Op), Label(L), Register(R1), Register2(R2), Loc(Loc) {
assert(Op == OpRegister);
U.RR = {R1, R2};
}

MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, unsigned AS,
SMLoc Loc)
: Label(L), Operation(Op), Loc(Loc) {
: Operation(Op), Label(L), Register(R), Offset(O), AddressSpace(AS),
Loc(Loc) {
assert(Op == OpLLVMDefAspaceCfa);
U.RIA = {R, O, AS};
}

public:
Expand Down Expand Up @@ -668,34 +659,30 @@ class MCCFIInstruction {
MCSymbol *getLabel() const { return Label; }

unsigned getRegister() const {
if (Operation == OpRegister)
return U.RR.Register;
if (Operation == OpLLVMDefAspaceCfa)
return U.RIA.Register;
assert(Operation == OpDefCfa || Operation == OpOffset ||
Operation == OpRestore || Operation == OpUndefined ||
Operation == OpSameValue || Operation == OpDefCfaRegister ||
Operation == OpRelOffset);
return U.RI.Register;
Operation == OpRelOffset || Operation == OpRegister ||
Operation == OpLLVMDefAspaceCfa);
return Register;
}

unsigned getRegister2() const {
assert(Operation == OpRegister);
return U.RR.Register2;
return Register2;
}

unsigned getAddressSpace() const {
assert(Operation == OpLLVMDefAspaceCfa);
return U.RIA.AddressSpace;
return AddressSpace;
}

int getOffset() const {
if (Operation == OpLLVMDefAspaceCfa)
return U.RIA.Offset;
assert(Operation == OpDefCfa || Operation == OpOffset ||
Operation == OpRelOffset || Operation == OpDefCfaOffset ||
Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize);
return U.RI.Offset;
Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize ||
Operation == OpLLVMDefAspaceCfa);
return Offset;
}

StringRef getValues() const {
Expand Down

0 comments on commit fe82af3

Please sign in to comment.