summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-18 23:04:45 +0000
committerChris Lattner <sabre@nondot.org>2009-06-18 23:04:45 +0000
commitf9f065e45500823cdeb25bde2154d871ab6e9125 (patch)
tree7e48ae8c91c40929a1da3241e67d6476f01e69db
parent3ea4edce6a288579d190460135dc7255e9e1d294 (diff)
downloadllvm-f9f065e45500823cdeb25bde2154d871ab6e9125.tar.gz
llvm-f9f065e45500823cdeb25bde2154d871ab6e9125.tar.bz2
llvm-f9f065e45500823cdeb25bde2154d871ab6e9125.tar.xz
Add a skeleton driver for new machine code level fun. llvm-mc is meant
to be a test driver of other components in the system, which will develop over time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73732 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/CMakeLists.txt1
-rw-r--r--tools/Makefile3
-rw-r--r--tools/llvm-mc/CMakeLists.txt5
-rw-r--r--tools/llvm-mc/Makefile17
-rw-r--r--tools/llvm-mc/llvm-mc.cpp61
5 files changed, 86 insertions, 1 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 5c1ee351a2..7191d80354 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -9,6 +9,7 @@ endif()
add_subdirectory(opt)
add_subdirectory(llvm-as)
add_subdirectory(llvm-dis)
+add_subdirectory(llvm-mc)
add_subdirectory(llc)
add_subdirectory(llvm-ranlib)
diff --git a/tools/Makefile b/tools/Makefile
index b3c015f307..5ed090ea0e 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -20,7 +20,8 @@ PARALLEL_DIRS := opt llvm-as llvm-dis \
llc llvm-ranlib llvm-ar llvm-nm \
llvm-ld llvm-prof llvm-link \
lli gccas gccld llvm-extract llvm-db \
- bugpoint llvm-bcanalyzer llvm-stub llvmc
+ bugpoint llvm-bcanalyzer llvm-stub llvmc \
+ llvm-mc
# Let users override the set of tools to build from the command line.
ifdef ONLY_TOOLS
diff --git a/tools/llvm-mc/CMakeLists.txt b/tools/llvm-mc/CMakeLists.txt
new file mode 100644
index 0000000000..a932cca628
--- /dev/null
+++ b/tools/llvm-mc/CMakeLists.txt
@@ -0,0 +1,5 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_llvm_tool(llvm-dis
+ llvm-mc.cpp
+ )
diff --git a/tools/llvm-mc/Makefile b/tools/llvm-mc/Makefile
new file mode 100644
index 0000000000..7b4d944456
--- /dev/null
+++ b/tools/llvm-mc/Makefile
@@ -0,0 +1,17 @@
+##===- tools/llvm-mc/Makefile ------------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../..
+TOOLNAME = llvm-mc
+LINK_COMPONENTS := support
+
+# This tool has no plugins, optimize startup time.
+TOOL_NO_EXPORTS = 1
+
+include $(LEVEL)/Makefile.common
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
new file mode 100644
index 0000000000..80a83d9040
--- /dev/null
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -0,0 +1,61 @@
+//===-- llvm-dis.cpp - The low-level LLVM disassembler --------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This utility may be invoked in the following manner:
+// llvm-dis [options] - Read LLVM bitcode from stdin, write asm to stdout
+// llvm-dis [options] x.bc - Read LLVM bitcode from the x.bc file, write asm
+// to the x.ll file.
+// Options:
+// --help - Output information about command line switches
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/System/Signals.h"
+using namespace llvm;
+
+static cl::opt<std::string>
+InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
+
+static cl::opt<std::string>
+OutputFilename("o", cl::desc("Output filename"),
+ cl::value_desc("filename"));
+
+int main(int argc, char **argv) {
+ // Print a stack trace if we signal out.
+ sys::PrintStackTraceOnErrorSignal();
+ PrettyStackTraceProgram X(argc, argv);
+
+ llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+
+ cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
+
+ std::string ErrorMessage;
+
+ MemoryBuffer *Buffer
+ = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage);
+
+ if (Buffer == 0) {
+ errs() << argv[0] << ": ";
+ if (ErrorMessage.size())
+ errs() << ErrorMessage << "\n";
+ else
+ errs() << "input file didn't read correctly.\n";
+ return 1;
+ }
+
+
+
+ return 0;
+}
+