OLD | NEW |
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (Func->hasError()) | 377 if (Func->hasError()) |
378 return; | 378 return; |
379 Func->dump("After linear scan regalloc"); | 379 Func->dump("After linear scan regalloc"); |
380 | 380 |
381 // Stack frame mapping. | 381 // Stack frame mapping. |
382 Func->genFrame(); | 382 Func->genFrame(); |
383 if (Func->hasError()) | 383 if (Func->hasError()) |
384 return; | 384 return; |
385 Func->dump("After stack frame mapping"); | 385 Func->dump("After stack frame mapping"); |
386 | 386 |
| 387 Func->deleteRedundantAssignments(); |
| 388 |
387 // Branch optimization. This needs to be done just before code | 389 // Branch optimization. This needs to be done just before code |
388 // emission. In particular, no transformations that insert or | 390 // emission. In particular, no transformations that insert or |
389 // reorder CfgNodes should be done after branch optimization. We go | 391 // reorder CfgNodes should be done after branch optimization. We go |
390 // ahead and do it before nop insertion to reduce the amount of work | 392 // ahead and do it before nop insertion to reduce the amount of work |
391 // needed for searching for opportunities. | 393 // needed for searching for opportunities. |
392 Func->doBranchOpt(); | 394 Func->doBranchOpt(); |
393 Func->dump("After branch optimization"); | 395 Func->dump("After branch optimization"); |
394 | 396 |
395 // Nop insertion | 397 // Nop insertion |
396 if (shouldDoNopInsertion()) { | 398 if (shouldDoNopInsertion()) { |
(...skipping 19 matching lines...) Expand all Loading... |
416 Func->genCode(); | 418 Func->genCode(); |
417 if (Func->hasError()) | 419 if (Func->hasError()) |
418 return; | 420 return; |
419 Func->dump("After initial x8632 codegen"); | 421 Func->dump("After initial x8632 codegen"); |
420 | 422 |
421 Func->genFrame(); | 423 Func->genFrame(); |
422 if (Func->hasError()) | 424 if (Func->hasError()) |
423 return; | 425 return; |
424 Func->dump("After stack frame mapping"); | 426 Func->dump("After stack frame mapping"); |
425 | 427 |
| 428 Func->deleteRedundantAssignments(); |
| 429 |
426 // Nop insertion | 430 // Nop insertion |
427 if (shouldDoNopInsertion()) { | 431 if (shouldDoNopInsertion()) { |
428 Func->doNopInsertion(); | 432 Func->doNopInsertion(); |
429 } | 433 } |
430 } | 434 } |
431 | 435 |
432 bool TargetX8632::doBranchOpt(Inst *I, const CfgNode *NextNode) { | 436 bool TargetX8632::doBranchOpt(Inst *I, const CfgNode *NextNode) { |
433 if (InstX8632Br *Br = llvm::dyn_cast<InstX8632Br>(I)) { | 437 if (InstX8632Br *Br = llvm::dyn_cast<InstX8632Br>(I)) { |
434 return Br->optimizeBranch(NextNode); | 438 return Br->optimizeBranch(NextNode); |
435 } | 439 } |
436 return false; | 440 return false; |
437 } | 441 } |
438 | 442 |
439 IceString TargetX8632::RegNames[] = { | 443 IceString TargetX8632::RegNames[] = { |
440 #define X(val, encode, name, name16, name8, scratch, preserved, stackptr, \ | 444 #define X(val, encode, name, name16, name8, scratch, preserved, stackptr, \ |
441 frameptr, isI8, isInt, isFP) \ | 445 frameptr, isI8, isInt, isFP) \ |
442 name, | 446 name, |
443 REGX8632_TABLE | 447 REGX8632_TABLE |
444 #undef X | 448 #undef X |
445 }; | 449 }; |
446 | 450 |
447 Variable *TargetX8632::getPhysicalRegister(SizeT RegNum) { | 451 Variable *TargetX8632::getPhysicalRegister(SizeT RegNum, Type Ty) { |
| 452 if (Ty == IceType_void) |
| 453 Ty = IceType_i32; |
448 assert(RegNum < PhysicalRegisters.size()); | 454 assert(RegNum < PhysicalRegisters.size()); |
449 Variable *Reg = PhysicalRegisters[RegNum]; | 455 Variable *Reg = PhysicalRegisters[RegNum]; |
450 if (Reg == NULL) { | 456 if (Reg == NULL) { |
451 Reg = Func->makeVariable(IceType_i32); | 457 Reg = Func->makeVariable(Ty); |
452 Reg->setRegNum(RegNum); | 458 Reg->setRegNum(RegNum); |
453 PhysicalRegisters[RegNum] = Reg; | 459 PhysicalRegisters[RegNum] = Reg; |
454 // Specially mark esp as an "argument" so that it is considered | 460 // Specially mark esp as an "argument" so that it is considered |
455 // live upon function entry. | 461 // live upon function entry. |
456 if (RegNum == RegX8632::Reg_esp) { | 462 if (RegNum == RegX8632::Reg_esp) { |
457 Func->addImplicitArg(Reg); | 463 Func->addImplicitArg(Reg); |
458 Reg->setIgnoreLiveness(); | 464 Reg->setIgnoreLiveness(); |
459 } | 465 } |
460 } | 466 } |
461 return Reg; | 467 return Reg; |
(...skipping 4067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4529 } else if (IsConstant || IsExternal) | 4535 } else if (IsConstant || IsExternal) |
4530 Str << "\t.zero\t" << Size << "\n"; | 4536 Str << "\t.zero\t" << Size << "\n"; |
4531 // Size is part of .comm. | 4537 // Size is part of .comm. |
4532 | 4538 |
4533 if (IsConstant || HasNonzeroInitializer || IsExternal) | 4539 if (IsConstant || HasNonzeroInitializer || IsExternal) |
4534 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 4540 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
4535 // Size is part of .comm. | 4541 // Size is part of .comm. |
4536 } | 4542 } |
4537 | 4543 |
4538 } // end of namespace Ice | 4544 } // end of namespace Ice |
OLD | NEW |