mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
AsmParser: Add support for the .purgem directive.
Based on a patch by Team PaX. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156709 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5cdf0add9e
commit
bc3b27ccd9
@ -336,6 +336,7 @@ public:
|
|||||||
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveMacro>(".macro");
|
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveMacro>(".macro");
|
||||||
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveEndMacro>(".endm");
|
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveEndMacro>(".endm");
|
||||||
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveEndMacro>(".endmacro");
|
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveEndMacro>(".endmacro");
|
||||||
|
AddDirectiveHandler<&GenericAsmParser::ParseDirectivePurgeMacro>(".purgem");
|
||||||
|
|
||||||
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveLEB128>(".sleb128");
|
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveLEB128>(".sleb128");
|
||||||
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveLEB128>(".uleb128");
|
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveLEB128>(".uleb128");
|
||||||
@ -367,6 +368,7 @@ public:
|
|||||||
bool ParseDirectiveMacrosOnOff(StringRef, SMLoc DirectiveLoc);
|
bool ParseDirectiveMacrosOnOff(StringRef, SMLoc DirectiveLoc);
|
||||||
bool ParseDirectiveMacro(StringRef, SMLoc DirectiveLoc);
|
bool ParseDirectiveMacro(StringRef, SMLoc DirectiveLoc);
|
||||||
bool ParseDirectiveEndMacro(StringRef, SMLoc DirectiveLoc);
|
bool ParseDirectiveEndMacro(StringRef, SMLoc DirectiveLoc);
|
||||||
|
bool ParseDirectivePurgeMacro(StringRef, SMLoc DirectiveLoc);
|
||||||
|
|
||||||
bool ParseDirectiveLEB128(StringRef, SMLoc);
|
bool ParseDirectiveLEB128(StringRef, SMLoc);
|
||||||
};
|
};
|
||||||
@ -3083,6 +3085,27 @@ bool GenericAsmParser::ParseDirectiveEndMacro(StringRef Directive,
|
|||||||
"no current macro definition");
|
"no current macro definition");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ParseDirectivePurgeMacro
|
||||||
|
/// ::= .purgem
|
||||||
|
bool GenericAsmParser::ParseDirectivePurgeMacro(StringRef Directive,
|
||||||
|
SMLoc DirectiveLoc) {
|
||||||
|
StringRef Name;
|
||||||
|
if (getParser().ParseIdentifier(Name))
|
||||||
|
return TokError("expected identifier in '.purgem' directive");
|
||||||
|
|
||||||
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
|
return TokError("unexpected token in '.purgem' directive");
|
||||||
|
|
||||||
|
StringMap<Macro*>::iterator I = getParser().MacroMap.find(Name);
|
||||||
|
if (I == getParser().MacroMap.end())
|
||||||
|
return Error(DirectiveLoc, "macro '" + Name + "' is not defined");
|
||||||
|
|
||||||
|
// Undefine the macro.
|
||||||
|
delete I->getValue();
|
||||||
|
getParser().MacroMap.erase(I);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool GenericAsmParser::ParseDirectiveLEB128(StringRef DirName, SMLoc) {
|
bool GenericAsmParser::ParseDirectiveLEB128(StringRef DirName, SMLoc) {
|
||||||
getParser().CheckForValidSection();
|
getParser().CheckForValidSection();
|
||||||
|
|
||||||
|
12
test/MC/AsmParser/purgem.s
Normal file
12
test/MC/AsmParser/purgem.s
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# RUN: not llvm-mc -triple i386-unknown-unknown %s |& FileCheck %s
|
||||||
|
|
||||||
|
.macro foo
|
||||||
|
.err
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.purgem bar
|
||||||
|
# CHECK: error: macro 'bar' is not defined
|
||||||
|
|
||||||
|
.purgem foo
|
||||||
|
foo
|
||||||
|
# CHECK: error: invalid instruction mnemonic 'foo'
|
Loading…
Reference in New Issue
Block a user