mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
[AsmParser] Provide target direct access to mnemonic token. Allow assignment parsing to be hooked by target. Allow target to specify if identifier is a label.
Differential Revision: http://reviews.llvm.org/D14255 llvm-svn: 252435
This commit is contained in:
parent
705d5922fa
commit
0bbf32d6ae
@ -143,6 +143,10 @@ public:
|
|||||||
/// \return True on failure.
|
/// \return True on failure.
|
||||||
virtual bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
|
virtual bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
|
||||||
SMLoc NameLoc, OperandVector &Operands) = 0;
|
SMLoc NameLoc, OperandVector &Operands) = 0;
|
||||||
|
virtual bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
|
||||||
|
AsmToken Token, OperandVector &Operands) {
|
||||||
|
return ParseInstruction(Info, Name, Token.getLoc(), Operands);
|
||||||
|
}
|
||||||
|
|
||||||
/// ParseDirective - Parse a target specific assembler directive
|
/// ParseDirective - Parse a target specific assembler directive
|
||||||
///
|
///
|
||||||
@ -192,6 +196,11 @@ public:
|
|||||||
virtual void convertToMapAndConstraints(unsigned Kind,
|
virtual void convertToMapAndConstraints(unsigned Kind,
|
||||||
const OperandVector &Operands) = 0;
|
const OperandVector &Operands) = 0;
|
||||||
|
|
||||||
|
// Return whether this parser uses assignment statements with equals tokens
|
||||||
|
virtual bool equalIsAsmAssignment() { return true; };
|
||||||
|
// Return whether this start of statement identifier is a label
|
||||||
|
virtual bool isLabel(AsmToken &Token) { return true; };
|
||||||
|
|
||||||
virtual const MCExpr *applyModifierToExpr(const MCExpr *E,
|
virtual const MCExpr *applyModifierToExpr(const MCExpr *E,
|
||||||
MCSymbolRefExpr::VariantKind,
|
MCSymbolRefExpr::VariantKind,
|
||||||
MCContext &Ctx) {
|
MCContext &Ctx) {
|
||||||
|
@ -1396,6 +1396,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
|
|||||||
// See what kind of statement we have.
|
// See what kind of statement we have.
|
||||||
switch (Lexer.getKind()) {
|
switch (Lexer.getKind()) {
|
||||||
case AsmToken::Colon: {
|
case AsmToken::Colon: {
|
||||||
|
if (!getTargetParser().isLabel(ID))
|
||||||
|
break;
|
||||||
checkForValidSection();
|
checkForValidSection();
|
||||||
|
|
||||||
// identifier ':' -> Label.
|
// identifier ':' -> Label.
|
||||||
@ -1454,6 +1456,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case AsmToken::Equal:
|
case AsmToken::Equal:
|
||||||
|
if (!getTargetParser().equalIsAsmAssignment())
|
||||||
|
break;
|
||||||
// identifier '=' ... -> assignment statement
|
// identifier '=' ... -> assignment statement
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
@ -1701,7 +1705,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
|
|||||||
// Canonicalize the opcode to lower case.
|
// Canonicalize the opcode to lower case.
|
||||||
std::string OpcodeStr = IDVal.lower();
|
std::string OpcodeStr = IDVal.lower();
|
||||||
ParseInstructionInfo IInfo(Info.AsmRewrites);
|
ParseInstructionInfo IInfo(Info.AsmRewrites);
|
||||||
bool HadError = getTargetParser().ParseInstruction(IInfo, OpcodeStr, IDLoc,
|
bool HadError = getTargetParser().ParseInstruction(IInfo, OpcodeStr, ID,
|
||||||
Info.ParsedOperands);
|
Info.ParsedOperands);
|
||||||
Info.ParseError = HadError;
|
Info.ParseError = HadError;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user