[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 22 10:36:04 PDT 2024


================
@@ -808,6 +835,20 @@ bool SPIRVInstructionSelector::selectExtInst(Register ResVReg,
   return false;
 }
 
+bool SPIRVInstructionSelector::selectNAryOpWithSrcs(Register ResVReg,
+                                                    const SPIRVType *ResType,
+                                                    MachineInstr &I,
+                                                    std::vector<Register> Srcs,
+                                                    unsigned Opcode) const {
+  auto MIB = BuildMI(*I.getParent(), I, I.getDebugLoc(), TII.get(Opcode))
+                 .addDef(ResVReg)
+                 .addUse(GR.getSPIRVTypeID(ResType));
+  for (Register SReg : Srcs) {
+    MIB.addUse(SReg);
----------------
farzonl wrote:

I'm pretty sure this function could just replace `selectUnOpWithSrc` because unary wone just be one iteration of the loop. Maybe it would be better to do an NFC change that unifies to one function called `selectOpWithSrcs`?

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


More information about the cfe-commits mailing list