================ @@ -236,6 +236,59 @@ class OpLowerer { lowerToBindAndAnnotateHandle(F); } + void lowerTypedBufferLoad(Function &F) { + IRBuilder<> &IRB = OpBuilder.getIRB(); + Type *Int32Ty = IRB.getInt32Ty(); + + replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPoint(CI); + + Value *Handle = + createTmpHandleCast(CI->getArgOperand(0), OpBuilder.getHandleType()); + Value *Index0 = CI->getArgOperand(1); + Value *Index1 = UndefValue::get(Int32Ty); + Type *RetTy = OpBuilder.getResRetType(CI->getType()->getScalarType()); + + std::array<Value *, 3> Args{Handle, Index0, Index1}; + Expected<CallInst *> OpCall = + OpBuilder.tryCreateOp(OpCode::BufferLoad, Args, RetTy); + if (Error E = OpCall.takeError()) + return E; + + std::array<Value *, 4> Extracts = {}; + + // We've switched the return type from a vector to a struct, but at this + // point most vectors have probably already been scalarized. Try to + // forward arguments directly rather than inserting into and immediately + // extracting from a vector. + for (Use &U : make_early_inc_range(CI->uses())) + if (auto *EEI = dyn_cast<ExtractElementInst>(U.getUser())) + if (auto *Index = dyn_cast<ConstantInt>(EEI->getIndexOperand())) { + size_t IndexVal = Index->getZExtValue(); + assert(IndexVal < 4 && "Index into buffer load out of range"); ---------------- bogner wrote:
I imagine that the version of a load that provides the CheckAccessFullyMapped bit will be a separate intrinsic. See llvm/wg-hlsl#54 for some of my thoughts around that. https://github.com/llvm/llvm-project/pull/104252 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits