[llvm] [SPIR-V] Emit valid SPIR-V code for integer sizes other than 8,16,32,64 (PR #94219)

Vyacheslav Levytskyy via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 3 08:31:10 PDT 2024


================
@@ -90,27 +90,36 @@ SPIRVType *SPIRVGlobalRegistry::getOpTypeBool(MachineIRBuilder &MIRBuilder) {
       .addDef(createTypeVReg(MIRBuilder));
 }
 
-SPIRVType *SPIRVGlobalRegistry::getOpTypeInt(uint32_t Width,
-                                             MachineIRBuilder &MIRBuilder,
-                                             bool IsSigned) {
+unsigned SPIRVGlobalRegistry::adjustOpTypeIntWidth(unsigned Width) const {
   assert(Width <= 64 && "Unsupported integer width!");
-  const SPIRVSubtarget &ST =
-      cast<SPIRVSubtarget>(MIRBuilder.getMF().getSubtarget());
+  const SPIRVSubtarget &ST = cast<SPIRVSubtarget>(CurMF->getSubtarget());
   if (ST.canUseExtension(
-          SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers)) {
-    MIRBuilder.buildInstr(SPIRV::OpExtension)
-        .addImm(SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers);
-    MIRBuilder.buildInstr(SPIRV::OpCapability)
-        .addImm(SPIRV::Capability::ArbitraryPrecisionIntegersINTEL);
-  } else if (Width <= 8)
+          SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers))
+    return Width;
+  if (Width <= 8)
     Width = 8;
   else if (Width <= 16)
     Width = 16;
   else if (Width <= 32)
     Width = 32;
   else if (Width <= 64)
     Width = 64;
+  return Width;
----------------
VyacheslavLevytskyy wrote:

I will replace assert() with report_fatal_error() and remove the last condition to be sure all is working the same way even for builds without asserts().

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


More information about the llvm-commits mailing list