diff options
author | Devang Patel <dpatel@apple.com> | 2012-01-31 18:14:05 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2012-01-31 18:14:05 +0000 |
commit | 0db58bfecea020ffcdfa1fc6458995371e1c3c50 (patch) | |
tree | 712d3eb75b361e652c364f3cc235bf1cc2530556 | |
parent | 48381e5d20cd61160380233e59efdc1822c7e7f4 (diff) | |
download | external_llvm-0db58bfecea020ffcdfa1fc6458995371e1c3c50.zip external_llvm-0db58bfecea020ffcdfa1fc6458995371e1c3c50.tar.gz external_llvm-0db58bfecea020ffcdfa1fc6458995371e1c3c50.tar.bz2 |
Add assembler dialect attribute in asm parser which lets target specific asm parser change dialect on the fly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149396 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/MC/MCParser/MCAsmParser.h | 1 | ||||
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 16 | ||||
-rw-r--r-- | lib/Target/X86/AsmParser/X86AsmParser.cpp | 7 |
3 files changed, 18 insertions, 6 deletions
diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h index 70df99d..793c709 100644 --- a/include/llvm/MC/MCParser/MCAsmParser.h +++ b/include/llvm/MC/MCParser/MCAsmParser.h @@ -65,6 +65,7 @@ public: void setTargetParser(MCTargetAsmParser &P); virtual unsigned getAssemblerDialect() { return 0;} + virtual void setAssemblerDialect(unsigned i) { } bool getShowParsedOperands() const { return ShowParsedOperands; } void setShowParsedOperands(bool Value) { ShowParsedOperands = Value; } diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 01f68e3..dad72d2 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -123,6 +123,9 @@ private: int64_t CppHashLineNumber; SMLoc CppHashLoc; + /// AssemblerDialect. ~OU means unset value and use value provided by MAI. + unsigned AssemblerDialect; + public: AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out, const MCAsmInfo &MAI); @@ -144,7 +147,15 @@ public: virtual MCAsmLexer &getLexer() { return Lexer; } virtual MCContext &getContext() { return Ctx; } virtual MCStreamer &getStreamer() { return Out; } - virtual unsigned getAssemblerDialect() { return MAI.getAssemblerDialect(); } + virtual unsigned getAssemblerDialect() { + if (AssemblerDialect == ~0U) + return MAI.getAssemblerDialect(); + else + return AssemblerDialect; + } + virtual void setAssemblerDialect(unsigned i) { + AssemblerDialect = i; + } virtual bool Warning(SMLoc L, const Twine &Msg, ArrayRef<SMRange> Ranges = ArrayRef<SMRange>()); @@ -369,7 +380,8 @@ AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out, const MCAsmInfo &_MAI) : Lexer(_MAI), Ctx(_Ctx), Out(_Out), MAI(_MAI), SrcMgr(_SM), GenericParser(new GenericAsmParser), PlatformParser(0), - CurBuffer(0), MacrosEnabled(true), CppHashLineNumber(0) { + CurBuffer(0), MacrosEnabled(true), CppHashLineNumber(0), + AssemblerDialect(~0U) { // Save the old handler. SavedDiagHandler = SrcMgr.getDiagHandler(); SavedDiagContext = SrcMgr.getDiagContext(); diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index fd6efa6..a1f1d5c 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -34,7 +34,6 @@ struct X86Operand; class X86AsmParser : public MCTargetAsmParser { MCSubtargetInfo &STI; MCAsmParser &Parser; - bool IntelSyntax; private: MCAsmParser &getParser() const { return Parser; } @@ -94,7 +93,7 @@ private: public: X86AsmParser(MCSubtargetInfo &sti, MCAsmParser &parser) - : MCTargetAsmParser(), STI(sti), Parser(parser), IntelSyntax(false) { + : MCTargetAsmParser(), STI(sti), Parser(parser) { // Initialize the set of available features. setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits())); @@ -107,7 +106,7 @@ public: virtual bool ParseDirective(AsmToken DirectiveID); bool isParsingIntelSyntax() { - return IntelSyntax || getParser().getAssemblerDialect(); + return getParser().getAssemblerDialect(); } }; } // end anonymous namespace @@ -1646,7 +1645,7 @@ bool X86AsmParser::ParseDirective(AsmToken DirectiveID) { else if (IDVal.startswith(".code")) return ParseDirectiveCode(IDVal, DirectiveID.getLoc()); else if (IDVal.startswith(".intel_syntax")) { - IntelSyntax = true; + getParser().setAssemblerDialect(1); if (getLexer().isNot(AsmToken::EndOfStatement)) { if(Parser.getTok().getString() == "noprefix") { // FIXME : Handle noprefix |