Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: src/IceCompiler.cpp

Issue 1838753002: Subzero: Remove IceString. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceCompileServer.cpp ('k') | src/IceConverter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceCompiler.cpp - Driver for bitcode translation -------===// 1 //===- subzero/src/IceCompiler.cpp - Driver for bitcode translation -------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
11 /// \brief Defines a driver for translating PNaCl bitcode into native code. 11 /// \brief Defines a driver for translating PNaCl bitcode into native code.
12 /// 12 ///
13 /// The driver can either directly parse the binary bitcode file, or use LLVM 13 /// The driver can either directly parse the binary bitcode file, or use LLVM
14 /// routines to parse a textual bitcode file into LLVM IR and then convert LLVM 14 /// routines to parse a textual bitcode file into LLVM IR and then convert LLVM
15 /// IR into ICE. In either case, the high-level ICE is then compiled down to 15 /// IR into ICE. In either case, the high-level ICE is then compiled down to
16 /// native code, as either an ELF object file or a textual asm file. 16 /// native code, as either an ELF object file or a textual asm file.
17 /// 17 ///
18 //===----------------------------------------------------------------------===// 18 //===----------------------------------------------------------------------===//
19 19
20 #include "IceCompiler.h" 20 #include "IceCompiler.h"
21 21
22 #include "IceBuildDefs.h" 22 #include "IceBuildDefs.h"
23 #include "IceCfg.h" 23 #include "IceCfg.h"
24 #include "IceClFlags.h" 24 #include "IceClFlags.h"
25 #include "IceClFlags.h"
26 #include "IceConverter.h" 25 #include "IceConverter.h"
27 #include "IceELFObjectWriter.h" 26 #include "IceELFObjectWriter.h"
28 #include "PNaClTranslator.h" 27 #include "PNaClTranslator.h"
29 28
30 #ifdef __clang__ 29 #ifdef __clang__
31 #pragma clang diagnostic push 30 #pragma clang diagnostic push
32 #pragma clang diagnostic ignored "-Wunused-parameter" 31 #pragma clang diagnostic ignored "-Wunused-parameter"
33 #endif // __clang__ 32 #endif // __clang__
34 33
35 #include "llvm/ADT/STLExtras.h" 34 #include "llvm/ADT/STLExtras.h"
36 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" 35 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
37 #include "llvm/IR/LLVMContext.h" 36 #include "llvm/IR/LLVMContext.h"
38 #include "llvm/IR/Module.h" 37 #include "llvm/IR/Module.h"
39 #include "llvm/IRReader/IRReader.h" 38 #include "llvm/IRReader/IRReader.h"
40 #include "llvm/Support/SourceMgr.h" 39 #include "llvm/Support/SourceMgr.h"
41 #include "llvm/Support/StreamingMemoryObject.h" 40 #include "llvm/Support/StreamingMemoryObject.h"
42 41
43 #ifdef __clang__ 42 #ifdef __clang__
44 #pragma clang diagnostic pop 43 #pragma clang diagnostic pop
45 #endif // __clang__ 44 #endif // __clang__
46 45
47 #include <regex> 46 #include <regex>
48 47
49 namespace Ice { 48 namespace Ice {
50 49
51 namespace { 50 namespace {
52 51
53 bool llvmIRInput(const IceString &Filename) { 52 bool llvmIRInput(const std::string &Filename) {
54 return BuildDefs::llvmIrAsInput() && 53 return BuildDefs::llvmIrAsInput() &&
55 std::regex_match(Filename, std::regex(".*\\.ll")); 54 std::regex_match(Filename, std::regex(".*\\.ll"));
56 } 55 }
57 56
58 } // end of anonymous namespace 57 } // end of anonymous namespace
59 58
60 void Compiler::run(const Ice::ClFlags &Flags, GlobalContext &Ctx, 59 void Compiler::run(const Ice::ClFlags &Flags, GlobalContext &Ctx,
61 std::unique_ptr<llvm::DataStreamer> &&InputStream) { 60 std::unique_ptr<llvm::DataStreamer> &&InputStream) {
62 // The Minimal build (specifically, when dump()/emit() are not implemented) 61 // The Minimal build (specifically, when dump()/emit() are not implemented)
63 // allows only --filetype=obj. Check here to avoid cryptic error messages 62 // allows only --filetype=obj. Check here to avoid cryptic error messages
64 // downstream. 63 // downstream.
65 if (!BuildDefs::dump() && Ctx.getFlags().getOutFileType() != FT_Elf) { 64 if (!BuildDefs::dump() && Ctx.getFlags().getOutFileType() != FT_Elf) {
66 // TODO(stichnot): Access the actual command-line argument via 65 // TODO(stichnot): Access the actual command-line argument via
67 // llvm::Option.ArgStr and .ValueStr . 66 // llvm::Option.ArgStr and .ValueStr .
68 Ctx.getStrError() 67 Ctx.getStrError()
69 << "Error: only --filetype=obj is supported in this build.\n"; 68 << "Error: only --filetype=obj is supported in this build.\n";
70 Ctx.getErrorStatus()->assign(EC_Args); 69 Ctx.getErrorStatus()->assign(EC_Args);
71 return; 70 return;
72 } 71 }
73 72
74 TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx); 73 TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx);
75 74
76 Ctx.emitFileHeader(); 75 Ctx.emitFileHeader();
77 Ctx.startWorkerThreads(); 76 Ctx.startWorkerThreads();
78 77
79 std::unique_ptr<Translator> Translator; 78 std::unique_ptr<Translator> Translator;
80 const IceString &IRFilename = Flags.getIRFilename(); 79 const std::string IRFilename = Flags.getIRFilename();
81 const bool BuildOnRead = Flags.getBuildOnRead() && !llvmIRInput(IRFilename); 80 const bool BuildOnRead = Flags.getBuildOnRead() && !llvmIRInput(IRFilename);
82 if (BuildOnRead) { 81 if (BuildOnRead) {
83 std::unique_ptr<PNaClTranslator> PTranslator(new PNaClTranslator(&Ctx)); 82 std::unique_ptr<PNaClTranslator> PTranslator(new PNaClTranslator(&Ctx));
84 std::unique_ptr<llvm::StreamingMemoryObject> MemObj( 83 std::unique_ptr<llvm::StreamingMemoryObject> MemObj(
85 new llvm::StreamingMemoryObjectImpl(InputStream.release())); 84 new llvm::StreamingMemoryObjectImpl(InputStream.release()));
86 PTranslator->translate(IRFilename, std::move(MemObj)); 85 PTranslator->translate(IRFilename, std::move(MemObj));
87 Translator.reset(PTranslator.release()); 86 Translator.reset(PTranslator.release());
88 } else if (BuildDefs::llvmIr()) { 87 } else if (BuildDefs::llvmIr()) {
89 if (BuildDefs::browser()) { 88 if (BuildDefs::browser()) {
90 Ctx.getStrError() 89 Ctx.getStrError()
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 141
143 if (Ctx.getFlags().getTimeEachFunction()) { 142 if (Ctx.getFlags().getTimeEachFunction()) {
144 constexpr bool NoDumpCumulative = false; 143 constexpr bool NoDumpCumulative = false;
145 Ctx.dumpTimers(GlobalContext::TSK_Funcs, NoDumpCumulative); 144 Ctx.dumpTimers(GlobalContext::TSK_Funcs, NoDumpCumulative);
146 } 145 }
147 constexpr bool FinalStats = true; 146 constexpr bool FinalStats = true;
148 Ctx.dumpStats("_FINAL_", FinalStats); 147 Ctx.dumpStats("_FINAL_", FinalStats);
149 } 148 }
150 149
151 } // end of namespace Ice 150 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCompileServer.cpp ('k') | src/IceConverter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698