Skip to content
Merged
Changes from all commits
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
26 changes: 15 additions & 11 deletions clang/utils/TableGen/RISCVVEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ static VectorTypeModifier getTupleVTM(unsigned NF) {
static_cast<uint8_t>(VectorTypeModifier::Tuple2) + (NF - 2));
}

static const unsigned UnknownIndex = (unsigned)-1;

static unsigned getIndexedLoadStorePtrIdx(const RVVIntrinsic *RVVI) {
// We need a special rule for segment load/store since the data width is not
// encoded in the intrinsic name itself.
Expand All @@ -183,7 +185,7 @@ static unsigned getIndexedLoadStorePtrIdx(const RVVIntrinsic *RVVI) {
if (IRName.starts_with("vsoxseg") || IRName.starts_with("vsuxseg"))
return RVVI->isMasked() ? 1 : 0;

return (unsigned)-1;
return UnknownIndex;
}

// This function is used to get the log2SEW of each segment load/store, this
Expand Down Expand Up @@ -249,19 +251,21 @@ void emitCodeGenSwitchBody(const RVVIntrinsic *RVVI, raw_ostream &OS) {
OS << " ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";

OS << " PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
OS << " SegInstSEW = " << getSegInstLog2SEW(RVVI->getOverloadedName())
<< ";\n";
unsigned IndexedLoadStorePtrIdx = getIndexedLoadStorePtrIdx(RVVI);
if (IndexedLoadStorePtrIdx != UnknownIndex) {
OS << " {\n";
OS << " auto PointeeType = E->getArg(" << IndexedLoadStorePtrIdx
<< ")->getType()->getPointeeType();\n";
OS << " SegInstSEW = "
"llvm::Log2_64(getContext().getTypeSize(PointeeType));\n";
OS << " }\n";
} else {
OS << " SegInstSEW = " << getSegInstLog2SEW(RVVI->getOverloadedName())
<< ";\n";
}

if (RVVI->hasManualCodegen()) {
OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";

// Skip the non-indexed load/store and compatible header load/store.
OS << "if (SegInstSEW == (unsigned)-1) {\n";
OS << " auto PointeeType = E->getArg(" << getIndexedLoadStorePtrIdx(RVVI)
<< " )->getType()->getPointeeType();\n";
OS << " SegInstSEW = "
" llvm::Log2_64(getContext().getTypeSize(PointeeType));\n}\n";

OS << RVVI->getManualCodegen();
OS << "break;\n";
return;
Expand Down
Loading