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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 610813002: Subzero: Rewrite the pass timing infrastructure. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Bug fixes and performance improvements Created 6 years, 2 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
OLDNEW
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===//
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 implements the TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 TypeToRegisterSet[IceType_v8i1] = VectorRegisters; 295 TypeToRegisterSet[IceType_v8i1] = VectorRegisters;
296 TypeToRegisterSet[IceType_v16i1] = VectorRegisters; 296 TypeToRegisterSet[IceType_v16i1] = VectorRegisters;
297 TypeToRegisterSet[IceType_v16i8] = VectorRegisters; 297 TypeToRegisterSet[IceType_v16i8] = VectorRegisters;
298 TypeToRegisterSet[IceType_v8i16] = VectorRegisters; 298 TypeToRegisterSet[IceType_v8i16] = VectorRegisters;
299 TypeToRegisterSet[IceType_v4i32] = VectorRegisters; 299 TypeToRegisterSet[IceType_v4i32] = VectorRegisters;
300 TypeToRegisterSet[IceType_v4f32] = VectorRegisters; 300 TypeToRegisterSet[IceType_v4f32] = VectorRegisters;
301 } 301 }
302 302
303 void TargetX8632::translateO2() { 303 void TargetX8632::translateO2() {
304 GlobalContext *Context = Func->getContext(); 304 GlobalContext *Context = Func->getContext();
305 TimerMarker T("O2", Context);
305 306
306 // Lower Phi instructions. 307 // Lower Phi instructions.
307 Timer T_placePhiLoads;
308 Func->placePhiLoads(); 308 Func->placePhiLoads();
309 if (Func->hasError()) 309 if (Func->hasError())
310 return; 310 return;
311 T_placePhiLoads.printElapsedUs(Context, "placePhiLoads()");
312 Timer T_placePhiStores;
313 Func->placePhiStores(); 311 Func->placePhiStores();
314 if (Func->hasError()) 312 if (Func->hasError())
315 return; 313 return;
316 T_placePhiStores.printElapsedUs(Context, "placePhiStores()");
317 Timer T_deletePhis;
318 Func->deletePhis(); 314 Func->deletePhis();
319 if (Func->hasError()) 315 if (Func->hasError())
320 return; 316 return;
321 T_deletePhis.printElapsedUs(Context, "deletePhis()");
322 Func->dump("After Phi lowering"); 317 Func->dump("After Phi lowering");
323 318
324 // Address mode optimization. 319 // Address mode optimization.
325 Timer T_doAddressOpt;
326 Func->getVMetadata()->init(); 320 Func->getVMetadata()->init();
327 Func->doAddressOpt(); 321 Func->doAddressOpt();
328 T_doAddressOpt.printElapsedUs(Context, "doAddressOpt()");
329 322
330 // Argument lowering 323 // Argument lowering
331 Timer T_argLowering;
332 Func->doArgLowering(); 324 Func->doArgLowering();
333 T_argLowering.printElapsedUs(Context, "lowerArguments()");
334 325
335 // Target lowering. This requires liveness analysis for some parts 326 // Target lowering. This requires liveness analysis for some parts
336 // of the lowering decisions, such as compare/branch fusing. If 327 // of the lowering decisions, such as compare/branch fusing. If
337 // non-lightweight liveness analysis is used, the instructions need 328 // non-lightweight liveness analysis is used, the instructions need
338 // to be renumbered first. TODO: This renumbering should only be 329 // to be renumbered first. TODO: This renumbering should only be
339 // necessary if we're actually calculating live intervals, which we 330 // necessary if we're actually calculating live intervals, which we
340 // only do for register allocation. 331 // only do for register allocation.
341 Timer T_renumber1;
342 Func->renumberInstructions(); 332 Func->renumberInstructions();
343 if (Func->hasError()) 333 if (Func->hasError())
344 return; 334 return;
345 T_renumber1.printElapsedUs(Context, "renumberInstructions()");
346 335
347 // TODO: It should be sufficient to use the fastest liveness 336 // TODO: It should be sufficient to use the fastest liveness
348 // calculation, i.e. livenessLightweight(). However, for some 337 // calculation, i.e. livenessLightweight(). However, for some
349 // reason that slows down the rest of the translation. Investigate. 338 // reason that slows down the rest of the translation. Investigate.
350 Timer T_liveness1;
351 Func->liveness(Liveness_Basic); 339 Func->liveness(Liveness_Basic);
352 if (Func->hasError()) 340 if (Func->hasError())
353 return; 341 return;
354 T_liveness1.printElapsedUs(Context, "liveness()");
355 Func->dump("After x86 address mode opt"); 342 Func->dump("After x86 address mode opt");
356 343
357 Timer T_genCode;
358 Func->genCode(); 344 Func->genCode();
359 if (Func->hasError()) 345 if (Func->hasError())
360 return; 346 return;
361 T_genCode.printElapsedUs(Context, "genCode()");
362 347
363 // Register allocation. This requires instruction renumbering and 348 // Register allocation. This requires instruction renumbering and
364 // full liveness analysis. 349 // full liveness analysis.
365 Timer T_renumber2;
366 Func->renumberInstructions(); 350 Func->renumberInstructions();
367 if (Func->hasError()) 351 if (Func->hasError())
368 return; 352 return;
369 T_renumber2.printElapsedUs(Context, "renumberInstructions()");
370 Timer T_liveness2;
371 Func->liveness(Liveness_Intervals); 353 Func->liveness(Liveness_Intervals);
372 if (Func->hasError()) 354 if (Func->hasError())
373 return; 355 return;
374 T_liveness2.printElapsedUs(Context, "liveness()");
375 // Validate the live range computations. Do it outside the timing 356 // Validate the live range computations. Do it outside the timing
376 // code. TODO: Put this under a flag. 357 // code. TODO: Put this under a flag.
377 bool ValidLiveness = Func->validateLiveness(); 358 bool ValidLiveness = Func->validateLiveness();
378 assert(ValidLiveness); 359 assert(ValidLiveness);
379 (void)ValidLiveness; // used only in assert() 360 (void)ValidLiveness; // used only in assert()
380 ComputedLiveRanges = true; 361 ComputedLiveRanges = true;
381 // The post-codegen dump is done here, after liveness analysis and 362 // The post-codegen dump is done here, after liveness analysis and
382 // associated cleanup, to make the dump cleaner and more useful. 363 // associated cleanup, to make the dump cleaner and more useful.
383 Func->dump("After initial x8632 codegen"); 364 Func->dump("After initial x8632 codegen");
384 Timer T_regAlloc;
385 Func->getVMetadata()->init(); 365 Func->getVMetadata()->init();
386 regAlloc(); 366 regAlloc();
387 if (Func->hasError()) 367 if (Func->hasError())
388 return; 368 return;
389 T_regAlloc.printElapsedUs(Context, "regAlloc()");
390 Func->dump("After linear scan regalloc"); 369 Func->dump("After linear scan regalloc");
391 370
392 // Stack frame mapping. 371 // Stack frame mapping.
393 Timer T_genFrame;
394 Func->genFrame(); 372 Func->genFrame();
395 if (Func->hasError()) 373 if (Func->hasError())
396 return; 374 return;
397 T_genFrame.printElapsedUs(Context, "genFrame()");
398 Func->dump("After stack frame mapping"); 375 Func->dump("After stack frame mapping");
399 376
400 // Branch optimization. This needs to be done just before code 377 // Branch optimization. This needs to be done just before code
401 // emission. In particular, no transformations that insert or 378 // emission. In particular, no transformations that insert or
402 // reorder CfgNodes should be done after branch optimization. We go 379 // reorder CfgNodes should be done after branch optimization. We go
403 // ahead and do it before nop insertion to reduce the amount of work 380 // ahead and do it before nop insertion to reduce the amount of work
404 // needed for searching for opportunities. 381 // needed for searching for opportunities.
405 Func->doBranchOpt(); 382 Func->doBranchOpt();
406 Func->dump("After branch optimization"); 383 Func->dump("After branch optimization");
407 384
408 // Nop insertion 385 // Nop insertion
409 if (shouldDoNopInsertion()) { 386 if (shouldDoNopInsertion()) {
410 Func->doNopInsertion(); 387 Func->doNopInsertion();
411 } 388 }
412 } 389 }
413 390
414 void TargetX8632::translateOm1() { 391 void TargetX8632::translateOm1() {
415 GlobalContext *Context = Func->getContext(); 392 GlobalContext *Context = Func->getContext();
416 Timer T_placePhiLoads; 393 TimerMarker T("Om1", Context);
417 Func->placePhiLoads(); 394 Func->placePhiLoads();
418 if (Func->hasError()) 395 if (Func->hasError())
419 return; 396 return;
420 T_placePhiLoads.printElapsedUs(Context, "placePhiLoads()");
421 Timer T_placePhiStores;
422 Func->placePhiStores(); 397 Func->placePhiStores();
423 if (Func->hasError()) 398 if (Func->hasError())
424 return; 399 return;
425 T_placePhiStores.printElapsedUs(Context, "placePhiStores()");
426 Timer T_deletePhis;
427 Func->deletePhis(); 400 Func->deletePhis();
428 if (Func->hasError()) 401 if (Func->hasError())
429 return; 402 return;
430 T_deletePhis.printElapsedUs(Context, "deletePhis()");
431 Func->dump("After Phi lowering"); 403 Func->dump("After Phi lowering");
432 404
433 Timer T_argLowering;
434 Func->doArgLowering(); 405 Func->doArgLowering();
435 T_argLowering.printElapsedUs(Context, "lowerArguments()");
436 406
437 Timer T_genCode;
438 Func->genCode(); 407 Func->genCode();
439 if (Func->hasError()) 408 if (Func->hasError())
440 return; 409 return;
441 T_genCode.printElapsedUs(Context, "genCode()");
442 Func->dump("After initial x8632 codegen"); 410 Func->dump("After initial x8632 codegen");
443 411
444 Timer T_genFrame;
445 Func->genFrame(); 412 Func->genFrame();
446 if (Func->hasError()) 413 if (Func->hasError())
447 return; 414 return;
448 T_genFrame.printElapsedUs(Context, "genFrame()");
449 Func->dump("After stack frame mapping"); 415 Func->dump("After stack frame mapping");
450 416
451 // Nop insertion 417 // Nop insertion
452 if (shouldDoNopInsertion()) { 418 if (shouldDoNopInsertion()) {
453 Func->doNopInsertion(); 419 Func->doNopInsertion();
454 } 420 }
455 } 421 }
456 422
457 bool TargetX8632::doBranchOpt(Inst *I, const CfgNode *NextNode) { 423 bool TargetX8632::doBranchOpt(Inst *I, const CfgNode *NextNode) {
458 if (InstX8632Br *Br = llvm::dyn_cast<InstX8632Br>(I)) { 424 if (InstX8632Br *Br = llvm::dyn_cast<InstX8632Br>(I)) {
(...skipping 4095 matching lines...) Expand 10 before | Expand all | Expand 10 after
4554 Str << "\t.align\t" << Align << "\n"; 4520 Str << "\t.align\t" << Align << "\n";
4555 Str << MangledName << ":\n"; 4521 Str << MangledName << ":\n";
4556 for (SizeT i = 0; i < Size; ++i) { 4522 for (SizeT i = 0; i < Size; ++i) {
4557 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 4523 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
4558 } 4524 }
4559 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4525 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4560 } 4526 }
4561 } 4527 }
4562 4528
4563 } // end of namespace Ice 4529 } // end of namespace Ice
OLDNEW
« src/IceRegAlloc.cpp ('K') | « src/IceTargetLowering.cpp ('k') | src/IceTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698