[llvm] [AArch64][GISel] Allow import of DAG FCVT/CVTF patterns using fixedpoint immediate (PR #215812)

Kerry McLaughlin via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 05:42:44 PDT 2026


================
@@ -7973,26 +8007,54 @@ void AArch64InstructionSelector::renderFixedPointScalarXForm(
   MIB.addImm(MI.getOperand(OpIdx).getImm());
 }
 
-void AArch64InstructionSelector::renderFixedPointXForm(MachineInstrBuilder &MIB,
-                                                       const MachineInstr &MI,
-                                                       int OpIdx) const {
+void AArch64InstructionSelector::renderFixedPointImm(MachineInstrBuilder &MIB,
+                                                     const MachineOperand &Root,
+                                                     unsigned Width,
+                                                     bool isReciprocal) const {
   // FIXME: This is only needed to satisfy the type checking in tablegen, and
   // should be able to reuse the Renderers already calculated by
-  // selectCVTFixedPointVecBase.
+  // selectCVTFixedPointBase.
   InstructionSelector::ComplexRendererFns Renderer =
-      selectCVTFixedPointVecBase(MI.getOperand(OpIdx), /*isReciprocal*/ false);
+      selectCVTFixedPointBase(Root, Width, isReciprocal);
   assert((Renderer && Renderer->size() == 1) &&
-         "Expected selectCVTFixedPointVec to provide a function\n");
+         "Expected selectCVTFixedPointBase to provide a function\n");
   (Renderer->front())(MIB);
 }
 
-void AArch64InstructionSelector::renderFixedPointRecipXForm(
+template <unsigned Width>
+void AArch64InstructionSelector::renderFixedPointXForm(MachineInstrBuilder &MIB,
+                                                       const MachineInstr &MI,
+                                                       int OpIdx) const {
+  renderFixedPointImm(MIB, MI.getOperand(OpIdx), Width,
+                      /*isReciprocal*/ false);
+}
+
+void AArch64InstructionSelector::renderFixedPointXForm32(
     MachineInstrBuilder &MIB, const MachineInstr &MI, int OpIdx) const {
-  InstructionSelector::ComplexRendererFns Renderer =
-      selectCVTFixedPointVecBase(MI.getOperand(OpIdx), /*isReciprocal*/ true);
-  assert((Renderer && Renderer->size() == 1) &&
-         "Expected selectCVTFixedPosRecipOperandVec to provide a function\n");
-  (Renderer->front())(MIB);
+  // GIsel Renderers cannot use templates in .td so function name used to pass
+  // the width
+  renderFixedPointXForm<32>(MIB, MI, OpIdx);
+}
+
+void AArch64InstructionSelector::renderFixedPointXForm64(
+    MachineInstrBuilder &MIB, const MachineInstr &MI, int OpIdx) const {
+  renderFixedPointXForm<64>(MIB, MI, OpIdx);
----------------
kmclaughlin-arm wrote:

```suggestion
  renderFixedPointImm(MIB, MI.getOperand(OpIdx), 64, /*isReciprocal*/ false);
```
After these changes I think you can remove `renderFixedPointXForm`.

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


More information about the llvm-commits mailing list