MC X86: Accept ".att_syntax prefix" and diagnose noprefix

Fixes PR18916.  I don't think we need to implement support for either
hybrid syntax.  Nobody should write Intel assembly with '%' prefixes on
their registers or AT&T assembly without them.

llvm-svn: 215031
This commit is contained in:
Reid Kleckner 2014-08-06 23:21:13 +00:00
parent a8c5d79f89
commit f0567dde14
2 changed files with 20 additions and 1 deletions

View File

@ -2528,14 +2528,25 @@ bool X86AsmParser::ParseDirective(AsmToken DirectiveID) {
else if (IDVal.startswith(".code"))
return ParseDirectiveCode(IDVal, DirectiveID.getLoc());
else if (IDVal.startswith(".att_syntax")) {
if (getLexer().isNot(AsmToken::EndOfStatement)) {
if (Parser.getTok().getString() == "prefix")
Parser.Lex();
else if (Parser.getTok().getString() == "noprefix")
return Error(DirectiveID.getLoc(), "'.att_syntax noprefix' is not "
"supported: registers must have a "
"'%' prefix in .att_syntax");
}
getParser().setAssemblerDialect(0);
return false;
} else if (IDVal.startswith(".intel_syntax")) {
getParser().setAssemblerDialect(1);
if (getLexer().isNot(AsmToken::EndOfStatement)) {
// FIXME: Handle noprefix
if (Parser.getTok().getString() == "noprefix")
Parser.Lex();
else if (Parser.getTok().getString() == "prefix")
return Error(DirectiveID.getLoc(), "'.intel_syntax prefix' is not "
"supported: registers must not have "
"a '%' prefix in .intel_syntax");
}
return false;
}

View File

@ -7,3 +7,11 @@ _test:
.att_syntax
// CHECK: movl $257, -4(%rsp)
movl $257, -4(%rsp)
_test2:
.intel_syntax noprefix
mov DWORD PTR [RSP - 4], 255
// CHECK: movl $255, -4(%rsp)
.att_syntax prefix
movl $255, -4(%rsp)
// CHECK: movl $255, -4(%rsp)