mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
Fix Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116149 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -176,7 +176,7 @@ private:
|
|||||||
/// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
|
/// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
|
||||||
/// and set \arg Res to the identifier contents.
|
/// and set \arg Res to the identifier contents.
|
||||||
bool ParseIdentifier(StringRef &Res);
|
bool ParseIdentifier(StringRef &Res);
|
||||||
|
|
||||||
// Directive Parsing.
|
// Directive Parsing.
|
||||||
bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
|
bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
|
||||||
bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
|
bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
|
||||||
@@ -333,11 +333,11 @@ bool AsmParser::EnterIncludeFile(const std::string &Filename) {
|
|||||||
int NewBuf = SrcMgr.AddIncludeFile(Filename, Lexer.getLoc());
|
int NewBuf = SrcMgr.AddIncludeFile(Filename, Lexer.getLoc());
|
||||||
if (NewBuf == -1)
|
if (NewBuf == -1)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CurBuffer = NewBuf;
|
CurBuffer = NewBuf;
|
||||||
|
|
||||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ void AsmParser::JumpToLoc(SMLoc Loc) {
|
|||||||
|
|
||||||
const AsmToken &AsmParser::Lex() {
|
const AsmToken &AsmParser::Lex() {
|
||||||
const AsmToken *tok = &Lexer.Lex();
|
const AsmToken *tok = &Lexer.Lex();
|
||||||
|
|
||||||
if (tok->is(AsmToken::Eof)) {
|
if (tok->is(AsmToken::Eof)) {
|
||||||
// If this is the end of an included file, pop the parent file off the
|
// If this is the end of an included file, pop the parent file off the
|
||||||
// include stack.
|
// include stack.
|
||||||
@@ -358,10 +358,10 @@ const AsmToken &AsmParser::Lex() {
|
|||||||
tok = &Lexer.Lex();
|
tok = &Lexer.Lex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok->is(AsmToken::Error))
|
if (tok->is(AsmToken::Error))
|
||||||
Error(Lexer.getErrLoc(), Lexer.getErr());
|
Error(Lexer.getErrLoc(), Lexer.getErr());
|
||||||
|
|
||||||
return *tok;
|
return *tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
|
|||||||
// While we have input, parse each statement.
|
// While we have input, parse each statement.
|
||||||
while (Lexer.isNot(AsmToken::Eof)) {
|
while (Lexer.isNot(AsmToken::Eof)) {
|
||||||
if (!ParseStatement()) continue;
|
if (!ParseStatement()) continue;
|
||||||
|
|
||||||
// We had an error, validate that one was emitted and recover by skipping to
|
// We had an error, validate that one was emitted and recover by skipping to
|
||||||
// the next line.
|
// the next line.
|
||||||
assert(HadError && "Parse statement returned an error, but none emitted!");
|
assert(HadError && "Parse statement returned an error, but none emitted!");
|
||||||
@@ -397,10 +397,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
|
|||||||
if (!MCDwarfFiles[i])
|
if (!MCDwarfFiles[i])
|
||||||
TokError("unassigned file number: " + Twine(i) + " for .file directives");
|
TokError("unassigned file number: " + Twine(i) + " for .file directives");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalize the output stream if there are no errors and if the client wants
|
// Finalize the output stream if there are no errors and if the client wants
|
||||||
// us to.
|
// us to.
|
||||||
if (!HadError && !NoFinalize)
|
if (!HadError && !NoFinalize)
|
||||||
Out.Finish();
|
Out.Finish();
|
||||||
|
|
||||||
return HadError;
|
return HadError;
|
||||||
@@ -421,7 +421,7 @@ void AsmParser::EatToEndOfStatement() {
|
|||||||
while (Lexer.isNot(AsmToken::EndOfStatement) &&
|
while (Lexer.isNot(AsmToken::EndOfStatement) &&
|
||||||
Lexer.isNot(AsmToken::Eof))
|
Lexer.isNot(AsmToken::Eof))
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
// Eat EOL.
|
// Eat EOL.
|
||||||
if (Lexer.is(AsmToken::EndOfStatement))
|
if (Lexer.is(AsmToken::EndOfStatement))
|
||||||
Lex();
|
Lex();
|
||||||
@@ -540,7 +540,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
Lex(); // Eat identifier.
|
Lex(); // Eat identifier.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
case AsmToken::LParen:
|
case AsmToken::LParen:
|
||||||
Lex(); // Eat the '('.
|
Lex(); // Eat the '('.
|
||||||
return ParseParenExpr(Res, EndLoc);
|
return ParseParenExpr(Res, EndLoc);
|
||||||
@@ -620,7 +620,7 @@ AsmParser::ApplyModifierToExpr(const MCExpr *E,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// ParseExpression - Parse an expression and return it.
|
/// ParseExpression - Parse an expression and return it.
|
||||||
///
|
///
|
||||||
/// expr ::= expr +,- expr -> lowest.
|
/// expr ::= expr +,- expr -> lowest.
|
||||||
/// expr ::= expr |,^,&,! expr -> middle.
|
/// expr ::= expr |,^,&,! expr -> middle.
|
||||||
/// expr ::= expr *,/,%,<<,>> expr -> highest.
|
/// expr ::= expr *,/,%,<<,>> expr -> highest.
|
||||||
@@ -652,7 +652,7 @@ bool AsmParser::ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
"' (no symbols present)");
|
"' (no symbols present)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Res = ModifiedRes;
|
Res = ModifiedRes;
|
||||||
Lex();
|
Lex();
|
||||||
}
|
}
|
||||||
@@ -673,7 +673,7 @@ bool AsmParser::ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
|
|
||||||
bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
|
bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
|
||||||
const MCExpr *Expr;
|
const MCExpr *Expr;
|
||||||
|
|
||||||
SMLoc StartLoc = Lexer.getLoc();
|
SMLoc StartLoc = Lexer.getLoc();
|
||||||
if (ParseExpression(Expr))
|
if (ParseExpression(Expr))
|
||||||
return true;
|
return true;
|
||||||
@@ -684,7 +684,7 @@ bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
|
static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
|
||||||
MCBinaryExpr::Opcode &Kind) {
|
MCBinaryExpr::Opcode &Kind) {
|
||||||
switch (K) {
|
switch (K) {
|
||||||
default:
|
default:
|
||||||
@@ -698,7 +698,7 @@ static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
|
|||||||
Kind = MCBinaryExpr::LOr;
|
Kind = MCBinaryExpr::LOr;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
||||||
// Low Precedence: |, &, ^
|
// Low Precedence: |, &, ^
|
||||||
//
|
//
|
||||||
// FIXME: gas seems to support '!' as an infix operator?
|
// FIXME: gas seems to support '!' as an infix operator?
|
||||||
@@ -711,7 +711,7 @@ static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
|
|||||||
case AsmToken::Amp:
|
case AsmToken::Amp:
|
||||||
Kind = MCBinaryExpr::And;
|
Kind = MCBinaryExpr::And;
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
// Intermediate Precedence: +, -, ==, !=, <>, <, <=, >, >=
|
// Intermediate Precedence: +, -, ==, !=, <>, <, <=, >, >=
|
||||||
case AsmToken::Plus:
|
case AsmToken::Plus:
|
||||||
Kind = MCBinaryExpr::Add;
|
Kind = MCBinaryExpr::Add;
|
||||||
@@ -766,18 +766,18 @@ bool AsmParser::ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res,
|
|||||||
while (1) {
|
while (1) {
|
||||||
MCBinaryExpr::Opcode Kind = MCBinaryExpr::Add;
|
MCBinaryExpr::Opcode Kind = MCBinaryExpr::Add;
|
||||||
unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind);
|
unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind);
|
||||||
|
|
||||||
// If the next token is lower precedence than we are allowed to eat, return
|
// If the next token is lower precedence than we are allowed to eat, return
|
||||||
// successfully with what we ate already.
|
// successfully with what we ate already.
|
||||||
if (TokPrec < Precedence)
|
if (TokPrec < Precedence)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
// Eat the next primary expression.
|
// Eat the next primary expression.
|
||||||
const MCExpr *RHS;
|
const MCExpr *RHS;
|
||||||
if (ParsePrimaryExpr(RHS, EndLoc)) return true;
|
if (ParsePrimaryExpr(RHS, EndLoc)) return true;
|
||||||
|
|
||||||
// If BinOp binds less tightly with RHS than the operator after RHS, let
|
// If BinOp binds less tightly with RHS than the operator after RHS, let
|
||||||
// the pending operator take RHS as its LHS.
|
// the pending operator take RHS as its LHS.
|
||||||
MCBinaryExpr::Opcode Dummy;
|
MCBinaryExpr::Opcode Dummy;
|
||||||
@@ -791,9 +791,9 @@ bool AsmParser::ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// ParseStatement:
|
/// ParseStatement:
|
||||||
/// ::= EndOfStatement
|
/// ::= EndOfStatement
|
||||||
/// ::= Label* Directive ...Operands... EndOfStatement
|
/// ::= Label* Directive ...Operands... EndOfStatement
|
||||||
@@ -844,13 +844,13 @@ bool AsmParser::ParseStatement() {
|
|||||||
return ParseDirectiveElse(IDLoc);
|
return ParseDirectiveElse(IDLoc);
|
||||||
if (IDVal == ".endif")
|
if (IDVal == ".endif")
|
||||||
return ParseDirectiveEndIf(IDLoc);
|
return ParseDirectiveEndIf(IDLoc);
|
||||||
|
|
||||||
// If we are in a ".if 0" block, ignore this statement.
|
// If we are in a ".if 0" block, ignore this statement.
|
||||||
if (TheCondState.Ignore) {
|
if (TheCondState.Ignore) {
|
||||||
EatToEndOfStatement();
|
EatToEndOfStatement();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Recurse on local labels?
|
// FIXME: Recurse on local labels?
|
||||||
|
|
||||||
// See what kind of statement we have.
|
// See what kind of statement we have.
|
||||||
@@ -873,10 +873,10 @@ bool AsmParser::ParseStatement() {
|
|||||||
Sym = Ctx.CreateDirectionalLocalSymbol(LocalLabelVal);
|
Sym = Ctx.CreateDirectionalLocalSymbol(LocalLabelVal);
|
||||||
if (!Sym->isUndefined() || Sym->isVariable())
|
if (!Sym->isUndefined() || Sym->isVariable())
|
||||||
return Error(IDLoc, "invalid symbol redefinition");
|
return Error(IDLoc, "invalid symbol redefinition");
|
||||||
|
|
||||||
// Emit the label.
|
// Emit the label.
|
||||||
Out.EmitLabel(Sym);
|
Out.EmitLabel(Sym);
|
||||||
|
|
||||||
// Consume any end of statement token, if present, to avoid spurious
|
// Consume any end of statement token, if present, to avoid spurious
|
||||||
// AddBlankLine calls().
|
// AddBlankLine calls().
|
||||||
if (Lexer.is(AsmToken::EndOfStatement)) {
|
if (Lexer.is(AsmToken::EndOfStatement)) {
|
||||||
@@ -903,7 +903,7 @@ bool AsmParser::ParseStatement() {
|
|||||||
if (const Macro *M = MacroMap.lookup(IDVal))
|
if (const Macro *M = MacroMap.lookup(IDVal))
|
||||||
return HandleMacroEntry(IDVal, IDLoc, M);
|
return HandleMacroEntry(IDVal, IDLoc, M);
|
||||||
|
|
||||||
// Otherwise, we have a normal instruction or directive.
|
// Otherwise, we have a normal instruction or directive.
|
||||||
if (IDVal[0] == '.') {
|
if (IDVal[0] == '.') {
|
||||||
// Assembler features
|
// Assembler features
|
||||||
if (IDVal == ".set")
|
if (IDVal == ".set")
|
||||||
@@ -1023,7 +1023,7 @@ bool AsmParser::ParseStatement() {
|
|||||||
SmallString<128> Opcode;
|
SmallString<128> Opcode;
|
||||||
for (unsigned i = 0, e = IDVal.size(); i != e; ++i)
|
for (unsigned i = 0, e = IDVal.size(); i != e; ++i)
|
||||||
Opcode.push_back(tolower(IDVal[i]));
|
Opcode.push_back(tolower(IDVal[i]));
|
||||||
|
|
||||||
SmallVector<MCParsedAsmOperand*, 8> ParsedOperands;
|
SmallVector<MCParsedAsmOperand*, 8> ParsedOperands;
|
||||||
bool HadError = getTargetParser().ParseInstruction(Opcode.str(), IDLoc,
|
bool HadError = getTargetParser().ParseInstruction(Opcode.str(), IDLoc,
|
||||||
ParsedOperands);
|
ParsedOperands);
|
||||||
@@ -1190,7 +1190,7 @@ bool AsmParser::ParseAssignment(StringRef Name) {
|
|||||||
const MCExpr *Value;
|
const MCExpr *Value;
|
||||||
if (ParseExpression(Value))
|
if (ParseExpression(Value))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Lexer.isNot(AsmToken::EndOfStatement))
|
if (Lexer.isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in assignment");
|
return TokError("unexpected token in assignment");
|
||||||
|
|
||||||
@@ -1273,7 +1273,7 @@ bool AsmParser::ParseDirectiveSet() {
|
|||||||
|
|
||||||
if (ParseIdentifier(Name))
|
if (ParseIdentifier(Name))
|
||||||
return TokError("expected identifier after '.set' directive");
|
return TokError("expected identifier after '.set' directive");
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("unexpected token in '.set'");
|
return TokError("unexpected token in '.set'");
|
||||||
Lex();
|
Lex();
|
||||||
@@ -1392,7 +1392,7 @@ bool AsmParser::ParseDirectiveValue(unsigned Size) {
|
|||||||
|
|
||||||
if (getLexer().is(AsmToken::EndOfStatement))
|
if (getLexer().is(AsmToken::EndOfStatement))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// FIXME: Improve diagnostic.
|
// FIXME: Improve diagnostic.
|
||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
@@ -1420,7 +1420,7 @@ bool AsmParser::ParseDirectiveRealValue(const fltSemantics &Semantics) {
|
|||||||
} else if (getLexer().is(AsmToken::Plus))
|
} else if (getLexer().is(AsmToken::Plus))
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::Integer) &&
|
if (getLexer().isNot(AsmToken::Integer) &&
|
||||||
getLexer().isNot(AsmToken::Real))
|
getLexer().isNot(AsmToken::Real))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
|
|
||||||
@@ -1443,7 +1443,7 @@ bool AsmParser::ParseDirectiveRealValue(const fltSemantics &Semantics) {
|
|||||||
|
|
||||||
if (getLexer().is(AsmToken::EndOfStatement))
|
if (getLexer().is(AsmToken::EndOfStatement))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
Lex();
|
Lex();
|
||||||
@@ -1468,7 +1468,7 @@ bool AsmParser::ParseDirectiveSpace() {
|
|||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("unexpected token in '.space' directive");
|
return TokError("unexpected token in '.space' directive");
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (ParseAbsoluteExpression(FillExpr))
|
if (ParseAbsoluteExpression(FillExpr))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -1525,7 +1525,7 @@ bool AsmParser::ParseDirectiveFill() {
|
|||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("unexpected token in '.fill' directive");
|
return TokError("unexpected token in '.fill' directive");
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
int64_t FillSize;
|
int64_t FillSize;
|
||||||
if (ParseAbsoluteExpression(FillSize))
|
if (ParseAbsoluteExpression(FillSize))
|
||||||
return true;
|
return true;
|
||||||
@@ -1533,14 +1533,14 @@ bool AsmParser::ParseDirectiveFill() {
|
|||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("unexpected token in '.fill' directive");
|
return TokError("unexpected token in '.fill' directive");
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
int64_t FillExpr;
|
int64_t FillExpr;
|
||||||
if (ParseAbsoluteExpression(FillExpr))
|
if (ParseAbsoluteExpression(FillExpr))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in '.fill' directive");
|
return TokError("unexpected token in '.fill' directive");
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (FillSize != 1 && FillSize != 2 && FillSize != 4 && FillSize != 8)
|
if (FillSize != 1 && FillSize != 2 && FillSize != 4 && FillSize != 8)
|
||||||
@@ -1567,7 +1567,7 @@ bool AsmParser::ParseDirectiveOrg() {
|
|||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("unexpected token in '.org' directive");
|
return TokError("unexpected token in '.org' directive");
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (ParseAbsoluteExpression(FillExpr))
|
if (ParseAbsoluteExpression(FillExpr))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -1620,7 +1620,7 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
|
|||||||
MaxBytesLoc = getLexer().getLoc();
|
MaxBytesLoc = getLexer().getLoc();
|
||||||
if (ParseAbsoluteExpression(MaxBytesToFill))
|
if (ParseAbsoluteExpression(MaxBytesToFill))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
}
|
}
|
||||||
@@ -1681,7 +1681,7 @@ bool AsmParser::ParseDirectiveSymbolAttribute(MCSymbolAttr Attr) {
|
|||||||
|
|
||||||
if (ParseIdentifier(Name))
|
if (ParseIdentifier(Name))
|
||||||
return TokError("expected identifier in directive");
|
return TokError("expected identifier in directive");
|
||||||
|
|
||||||
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
|
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
|
||||||
|
|
||||||
getStreamer().EmitSymbolAttribute(Sym, Attr);
|
getStreamer().EmitSymbolAttribute(Sym, Attr);
|
||||||
@@ -1708,7 +1708,7 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
|
|||||||
StringRef Name;
|
StringRef Name;
|
||||||
if (ParseIdentifier(Name))
|
if (ParseIdentifier(Name))
|
||||||
return TokError("expected identifier in directive");
|
return TokError("expected identifier in directive");
|
||||||
|
|
||||||
// Handle the identifier as the key symbol.
|
// Handle the identifier as the key symbol.
|
||||||
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
|
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
|
||||||
|
|
||||||
@@ -1728,7 +1728,7 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
|
|||||||
Pow2AlignmentLoc = getLexer().getLoc();
|
Pow2AlignmentLoc = getLexer().getLoc();
|
||||||
if (ParseAbsoluteExpression(Pow2Alignment))
|
if (ParseAbsoluteExpression(Pow2Alignment))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// If this target takes alignments in bytes (not log) validate and convert.
|
// If this target takes alignments in bytes (not log) validate and convert.
|
||||||
if (Lexer.getMAI().getAlignmentIsInBytes()) {
|
if (Lexer.getMAI().getAlignmentIsInBytes()) {
|
||||||
if (!isPowerOf2_64(Pow2Alignment))
|
if (!isPowerOf2_64(Pow2Alignment))
|
||||||
@@ -1736,10 +1736,10 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
|
|||||||
Pow2Alignment = Log2_64(Pow2Alignment);
|
Pow2Alignment = Log2_64(Pow2Alignment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in '.comm' or '.lcomm' directive");
|
return TokError("unexpected token in '.comm' or '.lcomm' directive");
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
// NOTE: a size of zero for a .comm should create a undefined symbol
|
// NOTE: a size of zero for a .comm should create a undefined symbol
|
||||||
@@ -1798,17 +1798,17 @@ bool AsmParser::ParseDirectiveAbort() {
|
|||||||
bool AsmParser::ParseDirectiveInclude() {
|
bool AsmParser::ParseDirectiveInclude() {
|
||||||
if (getLexer().isNot(AsmToken::String))
|
if (getLexer().isNot(AsmToken::String))
|
||||||
return TokError("expected string in '.include' directive");
|
return TokError("expected string in '.include' directive");
|
||||||
|
|
||||||
std::string Filename = getTok().getString();
|
std::string Filename = getTok().getString();
|
||||||
SMLoc IncludeLoc = getLexer().getLoc();
|
SMLoc IncludeLoc = getLexer().getLoc();
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in '.include' directive");
|
return TokError("unexpected token in '.include' directive");
|
||||||
|
|
||||||
// Strip the quotes.
|
// Strip the quotes.
|
||||||
Filename = Filename.substr(1, Filename.size()-2);
|
Filename = Filename.substr(1, Filename.size()-2);
|
||||||
|
|
||||||
// Attempt to switch the lexer to the included file before consuming the end
|
// Attempt to switch the lexer to the included file before consuming the end
|
||||||
// of statement to avoid losing it when we switch.
|
// of statement to avoid losing it when we switch.
|
||||||
if (EnterIncludeFile(Filename)) {
|
if (EnterIncludeFile(Filename)) {
|
||||||
@@ -1834,7 +1834,7 @@ bool AsmParser::ParseDirectiveIf(SMLoc DirectiveLoc) {
|
|||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in '.if' directive");
|
return TokError("unexpected token in '.if' directive");
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
TheCondState.CondMet = ExprValue;
|
TheCondState.CondMet = ExprValue;
|
||||||
@@ -1867,7 +1867,7 @@ bool AsmParser::ParseDirectiveElseIf(SMLoc DirectiveLoc) {
|
|||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in '.elseif' directive");
|
return TokError("unexpected token in '.elseif' directive");
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
TheCondState.CondMet = ExprValue;
|
TheCondState.CondMet = ExprValue;
|
||||||
TheCondState.Ignore = !TheCondState.CondMet;
|
TheCondState.Ignore = !TheCondState.CondMet;
|
||||||
@@ -1881,7 +1881,7 @@ bool AsmParser::ParseDirectiveElseIf(SMLoc DirectiveLoc) {
|
|||||||
bool AsmParser::ParseDirectiveElse(SMLoc DirectiveLoc) {
|
bool AsmParser::ParseDirectiveElse(SMLoc DirectiveLoc) {
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in '.else' directive");
|
return TokError("unexpected token in '.else' directive");
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if (TheCondState.TheCond != AsmCond::IfCond &&
|
if (TheCondState.TheCond != AsmCond::IfCond &&
|
||||||
@@ -1905,7 +1905,7 @@ bool AsmParser::ParseDirectiveElse(SMLoc DirectiveLoc) {
|
|||||||
bool AsmParser::ParseDirectiveEndIf(SMLoc DirectiveLoc) {
|
bool AsmParser::ParseDirectiveEndIf(SMLoc DirectiveLoc) {
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in '.endif' directive");
|
return TokError("unexpected token in '.endif' directive");
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
if ((TheCondState.TheCond == AsmCond::NoCond) ||
|
if ((TheCondState.TheCond == AsmCond::NoCond) ||
|
||||||
@@ -1947,8 +1947,8 @@ bool GenericAsmParser::ParseDirectiveFile(StringRef, SMLoc DirectiveLoc) {
|
|||||||
if (FileNumber == -1)
|
if (FileNumber == -1)
|
||||||
getStreamer().EmitFileDirective(Filename);
|
getStreamer().EmitFileDirective(Filename);
|
||||||
else {
|
else {
|
||||||
if (getContext().GetDwarfFile(Filename, FileNumber) == 0)
|
if (getContext().GetDwarfFile(Filename, FileNumber) == 0)
|
||||||
Error(FileNumberLoc, "file number already allocated");
|
Error(FileNumberLoc, "file number already allocated");
|
||||||
getStreamer().EmitDwarfFileDirective(FileNumber, Filename);
|
getStreamer().EmitDwarfFileDirective(FileNumber, Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2042,7 +2042,7 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
|
|||||||
Flags |= DWARF2_FLAG_IS_STMT;
|
Flags |= DWARF2_FLAG_IS_STMT;
|
||||||
else
|
else
|
||||||
return Error(Loc, "is_stmt value not 0 or 1");
|
return Error(Loc, "is_stmt value not 0 or 1");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Error(Loc, "is_stmt value not the constant value of 0 or 1");
|
return Error(Loc, "is_stmt value not the constant value of 0 or 1");
|
||||||
}
|
}
|
||||||
@@ -2058,7 +2058,7 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
|
|||||||
if (Value < 0)
|
if (Value < 0)
|
||||||
return Error(Loc, "isa number less than zero");
|
return Error(Loc, "isa number less than zero");
|
||||||
Isa = Value;
|
Isa = Value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Error(Loc, "isa number not a constant value");
|
return Error(Loc, "isa number not a constant value");
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,7 @@ class X86ATTAsmParser : public TargetAsmParser {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned Is64Bit : 1;
|
unsigned Is64Bit : 1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MCAsmParser &getParser() const { return Parser; }
|
MCAsmParser &getParser() const { return Parser; }
|
||||||
|
|
||||||
@@ -57,16 +57,16 @@ private:
|
|||||||
|
|
||||||
/// @name Auto-generated Matcher Functions
|
/// @name Auto-generated Matcher Functions
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
#define GET_ASSEMBLER_HEADER
|
#define GET_ASSEMBLER_HEADER
|
||||||
#include "X86GenAsmMatcher.inc"
|
#include "X86GenAsmMatcher.inc"
|
||||||
|
|
||||||
/// }
|
/// }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
X86ATTAsmParser(const Target &T, MCAsmParser &_Parser, TargetMachine &TM)
|
X86ATTAsmParser(const Target &T, MCAsmParser &_Parser, TargetMachine &TM)
|
||||||
: TargetAsmParser(T), Parser(_Parser), TM(TM) {
|
: TargetAsmParser(T), Parser(_Parser), TM(TM) {
|
||||||
|
|
||||||
// Initialize the set of available features.
|
// Initialize the set of available features.
|
||||||
setAvailableFeatures(ComputeAvailableFeatures(
|
setAvailableFeatures(ComputeAvailableFeatures(
|
||||||
&TM.getSubtarget<X86Subtarget>()));
|
&TM.getSubtarget<X86Subtarget>()));
|
||||||
@@ -377,7 +377,7 @@ bool X86ATTAsmParser::ParseRegister(unsigned &RegNo,
|
|||||||
// If the match failed, try the register name as lowercase.
|
// If the match failed, try the register name as lowercase.
|
||||||
if (RegNo == 0)
|
if (RegNo == 0)
|
||||||
RegNo = MatchRegisterName(LowercaseString(Tok.getString()));
|
RegNo = MatchRegisterName(LowercaseString(Tok.getString()));
|
||||||
|
|
||||||
// FIXME: This should be done using Requires<In32BitMode> and
|
// FIXME: This should be done using Requires<In32BitMode> and
|
||||||
// Requires<In64BitMode> so "eiz" usage in 64-bit instructions
|
// Requires<In64BitMode> so "eiz" usage in 64-bit instructions
|
||||||
// can be also checked.
|
// can be also checked.
|
||||||
@@ -779,19 +779,19 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
PatchedName = "vpclmulqdq";
|
PatchedName = "vpclmulqdq";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Operands.push_back(X86Operand::CreateToken(PatchedName, NameLoc));
|
Operands.push_back(X86Operand::CreateToken(PatchedName, NameLoc));
|
||||||
|
|
||||||
if (ExtraImmOp)
|
if (ExtraImmOp)
|
||||||
Operands.push_back(X86Operand::CreateImm(ExtraImmOp, NameLoc, NameLoc));
|
Operands.push_back(X86Operand::CreateImm(ExtraImmOp, NameLoc, NameLoc));
|
||||||
|
|
||||||
|
|
||||||
// Determine whether this is an instruction prefix.
|
// Determine whether this is an instruction prefix.
|
||||||
bool isPrefix =
|
bool isPrefix =
|
||||||
PatchedName == "lock" || PatchedName == "rep" ||
|
PatchedName == "lock" || PatchedName == "rep" ||
|
||||||
PatchedName == "repne";
|
PatchedName == "repne";
|
||||||
|
|
||||||
|
|
||||||
// This does the actual operand parsing. Don't parse any more if we have a
|
// This does the actual operand parsing. Don't parse any more if we have a
|
||||||
// prefix juxtaposed with an operation like "lock incl 4(%rax)", because we
|
// prefix juxtaposed with an operation like "lock incl 4(%rax)", because we
|
||||||
// just want to parse the "lock" as the first instruction and the "incl" as
|
// just want to parse the "lock" as the first instruction and the "incl" as
|
||||||
@@ -824,13 +824,13 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||||
Parser.EatToEndOfStatement();
|
Parser.EatToEndOfStatement();
|
||||||
return TokError("unexpected token in argument list");
|
return TokError("unexpected token in argument list");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getLexer().is(AsmToken::EndOfStatement))
|
if (getLexer().is(AsmToken::EndOfStatement))
|
||||||
Parser.Lex(); // Consume the EndOfStatement
|
Parser.Lex(); // Consume the EndOfStatement
|
||||||
|
|
||||||
@@ -842,7 +842,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
delete Operands[0];
|
delete Operands[0];
|
||||||
Operands[0] = X86Operand::CreateToken("movabsq", NameLoc);
|
Operands[0] = X86Operand::CreateToken("movabsq", NameLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Hack to handle recognize s{hr,ar,hl} $1, <op>. Canonicalize to
|
// FIXME: Hack to handle recognize s{hr,ar,hl} $1, <op>. Canonicalize to
|
||||||
// "shift <op>".
|
// "shift <op>".
|
||||||
if ((Name.startswith("shr") || Name.startswith("sar") ||
|
if ((Name.startswith("shr") || Name.startswith("sar") ||
|
||||||
@@ -855,7 +855,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Operands.erase(Operands.begin() + 1);
|
Operands.erase(Operands.begin() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Hack to handle recognize "rc[lr] <op>" -> "rcl $1, <op>".
|
// FIXME: Hack to handle recognize "rc[lr] <op>" -> "rcl $1, <op>".
|
||||||
if ((Name.startswith("rcl") || Name.startswith("rcr")) &&
|
if ((Name.startswith("rcl") || Name.startswith("rcr")) &&
|
||||||
Operands.size() == 2) {
|
Operands.size() == 2) {
|
||||||
@@ -863,7 +863,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Operands.push_back(X86Operand::CreateImm(One, NameLoc, NameLoc));
|
Operands.push_back(X86Operand::CreateImm(One, NameLoc, NameLoc));
|
||||||
std::swap(Operands[1], Operands[2]);
|
std::swap(Operands[1], Operands[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Hack to handle recognize "sh[lr]d op,op" -> "shld $1, op,op".
|
// FIXME: Hack to handle recognize "sh[lr]d op,op" -> "shld $1, op,op".
|
||||||
if ((Name.startswith("shld") || Name.startswith("shrd")) &&
|
if ((Name.startswith("shld") || Name.startswith("shrd")) &&
|
||||||
Operands.size() == 3) {
|
Operands.size() == 3) {
|
||||||
@@ -871,7 +871,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Operands.insert(Operands.begin()+1,
|
Operands.insert(Operands.begin()+1,
|
||||||
X86Operand::CreateImm(One, NameLoc, NameLoc));
|
X86Operand::CreateImm(One, NameLoc, NameLoc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME: Hack to handle recognize "in[bwl] <op>". Canonicalize it to
|
// FIXME: Hack to handle recognize "in[bwl] <op>". Canonicalize it to
|
||||||
// "inb <op>, %al".
|
// "inb <op>, %al".
|
||||||
@@ -887,7 +887,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
SMLoc Loc = Operands.back()->getEndLoc();
|
SMLoc Loc = Operands.back()->getEndLoc();
|
||||||
Operands.push_back(X86Operand::CreateReg(Reg, Loc, Loc));
|
Operands.push_back(X86Operand::CreateReg(Reg, Loc, Loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Hack to handle recognize "out[bwl] <op>". Canonicalize it to
|
// FIXME: Hack to handle recognize "out[bwl] <op>". Canonicalize it to
|
||||||
// "outb %al, <op>".
|
// "outb %al, <op>".
|
||||||
if ((Name == "outb" || Name == "outw" || Name == "outl") &&
|
if ((Name == "outb" || Name == "outw" || Name == "outl") &&
|
||||||
@@ -903,7 +903,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Operands.push_back(X86Operand::CreateReg(Reg, Loc, Loc));
|
Operands.push_back(X86Operand::CreateReg(Reg, Loc, Loc));
|
||||||
std::swap(Operands[1], Operands[2]);
|
std::swap(Operands[1], Operands[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Hack to handle "out[bwl]? %al, (%dx)" -> "outb %al, %dx".
|
// FIXME: Hack to handle "out[bwl]? %al, (%dx)" -> "outb %al, %dx".
|
||||||
if ((Name == "outb" || Name == "outw" || Name == "outl" || Name == "out") &&
|
if ((Name == "outb" || Name == "outw" || Name == "outl" || Name == "out") &&
|
||||||
Operands.size() == 3) {
|
Operands.size() == 3) {
|
||||||
@@ -917,7 +917,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
delete &Op;
|
delete &Op;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Hack to handle "f{mul*,add*,sub*,div*} $op, st(0)" the same as
|
// FIXME: Hack to handle "f{mul*,add*,sub*,div*} $op, st(0)" the same as
|
||||||
// "f{mul*,add*,sub*,div*} $op"
|
// "f{mul*,add*,sub*,div*} $op"
|
||||||
if ((Name.startswith("fmul") || Name.startswith("fadd") ||
|
if ((Name.startswith("fmul") || Name.startswith("fadd") ||
|
||||||
@@ -928,7 +928,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
delete Operands[2];
|
delete Operands[2];
|
||||||
Operands.erase(Operands.begin() + 2);
|
Operands.erase(Operands.begin() + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Hack to handle "f{mulp,addp} st(0), $op" the same as
|
// FIXME: Hack to handle "f{mulp,addp} st(0), $op" the same as
|
||||||
// "f{mulp,addp} $op", since they commute. We also allow fdivrp/fsubrp even
|
// "f{mulp,addp} $op", since they commute. We also allow fdivrp/fsubrp even
|
||||||
// though they don't commute, solely because gas does support this.
|
// though they don't commute, solely because gas does support this.
|
||||||
@@ -939,7 +939,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
delete Operands[1];
|
delete Operands[1];
|
||||||
Operands.erase(Operands.begin() + 1);
|
Operands.erase(Operands.begin() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Hack to handle "imul <imm>, B" which is an alias for "imul <imm>, B,
|
// FIXME: Hack to handle "imul <imm>, B" which is an alias for "imul <imm>, B,
|
||||||
// B".
|
// B".
|
||||||
if (Name.startswith("imul") && Operands.size() == 3 &&
|
if (Name.startswith("imul") && Operands.size() == 3 &&
|
||||||
@@ -949,7 +949,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Operands.push_back(X86Operand::CreateReg(Op->getReg(), Op->getStartLoc(),
|
Operands.push_back(X86Operand::CreateReg(Op->getReg(), Op->getStartLoc(),
|
||||||
Op->getEndLoc()));
|
Op->getEndLoc()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'sldt <mem>' can be encoded with either sldtw or sldtq with the same
|
// 'sldt <mem>' can be encoded with either sldtw or sldtq with the same
|
||||||
// effect (both store to a 16-bit mem). Force to sldtw to avoid ambiguity
|
// effect (both store to a 16-bit mem). Force to sldtw to avoid ambiguity
|
||||||
// errors, since its encoding is the most compact.
|
// errors, since its encoding is the most compact.
|
||||||
@@ -958,7 +958,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
delete Operands[0];
|
delete Operands[0];
|
||||||
Operands[0] = X86Operand::CreateToken("sldtw", NameLoc);
|
Operands[0] = X86Operand::CreateToken("sldtw", NameLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The assembler accepts "xchgX <reg>, <mem>" and "xchgX <mem>, <reg>" as
|
// The assembler accepts "xchgX <reg>, <mem>" and "xchgX <mem>, <reg>" as
|
||||||
// synonyms. Our tables only have the "<reg>, <mem>" form, so if we see the
|
// synonyms. Our tables only have the "<reg>, <mem>" form, so if we see the
|
||||||
// other operand order, swap them.
|
// other operand order, swap them.
|
||||||
@@ -980,17 +980,17 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
static_cast<X86Operand*>(Operands[2])->isMem()) {
|
static_cast<X86Operand*>(Operands[2])->isMem()) {
|
||||||
std::swap(Operands[1], Operands[2]);
|
std::swap(Operands[1], Operands[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The assembler accepts these instructions with no operand as a synonym for
|
// The assembler accepts these instructions with no operand as a synonym for
|
||||||
// an instruction acting on st(1). e.g. "fxch" -> "fxch %st(1)".
|
// an instruction acting on st(1). e.g. "fxch" -> "fxch %st(1)".
|
||||||
if ((Name == "fxch" || Name == "fucom" || Name == "fucomp" ||
|
if ((Name == "fxch" || Name == "fucom" || Name == "fucomp" ||
|
||||||
Name == "faddp" || Name == "fsubp" || Name == "fsubrp" ||
|
Name == "faddp" || Name == "fsubp" || Name == "fsubrp" ||
|
||||||
Name == "fmulp" || Name == "fdivp" || Name == "fdivrp") &&
|
Name == "fmulp" || Name == "fdivp" || Name == "fdivrp") &&
|
||||||
Operands.size() == 1) {
|
Operands.size() == 1) {
|
||||||
Operands.push_back(X86Operand::CreateReg(MatchRegisterName("st(1)"),
|
Operands.push_back(X86Operand::CreateReg(MatchRegisterName("st(1)"),
|
||||||
NameLoc, NameLoc));
|
NameLoc, NameLoc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// The assembler accepts these instructions with two few operands as a synonym
|
// The assembler accepts these instructions with two few operands as a synonym
|
||||||
// for taking %st(1),%st(0) or X, %st(0).
|
// for taking %st(1),%st(0) or X, %st(0).
|
||||||
if ((Name == "fcomi" || Name == "fucomi") && Operands.size() < 3) {
|
if ((Name == "fcomi" || Name == "fucomi") && Operands.size() < 3) {
|
||||||
@@ -1000,7 +1000,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Operands.push_back(X86Operand::CreateReg(MatchRegisterName("st(0)"),
|
Operands.push_back(X86Operand::CreateReg(MatchRegisterName("st(0)"),
|
||||||
NameLoc, NameLoc));
|
NameLoc, NameLoc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// The assembler accepts various amounts of brokenness for fnstsw.
|
// The assembler accepts various amounts of brokenness for fnstsw.
|
||||||
if (Name == "fnstsw") {
|
if (Name == "fnstsw") {
|
||||||
if (Operands.size() == 2 &&
|
if (Operands.size() == 2 &&
|
||||||
@@ -1019,7 +1019,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Operands.push_back(X86Operand::CreateReg(MatchRegisterName("ax"),
|
Operands.push_back(X86Operand::CreateReg(MatchRegisterName("ax"),
|
||||||
NameLoc, NameLoc));
|
NameLoc, NameLoc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// jmp $42,$5 -> ljmp, similarly for call.
|
// jmp $42,$5 -> ljmp, similarly for call.
|
||||||
if ((Name.startswith("call") || Name.startswith("jmp")) &&
|
if ((Name.startswith("call") || Name.startswith("jmp")) &&
|
||||||
Operands.size() == 3 &&
|
Operands.size() == 3 &&
|
||||||
@@ -1041,14 +1041,14 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Name = NewOpName;
|
Name = NewOpName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lcall and ljmp -> lcalll and ljmpl
|
// lcall and ljmp -> lcalll and ljmpl
|
||||||
if ((Name == "lcall" || Name == "ljmp") && Operands.size() == 3) {
|
if ((Name == "lcall" || Name == "ljmp") && Operands.size() == 3) {
|
||||||
delete Operands[0];
|
delete Operands[0];
|
||||||
Operands[0] = X86Operand::CreateToken(Name == "lcall" ? "lcalll" : "ljmpl",
|
Operands[0] = X86Operand::CreateToken(Name == "lcall" ? "lcalll" : "ljmpl",
|
||||||
NameLoc);
|
NameLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// call foo is not ambiguous with callw.
|
// call foo is not ambiguous with callw.
|
||||||
if (Name == "call" && Operands.size() == 2) {
|
if (Name == "call" && Operands.size() == 2) {
|
||||||
const char *NewName = Is64Bit ? "callq" : "calll";
|
const char *NewName = Is64Bit ? "callq" : "calll";
|
||||||
@@ -1056,13 +1056,13 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
Operands[0] = X86Operand::CreateToken(NewName, NameLoc);
|
Operands[0] = X86Operand::CreateToken(NewName, NameLoc);
|
||||||
Name = NewName;
|
Name = NewName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// movsd -> movsl (when no operands are specified).
|
// movsd -> movsl (when no operands are specified).
|
||||||
if (Name == "movsd" && Operands.size() == 1) {
|
if (Name == "movsd" && Operands.size() == 1) {
|
||||||
delete Operands[0];
|
delete Operands[0];
|
||||||
Operands[0] = X86Operand::CreateToken("movsl", NameLoc);
|
Operands[0] = X86Operand::CreateToken("movsl", NameLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fstp <mem> -> fstps <mem>. Without this, we'll default to fstpl due to
|
// fstp <mem> -> fstps <mem>. Without this, we'll default to fstpl due to
|
||||||
// suffix searching.
|
// suffix searching.
|
||||||
if (Name == "fstp" && Operands.size() == 2 &&
|
if (Name == "fstp" && Operands.size() == 2 &&
|
||||||
@@ -1070,8 +1070,8 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
delete Operands[0];
|
delete Operands[0];
|
||||||
Operands[0] = X86Operand::CreateToken("fstps", NameLoc);
|
Operands[0] = X86Operand::CreateToken("fstps", NameLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// "clr <reg>" -> "xor <reg>, <reg>".
|
// "clr <reg>" -> "xor <reg>, <reg>".
|
||||||
if ((Name == "clrb" || Name == "clrw" || Name == "clrl" || Name == "clrq" ||
|
if ((Name == "clrb" || Name == "clrw" || Name == "clrl" || Name == "clrq" ||
|
||||||
Name == "clr") && Operands.size() == 2 &&
|
Name == "clr") && Operands.size() == 2 &&
|
||||||
@@ -1081,7 +1081,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
|
|||||||
delete Operands[0];
|
delete Operands[0];
|
||||||
Operands[0] = X86Operand::CreateToken("xor", NameLoc);
|
Operands[0] = X86Operand::CreateToken("xor", NameLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1147,11 +1147,11 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
delete Operands[0];
|
delete Operands[0];
|
||||||
Operands[0] = X86Operand::CreateToken(Repl, IDLoc);
|
Operands[0] = X86Operand::CreateToken(Repl, IDLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WasOriginallyInvalidOperand = false;
|
bool WasOriginallyInvalidOperand = false;
|
||||||
unsigned OrigErrorInfo;
|
unsigned OrigErrorInfo;
|
||||||
MCInst Inst;
|
MCInst Inst;
|
||||||
|
|
||||||
// First, try a direct match.
|
// First, try a direct match.
|
||||||
switch (MatchInstructionImpl(Operands, Inst, OrigErrorInfo)) {
|
switch (MatchInstructionImpl(Operands, Inst, OrigErrorInfo)) {
|
||||||
case Match_Success:
|
case Match_Success:
|
||||||
@@ -1171,7 +1171,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
// valid prefixes, and we could just infer the right unambiguous
|
// valid prefixes, and we could just infer the right unambiguous
|
||||||
// type. However, that requires substantially more matcher support than the
|
// type. However, that requires substantially more matcher support than the
|
||||||
// following hack.
|
// following hack.
|
||||||
|
|
||||||
// Change the operand to point to a temporary token.
|
// Change the operand to point to a temporary token.
|
||||||
StringRef Base = Op->getToken();
|
StringRef Base = Op->getToken();
|
||||||
SmallString<16> Tmp;
|
SmallString<16> Tmp;
|
||||||
@@ -1234,15 +1234,15 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
Error(IDLoc, OS.str());
|
Error(IDLoc, OS.str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Okay, we know that none of the variants matched successfully.
|
// Okay, we know that none of the variants matched successfully.
|
||||||
|
|
||||||
// If all of the instructions reported an invalid mnemonic, then the original
|
// If all of the instructions reported an invalid mnemonic, then the original
|
||||||
// mnemonic was invalid.
|
// mnemonic was invalid.
|
||||||
if ((MatchB == Match_MnemonicFail) && (MatchW == Match_MnemonicFail) &&
|
if ((MatchB == Match_MnemonicFail) && (MatchW == Match_MnemonicFail) &&
|
||||||
(MatchL == Match_MnemonicFail) && (MatchQ == Match_MnemonicFail)) {
|
(MatchL == Match_MnemonicFail) && (MatchQ == Match_MnemonicFail)) {
|
||||||
if (!WasOriginallyInvalidOperand) {
|
if (!WasOriginallyInvalidOperand) {
|
||||||
Error(IDLoc, "invalid instruction mnemonic '" + Base + "'");
|
Error(IDLoc, "invalid instruction mnemonic '" + Base + "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1251,14 +1251,14 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
if (OrigErrorInfo != ~0U) {
|
if (OrigErrorInfo != ~0U) {
|
||||||
if (OrigErrorInfo >= Operands.size())
|
if (OrigErrorInfo >= Operands.size())
|
||||||
return Error(IDLoc, "too few operands for instruction");
|
return Error(IDLoc, "too few operands for instruction");
|
||||||
|
|
||||||
ErrorLoc = ((X86Operand*)Operands[OrigErrorInfo])->getStartLoc();
|
ErrorLoc = ((X86Operand*)Operands[OrigErrorInfo])->getStartLoc();
|
||||||
if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;
|
if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Error(ErrorLoc, "invalid operand for instruction");
|
return Error(ErrorLoc, "invalid operand for instruction");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If one instruction matched with a missing feature, report this as a
|
// If one instruction matched with a missing feature, report this as a
|
||||||
// missing feature.
|
// missing feature.
|
||||||
if ((MatchB == Match_MissingFeature) + (MatchW == Match_MissingFeature) +
|
if ((MatchB == Match_MissingFeature) + (MatchW == Match_MissingFeature) +
|
||||||
@@ -1266,7 +1266,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
Error(IDLoc, "instruction requires a CPU feature not currently enabled");
|
Error(IDLoc, "instruction requires a CPU feature not currently enabled");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If one instruction matched with an invalid operand, report this as an
|
// If one instruction matched with an invalid operand, report this as an
|
||||||
// operand failure.
|
// operand failure.
|
||||||
if ((MatchB == Match_InvalidOperand) + (MatchW == Match_InvalidOperand) +
|
if ((MatchB == Match_InvalidOperand) + (MatchW == Match_InvalidOperand) +
|
||||||
@@ -1274,7 +1274,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
Error(IDLoc, "invalid operand for instruction");
|
Error(IDLoc, "invalid operand for instruction");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all of these were an outright failure, report it in a useless way.
|
// If all of these were an outright failure, report it in a useless way.
|
||||||
// FIXME: We should give nicer diagnostics about the exact failure.
|
// FIXME: We should give nicer diagnostics about the exact failure.
|
||||||
Error(IDLoc, "unknown use of instruction mnemonic without a size suffix");
|
Error(IDLoc, "unknown use of instruction mnemonic without a size suffix");
|
||||||
|
Reference in New Issue
Block a user