From f00ce8bc29c3194485b7251dd3e234cead10008e Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Sat, 24 May 2003 00:17:12 +0000 Subject: [PATCH] Add ability to utilize the code emitter generator (CodeEmitterGen). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6322 91177308-0d34-0410-b5e6-96231b3b80d8 --- support/tools/TableGen/TableGen.cpp | 22 +++++++++++++++++++++- utils/TableGen/TableGen.cpp | 22 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/support/tools/TableGen/TableGen.cpp b/support/tools/TableGen/TableGen.cpp index 35df907c2d6..5eb5a7c4c99 100644 --- a/support/tools/TableGen/TableGen.cpp +++ b/support/tools/TableGen/TableGen.cpp @@ -1,9 +1,11 @@ #include "Record.h" #include "Support/CommandLine.h" +#include "CodeEmitterGen.h" #include static cl::opt Class("class", cl::desc("Print Enum list for this class")); static cl::opt Parse("parse"); +static cl::opt GenEmitter("gen-emitter"); void ParseFile(); @@ -289,6 +291,7 @@ static void PrintInstruction(Record *I, unsigned char *Ptr) { } static void ParseMachineCode() { + // X86 code unsigned char Buffer[] = { 0x55, // push EBP 0x89, 0xE5, // mov EBP, ESP @@ -307,7 +310,18 @@ static void ParseMachineCode() { 0x85, 0xC0, // test EAX, EAX 0xF4, // hlt }; - + +#if 0 + // SparcV9 code + unsigned char Buffer[] = { 0xbf, 0xe0, 0x20, 0x1f, 0x1, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x0, 0x0, 0xc1, 0x0, 0x20, 0x1, 0x1, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0xaf, 0xe8, 0x20, 0x17 + }; +#endif + std::vector Insts; const std::map &Defs = Records.getDefs(); @@ -344,6 +358,12 @@ int main(int argc, char **argv) { return 0; } + if (GenEmitter) { + CodeEmitterGen CEG(Records); + CEG.createEmitter(std::cout); + return 0; + } + if (Class == "") { std::cout << Records; // No argument, dump all contents } else { diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp index 35df907c2d6..5eb5a7c4c99 100644 --- a/utils/TableGen/TableGen.cpp +++ b/utils/TableGen/TableGen.cpp @@ -1,9 +1,11 @@ #include "Record.h" #include "Support/CommandLine.h" +#include "CodeEmitterGen.h" #include static cl::opt Class("class", cl::desc("Print Enum list for this class")); static cl::opt Parse("parse"); +static cl::opt GenEmitter("gen-emitter"); void ParseFile(); @@ -289,6 +291,7 @@ static void PrintInstruction(Record *I, unsigned char *Ptr) { } static void ParseMachineCode() { + // X86 code unsigned char Buffer[] = { 0x55, // push EBP 0x89, 0xE5, // mov EBP, ESP @@ -307,7 +310,18 @@ static void ParseMachineCode() { 0x85, 0xC0, // test EAX, EAX 0xF4, // hlt }; - + +#if 0 + // SparcV9 code + unsigned char Buffer[] = { 0xbf, 0xe0, 0x20, 0x1f, 0x1, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x0, 0x0, 0xc1, 0x0, 0x20, 0x1, 0x1, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x1, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0xaf, 0xe8, 0x20, 0x17 + }; +#endif + std::vector Insts; const std::map &Defs = Records.getDefs(); @@ -344,6 +358,12 @@ int main(int argc, char **argv) { return 0; } + if (GenEmitter) { + CodeEmitterGen CEG(Records); + CEG.createEmitter(std::cout); + return 0; + } + if (Class == "") { std::cout << Records; // No argument, dump all contents } else {