[llvm] r360888 - GlobalISel: Add buildFMA to MachineIRBuilder

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 06:04:21 PDT 2019


Author: arsenm
Date: Thu May 16 06:04:20 2019
New Revision: 360888

URL: http://llvm.org/viewvc/llvm-project?rev=360888&view=rev
Log:
GlobalISel: Add buildFMA to MachineIRBuilder

Modified:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
    llvm/trunk/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp

Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h?rev=360888&r1=360887&r2=360888&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h Thu May 16 06:04:20 2019
@@ -1268,6 +1268,12 @@ public:
     return buildInstr(TargetOpcode::G_FSUB, {Dst}, {Src0, Src1});
   }
 
+  /// Build and insert \p Res = G_FMA \p Op0, \p Op1, \p Op2
+  MachineInstrBuilder buildFMA(const DstOp &Dst, const SrcOp &Src0,
+                               const SrcOp &Src1, const SrcOp &Src2) {
+    return buildInstr(TargetOpcode::G_FMA, {Dst}, {Src0, Src1, Src2});
+  }
+
   /// Build and insert \p Res = G_FNEG \p Op0
   MachineInstrBuilder buildFNeg(const DstOp &Dst, const SrcOp &Src0) {
     return buildInstr(TargetOpcode::G_FNEG, {Dst}, {Src0});

Modified: llvm/trunk/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp?rev=360888&r1=360887&r2=360888&view=diff
==============================================================================
--- llvm/trunk/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp (original)
+++ llvm/trunk/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp Thu May 16 06:04:20 2019
@@ -127,6 +127,7 @@ TEST_F(GISelMITest, TestBuildFPInsts) {
 
   B.buildFAdd(S64, Copies[0], Copies[1]);
   B.buildFSub(S64, Copies[0], Copies[1]);
+  B.buildFMA(S64, Copies[0], Copies[1], Copies[2]);
   B.buildFNeg(S64, Copies[0]);
   B.buildFAbs(S64, Copies[0]);
   B.buildFCopysign(S64, Copies[0], Copies[1]);
@@ -134,8 +135,10 @@ TEST_F(GISelMITest, TestBuildFPInsts) {
   auto CheckStr = R"(
   ; CHECK: [[COPY0:%[0-9]+]]:_(s64) = COPY $x0
   ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+  ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
   ; CHECK: [[FADD:%[0-9]+]]:_(s64) = G_FADD [[COPY0]]:_, [[COPY1]]:_
   ; CHECK: [[FSUB:%[0-9]+]]:_(s64) = G_FSUB [[COPY0]]:_, [[COPY1]]:_
+  ; CHECK: [[FMA:%[0-9]+]]:_(s64) = G_FMA [[COPY0]]:_, [[COPY1]]:_, [[COPY2]]:_
   ; CHECK: [[FNEG:%[0-9]+]]:_(s64) = G_FNEG [[COPY0]]:_
   ; CHECK: [[FABS:%[0-9]+]]:_(s64) = G_FABS [[COPY0]]:_
   ; CHECK: [[FCOPYSIGN:%[0-9]+]]:_(s64) = G_FCOPYSIGN [[COPY0]]:_, [[COPY1]]:_




More information about the llvm-commits mailing list