// used to support targets that need to parser multiple formats for the
// assembly language.
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 ATTAsmParser : AsmParser {
string AsmParserClassName = "ATTAsmParser";
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.
class AsmMatcherInfo {
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.
std::vector<ClassInfo*> Classes;
void BuildOperandClasses(CodeGenTarget &Target);
public:
+ AsmMatcherInfo(Record *_AsmParser);
+
/// BuildInfo - Construct the various tables used during matching.
void BuildInfo(CodeGenTarget &Target);
};
}
}
+AsmMatcherInfo::AsmMatcherInfo(Record *_AsmParser)
+ : AsmParser(_AsmParser),
+ CommentDelimiter(AsmParser->getValueAsString("CommentDelimiter")),
+ RegisterPrefix(AsmParser->getValueAsString("RegisterPrefix"))
+{
+}
+
void AsmMatcherInfo::BuildInfo(CodeGenTarget &Target) {
// Build info for the register classes.
BuildRegisterClasses(Target);
II->Instr = &it->second;
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);
// Ignore instructions which shouldn't be matched.
EmitMatchRegisterName(Target, AsmParser, OS);
// Compute the information on the instructions to match.
- AsmMatcherInfo Info;
+ AsmMatcherInfo Info(AsmParser);
Info.BuildInfo(Target);
// Sort the instruction table using the partial order on classes.