mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Implement x86 asm parsing support for %st and %st(4)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95634 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ddea94a819
commit
e16b0fc3cb
@ -292,6 +292,41 @@ bool X86ATTAsmParser::ParseRegister(unsigned &RegNo,
|
||||
// validation later, so maybe there is no need for this here.
|
||||
RegNo = MatchRegisterName(Tok.getString());
|
||||
|
||||
// Parse %st(1) and "%st" as "%st(0)"
|
||||
if (RegNo == 0 && Tok.getString() == "st") {
|
||||
RegNo = X86::ST0;
|
||||
EndLoc = Tok.getLoc();
|
||||
Parser.Lex(); // Eat 'st'
|
||||
|
||||
// Check to see if we have '(4)' after %st.
|
||||
if (getLexer().isNot(AsmToken::LParen))
|
||||
return false;
|
||||
// Lex the paren.
|
||||
getParser().Lex();
|
||||
|
||||
const AsmToken &IntTok = Parser.getTok();
|
||||
if (IntTok.isNot(AsmToken::Integer))
|
||||
return Error(IntTok.getLoc(), "expected stack index");
|
||||
switch (IntTok.getIntVal()) {
|
||||
case 0: RegNo = X86::ST0; break;
|
||||
case 1: RegNo = X86::ST1; break;
|
||||
case 2: RegNo = X86::ST2; break;
|
||||
case 3: RegNo = X86::ST3; break;
|
||||
case 4: RegNo = X86::ST4; break;
|
||||
case 5: RegNo = X86::ST5; break;
|
||||
case 6: RegNo = X86::ST6; break;
|
||||
case 7: RegNo = X86::ST7; break;
|
||||
default: return Error(IntTok.getLoc(), "invalid stack index");
|
||||
}
|
||||
|
||||
if (getParser().Lex().isNot(AsmToken::RParen))
|
||||
return Error(Parser.getTok().getLoc(), "expected ')'");
|
||||
|
||||
EndLoc = Tok.getLoc();
|
||||
Parser.Lex(); // Eat ')'
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RegNo == 0)
|
||||
return Error(Tok.getLoc(), "invalid register name");
|
||||
|
||||
|
@ -136,3 +136,10 @@
|
||||
// CHECK: movb 0(%eax), %al
|
||||
gs;movb 0(%eax), %al
|
||||
|
||||
// CHECK: fadd %st(0)
|
||||
// CHECK: fadd %st(1)
|
||||
// CHECK: fadd %st(7)
|
||||
|
||||
fadd %st(0)
|
||||
fadd %st(1)
|
||||
fadd %st(7)
|
||||
|
Loading…
Reference in New Issue
Block a user