microsoft / llvm-mctoll

llvm-mctoll
Other
799 stars 123 forks source link

How to support thumb2 #79

Open yujack008 opened 3 years ago

yujack008 commented 3 years ago

In order to support thumb2,i change Triple::arm to Triple::thumb in ARMModuleRaiser.h file. the output below:

Generated CFG
# Machine code for function add: TracksLiveness

bb.0:
  $sp = tSUBspi $sp(tied-def 0), 2, 14, $noreg, <0x55934479e8b8>
  tSTRspi $r0, $sp, 1, 14, $noreg, <0x55934479ebc8>
  tSTRspi $r1, $sp, 0, 14, $noreg, <0x55934479ece8>
  $r0 = tLDRspi $sp, 1, 14, $noreg, <0x55934479ee08>
  $r1 = tLDRspi $sp, 0, 14, $noreg, <0x55934479ef28>
  $r0 = tADDhirr $r0(tied-def 0), $r1, 14, $noreg, <0x55934479f048>
  $sp = tADDspi $sp(tied-def 0), 2, 14, $noreg, <0x55934479f168>
  tBX $lr, 14, $noreg, <0x55934479f288>

# End machine code for function add.

how can i fix the problem with "tied-def".

my source file main.c is:

#include <stdio.h>
int add(int a,int b)
{
    return a + b;
}
int main(int argc,char **argv)
{
    printf("1 + 2 = %d\r\n",add(1,2));
    return 0;
}

./bin/clang main.c -target armv7-none-linux-androideabi14 -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-exceptions -fno-rtti -mthumb -O0 -c -o main_thumb.o ./bin/llvm-mctoll main_thumb.o -print-after-all -triple=thumbv7-none-linux-android14

bharadwajy commented 3 years ago

Thanks for your interest in the project.

I am not sure I understand the problem you are referring to. An operand that is used and defined is annotated as tied-def. See here.

What is the problem you wish to fix?

shijiameng commented 3 years ago

@yujack008 Did you solve the issues in Thumb2? I also want it works for thumb2 but have the same problem of yours. Thanks.