Skip to content

Commit d413727

Browse files
[RISCV][GISEL] Add support for lowerFormalArguments that contain scalable vector types
Scalable vector types from LLVM IR can be lowered to scalable vector types in MIR according to the RISCV::CC_RISCV function.
1 parent 664f084 commit d413727

File tree

3 files changed

+701
-1
lines changed

3 files changed

+701
-1
lines changed

llvm/lib/CodeGen/LowLevelType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using namespace llvm;
1717

1818
LLT::LLT(MVT VT) {
1919
if (VT.isVector()) {
20-
bool asVector = VT.getVectorMinNumElements() > 1;
20+
bool asVector = VT.getVectorMinNumElements() > 1 || VT.isScalableVector();
2121
init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector,
2222
VT.getVectorElementCount(), VT.getVectorElementType().getSizeInBits(),
2323
/*AddressSpace=*/0);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "RISCVCallLowering.h"
1616
#include "RISCVISelLowering.h"
17+
#include "RISCVMachineFunctionInfo.h"
1718
#include "RISCVSubtarget.h"
1819
#include "llvm/CodeGen/Analysis.h"
1920
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
@@ -181,6 +182,9 @@ struct RISCVIncomingValueAssigner : public CallLowering::IncomingValueAssigner {
181182
const DataLayout &DL = MF.getDataLayout();
182183
const RISCVSubtarget &Subtarget = MF.getSubtarget<RISCVSubtarget>();
183184

185+
if (LocVT.isScalableVector())
186+
MF.getInfo<RISCVMachineFunctionInfo>()->setIsVectorCall();
187+
184188
return RISCVAssignFn(DL, Subtarget.getTargetABI(), ValNo, ValVT, LocVT,
185189
LocInfo, Flags, State, /*IsFixed=*/true, IsRet,
186190
Info.Ty, *Subtarget.getTargetLowering(),
@@ -303,6 +307,9 @@ static bool isSupportedArgumentType(Type *T, const RISCVSubtarget &Subtarget) {
303307
return true;
304308
if (T->isPointerTy())
305309
return true;
310+
// TODO: Support fixed vector types.
311+
if (T->isVectorTy() && T->isScalableTy() && Subtarget.hasVInstructions())
312+
return true;
306313
return false;
307314
}
308315

0 commit comments

Comments
 (0)