mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-20 14:29:27 +00:00
Promoted the getTok() method to MCAsmParser so that
the two token accessor functions are declared consistently. Modified the clients of MCAsmParser to reflect this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93916 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1c8183df7f
commit
18b8323de7
@ -55,6 +55,9 @@ public:
|
|||||||
/// inclusion first.
|
/// inclusion first.
|
||||||
virtual const AsmToken &Lex() = 0;
|
virtual const AsmToken &Lex() = 0;
|
||||||
|
|
||||||
|
/// getTok - Get the current AsmToken from the stream.
|
||||||
|
const AsmToken &getTok();
|
||||||
|
|
||||||
/// ParseExpression - Parse an arbitrary expression.
|
/// ParseExpression - Parse an arbitrary expression.
|
||||||
///
|
///
|
||||||
/// @param Res - The value of the expression. The result is undefined
|
/// @param Res - The value of the expression. The result is undefined
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/MC/MCAsmParser.h"
|
#include "llvm/MC/MCAsmParser.h"
|
||||||
|
#include "llvm/MC/MCAsmLexer.h"
|
||||||
#include "llvm/MC/MCParsedAsmOperand.h"
|
#include "llvm/MC/MCParsedAsmOperand.h"
|
||||||
#include "llvm/Support/SourceMgr.h"
|
#include "llvm/Support/SourceMgr.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -18,12 +19,15 @@ MCAsmParser::MCAsmParser() {
|
|||||||
MCAsmParser::~MCAsmParser() {
|
MCAsmParser::~MCAsmParser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AsmToken &MCAsmParser::getTok() {
|
||||||
|
return getLexer().getTok();
|
||||||
|
}
|
||||||
|
|
||||||
bool MCAsmParser::ParseExpression(const MCExpr *&Res) {
|
bool MCAsmParser::ParseExpression(const MCExpr *&Res) {
|
||||||
SMLoc L;
|
SMLoc L;
|
||||||
return ParseExpression(Res, L);
|
return ParseExpression(Res, L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// getStartLoc - Get the location of the first token of this operand.
|
/// getStartLoc - Get the location of the first token of this operand.
|
||||||
SMLoc MCParsedAsmOperand::getStartLoc() const { return SMLoc(); }
|
SMLoc MCParsedAsmOperand::getStartLoc() const { return SMLoc(); }
|
||||||
SMLoc MCParsedAsmOperand::getEndLoc() const { return SMLoc(); }
|
SMLoc MCParsedAsmOperand::getEndLoc() const { return SMLoc(); }
|
||||||
|
@ -222,7 +222,7 @@ struct ARMOperand : public MCParsedAsmOperand {
|
|||||||
/// TODO this is likely to change to allow different register types and or to
|
/// TODO this is likely to change to allow different register types and or to
|
||||||
/// parse for a specific register type.
|
/// parse for a specific register type.
|
||||||
bool ARMAsmParser::MaybeParseRegister(ARMOperand &Op, bool ParseWriteBack) {
|
bool ARMAsmParser::MaybeParseRegister(ARMOperand &Op, bool ParseWriteBack) {
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
assert(Tok.is(AsmToken::Identifier) && "Token is not an Identifier");
|
assert(Tok.is(AsmToken::Identifier) && "Token is not an Identifier");
|
||||||
|
|
||||||
// FIXME: Validate register for the current architecture; we have to do
|
// FIXME: Validate register for the current architecture; we have to do
|
||||||
@ -236,7 +236,7 @@ bool ARMAsmParser::MaybeParseRegister(ARMOperand &Op, bool ParseWriteBack) {
|
|||||||
|
|
||||||
bool Writeback = false;
|
bool Writeback = false;
|
||||||
if (ParseWriteBack) {
|
if (ParseWriteBack) {
|
||||||
const AsmToken &ExclaimTok = getLexer().getTok();
|
const AsmToken &ExclaimTok = Parser.getTok();
|
||||||
if (ExclaimTok.is(AsmToken::Exclaim)) {
|
if (ExclaimTok.is(AsmToken::Exclaim)) {
|
||||||
Writeback = true;
|
Writeback = true;
|
||||||
Parser.Lex(); // Eat exclaim token
|
Parser.Lex(); // Eat exclaim token
|
||||||
@ -251,11 +251,11 @@ bool ARMAsmParser::MaybeParseRegister(ARMOperand &Op, bool ParseWriteBack) {
|
|||||||
/// Parse a register list, return false if successful else return true or an
|
/// Parse a register list, return false if successful else return true or an
|
||||||
/// error. The first token must be a '{' when called.
|
/// error. The first token must be a '{' when called.
|
||||||
bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) {
|
bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) {
|
||||||
assert(getLexer().getTok().is(AsmToken::LCurly) &&
|
assert(Parser.getTok().is(AsmToken::LCurly) &&
|
||||||
"Token is not an Left Curly Brace");
|
"Token is not an Left Curly Brace");
|
||||||
Parser.Lex(); // Eat left curly brace token.
|
Parser.Lex(); // Eat left curly brace token.
|
||||||
|
|
||||||
const AsmToken &RegTok = getLexer().getTok();
|
const AsmToken &RegTok = Parser.getTok();
|
||||||
SMLoc RegLoc = RegTok.getLoc();
|
SMLoc RegLoc = RegTok.getLoc();
|
||||||
if (RegTok.isNot(AsmToken::Identifier))
|
if (RegTok.isNot(AsmToken::Identifier))
|
||||||
return Error(RegLoc, "register expected");
|
return Error(RegLoc, "register expected");
|
||||||
@ -267,10 +267,10 @@ bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) {
|
|||||||
|
|
||||||
int HighRegNum = RegNum;
|
int HighRegNum = RegNum;
|
||||||
// TODO ranges like "{Rn-Rm}"
|
// TODO ranges like "{Rn-Rm}"
|
||||||
while (getLexer().getTok().is(AsmToken::Comma)) {
|
while (Parser.getTok().is(AsmToken::Comma)) {
|
||||||
Parser.Lex(); // Eat comma token.
|
Parser.Lex(); // Eat comma token.
|
||||||
|
|
||||||
const AsmToken &RegTok = getLexer().getTok();
|
const AsmToken &RegTok = Parser.getTok();
|
||||||
SMLoc RegLoc = RegTok.getLoc();
|
SMLoc RegLoc = RegTok.getLoc();
|
||||||
if (RegTok.isNot(AsmToken::Identifier))
|
if (RegTok.isNot(AsmToken::Identifier))
|
||||||
return Error(RegLoc, "register expected");
|
return Error(RegLoc, "register expected");
|
||||||
@ -287,7 +287,7 @@ bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) {
|
|||||||
|
|
||||||
Parser.Lex(); // Eat identifier token.
|
Parser.Lex(); // Eat identifier token.
|
||||||
}
|
}
|
||||||
const AsmToken &RCurlyTok = getLexer().getTok();
|
const AsmToken &RCurlyTok = Parser.getTok();
|
||||||
if (RCurlyTok.isNot(AsmToken::RCurly))
|
if (RCurlyTok.isNot(AsmToken::RCurly))
|
||||||
return Error(RCurlyTok.getLoc(), "'}' expected");
|
return Error(RCurlyTok.getLoc(), "'}' expected");
|
||||||
Parser.Lex(); // Eat left curly brace token.
|
Parser.Lex(); // Eat left curly brace token.
|
||||||
@ -300,11 +300,11 @@ bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) {
|
|||||||
/// TODO Only preindexing and postindexing addressing are started, unindexed
|
/// TODO Only preindexing and postindexing addressing are started, unindexed
|
||||||
/// with option, etc are still to do.
|
/// with option, etc are still to do.
|
||||||
bool ARMAsmParser::ParseMemory(ARMOperand &Op) {
|
bool ARMAsmParser::ParseMemory(ARMOperand &Op) {
|
||||||
assert(getLexer().getTok().is(AsmToken::LBrac) &&
|
assert(Parser.getTok().is(AsmToken::LBrac) &&
|
||||||
"Token is not an Left Bracket");
|
"Token is not an Left Bracket");
|
||||||
Parser.Lex(); // Eat left bracket token.
|
Parser.Lex(); // Eat left bracket token.
|
||||||
|
|
||||||
const AsmToken &BaseRegTok = getLexer().getTok();
|
const AsmToken &BaseRegTok = Parser.getTok();
|
||||||
if (BaseRegTok.isNot(AsmToken::Identifier))
|
if (BaseRegTok.isNot(AsmToken::Identifier))
|
||||||
return Error(BaseRegTok.getLoc(), "register expected");
|
return Error(BaseRegTok.getLoc(), "register expected");
|
||||||
if (MaybeParseRegister(Op, false))
|
if (MaybeParseRegister(Op, false))
|
||||||
@ -319,7 +319,7 @@ bool ARMAsmParser::ParseMemory(ARMOperand &Op) {
|
|||||||
|
|
||||||
// First look for preindexed address forms, that is after the "[Rn" we now
|
// First look for preindexed address forms, that is after the "[Rn" we now
|
||||||
// have to see if the next token is a comma.
|
// have to see if the next token is a comma.
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
if (Tok.is(AsmToken::Comma)) {
|
if (Tok.is(AsmToken::Comma)) {
|
||||||
Preindexed = true;
|
Preindexed = true;
|
||||||
Parser.Lex(); // Eat comma token.
|
Parser.Lex(); // Eat comma token.
|
||||||
@ -331,12 +331,12 @@ bool ARMAsmParser::ParseMemory(ARMOperand &Op) {
|
|||||||
if(ParseMemoryOffsetReg(Negative, OffsetRegShifted, ShiftType, ShiftAmount,
|
if(ParseMemoryOffsetReg(Negative, OffsetRegShifted, ShiftType, ShiftAmount,
|
||||||
Offset, OffsetIsReg, OffsetRegNum))
|
Offset, OffsetIsReg, OffsetRegNum))
|
||||||
return true;
|
return true;
|
||||||
const AsmToken &RBracTok = getLexer().getTok();
|
const AsmToken &RBracTok = Parser.getTok();
|
||||||
if (RBracTok.isNot(AsmToken::RBrac))
|
if (RBracTok.isNot(AsmToken::RBrac))
|
||||||
return Error(RBracTok.getLoc(), "']' expected");
|
return Error(RBracTok.getLoc(), "']' expected");
|
||||||
Parser.Lex(); // Eat right bracket token.
|
Parser.Lex(); // Eat right bracket token.
|
||||||
|
|
||||||
const AsmToken &ExclaimTok = getLexer().getTok();
|
const AsmToken &ExclaimTok = Parser.getTok();
|
||||||
if (ExclaimTok.is(AsmToken::Exclaim)) {
|
if (ExclaimTok.is(AsmToken::Exclaim)) {
|
||||||
Writeback = true;
|
Writeback = true;
|
||||||
Parser.Lex(); // Eat exclaim token
|
Parser.Lex(); // Eat exclaim token
|
||||||
@ -360,7 +360,7 @@ bool ARMAsmParser::ParseMemory(ARMOperand &Op) {
|
|||||||
const MCExpr *ShiftAmount;
|
const MCExpr *ShiftAmount;
|
||||||
const MCExpr *Offset;
|
const MCExpr *Offset;
|
||||||
|
|
||||||
const AsmToken &NextTok = getLexer().getTok();
|
const AsmToken &NextTok = Parser.getTok();
|
||||||
if (NextTok.isNot(AsmToken::EndOfStatement)) {
|
if (NextTok.isNot(AsmToken::EndOfStatement)) {
|
||||||
if (NextTok.isNot(AsmToken::Comma))
|
if (NextTok.isNot(AsmToken::Comma))
|
||||||
return Error(NextTok.getLoc(), "',' expected");
|
return Error(NextTok.getLoc(), "',' expected");
|
||||||
@ -398,7 +398,7 @@ bool ARMAsmParser::ParseMemoryOffsetReg(bool &Negative,
|
|||||||
OffsetRegShifted = false;
|
OffsetRegShifted = false;
|
||||||
OffsetIsReg = false;
|
OffsetIsReg = false;
|
||||||
OffsetRegNum = -1;
|
OffsetRegNum = -1;
|
||||||
const AsmToken &NextTok = getLexer().getTok();
|
const AsmToken &NextTok = Parser.getTok();
|
||||||
if (NextTok.is(AsmToken::Plus))
|
if (NextTok.is(AsmToken::Plus))
|
||||||
Parser.Lex(); // Eat plus token.
|
Parser.Lex(); // Eat plus token.
|
||||||
else if (NextTok.is(AsmToken::Minus)) {
|
else if (NextTok.is(AsmToken::Minus)) {
|
||||||
@ -406,7 +406,7 @@ bool ARMAsmParser::ParseMemoryOffsetReg(bool &Negative,
|
|||||||
Parser.Lex(); // Eat minus token
|
Parser.Lex(); // Eat minus token
|
||||||
}
|
}
|
||||||
// See if there is a register following the "[Rn," or "[Rn]," we have so far.
|
// See if there is a register following the "[Rn," or "[Rn]," we have so far.
|
||||||
const AsmToken &OffsetRegTok = getLexer().getTok();
|
const AsmToken &OffsetRegTok = Parser.getTok();
|
||||||
if (OffsetRegTok.is(AsmToken::Identifier)) {
|
if (OffsetRegTok.is(AsmToken::Identifier)) {
|
||||||
OffsetIsReg = !MaybeParseRegister(Op, false);
|
OffsetIsReg = !MaybeParseRegister(Op, false);
|
||||||
if (OffsetIsReg)
|
if (OffsetIsReg)
|
||||||
@ -415,11 +415,11 @@ bool ARMAsmParser::ParseMemoryOffsetReg(bool &Negative,
|
|||||||
// If we parsed a register as the offset then their can be a shift after that
|
// If we parsed a register as the offset then their can be a shift after that
|
||||||
if (OffsetRegNum != -1) {
|
if (OffsetRegNum != -1) {
|
||||||
// Look for a comma then a shift
|
// Look for a comma then a shift
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
if (Tok.is(AsmToken::Comma)) {
|
if (Tok.is(AsmToken::Comma)) {
|
||||||
Parser.Lex(); // Eat comma token.
|
Parser.Lex(); // Eat comma token.
|
||||||
|
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
if (ParseShift(ShiftType, ShiftAmount))
|
if (ParseShift(ShiftType, ShiftAmount))
|
||||||
return Error(Tok.getLoc(), "shift expected");
|
return Error(Tok.getLoc(), "shift expected");
|
||||||
OffsetRegShifted = true;
|
OffsetRegShifted = true;
|
||||||
@ -427,7 +427,7 @@ bool ARMAsmParser::ParseMemoryOffsetReg(bool &Negative,
|
|||||||
}
|
}
|
||||||
else { // the "[Rn," or "[Rn,]" we have so far was not followed by "Rm"
|
else { // the "[Rn," or "[Rn,]" we have so far was not followed by "Rm"
|
||||||
// Look for #offset following the "[Rn," or "[Rn],"
|
// Look for #offset following the "[Rn," or "[Rn],"
|
||||||
const AsmToken &HashTok = getLexer().getTok();
|
const AsmToken &HashTok = Parser.getTok();
|
||||||
if (HashTok.isNot(AsmToken::Hash))
|
if (HashTok.isNot(AsmToken::Hash))
|
||||||
return Error(HashTok.getLoc(), "'#' expected");
|
return Error(HashTok.getLoc(), "'#' expected");
|
||||||
Parser.Lex(); // Eat hash token.
|
Parser.Lex(); // Eat hash token.
|
||||||
@ -443,7 +443,7 @@ bool ARMAsmParser::ParseMemoryOffsetReg(bool &Negative,
|
|||||||
/// rrx
|
/// rrx
|
||||||
/// and returns true if it parses a shift otherwise it returns false.
|
/// and returns true if it parses a shift otherwise it returns false.
|
||||||
bool ARMAsmParser::ParseShift(ShiftType &St, const MCExpr *&ShiftAmount) {
|
bool ARMAsmParser::ParseShift(ShiftType &St, const MCExpr *&ShiftAmount) {
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
if (Tok.isNot(AsmToken::Identifier))
|
if (Tok.isNot(AsmToken::Identifier))
|
||||||
return true;
|
return true;
|
||||||
const StringRef &ShiftName = Tok.getString();
|
const StringRef &ShiftName = Tok.getString();
|
||||||
@ -466,7 +466,7 @@ bool ARMAsmParser::ParseShift(ShiftType &St, const MCExpr *&ShiftAmount) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Otherwise, there must be a '#' and a shift amount.
|
// Otherwise, there must be a '#' and a shift amount.
|
||||||
const AsmToken &HashTok = getLexer().getTok();
|
const AsmToken &HashTok = Parser.getTok();
|
||||||
if (HashTok.isNot(AsmToken::Hash))
|
if (HashTok.isNot(AsmToken::Hash))
|
||||||
return Error(HashTok.getLoc(), "'#' expected");
|
return Error(HashTok.getLoc(), "'#' expected");
|
||||||
Parser.Lex(); // Eat hash token.
|
Parser.Lex(); // Eat hash token.
|
||||||
@ -576,7 +576,7 @@ bool ARMAsmParser::ParseOperand(ARMOperand &Op) {
|
|||||||
Op = ARMOperand::CreateImm(ImmVal);
|
Op = ARMOperand::CreateImm(ImmVal);
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return Error(getLexer().getTok().getLoc(), "unexpected token in operand");
|
return Error(Parser.getTok().getLoc(), "unexpected token in operand");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,7 +585,7 @@ bool ARMAsmParser::ParseInstruction(const StringRef &Name, SMLoc NameLoc,
|
|||||||
SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||||
Operands.push_back(new ARMOperand(ARMOperand::CreateToken(Name)));
|
Operands.push_back(new ARMOperand(ARMOperand::CreateToken(Name)));
|
||||||
|
|
||||||
SMLoc Loc = getLexer().getTok().getLoc();
|
SMLoc Loc = Parser.getTok().getLoc();
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||||
|
|
||||||
// Read the first operand.
|
// Read the first operand.
|
||||||
@ -661,10 +661,10 @@ bool ARMAsmParser::ParseDirectiveThumb(SMLoc L) {
|
|||||||
/// ParseDirectiveThumbFunc
|
/// ParseDirectiveThumbFunc
|
||||||
/// ::= .thumbfunc symbol_name
|
/// ::= .thumbfunc symbol_name
|
||||||
bool ARMAsmParser::ParseDirectiveThumbFunc(SMLoc L) {
|
bool ARMAsmParser::ParseDirectiveThumbFunc(SMLoc L) {
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String))
|
if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String))
|
||||||
return Error(L, "unexpected token in .syntax directive");
|
return Error(L, "unexpected token in .syntax directive");
|
||||||
StringRef ATTRIBUTE_UNUSED SymbolName = getLexer().getTok().getIdentifier();
|
StringRef ATTRIBUTE_UNUSED SymbolName = Parser.getTok().getIdentifier();
|
||||||
Parser.Lex(); // Consume the identifier token.
|
Parser.Lex(); // Consume the identifier token.
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
@ -679,7 +679,7 @@ bool ARMAsmParser::ParseDirectiveThumbFunc(SMLoc L) {
|
|||||||
/// ParseDirectiveSyntax
|
/// ParseDirectiveSyntax
|
||||||
/// ::= .syntax unified | divided
|
/// ::= .syntax unified | divided
|
||||||
bool ARMAsmParser::ParseDirectiveSyntax(SMLoc L) {
|
bool ARMAsmParser::ParseDirectiveSyntax(SMLoc L) {
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
if (Tok.isNot(AsmToken::Identifier))
|
if (Tok.isNot(AsmToken::Identifier))
|
||||||
return Error(L, "unexpected token in .syntax directive");
|
return Error(L, "unexpected token in .syntax directive");
|
||||||
const StringRef &Mode = Tok.getString();
|
const StringRef &Mode = Tok.getString();
|
||||||
@ -696,7 +696,7 @@ bool ARMAsmParser::ParseDirectiveSyntax(SMLoc L) {
|
|||||||
return Error(L, "unrecognized syntax mode in .syntax directive");
|
return Error(L, "unrecognized syntax mode in .syntax directive");
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return Error(getLexer().getTok().getLoc(), "unexpected token in directive");
|
return Error(Parser.getTok().getLoc(), "unexpected token in directive");
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
|
|
||||||
// TODO tell the MC streamer the mode
|
// TODO tell the MC streamer the mode
|
||||||
@ -707,10 +707,10 @@ bool ARMAsmParser::ParseDirectiveSyntax(SMLoc L) {
|
|||||||
/// ParseDirectiveCode
|
/// ParseDirectiveCode
|
||||||
/// ::= .code 16 | 32
|
/// ::= .code 16 | 32
|
||||||
bool ARMAsmParser::ParseDirectiveCode(SMLoc L) {
|
bool ARMAsmParser::ParseDirectiveCode(SMLoc L) {
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
if (Tok.isNot(AsmToken::Integer))
|
if (Tok.isNot(AsmToken::Integer))
|
||||||
return Error(L, "unexpected token in .code directive");
|
return Error(L, "unexpected token in .code directive");
|
||||||
int64_t Val = getLexer().getTok().getIntVal();
|
int64_t Val = Parser.getTok().getIntVal();
|
||||||
bool thumb_mode;
|
bool thumb_mode;
|
||||||
if (Val == 16) {
|
if (Val == 16) {
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
@ -724,7 +724,7 @@ bool ARMAsmParser::ParseDirectiveCode(SMLoc L) {
|
|||||||
return Error(L, "invalid operand to .code directive");
|
return Error(L, "invalid operand to .code directive");
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return Error(getLexer().getTok().getLoc(), "unexpected token in directive");
|
return Error(Parser.getTok().getLoc(), "unexpected token in directive");
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
|
|
||||||
// TODO tell the MC streamer the mode
|
// TODO tell the MC streamer the mode
|
||||||
|
@ -245,12 +245,12 @@ struct X86Operand : public MCParsedAsmOperand {
|
|||||||
bool X86ATTAsmParser::ParseRegister(unsigned &RegNo,
|
bool X86ATTAsmParser::ParseRegister(unsigned &RegNo,
|
||||||
SMLoc &StartLoc, SMLoc &EndLoc) {
|
SMLoc &StartLoc, SMLoc &EndLoc) {
|
||||||
RegNo = 0;
|
RegNo = 0;
|
||||||
const AsmToken &TokPercent = getLexer().getTok();
|
const AsmToken &TokPercent = Parser.getTok();
|
||||||
assert(TokPercent.is(AsmToken::Percent) && "Invalid token kind!");
|
assert(TokPercent.is(AsmToken::Percent) && "Invalid token kind!");
|
||||||
StartLoc = TokPercent.getLoc();
|
StartLoc = TokPercent.getLoc();
|
||||||
Parser.Lex(); // Eat percent token.
|
Parser.Lex(); // Eat percent token.
|
||||||
|
|
||||||
const AsmToken &Tok = getLexer().getTok();
|
const AsmToken &Tok = Parser.getTok();
|
||||||
if (Tok.isNot(AsmToken::Identifier))
|
if (Tok.isNot(AsmToken::Identifier))
|
||||||
return Error(Tok.getLoc(), "invalid register name");
|
return Error(Tok.getLoc(), "invalid register name");
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ X86Operand *X86ATTAsmParser::ParseOperand() {
|
|||||||
}
|
}
|
||||||
case AsmToken::Dollar: {
|
case AsmToken::Dollar: {
|
||||||
// $42 -> immediate.
|
// $42 -> immediate.
|
||||||
SMLoc Start = getLexer().getTok().getLoc(), End;
|
SMLoc Start = Parser.getTok().getLoc(), End;
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
const MCExpr *Val;
|
const MCExpr *Val;
|
||||||
if (getParser().ParseExpression(Val, End))
|
if (getParser().ParseExpression(Val, End))
|
||||||
@ -291,7 +291,7 @@ X86Operand *X86ATTAsmParser::ParseOperand() {
|
|||||||
|
|
||||||
/// ParseMemOperand: segment: disp(basereg, indexreg, scale)
|
/// ParseMemOperand: segment: disp(basereg, indexreg, scale)
|
||||||
X86Operand *X86ATTAsmParser::ParseMemOperand() {
|
X86Operand *X86ATTAsmParser::ParseMemOperand() {
|
||||||
SMLoc MemStart = getLexer().getTok().getLoc();
|
SMLoc MemStart = Parser.getTok().getLoc();
|
||||||
|
|
||||||
// FIXME: If SegReg ':' (e.g. %gs:), eat and remember.
|
// FIXME: If SegReg ':' (e.g. %gs:), eat and remember.
|
||||||
unsigned SegReg = 0;
|
unsigned SegReg = 0;
|
||||||
@ -319,7 +319,7 @@ X86Operand *X86ATTAsmParser::ParseMemOperand() {
|
|||||||
} else {
|
} else {
|
||||||
// Okay, we have a '('. We don't know if this is an expression or not, but
|
// Okay, we have a '('. We don't know if this is an expression or not, but
|
||||||
// so we have to eat the ( to see beyond it.
|
// so we have to eat the ( to see beyond it.
|
||||||
SMLoc LParenLoc = getLexer().getTok().getLoc();
|
SMLoc LParenLoc = Parser.getTok().getLoc();
|
||||||
Parser.Lex(); // Eat the '('.
|
Parser.Lex(); // Eat the '('.
|
||||||
|
|
||||||
if (getLexer().is(AsmToken::Percent) || getLexer().is(AsmToken::Comma)) {
|
if (getLexer().is(AsmToken::Percent) || getLexer().is(AsmToken::Comma)) {
|
||||||
@ -372,14 +372,14 @@ X86Operand *X86ATTAsmParser::ParseMemOperand() {
|
|||||||
// Parse the scale amount:
|
// Parse the scale amount:
|
||||||
// ::= ',' [scale-expression]
|
// ::= ',' [scale-expression]
|
||||||
if (getLexer().isNot(AsmToken::Comma)) {
|
if (getLexer().isNot(AsmToken::Comma)) {
|
||||||
Error(getLexer().getTok().getLoc(),
|
Error(Parser.getTok().getLoc(),
|
||||||
"expected comma in scale expression");
|
"expected comma in scale expression");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Parser.Lex(); // Eat the comma.
|
Parser.Lex(); // Eat the comma.
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::RParen)) {
|
if (getLexer().isNot(AsmToken::RParen)) {
|
||||||
SMLoc Loc = getLexer().getTok().getLoc();
|
SMLoc Loc = Parser.getTok().getLoc();
|
||||||
|
|
||||||
int64_t ScaleVal;
|
int64_t ScaleVal;
|
||||||
if (getParser().ParseAbsoluteExpression(ScaleVal))
|
if (getParser().ParseAbsoluteExpression(ScaleVal))
|
||||||
@ -396,7 +396,7 @@ X86Operand *X86ATTAsmParser::ParseMemOperand() {
|
|||||||
} else if (getLexer().isNot(AsmToken::RParen)) {
|
} else if (getLexer().isNot(AsmToken::RParen)) {
|
||||||
// Otherwise we have the unsupported form of a scale amount without an
|
// Otherwise we have the unsupported form of a scale amount without an
|
||||||
// index.
|
// index.
|
||||||
SMLoc Loc = getLexer().getTok().getLoc();
|
SMLoc Loc = Parser.getTok().getLoc();
|
||||||
|
|
||||||
int64_t Value;
|
int64_t Value;
|
||||||
if (getParser().ParseAbsoluteExpression(Value))
|
if (getParser().ParseAbsoluteExpression(Value))
|
||||||
@ -409,10 +409,10 @@ X86Operand *X86ATTAsmParser::ParseMemOperand() {
|
|||||||
|
|
||||||
// Ok, we've eaten the memory operand, verify we have a ')' and eat it too.
|
// Ok, we've eaten the memory operand, verify we have a ')' and eat it too.
|
||||||
if (getLexer().isNot(AsmToken::RParen)) {
|
if (getLexer().isNot(AsmToken::RParen)) {
|
||||||
Error(getLexer().getTok().getLoc(), "unexpected token in memory operand");
|
Error(Parser.getTok().getLoc(), "unexpected token in memory operand");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SMLoc MemEnd = getLexer().getTok().getLoc();
|
SMLoc MemEnd = Parser.getTok().getLoc();
|
||||||
Parser.Lex(); // Eat the ')'.
|
Parser.Lex(); // Eat the ')'.
|
||||||
|
|
||||||
return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale,
|
return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale,
|
||||||
@ -429,7 +429,7 @@ ParseInstruction(const StringRef &Name, SMLoc NameLoc,
|
|||||||
|
|
||||||
// Parse '*' modifier.
|
// Parse '*' modifier.
|
||||||
if (getLexer().is(AsmToken::Star)) {
|
if (getLexer().is(AsmToken::Star)) {
|
||||||
SMLoc Loc = getLexer().getTok().getLoc();
|
SMLoc Loc = Parser.getTok().getLoc();
|
||||||
Operands.push_back(X86Operand::CreateToken("*", Loc));
|
Operands.push_back(X86Operand::CreateToken("*", Loc));
|
||||||
Parser.Lex(); // Eat the star.
|
Parser.Lex(); // Eat the star.
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ bool AsmParser::Run() {
|
|||||||
// Handle conditional assembly here before calling ParseStatement()
|
// Handle conditional assembly here before calling ParseStatement()
|
||||||
if (Lexer.getKind() == AsmToken::Identifier) {
|
if (Lexer.getKind() == AsmToken::Identifier) {
|
||||||
// If we have an identifier, handle it as the key symbol.
|
// If we have an identifier, handle it as the key symbol.
|
||||||
AsmToken ID = Lexer.getTok();
|
AsmToken ID = getTok();
|
||||||
SMLoc IDLoc = ID.getLoc();
|
SMLoc IDLoc = ID.getLoc();
|
||||||
StringRef IDVal = ID.getString();
|
StringRef IDVal = ID.getString();
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
case AsmToken::String:
|
case AsmToken::String:
|
||||||
case AsmToken::Identifier: {
|
case AsmToken::Identifier: {
|
||||||
// This is a symbol reference.
|
// This is a symbol reference.
|
||||||
MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier());
|
MCSymbol *Sym = CreateSymbol(getTok().getIdentifier());
|
||||||
EndLoc = Lexer.getLoc();
|
EndLoc = Lexer.getLoc();
|
||||||
Lex(); // Eat identifier.
|
Lex(); // Eat identifier.
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case AsmToken::Integer:
|
case AsmToken::Integer:
|
||||||
Res = MCConstantExpr::Create(Lexer.getTok().getIntVal(), getContext());
|
Res = MCConstantExpr::Create(getTok().getIntVal(), getContext());
|
||||||
EndLoc = Lexer.getLoc();
|
EndLoc = Lexer.getLoc();
|
||||||
Lex(); // Eat token.
|
Lex(); // Eat token.
|
||||||
return false;
|
return false;
|
||||||
@ -435,7 +435,7 @@ bool AsmParser::ParseStatement() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Statements always start with an identifier.
|
// Statements always start with an identifier.
|
||||||
AsmToken ID = Lexer.getTok();
|
AsmToken ID = getTok();
|
||||||
SMLoc IDLoc = ID.getLoc();
|
SMLoc IDLoc = ID.getLoc();
|
||||||
StringRef IDVal;
|
StringRef IDVal;
|
||||||
if (ParseIdentifier(IDVal))
|
if (ParseIdentifier(IDVal))
|
||||||
@ -811,7 +811,7 @@ bool AsmParser::ParseIdentifier(StringRef &Res) {
|
|||||||
Lexer.isNot(AsmToken::String))
|
Lexer.isNot(AsmToken::String))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Res = Lexer.getTok().getIdentifier();
|
Res = getTok().getIdentifier();
|
||||||
|
|
||||||
Lex(); // Consume the identifier token.
|
Lex(); // Consume the identifier token.
|
||||||
|
|
||||||
@ -908,7 +908,7 @@ bool AsmParser::ParseEscapedString(std::string &Data) {
|
|||||||
assert(Lexer.is(AsmToken::String) && "Unexpected current token!");
|
assert(Lexer.is(AsmToken::String) && "Unexpected current token!");
|
||||||
|
|
||||||
Data = "";
|
Data = "";
|
||||||
StringRef Str = Lexer.getTok().getStringContents();
|
StringRef Str = getTok().getStringContents();
|
||||||
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
|
||||||
if (Str[i] != '\\') {
|
if (Str[i] != '\\') {
|
||||||
Data += Str[i];
|
Data += Str[i];
|
||||||
@ -1337,7 +1337,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
|
|||||||
|
|
||||||
if (Lexer.isNot(AsmToken::Identifier))
|
if (Lexer.isNot(AsmToken::Identifier))
|
||||||
return TokError("expected segment name after '.zerofill' directive");
|
return TokError("expected segment name after '.zerofill' directive");
|
||||||
StringRef Segment = Lexer.getTok().getString();
|
StringRef Segment = getTok().getString();
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (Lexer.isNot(AsmToken::Comma))
|
if (Lexer.isNot(AsmToken::Comma))
|
||||||
@ -1347,7 +1347,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
|
|||||||
if (Lexer.isNot(AsmToken::Identifier))
|
if (Lexer.isNot(AsmToken::Identifier))
|
||||||
return TokError("expected section name after comma in '.zerofill' "
|
return TokError("expected section name after comma in '.zerofill' "
|
||||||
"directive");
|
"directive");
|
||||||
StringRef Section = Lexer.getTok().getString();
|
StringRef Section = getTok().getString();
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
// If this is the end of the line all that was wanted was to create the
|
// If this is the end of the line all that was wanted was to create the
|
||||||
@ -1369,7 +1369,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
|
|||||||
|
|
||||||
// handle the identifier as the key symbol.
|
// handle the identifier as the key symbol.
|
||||||
SMLoc IDLoc = Lexer.getLoc();
|
SMLoc IDLoc = Lexer.getLoc();
|
||||||
MCSymbol *Sym = CreateSymbol(Lexer.getTok().getString());
|
MCSymbol *Sym = CreateSymbol(getTok().getString());
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (Lexer.isNot(AsmToken::Comma))
|
if (Lexer.isNot(AsmToken::Comma))
|
||||||
@ -1444,7 +1444,7 @@ bool AsmParser::ParseDirectiveAbort() {
|
|||||||
if (Lexer.isNot(AsmToken::String))
|
if (Lexer.isNot(AsmToken::String))
|
||||||
return TokError("expected string in '.abort' directive");
|
return TokError("expected string in '.abort' directive");
|
||||||
|
|
||||||
Str = Lexer.getTok().getString();
|
Str = getTok().getString();
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
}
|
}
|
||||||
@ -1500,7 +1500,7 @@ bool AsmParser::ParseDirectiveInclude() {
|
|||||||
if (Lexer.isNot(AsmToken::String))
|
if (Lexer.isNot(AsmToken::String))
|
||||||
return TokError("expected string in '.include' directive");
|
return TokError("expected string in '.include' directive");
|
||||||
|
|
||||||
std::string Filename = Lexer.getTok().getString();
|
std::string Filename = getTok().getString();
|
||||||
SMLoc IncludeLoc = Lexer.getLoc();
|
SMLoc IncludeLoc = Lexer.getLoc();
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
@ -1664,7 +1664,7 @@ bool AsmParser::ParseDirectiveFile(StringRef, SMLoc DirectiveLoc) {
|
|||||||
// FIXME: I'm not sure what this is.
|
// FIXME: I'm not sure what this is.
|
||||||
int64_t FileNumber = -1;
|
int64_t FileNumber = -1;
|
||||||
if (Lexer.is(AsmToken::Integer)) {
|
if (Lexer.is(AsmToken::Integer)) {
|
||||||
FileNumber = Lexer.getTok().getIntVal();
|
FileNumber = getTok().getIntVal();
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (FileNumber < 1)
|
if (FileNumber < 1)
|
||||||
@ -1674,7 +1674,7 @@ bool AsmParser::ParseDirectiveFile(StringRef, SMLoc DirectiveLoc) {
|
|||||||
if (Lexer.isNot(AsmToken::String))
|
if (Lexer.isNot(AsmToken::String))
|
||||||
return TokError("unexpected token in '.file' directive");
|
return TokError("unexpected token in '.file' directive");
|
||||||
|
|
||||||
StringRef ATTRIBUTE_UNUSED FileName = Lexer.getTok().getString();
|
StringRef ATTRIBUTE_UNUSED FileName = getTok().getString();
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (Lexer.isNot(AsmToken::EndOfStatement))
|
if (Lexer.isNot(AsmToken::EndOfStatement))
|
||||||
@ -1692,7 +1692,7 @@ bool AsmParser::ParseDirectiveLine(StringRef, SMLoc DirectiveLoc) {
|
|||||||
if (Lexer.isNot(AsmToken::Integer))
|
if (Lexer.isNot(AsmToken::Integer))
|
||||||
return TokError("unexpected token in '.line' directive");
|
return TokError("unexpected token in '.line' directive");
|
||||||
|
|
||||||
int64_t LineNumber = Lexer.getTok().getIntVal();
|
int64_t LineNumber = getTok().getIntVal();
|
||||||
(void) LineNumber;
|
(void) LineNumber;
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
@ -1713,7 +1713,7 @@ bool AsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
|
|||||||
return TokError("unexpected token in '.loc' directive");
|
return TokError("unexpected token in '.loc' directive");
|
||||||
|
|
||||||
// FIXME: What are these fields?
|
// FIXME: What are these fields?
|
||||||
int64_t FileNumber = Lexer.getTok().getIntVal();
|
int64_t FileNumber = getTok().getIntVal();
|
||||||
(void) FileNumber;
|
(void) FileNumber;
|
||||||
// FIXME: Validate file.
|
// FIXME: Validate file.
|
||||||
|
|
||||||
@ -1722,7 +1722,7 @@ bool AsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
|
|||||||
if (Lexer.isNot(AsmToken::Integer))
|
if (Lexer.isNot(AsmToken::Integer))
|
||||||
return TokError("unexpected token in '.loc' directive");
|
return TokError("unexpected token in '.loc' directive");
|
||||||
|
|
||||||
int64_t Param2 = Lexer.getTok().getIntVal();
|
int64_t Param2 = getTok().getIntVal();
|
||||||
(void) Param2;
|
(void) Param2;
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
@ -1730,7 +1730,7 @@ bool AsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
|
|||||||
if (Lexer.isNot(AsmToken::Integer))
|
if (Lexer.isNot(AsmToken::Integer))
|
||||||
return TokError("unexpected token in '.loc' directive");
|
return TokError("unexpected token in '.loc' directive");
|
||||||
|
|
||||||
int64_t Param3 = Lexer.getTok().getIntVal();
|
int64_t Param3 = getTok().getIntVal();
|
||||||
(void) Param3;
|
(void) Param3;
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user