mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
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:
parent
048c00db1c
commit
3112326c88
40
support/tools/TableGen/RegisterInfoEmitter.cpp
Normal file
40
support/tools/TableGen/RegisterInfoEmitter.cpp
Normal 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) {
|
||||
|
||||
}
|
28
support/tools/TableGen/RegisterInfoEmitter.h
Normal file
28
support/tools/TableGen/RegisterInfoEmitter.h
Normal 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
|
40
utils/TableGen/RegisterInfoEmitter.cpp
Normal file
40
utils/TableGen/RegisterInfoEmitter.cpp
Normal 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) {
|
||||
|
||||
}
|
28
utils/TableGen/RegisterInfoEmitter.h
Normal file
28
utils/TableGen/RegisterInfoEmitter.h
Normal 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
|
Loading…
Reference in New Issue
Block a user