| OLD | NEW |
| 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// | 1 //===- subzero/src/IceCfg.cpp - Control flow graph 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 Cfg class, including constant pool | 10 // This file implements the Cfg class, including constant pool |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "IceTargetLowering.h" | 26 #include "IceTargetLowering.h" |
| 27 | 27 |
| 28 namespace Ice { | 28 namespace Ice { |
| 29 | 29 |
| 30 ICE_TLS_DEFINE_FIELD(const Cfg *, Cfg, CurrentCfg); | 30 ICE_TLS_DEFINE_FIELD(const Cfg *, Cfg, CurrentCfg); |
| 31 | 31 |
| 32 ArenaAllocator<> *getCurrentCfgAllocator() { | 32 ArenaAllocator<> *getCurrentCfgAllocator() { |
| 33 return Cfg::getCurrentCfgAllocator(); | 33 return Cfg::getCurrentCfgAllocator(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 Cfg::Cfg(GlobalContext *Ctx, uint32_t SequenceNumber) | 36 Cfg::Cfg(GlobalContext *MyCtx, uint32_t MySequenceNumber) |
| 37 : Ctx(Ctx), SequenceNumber(SequenceNumber), | 37 : Ctx(MyCtx), SequenceNumber(MySequenceNumber), |
| 38 VMask(Ctx->getFlags().getVerbose()), NextInstNumber(Inst::NumberInitial), | 38 VMask(Ctx->getFlags().getVerbose()), NextInstNumber(Inst::NumberInitial), |
| 39 Allocator(new ArenaAllocator<>()), Live(nullptr), | 39 Allocator(new ArenaAllocator<>()), Live(nullptr), |
| 40 Target(TargetLowering::createLowering(Ctx->getFlags().getTargetArch(), | 40 Target(TargetLowering::createLowering(Ctx->getFlags().getTargetArch(), |
| 41 this)), | 41 this)), |
| 42 VMetadata(new VariablesMetadata(this)), | 42 VMetadata(new VariablesMetadata(this)), |
| 43 TargetAssembler(TargetLowering::createAssembler( | 43 TargetAssembler(TargetLowering::createAssembler( |
| 44 Ctx->getFlags().getTargetArch(), this)) { | 44 Ctx->getFlags().getTargetArch(), this)) { |
| 45 assert(!Ctx->isIRGenerationDisabled() && | 45 assert(!Ctx->isIRGenerationDisabled() && |
| 46 "Attempt to build cfg when IR generation disabled"); | 46 "Attempt to build cfg when IR generation disabled"); |
| 47 } | 47 } |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 renumberInstructions(); | 559 renumberInstructions(); |
| 560 getVMetadata()->init(VMK_Uses); | 560 getVMetadata()->init(VMK_Uses); |
| 561 liveness(Liveness_Basic); | 561 liveness(Liveness_Basic); |
| 562 dump("After recomputing liveness for -decorate-asm"); | 562 dump("After recomputing liveness for -decorate-asm"); |
| 563 } | 563 } |
| 564 OstreamLocker L(Ctx); | 564 OstreamLocker L(Ctx); |
| 565 Ostream &Str = Ctx->getStrEmit(); | 565 Ostream &Str = Ctx->getStrEmit(); |
| 566 IceString MangledName = getContext()->mangleName(getFunctionName()); | 566 IceString MangledName = getContext()->mangleName(getFunctionName()); |
| 567 emitTextHeader(MangledName, Ctx, getAssembler<>()); | 567 emitTextHeader(MangledName, Ctx, getAssembler<>()); |
| 568 for (CfgNode *Node : Nodes) | 568 for (CfgNode *Node : Nodes) |
| 569 Node->emit(this); | 569 Node->emit(); |
| 570 Str << "\n"; | 570 Str << "\n"; |
| 571 } | 571 } |
| 572 | 572 |
| 573 void Cfg::emitIAS() { | 573 void Cfg::emitIAS() { |
| 574 TimerMarker T(TimerStack::TT_emit, this); | 574 TimerMarker T(TimerStack::TT_emit, this); |
| 575 // The emitIAS() routines emit into the internal assembler buffer, | 575 // The emitIAS() routines emit into the internal assembler buffer, |
| 576 // so there's no need to lock the streams. | 576 // so there's no need to lock the streams. |
| 577 for (CfgNode *Node : Nodes) | 577 for (CfgNode *Node : Nodes) |
| 578 Node->emitIAS(this); | 578 Node->emitIAS(); |
| 579 } | 579 } |
| 580 | 580 |
| 581 // Dumps the IR with an optional introductory message. | 581 // Dumps the IR with an optional introductory message. |
| 582 void Cfg::dump(const IceString &Message) { | 582 void Cfg::dump(const IceString &Message) { |
| 583 if (!BuildDefs::dump()) | 583 if (!BuildDefs::dump()) |
| 584 return; | 584 return; |
| 585 if (!isVerbose()) | 585 if (!isVerbose()) |
| 586 return; | 586 return; |
| 587 OstreamLocker L(Ctx); | 587 OstreamLocker L(Ctx); |
| 588 Ostream &Str = Ctx->getStrDump(); | 588 Ostream &Str = Ctx->getStrDump(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 612 Str << getVMetadata()->isMultiBlock(Var); | 612 Str << getVMetadata()->isMultiBlock(Var); |
| 613 else | 613 else |
| 614 Str << "?"; | 614 Str << "?"; |
| 615 Str << " weight=" << Var->getWeight() << " "; | 615 Str << " weight=" << Var->getWeight() << " "; |
| 616 Var->dump(this); | 616 Var->dump(this); |
| 617 Str << " LIVE=" << Var->getLiveRange() << "\n"; | 617 Str << " LIVE=" << Var->getLiveRange() << "\n"; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 // Print each basic block | 620 // Print each basic block |
| 621 for (CfgNode *Node : Nodes) | 621 for (CfgNode *Node : Nodes) |
| 622 Node->dump(this); | 622 Node->dump(); |
| 623 if (isVerbose(IceV_Instructions)) | 623 if (isVerbose(IceV_Instructions)) |
| 624 Str << "}\n"; | 624 Str << "}\n"; |
| 625 } | 625 } |
| 626 | 626 |
| 627 } // end of namespace Ice | 627 } // end of namespace Ice |
| OLD | NEW |