[clang] [RISCV][Sema] Add feature check for target attribute to VSETVL intrinsics (PR #126064)
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 6 19:07:05 PST 2025
================
@@ -623,13 +623,37 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
}
}
+ auto checkVsetvl = [&](unsigned SEWOffset,
+ unsigned LMULOffset) -> bool {
+ const FunctionDecl *FD = SemaRef.getCurFunctionDecl();
+ llvm::StringMap<bool> FunctionFeatureMap;
+ Context.getFunctionFeatureMap(FunctionFeatureMap, FD);
+ llvm::APSInt SEWResult;
+ llvm::APSInt LMULResult;
+ if (SemaRef.BuiltinConstantArg(TheCall, SEWOffset, SEWResult) ||
+ SemaRef.BuiltinConstantArg(TheCall, LMULOffset, LMULResult))
+ return true;
+ int SEWValue = SEWResult.getSExtValue();
+ int LMULValue = LMULResult.getSExtValue();
+ if (((SEWValue == 0 && LMULValue == 5) || // e8mf8
+ (SEWValue == 1 && LMULValue == 6) || // e16mf4
+ (SEWValue == 2 && LMULValue == 7) || // e32mf2
+ (SEWValue == 3 && LMULValue == 0) || // e64m1
+ (SEWValue == 3 && LMULValue == 1) || // e64m2
+ (SEWValue == 3 && LMULValue == 2) || // e64m4
+ (SEWValue == 3 && LMULValue == 3)) && // e64m8
+ (!TI.hasFeature("zve64x") && !FunctionFeatureMap.lookup("zve64x")))
----------------
topperc wrote:
The requirements for supported vtypes is a function of ELEN not VLEN. A Zvl64b+Zve32x implementation may support `e8,mf8`, `e16,mf4`, `e32,mf2` but it not required by the spec so the code would not be portable.
https://github.com/llvm/llvm-project/pull/126064
More information about the cfe-commits
mailing list