| 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 /// \file | 10 /// \file |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 Cfg::~Cfg() { assert(ICE_TLS_GET_FIELD(CurrentCfg) == nullptr); } | 57 Cfg::~Cfg() { assert(ICE_TLS_GET_FIELD(CurrentCfg) == nullptr); } |
| 58 | 58 |
| 59 void Cfg::setError(const IceString &Message) { | 59 void Cfg::setError(const IceString &Message) { |
| 60 HasError = true; | 60 HasError = true; |
| 61 ErrorMessage = Message; | 61 ErrorMessage = Message; |
| 62 } | 62 } |
| 63 | 63 |
| 64 CfgNode *Cfg::makeNode() { | 64 CfgNode *Cfg::makeNode() { |
| 65 SizeT LabelIndex = Nodes.size(); | 65 SizeT LabelIndex = Nodes.size(); |
| 66 CfgNode *Node = CfgNode::create(this, LabelIndex); | 66 auto *Node = CfgNode::create(this, LabelIndex); |
| 67 Nodes.push_back(Node); | 67 Nodes.push_back(Node); |
| 68 return Node; | 68 return Node; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void Cfg::swapNodes(NodeList &NewNodes) { | 71 void Cfg::swapNodes(NodeList &NewNodes) { |
| 72 assert(Nodes.size() == NewNodes.size()); | 72 assert(Nodes.size() == NewNodes.size()); |
| 73 Nodes.swap(NewNodes); | 73 Nodes.swap(NewNodes); |
| 74 for (SizeT I = 0, NumNodes = getNumNodes(); I < NumNodes; ++I) | 74 for (SizeT I = 0, NumNodes = getNumNodes(); I < NumNodes; ++I) |
| 75 Nodes[I]->resetIndex(I); | 75 Nodes[I]->resetIndex(I); |
| 76 } | 76 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 97 // Returns whether the stack frame layout has been computed yet. This is used | 97 // Returns whether the stack frame layout has been computed yet. This is used |
| 98 // for dumping the stack frame location of Variables. | 98 // for dumping the stack frame location of Variables. |
| 99 bool Cfg::hasComputedFrame() const { return getTarget()->hasComputedFrame(); } | 99 bool Cfg::hasComputedFrame() const { return getTarget()->hasComputedFrame(); } |
| 100 | 100 |
| 101 namespace { | 101 namespace { |
| 102 constexpr char BlockNameGlobalPrefix[] = ".L$profiler$block_name$"; | 102 constexpr char BlockNameGlobalPrefix[] = ".L$profiler$block_name$"; |
| 103 constexpr char BlockStatsGlobalPrefix[] = ".L$profiler$block_info$"; | 103 constexpr char BlockStatsGlobalPrefix[] = ".L$profiler$block_info$"; |
| 104 | 104 |
| 105 VariableDeclaration *nodeNameDeclaration(GlobalContext *Ctx, | 105 VariableDeclaration *nodeNameDeclaration(GlobalContext *Ctx, |
| 106 const IceString &NodeAsmName) { | 106 const IceString &NodeAsmName) { |
| 107 VariableDeclaration *Var = VariableDeclaration::create(Ctx); | 107 auto *Var = VariableDeclaration::create(Ctx); |
| 108 Var->setName(BlockNameGlobalPrefix + NodeAsmName); | 108 Var->setName(BlockNameGlobalPrefix + NodeAsmName); |
| 109 Var->setIsConstant(true); | 109 Var->setIsConstant(true); |
| 110 Var->addInitializer(VariableDeclaration::DataInitializer::create( | 110 Var->addInitializer(VariableDeclaration::DataInitializer::create( |
| 111 NodeAsmName.data(), NodeAsmName.size() + 1)); | 111 NodeAsmName.data(), NodeAsmName.size() + 1)); |
| 112 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64); | 112 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64); |
| 113 Var->setAlignment(Int64ByteSize); // Wasteful, 32-bit could use 4 bytes. | 113 Var->setAlignment(Int64ByteSize); // Wasteful, 32-bit could use 4 bytes. |
| 114 return Var; | 114 return Var; |
| 115 } | 115 } |
| 116 | 116 |
| 117 VariableDeclaration * | 117 VariableDeclaration * |
| 118 blockProfilingInfoDeclaration(GlobalContext *Ctx, const IceString &NodeAsmName, | 118 blockProfilingInfoDeclaration(GlobalContext *Ctx, const IceString &NodeAsmName, |
| 119 VariableDeclaration *NodeNameDeclaration) { | 119 VariableDeclaration *NodeNameDeclaration) { |
| 120 VariableDeclaration *Var = VariableDeclaration::create(Ctx); | 120 auto *Var = VariableDeclaration::create(Ctx); |
| 121 Var->setName(BlockStatsGlobalPrefix + NodeAsmName); | 121 Var->setName(BlockStatsGlobalPrefix + NodeAsmName); |
| 122 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64); | 122 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64); |
| 123 Var->addInitializer( | 123 Var->addInitializer( |
| 124 VariableDeclaration::ZeroInitializer::create(Int64ByteSize)); | 124 VariableDeclaration::ZeroInitializer::create(Int64ByteSize)); |
| 125 | 125 |
| 126 const RelocOffsetT NodeNameDeclarationOffset = 0; | 126 const RelocOffsetT NodeNameDeclarationOffset = 0; |
| 127 Var->addInitializer(VariableDeclaration::RelocInitializer::create( | 127 Var->addInitializer(VariableDeclaration::RelocInitializer::create( |
| 128 NodeNameDeclaration, NodeNameDeclarationOffset)); | 128 NodeNameDeclaration, NodeNameDeclarationOffset)); |
| 129 Var->setAlignment(Int64ByteSize); | 129 Var->setAlignment(Int64ByteSize); |
| 130 return Var; | 130 return Var; |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 InstAlloca::create(this, BaseVariable, AllocaSize, CombinedAlignment); | 519 InstAlloca::create(this, BaseVariable, AllocaSize, CombinedAlignment); |
| 520 CombinedAlloca->setKnownFrameOffset(); | 520 CombinedAlloca->setKnownFrameOffset(); |
| 521 Insts.push_front(CombinedAlloca); | 521 Insts.push_front(CombinedAlloca); |
| 522 } break; | 522 } break; |
| 523 case BVT_StackPointer: | 523 case BVT_StackPointer: |
| 524 case BVT_FramePointer: { | 524 case BVT_FramePointer: { |
| 525 for (SizeT i = 0; i < Allocas.size(); ++i) { | 525 for (SizeT i = 0; i < Allocas.size(); ++i) { |
| 526 auto *Alloca = llvm::cast<InstAlloca>(Allocas[i]); | 526 auto *Alloca = llvm::cast<InstAlloca>(Allocas[i]); |
| 527 // Emit a fake definition of the rematerializable variable. | 527 // Emit a fake definition of the rematerializable variable. |
| 528 Variable *Dest = Alloca->getDest(); | 528 Variable *Dest = Alloca->getDest(); |
| 529 InstFakeDef *Def = InstFakeDef::create(this, Dest); | 529 auto *Def = InstFakeDef::create(this, Dest); |
| 530 if (BaseVariableType == BVT_StackPointer) | 530 if (BaseVariableType == BVT_StackPointer) |
| 531 Dest->setRematerializable(getTarget()->getStackReg(), Offsets[i]); | 531 Dest->setRematerializable(getTarget()->getStackReg(), Offsets[i]); |
| 532 else | 532 else |
| 533 Dest->setRematerializable(getTarget()->getFrameReg(), Offsets[i]); | 533 Dest->setRematerializable(getTarget()->getFrameReg(), Offsets[i]); |
| 534 Insts.push_front(Def); | 534 Insts.push_front(Def); |
| 535 Alloca->setDeleted(); | 535 Alloca->setDeleted(); |
| 536 } | 536 } |
| 537 // Allocate the fixed area in the function prolog. | 537 // Allocate the fixed area in the function prolog. |
| 538 getTarget()->reserveFixedAllocaArea(TotalSize, CombinedAlignment); | 538 getTarget()->reserveFixedAllocaArea(TotalSize, CombinedAlignment); |
| 539 } break; | 539 } break; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 } | 1096 } |
| 1097 } | 1097 } |
| 1098 // Print each basic block | 1098 // Print each basic block |
| 1099 for (CfgNode *Node : Nodes) | 1099 for (CfgNode *Node : Nodes) |
| 1100 Node->dump(this); | 1100 Node->dump(this); |
| 1101 if (isVerbose(IceV_Instructions)) | 1101 if (isVerbose(IceV_Instructions)) |
| 1102 Str << "}\n"; | 1102 Str << "}\n"; |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 } // end of namespace Ice | 1105 } // end of namespace Ice |
| OLD | NEW |