[LLVMdev] MIPS & GP register

reed kotler rkotler at mips.com
Thu Aug 16 11:10:03 PDT 2012


Our guy that works on the Clang/LLVM driver is on vacation for another week.


On 08/16/2012 10:58 AM, Eli Friedman wrote:
> On Thu, Aug 16, 2012 at 10:37 AM, Carl Norum<carl at lytro.com>  wrote:
>> On Aug 15, 2012, at 11:56 PM, Eli Friedman wrote:
>>
>>> On Wed, Aug 15, 2012 at 10:17 PM, Carl Norum<carl at lytro.com>  wrote:
>>>>>     -march=mips32r2
>>>>>     -mtune=4kem
>>>>>     -msoft-float
>>>>>     -EL
>>>>>
>>>>>     -Xclang -triple -Xclang mipsel-sde-elf
>>>>>     -Xclang -mrelocation-model -Xclang static
>>>>>
>>>>>     -Xclang -mllvm -Xclang -mips-ssection-threshold=0
>>>>>     -Xclang -mllvm -Xclang -enable-mips-delay-filler
>>> We generally try to discourage people from using -Xclang flags
>>> wherever possible; they're really implementation details, and
>>> considered an unstable interface.
>>>
>>> For the triple and relocation model, the flags you're looking for are
>>> "-target mipsel-sde-elf" and "-static".
>> "-static" I think is OK.  "-target mipsel-sde-elf" doesn't work at all - it seems like it tries to pass that flag along to GCC, which then complains "error: unrecognized command line option ‘-triple’".  I changed it to "-ccc-host-triple" and that seemed to fix that problem, but the assembler seems to freak out something fierce.  At first, it said "FATAL:/usr/bin/../libexec/as/x86_64/as: I don't understand 'G' flag!", and when I removed the offending "-Xassembler" flags, it generates hundreds of errors, I think because it's calling "/usr/bin/gcc" and then getting an x86_64 assembler instead of the MIPS cross-assembler.  Adding a -v flag seems to confirm this thinking.  With "-ccc-host-triple mips-sde-elf" and the -v flag, I get this invocation to the assembler (-D, -W and -I flags removed):
>>
>>       "/usr/bin/gcc" -funsigned-char -msoft-float -Oz -static
>>          -v -Xassembler -G -Xassembler 0 -ffunction-sections
>>          -fdata-sections -MD -march=mips32r2 -mtune=4kem -EL
>>          -fshort-wchar -fno-zero-initialized-in-bss
>>          -fasynchronous-unwind-tables -c
>>          -o Coach12p/RfiUiAssetsCompiled1.o -G 0 -x assembler
>>          /var/folders/mk/0mblc5810cjgs0nylrkjxqbm0000gq/T/RfiUiAssetsCompiled1-cNtWix.s
>>
>> This GCC invocation gives the error message "i686-apple-darwin11-llvm-gcc-4.2: 0: No such file or directory", I think because of the -G 0 flag.  Here's the matching assembler invocation:
>>
>>       /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/as
>>          -arch x86_64 -force_cpusubtype_ALL -G 0
>>          -o Coach12p/RfiUiAssetsCompiled1.o
>>          /var/folders/mk/0mblc5810cjgs0nylrkjxqbm0000gq/T/RfiUiAssetsCompiled1-cNtWix.s
>>
>> This is the invocation that says:
>>
>>       FATAL:/usr/bin/../libexec/as/x86_64/as: I don't understand 'G' flag!
>>
>> As I mentioned above, I tried taking out the "-Xassembler -G -Xassembler 0" flags to shut that error up and see if anything useful happened.  Instead I got a bunch of errors about bad opcodes, which makes sense if it's trying to assemble MIPS assembly with an Intel assembler.  Here are the invocations for reference:
>>
>>       "/usr/bin/gcc" -funsigned-char -msoft-float -Oz -static
>>          -v -ffunction-sections -fdata-sections -MD
>>          -march=mips32r2 -mtune=4kem -EL -fshort-wchar
>>          -fno-zero-initialized-in-bss -fasynchronous-unwind-tables
>>          -c -o Coach12p/RfiUiAssetsCompiled1.o -x assembler
>>          /var/folders/mk/0mblc5810cjgs0nylrkjxqbm0000gq/T/RfiUiAssetsCompiled1-kTss18.s
>>
>>       /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/as -arch x86_64
>>          -force_cpusubtype_ALL -o Coach12p/RfiUiAssetsCompiled1.o
>>          /var/folders/mk/0mblc5810cjgs0nylrkjxqbm0000gq/T/RfiUiAssetsCompiled1-kTss18.s
>>
>> whereas when I do it with the "-Xclang -triple -Xclang mipsel-sde-elf" style it seems to call the cross-assembler correctly:
>>
>>       "/usr/local/lytro/bin/mips-sde-elf-gcc" -funsigned-char
>>         -msoft-float -Oz -static -v -Xassembler -G -Xassembler 0
>>         -ffunction-sections -fdata-sections -MD -march=mips32r2
>>         -mtune=4kem -EL -fshort-wchar -fno-zero-initialized-in-bss
>>         -fasynchronous-unwind-tables -c -o Coach12p/RfiUiAssetsCompiled1.o
>>         -G 0 -x assembler
>>         /var/folders/mk/0mblc5810cjgs0nylrkjxqbm0000gq/T/RfiUiAssetsCompiled1-BmjBFI.s
>>
>>        /usr/local/lytro/lib/gcc/mips-sde-elf/4.7.1/../../../../mips-sde-elf/bin/as
>>            -G 0 -EL -mips32r2 -O2 -no-mdebug -mabi=32 -march=mips32r2 -mtune=4kem
>>            --trap -G 0 -o Coach12p/RfiUiAssetsCompiled1.o
>>            /var/folders/mk/0mblc5810cjgs0nylrkjxqbm0000gq/T/RfiUiAssetsCompiled1-BmjBFI.s
> That's weird... you're probably triggering some sort of bad case in
> the driver logic which tries to call gcc to assemble and link on
> targets where we don't know what to do.  That logic is generally a bit
> shaky to begin with.
>
>>> For the MIPS-specific flags, I don't think there's an equivalent;
>>> please file bugs if it's actually useful functionality we should
>>> be exposing with regular flags.
>> Both of those flags are critical, I think.  It's possible the delay slot filler isn't believed to be "ready for prime time" and so it's hidden?  It does seem to work fine for us.  Setting the SDATA section threshold is very important for us - our program is much too large and has far too many globals to fit in the 64 KB SDATA section.  I'll file bugs and see what turns up.  I can make the patches myself if you can give me the 30-second pointer in the right direction.
> Clang::AddMIPSTargetArgs does the relevant parsing; options are
> defined in include/clang/Driver/Options.td .
>
> -Eli
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list