================ @@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef<Value *>{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdouble: { + + assert((E->getArg(0)->getType()->hasFloatingRepresentation() && + E->getArg(1)->getType()->hasUnsignedIntegerRepresentation() && + E->getArg(2)->getType()->hasUnsignedIntegerRepresentation()) && + "asuint operands types mismatch"); + Value *Op0 = EmitScalarExpr(E->getArg(0)); + const HLSLOutArgExpr *OutArg1 = dyn_cast<HLSLOutArgExpr>(E->getArg(1)); + const HLSLOutArgExpr *OutArg2 = dyn_cast<HLSLOutArgExpr>(E->getArg(2)); + + CallArgList Args; + auto [Op1BaseLValue, Op1TmpLValue] = + EmitHLSLOutArgExpr(OutArg1, Args, OutArg1->getType()); + auto [Op2BaseLValue, Op2TmpLValue] = + EmitHLSLOutArgExpr(OutArg2, Args, OutArg2->getType()); + + if (CGM.getTarget().getTriple().getArch() == llvm::Triple::dxil) { + + llvm::StructType *retType = llvm::StructType::get(Int32Ty, Int32Ty); + + if (Op0->getType()->isVectorTy()) { + auto *Op0VecTy = E->getArg(0)->getType()->getAs<VectorType>(); + + llvm::VectorType *i32VecTy = llvm::VectorType::get( + Int32Ty, ElementCount::getFixed(Op0VecTy->getNumElements())); + retType = llvm::StructType::get(i32VecTy, i32VecTy); ---------------- llvm-beanz wrote:
creating struct types isn't free, so creating the type outside the branch then inside the branch isn't ideal. Better to initialize it to null and create it in an `if`/`else`. https://github.com/llvm/llvm-project/pull/109331 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits