From cc4b6920b36f81ff3a4370c6646de07e268e838b Mon Sep 17 00:00:00 2001 From: Jessica Paquette Date: Fri, 7 Dec 2018 22:08:02 +0000 Subject: [PATCH] [GlobalISel] Add IR translation support for the @llvm.log10 intrinsic This adds IR translation support for @llvm.log10 and updates relevant tests. https://reviews.llvm.org/D55392 llvm-svn: 348657 --- llvm/include/llvm/Support/TargetOpcodes.def | 3 +++ llvm/include/llvm/Target/GenericOpcodes.td | 7 +++++++ llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 5 +++++ llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll | 10 ++++++++++ .../CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir | 3 +++ 5 files changed, 28 insertions(+) diff --git a/llvm/include/llvm/Support/TargetOpcodes.def b/llvm/include/llvm/Support/TargetOpcodes.def index 5bf2a7f..3245276 100644 --- a/llvm/include/llvm/Support/TargetOpcodes.def +++ b/llvm/include/llvm/Support/TargetOpcodes.def @@ -454,6 +454,9 @@ HANDLE_TARGET_OPCODE(G_FLOG) /// Floating point base-2 logarithm of a value. HANDLE_TARGET_OPCODE(G_FLOG2) +/// Floating point base-10 logarithm of a value. +HANDLE_TARGET_OPCODE(G_FLOG10) + /// Generic FP negation. HANDLE_TARGET_OPCODE(G_FNEG) diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td index ae3176c..775221a 100644 --- a/llvm/include/llvm/Target/GenericOpcodes.td +++ b/llvm/include/llvm/Target/GenericOpcodes.td @@ -540,6 +540,13 @@ def G_FLOG2 : GenericInstruction { let hasSideEffects = 0; } +// Floating point base-10 logarithm of a value. +def G_FLOG10 : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$src1); + let hasSideEffects = 0; +} + //------------------------------------------------------------------------------ // Opcodes for LLVM Intrinsics //------------------------------------------------------------------------------ diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 8ea43db..7a39883 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -895,6 +895,11 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, .addDef(getOrCreateVReg(CI)) .addUse(getOrCreateVReg(*CI.getArgOperand(0))); return true; + case Intrinsic::log10: + MIRBuilder.buildInstr(TargetOpcode::G_FLOG10) + .addDef(getOrCreateVReg(CI)) + .addUse(getOrCreateVReg(*CI.getArgOperand(0))); + return true; case Intrinsic::fabs: MIRBuilder.buildInstr(TargetOpcode::G_FABS) .addDef(getOrCreateVReg(CI)) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll index 2997c53..0d2300b 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll @@ -1396,6 +1396,16 @@ define float @test_log2_intrin(float %a) { ret float %res } +declare float @llvm.log10.f32(float) +define float @test_log10_intrin(float %a) { +; CHECK-LABEL: name: test_log10_intrin +; CHECK: [[A:%[0-9]+]]:_(s32) = COPY $s0 +; CHECK: [[RES:%[0-9]+]]:_(s32) = G_FLOG10 [[A]] +; CHECK: $s0 = COPY [[RES]] + %res = call float @llvm.log10.f32(float %a) + ret float %res +} + declare float @llvm.fabs.f32(float) define float @test_fabs_intrin(float %a) { ; CHECK-LABEL: name: test_fabs_intrin diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir index 1bdd0f1..a1d2ab9 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -267,6 +267,9 @@ # DEBUG-NEXT: G_FLOG2 (opcode {{[0-9]+}}): 1 type index # DEBUG: .. type index coverage check SKIPPED: no rules defined # +# DEBUG-NEXT: G_FLOG10 (opcode {{[0-9]+}}): 1 type index +# DEBUG: .. type index coverage check SKIPPED: no rules defined +# # DEBUG-NEXT: G_FNEG (opcode {{[0-9]+}}): 1 type index # DEBUG: .. type index coverage check SKIPPED: no rules defined # -- 2.7.4