From f0567dde14b76c5339e81b28cf064e70caab0760 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 6 Aug 2014 23:21:13 +0000 Subject: [PATCH] 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 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 13 ++++++++++++- test/MC/X86/intel-syntax-2.s | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index e504f270552..17aca81d375 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -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; } diff --git a/test/MC/X86/intel-syntax-2.s b/test/MC/X86/intel-syntax-2.s index d6dbe152cd5..f7bdaf92dbb 100644 --- a/test/MC/X86/intel-syntax-2.s +++ b/test/MC/X86/intel-syntax-2.s @@ -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)