[llvm] [SPIRV] Implement translation for llvm.modf.* intrinsics (PR #147556)
Marcos Maronas via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 08:06:08 PDT 2025
================
@@ -995,4 +995,26 @@ unsigned getArrayComponentCount(const MachineRegisterInfo *MRI,
return foldImm(ResType->getOperand(2), MRI);
}
+MachineBasicBlock::iterator
+getPosForOpVariableWithinBlock(MachineBasicBlock &BB) {
+ // Find the position to insert the OpVariable instruction.
+ // We will insert it after the last OpFunctionParameter, if any, or
+ // after OpFunction otherwise.
+ MachineBasicBlock::iterator VarPos = BB.begin();
+ while (VarPos != BB.end() && VarPos->getOpcode() != SPIRV::OpFunction) {
+ ++VarPos;
+ }
+ // Advance VarPos to the next instruction after OpFunction, it will either
+ // be an OpFunctionParameter, so that we can start the next loop, or the
+ // position to insert the OpVariable instruction.
+ ++VarPos;
+ while (VarPos != BB.end() &&
+ VarPos->getOpcode() == SPIRV::OpFunctionParameter) {
+ ++VarPos;
+ }
+ // VarPos is now pointing at after the last OpFunctionParameter, if any,
+ // or after OpFunction, if no parameters.
+ return VarPos;
----------------
maarquitos14 wrote:
Done in https://github.com/llvm/llvm-project/pull/147556/commits/435d6361768078068c911f1456cc02ad93deb906, but it should never happen, `OpLabel` is generated later.
https://github.com/llvm/llvm-project/pull/147556
More information about the llvm-commits
mailing list