Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/include/llvm/CodeGen/ValueTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class VTVecTup<int size, int nf, ValueType dummy_elt, int value>
let NF = nf;
let ElementType = dummy_elt;
let isRISCVVecTuple = true;
let isScalable = true;
}

defset list<ValueType> ValueTypes = {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/ValueTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ std::string EVT::getEVTString() const {
switch (V.SimpleTy) {
default:
if (isRISCVVectorTuple()) {
unsigned Sz = getSizeInBits();
unsigned Sz = getSizeInBits().getKnownMinValue();
unsigned NF = getRISCVVectorTupleNumFields();
unsigned MinNumElts = Sz / (NF * 8);
return "riscv_nxv" + utostr(MinNumElts) + "i8x" + utostr(NF);
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/CodeGenTypes/LowLevelType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ LLT::LLT(MVT VT) {
init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector,
VT.getVectorElementCount(), VT.getVectorElementType().getSizeInBits(),
/*AddressSpace=*/0);
} else if (VT.isRISCVVectorTuple()) {
// TODO: Correctly model RISC-V vector tuple type
init(/*IsPointer=*/false, /*IsVector=*/false, /*IsScalar=*/true,
ElementCount::getFixed(0), VT.getSizeInBits().getKnownMinValue(),
/*AddressSpace=*/0);
} else if (VT.isValid() && !VT.isScalableTargetExtVT()) {
// Aggregates are no different from real scalars as far as GlobalISel is
// concerned.
Expand Down
47 changes: 27 additions & 20 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2416,8 +2416,9 @@ unsigned RISCVTargetLowering::getSubregIndexByMVT(MVT VT, unsigned Index) {
unsigned RISCVTargetLowering::getRegClassIDForVecVT(MVT VT) {
if (VT.isRISCVVectorTuple()) {
unsigned NF = VT.getRISCVVectorTupleNumFields();
unsigned RegsPerField = std::max(1U, (unsigned)VT.getSizeInBits() /
(NF * RISCV::RVVBitsPerBlock));
unsigned RegsPerField =
std::max(1U, (unsigned)VT.getSizeInBits().getKnownMinValue() /
(NF * RISCV::RVVBitsPerBlock));
switch (RegsPerField) {
case 1:
if (NF == 2)
Expand Down Expand Up @@ -7006,7 +7007,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
SDLoc DL(Op);
MVT XLenVT = Subtarget.getXLenVT();
unsigned NF = VecTy.getRISCVVectorTupleNumFields();
unsigned Sz = VecTy.getSizeInBits();
unsigned Sz = VecTy.getSizeInBits().getKnownMinValue();
unsigned NumElts = Sz / (NF * 8);
int Log2LMUL = Log2_64(NumElts) - 3;

Expand Down Expand Up @@ -7049,7 +7050,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
SDLoc DL(Op);
MVT XLenVT = Subtarget.getXLenVT();
unsigned NF = VecTy.getRISCVVectorTupleNumFields();
unsigned Sz = VecTy.getSizeInBits();
unsigned Sz = VecTy.getSizeInBits().getKnownMinValue();
unsigned NumElts = Sz / (NF * 8);
int Log2LMUL = Log2_64(NumElts) - 3;

Expand Down Expand Up @@ -21309,6 +21310,25 @@ bool RISCVTargetLowering::splitValueIntoRegisterParts(
return true;
}

if (ValueVT.isRISCVVectorTuple() && PartVT.isRISCVVectorTuple()) {
unsigned ValNF = ValueVT.getRISCVVectorTupleNumFields();
[[maybe_unused]] unsigned ValLMUL =
divideCeil(ValueVT.getSizeInBits().getKnownMinValue(),
ValNF * RISCV::RVVBitsPerBlock);
unsigned PartNF = PartVT.getRISCVVectorTupleNumFields();
[[maybe_unused]] unsigned PartLMUL =
divideCeil(PartVT.getSizeInBits().getKnownMinValue(),
PartNF * RISCV::RVVBitsPerBlock);
assert(ValNF == PartNF && ValLMUL == PartLMUL &&
"RISC-V vector tuple type only accepts same register class type "
"TUPLE_INSERT");

Val = DAG.getNode(RISCVISD::TUPLE_INSERT, DL, PartVT, DAG.getUNDEF(PartVT),
Val, DAG.getVectorIdxConstant(0, DL));
Parts[0] = Val;
return true;
}

if (ValueVT.isScalableVector() && PartVT.isScalableVector()) {
LLVMContext &Context = *DAG.getContext();
EVT ValueEltVT = ValueVT.getVectorElementType();
Expand Down Expand Up @@ -21344,22 +21364,6 @@ bool RISCVTargetLowering::splitValueIntoRegisterParts(
}
}

if (ValueVT.isRISCVVectorTuple() && PartVT.isRISCVVectorTuple()) {
unsigned ValNF = ValueVT.getRISCVVectorTupleNumFields();
[[maybe_unused]] unsigned ValLMUL =
divideCeil(ValueVT.getSizeInBits(), ValNF * RISCV::RVVBitsPerBlock);
unsigned PartNF = PartVT.getRISCVVectorTupleNumFields();
[[maybe_unused]] unsigned PartLMUL =
divideCeil(PartVT.getSizeInBits(), PartNF * RISCV::RVVBitsPerBlock);
assert(ValNF == PartNF && ValLMUL == PartLMUL &&
"RISC-V vector tuple type only accepts same register class type "
"TUPLE_INSERT");

Val = DAG.getNode(RISCVISD::TUPLE_INSERT, DL, PartVT, DAG.getUNDEF(PartVT),
Val, DAG.getVectorIdxConstant(0, DL));
Parts[0] = Val;
return true;
}
return false;
}

Expand All @@ -21378,6 +21382,9 @@ SDValue RISCVTargetLowering::joinRegisterPartsIntoValue(
return Val;
}

if (ValueVT.isRISCVVectorTuple())
return SDValue();

if (ValueVT.isScalableVector() && PartVT.isScalableVector()) {
LLVMContext &Context = *DAG.getContext();
SDValue Val = Parts[0];
Expand Down
Loading