[llvm-dev] [ARM/Thumb] Make a function in arm while in Thumb triple

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Tue May 2 06:55:20 PDT 2017


2017-05-02 21:47 GMT+08:00 Evgeny Astigeevich via llvm-dev <
llvm-dev at lists.llvm.org>:

> Hi Dimitri,
>
>
>
> As I know the following ACLE attributes are not supported in Clang/LLVM at
> the moment:
>
>
>
> __attribute__((target("arm"))) attribute
>
> __attribute__((target("thumb"))) attribute
>
>
>
> But there is a workaround:
>
>
>
> __attribute__((target("no-thumb-mode")))
>
> __attribute__((target("thumb-mode")))
>

Just curious. Why not provide target("arm") and target("thumb")?​



> The attributes are propagated to a function declaration in IR by the
> frontend and the backend generated the code according to them:
>
>
>
> $ cat test.c
>
>     __attribute__((target("no-thumb-mode"))) int foo(void)
>
>     {
>
>         return 0;
>
>     }
>
>     int main(void)
>
>     {
>
>         return foo();
>
>     }
>
>
>
> $ clang -nostdlib -target armv4t-none-eabi -mthumb -c test.c -emit-llvm -S
> -o -
>
> ; ModuleID = 'test.c'
>
> source_filename = "test.c"
>
> target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
>
> target triple = "thumbv4t-none--eabi"
>
>
>
> ; Function Attrs: noinline nounwind
>
> define i32 @foo() #0 {
>
>   ret i32 0
>
> }
>
>
>
> ; Function Attrs: noinline nounwind
>
> define i32 @main() #1 {
>
>   %1 = alloca i32, align 4
>
>   store i32 0, i32* %1, align 4
>
>   %2 = call i32 @foo()
>
>  ret i32 %2
>
> }
>
>
>
> attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false"
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
> "no-infs-fp-math"="false" "no-jump-tables"="false"
> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
> "no-trapping-math"="false" "stack-protector-buffer-size"="8"
> "target-cpu"="arm7tdmi" "target-features"="+soft-float-abi,+strict-align,
> *-thumb-mode*" "unsafe-fp-math"="false" "use-soft-float"="false" }
>
> attributes #1 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false"
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
> "no-infs-fp-math"="false" "no-jump-tables"="false"
> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
> "no-trapping-math"="false" "stack-protector-buffer-size"="8"
> "target-cpu"="arm7tdmi" "target-features"="+strict-align"
> "unsafe-fp-math"="false" "use-soft-float"="false" }
>

​I don't know if I am reading this wrong (not try this by myself)​. I see
you apply target("no-thumb-mode") attribute on function foo, yet foo's
attribute #0 has -thumb-mode? Seems to be contradiction?

Regards,
chenwj


-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170502/6f09e384/attachment.html>


More information about the llvm-dev mailing list