@@ -711,7 +711,8 @@ bool X86FastISel::handleConstantAddresses(const Value *V, X86AddressMode &AM) {
711
711
// Handle constant address.
712
712
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
713
713
// Can't handle alternate code models yet.
714
- if (TM.getCodeModel () != CodeModel::Small)
714
+ if (TM.getCodeModel () != CodeModel::Small &&
715
+ TM.getCodeModel () != CodeModel::Medium)
715
716
return false ;
716
717
717
718
// Can't handle large objects yet.
@@ -1050,7 +1051,8 @@ bool X86FastISel::X86SelectCallAddress(const Value *V, X86AddressMode &AM) {
1050
1051
// Handle constant address.
1051
1052
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
1052
1053
// Can't handle alternate code models yet.
1053
- if (TM.getCodeModel () != CodeModel::Small)
1054
+ if (TM.getCodeModel () != CodeModel::Small &&
1055
+ TM.getCodeModel () != CodeModel::Medium)
1054
1056
return false ;
1055
1057
1056
1058
// RIP-relative addresses can't have additional register operands.
@@ -3774,7 +3776,8 @@ unsigned X86FastISel::X86MaterializeFP(const ConstantFP *CFP, MVT VT) {
3774
3776
3775
3777
// Can't handle alternate code models yet.
3776
3778
CodeModel::Model CM = TM.getCodeModel ();
3777
- if (CM != CodeModel::Small && CM != CodeModel::Large)
3779
+ if (CM != CodeModel::Small && CM != CodeModel::Medium &&
3780
+ CM != CodeModel::Large)
3778
3781
return 0 ;
3779
3782
3780
3783
// Get opcode and regclass of the output for the given load instruction.
@@ -3812,7 +3815,7 @@ unsigned X86FastISel::X86MaterializeFP(const ConstantFP *CFP, MVT VT) {
3812
3815
PICBase = getInstrInfo ()->getGlobalBaseReg (FuncInfo.MF );
3813
3816
else if (OpFlag == X86II::MO_GOTOFF)
3814
3817
PICBase = getInstrInfo ()->getGlobalBaseReg (FuncInfo.MF );
3815
- else if (Subtarget->is64Bit () && TM.getCodeModel () == CodeModel::Small )
3818
+ else if (Subtarget->is64Bit () && TM.getCodeModel () != CodeModel::Large )
3816
3819
PICBase = X86::RIP;
3817
3820
3818
3821
// Create the load from the constant pool.
@@ -3842,8 +3845,11 @@ unsigned X86FastISel::X86MaterializeFP(const ConstantFP *CFP, MVT VT) {
3842
3845
}
3843
3846
3844
3847
unsigned X86FastISel::X86MaterializeGV (const GlobalValue *GV, MVT VT) {
3845
- // Can't handle alternate code models yet.
3846
- if (TM.getCodeModel () != CodeModel::Small)
3848
+ // Can't handle large GlobalValues yet.
3849
+ if (TM.getCodeModel () != CodeModel::Small &&
3850
+ TM.getCodeModel () != CodeModel::Medium)
3851
+ return 0 ;
3852
+ if (!isa<GlobalObject>(GV) || TM.isLargeGlobalObject (cast<GlobalObject>(GV)))
3847
3853
return 0 ;
3848
3854
3849
3855
// Materialize addresses with LEA/MOV instructions.
0 commit comments