[llvm-commits] [llvm] r149270 - in /llvm/trunk: lib/Target/X86/AsmParser/X86AsmParser.cpp test/MC/X86/intel-syntax-2.s
Devang Patel
dpatel at apple.com
Mon Jan 30 12:02:43 PST 2012
Author: dpatel
Date: Mon Jan 30 14:02:42 2012
New Revision: 149270
URL: http://llvm.org/viewvc/llvm-project?rev=149270&view=rev
Log:
Intel syntax. Support .intel_syntax directive.
Added:
llvm/trunk/test/MC/X86/intel-syntax-2.s
Modified:
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=149270&r1=149269&r2=149270&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Mon Jan 30 14:02:42 2012
@@ -34,7 +34,7 @@
class X86AsmParser : public MCTargetAsmParser {
MCSubtargetInfo &STI;
MCAsmParser &Parser;
-
+ bool IntelSyntax;
private:
MCAsmParser &getParser() const { return Parser; }
@@ -94,7 +94,7 @@
public:
X86AsmParser(MCSubtargetInfo &sti, MCAsmParser &parser)
- : MCTargetAsmParser(), STI(sti), Parser(parser) {
+ : MCTargetAsmParser(), STI(sti), Parser(parser), IntelSyntax(false) {
// Initialize the set of available features.
setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
@@ -105,6 +105,10 @@
SmallVectorImpl<MCParsedAsmOperand*> &Operands);
virtual bool ParseDirective(AsmToken DirectiveID);
+
+ bool isParsingIntelSyntax() {
+ return IntelSyntax || getParser().getAssemblerDialect();
+ }
};
} // end anonymous namespace
@@ -470,8 +474,7 @@
bool X86AsmParser::ParseRegister(unsigned &RegNo,
SMLoc &StartLoc, SMLoc &EndLoc) {
RegNo = 0;
- bool IntelSyntax = getParser().getAssemblerDialect();
- if (!IntelSyntax) {
+ if (!isParsingIntelSyntax()) {
const AsmToken &TokPercent = Parser.getTok();
assert(TokPercent.is(AsmToken::Percent) && "Invalid token kind!");
StartLoc = TokPercent.getLoc();
@@ -480,7 +483,7 @@
const AsmToken &Tok = Parser.getTok();
if (Tok.isNot(AsmToken::Identifier)) {
- if (IntelSyntax) return true;
+ if (isParsingIntelSyntax()) return true;
return Error(StartLoc, "invalid register name",
SMRange(StartLoc, Tok.getEndLoc()));
}
@@ -564,7 +567,7 @@
}
if (RegNo == 0) {
- if (IntelSyntax) return true;
+ if (isParsingIntelSyntax()) return true;
return Error(StartLoc, "invalid register name",
SMRange(StartLoc, Tok.getEndLoc()));
}
@@ -575,7 +578,7 @@
}
X86Operand *X86AsmParser::ParseOperand() {
- if (getParser().getAssemblerDialect())
+ if (isParsingIntelSyntax())
return ParseIntelOperand();
return ParseATTOperand();
}
@@ -1170,7 +1173,7 @@
Name.startswith("rcl") || Name.startswith("rcr") ||
Name.startswith("rol") || Name.startswith("ror")) &&
Operands.size() == 3) {
- if (getParser().getAssemblerDialect()) {
+ if (isParsingIntelSyntax()) {
// Intel syntax
X86Operand *Op1 = static_cast<X86Operand*>(Operands[2]);
if (Op1->isImm() && isa<MCConstantExpr>(Op1->getImm()) &&
@@ -1485,8 +1488,8 @@
MCInst Inst;
// First, try a direct match.
- switch (MatchInstructionImpl(Operands, Inst, OrigErrorInfo,
- getParser().getAssemblerDialect())) {
+ switch (MatchInstructionImpl(Operands, Inst, OrigErrorInfo,
+ isParsingIntelSyntax())) {
default: break;
case Match_Success:
// Some instructions need post-processing to, for example, tweak which
@@ -1640,6 +1643,17 @@
return ParseDirectiveWord(2, DirectiveID.getLoc());
else if (IDVal.startswith(".code"))
return ParseDirectiveCode(IDVal, DirectiveID.getLoc());
+ else if (IDVal.startswith(".intel_syntax")) {
+ IntelSyntax = true;
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
+ if(Parser.getTok().getString() == "noprefix") {
+ // FIXME : Handle noprefix
+ Parser.Lex();
+ } else
+ return true;
+ }
+ return false;
+ }
return true;
}
Added: llvm/trunk/test/MC/X86/intel-syntax-2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/intel-syntax-2.s?rev=149270&view=auto
==============================================================================
--- llvm/trunk/test/MC/X86/intel-syntax-2.s (added)
+++ llvm/trunk/test/MC/X86/intel-syntax-2.s Mon Jan 30 14:02:42 2012
@@ -0,0 +1,7 @@
+// RUN: llvm-mc -triple x86_64-unknown-unknown %s | FileCheck %s
+
+ .intel_syntax
+_test:
+// CHECK: movl $257, -4(%rsp)
+ mov DWORD PTR [RSP - 4], 257
+
More information about the llvm-commits
mailing list