@@ -483,7 +483,7 @@ class MCGenDwarfLabelEntry {
483
483
484
484
class MCCFIInstruction {
485
485
public:
486
- enum OpType {
486
+ enum OpType : uint8_t {
487
487
OpSameValue,
488
488
OpRememberState,
489
489
OpRestoreState,
@@ -504,35 +504,44 @@ class MCCFIInstruction {
504
504
};
505
505
506
506
private:
507
- OpType Operation;
508
507
MCSymbol *Label;
509
- unsigned Register;
510
508
union {
511
- int Offset;
512
- unsigned Register2;
513
- };
514
- unsigned AddressSpace = ~0u ;
509
+ struct {
510
+ unsigned Register;
511
+ int Offset;
512
+ } RI;
513
+ struct {
514
+ unsigned Register;
515
+ int Offset;
516
+ unsigned AddressSpace;
517
+ } RIA;
518
+ struct {
519
+ unsigned Register;
520
+ unsigned Register2;
521
+ } RR;
522
+ } U;
523
+ OpType Operation;
515
524
SMLoc Loc;
516
525
std::vector<char > Values;
517
526
std::string Comment;
518
527
519
528
MCCFIInstruction (OpType Op, MCSymbol *L, unsigned R, int O, SMLoc Loc,
520
529
StringRef V = " " , StringRef Comment = " " )
521
- : Operation(Op ), Label(L ), Register(R ), Offset(O ), Loc(Loc ),
522
- Values (V.begin(), V.end()), Comment(Comment) {
530
+ : Label(L ), Operation(Op ), Loc(Loc ), Values(V.begin( ), V.end() ),
531
+ Comment (Comment) {
523
532
assert (Op != OpRegister && Op != OpLLVMDefAspaceCfa);
533
+ U.RI = {R, O};
524
534
}
525
-
526
535
MCCFIInstruction (OpType Op, MCSymbol *L, unsigned R1, unsigned R2, SMLoc Loc)
527
- : Operation(Op), Label(L), Register(R1), Register2(R2 ), Loc(Loc) {
536
+ : Label(L), Operation(Op ), Loc(Loc) {
528
537
assert (Op == OpRegister);
538
+ U.RR = {R1, R2};
529
539
}
530
-
531
540
MCCFIInstruction (OpType Op, MCSymbol *L, unsigned R, int O, unsigned AS,
532
541
SMLoc Loc)
533
- : Operation(Op), Label(L), Register(R), Offset(O), AddressSpace(AS),
534
- Loc(Loc) {
542
+ : Label(L), Operation(Op), Loc(Loc) {
535
543
assert (Op == OpLLVMDefAspaceCfa);
544
+ U.RIA = {R, O, AS};
536
545
}
537
546
538
547
public:
@@ -659,30 +668,34 @@ class MCCFIInstruction {
659
668
MCSymbol *getLabel () const { return Label; }
660
669
661
670
unsigned getRegister () const {
671
+ if (Operation == OpRegister)
672
+ return U.RR .Register ;
673
+ if (Operation == OpLLVMDefAspaceCfa)
674
+ return U.RIA .Register ;
662
675
assert (Operation == OpDefCfa || Operation == OpOffset ||
663
676
Operation == OpRestore || Operation == OpUndefined ||
664
677
Operation == OpSameValue || Operation == OpDefCfaRegister ||
665
- Operation == OpRelOffset || Operation == OpRegister ||
666
- Operation == OpLLVMDefAspaceCfa);
667
- return Register;
678
+ Operation == OpRelOffset);
679
+ return U.RI .Register ;
668
680
}
669
681
670
682
unsigned getRegister2 () const {
671
683
assert (Operation == OpRegister);
672
- return Register2;
684
+ return U. RR . Register2 ;
673
685
}
674
686
675
687
unsigned getAddressSpace () const {
676
688
assert (Operation == OpLLVMDefAspaceCfa);
677
- return AddressSpace;
689
+ return U. RIA . AddressSpace ;
678
690
}
679
691
680
692
int getOffset () const {
693
+ if (Operation == OpLLVMDefAspaceCfa)
694
+ return U.RIA .Offset ;
681
695
assert (Operation == OpDefCfa || Operation == OpOffset ||
682
696
Operation == OpRelOffset || Operation == OpDefCfaOffset ||
683
- Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize ||
684
- Operation == OpLLVMDefAspaceCfa);
685
- return Offset;
697
+ Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize);
698
+ return U.RI .Offset ;
686
699
}
687
700
688
701
StringRef getValues () const {
0 commit comments