[llvm-commits] [llvm] r73732 - in /llvm/trunk/tools: CMakeLists.txt Makefile llvm-mc/ llvm-mc/CMakeLists.txt llvm-mc/Makefile llvm-mc/llvm-mc.cpp
Chris Lattner
sabre at nondot.org
Thu Jun 18 16:04:49 PDT 2009
Author: lattner
Date: Thu Jun 18 18:04:45 2009
New Revision: 73732
URL: http://llvm.org/viewvc/llvm-project?rev=73732&view=rev
Log:
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.
Added:
llvm/trunk/tools/llvm-mc/
llvm/trunk/tools/llvm-mc/CMakeLists.txt
llvm/trunk/tools/llvm-mc/Makefile
llvm/trunk/tools/llvm-mc/llvm-mc.cpp
Modified:
llvm/trunk/tools/CMakeLists.txt
llvm/trunk/tools/Makefile
Modified: llvm/trunk/tools/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/CMakeLists.txt?rev=73732&r1=73731&r2=73732&view=diff
==============================================================================
--- llvm/trunk/tools/CMakeLists.txt (original)
+++ llvm/trunk/tools/CMakeLists.txt Thu Jun 18 18:04:45 2009
@@ -9,6 +9,7 @@
add_subdirectory(opt)
add_subdirectory(llvm-as)
add_subdirectory(llvm-dis)
+add_subdirectory(llvm-mc)
add_subdirectory(llc)
add_subdirectory(llvm-ranlib)
Modified: llvm/trunk/tools/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/Makefile?rev=73732&r1=73731&r2=73732&view=diff
==============================================================================
--- llvm/trunk/tools/Makefile (original)
+++ llvm/trunk/tools/Makefile Thu Jun 18 18:04:45 2009
@@ -20,7 +20,8 @@
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
Added: llvm/trunk/tools/llvm-mc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/CMakeLists.txt?rev=73732&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-mc/CMakeLists.txt (added)
+++ llvm/trunk/tools/llvm-mc/CMakeLists.txt Thu Jun 18 18:04:45 2009
@@ -0,0 +1,5 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_llvm_tool(llvm-dis
+ llvm-mc.cpp
+ )
Added: llvm/trunk/tools/llvm-mc/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/Makefile?rev=73732&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-mc/Makefile (added)
+++ llvm/trunk/tools/llvm-mc/Makefile Thu Jun 18 18:04:45 2009
@@ -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
Added: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=73732&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (added)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Thu Jun 18 18:04:45 2009
@@ -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;
+}
+
More information about the llvm-commits
mailing list