summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-06-25 03:32:05 +0000
committerChris Lattner <sabre@nondot.org>2005-06-25 03:32:05 +0000
commit812125aea956d0c22d92b456dbc5030a1d2780ef (patch)
tree6d538310710c6f8a7e8b0749c946027eb50e892e /tools
parent33f80a87230f61b85f62cbc956b6f521b6e2063c (diff)
downloadllvm-812125aea956d0c22d92b456dbc5030a1d2780ef.tar.gz
llvm-812125aea956d0c22d92b456dbc5030a1d2780ef.tar.bz2
llvm-812125aea956d0c22d92b456dbc5030a1d2780ef.tar.xz
add a new -filetype argument to llc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llc/llc.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index a6f3e8a5ec..70d8c70fc3 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -23,6 +23,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/System/Signals.h"
+#include "llvm/Config/config.h"
#include <fstream>
#include <iostream>
#include <memory>
@@ -44,7 +45,20 @@ static cl::opt<bool> Force("f", cl::desc("Overwrite output files"));
static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser>
MArch("march", cl::desc("Architecture to generate code for:"));
-// GetFileNameRoot - Helper function to get the basename of a filename...
+cl::opt<TargetMachine::CodeGenFileType>
+FileType("filetype", cl::init(TargetMachine::AssemblyFile),
+ cl::desc("Choose a file type (not all types are supported by all targets):"),
+ cl::values(
+ clEnumValN(TargetMachine::AssemblyFile, "asm",
+ " Emit an assembly ('.s') file"),
+ clEnumValN(TargetMachine::ObjectFile, "obj",
+ " Emit a native object ('.o') file"),
+ clEnumValN(TargetMachine::DynamicLibrary, "dynlib",
+ " Emit a native dynamic library ('.so') file"),
+ clEnumValEnd));
+
+
+// GetFileNameRoot - Helper function to get the basename of a filename.
static inline std::string
GetFileNameRoot(const std::string &InputFilename) {
std::string IFN = InputFilename;
@@ -126,10 +140,20 @@ int main(int argc, char **argv) {
} else {
OutputFilename = GetFileNameRoot(InputFilename);
- if (MArch->Name[0] != 'c' || MArch->Name[1] != 0) // not CBE
- OutputFilename += ".s";
- else
- OutputFilename += ".cbe.c";
+ switch (FileType) {
+ case TargetMachine::AssemblyFile:
+ if (MArch->Name[0] != 'c' || MArch->Name[1] != 0) // not CBE
+ OutputFilename += ".s";
+ else
+ OutputFilename += ".cbe.c";
+ break;
+ case TargetMachine::ObjectFile:
+ OutputFilename += ".o";
+ break;
+ case TargetMachine::DynamicLibrary:
+ OutputFilename += LTDL_SHLIB_EXT;
+ break;
+ }
if (!Force && std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file!
@@ -153,9 +177,9 @@ int main(int argc, char **argv) {
}
// Ask the target to add backend passes as necessary.
- if (Target.addPassesToEmitFile(Passes, *Out, TargetMachine::AssemblyFile)) {
+ if (Target.addPassesToEmitFile(Passes, *Out, FileType)) {
std::cerr << argv[0] << ": target '" << Target.getName()
- << "' does not support static compilation!\n";
+ << "' does not support generation of this file type!\n";
if (Out != &std::cout) delete Out;
// And the Out file is empty and useless, so remove it now.
std::remove(OutputFilename.c_str());