Initial checkin of register info emitter

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7465 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-08-01 04:38:38 +00:00
parent 048c00db1c
commit 3112326c88
4 changed files with 136 additions and 0 deletions

View File

@ -0,0 +1,40 @@
//===- RegisterInfoEmitter.cpp - Generate a Register File Desc. -*- C++ -*-===//
//
// This tablegen backend is responsible for emitting a description of a target
// register file for a code generator. It uses instances of the Register,
// RegisterAliases, and RegisterClass classes to gather this information.
//
//===----------------------------------------------------------------------===//
#include "RegisterInfoEmitter.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";
}
void RegisterInfoEmitter::runHeader(std::ostream &OS) {
std::vector<Record*> RegisterInfos =
Records.getAllDerivedDefinitions("RegisterInfo");
if (RegisterInfos.size() != 1)
throw std::string("ERROR: Multiple subclasses of RegisterInfo defined!");
EmitSourceHeader("Register Information Header Fragment", OS);
std::string ClassName = RegisterInfos[0]->getValueAsString("ClassName");
OS << "#include \"llvm/CodeGen/MRegisterInfo.h\"\n\n";
OS << "struct " << ClassName << ": public MRegisterInfo {\n"
<< " " << ClassName << "();\n"
<< " const unsigned* getCalleeSaveRegs() const;\n"
<< "};\n\n";
}
void RegisterInfoEmitter::run(std::ostream &o) {
}

View File

@ -0,0 +1,28 @@
//===- RegisterInfoEmitter.h - Generate a Register File Desc. ---*- C++ -*-===//
//
// This tablegen backend is responsible for emitting a description of a target
// register file for a code generator. It uses instances of the Register,
// RegisterAliases, and RegisterClass classes to gather this information.
//
//===----------------------------------------------------------------------===//
#ifndef REGISTER_INFO_EMITTER_H
#define REGISTER_INFO_EMITTER_H
#include <iosfwd>
class RecordKeeper;
class RegisterInfoEmitter {
RecordKeeper &Records;
public:
RegisterInfoEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the register file description, returning true on failure.
void run(std::ostream &o);
// runHeader - Emit a header fragment for the register info emitter.
void runHeader(std::ostream &o);
private:
};
#endif

View File

@ -0,0 +1,40 @@
//===- RegisterInfoEmitter.cpp - Generate a Register File Desc. -*- C++ -*-===//
//
// This tablegen backend is responsible for emitting a description of a target
// register file for a code generator. It uses instances of the Register,
// RegisterAliases, and RegisterClass classes to gather this information.
//
//===----------------------------------------------------------------------===//
#include "RegisterInfoEmitter.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";
}
void RegisterInfoEmitter::runHeader(std::ostream &OS) {
std::vector<Record*> RegisterInfos =
Records.getAllDerivedDefinitions("RegisterInfo");
if (RegisterInfos.size() != 1)
throw std::string("ERROR: Multiple subclasses of RegisterInfo defined!");
EmitSourceHeader("Register Information Header Fragment", OS);
std::string ClassName = RegisterInfos[0]->getValueAsString("ClassName");
OS << "#include \"llvm/CodeGen/MRegisterInfo.h\"\n\n";
OS << "struct " << ClassName << ": public MRegisterInfo {\n"
<< " " << ClassName << "();\n"
<< " const unsigned* getCalleeSaveRegs() const;\n"
<< "};\n\n";
}
void RegisterInfoEmitter::run(std::ostream &o) {
}

View File

@ -0,0 +1,28 @@
//===- RegisterInfoEmitter.h - Generate a Register File Desc. ---*- C++ -*-===//
//
// This tablegen backend is responsible for emitting a description of a target
// register file for a code generator. It uses instances of the Register,
// RegisterAliases, and RegisterClass classes to gather this information.
//
//===----------------------------------------------------------------------===//
#ifndef REGISTER_INFO_EMITTER_H
#define REGISTER_INFO_EMITTER_H
#include <iosfwd>
class RecordKeeper;
class RegisterInfoEmitter {
RecordKeeper &Records;
public:
RegisterInfoEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the register file description, returning true on failure.
void run(std::ostream &o);
// runHeader - Emit a header fragment for the register info emitter.
void runHeader(std::ostream &o);
private:
};
#endif