GlobalISel: translate floating-point round/extend

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279320 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tim Northover 2016-08-19 20:48:23 +00:00
parent b47e6e5d98
commit ff508217db
4 changed files with 42 additions and 2 deletions

View File

@ -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; }

View File

@ -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);

View File

@ -310,6 +310,12 @@ HANDLE_TARGET_OPCODE(G_FDIV)
/// Generic FP remainder.
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)

View File

@ -785,6 +785,24 @@ define void @test_uitofp(double* %addr, i32 %in) {
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