1 //===-- llvm-mc.cpp - Machine Code Hacking Driver -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This utility is a simple driver that allows command line hacking on machine
13 //===----------------------------------------------------------------------===//
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/SourceMgr.h"
20 #include "llvm/Support/raw_ostream.h"
21 #include "llvm/System/Signals.h"
24 static cl::opt<std::string>
25 InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
27 static cl::opt<std::string>
28 OutputFilename("o", cl::desc("Output filename"),
29 cl::value_desc("filename"));
31 static cl::list<std::string>
32 IncludeDirs("I", cl::desc("Directory of include files"),
33 cl::value_desc("directory"), cl::Prefix);
39 static cl::opt<ActionType>
40 Action(cl::desc("Action to perform:"),
41 cl::values(clEnumValN(AC_Assemble, "assemble",
42 "Assemble a .s file (default)"),
45 static int AssembleInput(const char *ProgName) {
46 std::string ErrorMessage;
47 MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename,
50 errs() << ProgName << ": ";
51 if (ErrorMessage.size())
52 errs() << ErrorMessage << "\n";
54 errs() << "input file didn't read correctly.\n";
60 // Tell SrcMgr about this buffer, which is what TGParser will pick up.
61 SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
63 // Record the location of the include directories so that the lexer can find
65 SrcMgr.setIncludeDirs(IncludeDirs);
67 //TGParser Parser(SrcMgr);
68 //return Parser.ParseFile();
75 int main(int argc, char **argv) {
76 // Print a stack trace if we signal out.
77 sys::PrintStackTraceOnErrorSignal();
78 PrettyStackTraceProgram X(argc, argv);
79 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
80 cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
85 return AssembleInput(argv[0]);