[llvm-commits] [patch] add support for a movi32 of a symbol to the ARM MC asm printer

Chris Lattner clattner at apple.com
Sun May 9 11:08:56 PDT 2010

On May 8, 2010, at 7:11 PM, Rafael Espindola wrote:

> The attached patch implements support in the new ARM MC asm printer
> for a movi32 of a global. Previously only constants were supported.
> With this patch "llc -enable-arm-mcinst-printer" works on
> --------------------------------------------
> target triple = "armv7-unknown-linux-gnueabi"
> @.str = private constant [4 x i8] c"%d\0A\00"     ; <[4 x i8]*> [#uses=1]
> define i32 @main() nounwind optsize {
> entry:
>  %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds
> ([4 x i8]* @.str, i32 0, i32 0), i32 1001) nounwind optsize ; <i32>
> [#uses=0]
>  ret i32 0
> }
> declare i32 @printf(i8* nocapture, ...) nounwind optsize
> ------------------------------------------------
> I find it strange that I have to define a new instruction just to use
> a modifier. Should I try to add VK_LOWER16 and VK_HIGH16 to
> VariantKind instead?

Right, this isn't the right way to go here.  In general, the MC stuff should use *fewer* instructions that codegen does.  Things like "the tail call form of return" etc go away with MC.

The right thing to do here depends on whether the reference to the global ends up with a special relocation type in the relocation entry.  Assuming it does, adding new VariantKinds is the right way to go (currently VariantKind is going to be a union of all target's relocation flags).  The best way to handle this is to have isel set these as TargetFlags when it lowers the instruction, then have ARM's MCInstLowering convert the target flags to the VariantKinds.


More information about the llvm-commits mailing list