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

Side by Side Diff: src/main.cpp

Issue 1024203002: Move some flag-like props from GlobalContext and TargetLowering to ClFlags. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: review / clean up formatting Created 5 years, 9 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/IceTypes.h ('k') | unittest/BitcodeMunge.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/main.cpp - Driver for bitcode translation --------------===// 1 //===- subzero/src/main.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 // This file defines a driver for translating PNaCl bitcode into native code. 10 // This file defines a driver for translating PNaCl bitcode into native code.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 cl::values( 62 cl::values(
63 clEnumValN(Ice::Target_X8632, "x8632", "x86-32"), 63 clEnumValN(Ice::Target_X8632, "x8632", "x86-32"),
64 clEnumValN(Ice::Target_X8632, "x86-32", "x86-32 (same as x8632)"), 64 clEnumValN(Ice::Target_X8632, "x86-32", "x86-32 (same as x8632)"),
65 clEnumValN(Ice::Target_X8632, "x86_32", "x86-32 (same as x8632)"), 65 clEnumValN(Ice::Target_X8632, "x86_32", "x86-32 (same as x8632)"),
66 clEnumValN(Ice::Target_X8664, "x8664", "x86-64"), 66 clEnumValN(Ice::Target_X8664, "x8664", "x86-64"),
67 clEnumValN(Ice::Target_X8664, "x86-64", "x86-64 (same as x8664)"), 67 clEnumValN(Ice::Target_X8664, "x86-64", "x86-64 (same as x8664)"),
68 clEnumValN(Ice::Target_X8664, "x86_64", "x86-64 (same as x8664)"), 68 clEnumValN(Ice::Target_X8664, "x86_64", "x86-64 (same as x8664)"),
69 clEnumValN(Ice::Target_ARM32, "arm", "arm32"), 69 clEnumValN(Ice::Target_ARM32, "arm", "arm32"),
70 clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"), 70 clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"),
71 clEnumValN(Ice::Target_ARM64, "arm64", "arm64"), clEnumValEnd)); 71 clEnumValN(Ice::Target_ARM64, "arm64", "arm64"), clEnumValEnd));
72
73 cl::opt<Ice::TargetInstructionSet> InstructionSet(
74 "mattr", cl::desc("Target architecture attributes"),
75 cl::init(Ice::X86InstructionSet_SSE2),
76 cl::values(clEnumValN(Ice::X86InstructionSet_SSE2, "sse2",
77 "Enable SSE2 instructions (default)"),
78 clEnumValN(Ice::X86InstructionSet_SSE4_1, "sse4.1",
79 "Enable SSE 4.1 instructions"),
80 clEnumValEnd));
81
72 static cl::opt<bool> UseSandboxing("sandbox", cl::desc("Use sandboxing")); 82 static cl::opt<bool> UseSandboxing("sandbox", cl::desc("Use sandboxing"));
73 static cl::opt<bool> 83 static cl::opt<bool>
74 FunctionSections("ffunction-sections", 84 FunctionSections("ffunction-sections",
75 cl::desc("Emit functions into separate sections")); 85 cl::desc("Emit functions into separate sections"));
76 static cl::opt<bool> 86 static cl::opt<bool>
77 DataSections("fdata-sections", 87 DataSections("fdata-sections",
78 cl::desc("Emit (global) data into separate sections")); 88 cl::desc("Emit (global) data into separate sections"));
79 static cl::opt<Ice::OptLevel> 89 static cl::opt<Ice::OptLevel>
80 OptLevel(cl::desc("Optimization level"), cl::init(Ice::Opt_m1), 90 OptLevel(cl::desc("Optimization level"), cl::init(Ice::Opt_m1),
81 cl::value_desc("level"), 91 cl::value_desc("level"),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // sequential, i.e. parser, translator, and emitter all within the 214 // sequential, i.e. parser, translator, and emitter all within the
205 // same single thread. (This may need a slight rework if we expand to 215 // same single thread. (This may need a slight rework if we expand to
206 // multiple parser or emitter threads.) 216 // multiple parser or emitter threads.)
207 static cl::opt<uint32_t> NumThreads( 217 static cl::opt<uint32_t> NumThreads(
208 "threads", 218 "threads",
209 cl::desc("Number of translation threads (0 for purely sequential)"), 219 cl::desc("Number of translation threads (0 for purely sequential)"),
210 // TODO(stichnot): Settle on a good default. Consider 220 // TODO(stichnot): Settle on a good default. Consider
211 // something related to std::thread::hardware_concurrency(). 221 // something related to std::thread::hardware_concurrency().
212 cl::init(2)); 222 cl::init(2));
213 223
224 static cl::opt<bool> DoNopInsertion("nop-insertion",
225 cl::desc("Randomly insert NOPs"),
226 cl::init(false));
227
228 static cl::opt<int> MaxNopsPerInstruction(
229 "max-nops-per-instruction",
230 cl::desc("Max number of nops to insert per instruction"), cl::init(1));
231
232 static cl::opt<int> NopProbabilityAsPercentage(
233 "nop-insertion-percentage",
234 cl::desc("Nop insertion probability as percentage"), cl::init(10));
235
236 static cl::opt<bool>
237 RandomizeRegisterAllocation("randomize-regalloc",
238 cl::desc("Randomize register allocation"),
239 cl::init(false));
240
241 // TODO(stichnot): See if we can easily use LLVM's -rng-seed option
242 // and implementation. I expect the implementation is different and
243 // therefore the tests would need to be changed.
244 cl::opt<unsigned long long>
245 RandomSeed("sz-seed", cl::desc("Seed the random number generator"),
246 cl::init(time(0)));
247
214 static int GetReturnValue(int Val) { 248 static int GetReturnValue(int Val) {
215 if (AlwaysExitSuccess) 249 if (AlwaysExitSuccess)
216 return 0; 250 return 0;
217 return Val; 251 return Val;
218 } 252 }
219 253
220 static struct { 254 static struct {
221 const char *FlagName; 255 const char *FlagName;
222 int FlagValue; 256 int FlagValue;
223 } ConditionalBuildAttributes[] = {{"dump", ALLOW_DUMP}, 257 } ConditionalBuildAttributes[] = {{"dump", ALLOW_DUMP},
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 Flags.setDataSections(DataSections); 331 Flags.setDataSections(DataSections);
298 Flags.setDecorateAsm(DecorateAsm); 332 Flags.setDecorateAsm(DecorateAsm);
299 Flags.setDefaultFunctionPrefix(DefaultFunctionPrefix); 333 Flags.setDefaultFunctionPrefix(DefaultFunctionPrefix);
300 Flags.setDefaultGlobalPrefix(DefaultGlobalPrefix); 334 Flags.setDefaultGlobalPrefix(DefaultGlobalPrefix);
301 Flags.setDisableInternal(DisableInternal); 335 Flags.setDisableInternal(DisableInternal);
302 Flags.setDisableIRGeneration(DisableIRGeneration); 336 Flags.setDisableIRGeneration(DisableIRGeneration);
303 Flags.setDisableTranslation(DisableTranslation); 337 Flags.setDisableTranslation(DisableTranslation);
304 Flags.setDumpStats(DumpStats); 338 Flags.setDumpStats(DumpStats);
305 Flags.setFunctionSections(FunctionSections); 339 Flags.setFunctionSections(FunctionSections);
306 Flags.setNumTranslationThreads(NumThreads); 340 Flags.setNumTranslationThreads(NumThreads);
341 Flags.setOptLevel(OptLevel);
307 Flags.setPhiEdgeSplit(EnablePhiEdgeSplit); 342 Flags.setPhiEdgeSplit(EnablePhiEdgeSplit);
343 Flags.setRandomSeed(RandomSeed);
344 Flags.setShouldDoNopInsertion(DoNopInsertion);
345 Flags.setShouldRandomizeRegAlloc(RandomizeRegisterAllocation);
308 Flags.setSubzeroTimingEnabled(SubzeroTimingEnabled); 346 Flags.setSubzeroTimingEnabled(SubzeroTimingEnabled);
347 Flags.setTargetArch(TargetArch);
348 Flags.setTargetInstructionSet(InstructionSet);
349 Flags.setTestPrefix(TestPrefix);
309 Flags.setTimeEachFunction(TimeEachFunction); 350 Flags.setTimeEachFunction(TimeEachFunction);
310 Flags.setTimingFocusOn(TimingFocusOn); 351 Flags.setTimingFocusOn(TimingFocusOn);
311 Flags.setTranslateOnly(TranslateOnly); 352 Flags.setTranslateOnly(TranslateOnly);
312 Flags.setUseSandboxing(UseSandboxing); 353 Flags.setUseSandboxing(UseSandboxing);
313 Flags.setVerboseFocusOn(VerboseFocusOn); 354 Flags.setVerboseFocusOn(VerboseFocusOn);
314 Flags.setOutFileType(OutFileType); 355 Flags.setOutFileType(OutFileType);
356 Flags.setMaxNopsPerInstruction(MaxNopsPerInstruction);
357 Flags.setNopProbabilityAsPercentage(NopProbabilityAsPercentage);
358 Flags.setVerbose(VMask);
315 359
316 // Force -build-on-read=0 for .ll files. 360 // Force -build-on-read=0 for .ll files.
317 const std::string LLSuffix = ".ll"; 361 const std::string LLSuffix = ".ll";
318 if (IRFilename.length() >= LLSuffix.length() && 362 if (IRFilename.length() >= LLSuffix.length() &&
319 IRFilename.compare(IRFilename.length() - LLSuffix.length(), 363 IRFilename.compare(IRFilename.length() - LLSuffix.length(),
320 LLSuffix.length(), LLSuffix) == 0) 364 LLSuffix.length(), LLSuffix) == 0)
321 BuildOnRead = false; 365 BuildOnRead = false;
322 366
323 // With the ELF writer, use a raw_fd_ostream to allow seeking. 367 // With the ELF writer, use a raw_fd_ostream to allow seeking.
324 // Also don't buffer, otherwise it gets pretty slow. 368 // Also don't buffer, otherwise it gets pretty slow.
(...skipping 25 matching lines...) Expand all
350 if (OutputFilename != "-") { 394 if (OutputFilename != "-") {
351 Ofs.open(OutputFilename.c_str(), std::ofstream::out); 395 Ofs.open(OutputFilename.c_str(), std::ofstream::out);
352 Os.reset(new raw_os_ostream(Ofs)); 396 Os.reset(new raw_os_ostream(Ofs));
353 } else { 397 } else {
354 Os.reset(new raw_os_ostream(std::cout)); 398 Os.reset(new raw_os_ostream(std::cout));
355 } 399 }
356 Os->SetUnbuffered(); 400 Os->SetUnbuffered();
357 } break; 401 } break;
358 } 402 }
359 403
360 Ice::GlobalContext Ctx(Ls.get(), Os.get(), ELFStr.get(), VMask, TargetArch, 404 Ice::GlobalContext Ctx(Ls.get(), Os.get(), ELFStr.get(), Flags);
361 OptLevel, TestPrefix, Flags);
362 405
363 Ice::TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx); 406 Ice::TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx);
364 407
365 if (OutFileType == Ice::FT_Elf) { 408 if (OutFileType == Ice::FT_Elf) {
366 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); 409 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx);
367 Ctx.getObjectWriter()->writeInitialELFHeader(); 410 Ctx.getObjectWriter()->writeInitialELFHeader();
368 } 411 }
369 412
370 Ctx.startWorkerThreads(); 413 Ctx.startWorkerThreads();
371 414
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 if (SubzeroTimingEnabled) 462 if (SubzeroTimingEnabled)
420 Ctx.dumpTimers(); 463 Ctx.dumpTimers();
421 if (TimeEachFunction) { 464 if (TimeEachFunction) {
422 const bool DumpCumulative = false; 465 const bool DumpCumulative = false;
423 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); 466 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative);
424 } 467 }
425 const bool FinalStats = true; 468 const bool FinalStats = true;
426 Ctx.dumpStats("_FINAL_", FinalStats); 469 Ctx.dumpStats("_FINAL_", FinalStats);
427 return GetReturnValue(Ctx.getErrorStatus()->value()); 470 return GetReturnValue(Ctx.getErrorStatus()->value());
428 } 471 }
OLDNEW
« no previous file with comments | « src/IceTypes.h ('k') | unittest/BitcodeMunge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698