| Index: tools/pnacl-llc/pnacl-llc.cpp
|
| diff --git a/tools/llc/llc.cpp b/tools/pnacl-llc/pnacl-llc.cpp
|
| similarity index 87%
|
| copy from tools/llc/llc.cpp
|
| copy to tools/pnacl-llc/pnacl-llc.cpp
|
| index 64bb6991d8d990e75028acacdcbd5ae1f092b46a..437dff7c0bdd34545ff51843acffff0004932ae2 100644
|
| --- a/tools/llc/llc.cpp
|
| +++ b/tools/pnacl-llc/pnacl-llc.cpp
|
| @@ -1,4 +1,4 @@
|
| -//===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===//
|
| +//===-- pnacl-llc.cpp - PNaCl-specific llc: pexe ---> nexe ---------------===//
|
| //
|
| // The LLVM Compiler Infrastructure
|
| //
|
| @@ -7,22 +7,19 @@
|
| //
|
| //===----------------------------------------------------------------------===//
|
| //
|
| -// This is the llc code generator driver. It provides a convenient
|
| -// command-line interface for generating native assembly-language code
|
| -// or C code, given LLVM bitcode.
|
| +// pnacl-llc: the core of the PNaCl translator, compiling a pexe into a nexe.
|
| //
|
| //===----------------------------------------------------------------------===//
|
|
|
| -#include "llvm/IR/LLVMContext.h"
|
| #include "llvm/ADT/Triple.h"
|
| #include "llvm/Analysis/NaCl.h"
|
| #include "llvm/Assembly/PrintModulePass.h"
|
| -#include "llvm/Support/DataStream.h" // @LOCALMOD
|
| +#include "llvm/Support/DataStream.h"
|
| #include "llvm/CodeGen/CommandFlags.h"
|
| -#include "llvm/CodeGen/IntrinsicLowering.h" // @LOCALMOD
|
| #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
|
| #include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
| #include "llvm/IR/DataLayout.h"
|
| +#include "llvm/IR/LLVMContext.h"
|
| #include "llvm/IR/Module.h"
|
| #include "llvm/MC/SubtargetFeature.h"
|
| #include "llvm/Pass.h"
|
| @@ -33,23 +30,16 @@
|
| #include "llvm/Support/Host.h"
|
| #include "llvm/Support/IRReader.h"
|
| #include "llvm/Support/ManagedStatic.h"
|
| -#if !defined(__native_client__)
|
| -#include "llvm/Support/PluginLoader.h"
|
| -#endif
|
| #include "llvm/Support/PrettyStackTrace.h"
|
| #include "llvm/Support/Signals.h"
|
| #include "llvm/Support/TargetRegistry.h"
|
| #include "llvm/Support/TargetSelect.h"
|
| +#include "llvm/Support/Timer.h"
|
| #include "llvm/Support/ToolOutputFile.h"
|
| #include "llvm/Target/TargetLibraryInfo.h"
|
| #include "llvm/Target/TargetMachine.h"
|
| #include <memory>
|
|
|
| -// @LOCALMOD-BEGIN
|
| -#include "llvm/Support/Timer.h"
|
| -#include "StubMaker.h"
|
| -#include "TextStubWriter.h"
|
| -// @LOCALMOD-END
|
|
|
| using namespace llvm;
|
|
|
| @@ -94,10 +84,6 @@ static cl::opt<unsigned>
|
| TimeCompilations("time-compilations", cl::Hidden, cl::init(1u),
|
| cl::value_desc("N"),
|
| cl::desc("Repeat compilation N times for timing"));
|
| -// @LOCALMOD-BEGIN
|
| -static cl::opt<std::string>
|
| -MetadataTextFilename("metadata-text", cl::desc("Metadata as text, out filename"),
|
| - cl::value_desc("filename"));
|
|
|
| // Using bitcode streaming has a couple of ramifications. Primarily it means
|
| // that the module in the file will be compiled one function at a time rather
|
| @@ -126,7 +112,6 @@ static cl::opt<bool>
|
| PNaClABIVerifyFatalErrors("pnaclabi-verify-fatal-errors",
|
| cl::desc("PNaCl ABI verification errors are fatal"),
|
| cl::init(false));
|
| -// @LOCALMOD-END
|
|
|
| // Determine optimization level.
|
| static cl::opt<char>
|
| @@ -228,57 +213,6 @@ static tool_output_file *GetOutputStream(const char *TargetName,
|
| return FDOut;
|
| }
|
|
|
| -// @LOCALMOD-BEGIN
|
| -#if defined(__native_client__) && defined(NACL_SRPC)
|
| -void RecordMetadataForSrpc(const Module &mod) {
|
| - bool is_shared = (mod.getOutputFormat() == Module::SharedOutputFormat);
|
| - std::string soname = mod.getSOName();
|
| - NaClRecordObjectInformation(is_shared, soname);
|
| - for (Module::lib_iterator L = mod.lib_begin(),
|
| - E = mod.lib_end();
|
| - L != E; ++L) {
|
| - NaClRecordSharedLibraryDependency(*L);
|
| - }
|
| -}
|
| -#endif // defined(__native_client__) && defined(NACL_SRPC)
|
| -// @LOCALMOD-END
|
| -
|
| -
|
| -// @LOCALMOD-BEGIN
|
| -
|
| -// Write the ELF Stubs to the metadata file, in text format
|
| -// Returns 0 on success, non-zero on error.
|
| -int WriteTextMetadataFile(const Module &M, const Triple &TheTriple) {
|
| - // Build the ELF stubs (in high level format)
|
| - SmallVector<ELFStub*, 8> StubList;
|
| - // NOTE: The triple is unnecessary for the text version.
|
| - MakeAllStubs(M, TheTriple, &StubList);
|
| - // For each stub, write the ELF object to the metadata file.
|
| - std::string s;
|
| - for (unsigned i = 0; i < StubList.size(); i++) {
|
| - WriteTextELFStub(StubList[i], &s);
|
| - }
|
| - FreeStubList(&StubList);
|
| -
|
| -#if defined(__native_client__) && defined(NACL_SRPC)
|
| - llvm_unreachable("Not yet implemented. Need a file handle to write to.");
|
| -#else
|
| - std::string error;
|
| - OwningPtr<tool_output_file> MOut(
|
| - new tool_output_file(MetadataTextFilename.c_str(), error,
|
| - raw_fd_ostream::F_Binary));
|
| - if (!error.empty()) {
|
| - errs() << error << '\n';
|
| - return 1;
|
| - }
|
| - MOut->os().write(s.data(), s.size());
|
| - MOut->keep();
|
| -#endif
|
| - return 0;
|
| -}
|
| -
|
| -// @LOCALMOD-END
|
| -
|
| // main - Entry point for the llc compiler.
|
| //
|
| int llc_main(int argc, char **argv) {
|
| @@ -393,8 +327,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
| CheckABIVerifyErrors(ABIErrorReporter, "Module");
|
| }
|
| #if defined(__native_client__) && defined(NACL_SRPC)
|
| - RecordMetadataForSrpc(*mod);
|
| -
|
| // To determine if we should compile PIC or not, we needed to load at
|
| // least the metadata. Since we've already constructed the commandline,
|
| // we have to hack this in after commandline processing.
|
| @@ -640,23 +572,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
| Out->keep();
|
| #endif
|
|
|
| - // @LOCALMOD-BEGIN
|
| - // Write out the metadata.
|
| - //
|
| - // We need to ensure that intrinsic prototypes are available, in case
|
| - // we have a NeededRecord for one of them.
|
| - // They may have been eliminated by the StripDeadPrototypes pass,
|
| - // or some other pass that is unaware of NeededRecords / IntrinsicLowering.
|
| - if (!MetadataTextFilename.empty()) {
|
| - IntrinsicLowering IL(*target->getDataLayout());
|
| - IL.AddPrototypes(*M);
|
| -
|
| - int err = WriteTextMetadataFile(*M.get(), TheTriple);
|
| - if (err != 0)
|
| - return err;
|
| - }
|
| - // @LOCALMOD-END
|
| -
|
| return 0;
|
| }
|
|
|
|
|