mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-24 08:18:33 +00:00
*** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2552 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
21
include/llvm/Assembly/CWriter.h
Normal file
21
include/llvm/Assembly/CWriter.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//===-- llvm/CGen/Writer.h - Printer for VM assembly files -------*- C++ -*--=//
|
||||||
|
//
|
||||||
|
// This functionality is implemented by the lib/CWriter library.
|
||||||
|
// This library is used to print C language files to an iostream.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_C_WRITER_H
|
||||||
|
#define LLVM_C_WRITER_H
|
||||||
|
|
||||||
|
class Module;
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
|
||||||
|
void WriteToC(const Module *Module, std::ostream &o);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
LEVEL = ..
|
LEVEL = ..
|
||||||
DIRS = VMCore Analysis Transforms AsmParser Bytecode Support CodeGen Target
|
DIRS = VMCore Analysis Transforms AsmParser Bytecode Support CodeGen Target CWriter
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
|
|||||||
1415
lib/Target/CBackend/CBackend.cpp
Normal file
1415
lib/Target/CBackend/CBackend.cpp
Normal file
File diff suppressed because it is too large
Load Diff
7
lib/Target/CBackend/Makefile
Normal file
7
lib/Target/CBackend/Makefile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
LEVEL = ../..
|
||||||
|
|
||||||
|
LIBRARYNAME = cwriter
|
||||||
|
|
||||||
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
1415
lib/Target/CBackend/Writer.cpp
Normal file
1415
lib/Target/CBackend/Writer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
LEVEL = ../..
|
LEVEL = ../..
|
||||||
|
|
||||||
TOOLNAME = dis
|
TOOLNAME = dis
|
||||||
USEDLIBS = bcreader vmcore support
|
USEDLIBS = bcreader vmcore support cwriter
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
// -po - Print basic blocks in post order
|
// -po - Print basic blocks in post order
|
||||||
// -rpo - Print basic blocks in reverse post order
|
// -rpo - Print basic blocks in reverse post order
|
||||||
//
|
//
|
||||||
|
// -c - Print C code
|
||||||
|
//
|
||||||
// TODO: add -vcg which prints VCG compatible output.
|
// TODO: add -vcg which prints VCG compatible output.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
#include "Support/PostOrderIterator.h"
|
#include "Support/PostOrderIterator.h"
|
||||||
#include "Support/CommandLine.h"
|
#include "Support/CommandLine.h"
|
||||||
#include "Support/Signals.h"
|
#include "Support/Signals.h"
|
||||||
|
#include "llvm/Assembly/CWriter.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
@@ -34,6 +37,8 @@ enum OutputMode {
|
|||||||
rdfo, // Reverse Depth First ordering
|
rdfo, // Reverse Depth First ordering
|
||||||
po, // Post Order
|
po, // Post Order
|
||||||
rpo, // Reverse Post Order
|
rpo, // Reverse Post Order
|
||||||
|
|
||||||
|
c, // Generate C code
|
||||||
};
|
};
|
||||||
|
|
||||||
cl::String InputFilename ("", "Load <arg> file, print as assembly", 0, "-");
|
cl::String InputFilename ("", "Load <arg> file, print as assembly", 0, "-");
|
||||||
@@ -45,6 +50,8 @@ cl::EnumFlags<enum OutputMode> WriteMode(cl::NoFlags,
|
|||||||
clEnumVal(rdfo , "Write basic blocks in reverse DFO"),
|
clEnumVal(rdfo , "Write basic blocks in reverse DFO"),
|
||||||
clEnumVal(po , "Write basic blocks in postorder"),
|
clEnumVal(po , "Write basic blocks in postorder"),
|
||||||
clEnumVal(rpo , "Write basic blocks in reverse postorder"),
|
clEnumVal(rpo , "Write basic blocks in reverse postorder"),
|
||||||
|
|
||||||
|
clEnumVal(c , "Write corresponding C code"),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@@ -77,6 +84,9 @@ int main(int argc, char **argv) {
|
|||||||
} else {
|
} else {
|
||||||
OutputFilename = IFN; // Append a .ll to it
|
OutputFilename = IFN; // Append a .ll to it
|
||||||
}
|
}
|
||||||
|
if (WriteMode == c)
|
||||||
|
OutputFilename += ".c";
|
||||||
|
else
|
||||||
OutputFilename += ".ll";
|
OutputFilename += ".ll";
|
||||||
|
|
||||||
if (!Force && std::ifstream(OutputFilename.c_str())) {
|
if (!Force && std::ifstream(OutputFilename.c_str())) {
|
||||||
@@ -99,11 +109,12 @@ int main(int argc, char **argv) {
|
|||||||
Out = &std::cout;
|
Out = &std::cout;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All that dis does is write the assembly out to a file... which is exactly
|
// All that dis does is write the assembly or C out to a file... which is
|
||||||
// what the writer library is supposed to do...
|
// exactly what the writer or cwriter library is supposed to do...
|
||||||
//
|
|
||||||
if (WriteMode == Default) {
|
if (WriteMode == Default) {
|
||||||
(*Out) << M; // Print out in list order
|
(*Out) << M; // Print out in list order
|
||||||
|
} else if (WriteMode == c) {
|
||||||
|
WriteToC(M, *Out);
|
||||||
} else {
|
} else {
|
||||||
// TODO: This does not print anything other than the basic blocks in the
|
// TODO: This does not print anything other than the basic blocks in the
|
||||||
// functions... more should definately be printed. It should be valid
|
// functions... more should definately be printed. It should be valid
|
||||||
@@ -145,3 +156,4 @@ int main(int argc, char **argv) {
|
|||||||
if (Out != &std::cout) delete Out;
|
if (Out != &std::cout) delete Out;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
LEVEL = ../..
|
LEVEL = ../..
|
||||||
|
|
||||||
TOOLNAME = dis
|
TOOLNAME = dis
|
||||||
USEDLIBS = bcreader vmcore support
|
USEDLIBS = bcreader vmcore support cwriter
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
// -po - Print basic blocks in post order
|
// -po - Print basic blocks in post order
|
||||||
// -rpo - Print basic blocks in reverse post order
|
// -rpo - Print basic blocks in reverse post order
|
||||||
//
|
//
|
||||||
|
// -c - Print C code
|
||||||
|
//
|
||||||
// TODO: add -vcg which prints VCG compatible output.
|
// TODO: add -vcg which prints VCG compatible output.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
#include "Support/PostOrderIterator.h"
|
#include "Support/PostOrderIterator.h"
|
||||||
#include "Support/CommandLine.h"
|
#include "Support/CommandLine.h"
|
||||||
#include "Support/Signals.h"
|
#include "Support/Signals.h"
|
||||||
|
#include "llvm/Assembly/CWriter.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
@@ -34,6 +37,8 @@ enum OutputMode {
|
|||||||
rdfo, // Reverse Depth First ordering
|
rdfo, // Reverse Depth First ordering
|
||||||
po, // Post Order
|
po, // Post Order
|
||||||
rpo, // Reverse Post Order
|
rpo, // Reverse Post Order
|
||||||
|
|
||||||
|
c, // Generate C code
|
||||||
};
|
};
|
||||||
|
|
||||||
cl::String InputFilename ("", "Load <arg> file, print as assembly", 0, "-");
|
cl::String InputFilename ("", "Load <arg> file, print as assembly", 0, "-");
|
||||||
@@ -45,6 +50,8 @@ cl::EnumFlags<enum OutputMode> WriteMode(cl::NoFlags,
|
|||||||
clEnumVal(rdfo , "Write basic blocks in reverse DFO"),
|
clEnumVal(rdfo , "Write basic blocks in reverse DFO"),
|
||||||
clEnumVal(po , "Write basic blocks in postorder"),
|
clEnumVal(po , "Write basic blocks in postorder"),
|
||||||
clEnumVal(rpo , "Write basic blocks in reverse postorder"),
|
clEnumVal(rpo , "Write basic blocks in reverse postorder"),
|
||||||
|
|
||||||
|
clEnumVal(c , "Write corresponding C code"),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@@ -77,6 +84,9 @@ int main(int argc, char **argv) {
|
|||||||
} else {
|
} else {
|
||||||
OutputFilename = IFN; // Append a .ll to it
|
OutputFilename = IFN; // Append a .ll to it
|
||||||
}
|
}
|
||||||
|
if (WriteMode == c)
|
||||||
|
OutputFilename += ".c";
|
||||||
|
else
|
||||||
OutputFilename += ".ll";
|
OutputFilename += ".ll";
|
||||||
|
|
||||||
if (!Force && std::ifstream(OutputFilename.c_str())) {
|
if (!Force && std::ifstream(OutputFilename.c_str())) {
|
||||||
@@ -99,11 +109,12 @@ int main(int argc, char **argv) {
|
|||||||
Out = &std::cout;
|
Out = &std::cout;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All that dis does is write the assembly out to a file... which is exactly
|
// All that dis does is write the assembly or C out to a file... which is
|
||||||
// what the writer library is supposed to do...
|
// exactly what the writer or cwriter library is supposed to do...
|
||||||
//
|
|
||||||
if (WriteMode == Default) {
|
if (WriteMode == Default) {
|
||||||
(*Out) << M; // Print out in list order
|
(*Out) << M; // Print out in list order
|
||||||
|
} else if (WriteMode == c) {
|
||||||
|
WriteToC(M, *Out);
|
||||||
} else {
|
} else {
|
||||||
// TODO: This does not print anything other than the basic blocks in the
|
// TODO: This does not print anything other than the basic blocks in the
|
||||||
// functions... more should definately be printed. It should be valid
|
// functions... more should definately be printed. It should be valid
|
||||||
@@ -145,3 +156,4 @@ int main(int argc, char **argv) {
|
|||||||
if (Out != &std::cout) delete Out;
|
if (Out != &std::cout) delete Out;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
// -po - Print basic blocks in post order
|
// -po - Print basic blocks in post order
|
||||||
// -rpo - Print basic blocks in reverse post order
|
// -rpo - Print basic blocks in reverse post order
|
||||||
//
|
//
|
||||||
|
// -c - Print C code
|
||||||
|
//
|
||||||
// TODO: add -vcg which prints VCG compatible output.
|
// TODO: add -vcg which prints VCG compatible output.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
#include "Support/PostOrderIterator.h"
|
#include "Support/PostOrderIterator.h"
|
||||||
#include "Support/CommandLine.h"
|
#include "Support/CommandLine.h"
|
||||||
#include "Support/Signals.h"
|
#include "Support/Signals.h"
|
||||||
|
#include "llvm/Assembly/CWriter.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
@@ -34,6 +37,8 @@ enum OutputMode {
|
|||||||
rdfo, // Reverse Depth First ordering
|
rdfo, // Reverse Depth First ordering
|
||||||
po, // Post Order
|
po, // Post Order
|
||||||
rpo, // Reverse Post Order
|
rpo, // Reverse Post Order
|
||||||
|
|
||||||
|
c, // Generate C code
|
||||||
};
|
};
|
||||||
|
|
||||||
cl::String InputFilename ("", "Load <arg> file, print as assembly", 0, "-");
|
cl::String InputFilename ("", "Load <arg> file, print as assembly", 0, "-");
|
||||||
@@ -45,6 +50,8 @@ cl::EnumFlags<enum OutputMode> WriteMode(cl::NoFlags,
|
|||||||
clEnumVal(rdfo , "Write basic blocks in reverse DFO"),
|
clEnumVal(rdfo , "Write basic blocks in reverse DFO"),
|
||||||
clEnumVal(po , "Write basic blocks in postorder"),
|
clEnumVal(po , "Write basic blocks in postorder"),
|
||||||
clEnumVal(rpo , "Write basic blocks in reverse postorder"),
|
clEnumVal(rpo , "Write basic blocks in reverse postorder"),
|
||||||
|
|
||||||
|
clEnumVal(c , "Write corresponding C code"),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@@ -77,6 +84,9 @@ int main(int argc, char **argv) {
|
|||||||
} else {
|
} else {
|
||||||
OutputFilename = IFN; // Append a .ll to it
|
OutputFilename = IFN; // Append a .ll to it
|
||||||
}
|
}
|
||||||
|
if (WriteMode == c)
|
||||||
|
OutputFilename += ".c";
|
||||||
|
else
|
||||||
OutputFilename += ".ll";
|
OutputFilename += ".ll";
|
||||||
|
|
||||||
if (!Force && std::ifstream(OutputFilename.c_str())) {
|
if (!Force && std::ifstream(OutputFilename.c_str())) {
|
||||||
@@ -99,11 +109,12 @@ int main(int argc, char **argv) {
|
|||||||
Out = &std::cout;
|
Out = &std::cout;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All that dis does is write the assembly out to a file... which is exactly
|
// All that dis does is write the assembly or C out to a file... which is
|
||||||
// what the writer library is supposed to do...
|
// exactly what the writer or cwriter library is supposed to do...
|
||||||
//
|
|
||||||
if (WriteMode == Default) {
|
if (WriteMode == Default) {
|
||||||
(*Out) << M; // Print out in list order
|
(*Out) << M; // Print out in list order
|
||||||
|
} else if (WriteMode == c) {
|
||||||
|
WriteToC(M, *Out);
|
||||||
} else {
|
} else {
|
||||||
// TODO: This does not print anything other than the basic blocks in the
|
// TODO: This does not print anything other than the basic blocks in the
|
||||||
// functions... more should definately be printed. It should be valid
|
// functions... more should definately be printed. It should be valid
|
||||||
@@ -145,3 +156,4 @@ int main(int argc, char **argv) {
|
|||||||
if (Out != &std::cout) delete Out;
|
if (Out != &std::cout) delete Out;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user