@@ -345,6 +345,32 @@ class VString<int nf, bit signed> {
345345 !eq(nf, 8): !if(signed, "vvvvvvvv", "UvUvUvUvUvUvUvUv"));
346346}
347347
348+
349+ class FixedVString<int fixed_lmul, int num, string vec> {
350+ string V = "(LFixedLog2LMUL:" # fixed_lmul # ")" # vec;
351+ string S = !interleave(!listsplat(V, num), "");
352+ }
353+
354+ multiclass RVVNonTupleVCreateBuiltin<int dst_lmul, list<int> src_lmul_list> {
355+ defvar dst_v = FixedVString<dst_lmul, 1, "v">.V;
356+ defvar dst_uv = FixedVString<dst_lmul, 1, "Uv">.V;
357+ foreach src_lmul = src_lmul_list in {
358+ defvar num = !shl(1, !sub(dst_lmul, src_lmul));
359+
360+ defvar src_v = FixedVString<src_lmul, num, "v">.V;
361+ defvar src_s = FixedVString<src_lmul, num, "v">.S;
362+ def vcreate # src_v # dst_v : RVVBuiltin<src_v # dst_v,
363+ dst_v # src_s,
364+ "csilxfd", dst_v>;
365+
366+ defvar src_uv = FixedVString<src_lmul, num, "Uv">.V;
367+ defvar src_us = FixedVString<src_lmul, num, "Uv">.S;
368+ def vcreate_u # src_uv # dst_uv : RVVBuiltin<src_uv # dst_uv,
369+ dst_uv # src_us,
370+ "csil", dst_uv>;
371+ }
372+ }
373+
348374multiclass RVVPseudoUnaryBuiltin<string IR, string type_range> {
349375 let Name = NAME,
350376 IRName = IR,
@@ -2438,15 +2464,31 @@ let HasMasked = false, HasVL = false, IRName = "" in {
24382464 SupportOverloading = false,
24392465 ManualCodegen = [{
24402466 {
2441- assert(isa<StructType>(ResultType));
2442- unsigned NF = cast<StructType>(ResultType)->getNumElements();
2443- llvm::Value *ReturnTuple = llvm::PoisonValue::get(ResultType);
2444- for (unsigned I = 0; I < NF; ++I) {
2445- ReturnTuple = Builder.CreateInsertValue(ReturnTuple, Ops[I], {I});
2467+ if (isa<StructType>(ResultType)) {
2468+ unsigned NF = cast<StructType>(ResultType)->getNumElements();
2469+ llvm::Value *ReturnTuple = llvm::PoisonValue::get(ResultType);
2470+ for (unsigned I = 0; I < NF; ++I) {
2471+ ReturnTuple = Builder.CreateInsertValue(ReturnTuple, Ops[I], {I});
2472+ }
2473+ return ReturnTuple;
24462474 }
2447- return ReturnTuple;
2475+ llvm::Value *ReturnVector = llvm::PoisonValue::get(ResultType);
2476+ auto *VecTy = cast<ScalableVectorType>(Ops[0]->getType());
2477+ for (unsigned I = 0, N = Ops.size(); I < N; ++I) {
2478+ llvm::Value *Idx =
2479+ ConstantInt::get(Builder.getInt64Ty(),
2480+ VecTy->getMinNumElements() * I);
2481+ ReturnVector =
2482+ Builder.CreateInsertVector(ResultType, ReturnVector, Ops[I], Idx);
2483+ }
2484+ return ReturnVector;
24482485 }
24492486 }] in {
2487+
2488+ defm : RVVNonTupleVCreateBuiltin<1, [0]>;
2489+ defm : RVVNonTupleVCreateBuiltin<2, [0, 1]>;
2490+ defm : RVVNonTupleVCreateBuiltin<3, [0, 1, 2]>;
2491+
24502492 foreach nf = NFList in {
24512493 let NF = nf in {
24522494 defvar T = "(Tuple:" # nf # ")";
0 commit comments