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; } 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