aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-dis/llvm-dis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-dis/llvm-dis.cpp')
-rw-r--r--tools/llvm-dis/llvm-dis.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
index 067955e5cc..db9ca40f45 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"
@@ -51,6 +53,23 @@ static cl::opt<bool>
ShowAnnotations("show-annotations",
cl::desc("Add informational comments to the .ll file"));
+// @LOCALMOD-BEGIN
+// Print bitcode metadata only, in text format.
+// (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 {
static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) {
@@ -133,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();
}
@@ -154,7 +187,7 @@ int main(int argc, char **argv) {
OutputFilename = "-";
if (OutputFilename.empty()) { // Unspecified output, infer it.
- if (InputFilename == "-") {
+ if (InputFilename == "-" || DumpMetadata) { // @LOCALMOD
OutputFilename = "-";
} else {
const std::string &IFN = InputFilename;
@@ -176,6 +209,14 @@ int main(int argc, char **argv) {
return 1;
}
+ // @LOCALMOD-BEGIN
+ if (DumpMetadata) {
+ M->dumpMeta(Out->os());
+ Out->keep();
+ return 0;
+ }
+ // @LOCALMOD-END
+
OwningPtr<AssemblyAnnotationWriter> Annotator;
if (ShowAnnotations)
Annotator.reset(new CommentWriter());