Index: tools/pnacl-thaw/pnacl-thaw.cpp |
diff --git a/tools/pnacl-freeze/pnacl-freeze.cpp b/tools/pnacl-thaw/pnacl-thaw.cpp |
similarity index 66% |
copy from tools/pnacl-freeze/pnacl-freeze.cpp |
copy to tools/pnacl-thaw/pnacl-thaw.cpp |
index 1134dbdd5cec00b6417518b4ac890fb121f27396..076cb05cb08d9ae4c150286e6e7f4593f51a940a 100644 |
--- a/tools/pnacl-freeze/pnacl-freeze.cpp |
+++ b/tools/pnacl-thaw/pnacl-thaw.cpp |
@@ -3,63 +3,54 @@ |
* be found in the LICENSE file. |
*/ |
-//===-- pnacl-freeze.cpp - The low-level NaCl bitcode freezer --------===// |
+//===-- pnacl-thaw.cpp - The low-level NaCl bitcode thawer ----------------===// |
// |
//===----------------------------------------------------------------------===// |
// |
-// Generates NaCl pexe wire format. |
+// Converts NaCl pexe wire format back to LLVM pexe. |
jvoung (off chromium)
2013/04/29 18:02:08
nit: "pexe" seems like a NaCl thing, so perhaps ju
Karl
2013/04/29 20:44:37
Done.
|
// |
//===----------------------------------------------------------------------===// |
#include "llvm/IR/LLVMContext.h" |
-#include "llvm/Assembly/AssemblyAnnotationWriter.h" |
+#include "llvm/IR/LLVMContext.h" |
jvoung (off chromium)
2013/04/29 18:02:08
include the context header only once?
Karl
2013/04/29 20:44:37
Done.
|
// Note: We need the following to provide the API for calling the NaCl |
-// Bitcode Writer to generate the frozen file. |
+// Bitcode Reader to read the frozen file. |
#include "llvm/Bitcode/NaCl/NaClReaderWriter.h" |
// Note: We need the following to provide the API for calling the (LLVM) |
-// Bitcode Reader to read in the corresonding pexe file to freeze. |
+// Bitcode Writer to generate the corresponding LLVM bitcode file. |
#include "llvm/Bitcode/ReaderWriter.h" |
-#include "llvm/DebugInfo.h" |
jvoung (off chromium)
2013/04/29 18:02:08
can you apply similar cleanup to pnacl-freeze?
Karl
2013/04/29 20:44:37
Done.
|
-#include "llvm/IR/IntrinsicInst.h" |
#include "llvm/IR/Module.h" |
-#include "llvm/IR/Type.h" |
#include "llvm/Support/CommandLine.h" |
#include "llvm/Support/DataStream.h" |
-#include "llvm/Support/FormattedStream.h" |
#include "llvm/Support/ManagedStatic.h" |
-#include "llvm/Support/MemoryBuffer.h" |
#include "llvm/Support/PrettyStackTrace.h" |
#include "llvm/Support/Signals.h" |
#include "llvm/Support/ToolOutputFile.h" |
-#include "llvm/Support/system_error.h" |
- |
-// llvm/Bitcode/BitstreamWriter.h |
using namespace llvm; |
- |
static cl::opt<std::string> |
-OutputFilename("o", cl::desc("Specify output filename"), |
+OutputFilename("o", cl::desc("Specify thawed pexe filename"), |
cl::value_desc("filename")); |
static cl::opt<std::string> |
-InputFilename(cl::Positional, cl::desc("<pexe file>"), cl::Required); |
+InputFilename(cl::Positional, cl::desc("<frozen file>"), cl::Required); |
static void WriteOutputFile(const Module *M) { |
- std::string FrozenFilename = |
- (OutputFilename.size() == 0 ? (InputFilename + ".frozen") : OutputFilename); |
+ std::string ThawedFilename = |
+ (OutputFilename.size() == 0 ? (InputFilename + ".thawed") : OutputFilename); |
std::string ErrorInfo; |
OwningPtr<tool_output_file> Out |
- (new tool_output_file(FrozenFilename.c_str(), ErrorInfo, |
+ (new tool_output_file(ThawedFilename.c_str(), ErrorInfo, |
raw_fd_ostream::F_Binary)); |
if (!ErrorInfo.empty()) { |
errs() << ErrorInfo << '\n'; |
exit(1); |
} |
- NaClWriteBitcodeToFile(M, Out->os()); |
+ WriteBitcodeToFile(M, Out->os()); |
// Declare success. |
Out->keep(); |
@@ -73,7 +64,8 @@ int main(int argc, char **argv) { |
LLVMContext &Context = getGlobalContext(); |
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. |
- cl::ParseCommandLineOptions(argc, argv, "Generates NaCl pexe wire format\n"); |
+ cl::ParseCommandLineOptions( |
+ argc, argv, "Converts NaCl pexe wire format into LLVM bitcode format\n"); |
std::string ErrorMessage; |
std::auto_ptr<Module> M; |
@@ -82,8 +74,8 @@ int main(int argc, char **argv) { |
DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage); |
if (streamer) { |
std::string DisplayFilename = InputFilename; |
- M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context, |
- &ErrorMessage)); |
+ M.reset(getNaClStreamedBitcodeModule(DisplayFilename, streamer, Context, |
+ &ErrorMessage)); |
if(M.get() != 0 && M->MaterializeAllPermanently(&ErrorMessage)) { |
M.reset(); |
} |