[cfe-dev] [LLVMdev] [MIPS] How can I add a constraint to LLVM/Clang for MIPS BE?

Jia Liu proljc at gmail.com
Thu Feb 28 17:31:35 PST 2013


Hi Jack,

On Fri, Mar 1, 2013 at 2:52 AM, Jack Carter <Jack.Carter at imgtec.com> wrote:
> Jia,
>
> Try this in : lib/Basic/Targets.cpp ~line 4390
>
>   virtual bool validateAsmConstraint(const char *&Name,
>                                      TargetInfo::ConstraintInfo &Info) const
> {
>     switch (*Name) {
>     default:
>       return false;
>
>     case 'r': // CPU registers.
>     case 'd': // Equivalent to "r" unless generating MIPS16 code.
>     case 'y': // Equivalent to "r", backwards compatibility only.
>     case 'f': // floating-point registers.
>     case 'c': // $25 for indirect jumps
>     case 'l': // lo register
>
>     case 'x': // hilo register pair
>       Info.setAllowsRegister();
>       return true;
>     case 'R': // An address tha can be sued in a non-macro load or store
>       Info.setAllowsMemory();
>       return true;
>     }

This is what exactly I did, I've attach my clang patch in the mail like this:
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 24a69ee..854e12b 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -4393,6 +4393,9 @@ public:
     case 'x': // hilo register pair
       Info.setAllowsRegister();
       return true;
+    case 'R': // An address that can be used in a non-macro load or store
+      Info.setAllowsMemory();
+      return true;
     }
   }

Then I get wrong generated code, more ideas, please?

>
> Jack
>
> On 02/28/2013 08:12 AM, Jia Liu wrote:> Hi all,
>
>>
>> I find clang-mips doesn't support constraint 'R' and I'm trying make
>> LLVM/Clang support it.
>> I did a little job, but Clang can not generate right code, it use the
>> same register in inline asm,
>> and the binary will segment fault in MIPS environment.
>>
>

Regards,
Jia



More information about the cfe-dev mailing list