12
12
13
13
#include " X86RegisterBankInfo.h"
14
14
#include " X86InstrInfo.h"
15
+ #include " X86Subtarget.h"
15
16
#include " llvm/CodeGen/MachineRegisterInfo.h"
16
17
#include " llvm/CodeGen/RegisterBank.h"
17
18
#include " llvm/CodeGen/RegisterBankInfo.h"
@@ -59,11 +60,24 @@ X86RegisterBankInfo::getRegBankFromRegClass(const TargetRegisterClass &RC,
59
60
X86::VR512RegClass.hasSubClassEq (&RC))
60
61
return getRegBank (X86::VECRRegBankID);
61
62
63
+ if (X86::RFP80RegClass.hasSubClassEq (&RC) ||
64
+ X86::RFP32RegClass.hasSubClassEq (&RC) ||
65
+ X86::RFP64RegClass.hasSubClassEq (&RC))
66
+ return getRegBank (X86::PSRRegBankID);
67
+
62
68
llvm_unreachable (" Unsupported register kind yet." );
63
69
}
64
70
65
71
X86GenRegisterBankInfo::PartialMappingIdx
66
- X86GenRegisterBankInfo::getPartialMappingIdx (const LLT &Ty, bool isFP) {
72
+ X86GenRegisterBankInfo::getPartialMappingIdx (const MachineInstr &MI,
73
+ const LLT &Ty, bool isFP) {
74
+ const MachineFunction *MF = MI.getMF ();
75
+ const X86Subtarget *ST = &MF->getSubtarget <X86Subtarget>();
76
+ bool HasSSE1 = ST->hasSSE1 ();
77
+ bool HasSSE2 = ST->hasSSE2 ();
78
+ // 80 bits is only generated for X87 floating points.
79
+ if (Ty.getSizeInBits () == 80 )
80
+ isFP = true ;
67
81
if ((Ty.isScalar () && !isFP) || Ty.isPointer ()) {
68
82
switch (Ty.getSizeInBits ()) {
69
83
case 1 :
@@ -84,11 +98,13 @@ X86GenRegisterBankInfo::getPartialMappingIdx(const LLT &Ty, bool isFP) {
84
98
} else if (Ty.isScalar ()) {
85
99
switch (Ty.getSizeInBits ()) {
86
100
case 32 :
87
- return PMI_FP32;
101
+ return HasSSE1 ? PMI_FP32 : PMI_PSR32 ;
88
102
case 64 :
89
- return PMI_FP64;
103
+ return HasSSE2 ? PMI_FP64 : PMI_PSR64 ;
90
104
case 128 :
91
105
return PMI_VEC128;
106
+ case 80 :
107
+ return PMI_PSR80;
92
108
default :
93
109
llvm_unreachable (" Unsupported register size." );
94
110
}
@@ -118,7 +134,8 @@ void X86RegisterBankInfo::getInstrPartialMappingIdxs(
118
134
if (!MO.isReg () || !MO.getReg ())
119
135
OpRegBankIdx[Idx] = PMI_None;
120
136
else
121
- OpRegBankIdx[Idx] = getPartialMappingIdx (MRI.getType (MO.getReg ()), isFP);
137
+ OpRegBankIdx[Idx] =
138
+ getPartialMappingIdx (MI, MRI.getType (MO.getReg ()), isFP);
122
139
}
123
140
}
124
141
@@ -156,7 +173,7 @@ X86RegisterBankInfo::getSameOperandsMapping(const MachineInstr &MI,
156
173
(Ty != MRI.getType (MI.getOperand (2 ).getReg ())))
157
174
llvm_unreachable (" Unsupported operand mapping yet." );
158
175
159
- auto Mapping = getValueMapping (getPartialMappingIdx (Ty, isFP), 3 );
176
+ auto Mapping = getValueMapping (getPartialMappingIdx (MI, Ty, isFP), 3 );
160
177
return getInstructionMapping (DefaultMappingID, 1 , Mapping, NumOperands);
161
178
}
162
179
@@ -190,9 +207,8 @@ X86RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
190
207
unsigned NumOperands = MI.getNumOperands ();
191
208
LLT Ty = MRI.getType (MI.getOperand (0 ).getReg ());
192
209
193
- auto Mapping = getValueMapping (getPartialMappingIdx (Ty, false ), 3 );
210
+ auto Mapping = getValueMapping (getPartialMappingIdx (MI, Ty, false ), 3 );
194
211
return getInstructionMapping (DefaultMappingID, 1 , Mapping, NumOperands);
195
-
196
212
}
197
213
default :
198
214
break ;
@@ -206,7 +222,7 @@ X86RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
206
222
case TargetOpcode::G_FPTRUNC:
207
223
case TargetOpcode::G_FCONSTANT:
208
224
// Instruction having only floating-point operands (all scalars in VECRReg)
209
- getInstrPartialMappingIdxs (MI, MRI, /* isFP */ true , OpRegBankIdx);
225
+ getInstrPartialMappingIdxs (MI, MRI, /* isFP= */ true , OpRegBankIdx);
210
226
break ;
211
227
case TargetOpcode::G_SITOFP:
212
228
case TargetOpcode::G_FPTOSI: {
@@ -219,8 +235,8 @@ X86RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
219
235
220
236
bool FirstArgIsFP = Opc == TargetOpcode::G_SITOFP;
221
237
bool SecondArgIsFP = Opc == TargetOpcode::G_FPTOSI;
222
- OpRegBankIdx[0 ] = getPartialMappingIdx (Ty0, /* isFP */ FirstArgIsFP);
223
- OpRegBankIdx[1 ] = getPartialMappingIdx (Ty1, /* isFP */ SecondArgIsFP);
238
+ OpRegBankIdx[0 ] = getPartialMappingIdx (MI, Ty0, /* isFP= */ FirstArgIsFP);
239
+ OpRegBankIdx[1 ] = getPartialMappingIdx (MI, Ty1, /* isFP= */ SecondArgIsFP);
224
240
break ;
225
241
}
226
242
case TargetOpcode::G_FCMP: {
@@ -234,7 +250,7 @@ X86RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
234
250
(void )Size;
235
251
assert ((Size == 32 || Size == 64 ) && " Unsupported size for G_FCMP" );
236
252
237
- auto FpRegBank = getPartialMappingIdx (Ty1, /* isFP */ true );
253
+ auto FpRegBank = getPartialMappingIdx (MI, Ty1, /* isFP= */ true );
238
254
OpRegBankIdx = {PMI_GPR8,
239
255
/* Predicate */ PMI_None, FpRegBank, FpRegBank};
240
256
break ;
@@ -253,12 +269,12 @@ X86RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
253
269
(Ty1.getSizeInBits () == 32 || Ty1.getSizeInBits () == 64 ) &&
254
270
Opc == TargetOpcode::G_ANYEXT;
255
271
256
- getInstrPartialMappingIdxs (MI, MRI, /* isFP */ isFPTrunc || isFPAnyExt,
272
+ getInstrPartialMappingIdxs (MI, MRI, /* isFP= */ isFPTrunc || isFPAnyExt,
257
273
OpRegBankIdx);
258
274
} break ;
259
275
default :
260
276
// Track the bank of each register, use NotFP mapping (all scalars in GPRs)
261
- getInstrPartialMappingIdxs (MI, MRI, /* isFP */ false , OpRegBankIdx);
277
+ getInstrPartialMappingIdxs (MI, MRI, /* isFP= */ false , OpRegBankIdx);
262
278
break ;
263
279
}
264
280
@@ -288,16 +304,16 @@ X86RegisterBankInfo::getInstrAlternativeMappings(const MachineInstr &MI) const {
288
304
case TargetOpcode::G_LOAD:
289
305
case TargetOpcode::G_STORE:
290
306
case TargetOpcode::G_IMPLICIT_DEF: {
291
- // we going to try to map 32/64 bit to PMI_FP32/PMI_FP64
307
+ // we going to try to map 32/64/80 bit to PMI_FP32/PMI_FP64/PMI_FP80
292
308
unsigned Size = getSizeInBits (MI.getOperand (0 ).getReg (), MRI, TRI);
293
- if (Size != 32 && Size != 64 )
309
+ if (Size != 32 && Size != 64 && Size != 80 )
294
310
break ;
295
311
296
312
unsigned NumOperands = MI.getNumOperands ();
297
313
298
314
// Track the bank of each register, use FP mapping (all scalars in VEC)
299
315
SmallVector<PartialMappingIdx, 4 > OpRegBankIdx (NumOperands);
300
- getInstrPartialMappingIdxs (MI, MRI, /* isFP */ true , OpRegBankIdx);
316
+ getInstrPartialMappingIdxs (MI, MRI, /* isFP= */ true , OpRegBankIdx);
301
317
302
318
// Finally construct the computed mapping.
303
319
SmallVector<const ValueMapping *, 8 > OpdsMapping (NumOperands);
0 commit comments