Fix Whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116149 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael J. Spencer 2010-10-09 11:00:50 +00:00
parent d47f4a9c98
commit c0c8df3cea
2 changed files with 104 additions and 104 deletions

View File

@ -176,7 +176,7 @@ private:
/// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
/// and set \arg Res to the identifier contents.
bool ParseIdentifier(StringRef &Res);
// Directive Parsing.
bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
@ -333,11 +333,11 @@ bool AsmParser::EnterIncludeFile(const std::string &Filename) {
int NewBuf = SrcMgr.AddIncludeFile(Filename, Lexer.getLoc());
if (NewBuf == -1)
return true;
CurBuffer = NewBuf;
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
return false;
}
@ -348,7 +348,7 @@ void AsmParser::JumpToLoc(SMLoc Loc) {
const AsmToken &AsmParser::Lex() {
const AsmToken *tok = &Lexer.Lex();
if (tok->is(AsmToken::Eof)) {
// If this is the end of an included file, pop the parent file off the
// include stack.
@ -358,10 +358,10 @@ const AsmToken &AsmParser::Lex() {
tok = &Lexer.Lex();
}
}
if (tok->is(AsmToken::Error))
Error(Lexer.getErrLoc(), Lexer.getErr());
return *tok;
}
@ -379,7 +379,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
// While we have input, parse each statement.
while (Lexer.isNot(AsmToken::Eof)) {
if (!ParseStatement()) continue;
// We had an error, validate that one was emitted and recover by skipping to
// the next line.
assert(HadError && "Parse statement returned an error, but none emitted!");
@ -397,10 +397,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
if (!MCDwarfFiles[i])
TokError("unassigned file number: " + Twine(i) + " for .file directives");
}
// Finalize the output stream if there are no errors and if the client wants
// us to.
if (!HadError && !NoFinalize)
if (!HadError && !NoFinalize)
Out.Finish();
return HadError;
@ -421,7 +421,7 @@ void AsmParser::EatToEndOfStatement() {
while (Lexer.isNot(AsmToken::EndOfStatement) &&
Lexer.isNot(AsmToken::Eof))
Lex();
// Eat EOL.
if (Lexer.is(AsmToken::EndOfStatement))
Lex();
@ -540,7 +540,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
Lex(); // Eat identifier.
return false;
}
case AsmToken::LParen:
Lex(); // Eat the '('.
return ParseParenExpr(Res, EndLoc);
@ -620,7 +620,7 @@ AsmParser::ApplyModifierToExpr(const MCExpr *E,
}
/// ParseExpression - Parse an expression and return it.
///
///
/// expr ::= expr +,- expr -> lowest.
/// expr ::= expr |,^,&,! expr -> middle.
/// expr ::= expr *,/,%,<<,>> expr -> highest.
@ -652,7 +652,7 @@ bool AsmParser::ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) {
"' (no symbols present)");
return true;
}
Res = ModifiedRes;
Lex();
}
@ -673,7 +673,7 @@ bool AsmParser::ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) {
bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
const MCExpr *Expr;
SMLoc StartLoc = Lexer.getLoc();
if (ParseExpression(Expr))
return true;
@ -684,7 +684,7 @@ bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
return false;
}
static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
MCBinaryExpr::Opcode &Kind) {
switch (K) {
default:
@ -698,7 +698,7 @@ static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
Kind = MCBinaryExpr::LOr;
return 1;
// Low Precedence: |, &, ^
//
// FIXME: gas seems to support '!' as an infix operator?
@ -711,7 +711,7 @@ static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
case AsmToken::Amp:
Kind = MCBinaryExpr::And;
return 2;
// Intermediate Precedence: +, -, ==, !=, <>, <, <=, >, >=
case AsmToken::Plus:
Kind = MCBinaryExpr::Add;
@ -766,18 +766,18 @@ bool AsmParser::ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res,
while (1) {
MCBinaryExpr::Opcode Kind = MCBinaryExpr::Add;
unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind);
// If the next token is lower precedence than we are allowed to eat, return
// successfully with what we ate already.
if (TokPrec < Precedence)
return false;
Lex();
// Eat the next primary expression.
const MCExpr *RHS;
if (ParsePrimaryExpr(RHS, EndLoc)) return true;
// If BinOp binds less tightly with RHS than the operator after RHS, let
// the pending operator take RHS as its LHS.
MCBinaryExpr::Opcode Dummy;
@ -791,9 +791,9 @@ bool AsmParser::ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res,
}
}
/// ParseStatement:
/// ::= EndOfStatement
/// ::= Label* Directive ...Operands... EndOfStatement
@ -844,13 +844,13 @@ bool AsmParser::ParseStatement() {
return ParseDirectiveElse(IDLoc);
if (IDVal == ".endif")
return ParseDirectiveEndIf(IDLoc);
// If we are in a ".if 0" block, ignore this statement.
if (TheCondState.Ignore) {
EatToEndOfStatement();
return false;
}
// FIXME: Recurse on local labels?
// See what kind of statement we have.
@ -873,10 +873,10 @@ bool AsmParser::ParseStatement() {
Sym = Ctx.CreateDirectionalLocalSymbol(LocalLabelVal);
if (!Sym->isUndefined() || Sym->isVariable())
return Error(IDLoc, "invalid symbol redefinition");
// Emit the label.
Out.EmitLabel(Sym);
// Consume any end of statement token, if present, to avoid spurious
// AddBlankLine calls().
if (Lexer.is(AsmToken::EndOfStatement)) {
@ -903,7 +903,7 @@ bool AsmParser::ParseStatement() {
if (const Macro *M = MacroMap.lookup(IDVal))
return HandleMacroEntry(IDVal, IDLoc, M);
// Otherwise, we have a normal instruction or directive.
// Otherwise, we have a normal instruction or directive.
if (IDVal[0] == '.') {
// Assembler features
if (IDVal == ".set")
@ -1023,7 +1023,7 @@ bool AsmParser::ParseStatement() {
SmallString<128> Opcode;
for (unsigned i = 0, e = IDVal.size(); i != e; ++i)
Opcode.push_back(tolower(IDVal[i]));
SmallVector<MCParsedAsmOperand*, 8> ParsedOperands;
bool HadError = getTargetParser().ParseInstruction(Opcode.str(), IDLoc,
ParsedOperands);
@ -1190,7 +1190,7 @@ bool AsmParser::ParseAssignment(StringRef Name) {
const MCExpr *Value;
if (ParseExpression(Value))
return true;
if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in assignment");
@ -1273,7 +1273,7 @@ bool AsmParser::ParseDirectiveSet() {
if (ParseIdentifier(Name))
return TokError("expected identifier after '.set' directive");
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.set'");
Lex();
@ -1392,7 +1392,7 @@ bool AsmParser::ParseDirectiveValue(unsigned Size) {
if (getLexer().is(AsmToken::EndOfStatement))
break;
// FIXME: Improve diagnostic.
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
@ -1420,7 +1420,7 @@ bool AsmParser::ParseDirectiveRealValue(const fltSemantics &Semantics) {
} else if (getLexer().is(AsmToken::Plus))
Lex();
if (getLexer().isNot(AsmToken::Integer) &&
if (getLexer().isNot(AsmToken::Integer) &&
getLexer().isNot(AsmToken::Real))
return TokError("unexpected token in directive");
@ -1443,7 +1443,7 @@ bool AsmParser::ParseDirectiveRealValue(const fltSemantics &Semantics) {
if (getLexer().is(AsmToken::EndOfStatement))
break;
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lex();
@ -1468,7 +1468,7 @@ bool AsmParser::ParseDirectiveSpace() {
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.space' directive");
Lex();
if (ParseAbsoluteExpression(FillExpr))
return true;
@ -1525,7 +1525,7 @@ bool AsmParser::ParseDirectiveFill() {
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.fill' directive");
Lex();
int64_t FillSize;
if (ParseAbsoluteExpression(FillSize))
return true;
@ -1533,14 +1533,14 @@ bool AsmParser::ParseDirectiveFill() {
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.fill' directive");
Lex();
int64_t FillExpr;
if (ParseAbsoluteExpression(FillExpr))
return true;
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.fill' directive");
Lex();
if (FillSize != 1 && FillSize != 2 && FillSize != 4 && FillSize != 8)
@ -1567,7 +1567,7 @@ bool AsmParser::ParseDirectiveOrg() {
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.org' directive");
Lex();
if (ParseAbsoluteExpression(FillExpr))
return true;
@ -1620,7 +1620,7 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
MaxBytesLoc = getLexer().getLoc();
if (ParseAbsoluteExpression(MaxBytesToFill))
return true;
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
}
@ -1681,7 +1681,7 @@ bool AsmParser::ParseDirectiveSymbolAttribute(MCSymbolAttr Attr) {
if (ParseIdentifier(Name))
return TokError("expected identifier in directive");
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
getStreamer().EmitSymbolAttribute(Sym, Attr);
@ -1708,7 +1708,7 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
StringRef Name;
if (ParseIdentifier(Name))
return TokError("expected identifier in directive");
// Handle the identifier as the key symbol.
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
@ -1728,7 +1728,7 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
Pow2AlignmentLoc = getLexer().getLoc();
if (ParseAbsoluteExpression(Pow2Alignment))
return true;
// If this target takes alignments in bytes (not log) validate and convert.
if (Lexer.getMAI().getAlignmentIsInBytes()) {
if (!isPowerOf2_64(Pow2Alignment))
@ -1736,10 +1736,10 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
Pow2Alignment = Log2_64(Pow2Alignment);
}
}
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.comm' or '.lcomm' directive");
Lex();
// NOTE: a size of zero for a .comm should create a undefined symbol
@ -1798,17 +1798,17 @@ bool AsmParser::ParseDirectiveAbort() {
bool AsmParser::ParseDirectiveInclude() {
if (getLexer().isNot(AsmToken::String))
return TokError("expected string in '.include' directive");
std::string Filename = getTok().getString();
SMLoc IncludeLoc = getLexer().getLoc();
Lex();
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.include' directive");
// Strip the quotes.
Filename = Filename.substr(1, Filename.size()-2);
// Attempt to switch the lexer to the included file before consuming the end
// of statement to avoid losing it when we switch.
if (EnterIncludeFile(Filename)) {
@ -1834,7 +1834,7 @@ bool AsmParser::ParseDirectiveIf(SMLoc DirectiveLoc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.if' directive");
Lex();
TheCondState.CondMet = ExprValue;
@ -1867,7 +1867,7 @@ bool AsmParser::ParseDirectiveElseIf(SMLoc DirectiveLoc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.elseif' directive");
Lex();
TheCondState.CondMet = ExprValue;
TheCondState.Ignore = !TheCondState.CondMet;
@ -1881,7 +1881,7 @@ bool AsmParser::ParseDirectiveElseIf(SMLoc DirectiveLoc) {
bool AsmParser::ParseDirectiveElse(SMLoc DirectiveLoc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.else' directive");
Lex();
if (TheCondState.TheCond != AsmCond::IfCond &&
@ -1905,7 +1905,7 @@ bool AsmParser::ParseDirectiveElse(SMLoc DirectiveLoc) {
bool AsmParser::ParseDirectiveEndIf(SMLoc DirectiveLoc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.endif' directive");
Lex();
if ((TheCondState.TheCond == AsmCond::NoCond) ||
@ -1947,8 +1947,8 @@ bool GenericAsmParser::ParseDirectiveFile(StringRef, SMLoc DirectiveLoc) {
if (FileNumber == -1)
getStreamer().EmitFileDirective(Filename);
else {
if (getContext().GetDwarfFile(Filename, FileNumber) == 0)
Error(FileNumberLoc, "file number already allocated");
if (getContext().GetDwarfFile(Filename, FileNumber) == 0)
Error(FileNumberLoc, "file number already allocated");
getStreamer().EmitDwarfFileDirective(FileNumber, Filename);
}
@ -2042,7 +2042,7 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
Flags |= DWARF2_FLAG_IS_STMT;
else
return Error(Loc, "is_stmt value not 0 or 1");
}
}
else {
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)
return Error(Loc, "isa number less than zero");
Isa = Value;
}
}
else {
return Error(Loc, "isa number not a constant value");
}

View File

@ -36,7 +36,7 @@ class X86ATTAsmParser : public TargetAsmParser {
protected:
unsigned Is64Bit : 1;
private:
MCAsmParser &getParser() const { return Parser; }
@ -57,16 +57,16 @@ private:
/// @name Auto-generated Matcher Functions
/// {
#define GET_ASSEMBLER_HEADER
#include "X86GenAsmMatcher.inc"
/// }
public:
X86ATTAsmParser(const Target &T, MCAsmParser &_Parser, TargetMachine &TM)
: TargetAsmParser(T), Parser(_Parser), TM(TM) {
// Initialize the set of available features.
setAvailableFeatures(ComputeAvailableFeatures(
&TM.getSubtarget<X86Subtarget>()));
@ -377,7 +377,7 @@ bool X86ATTAsmParser::ParseRegister(unsigned &RegNo,
// If the match failed, try the register name as lowercase.
if (RegNo == 0)
RegNo = MatchRegisterName(LowercaseString(Tok.getString()));
// FIXME: This should be done using Requires<In32BitMode> and
// Requires<In64BitMode> so "eiz" usage in 64-bit instructions
// can be also checked.
@ -779,19 +779,19 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
PatchedName = "vpclmulqdq";
}
}
Operands.push_back(X86Operand::CreateToken(PatchedName, NameLoc));
if (ExtraImmOp)
Operands.push_back(X86Operand::CreateImm(ExtraImmOp, NameLoc, NameLoc));
// Determine whether this is an instruction prefix.
bool isPrefix =
PatchedName == "lock" || PatchedName == "rep" ||
PatchedName == "lock" || PatchedName == "rep" ||
PatchedName == "repne";
// 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
// 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;
}
}
if (getLexer().isNot(AsmToken::EndOfStatement)) {
Parser.EatToEndOfStatement();
return TokError("unexpected token in argument list");
}
}
if (getLexer().is(AsmToken::EndOfStatement))
Parser.Lex(); // Consume the EndOfStatement
@ -842,7 +842,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
delete Operands[0];
Operands[0] = X86Operand::CreateToken("movabsq", NameLoc);
}
// FIXME: Hack to handle recognize s{hr,ar,hl} $1, <op>. Canonicalize to
// "shift <op>".
if ((Name.startswith("shr") || Name.startswith("sar") ||
@ -855,7 +855,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
Operands.erase(Operands.begin() + 1);
}
}
// FIXME: Hack to handle recognize "rc[lr] <op>" -> "rcl $1, <op>".
if ((Name.startswith("rcl") || Name.startswith("rcr")) &&
Operands.size() == 2) {
@ -863,7 +863,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
Operands.push_back(X86Operand::CreateImm(One, NameLoc, NameLoc));
std::swap(Operands[1], Operands[2]);
}
// FIXME: Hack to handle recognize "sh[lr]d op,op" -> "shld $1, op,op".
if ((Name.startswith("shld") || Name.startswith("shrd")) &&
Operands.size() == 3) {
@ -871,7 +871,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
Operands.insert(Operands.begin()+1,
X86Operand::CreateImm(One, NameLoc, NameLoc));
}
// FIXME: Hack to handle recognize "in[bwl] <op>". Canonicalize it to
// "inb <op>, %al".
@ -887,7 +887,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
SMLoc Loc = Operands.back()->getEndLoc();
Operands.push_back(X86Operand::CreateReg(Reg, Loc, Loc));
}
// FIXME: Hack to handle recognize "out[bwl] <op>". Canonicalize it to
// "outb %al, <op>".
if ((Name == "outb" || Name == "outw" || Name == "outl") &&
@ -903,7 +903,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
Operands.push_back(X86Operand::CreateReg(Reg, Loc, Loc));
std::swap(Operands[1], Operands[2]);
}
// FIXME: Hack to handle "out[bwl]? %al, (%dx)" -> "outb %al, %dx".
if ((Name == "outb" || Name == "outw" || Name == "outl" || Name == "out") &&
Operands.size() == 3) {
@ -917,7 +917,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
delete &Op;
}
}
// FIXME: Hack to handle "f{mul*,add*,sub*,div*} $op, st(0)" the same as
// "f{mul*,add*,sub*,div*} $op"
if ((Name.startswith("fmul") || Name.startswith("fadd") ||
@ -928,7 +928,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
delete Operands[2];
Operands.erase(Operands.begin() + 2);
}
// 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
// though they don't commute, solely because gas does support this.
@ -939,7 +939,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
delete Operands[1];
Operands.erase(Operands.begin() + 1);
}
// FIXME: Hack to handle "imul <imm>, B" which is an alias for "imul <imm>, B,
// B".
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(),
Op->getEndLoc()));
}
// '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
// errors, since its encoding is the most compact.
@ -958,7 +958,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
delete Operands[0];
Operands[0] = X86Operand::CreateToken("sldtw", NameLoc);
}
// 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
// other operand order, swap them.
@ -980,17 +980,17 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
static_cast<X86Operand*>(Operands[2])->isMem()) {
std::swap(Operands[1], Operands[2]);
}
// The assembler accepts these instructions with no operand as a synonym for
// an instruction acting on st(1). e.g. "fxch" -> "fxch %st(1)".
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") &&
Operands.size() == 1) {
Operands.push_back(X86Operand::CreateReg(MatchRegisterName("st(1)"),
NameLoc, NameLoc));
}
// The assembler accepts these instructions with two few operands as a synonym
// for taking %st(1),%st(0) or X, %st(0).
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)"),
NameLoc, NameLoc));
}
// The assembler accepts various amounts of brokenness for fnstsw.
if (Name == "fnstsw") {
if (Operands.size() == 2 &&
@ -1019,7 +1019,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
Operands.push_back(X86Operand::CreateReg(MatchRegisterName("ax"),
NameLoc, NameLoc));
}
// jmp $42,$5 -> ljmp, similarly for call.
if ((Name.startswith("call") || Name.startswith("jmp")) &&
Operands.size() == 3 &&
@ -1041,14 +1041,14 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
Name = NewOpName;
}
}
// lcall and ljmp -> lcalll and ljmpl
if ((Name == "lcall" || Name == "ljmp") && Operands.size() == 3) {
delete Operands[0];
Operands[0] = X86Operand::CreateToken(Name == "lcall" ? "lcalll" : "ljmpl",
NameLoc);
}
// call foo is not ambiguous with callw.
if (Name == "call" && Operands.size() == 2) {
const char *NewName = Is64Bit ? "callq" : "calll";
@ -1056,13 +1056,13 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
Operands[0] = X86Operand::CreateToken(NewName, NameLoc);
Name = NewName;
}
// movsd -> movsl (when no operands are specified).
if (Name == "movsd" && Operands.size() == 1) {
delete Operands[0];
Operands[0] = X86Operand::CreateToken("movsl", NameLoc);
}
// fstp <mem> -> fstps <mem>. Without this, we'll default to fstpl due to
// suffix searching.
if (Name == "fstp" && Operands.size() == 2 &&
@ -1070,8 +1070,8 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
delete Operands[0];
Operands[0] = X86Operand::CreateToken("fstps", NameLoc);
}
// "clr <reg>" -> "xor <reg>, <reg>".
if ((Name == "clrb" || Name == "clrw" || Name == "clrl" || Name == "clrq" ||
Name == "clr") && Operands.size() == 2 &&
@ -1081,7 +1081,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
delete Operands[0];
Operands[0] = X86Operand::CreateToken("xor", NameLoc);
}
return false;
}
@ -1147,11 +1147,11 @@ MatchAndEmitInstruction(SMLoc IDLoc,
delete Operands[0];
Operands[0] = X86Operand::CreateToken(Repl, IDLoc);
}
bool WasOriginallyInvalidOperand = false;
unsigned OrigErrorInfo;
MCInst Inst;
// First, try a direct match.
switch (MatchInstructionImpl(Operands, Inst, OrigErrorInfo)) {
case Match_Success:
@ -1171,7 +1171,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
// valid prefixes, and we could just infer the right unambiguous
// type. However, that requires substantially more matcher support than the
// following hack.
// Change the operand to point to a temporary token.
StringRef Base = Op->getToken();
SmallString<16> Tmp;
@ -1234,15 +1234,15 @@ MatchAndEmitInstruction(SMLoc IDLoc,
Error(IDLoc, OS.str());
return true;
}
// Okay, we know that none of the variants matched successfully.
// If all of the instructions reported an invalid mnemonic, then the original
// mnemonic was invalid.
if ((MatchB == Match_MnemonicFail) && (MatchW == Match_MnemonicFail) &&
(MatchL == Match_MnemonicFail) && (MatchQ == Match_MnemonicFail)) {
if (!WasOriginallyInvalidOperand) {
Error(IDLoc, "invalid instruction mnemonic '" + Base + "'");
Error(IDLoc, "invalid instruction mnemonic '" + Base + "'");
return true;
}
@ -1251,14 +1251,14 @@ MatchAndEmitInstruction(SMLoc IDLoc,
if (OrigErrorInfo != ~0U) {
if (OrigErrorInfo >= Operands.size())
return Error(IDLoc, "too few operands for instruction");
ErrorLoc = ((X86Operand*)Operands[OrigErrorInfo])->getStartLoc();
if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;
}
return Error(ErrorLoc, "invalid operand for instruction");
}
// If one instruction matched with a missing feature, report this as a
// missing feature.
if ((MatchB == Match_MissingFeature) + (MatchW == Match_MissingFeature) +
@ -1266,7 +1266,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
Error(IDLoc, "instruction requires a CPU feature not currently enabled");
return true;
}
// If one instruction matched with an invalid operand, report this as an
// operand failure.
if ((MatchB == Match_InvalidOperand) + (MatchW == Match_InvalidOperand) +
@ -1274,7 +1274,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
Error(IDLoc, "invalid operand for instruction");
return true;
}
// If all of these were an outright failure, report it in a useless way.
// FIXME: We should give nicer diagnostics about the exact failure.
Error(IDLoc, "unknown use of instruction mnemonic without a size suffix");