[clang] [llvm] Add cross builtins and cross HLSL function to DirectX and SPIR-V backend (PR #109180)
Joshua Batista via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 2 14:19:38 PDT 2024
================
@@ -74,6 +75,42 @@ static Value *expandAbs(CallInst *Orig) {
"dx.max");
}
+static Value *expandCrossIntrinsic(CallInst *Orig) {
+
+ VectorType *VT = cast<VectorType>(Orig->getType());
+ if (cast<FixedVectorType>(VT)->getNumElements() != 3)
+ report_fatal_error(Twine("return vector must have exactly 3 elements"),
+ /* gen_crash_diag=*/false);
+
+ Value *op0 = Orig->getOperand(0);
+ Value *op1 = Orig->getOperand(1);
+ IRBuilder<> Builder(Orig);
+
+ Value *op0_x = Builder.CreateExtractElement(op0, (uint64_t)0, "x0");
----------------
bob80905 wrote:
Without the cast I get:
`error C2668: 'llvm::IRBuilderBase::CreateExtractElement': ambiguous call to overloaded function note: while trying to match the argument list '(llvm::Value *, int)' `
as a compilation error.
https://github.com/llvm/llvm-project/pull/109180
More information about the cfe-commits
mailing list