[llvm] [Spirv][HLSL] Add OpAll lowering and float vec support (PR #87952)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 8 09:58:13 PDT 2024


================
@@ -164,9 +178,82 @@ SPIRVGlobalRegistry::getOrCreateConstIntReg(uint64_t Val, SPIRVType *SpvType,
   return std::make_tuple(Res, CI, NewInstr);
 }
 
+std::tuple<Register, ConstantFP *, bool, unsigned>
+SPIRVGlobalRegistry::getOrCreateConstFloatReg(APFloat Val, SPIRVType *SpvType,
+                                              MachineIRBuilder *MIRBuilder,
+                                              MachineInstr *I,
+                                              const SPIRVInstrInfo *TII) {
+  const Type *LLVMFloatTy;
+  LLVMContext &Ctx = CurMF->getFunction().getContext();
+  unsigned BitWidth = 32;
+  if (SpvType)
+    LLVMFloatTy = getTypeForSPIRVType(SpvType);
+  else {
+    LLVMFloatTy = Type::getFloatTy(Ctx);
+    if (MIRBuilder)
+      SpvType = getOrCreateSPIRVType(LLVMFloatTy, *MIRBuilder);
+  }
+  bool NewInstr = false;
+  // Find a constant in DT or build a new one.
+  auto *const CI = ConstantFP::get(Ctx, Val);
+  Register Res = DT.find(CI, CurMF);
+  if (!Res.isValid()) {
+    if (SpvType)
+      BitWidth = getScalarOrVectorBitWidth(SpvType);
+
+    LLT LLTy = LLT::scalar(32);
----------------
farzonl wrote:

So this is the stacktrace and why I left the behavior as is:
```
#0 0x000060969b04c53d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /mnt/DevDrive/projects/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x000060969b04ca2b PrintStackTraceSignalHandler(void*) /mnt/DevDrive/projects/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x000060969b04aa96 llvm::sys::RunSignalHandlers() /mnt/DevDrive/projects/llvm-project/llvm/lib/Support/Signals.cpp:105:5
 #3 0x000060969b04d1e5 SignalHandler(int) /mnt/DevDrive/projects/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x0000701f3f442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x0000701f3f4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #6 0x0000701f3f442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #7 0x0000701f3f4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #8 0x000060969af643f4 llvm::report_fatal_error(llvm::Twine const&, bool) /mnt/DevDrive/projects/llvm-project/llvm/lib/Support/ErrorHandling.cpp:125:5
 #9 0x000060969bd32def reportGISelDiagnostic(llvm::DiagnosticSeverity, llvm::MachineFunction&, llvm::TargetPassConfig const&, llvm::MachineOptimizationRemarkEmitter&, llvm::MachineOptimizationRemarkMissed&) /mnt/DevDrive/projects/llvm-project/llvm/lib/CodeGen/GlobalISel/Utils.cpp:264:5
#10 0x000060969bd32e55 llvm::reportGISelFailure(llvm::MachineFunction&, llvm::TargetPassConfig const&, llvm::MachineOptimizationRemarkEmitter&, llvm::MachineOptimizationRemarkMissed&) /mnt/DevDrive/projects/llvm-project/llvm/lib/CodeGen/GlobalISel/Utils.cpp:278:1
#11 0x000060969bd3302f llvm::reportGISelFailure(llvm::MachineFunction&, llvm::TargetPassConfig const&, llvm::MachineOptimizationRemarkEmitter&, char const*, llvm::StringRef, llvm::MachineInstr const&) /mnt/DevDrive/projects/llvm-project/llvm/lib/CodeGen/GlobalISel/Utils.cpp:291:1
#12 0x000060969bc95634 llvm::InstructionSelect::runOnMachineFunction(llvm::MachineFunction&) /mnt/DevDrive/projects/llvm-project/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp:289:7
#13 0x0000609699a897f6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /mnt/DevDrive/projects/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:93:8
#14 0x000060969a1ebb4a llvm::FPPassManager::runOnFunction(llvm::Function&) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1441:23
#15 0x000060969a1f09a2 llvm::FPPassManager::runOnModule(llvm::Module&) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1487:16
#16 0x000060969a1ec43b (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1556:23
#17 0x000060969a1ebfb1 llvm::legacy::PassManagerImpl::run(llvm::Module&) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:541:16
#18 0x000060969a1f0c81 llvm::legacy::PassManager::run(llvm::Module&) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1683:3
#19 0x0000609696bf0747 compileModule(char**, llvm::LLVMContext&) /mnt/DevDrive/projects/llvm-project/llvm/tools/llc/llc.cpp:741:9
#20 0x0000609696bee8f5 main /mnt/DevDrive/projects/llvm-project/llvm/tools/llc/llc.cpp:408:13
#21 0x0000701f3f429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x0000701f3f429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
```

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


More information about the llvm-commits mailing list