[LLVMdev] [MIPS] How can I add a constraint to LLVM/Clang for MIPS BE?
reed kotler
rkotler at mips.com
Mon Mar 4 16:31:25 PST 2013
Here is part of the problem...
Gcc does not try to be creative with AT. It's a reserved register just
like it is with gas by default.
We use AT as an allocatable register and never emit instructions that
would require the assembler to be need to use AT.
By default we have :
.set noat
So if you try and use assembly instructions that need AT you will have a
problem.
So you could add
.set at
and at AT to the clobber list.
Quite possibly it would be more correct for use to do this for you when
inline assembly is present.
I.e.
.set AT
and add AT to the clobber list
however we don't do that at this time.
On 03/04/2013 04:10 PM, Reed Kotler wrote:
> Maybe try:
>
> .set noat
>
> AT is needed to create certain instructions from pseudo instructions,
> so you have to be careful how you use this. Some instructions that you
> can use in Mips assembler are in fact pseudos.
>
> While AT is not available to it (.set noat), the assembler can not
> assemble certain pseudos for you.
>
> On 03/03/2013 06:02 PM, Jia Liu wrote:
>> Hi Jack,
>>
>> On Sat, Mar 2, 2013 at 8:15 AM, Jack Carter
>> <Jack.Carter-1AXoQHu6uovQT0dZR+AlfA at public.gmane.org> wrote:
>>> Jia,
>>>
>>> I made what I believe to be the correct changes and rebuilt clang
>>> and llc. Are the results what you expected? I so I will prepare the
>>> patches for commitment.
>>>
>>> Jack
>>>
>>> clang ../mips_R_JiaLiu.c -o mips_R_JiaLiu.ll -emit-llvm -O3 -S
>>> -target mipsel-unknown-linux -std=gnu89
>>> llc mips_R_JiaLiu.ll -o mips_R_JiaLiu.o -mcpu=mips32r2 -march=mipsel
>>> -filetype=obj
>>> mips-linux-gnu-gcc -mips32r2 -O3 -EL -fPIC -o mips_R_JiaLiu.exe
>>> mips_R_JiaLiu.o
>>>
>>
>> I use your way to compile test case:
>> llvm-install/bin/clang constraints.c -o constraints.ll -emit-llvm -O3
>> -S -target mipsel-unknown-linux -std=gnu89 --sysroot
>> /Users/jia/project/Cross-SDK/sdk/mipsel-gnu-rootfs
>> llvm-install/bin/llc constraints.ll -o constraints.llc.s
>> -mcpu=mips32r2 -march=mipsel -filetype=asm
>> llvm-install/bin/llc constraints.ll -o constraints.o -mcpu=mips32r2
>> -march=mipsel -filetype=obj
>> mipsel-unknown-linux-gnu-gcc -mips32r2 -O3 -EL -fPIC -static -o
>> constraints.exe constraints.o
>>
>> the inline-asm is:
>> #APP
>> lw $5, 0($1)
>> #NO_APP
>>
>> #APP
>> lw $5, 0($1)
>> #NO_APP
>>
>> #APP
>> lwl $5, 1 + 0($1)
>> lwr $5, 2 + 0($1)
>> #NO_APP
>>
>> It use different registers, but $1, that is $AT, cann't be used, it is
>> reserved for $AS using.
>> any ideas?
>>
>>> inline_asm: run *.exe
>>> out is 4
>>> out is 10
>>> out is ccddffbb
>>> inline_asm:
>>>
>>
>> Regards,
>> Jia
>>
>
More information about the llvm-dev
mailing list