[clang] [llvm] [SPIR-V] Implement SPV_KHR_untyped_pointers extension (PR #201233)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 29 06:34:13 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h llvm/lib/Target/SPIRV/SPIRVIRMapping.h llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp llvm/lib/Target/SPIRV/SPIRVTypeInst.cpp llvm/lib/Target/SPIRV/SPIRVTypeInst.h --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index bf27296ed..3f8f9cf12 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -1548,12 +1548,13 @@ bool SPIRVInstructionSelector::selectFrexp(Register ResVReg,
// (which carries an explicit Data Type operand), never on OpVariable.
const bool IsUntyped =
PointerType->getOpcode() == SPIRV::OpTypeUntypedPointerKHR;
- auto VarMIB = BuildMI(*It->getParent(), It, It->getDebugLoc(),
- TII.get(IsUntyped ? SPIRV::OpUntypedVariableKHR
- : SPIRV::OpVariable))
- .addDef(PointerVReg)
- .addUse(GR.getSPIRVTypeID(PointerType))
- .addImm(static_cast<uint32_t>(SPIRV::StorageClass::Function));
+ auto VarMIB =
+ BuildMI(*It->getParent(), It, It->getDebugLoc(),
+ TII.get(IsUntyped ? SPIRV::OpUntypedVariableKHR
+ : SPIRV::OpVariable))
+ .addDef(PointerVReg)
+ .addUse(GR.getSPIRVTypeID(PointerType))
+ .addImm(static_cast<uint32_t>(SPIRV::StorageClass::Function));
if (IsUntyped)
VarMIB.addUse(GR.getSPIRVTypeID(PointeeTy)); // Data Type
VarMIB.constrainAllUses(TII, TRI, RBI);
@@ -1631,12 +1632,13 @@ bool SPIRVInstructionSelector::selectSincos(Register ResVReg,
// (which carries an explicit Data Type operand), never on OpVariable.
const bool IsUntyped =
PointerType->getOpcode() == SPIRV::OpTypeUntypedPointerKHR;
- auto VarMIB = BuildMI(*It->getParent(), It, It->getDebugLoc(),
- TII.get(IsUntyped ? SPIRV::OpUntypedVariableKHR
- : SPIRV::OpVariable))
- .addDef(PointerVReg)
- .addUse(GR.getSPIRVTypeID(PointerType))
- .addImm(static_cast<uint32_t>(SPIRV::StorageClass::Function));
+ auto VarMIB =
+ BuildMI(*It->getParent(), It, It->getDebugLoc(),
+ TII.get(IsUntyped ? SPIRV::OpUntypedVariableKHR
+ : SPIRV::OpVariable))
+ .addDef(PointerVReg)
+ .addUse(GR.getSPIRVTypeID(PointerType))
+ .addImm(static_cast<uint32_t>(SPIRV::StorageClass::Function));
if (IsUntyped)
VarMIB.addUse(GR.getSPIRVTypeID(ResType)); // Data Type
VarMIB.constrainAllUses(TII, TRI, RBI);
@@ -2441,17 +2443,17 @@ SPIRVInstructionSelector::getOrCreateMemSetGlobal(MachineInstr &I) const {
Register VarReg = MRI->createGenericVirtualRegister(LLT::scalar(64));
// With SPV_KHR_untyped_pointers enabled, getOrCreateSPIRVPointerType returns
// an untyped pointer type. An untyped pointer result type is only legal on
- // OpUntypedVariableKHR (which carries an explicit Data Type operand), never on
- // OpVariable. Pick the matching opcode/operands so the synthesized constant
- // global is valid SPIR-V (otherwise consumers mis-size it -> GPU fault).
+ // OpUntypedVariableKHR (which carries an explicit Data Type operand), never
+ // on OpVariable. Pick the matching opcode/operands so the synthesized
+ // constant global is valid SPIR-V (otherwise consumers mis-size it -> GPU
+ // fault).
const bool IsUntyped = VarTy->getOpcode() == SPIRV::OpTypeUntypedPointerKHR;
- auto MIBVar =
- BuildMI(*I.getParent(), I, I.getDebugLoc(),
- TII.get(IsUntyped ? SPIRV::OpUntypedVariableKHR
- : SPIRV::OpVariable))
- .addDef(VarReg)
- .addUse(GR.getSPIRVTypeID(VarTy))
- .addImm(SPIRV::StorageClass::UniformConstant);
+ auto MIBVar = BuildMI(*I.getParent(), I, I.getDebugLoc(),
+ TII.get(IsUntyped ? SPIRV::OpUntypedVariableKHR
+ : SPIRV::OpVariable))
+ .addDef(VarReg)
+ .addUse(GR.getSPIRVTypeID(VarTy))
+ .addImm(SPIRV::StorageClass::UniformConstant);
if (IsUntyped)
MIBVar.addUse(GR.getSPIRVTypeID(SpvArrTy)); // Data Type
MIBVar.addUse(Const); // Initializer
``````````
</details>
https://github.com/llvm/llvm-project/pull/201233
More information about the llvm-commits
mailing list