summaryrefslogtreecommitdiff
path: root/utils/TableGen/InstrInfoEmitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-06 04:32:07 +0000
committerChris Lattner <sabre@nondot.org>2003-08-06 04:32:07 +0000
commitbc01723605de979e67b1aea67385a029f851de34 (patch)
tree782135308f0fbd600844d81afc2e5434f9f8685c /utils/TableGen/InstrInfoEmitter.cpp
parent18a6a94e1fc5cd10d50a91598b1465f31e307266 (diff)
downloadllvm-bc01723605de979e67b1aea67385a029f851de34.tar.gz
llvm-bc01723605de979e67b1aea67385a029f851de34.tar.bz2
llvm-bc01723605de979e67b1aea67385a029f851de34.tar.xz
Switch code over to being a TableGenBackend
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7627 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/InstrInfoEmitter.cpp')
-rw-r--r--utils/TableGen/InstrInfoEmitter.cpp29
1 files changed, 4 insertions, 25 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp
index 761bdeef0c..ad501dc426 100644
--- a/utils/TableGen/InstrInfoEmitter.cpp
+++ b/utils/TableGen/InstrInfoEmitter.cpp
@@ -8,27 +8,6 @@
#include "InstrInfoEmitter.h"
#include "Record.h"
-static void EmitSourceHeader(const std::string &Desc, std::ostream &o) {
- o << "//===- TableGen'erated file -------------------------------------*-"
- " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate"
- "d file, do not edit!\n//\n//===------------------------------------"
- "----------------------------------===//\n\n";
-}
-
-static std::string getQualifiedName(Record *R) {
- std::string Namespace = R->getValueAsString("Namespace");
- if (Namespace.empty()) return R->getName();
- return Namespace + "::" + R->getName();
-}
-
-static Record *getTarget(RecordKeeper &RC) {
- std::vector<Record*> Targets = RC.getAllDerivedDefinitions("Target");
-
- if (Targets.size() != 1)
- throw std::string("ERROR: Multiple subclasses of Target defined!");
- return Targets[0];
-}
-
// runEnums - Print out enum values for all of the instructions.
void InstrInfoEmitter::runEnums(std::ostream &OS) {
std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
@@ -38,7 +17,7 @@ void InstrInfoEmitter::runEnums(std::ostream &OS) {
std::string Namespace = Insts[0]->getValueAsString("Namespace");
- EmitSourceHeader("Target Instruction Enum Values", OS);
+ EmitSourceFileHeader("Target Instruction Enum Values", OS);
if (!Namespace.empty())
OS << "namespace " << Namespace << " {\n";
@@ -61,8 +40,8 @@ void InstrInfoEmitter::runEnums(std::ostream &OS) {
OS << "}\n";
}
-static void printDefList(ListInit *LI, const std::string &Name,
- std::ostream &OS) {
+void InstrInfoEmitter::printDefList(ListInit *LI, const std::string &Name,
+ std::ostream &OS) const {
OS << "static const unsigned " << Name << "[] = { ";
for (unsigned j = 0, e = LI->getSize(); j != e; ++j)
if (DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(j)))
@@ -75,7 +54,7 @@ static void printDefList(ListInit *LI, const std::string &Name,
// run - Emit the main instruction description records for the target...
void InstrInfoEmitter::run(std::ostream &OS) {
- EmitSourceHeader("Target Instruction Descriptors", OS);
+ EmitSourceFileHeader("Target Instruction Descriptors", OS);
Record *Target = getTarget(Records);
const std::string &TargetName = Target->getName();
Record *InstrInfo = Target->getValueAsDef("InstructionSet");