mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-16 12:24:44 +00:00
llvm-mc/AsmParser: Allow target to specific a comment delimiter, which will be
used to strip hard coded comments out of .td assembly strings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78716 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a942ad3d99
commit
59fc42debd
@ -484,6 +484,17 @@ class AsmParser {
|
|||||||
// used to support targets that need to parser multiple formats for the
|
// used to support targets that need to parser multiple formats for the
|
||||||
// assembly language.
|
// assembly language.
|
||||||
int Variant = 0;
|
int Variant = 0;
|
||||||
|
|
||||||
|
// CommentDelimiter - If given, the delimiter string used to recognize
|
||||||
|
// comments which are hard coded in the .td assembler strings for individual
|
||||||
|
// instructions.
|
||||||
|
string CommentDelimiter = "";
|
||||||
|
|
||||||
|
// RegisterPrefix - If given, the token prefix which indicates a register
|
||||||
|
// token. This is used by the matcher to automatically recognize hard coded
|
||||||
|
// register tokens as constrained registers, instead of tokens, for the
|
||||||
|
// purposes of matching.
|
||||||
|
string RegisterPrefix = "";
|
||||||
}
|
}
|
||||||
def DefaultAsmParser : AsmParser;
|
def DefaultAsmParser : AsmParser;
|
||||||
|
|
||||||
|
@ -182,6 +182,12 @@ include "X86CallingConv.td"
|
|||||||
def ATTAsmParser : AsmParser {
|
def ATTAsmParser : AsmParser {
|
||||||
string AsmParserClassName = "ATTAsmParser";
|
string AsmParserClassName = "ATTAsmParser";
|
||||||
int Variant = 0;
|
int Variant = 0;
|
||||||
|
|
||||||
|
// Discard comments in assembly strings.
|
||||||
|
string CommentDelimiter = "#";
|
||||||
|
|
||||||
|
// Recognize hard coded registers.
|
||||||
|
string RegisterPrefix = "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
// The X86 target supports two different syntaxes for emitting machine code.
|
// The X86 target supports two different syntaxes for emitting machine code.
|
||||||
|
@ -501,6 +501,15 @@ public:
|
|||||||
|
|
||||||
class AsmMatcherInfo {
|
class AsmMatcherInfo {
|
||||||
public:
|
public:
|
||||||
|
/// The tablegen AsmParser record.
|
||||||
|
Record *AsmParser;
|
||||||
|
|
||||||
|
/// The AsmParser "CommentDelimiter" value.
|
||||||
|
std::string CommentDelimiter;
|
||||||
|
|
||||||
|
/// The AsmParser "RegisterPrefix" value.
|
||||||
|
std::string RegisterPrefix;
|
||||||
|
|
||||||
/// The classes which are needed for matching.
|
/// The classes which are needed for matching.
|
||||||
std::vector<ClassInfo*> Classes;
|
std::vector<ClassInfo*> Classes;
|
||||||
|
|
||||||
@ -537,6 +546,8 @@ private:
|
|||||||
void BuildOperandClasses(CodeGenTarget &Target);
|
void BuildOperandClasses(CodeGenTarget &Target);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
AsmMatcherInfo(Record *_AsmParser);
|
||||||
|
|
||||||
/// BuildInfo - Construct the various tables used during matching.
|
/// BuildInfo - Construct the various tables used during matching.
|
||||||
void BuildInfo(CodeGenTarget &Target);
|
void BuildInfo(CodeGenTarget &Target);
|
||||||
};
|
};
|
||||||
@ -778,6 +789,13 @@ void AsmMatcherInfo::BuildOperandClasses(CodeGenTarget &Target) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AsmMatcherInfo::AsmMatcherInfo(Record *_AsmParser)
|
||||||
|
: AsmParser(_AsmParser),
|
||||||
|
CommentDelimiter(AsmParser->getValueAsString("CommentDelimiter")),
|
||||||
|
RegisterPrefix(AsmParser->getValueAsString("RegisterPrefix"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void AsmMatcherInfo::BuildInfo(CodeGenTarget &Target) {
|
void AsmMatcherInfo::BuildInfo(CodeGenTarget &Target) {
|
||||||
// Build info for the register classes.
|
// Build info for the register classes.
|
||||||
BuildRegisterClasses(Target);
|
BuildRegisterClasses(Target);
|
||||||
@ -801,6 +819,13 @@ void AsmMatcherInfo::BuildInfo(CodeGenTarget &Target) {
|
|||||||
II->Instr = &it->second;
|
II->Instr = &it->second;
|
||||||
II->AsmString = FlattenVariants(CGI.AsmString, 0);
|
II->AsmString = FlattenVariants(CGI.AsmString, 0);
|
||||||
|
|
||||||
|
// Remove comments from the asm string.
|
||||||
|
if (!CommentDelimiter.empty()) {
|
||||||
|
size_t Idx = StringRef(II->AsmString).find(CommentDelimiter);
|
||||||
|
if (Idx != StringRef::npos)
|
||||||
|
II->AsmString = II->AsmString.substr(0, Idx);
|
||||||
|
}
|
||||||
|
|
||||||
TokenizeAsmString(II->AsmString, II->Tokens);
|
TokenizeAsmString(II->AsmString, II->Tokens);
|
||||||
|
|
||||||
// Ignore instructions which shouldn't be matched.
|
// Ignore instructions which shouldn't be matched.
|
||||||
@ -1309,7 +1334,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
|
|||||||
EmitMatchRegisterName(Target, AsmParser, OS);
|
EmitMatchRegisterName(Target, AsmParser, OS);
|
||||||
|
|
||||||
// Compute the information on the instructions to match.
|
// Compute the information on the instructions to match.
|
||||||
AsmMatcherInfo Info;
|
AsmMatcherInfo Info(AsmParser);
|
||||||
Info.BuildInfo(Target);
|
Info.BuildInfo(Target);
|
||||||
|
|
||||||
// Sort the instruction table using the partial order on classes.
|
// Sort the instruction table using the partial order on classes.
|
||||||
|
Loading…
Reference in New Issue
Block a user