mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-18 12:25:47 +00:00
Refactor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148131 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -48,6 +48,7 @@ private:
|
|||||||
X86Operand *ParseOperand();
|
X86Operand *ParseOperand();
|
||||||
X86Operand *ParseATTOperand();
|
X86Operand *ParseATTOperand();
|
||||||
X86Operand *ParseIntelOperand();
|
X86Operand *ParseIntelOperand();
|
||||||
|
X86Operand *ParseIntelMemOperand(StringRef TokenString, unsigned Size);
|
||||||
X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
|
X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
|
||||||
|
|
||||||
bool ParseDirectiveWord(unsigned Size, SMLoc L);
|
bool ParseDirectiveWord(unsigned Size, SMLoc L);
|
||||||
@@ -573,32 +574,20 @@ static bool isIntelMemOperand(StringRef OpStr, unsigned &Size) {
|
|||||||
return Size != 0;
|
return Size != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
X86Operand *X86AsmParser::ParseIntelOperand() {
|
/// ParseIntelMemOperand - Parse intel style memory operand.
|
||||||
|
X86Operand *X86AsmParser::ParseIntelMemOperand(StringRef TokenString,
|
||||||
const AsmToken &Tok = Parser.getTok();
|
unsigned Size) {
|
||||||
SMLoc Start = Parser.getTok().getLoc(), End;
|
SMLoc Start = Parser.getTok().getLoc(), End;
|
||||||
|
|
||||||
// register
|
|
||||||
if(unsigned RegNo = getIntelRegisterOperand(Tok.getString())) {
|
|
||||||
Parser.Lex();
|
|
||||||
End = Parser.getTok().getLoc();
|
|
||||||
return X86Operand::CreateReg(RegNo, Start, End);
|
|
||||||
}
|
|
||||||
|
|
||||||
// mem operand
|
|
||||||
unsigned SegReg = 0, BaseReg = 0, IndexReg = 0, Scale = 1;
|
unsigned SegReg = 0, BaseReg = 0, IndexReg = 0, Scale = 1;
|
||||||
StringRef OpStr = Tok.getString();
|
|
||||||
unsigned Size = 0;
|
|
||||||
if (isIntelMemOperand(OpStr, Size)) {
|
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
if (Tok.getString() == "PTR")
|
if (TokenString == "PTR")
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
else {
|
else {
|
||||||
Error(Start, "unexpected token!");
|
Error(Start, "unexpected token!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tok.getString() == "[")
|
if (TokenString == "[")
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
else {
|
else {
|
||||||
Error(Start, "unexpected token!");
|
Error(Start, "unexpected token!");
|
||||||
@@ -606,7 +595,7 @@ X86Operand *X86AsmParser::ParseIntelOperand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SMLoc LParenLoc = Parser.getTok().getLoc();
|
SMLoc LParenLoc = Parser.getTok().getLoc();
|
||||||
BaseReg = getIntelRegisterOperand(Tok.getString());
|
BaseReg = getIntelRegisterOperand(TokenString);
|
||||||
if (BaseReg == 0) {
|
if (BaseReg == 0) {
|
||||||
Error(LParenLoc, "unexpected token!");
|
Error(LParenLoc, "unexpected token!");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -616,7 +605,7 @@ X86Operand *X86AsmParser::ParseIntelOperand() {
|
|||||||
SMLoc ExprEnd;
|
SMLoc ExprEnd;
|
||||||
if (getParser().ParseExpression(Disp, ExprEnd)) return 0;
|
if (getParser().ParseExpression(Disp, ExprEnd)) return 0;
|
||||||
End = Parser.getTok().getLoc();
|
End = Parser.getTok().getLoc();
|
||||||
if (Tok.getString() == "]")
|
if (TokenString == "]")
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
if (BaseReg == 0) {
|
if (BaseReg == 0) {
|
||||||
Error(End, "unexpected token!");
|
Error(End, "unexpected token!");
|
||||||
@@ -626,6 +615,23 @@ X86Operand *X86AsmParser::ParseIntelOperand() {
|
|||||||
Start, End, Size);
|
Start, End, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
X86Operand *X86AsmParser::ParseIntelOperand() {
|
||||||
|
|
||||||
|
StringRef TokenString = Parser.getTok().getString();
|
||||||
|
SMLoc Start = Parser.getTok().getLoc(), End;
|
||||||
|
|
||||||
|
// register
|
||||||
|
if(unsigned RegNo = getIntelRegisterOperand(TokenString)) {
|
||||||
|
Parser.Lex();
|
||||||
|
End = Parser.getTok().getLoc();
|
||||||
|
return X86Operand::CreateReg(RegNo, Start, End);
|
||||||
|
}
|
||||||
|
|
||||||
|
// mem operand
|
||||||
|
unsigned Size = 0;
|
||||||
|
if (isIntelMemOperand(TokenString, Size))
|
||||||
|
ParseIntelMemOperand(TokenString, Size);
|
||||||
|
|
||||||
// immediate.
|
// immediate.
|
||||||
const MCExpr *Val;
|
const MCExpr *Val;
|
||||||
if (!getParser().ParseExpression(Val, End)) {
|
if (!getParser().ParseExpression(Val, End)) {
|
||||||
|
Reference in New Issue
Block a user