[llvm-dev] Substitute instruction with a jump to a library code

Anton Korobeynikov via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 30 02:48:54 PST 2015


Just a side note - the assembly posted is clearly ARM, not MSP430 :)

On Wed, Dec 30, 2015 at 5:38 AM, Rail Shafigulin via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I'm trying to find a way to emulate a floating point instruction, say a
> floating point add. My understanding is that in order to do that I need to
> execute
>
> setOperationAction(ISD::FADD, (MVT::f32, Expand);
> setOperationAction(ISD::FADD, (MVT::f64, Expand);
>
> in MyTargetISelLowering.cpp, MyTargetLowering::MyTargetLowering(...).
>
> However for some reason I'm still seeing a floating point add in the final
> assembly. I tried running my test code (provided below) on MSP430 and can
> see it execute a jump instruction to a label that is clearly located in the
> library code.
>
> Here is my test code:
>
> ; ModuleID = 'simple-fadd.c'
> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-pc-linux-gnu"
>
> ; Function Attrs: nounwind readnone uwtable
> define float @fadd(float %a, float %b) #0 {
>   %1 = fadd float %a, %b
>   ret float %1
> }
>
> attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
> "no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
> "unsafe-fp-math"="false" "use-soft-float"="false" }
>
> !llvm.ident = !{!0}
>
> !0 = metadata !{metadata !"Ubuntu clang version 3.4.0-2ubuntu1~trusty1
> (tags/RELEASE_340/final) (based on LLVM 3.4.0)"}
>
>
> And here is what I see in MSP430
>
> .text
> .syntax unified
> .cpu msp430
> .eabi_attribute 6, 1 @ Tag_CPU_arch
> .eabi_attribute 8, 1 @ Tag_ARM_ISA_use
> .eabi_attribute 20, 1 @ Tag_ABI_FP_denormal
> .eabi_attribute 21, 1 @ Tag_ABI_FP_exceptions
> .eabi_attribute 23, 3 @ Tag_ABI_FP_number_model
> .eabi_attribute 24, 1 @ Tag_ABI_align_needed
> .eabi_attribute 25, 1 @ Tag_ABI_align_preserved
> .file "simple-fadd.ll"
> .globl fadd
> .align 2
> .type fadd,%function
> fadd:                                   @ @fadd
> .fnstart
> .Leh_func_begin0:
> @ BB#0:
> push {lr}
> bl __addsf3
> pop {lr}
> mov pc, lr
> .Ltmp0:
> .size fadd, .Ltmp0-fadd
> .Leh_func_end0:
> .fnend
>
>
> .ident "Ubuntu clang version 3.6.0-2ubuntu1~trusty1 (tags/RELEASE_360/final)
> (based on LLVM 3.6.0)"
>
> One can clearly see a bl __addsf3 instruction. However for some reason my
> target produces a lf.add.s (which is a floating point add) instead of
> branching to a library code. Clearly I'm missing something, but I can't
> figure out what exactly. Would anyone care to help?
>
>
> --
> Rail Shafigulin
> Software Engineer
> Esencia Technologies
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>



-- 
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University


More information about the llvm-dev mailing list