forked from OSchip/llvm-project
[GISel]: Add Opcodes for a few LLVM Intrinsics
https://reviews.llvm.org/D50401 Add opcodes for llvm.intrinsic.trunc, round, and update the IRTranslator for the same. Reviewed by: dsanders. llvm-svn: 339977
This commit is contained in:
parent
be57e8e328
commit
973a557338
|
@ -268,6 +268,12 @@ HANDLE_TARGET_OPCODE(G_INTTOPTR)
|
|||
/// COPY is the relevant instruction.
|
||||
HANDLE_TARGET_OPCODE(G_BITCAST)
|
||||
|
||||
/// INTRINSIC trunc intrinsic.
|
||||
HANDLE_TARGET_OPCODE(G_INTRINSIC_TRUNC)
|
||||
|
||||
/// INTRINSIC round intrinsic.
|
||||
HANDLE_TARGET_OPCODE(G_INTRINSIC_ROUND)
|
||||
|
||||
/// Generic load (including anyext load)
|
||||
HANDLE_TARGET_OPCODE(G_LOAD)
|
||||
|
||||
|
|
|
@ -512,6 +512,21 @@ def G_FLOG2 : GenericInstruction {
|
|||
let hasSideEffects = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Opcodes for LLVM Intrinsics
|
||||
//------------------------------------------------------------------------------
|
||||
def G_INTRINSIC_TRUNC : GenericInstruction {
|
||||
let OutOperandList = (outs type0:$dst);
|
||||
let InOperandList = (ins type0:$src1);
|
||||
let hasSideEffects = 0;
|
||||
}
|
||||
|
||||
def G_INTRINSIC_ROUND : GenericInstruction {
|
||||
let OutOperandList = (outs type0:$dst);
|
||||
let InOperandList = (ins type0:$src1);
|
||||
let hasSideEffects = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Memory ops
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -850,6 +850,16 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
|
|||
.addDef(getOrCreateVReg(CI))
|
||||
.addUse(getOrCreateVReg(*CI.getArgOperand(0)));
|
||||
return true;
|
||||
case Intrinsic::trunc:
|
||||
MIRBuilder.buildInstr(TargetOpcode::G_INTRINSIC_TRUNC)
|
||||
.addDef(getOrCreateVReg(CI))
|
||||
.addUse(getOrCreateVReg(*CI.getArgOperand(0)));
|
||||
return true;
|
||||
case Intrinsic::round:
|
||||
MIRBuilder.buildInstr(TargetOpcode::G_INTRINSIC_ROUND)
|
||||
.addDef(getOrCreateVReg(CI))
|
||||
.addUse(getOrCreateVReg(*CI.getArgOperand(0)));
|
||||
return true;
|
||||
case Intrinsic::fma:
|
||||
MIRBuilder.buildInstr(TargetOpcode::G_FMA)
|
||||
.addDef(getOrCreateVReg(CI))
|
||||
|
|
|
@ -1408,6 +1408,26 @@ define float @test_fabs_intrin(float %a) {
|
|||
ret float %res
|
||||
}
|
||||
|
||||
declare float @llvm.trunc.f32(float)
|
||||
define float @test_intrinsic_trunc(float %a) {
|
||||
; CHECK-LABEL: name: test_intrinsic_trunc
|
||||
; CHECK: [[A:%[0-9]+]]:_(s32) = COPY $s0
|
||||
; CHECK: [[RES:%[0-9]+]]:_(s32) = G_INTRINSIC_TRUNC [[A]]
|
||||
; CHECK: $s0 = COPY [[RES]]
|
||||
%res = call float @llvm.trunc.f32(float %a)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare float @llvm.round.f32(float)
|
||||
define float @test_intrinsic_round(float %a) {
|
||||
; CHECK-LABEL: name: test_intrinsic_round
|
||||
; CHECK: [[A:%[0-9]+]]:_(s32) = COPY $s0
|
||||
; CHECK: [[RES:%[0-9]+]]:_(s32) = G_INTRINSIC_ROUND [[A]]
|
||||
; CHECK: $s0 = COPY [[RES]]
|
||||
%res = call float @llvm.round.f32(float %a)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare i32 @llvm.ctlz.i32(i32, i1)
|
||||
define i32 @test_ctlz_intrinsic_zero_not_undef(i32 %a) {
|
||||
; CHECK-LABEL: name: test_ctlz_intrinsic_zero_not_undef
|
||||
|
|
Loading…
Reference in New Issue