summaryrefslogtreecommitdiff
path: root/utils/TableGen/LLVMCConfigurationEmitter.cpp
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2010-02-23 09:04:28 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2010-02-23 09:04:28 +0000
commitbe6ee7c116f8f768a180df6eba6799a6660722e7 (patch)
tree3006b1eabe59ac0a33431d2652591636c7019d98 /utils/TableGen/LLVMCConfigurationEmitter.cpp
parent9f2a0802e548d07946e6ad47cb06b53c105bdb65 (diff)
downloadllvm-be6ee7c116f8f768a180df6eba6799a6660722e7.tar.gz
llvm-be6ee7c116f8f768a180df6eba6799a6660722e7.tar.bz2
llvm-be6ee7c116f8f768a180df6eba6799a6660722e7.tar.xz
New experimental/undocumented feature: 'works_on_empty'.
For now, just enough support to make -filelist work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/LLVMCConfigurationEmitter.cpp')
-rw-r--r--utils/TableGen/LLVMCConfigurationEmitter.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 98952606c9..836a7750c7 100644
--- a/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -783,6 +783,7 @@ struct ToolDescription : public RefCountedBase<ToolDescription> {
std::string OutLanguage;
std::string OutputSuffix;
unsigned Flags;
+ const Init* OnEmpty;
// Various boolean properties
void setSink() { Flags |= ToolFlags::Sink; }
@@ -792,9 +793,9 @@ struct ToolDescription : public RefCountedBase<ToolDescription> {
// Default ctor here is needed because StringMap can only store
// DefaultConstructible objects
- ToolDescription() : CmdLine(0), Actions(0), Flags(0) {}
+ ToolDescription() : CmdLine(0), Actions(0), Flags(0), OnEmpty(0) {}
ToolDescription (const std::string& n)
- : Name(n), CmdLine(0), Actions(0), Flags(0)
+ : Name(n), CmdLine(0), Actions(0), Flags(0), OnEmpty(0)
{}
};
@@ -831,6 +832,7 @@ public:
AddHandler("out_language", &CollectToolProperties::onOutLanguage);
AddHandler("output_suffix", &CollectToolProperties::onOutputSuffix);
AddHandler("sink", &CollectToolProperties::onSink);
+ AddHandler("works_on_empty", &CollectToolProperties::onWorksOnEmpty);
staticMembersInitialized_ = true;
}
@@ -907,6 +909,10 @@ private:
toolDesc_.setSink();
}
+ void onWorksOnEmpty (const DagInit& d) {
+ toolDesc_.OnEmpty = d.getArg(0);
+ }
+
};
/// CollectToolDescriptions - Gather information about tool properties
@@ -1509,7 +1515,7 @@ public:
/// EmitCaseConstructHandler - Emit code that handles the 'case'
/// construct. Takes a function object that should emit code for every case
/// clause. Implemented on top of WalkCase.
-/// Callback's type is void F(Init* Statement, unsigned IndentLevel,
+/// Callback's type is void F(const Init* Statement, unsigned IndentLevel,
/// raw_ostream& O).
/// EmitElseIf parameter controls the type of condition that is emitted ('if
/// (..) {..} else if (..) {} .. else {..}' vs. 'if (..) {..} if(..) {..}
@@ -2221,6 +2227,29 @@ void EmitIsJoinMethod (const ToolDescription& D, raw_ostream& O) {
O.indent(Indent1) << "}\n\n";
}
+/// EmitWorksOnEmptyCallback - Callback used by EmitWorksOnEmptyMethod in
+/// conjunction with EmitCaseConstructHandler.
+void EmitWorksOnEmptyCallback (const Init* Value,
+ unsigned IndentLevel, raw_ostream& O) {
+ CheckBooleanConstant(Value);
+ O.indent(IndentLevel) << "return " << Value->getAsString() << ";\n";
+}
+
+/// EmitWorksOnEmptyMethod - Emit the WorksOnEmpty() method for a given Tool
+/// class.
+void EmitWorksOnEmptyMethod (const ToolDescription& D,
+ const OptionDescriptions& OptDescs,
+ raw_ostream& O)
+{
+ O.indent(Indent1) << "bool WorksOnEmpty() const {\n";
+ if (D.OnEmpty == 0)
+ O.indent(Indent2) << "return false;\n";
+ else
+ EmitCaseConstructHandler(D.OnEmpty, Indent2, EmitWorksOnEmptyCallback,
+ /*EmitElseIf = */ true, OptDescs, O);
+ O.indent(Indent1) << "}\n\n";
+}
+
/// EmitStaticMemberDefinitions - Emit static member definitions for a
/// given Tool class.
void EmitStaticMemberDefinitions(const ToolDescription& D, raw_ostream& O) {
@@ -2255,6 +2284,7 @@ void EmitToolClassDefinition (const ToolDescription& D,
EmitNameMethod(D, O);
EmitInOutLanguageMethods(D, O);
EmitIsJoinMethod(D, O);
+ EmitWorksOnEmptyMethod(D, OptDescs, O);
EmitGenerateActionMethods(D, OptDescs, O);
// Close class definition