mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
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
This commit is contained in:
parent
48381e5d20
commit
0db58bfece
@ -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; }
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user