aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-dis/llvm-dis.cpp
diff options
context:
space:
mode:
authorKarl Schimpf <kschimpf@google.com>2013-06-07 09:46:15 -0700
committerKarl Schimpf <kschimpf@google.com>2013-06-07 09:46:15 -0700
commit098dc634a5e6458a319617ec1737868cbf0f3d01 (patch)
treeb0272b1653e50b9fc8a3c5d4ab0a7d5a854eb30e /tools/llvm-dis/llvm-dis.cpp
parentbcbad3ce541bc70ab3383d3d77198ceb9e813b46 (diff)
Add CL argument -bitcode-format to llvm-dis, llc, and pnacl-llc.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3469 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/16385002
Diffstat (limited to 'tools/llvm-dis/llvm-dis.cpp')
-rw-r--r--tools/llvm-dis/llvm-dis.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
index 7af85d440a..d709ba9987 100644
--- a/tools/llvm-dis/llvm-dis.cpp
+++ b/tools/llvm-dis/llvm-dis.cpp
@@ -19,10 +19,12 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/Assembly/AssemblyAnnotationWriter.h"
#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Bitcode/NaCl/NaClReaderWriter.h" // @LOCALMOD
#include "llvm/DebugInfo.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
+#include "llvm/IRReader/IRReader.h" // @LOCALMOD
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DataStream.h"
#include "llvm/Support/FormattedStream.h"
@@ -56,6 +58,16 @@ ShowAnnotations("show-annotations",
// (includes output format, soname, and dependencies).
static cl::opt<bool>
DumpMetadata("dump-metadata", cl::desc("Dump bitcode metadata"));
+
+static cl::opt<NaClFileFormat>
+InputFileFormat(
+ "bitcode-format",
+ cl::desc("Define format of input bitcode file:"),
+ cl::values(
+ clEnumValN(LLVMFormat, "llvm", "LLVM bitcode file (default)"),
+ clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
+ clEnumValEnd),
+ cl::init(LLVMFormat));
// @LOCALMOD-END
namespace {
@@ -140,8 +152,22 @@ int main(int argc, char **argv) {
DisplayFilename = "<stdin>";
else
DisplayFilename = InputFilename;
- M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context,
- &ErrorMessage));
+
+ // @LOCALMOD-BEGIN
+ switch (InputFileFormat) {
+ case LLVMFormat:
+ M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context,
+ &ErrorMessage));
+ break;
+ case PNaClFormat:
+ M.reset(getNaClStreamedBitcodeModule(DisplayFilename, streamer, Context,
+ &ErrorMessage));
+ break;
+ default:
+ ErrorMessage = "Don't understand specified bitcode format";
+ break;
+ }
+ // @LOCALMOD-END
if(M.get() != 0 && M->MaterializeAllPermanently(&ErrorMessage)) {
M.reset();
}