blob: e8e51c5023e8247e29bfb81ff9bc982211382091 [file] [log] [blame]
Chris Lattnerbb4688a2009-06-18 23:05:21 +00001//===-- llvm-mc.cpp - Machine Code Hacking Driver -------------------------===//
Chris Lattnerf9f065e2009-06-18 23:04:45 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Chris Lattnerbb4688a2009-06-18 23:05:21 +000010// This utility is a simple driver that allows command line hacking on machine
11// code.
Chris Lattnerf9f065e2009-06-18 23:04:45 +000012//
13//===----------------------------------------------------------------------===//
14
15#include "llvm/Support/CommandLine.h"
16#include "llvm/Support/ManagedStatic.h"
17#include "llvm/Support/MemoryBuffer.h"
18#include "llvm/Support/PrettyStackTrace.h"
19#include "llvm/Support/raw_ostream.h"
20#include "llvm/System/Signals.h"
21using namespace llvm;
22
23static cl::opt<std::string>
24InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
25
26static cl::opt<std::string>
27OutputFilename("o", cl::desc("Output filename"),
28 cl::value_desc("filename"));
29
30int main(int argc, char **argv) {
31 // Print a stack trace if we signal out.
32 sys::PrintStackTraceOnErrorSignal();
33 PrettyStackTraceProgram X(argc, argv);
34
35 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
36
37 cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
38
39 std::string ErrorMessage;
40
41 MemoryBuffer *Buffer
42 = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage);
43
44 if (Buffer == 0) {
45 errs() << argv[0] << ": ";
46 if (ErrorMessage.size())
47 errs() << ErrorMessage << "\n";
48 else
49 errs() << "input file didn't read correctly.\n";
50 return 1;
51 }
52
53
54
55 return 0;
56}
57