[PATCH] D12261: [Sparc] Accept %0 through %31 as registers in assembly code.

James Y Knight via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 21 20:17:23 PDT 2015


I'm not sure this is actually a good idea. The asm file in question seems
to me probably to have just been a typo. (Says %0 in one place, instead of
%g0 or 0.)

Unless there's more widespread usage of this, I think it might be better to
treat that "%0" usage as a bug, and just fix it, rather than adding support
for this confusing register-naming variant in llvm.

Solaris 'as' also doesn't accept that syntax.
$ echo "mov %0, %g1" > /tmp/test.s
$ as -o /tmp/test.o /tmp/test.s
as: "/tmp/test.s", line 1: error: statement syntax


On Fri, Aug 21, 2015 at 10:34 PM, Douglas Katzman <dougk at google.com> wrote:

> dougk created this revision.
> dougk added a reviewer: jyknight.
> dougk added a subscriber: llvm-commits.
>
> This syntax appears in actual code in the wild, and is valid according to
> gnu as.
>
> http://reviews.llvm.org/D12261
>
> Files:
>   lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
>   test/MC/Sparc/sparc-alu-instructions.s
>
> Index: test/MC/Sparc/sparc-alu-instructions.s
> ===================================================================
> --- test/MC/Sparc/sparc-alu-instructions.s
> +++ test/MC/Sparc/sparc-alu-instructions.s
> @@ -126,3 +126,7 @@
>
>          ! CHECK:  tsubcctv %g2, %g1, %g3          ! encoding:
> [0x87,0x18,0x80,0x01]
>          tsubcctv %g2, %g1, %g3
> +
> +        ! "%0" is a synonym for "%g0" and so on
> +        ! CHECK:   mov  %g0, %i7                 ! encoding:
> [0xbe,0x10,0x00,0x00]
> +        mov %0, %31
> Index: lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
> ===================================================================
> --- lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
> +++ lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
> @@ -1023,6 +1023,19 @@
>        return true;
>      }
>    }
> +  // For compatibility with other assemblers, %0 through %31 refer to
> integer
> +  // registers without subdividing them into globals,locals,outs,ins.
> +  // Strictly speaking, the valid spellings exclude alternative ways of
> +  // writing the decimal integers, but the lexer doesn't know that.
> +  if (Tok.is(AsmToken::Integer)) {
> +    intVal = Tok.getIntVal();
> +    // The size() check rejects "%001", "%0b1", "%0x1" as putative
> spellings.
> +    if (intVal >= 0 && intVal < 32 && Tok.getString().size()<= 2) {
> +        RegNo = IntRegs[intVal];
> +        RegKind = SparcOperand::rk_IntReg;
> +        return true;
> +    }
> +  }
>    return false;
>  }
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150821/e3dbde87/attachment.html>


More information about the llvm-commits mailing list