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

Side by Side Diff: src/IceCompiler.cpp

Issue 1584923002: Subzero: Fix -build-atts option. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 11 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') | no next file » | 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
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #ifdef __clang__ 43 #ifdef __clang__
44 #pragma clang diagnostic pop 44 #pragma clang diagnostic pop
45 #endif // __clang__ 45 #endif // __clang__
46 46
47 #include <regex> 47 #include <regex>
48 48
49 namespace Ice { 49 namespace Ice {
50 50
51 namespace { 51 namespace {
52 52
53 struct {
54 const char *FlagName;
55 bool FlagValue;
56 } ConditionalBuildAttributes[] = {
57 {"dump", BuildDefs::dump()},
58 {"llvm_cl", BuildDefs::llvmCl()},
59 {"llvm_ir", BuildDefs::llvmIr()},
60 {"llvm_ir_as_input", BuildDefs::llvmIrAsInput()},
61 {"minimal_build", BuildDefs::minimal()},
62 {"browser_mode", BuildDefs::browser()}};
63
64 /// Dumps values of build attributes to Stream if Stream is non-null.
65 void dumpBuildAttributes(Ostream &Str) {
66 // List the supported targets.
67 #define SUBZERO_TARGET(TARGET) Str << "target_" #TARGET << "\n";
68 #include "llvm/Config/SZTargets.def"
69 const char *Prefix[2] = {"no", "allow"};
70 for (size_t i = 0; i < llvm::array_lengthof(ConditionalBuildAttributes);
71 ++i) {
72 const auto &A = ConditionalBuildAttributes[i];
73 Str << Prefix[A.FlagValue] << "_" << A.FlagName << "\n";
74 }
75 }
76 bool llvmIRInput(const IceString &Filename) { 53 bool llvmIRInput(const IceString &Filename) {
77 return BuildDefs::llvmIrAsInput() && 54 return BuildDefs::llvmIrAsInput() &&
78 std::regex_match(Filename, std::regex(".*\\.ll")); 55 std::regex_match(Filename, std::regex(".*\\.ll"));
79 } 56 }
80 57
81 } // end of anonymous namespace 58 } // end of anonymous namespace
82 59
83 void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, 60 void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
84 std::unique_ptr<llvm::DataStreamer> &&InputStream) { 61 std::unique_ptr<llvm::DataStreamer> &&InputStream) {
85 if (ExtraFlags.getGenerateBuildAtts()) {
86 dumpBuildAttributes(Ctx.getStrDump());
87 Ctx.getErrorStatus()->assign(EC_None);
88 return;
89 }
90 // The Minimal build (specifically, when dump()/emit() are not implemented) 62 // The Minimal build (specifically, when dump()/emit() are not implemented)
91 // allows only --filetype=obj. Check here to avoid cryptic error messages 63 // allows only --filetype=obj. Check here to avoid cryptic error messages
92 // downstream. 64 // downstream.
93 if (!BuildDefs::dump() && Ctx.getFlags().getOutFileType() != FT_Elf) { 65 if (!BuildDefs::dump() && Ctx.getFlags().getOutFileType() != FT_Elf) {
94 // TODO(stichnot): Access the actual command-line argument via 66 // TODO(stichnot): Access the actual command-line argument via
95 // llvm::Option.ArgStr and .ValueStr . 67 // llvm::Option.ArgStr and .ValueStr .
96 Ctx.getStrError() 68 Ctx.getStrError()
97 << "Error: only --filetype=obj is supported in this build.\n"; 69 << "Error: only --filetype=obj is supported in this build.\n";
98 Ctx.getErrorStatus()->assign(EC_Args); 70 Ctx.getErrorStatus()->assign(EC_Args);
99 return; 71 return;
100 } 72 }
101 73
102 TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx); 74 TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx);
103 75
104 Ctx.emitFileHeader(); 76 Ctx.emitFileHeader();
105 Ctx.startWorkerThreads(); 77 Ctx.startWorkerThreads();
106 78
107 std::unique_ptr<Translator> Translator; 79 std::unique_ptr<Translator> Translator;
108 const IceString &IRFilename = ExtraFlags.getIRFilename(); 80 const IceString &IRFilename = ExtraFlags.getIRFilename();
109 bool BuildOnRead = ExtraFlags.getBuildOnRead() && !llvmIRInput(IRFilename); 81 const bool BuildOnRead =
82 ExtraFlags.getBuildOnRead() && !llvmIRInput(IRFilename);
110 if (BuildOnRead) { 83 if (BuildOnRead) {
111 std::unique_ptr<PNaClTranslator> PTranslator(new PNaClTranslator(&Ctx)); 84 std::unique_ptr<PNaClTranslator> PTranslator(new PNaClTranslator(&Ctx));
112 std::unique_ptr<llvm::StreamingMemoryObject> MemObj( 85 std::unique_ptr<llvm::StreamingMemoryObject> MemObj(
113 new llvm::StreamingMemoryObjectImpl(InputStream.release())); 86 new llvm::StreamingMemoryObjectImpl(InputStream.release()));
114 PTranslator->translate(IRFilename, std::move(MemObj)); 87 PTranslator->translate(IRFilename, std::move(MemObj));
115 Translator.reset(PTranslator.release()); 88 Translator.reset(PTranslator.release());
116 } else if (BuildDefs::llvmIr()) { 89 } else if (BuildDefs::llvmIr()) {
117 if (BuildDefs::browser()) { 90 if (BuildDefs::browser()) {
118 Ctx.getStrError() 91 Ctx.getStrError()
119 << "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n"; 92 << "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n";
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 140
168 if (Ctx.getFlags().getTimeEachFunction()) { 141 if (Ctx.getFlags().getTimeEachFunction()) {
169 constexpr bool DumpCumulative = false; 142 constexpr bool DumpCumulative = false;
170 Ctx.dumpTimers(GlobalContext::TSK_Funcs, DumpCumulative); 143 Ctx.dumpTimers(GlobalContext::TSK_Funcs, DumpCumulative);
171 } 144 }
172 constexpr bool FinalStats = true; 145 constexpr bool FinalStats = true;
173 Ctx.dumpStats("_FINAL_", FinalStats); 146 Ctx.dumpStats("_FINAL_", FinalStats);
174 } 147 }
175 148
176 } // end of namespace Ice 149 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCompileServer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698