[llvm] [SPIRV] Implement handle_fromBinding intrinsic. (PR #111052)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 01:02:31 PDT 2024


================
@@ -44,6 +44,18 @@ using ExtInstList =
 
 namespace {
 
+uint64_t getUnsignedConstantValueFromReg(llvm::Register Reg,
+                                         const llvm::MachineRegisterInfo &MRI) {
+  llvm::SPIRVType *ConstTy = MRI.getVRegDef(Reg);
+  assert(ConstTy && ConstTy->getOpcode() == llvm::SPIRV::ASSIGN_TYPE &&
+         ConstTy->getOperand(1).isReg());
----------------
Keenuts wrote:

A bit weird, but I suppose this always run after we emitted the assign-type instructions, meaning we have this additional walk to do :/
Should the function do something like:
```
if (getOpcode() == ASSIGN_TYPE)
     return getUnsignedConstantValueFromReg(getOperand(1).getReg())
assert(getOpcode() == G_CONSTANT)
return getOperand(1).getCImm()
```

https://github.com/llvm/llvm-project/pull/111052


More information about the llvm-commits mailing list