| OLD | NEW |
| 1 //===- subzero/src/IceOperand.cpp - High-level operand implementation -----===// | 1 //===- subzero/src/IceOperand.cpp - High-level operand implementation -----===// |
| 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 Operand class and its target-independent | 10 // This file implements the Operand class and its target-independent |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 return NULL; // conservative answer | 424 return NULL; // conservative answer |
| 425 SizeT VarNum = Var->getIndex(); | 425 SizeT VarNum = Var->getIndex(); |
| 426 return Metadata[VarNum].getNode(); | 426 return Metadata[VarNum].getNode(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 const InstDefList VariablesMetadata::NoDefinitions; | 429 const InstDefList VariablesMetadata::NoDefinitions; |
| 430 | 430 |
| 431 // ======================== dump routines ======================== // | 431 // ======================== dump routines ======================== // |
| 432 | 432 |
| 433 void Variable::emit(const Cfg *Func) const { | 433 void Variable::emit(const Cfg *Func) const { |
| 434 Func->getTarget()->emitVariable(this); | 434 if (ALLOW_DUMP) |
| 435 Func->getTarget()->emitVariable(this); |
| 435 } | 436 } |
| 436 | 437 |
| 437 void Variable::dump(const Cfg *Func, Ostream &Str) const { | 438 void Variable::dump(const Cfg *Func, Ostream &Str) const { |
| 439 if (!ALLOW_DUMP) |
| 440 return; |
| 438 if (Func == NULL) { | 441 if (Func == NULL) { |
| 439 Str << "%" << getName(); | 442 Str << "%" << getName(); |
| 440 return; | 443 return; |
| 441 } | 444 } |
| 442 if (Func->getContext()->isVerbose(IceV_RegOrigins) || | 445 if (Func->getContext()->isVerbose(IceV_RegOrigins) || |
| 443 (!hasReg() && !Func->getTarget()->hasComputedFrame())) | 446 (!hasReg() && !Func->getTarget()->hasComputedFrame())) |
| 444 Str << "%" << getName(); | 447 Str << "%" << getName(); |
| 445 if (hasReg()) { | 448 if (hasReg()) { |
| 446 if (Func->getContext()->isVerbose(IceV_RegOrigins)) | 449 if (Func->getContext()->isVerbose(IceV_RegOrigins)) |
| 447 Str << ":"; | 450 Str << ":"; |
| 448 Str << Func->getTarget()->getRegName(RegNum, getType()); | 451 Str << Func->getTarget()->getRegName(RegNum, getType()); |
| 449 } else if (Func->getTarget()->hasComputedFrame()) { | 452 } else if (Func->getTarget()->hasComputedFrame()) { |
| 450 if (Func->getContext()->isVerbose(IceV_RegOrigins)) | 453 if (Func->getContext()->isVerbose(IceV_RegOrigins)) |
| 451 Str << ":"; | 454 Str << ":"; |
| 452 Str << "[" << Func->getTarget()->getRegName( | 455 Str << "[" << Func->getTarget()->getRegName( |
| 453 Func->getTarget()->getFrameOrStackReg(), IceType_i32); | 456 Func->getTarget()->getFrameOrStackReg(), IceType_i32); |
| 454 int32_t Offset = getStackOffset(); | 457 int32_t Offset = getStackOffset(); |
| 455 if (Offset) { | 458 if (Offset) { |
| 456 if (Offset > 0) | 459 if (Offset > 0) |
| 457 Str << "+"; | 460 Str << "+"; |
| 458 Str << Offset; | 461 Str << Offset; |
| 459 } | 462 } |
| 460 Str << "]"; | 463 Str << "]"; |
| 461 } | 464 } |
| 462 } | 465 } |
| 463 | 466 |
| 464 void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const { | 467 void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const { |
| 468 if (!ALLOW_DUMP) |
| 469 return; |
| 465 Ostream &Str = Ctx->getStrEmit(); | 470 Ostream &Str = Ctx->getStrEmit(); |
| 466 if (SuppressMangling) | 471 if (SuppressMangling) |
| 467 Str << Name; | 472 Str << Name; |
| 468 else | 473 else |
| 469 Str << Ctx->mangleName(Name); | 474 Str << Ctx->mangleName(Name); |
| 470 if (Offset) { | 475 if (Offset) { |
| 471 if (Offset > 0) | 476 if (Offset > 0) |
| 472 Str << "+"; | 477 Str << "+"; |
| 473 Str << Offset; | 478 Str << Offset; |
| 474 } | 479 } |
| 475 } | 480 } |
| 476 | 481 |
| 477 void ConstantRelocatable::emit(GlobalContext *Ctx) const { | 482 void ConstantRelocatable::emit(GlobalContext *Ctx) const { |
| 483 if (!ALLOW_DUMP) |
| 484 return; |
| 478 Ostream &Str = Ctx->getStrEmit(); | 485 Ostream &Str = Ctx->getStrEmit(); |
| 479 Str << "$"; | 486 Str << "$"; |
| 480 emitWithoutDollar(Ctx); | 487 emitWithoutDollar(Ctx); |
| 481 } | 488 } |
| 482 | 489 |
| 483 void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const { | 490 void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const { |
| 491 if (!ALLOW_DUMP) |
| 492 return; |
| 484 Str << "@"; | 493 Str << "@"; |
| 485 if (Func && !SuppressMangling) { | 494 if (Func && !SuppressMangling) { |
| 486 Str << Func->getContext()->mangleName(Name); | 495 Str << Func->getContext()->mangleName(Name); |
| 487 } else { | 496 } else { |
| 488 Str << Name; | 497 Str << Name; |
| 489 } | 498 } |
| 490 if (Offset) | 499 if (Offset) |
| 491 Str << "+" << Offset; | 500 Str << "+" << Offset; |
| 492 } | 501 } |
| 493 | 502 |
| 494 void LiveRange::dump(Ostream &Str) const { | 503 void LiveRange::dump(Ostream &Str) const { |
| 504 if (!ALLOW_DUMP) |
| 505 return; |
| 495 Str << "(weight=" << Weight << ") "; | 506 Str << "(weight=" << Weight << ") "; |
| 496 bool First = true; | 507 bool First = true; |
| 497 for (const RangeElementType &I : Range) { | 508 for (const RangeElementType &I : Range) { |
| 498 if (!First) | 509 if (!First) |
| 499 Str << ", "; | 510 Str << ", "; |
| 500 First = false; | 511 First = false; |
| 501 Str << "[" << I.first << ":" << I.second << ")"; | 512 Str << "[" << I.first << ":" << I.second << ")"; |
| 502 } | 513 } |
| 503 } | 514 } |
| 504 | 515 |
| 505 Ostream &operator<<(Ostream &Str, const LiveRange &L) { | 516 Ostream &operator<<(Ostream &Str, const LiveRange &L) { |
| 517 if (!ALLOW_DUMP) |
| 518 return Str; |
| 506 L.dump(Str); | 519 L.dump(Str); |
| 507 return Str; | 520 return Str; |
| 508 } | 521 } |
| 509 | 522 |
| 510 Ostream &operator<<(Ostream &Str, const RegWeight &W) { | 523 Ostream &operator<<(Ostream &Str, const RegWeight &W) { |
| 524 if (!ALLOW_DUMP) |
| 525 return Str; |
| 511 if (W.getWeight() == RegWeight::Inf) | 526 if (W.getWeight() == RegWeight::Inf) |
| 512 Str << "Inf"; | 527 Str << "Inf"; |
| 513 else | 528 else |
| 514 Str << W.getWeight(); | 529 Str << W.getWeight(); |
| 515 return Str; | 530 return Str; |
| 516 } | 531 } |
| 517 | 532 |
| 518 } // end of namespace Ice | 533 } // end of namespace Ice |
| OLD | NEW |