aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-07 21:41:02 +0000
committerChris Lattner <sabre@nondot.org>2007-02-07 21:41:02 +0000
commitf2e292ce58ca07d9bbe3cad75f8baa35bd85964a (patch)
treed3bc0114e2f71983baef4c33631278640cd7a1cd /tools
parent403e4a4725af21c267d4189fe88bc48bd438b08c (diff)
downloadexternal_llvm-f2e292ce58ca07d9bbe3cad75f8baa35bd85964a.zip
external_llvm-f2e292ce58ca07d9bbe3cad75f8baa35bd85964a.tar.gz
external_llvm-f2e292ce58ca07d9bbe3cad75f8baa35bd85964a.tar.bz2
push bytecode decompressor out through APIs. Now the bytecode reader
api's look like this: ModuleProvider *getBytecodeModuleProvider( const std::string &Filename, ///< Name of file to be read BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0, ///< Optional error message holder BytecodeHandler* H = 0 ///< Optional handler for reader events ); This is ugly, but allows a client to say: getBytecodeModuleProvider("foo", 0); If they do this, there is no dependency on the compression libraries, saving codesize. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34012 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/bugpoint/BugDriver.cpp4
-rw-r--r--tools/llc/llc.cpp4
-rw-r--r--tools/lli/lli.cpp5
-rw-r--r--tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp5
-rw-r--r--tools/llvm-dis/llvm-dis.cpp5
-rw-r--r--tools/llvm-extract/llvm-extract.cpp4
-rw-r--r--tools/llvm-link/llvm-link.cpp4
-rw-r--r--tools/llvm-nm/llvm-nm.cpp4
-rw-r--r--tools/llvm-prof/llvm-prof.cpp4
-rw-r--r--tools/llvm2cpp/llvm2cpp.cpp4
-rw-r--r--tools/llvmc/CompilerDriver.cpp4
-rw-r--r--tools/opt/opt.cpp3
12 files changed, 38 insertions, 12 deletions
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp
index 236e8a3..2b4d35d 100644
--- a/tools/bugpoint/BugDriver.cpp
+++ b/tools/bugpoint/BugDriver.cpp
@@ -21,6 +21,7 @@
#include "llvm/Assembly/Parser.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compressor.h"
#include "llvm/Support/FileUtilities.h"
#include <iostream>
#include <memory>
@@ -74,7 +75,8 @@ BugDriver::BugDriver(const char *toolname, bool as_child, bool find_bugs,
///
Module *llvm::ParseInputFile(const std::string &InputFilename) {
ParseError Err;
- Module *Result = ParseBytecodeFile(InputFilename);
+ Module *Result = ParseBytecodeFile(InputFilename,
+ Compressor::decompressToNewBuffer);
if (!Result && !(Result = ParseAssemblyFile(InputFilename,&Err))) {
std::cerr << "bugpoint: " << Err.getMessage() << "\n";
Result = 0;
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 200b147..d8b596d 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -24,6 +24,7 @@
#include "llvm/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compressor.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/FileUtilities.h"
@@ -175,7 +176,8 @@ int main(int argc, char **argv) {
sys::PrintStackTraceOnErrorSignal();
// Load the module to be compiled...
- std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
+ std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename,
+ Compressor::decompressToNewBuffer));
if (M.get() == 0) {
std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
return 1;
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index c7b0765..0f96a4a 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -22,6 +22,7 @@
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compressor.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/System/Process.h"
@@ -70,7 +71,9 @@ int main(int argc, char **argv, char * const *envp) {
// Load the bytecode...
std::string ErrorMsg;
ModuleProvider *MP = 0;
- MP = getBytecodeModuleProvider(InputFile, &ErrorMsg);
+ MP = getBytecodeModuleProvider(InputFile,
+ Compressor::decompressToNewBuffer,
+ &ErrorMsg);
if (!MP) {
std::cerr << "Error loading program '" << InputFile << "': "
<< ErrorMsg << "\n";
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index bba9c71..cbb5152 100644
--- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -32,6 +32,7 @@
#include "llvm/Analysis/Verifier.h"
#include "llvm/Bytecode/Analyzer.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compressor.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/System/Signals.h"
#include <fstream>
@@ -66,7 +67,9 @@ int main(int argc, char **argv) {
bca.progressiveVerify = Verify;
/// Analyze the bytecode file
- Module* M = AnalyzeBytecodeFile(InputFilename, bca, &ErrorMessage, (Dump?Out:0));
+ Module* M = AnalyzeBytecodeFile(InputFilename, bca,
+ Compressor::decompressToNewBuffer,
+ &ErrorMessage, (Dump?Out:0));
// All that bcanalyzer does is write the gathered statistics to the output
PrintBytecodeAnalysis(bca,*Out);
diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
index e4ed2b3..38b863c 100644
--- a/tools/llvm-dis/llvm-dis.cpp
+++ b/tools/llvm-dis/llvm-dis.cpp
@@ -20,6 +20,7 @@
#include "llvm/PassManager.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Assembly/PrintModulePass.h"
+#include "llvm/Support/Compressor.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Streams.h"
@@ -51,7 +52,9 @@ int main(int argc, char **argv) {
std::ostream *Out = &std::cout; // Default to printing to stdout.
std::string ErrorMessage;
- std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
+ std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename,
+ Compressor::decompressToNewBuffer,
+ &ErrorMessage));
if (M.get() == 0) {
cerr << argv[0] << ": ";
if (ErrorMessage.size())
diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp
index b26fd9c..60a0134 100644
--- a/tools/llvm-extract/llvm-extract.cpp
+++ b/tools/llvm-extract/llvm-extract.cpp
@@ -19,6 +19,7 @@
#include "llvm/Transforms/IPO.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compressor.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/Signals.h"
@@ -57,7 +58,8 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm extractor\n");
sys::PrintStackTraceOnErrorSignal();
- std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
+ std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename,
+ Compressor::decompressToNewBuffer));
if (M.get() == 0) {
cerr << argv[0] << ": bytecode didn't read correctly.\n";
return 1;
diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp
index 343b36c..223475e 100644
--- a/tools/llvm-link/llvm-link.cpp
+++ b/tools/llvm-link/llvm-link.cpp
@@ -59,7 +59,9 @@ static inline std::auto_ptr<Module> LoadFile(const std::string &FN) {
std::string ErrorMessage;
if (Filename.exists()) {
if (Verbose) cerr << "Loading '" << Filename.c_str() << "'\n";
- Module* Result = ParseBytecodeFile(Filename.toString(), &ErrorMessage);
+ Module* Result = ParseBytecodeFile(Filename.toString(),
+ Compressor::decompressToNewBuffer,
+ &ErrorMessage);
if (Result) return std::auto_ptr<Module>(Result); // Load successful!
if (Verbose) {
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index 2d80f53..49f662d 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -127,7 +127,9 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
}
// Note: Currently we do not support reading an archive from stdin.
if (Filename == "-" || aPath.isBytecodeFile()) {
- Module *Result = ParseBytecodeFile(Filename, &ErrorMessage);
+ Module *Result = ParseBytecodeFile(Filename,
+ Compressor::decompressToNewBuffer,
+ &ErrorMessage);
if (Result) {
DumpSymbolNamesFromModule (Result);
} else {
diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp
index 44bc6c5..b0767e6 100644
--- a/tools/llvm-prof/llvm-prof.cpp
+++ b/tools/llvm-prof/llvm-prof.cpp
@@ -115,7 +115,9 @@ int main(int argc, char **argv) {
// Read in the bytecode file...
std::string ErrorMessage;
- Module *M = ParseBytecodeFile(BytecodeFile, &ErrorMessage);
+ Module *M = ParseBytecodeFile(BytecodeFile,
+ Compressor::decompressToNewBuffer,
+ &ErrorMessage);
if (M == 0) {
std::cerr << argv[0] << ": " << BytecodeFile << ": "
<< ErrorMessage << "\n";
diff --git a/tools/llvm2cpp/llvm2cpp.cpp b/tools/llvm2cpp/llvm2cpp.cpp
index 01c8fbd..fe9504e 100644
--- a/tools/llvm2cpp/llvm2cpp.cpp
+++ b/tools/llvm2cpp/llvm2cpp.cpp
@@ -49,7 +49,9 @@ int main(int argc, char **argv) {
int exitCode = 0;
std::ostream *Out = 0;
std::string ErrorMessage;
- std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
+ std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename,
+ Compressor::decompressToNewBuffer,
+ &ErrorMessage));
if (M.get() == 0) {
std::cerr << argv[0] << ": ";
if (ErrorMessage.size())
diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp
index 18aab21..055a4f4 100644
--- a/tools/llvmc/CompilerDriver.cpp
+++ b/tools/llvmc/CompilerDriver.cpp
@@ -569,7 +569,9 @@ private:
if (fullpath.isBytecodeFile()) {
// Process the dependent libraries recursively
Module::LibraryListType modlibs;
- if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs,&err)) {
+ if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs,
+ Compressor::decompressToNewBuffer,
+ &err)) {
// Traverse the dependent libraries list
Module::lib_iterator LI = modlibs.begin();
Module::lib_iterator LE = modlibs.end();
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 5294cac..24dab74 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -254,7 +254,8 @@ int main(int argc, char **argv) {
std::string ErrorMessage;
// Load the input module...
- std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
+ std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename,
+ Compressor::decompressToNewBuffer, &ErrorMessage));
if (M.get() == 0) {
cerr << argv[0] << ": ";
if (ErrorMessage.size())