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

Side by Side Diff: src/llvm2ice.cpp

Issue 877003003: Subzero: Use a "known" version of clang-format. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add a clang-format blacklist. Fix formatting "errors". Created 5 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/assembler.h ('k') | unittest/BitcodeMunge.h » ('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/llvm2ice.cpp - Driver for testing ----------------------===// 1 //===- subzero/src/llvm2ice.cpp - Driver for testing ----------------------===//
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 // This file defines a driver that uses LLVM capabilities to parse a 10 // This file defines a driver that uses LLVM capabilities to parse a
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"), 66 clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"),
67 clEnumValN(Ice::Target_ARM64, "arm64", "arm64"), clEnumValEnd)); 67 clEnumValN(Ice::Target_ARM64, "arm64", "arm64"), clEnumValEnd));
68 static cl::opt<bool> UseSandboxing("sandbox", cl::desc("Use sandboxing")); 68 static cl::opt<bool> UseSandboxing("sandbox", cl::desc("Use sandboxing"));
69 static cl::opt<bool> 69 static cl::opt<bool>
70 FunctionSections("ffunction-sections", 70 FunctionSections("ffunction-sections",
71 cl::desc("Emit functions into separate sections")); 71 cl::desc("Emit functions into separate sections"));
72 static cl::opt<bool> 72 static cl::opt<bool>
73 DataSections("fdata-sections", 73 DataSections("fdata-sections",
74 cl::desc("Emit (global) data into separate sections")); 74 cl::desc("Emit (global) data into separate sections"));
75 static cl::opt<Ice::OptLevel> 75 static cl::opt<Ice::OptLevel>
76 OptLevel(cl::desc("Optimization level"), cl::init(Ice::Opt_m1), 76 OptLevel(cl::desc("Optimization level"), cl::init(Ice::Opt_m1),
77 cl::value_desc("level"), 77 cl::value_desc("level"),
78 cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"), 78 cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"),
79 clEnumValN(Ice::Opt_m1, "O-1", "-1"), 79 clEnumValN(Ice::Opt_m1, "O-1", "-1"),
80 clEnumValN(Ice::Opt_0, "O0", "0"), 80 clEnumValN(Ice::Opt_0, "O0", "0"),
81 clEnumValN(Ice::Opt_1, "O1", "1"), 81 clEnumValN(Ice::Opt_1, "O1", "1"),
82 clEnumValN(Ice::Opt_2, "O2", "2"), clEnumValEnd)); 82 clEnumValN(Ice::Opt_2, "O2", "2"), clEnumValEnd));
83 static cl::opt<std::string> IRFilename(cl::Positional, cl::desc("<IR file>"), 83 static cl::opt<std::string> IRFilename(cl::Positional, cl::desc("<IR file>"),
84 cl::init("-")); 84 cl::init("-"));
85 static cl::opt<std::string> OutputFilename("o", 85 static cl::opt<std::string> OutputFilename("o",
86 cl::desc("Override output filename"), 86 cl::desc("Override output filename"),
87 cl::init("-"), 87 cl::init("-"),
88 cl::value_desc("filename")); 88 cl::value_desc("filename"));
89 static cl::opt<std::string> LogFilename("log", cl::desc("Set log filename"), 89 static cl::opt<std::string> LogFilename("log", cl::desc("Set log filename"),
90 cl::init("-"), 90 cl::init("-"),
91 cl::value_desc("filename")); 91 cl::value_desc("filename"));
92 static cl::opt<std::string> 92 static cl::opt<std::string>
93 TestPrefix("prefix", cl::desc("Prepend a prefix to symbol names for testing"), 93 TestPrefix("prefix",
94 cl::init(""), cl::value_desc("prefix")); 94 cl::desc("Prepend a prefix to symbol names for testing"),
95 cl::init(""), cl::value_desc("prefix"));
96 static cl::opt<bool> DisableInternal("externalize",
97 cl::desc("Externalize all symbols"));
95 static cl::opt<bool> 98 static cl::opt<bool>
96 DisableInternal("externalize", 99 DisableTranslation("notranslate", cl::desc("Disable Subzero translation"));
97 cl::desc("Externalize all symbols"));
98 static cl::opt<bool>
99 DisableTranslation("notranslate", cl::desc("Disable Subzero translation"));
100 // Note: Modifiable only if ALLOW_DISABLE_IR_GEN. 100 // Note: Modifiable only if ALLOW_DISABLE_IR_GEN.
101 static cl::opt<bool> 101 static cl::opt<bool>
102 DisableIRGeneration("no-ir-gen", 102 DisableIRGeneration("no-ir-gen",
103 cl::desc("Disable generating Subzero IR.")); 103 cl::desc("Disable generating Subzero IR."));
104 static cl::opt<std::string> 104 static cl::opt<std::string>
105 TranslateOnly("translate-only", cl::desc("Translate only the given function"), 105 TranslateOnly("translate-only",
106 cl::init("")); 106 cl::desc("Translate only the given function"), cl::init(""));
107 107
108 static cl::opt<bool> SubzeroTimingEnabled( 108 static cl::opt<bool> SubzeroTimingEnabled(
109 "timing", cl::desc("Enable breakdown timing of Subzero translation")); 109 "timing", cl::desc("Enable breakdown timing of Subzero translation"));
110 110
111 static cl::opt<bool> 111 static cl::opt<bool> TimeEachFunction(
112 TimeEachFunction("timing-funcs", 112 "timing-funcs", cl::desc("Print total translation time for each function"));
113 cl::desc("Print total translation time for each function"));
114 113
115 static cl::opt<std::string> TimingFocusOn( 114 static cl::opt<std::string> TimingFocusOn(
116 "timing-focus", 115 "timing-focus",
117 cl::desc("Break down timing for a specific function (use '*' for all)"), 116 cl::desc("Break down timing for a specific function (use '*' for all)"),
118 cl::init("")); 117 cl::init(""));
119 118
120 static cl::opt<std::string> VerboseFocusOn( 119 static cl::opt<std::string> VerboseFocusOn(
121 "verbose-focus", 120 "verbose-focus",
122 cl::desc("Temporarily enable full verbosity for a specific function"), 121 cl::desc("Temporarily enable full verbosity for a specific function"),
123 cl::init("")); 122 cl::init(""));
124 123
125 static cl::opt<bool> 124 static cl::opt<bool>
126 EnablePhiEdgeSplit("phi-edge-split", 125 EnablePhiEdgeSplit("phi-edge-split",
127 cl::desc("Enable edge splitting for Phi lowering"), 126 cl::desc("Enable edge splitting for Phi lowering"),
128 cl::init(true)); 127 cl::init(true));
129 128
130 static cl::opt<bool> DecorateAsm( 129 static cl::opt<bool> DecorateAsm(
131 "asm-verbose", 130 "asm-verbose",
132 cl::desc("Decorate textual asm output with register liveness info")); 131 cl::desc("Decorate textual asm output with register liveness info"));
133 132
134 static cl::opt<bool> 133 static cl::opt<bool>
135 DumpStats("szstats", 134 DumpStats("szstats",
136 cl::desc("Print statistics after translating each function")); 135 cl::desc("Print statistics after translating each function"));
137 136
138 // This is currently needed by crosstest.py. 137 // This is currently needed by crosstest.py.
139 static cl::opt<bool> AllowUninitializedGlobals( 138 static cl::opt<bool> AllowUninitializedGlobals(
140 "allow-uninitialized-globals", 139 "allow-uninitialized-globals",
141 cl::desc("Allow global variables to be uninitialized")); 140 cl::desc("Allow global variables to be uninitialized"));
142 141
143 static cl::opt<NaClFileFormat> InputFileFormat( 142 static cl::opt<NaClFileFormat> InputFileFormat(
144 "bitcode-format", cl::desc("Define format of input file:"), 143 "bitcode-format", cl::desc("Define format of input file:"),
145 cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"), 144 cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"),
146 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"), 145 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
(...skipping 19 matching lines...) Expand all
166 static cl::opt<bool> 165 static cl::opt<bool>
167 BuildOnRead("build-on-read", 166 BuildOnRead("build-on-read",
168 cl::desc("Build ICE instructions when reading bitcode"), 167 cl::desc("Build ICE instructions when reading bitcode"),
169 cl::init(true)); 168 cl::init(true));
170 169
171 static cl::opt<bool> AllowErrorRecovery( 170 static cl::opt<bool> AllowErrorRecovery(
172 "allow-pnacl-reader-error-recovery", 171 "allow-pnacl-reader-error-recovery",
173 cl::desc("Allow error recovery when reading PNaCl bitcode."), 172 cl::desc("Allow error recovery when reading PNaCl bitcode."),
174 cl::init(false)); 173 cl::init(false));
175 174
176 static cl::opt<bool> 175 static cl::opt<bool> LLVMVerboseErrors(
177 LLVMVerboseErrors(
178 "verbose-llvm-parse-errors", 176 "verbose-llvm-parse-errors",
179 cl::desc("Print out more descriptive PNaCl bitcode parse errors when " 177 cl::desc("Print out more descriptive PNaCl bitcode parse errors when "
180 "building LLVM IR first"), 178 "building LLVM IR first"),
181 cl::init(false)); 179 cl::init(false));
182 180
183 static cl::opt<bool> 181 static cl::opt<bool>
184 UseIntegratedAssembler("integrated-as", 182 UseIntegratedAssembler("integrated-as",
185 cl::desc("Use integrated assembler (default yes)"), 183 cl::desc("Use integrated assembler (default yes)"),
186 cl::init(true)); 184 cl::init(true));
187 185
188 static cl::alias UseIas("ias", cl::desc("Alias for -integrated-as"), 186 static cl::alias UseIas("ias", cl::desc("Alias for -integrated-as"),
189 cl::NotHidden, cl::aliasopt(UseIntegratedAssembler)); 187 cl::NotHidden, cl::aliasopt(UseIntegratedAssembler));
190 188
191 static cl::opt<bool> 189 static cl::opt<bool>
192 UseELFWriter("elf-writer", 190 UseELFWriter("elf-writer",
193 cl::desc("Use ELF writer with the integrated assembler"), 191 cl::desc("Use ELF writer with the integrated assembler"),
194 cl::init(false)); 192 cl::init(false));
195 193
196 static cl::opt<bool> AlwaysExitSuccess( 194 static cl::opt<bool> AlwaysExitSuccess(
197 "exit-success", cl::desc("Exit with success status, even if errors found"), 195 "exit-success", cl::desc("Exit with success status, even if errors found"),
198 cl::init(false)); 196 cl::init(false));
199 197
200 static cl::opt<bool> 198 static cl::opt<bool> GenerateBuildAtts(
201 GenerateBuildAtts("build-atts", 199 "build-atts", cl::desc("Generate list of build attributes associated with "
202 cl::desc("Generate list of build attributes associated with "
203 "this executable."), 200 "this executable."),
204 cl::init(false)); 201 cl::init(false));
205 202
206 // Number of translation threads (in addition to the parser thread and 203 // Number of translation threads (in addition to the parser thread and
207 // the emitter thread). The special case of 0 means purely 204 // the emitter thread). The special case of 0 means purely
208 // sequential, i.e. parser, translator, and emitter all within the 205 // sequential, i.e. parser, translator, and emitter all within the
209 // same single thread. (This may need a slight rework if we expand to 206 // same single thread. (This may need a slight rework if we expand to
210 // multiple parser or emitter threads.) 207 // multiple parser or emitter threads.)
211 static cl::opt<uint32_t> 208 static cl::opt<uint32_t> NumThreads(
212 NumThreads("threads", 209 "threads",
213 cl::desc("Number of translation threads (0 for purely sequential)"), 210 cl::desc("Number of translation threads (0 for purely sequential)"),
214 // TODO(stichnot): Settle on a good default. Consider 211 // TODO(stichnot): Settle on a good default. Consider
215 // something related to std::thread::hardware_concurrency(). 212 // something related to std::thread::hardware_concurrency().
216 cl::init(0)); 213 cl::init(0));
217 214
218 static int GetReturnValue(int Val) { 215 static int GetReturnValue(int Val) {
219 if (AlwaysExitSuccess) 216 if (AlwaysExitSuccess)
220 return 0; 217 return 0;
221 return Val; 218 return Val;
222 } 219 }
223 220
224 static struct { 221 static struct {
225 const char *FlagName; 222 const char *FlagName;
226 int FlagValue; 223 int FlagValue;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 if (BuildOnRead) { 367 if (BuildOnRead) {
371 std::unique_ptr<Ice::PNaClTranslator> PTranslator( 368 std::unique_ptr<Ice::PNaClTranslator> PTranslator(
372 new Ice::PNaClTranslator(&Ctx, Flags)); 369 new Ice::PNaClTranslator(&Ctx, Flags));
373 PTranslator->translate(IRFilename); 370 PTranslator->translate(IRFilename);
374 Translator.reset(PTranslator.release()); 371 Translator.reset(PTranslator.release());
375 } else if (ALLOW_LLVM_IR) { 372 } else if (ALLOW_LLVM_IR) {
376 // Parse the input LLVM IR file into a module. 373 // Parse the input LLVM IR file into a module.
377 SMDiagnostic Err; 374 SMDiagnostic Err;
378 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); 375 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx);
379 raw_ostream *Verbose = LLVMVerboseErrors ? &errs() : nullptr; 376 raw_ostream *Verbose = LLVMVerboseErrors ? &errs() : nullptr;
380 Module *Mod = 377 Module *Mod = NaClParseIRFile(IRFilename, InputFileFormat, Err, Verbose,
381 NaClParseIRFile(IRFilename, InputFileFormat, Err, Verbose, 378 getGlobalContext());
382 getGlobalContext());
383 379
384 if (!Mod) { 380 if (!Mod) {
385 Err.print(argv[0], errs()); 381 Err.print(argv[0], errs());
386 return GetReturnValue(Ice::EC_Bitcode); 382 return GetReturnValue(Ice::EC_Bitcode);
387 } 383 }
388 384
389 std::unique_ptr<Ice::Converter> Converter( 385 std::unique_ptr<Ice::Converter> Converter(
390 new Ice::Converter(Mod, &Ctx, Flags)); 386 new Ice::Converter(Mod, &Ctx, Flags));
391 Converter->convertToIce(); 387 Converter->convertToIce();
392 Translator.reset(Converter.release()); 388 Translator.reset(Converter.release());
(...skipping 14 matching lines...) Expand all
407 if (SubzeroTimingEnabled) 403 if (SubzeroTimingEnabled)
408 Ctx.dumpTimers(); 404 Ctx.dumpTimers();
409 if (TimeEachFunction) { 405 if (TimeEachFunction) {
410 const bool DumpCumulative = false; 406 const bool DumpCumulative = false;
411 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); 407 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative);
412 } 408 }
413 const bool FinalStats = true; 409 const bool FinalStats = true;
414 Ctx.dumpStats("_FINAL_", FinalStats); 410 Ctx.dumpStats("_FINAL_", FinalStats);
415 return GetReturnValue(Ctx.getErrorStatus()->value()); 411 return GetReturnValue(Ctx.getErrorStatus()->value());
416 } 412 }
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | unittest/BitcodeMunge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698