Skip to content

Commit

Permalink
[8/11][Clang][RISCV] Expand all variants for indexed strided segment …
Browse files Browse the repository at this point in the history
…load

This is the 8th patch of the patch-set. For the cover letter, please
checkout D152069.

Depends on D152075.

This patch expands all variants of indexed strided segment load,
including the policy variants. This patch also fixes the trailing suffix
in the intrinsics' function name that representing the return type,
adding `x{NF}`.

For the same reason mentioned in [3/11], only full test case for
vluxseg2ei32, vloxseg2ei32 is added for now.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152076
  • Loading branch information
eopXD committed Jun 14, 2023
1 parent 91b90e0 commit 9588b18
Show file tree
Hide file tree
Showing 9 changed files with 14,036 additions and 33 deletions.
41 changes: 22 additions & 19 deletions clang/include/clang/Basic/riscv_vector.td
Original file line number Diff line number Diff line change
Expand Up @@ -1806,29 +1806,35 @@ multiclass RVVStridedSegStoreTuple<string op> {
}

multiclass RVVIndexedSegLoadTuple<string op> {
foreach type = ["i"] in {
foreach eew_info = [["32", "(Log2EEW:5)"]] in {
foreach type = TypeList in {
foreach eew_info = EEWList in {
defvar eew = eew_info[0];
defvar eew_type = eew_info[1];
foreach nf = [2] in {
foreach nf = NFList in {
let Name = op # nf # "ei" # eew # "_v_tuple",
OverloadedName = op # nf # "ei" # eew # "_tuple",
IRName = op # nf,
MaskedIRName = op # nf # "_mask",
NF = nf,
ManualCodegen = [{
{
assert(((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
(!IsMasked && (PolicyAttrs & RVV_VTA))) &&
"FIXME: Only handling default policy (TAMA) for now");

llvm::Type *ElementVectorType = cast<StructType>(ResultType)->elements()[0];

IntrinsicTypes = {ElementVectorType, Ops.back()->getType()};
SmallVector<llvm::Value*, 12> Operands;

Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));
bool NoPassthru =
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
(!IsMasked && (PolicyAttrs & RVV_VTA));
unsigned Offset = IsMasked ? NoPassthru ? 1 : 2 : NoPassthru ? 0 : 1;

if (NoPassthru) { // Push poison into passthru
Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));
} else { // Push intrinsics operands into passthru
llvm::Value *PassthruOperand = IsMasked ? Ops[1] : Ops[0];
for (unsigned I = 0; I < NF; ++I)
Operands.push_back(Builder.CreateExtractValue(PassthruOperand, {I}));
}

unsigned Offset = IsMasked ? 1 : 0;
Operands.push_back(Ops[Offset]); // Ptr
Operands.push_back(Ops[Offset + 1]); // Idx
if (IsMasked)
Expand All @@ -1849,7 +1855,10 @@ multiclass RVVIndexedSegLoadTuple<string op> {
}
}] in {
defvar T = "(Tuple:" # nf # ")";
def : RVVBuiltin<"v", T # "vPCe" # eew_type # "Uv", type>;
def : RVVBuiltin<T # "v", T # "vPCe" # eew_type # "Uv", type>;
if !not(IsFloat<type>.val) then {
def : RVVBuiltin<T # "Uv", T # "UvPCUe" # eew_type # "Uv", type>;
}
}
}
}
Expand Down Expand Up @@ -1910,14 +1919,8 @@ let UnMaskedPolicyScheme = HasPassthruOperand,
defm : RVVUnitStridedSegLoadTuple<"vlseg">;
defm : RVVUnitStridedSegLoadFFTuple<"vlseg">;
defm : RVVStridedSegLoadTuple<"vlsseg">;
}

// TODO: Extend for policy
let UnMaskedPolicyScheme = NonePolicy,
MaskedPolicyScheme = NonePolicy,
IsTuple = true in {
defm : RVVIndexedSegLoadTuple<"vluxseg">;
defm : RVVIndexedSegLoadTuple<"vloxseg">;
defm : RVVIndexedSegLoadTuple<"vluxseg">;
defm : RVVIndexedSegLoadTuple<"vloxseg">;
}

let UnMaskedPolicyScheme = NonePolicy,
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 9588b18

Please sign in to comment.