Skip to content

Commit

Permalink
convert over to using TableGen backends
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7628 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Aug 6, 2003
1 parent bc01723 commit 0e5e49e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 62 deletions.
2 changes: 2 additions & 0 deletions support/tools/TableGen/CodeEmitterGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
void CodeEmitterGen::run(std::ostream &o) {
std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");

EmitSourceFileHeader("Machine Code Emitter", o);

std::string Namespace = "V9::";
std::string ClassName = "SparcV9CodeEmitter::";

Expand Down
6 changes: 2 additions & 4 deletions support/tools/TableGen/CodeEmitterGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
#ifndef CODEMITTERGEN_H
#define CODEMITTERGEN_H

#include <string>
#include <iosfwd>
class RecordKeeper;
#include "TableGenBackend.h"

class CodeEmitterGen {
class CodeEmitterGen : public TableGenBackend {
RecordKeeper &Records;
public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {}
Expand Down
27 changes: 3 additions & 24 deletions support/tools/TableGen/RegisterInfoEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
#include "Support/StringExtras.h"
#include <set>

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";
}

// runEnums - Print out enum values for all of the registers.
void RegisterInfoEmitter::runEnums(std::ostream &OS) {
std::vector<Record*> Registers = Records.getAllDerivedDefinitions("Register");
Expand All @@ -27,7 +20,7 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) {

std::string Namespace = Registers[0]->getValueAsString("Namespace");

EmitSourceHeader("Target Register Enum Values", OS);
EmitSourceFileHeader("Target Register Enum Values", OS);

if (!Namespace.empty())
OS << "namespace " << Namespace << " {\n";
Expand All @@ -41,22 +34,8 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) {
OS << "}\n";
}

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];
}

static std::string getQualifiedName(Record *R) {
std::string Namespace = R->getValueAsString("Namespace");
if (Namespace.empty()) return R->getName();
return Namespace + "::" + R->getName();
}

void RegisterInfoEmitter::runHeader(std::ostream &OS) {
EmitSourceHeader("Register Information Header Fragment", OS);
EmitSourceFileHeader("Register Information Header Fragment", OS);

std::string ClassName = getTarget(Records)->getName() + "GenRegisterInfo";

Expand All @@ -72,7 +51,7 @@ void RegisterInfoEmitter::runHeader(std::ostream &OS) {
// RegisterInfoEmitter::run - Main register file description emitter.
//
void RegisterInfoEmitter::run(std::ostream &OS) {
EmitSourceHeader("Register Information Source Fragment", OS);
EmitSourceFileHeader("Register Information Source Fragment", OS);

// Start out by emitting each of the register classes... to do this, we build
// a set of registers which belong to a register class, this is to ensure that
Expand Down
5 changes: 2 additions & 3 deletions support/tools/TableGen/RegisterInfoEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#ifndef REGISTER_INFO_EMITTER_H
#define REGISTER_INFO_EMITTER_H

#include <iosfwd>
class RecordKeeper;
#include "TableGenBackend.h"

class RegisterInfoEmitter {
class RegisterInfoEmitter : public TableGenBackend {
RecordKeeper &Records;
public:
RegisterInfoEmitter(RecordKeeper &R) : Records(R) {}
Expand Down
2 changes: 2 additions & 0 deletions utils/TableGen/CodeEmitterGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
void CodeEmitterGen::run(std::ostream &o) {
std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");

EmitSourceFileHeader("Machine Code Emitter", o);

std::string Namespace = "V9::";
std::string ClassName = "SparcV9CodeEmitter::";

Expand Down
6 changes: 2 additions & 4 deletions utils/TableGen/CodeEmitterGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
#ifndef CODEMITTERGEN_H
#define CODEMITTERGEN_H

#include <string>
#include <iosfwd>
class RecordKeeper;
#include "TableGenBackend.h"

class CodeEmitterGen {
class CodeEmitterGen : public TableGenBackend {
RecordKeeper &Records;
public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {}
Expand Down
27 changes: 3 additions & 24 deletions utils/TableGen/RegisterInfoEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
#include "Support/StringExtras.h"
#include <set>

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";
}

// runEnums - Print out enum values for all of the registers.
void RegisterInfoEmitter::runEnums(std::ostream &OS) {
std::vector<Record*> Registers = Records.getAllDerivedDefinitions("Register");
Expand All @@ -27,7 +20,7 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) {

std::string Namespace = Registers[0]->getValueAsString("Namespace");

EmitSourceHeader("Target Register Enum Values", OS);
EmitSourceFileHeader("Target Register Enum Values", OS);

if (!Namespace.empty())
OS << "namespace " << Namespace << " {\n";
Expand All @@ -41,22 +34,8 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) {
OS << "}\n";
}

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];
}

static std::string getQualifiedName(Record *R) {
std::string Namespace = R->getValueAsString("Namespace");
if (Namespace.empty()) return R->getName();
return Namespace + "::" + R->getName();
}

void RegisterInfoEmitter::runHeader(std::ostream &OS) {
EmitSourceHeader("Register Information Header Fragment", OS);
EmitSourceFileHeader("Register Information Header Fragment", OS);

std::string ClassName = getTarget(Records)->getName() + "GenRegisterInfo";

Expand All @@ -72,7 +51,7 @@ void RegisterInfoEmitter::runHeader(std::ostream &OS) {
// RegisterInfoEmitter::run - Main register file description emitter.
//
void RegisterInfoEmitter::run(std::ostream &OS) {
EmitSourceHeader("Register Information Source Fragment", OS);
EmitSourceFileHeader("Register Information Source Fragment", OS);

// Start out by emitting each of the register classes... to do this, we build
// a set of registers which belong to a register class, this is to ensure that
Expand Down
5 changes: 2 additions & 3 deletions utils/TableGen/RegisterInfoEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#ifndef REGISTER_INFO_EMITTER_H
#define REGISTER_INFO_EMITTER_H

#include <iosfwd>
class RecordKeeper;
#include "TableGenBackend.h"

class RegisterInfoEmitter {
class RegisterInfoEmitter : public TableGenBackend {
RecordKeeper &Records;
public:
RegisterInfoEmitter(RecordKeeper &R) : Records(R) {}
Expand Down

0 comments on commit 0e5e49e

Please sign in to comment.