[LLVMdev] Inline Assembly: Memory constraints with offsets

Krzysztof Parzyszek kparzysz at codeaurora.org
Tue Mar 3 06:35:18 PST 2015


On 3/3/2015 6:01 AM, Daniel Sanders wrote:
> Hi,
>
> I'm trying to implement the ZC inline assembly constraint for Mips. This
> constraint is a memory constraint that expands to an address with an
> offset (the range of the offset varies according to the subtarget), so
> the inline assembly in:
>
>    int data[10];
>
>    void ZC(void) {
>
>      asm volatile ("foo %0 %1" : : "ZC"(data[1]), "ZC"(data[2]));
>
>    }
>
> Should expand to something like:
>
>    foo 4($2) 8($2)
>
> At the moment, the best I can get is something like:
>
>    foo 0($2) 0($3)
>
> with the offsets being added before the inline assembly.
>
> Does anyone have any suggestions as to how I can get the offset inside
> the inline assembly?

How are you actually getting this to compile?  I just built clang and 
I'm getting an error:

clang-3.6 -target mips -S mipsa.c
mipsa.c:4:33: error: invalid input constraint 'ZC' in asm
   asm volatile ("foo %0 %1" : : "ZC"(data[1]), "ZC"(data[2]));
                                 ^
1 error generated.


It doesn't seem that the function "validateAsmConstraint" in 
tools/clang/lib/Basic/Targets.cpp handles "ZC" as a constraint.

-Krzysztof


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list