@@ -83,55 +83,23 @@ using namespace llvm;
83
83
namespace {
84
84
85
85
// All possible address modes, plus some.
86
- class Address {
87
- public:
88
- using BaseKind = enum {
86
+ struct Address {
87
+ enum {
89
88
RegBase,
90
89
FrameIndexBase
91
- };
90
+ } BaseType = RegBase ;
92
91
93
- private:
94
- BaseKind Kind = RegBase;
95
92
union {
96
93
unsigned Reg;
97
94
int FI;
98
95
} Base;
99
96
100
97
int Offset = 0 ;
101
98
102
- public:
103
99
// Innocuous defaults for our address.
104
100
Address () {
105
101
Base.Reg = 0 ;
106
102
}
107
-
108
- void setKind (BaseKind K) { Kind = K; }
109
- BaseKind getKind () const { return Kind; }
110
- bool isRegBase () const { return Kind == RegBase; }
111
- bool isFIBase () const { return Kind == FrameIndexBase; }
112
-
113
- void setReg (Register Reg) {
114
- assert (isRegBase () && " Invalid base register access!" );
115
- Base.Reg = Reg.id ();
116
- }
117
-
118
- Register getReg () const {
119
- assert (isRegBase () && " Invalid base register access!" );
120
- return Base.Reg ;
121
- }
122
-
123
- void setFI (int FI) {
124
- assert (isFIBase () && " Invalid base frame index access!" );
125
- Base.FI = FI;
126
- }
127
-
128
- int getFI () const {
129
- assert (isFIBase () && " Invalid base frame index access!" );
130
- return Base.FI ;
131
- }
132
-
133
- void setOffset (int O) { Offset = O; }
134
- int getOffset () { return Offset; }
135
103
};
136
104
137
105
class ARMFastISel final : public FastISel {
@@ -770,7 +738,7 @@ bool ARMFastISel::ARMComputeAddress(const Value *Obj, Address &Addr) {
770
738
break ;
771
739
case Instruction::GetElementPtr: {
772
740
Address SavedAddr = Addr;
773
- int TmpOffset = Addr.getOffset () ;
741
+ int TmpOffset = Addr.Offset ;
774
742
775
743
// Iterate through the GEP folding the constants into offsets where
776
744
// we can.
@@ -806,7 +774,7 @@ bool ARMFastISel::ARMComputeAddress(const Value *Obj, Address &Addr) {
806
774
}
807
775
808
776
// Try to grab the base operand now.
809
- Addr.setOffset ( TmpOffset) ;
777
+ Addr.Offset = TmpOffset;
810
778
if (ARMComputeAddress (U->getOperand (0 ), Addr)) return true ;
811
779
812
780
// We failed, restore everything and try the other options.
@@ -820,17 +788,17 @@ bool ARMFastISel::ARMComputeAddress(const Value *Obj, Address &Addr) {
820
788
DenseMap<const AllocaInst*, int >::iterator SI =
821
789
FuncInfo.StaticAllocaMap .find (AI);
822
790
if (SI != FuncInfo.StaticAllocaMap .end ()) {
823
- Addr.setKind ( Address::FrameIndexBase) ;
824
- Addr.setFI ( SI->second ) ;
791
+ Addr.BaseType = Address::FrameIndexBase;
792
+ Addr.Base . FI = SI->second ;
825
793
return true ;
826
794
}
827
795
break ;
828
796
}
829
797
}
830
798
831
799
// Try to get this in a register if nothing else has worked.
832
- if (! Addr.getReg ()) Addr.setReg ( getRegForValue (Obj) );
833
- return Addr.getReg () ;
800
+ if (Addr.Base . Reg == 0 ) Addr.Base . Reg = getRegForValue (Obj);
801
+ return Addr.Base . Reg != 0 ;
834
802
}
835
803
836
804
void ARMFastISel::ARMSimplifyAddress (Address &Addr, MVT VT, bool useAM3) {
@@ -843,45 +811,45 @@ void ARMFastISel::ARMSimplifyAddress(Address &Addr, MVT VT, bool useAM3) {
843
811
case MVT::i32:
844
812
if (!useAM3) {
845
813
// Integer loads/stores handle 12-bit offsets.
846
- needsLowering = ((Addr.getOffset () & 0xfff ) != Addr.getOffset () );
814
+ needsLowering = ((Addr.Offset & 0xfff ) != Addr.Offset );
847
815
// Handle negative offsets.
848
816
if (needsLowering && isThumb2)
849
- needsLowering = !(Subtarget->hasV6T2Ops () && Addr.getOffset () < 0 &&
850
- Addr.getOffset () > -256 );
817
+ needsLowering = !(Subtarget->hasV6T2Ops () && Addr.Offset < 0 &&
818
+ Addr.Offset > -256 );
851
819
} else {
852
820
// ARM halfword load/stores and signed byte loads use +/-imm8 offsets.
853
- needsLowering = (Addr.getOffset () > 255 || Addr.getOffset () < -255 );
821
+ needsLowering = (Addr.Offset > 255 || Addr.Offset < -255 );
854
822
}
855
823
break ;
856
824
case MVT::f32:
857
825
case MVT::f64:
858
826
// Floating point operands handle 8-bit offsets.
859
- needsLowering = ((Addr.getOffset () & 0xff ) != Addr.getOffset () );
827
+ needsLowering = ((Addr.Offset & 0xff ) != Addr.Offset );
860
828
break ;
861
829
}
862
830
863
831
// If this is a stack pointer and the offset needs to be simplified then
864
832
// put the alloca address into a register, set the base type back to
865
833
// register and continue. This should almost never happen.
866
- if (needsLowering && Addr.isFIBase () ) {
834
+ if (needsLowering && Addr.BaseType == Address::FrameIndexBase ) {
867
835
const TargetRegisterClass *RC = isThumb2 ? &ARM::tGPRRegClass
868
836
: &ARM::GPRRegClass;
869
837
Register ResultReg = createResultReg (RC);
870
838
unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
871
839
AddOptionalDefs (BuildMI (*FuncInfo.MBB , FuncInfo.InsertPt , MIMD,
872
840
TII.get (Opc), ResultReg)
873
- .addFrameIndex (Addr.getFI () )
841
+ .addFrameIndex (Addr.Base . FI )
874
842
.addImm (0 ));
875
- Addr.setKind (Address::RegBase) ;
876
- Addr.setReg (ResultReg) ;
843
+ Addr.Base . Reg = ResultReg ;
844
+ Addr.BaseType = Address::RegBase ;
877
845
}
878
846
879
847
// Since the offset is too large for the load/store instruction
880
848
// get the reg+offset into a register.
881
849
if (needsLowering) {
882
- Addr.setReg ( fastEmit_ri_ (MVT::i32, ISD::ADD, Addr.getReg () ,
883
- Addr.getOffset () , MVT::i32) );
884
- Addr.setOffset ( 0 ) ;
850
+ Addr.Base . Reg = fastEmit_ri_ (MVT::i32, ISD::ADD, Addr.Base . Reg ,
851
+ Addr.Offset , MVT::i32);
852
+ Addr.Offset = 0 ;
885
853
}
886
854
}
887
855
@@ -892,12 +860,12 @@ void ARMFastISel::AddLoadStoreOperands(MVT VT, Address &Addr,
892
860
// addrmode5 output depends on the selection dag addressing dividing the
893
861
// offset by 4 that it then later multiplies. Do this here as well.
894
862
if (VT.SimpleTy == MVT::f32 || VT.SimpleTy == MVT::f64)
895
- Addr.setOffset (Addr. getOffset () / 4 ) ;
863
+ Addr.Offset /= 4 ;
896
864
897
865
// Frame base works a bit differently. Handle it separately.
898
- if (Addr.isFIBase () ) {
899
- int FI = Addr.getFI () ;
900
- int Offset = Addr.getOffset () ;
866
+ if (Addr.BaseType == Address::FrameIndexBase ) {
867
+ int FI = Addr.Base . FI ;
868
+ int Offset = Addr.Offset ;
901
869
MachineMemOperand *MMO = FuncInfo.MF ->getMachineMemOperand (
902
870
MachinePointerInfo::getFixedStack (*FuncInfo.MF , FI, Offset), Flags,
903
871
MFI.getObjectSize (FI), MFI.getObjectAlign (FI));
@@ -907,25 +875,25 @@ void ARMFastISel::AddLoadStoreOperands(MVT VT, Address &Addr,
907
875
// ARM halfword load/stores and signed byte loads need an additional
908
876
// operand.
909
877
if (useAM3) {
910
- int Imm = (Addr.getOffset () < 0 ) ? (0x100 | -Addr.getOffset ()) : Addr.getOffset () ;
878
+ int Imm = (Addr.Offset < 0 ) ? (0x100 | -Addr.Offset ) : Addr.Offset ;
911
879
MIB.addReg (0 );
912
880
MIB.addImm (Imm);
913
881
} else {
914
- MIB.addImm (Addr.getOffset () );
882
+ MIB.addImm (Addr.Offset );
915
883
}
916
884
MIB.addMemOperand (MMO);
917
885
} else {
918
886
// Now add the rest of the operands.
919
- MIB.addReg (Addr.getReg () );
887
+ MIB.addReg (Addr.Base . Reg );
920
888
921
889
// ARM halfword load/stores and signed byte loads need an additional
922
890
// operand.
923
891
if (useAM3) {
924
- int Imm = (Addr.getOffset () < 0 ) ? (0x100 | -Addr.getOffset ()) : Addr.getOffset () ;
892
+ int Imm = (Addr.Offset < 0 ) ? (0x100 | -Addr.Offset ) : Addr.Offset ;
925
893
MIB.addReg (0 );
926
894
MIB.addImm (Imm);
927
895
} else {
928
- MIB.addImm (Addr.getOffset () );
896
+ MIB.addImm (Addr.Offset );
929
897
}
930
898
}
931
899
AddOptionalDefs (MIB);
@@ -944,7 +912,7 @@ bool ARMFastISel::ARMEmitLoad(MVT VT, Register &ResultReg, Address &Addr,
944
912
case MVT::i1:
945
913
case MVT::i8:
946
914
if (isThumb2) {
947
- if (Addr.getOffset () < 0 && Addr.getOffset () > -256 && Subtarget->hasV6T2Ops ())
915
+ if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops ())
948
916
Opc = isZExt ? ARM::t2LDRBi8 : ARM::t2LDRSBi8;
949
917
else
950
918
Opc = isZExt ? ARM::t2LDRBi12 : ARM::t2LDRSBi12;
@@ -964,7 +932,7 @@ bool ARMFastISel::ARMEmitLoad(MVT VT, Register &ResultReg, Address &Addr,
964
932
return false ;
965
933
966
934
if (isThumb2) {
967
- if (Addr.getOffset () < 0 && Addr.getOffset () > -256 && Subtarget->hasV6T2Ops ())
935
+ if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops ())
968
936
Opc = isZExt ? ARM::t2LDRHi8 : ARM::t2LDRSHi8;
969
937
else
970
938
Opc = isZExt ? ARM::t2LDRHi12 : ARM::t2LDRSHi12;
@@ -980,7 +948,7 @@ bool ARMFastISel::ARMEmitLoad(MVT VT, Register &ResultReg, Address &Addr,
980
948
return false ;
981
949
982
950
if (isThumb2) {
983
- if (Addr.getOffset () < 0 && Addr.getOffset () > -256 && Subtarget->hasV6T2Ops ())
951
+ if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops ())
984
952
Opc = ARM::t2LDRi8;
985
953
else
986
954
Opc = ARM::t2LDRi12;
@@ -1093,7 +1061,7 @@ bool ARMFastISel::ARMEmitStore(MVT VT, Register SrcReg, Address &Addr,
1093
1061
}
1094
1062
case MVT::i8:
1095
1063
if (isThumb2) {
1096
- if (Addr.getOffset () < 0 && Addr.getOffset () > -256 && Subtarget->hasV6T2Ops ())
1064
+ if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops ())
1097
1065
StrOpc = ARM::t2STRBi8;
1098
1066
else
1099
1067
StrOpc = ARM::t2STRBi12;
@@ -1107,7 +1075,7 @@ bool ARMFastISel::ARMEmitStore(MVT VT, Register SrcReg, Address &Addr,
1107
1075
return false ;
1108
1076
1109
1077
if (isThumb2) {
1110
- if (Addr.getOffset () < 0 && Addr.getOffset () > -256 && Subtarget->hasV6T2Ops ())
1078
+ if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops ())
1111
1079
StrOpc = ARM::t2STRHi8;
1112
1080
else
1113
1081
StrOpc = ARM::t2STRHi12;
@@ -1122,7 +1090,7 @@ bool ARMFastISel::ARMEmitStore(MVT VT, Register SrcReg, Address &Addr,
1122
1090
return false ;
1123
1091
1124
1092
if (isThumb2) {
1125
- if (Addr.getOffset () < 0 && Addr.getOffset () > -256 && Subtarget->hasV6T2Ops ())
1093
+ if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops ())
1126
1094
StrOpc = ARM::t2STRi8;
1127
1095
else
1128
1096
StrOpc = ARM::t2STRi12;
@@ -2063,9 +2031,9 @@ bool ARMFastISel::ProcessCallArgs(SmallVectorImpl<Value*> &Args,
2063
2031
continue ;
2064
2032
2065
2033
Address Addr;
2066
- Addr.setKind ( Address::RegBase) ;
2067
- Addr.setReg ( ARM::SP) ;
2068
- Addr.setOffset ( VA.getLocMemOffset () );
2034
+ Addr.BaseType = Address::RegBase;
2035
+ Addr.Base . Reg = ARM::SP;
2036
+ Addr.Offset = VA.getLocMemOffset ();
2069
2037
2070
2038
bool EmitRet = ARMEmitStore (ArgVT, Arg, Addr); (void )EmitRet;
2071
2039
assert (EmitRet && " Could not emit a store for argument!" );
@@ -2538,8 +2506,8 @@ bool ARMFastISel::ARMTryEmitSmallMemCpy(Address Dest, Address Src, uint64_t Len,
2538
2506
2539
2507
unsigned Size = VT.getSizeInBits ()/8 ;
2540
2508
Len -= Size ;
2541
- Dest.setOffset (Dest. getOffset () + Size ) ;
2542
- Src.setOffset (Src. getOffset () + Size ) ;
2509
+ Dest.Offset += Size ;
2510
+ Src.Offset += Size ;
2543
2511
}
2544
2512
2545
2513
return true ;
0 commit comments