[llvm] r279320 - GlobalISel: translate floating-point round/extend

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 13:48:23 PDT 2016


Author: tnorthover
Date: Fri Aug 19 15:48:23 2016
New Revision: 279320

URL: http://llvm.org/viewvc/llvm-project?rev=279320&view=rev
Log:
GlobalISel: translate floating-point round/extend

Modified:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
    llvm/trunk/include/llvm/Target/GenericOpcodes.td
    llvm/trunk/include/llvm/Target/TargetOpcodes.def
    llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll

Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h?rev=279320&r1=279319&r2=279320&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h Fri Aug 19 15:48:23 2016
@@ -216,6 +216,12 @@ private:
   bool translateTrunc(const User &U) {
     return translateCast(TargetOpcode::G_TRUNC, U);
   }
+  bool translateFPTrunc(const User &U) {
+    return translateCast(TargetOpcode::G_FPTRUNC, U);
+  }
+  bool translateFPExt(const User &U) {
+    return translateCast(TargetOpcode::G_FPEXT, U);
+  }
   bool translateFPToUI(const User &U) {
     return translateCast(TargetOpcode::G_FPTOUI, U);
   }
@@ -279,8 +285,6 @@ private:
   bool translateFence(const User &U) { return false; }
   bool translateAtomicCmpXchg(const User &U) { return false; }
   bool translateAtomicRMW(const User &U) { return false; }
-  bool translateFPTrunc(const User &U) { return false; }
-  bool translateFPExt(const User &U) { return false; }
   bool translateAddrSpaceCast(const User &U) { return false; }
   bool translateCleanupPad(const User &U) { return false; }
   bool translateCatchPad(const User &U) { return false; }

Modified: llvm/trunk/include/llvm/Target/GenericOpcodes.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/GenericOpcodes.td?rev=279320&r1=279319&r2=279320&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/GenericOpcodes.td (original)
+++ llvm/trunk/include/llvm/Target/GenericOpcodes.td Fri Aug 19 15:48:23 2016
@@ -264,6 +264,18 @@ def G_SMULO : Instruction {
 // Floating Point Unary Ops.
 //------------------------------------------------------------------------------
 
+def G_FPEXT : Instruction {
+  let OutOperandList = (outs unknown:$dst);
+  let InOperandList = (ins unknown:$src);
+  let hasSideEffects = 0;
+}
+
+def G_FPTRUNC : Instruction {
+  let OutOperandList = (outs unknown:$dst);
+  let InOperandList = (ins unknown:$src);
+  let hasSideEffects = 0;
+}
+
 def G_FPTOSI : Instruction {
   let OutOperandList = (outs unknown:$dst);
   let InOperandList = (ins unknown:$src);

Modified: llvm/trunk/include/llvm/Target/TargetOpcodes.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOpcodes.def?rev=279320&r1=279319&r2=279320&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetOpcodes.def (original)
+++ llvm/trunk/include/llvm/Target/TargetOpcodes.def Fri Aug 19 15:48:23 2016
@@ -311,6 +311,12 @@ HANDLE_TARGET_OPCODE(G_FDIV)
 HANDLE_TARGET_OPCODE(G_FREM)
 
 /// Generic float to signed-int conversion
+HANDLE_TARGET_OPCODE(G_FPEXT)
+
+/// Generic float to signed-int conversion
+HANDLE_TARGET_OPCODE(G_FPTRUNC)
+
+/// Generic float to signed-int conversion
 HANDLE_TARGET_OPCODE(G_FPTOSI)
 
 /// Generic float to unsigned-int conversion

Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll?rev=279320&r1=279319&r2=279320&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll Fri Aug 19 15:48:23 2016
@@ -785,6 +785,24 @@ define void @test_uitofp(double* %addr,
   ret void
 }
 
+; CHECK-LABEL: name: test_fpext
+; CHECK: [[IN:%[0-9]+]](32) = COPY %s0
+; CHECK: [[RES:%[0-9]+]](64) = G_FPEXT { s64, s32 } [[IN]]
+; CHECK: %d0 = COPY [[RES]]
+define double @test_fpext(float %in) {
+  %res = fpext float %in to double
+  ret double %res
+}
+
+; CHECK-LABEL: name: test_fptrunc
+; CHECK: [[IN:%[0-9]+]](64) = COPY %d0
+; CHECK: [[RES:%[0-9]+]](32) = G_FPTRUNC { s32, s64 } [[IN]]
+; CHECK: %s0 = COPY [[RES]]
+define float @test_fptrunc(double %in) {
+  %res = fptrunc double %in to float
+  ret float %res
+}
+
 ; CHECK-LABEL: name: test_constant_float
 ; CHECK: [[ADDR:%[0-9]+]](64) = COPY %x0
 ; CHECK: [[TMP:%[0-9]+]](32) = G_FCONSTANT s32 float 1.500000e+00




More information about the llvm-commits mailing list