summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-11 20:59:47 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-11 20:59:47 +0000
commite43187185112d7ed81b9b2614e370a3507f4bf2a (patch)
treee90ee247b5ebf217789b5cf2c35ce605085ab30e /llvm/utils
parent828e2644fc1e45c78e5c88870634a22ce0641efb (diff)
downloadbcm5719-llvm-e43187185112d7ed81b9b2614e370a3507f4bf2a.tar.gz
bcm5719-llvm-e43187185112d7ed81b9b2614e370a3507f4bf2a.zip
llvm-mc/AsmParser: Allow target to specific a comment delimiter, which will be
used to strip hard coded comments out of .td assembly strings. llvm-svn: 78716
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/AsmMatcherEmitter.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 57b93b1d270..4dbd24c70db 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -501,6 +501,15 @@ public:
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;
@@ -537,6 +546,8 @@ private:
void BuildOperandClasses(CodeGenTarget &Target);
public:
+ AsmMatcherInfo(Record *_AsmParser);
+
/// BuildInfo - Construct the various tables used during matching.
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) {
// Build info for the register classes.
BuildRegisterClasses(Target);
@@ -801,6 +819,13 @@ void AsmMatcherInfo::BuildInfo(CodeGenTarget &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.
@@ -1309,7 +1334,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
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.
OpenPOWER on IntegriCloud