Skip to content

Commit 78a8878

Browse files
committed
Revert "[RISCV][GISel] Disable call lowering for integers larger than 2*XLen. (#69144)"
This reverts commit 3a4b0e9. Seems to be failing on the build bots.
1 parent 9189822 commit 78a8878

File tree

1 file changed

+18
-48
lines changed

1 file changed

+18
-48
lines changed

llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp

+18-48
Original file line numberDiff line numberDiff line change
@@ -193,52 +193,15 @@ struct RISCVCallReturnHandler : public RISCVIncomingValueHandler {
193193
RISCVCallLowering::RISCVCallLowering(const RISCVTargetLowering &TLI)
194194
: CallLowering(&TLI) {}
195195

196-
// TODO: Support all argument types.
197-
static bool isSupportedArgumentType(Type *T, const RISCVSubtarget &Subtarget) {
198-
// TODO: Integers larger than 2*XLen are passed indirectly which is not
199-
// supported yet.
200-
if (T->isIntegerTy())
201-
return T->getIntegerBitWidth() <= Subtarget.getXLen() * 2;
202-
if (T->isPointerTy())
203-
return true;
204-
return false;
205-
}
206-
207-
// TODO: Only integer, pointer and aggregate types are supported now.
208-
static bool isSupportedReturnType(Type *T, const RISCVSubtarget &Subtarget) {
209-
// TODO: Integers larger than 2*XLen are passed indirectly which is not
210-
// supported yet.
211-
if (T->isIntegerTy())
212-
return T->getIntegerBitWidth() <= Subtarget.getXLen() * 2;
213-
if (T->isPointerTy())
214-
return true;
215-
216-
if (T->isArrayTy())
217-
return isSupportedReturnType(T->getArrayElementType(), Subtarget);
218-
219-
if (T->isStructTy()) {
220-
// For now we only allow homogeneous structs that we can manipulate with
221-
// G_MERGE_VALUES and G_UNMERGE_VALUES
222-
auto StructT = cast<StructType>(T);
223-
for (unsigned i = 1, e = StructT->getNumElements(); i != e; ++i)
224-
if (StructT->getElementType(i) != StructT->getElementType(0))
225-
return false;
226-
return isSupportedReturnType(StructT->getElementType(0), Subtarget);
227-
}
228-
229-
return false;
230-
}
231-
232196
bool RISCVCallLowering::lowerReturnVal(MachineIRBuilder &MIRBuilder,
233197
const Value *Val,
234198
ArrayRef<Register> VRegs,
235199
MachineInstrBuilder &Ret) const {
236200
if (!Val)
237201
return true;
238202

239-
const RISCVSubtarget &Subtarget =
240-
MIRBuilder.getMF().getSubtarget<RISCVSubtarget>();
241-
if (!isSupportedReturnType(Val->getType(), Subtarget))
203+
// TODO: Only integer, pointer and aggregate types are supported now.
204+
if (!Val->getType()->isIntOrPtrTy() && !Val->getType()->isAggregateType())
242205
return false;
243206

244207
MachineFunction &MF = MIRBuilder.getMF();
@@ -285,11 +248,13 @@ bool RISCVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
285248
if (F.isVarArg())
286249
return false;
287250

288-
const RISCVSubtarget &Subtarget =
289-
MIRBuilder.getMF().getSubtarget<RISCVSubtarget>();
251+
// TODO: Support all argument types.
290252
for (auto &Arg : F.args()) {
291-
if (!isSupportedArgumentType(Arg.getType(), Subtarget))
292-
return false;
253+
if (Arg.getType()->isIntegerTy())
254+
continue;
255+
if (Arg.getType()->isPointerTy())
256+
continue;
257+
return false;
293258
}
294259

295260
MachineFunction &MF = MIRBuilder.getMF();
@@ -327,11 +292,15 @@ bool RISCVCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
327292
const Function &F = MF.getFunction();
328293
CallingConv::ID CC = F.getCallingConv();
329294

330-
const RISCVSubtarget &Subtarget =
331-
MIRBuilder.getMF().getSubtarget<RISCVSubtarget>();
295+
// TODO: Support all argument types.
332296
for (auto &AInfo : Info.OrigArgs) {
333-
if (!isSupportedArgumentType(AInfo.Ty, Subtarget))
334-
return false;
297+
if (AInfo.Ty->isIntegerTy())
298+
continue;
299+
if (AInfo.Ty->isPointerTy())
300+
continue;
301+
if (AInfo.Ty->isFloatingPointTy())
302+
continue;
303+
return false;
335304
}
336305

337306
SmallVector<ArgInfo, 32> SplitArgInfos;
@@ -368,7 +337,8 @@ bool RISCVCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
368337
if (Info.OrigRet.Ty->isVoidTy())
369338
return true;
370339

371-
if (!isSupportedReturnType(Info.OrigRet.Ty, Subtarget))
340+
// TODO: Only integer, pointer and aggregate types are supported now.
341+
if (!Info.OrigRet.Ty->isIntOrPtrTy() && !Info.OrigRet.Ty->isAggregateType())
372342
return false;
373343

374344
SmallVector<ArgInfo, 4> SplitRetInfos;

0 commit comments

Comments
 (0)