OLD | NEW |
1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// | 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) 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 CfgNode class, including the complexities | 10 // This file implements the CfgNode class, including the complexities |
11 // of instruction insertion and in-edge calculation. | 11 // of instruction insertion and in-edge calculation. |
12 // | 12 // |
13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
14 | 14 |
15 #include "IceAssembler.h" | 15 #include "IceAssembler.h" |
16 #include "IceCfg.h" | 16 #include "IceCfg.h" |
17 #include "IceCfgNode.h" | 17 #include "IceCfgNode.h" |
18 #include "IceGlobalInits.h" | 18 #include "IceGlobalInits.h" |
19 #include "IceInst.h" | 19 #include "IceInst.h" |
20 #include "IceLiveness.h" | 20 #include "IceLiveness.h" |
21 #include "IceOperand.h" | 21 #include "IceOperand.h" |
22 #include "IceTargetLowering.h" | 22 #include "IceTargetLowering.h" |
23 | 23 |
24 namespace Ice { | 24 namespace Ice { |
25 | 25 |
26 CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber) | 26 CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber) |
27 : Func(Func), Number(LabelNumber), NameIndex(Cfg::IdentifierIndexInvalid), | 27 : Func(Func), Number(LabelNumber) {} |
28 HasReturn(false), NeedsPlacement(false), InstCountEstimate(0) {} | |
29 | 28 |
30 // Returns the name the node was created with. If no name was given, | 29 // Returns the name the node was created with. If no name was given, |
31 // it synthesizes a (hopefully) unique name. | 30 // it synthesizes a (hopefully) unique name. |
32 IceString CfgNode::getName() const { | 31 IceString CfgNode::getName() const { |
33 if (NameIndex >= 0) | 32 if (NameIndex >= 0) |
34 return Func->getIdentifierName(NameIndex); | 33 return Func->getIdentifierName(NameIndex); |
35 return "__" + std::to_string(getIndex()); | 34 return "__" + std::to_string(getIndex()); |
36 } | 35 } |
37 | 36 |
38 // Adds an instruction to either the Phi list or the regular | 37 // Adds an instruction to either the Phi list or the regular |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 class BundleEmitHelper { | 941 class BundleEmitHelper { |
943 BundleEmitHelper() = delete; | 942 BundleEmitHelper() = delete; |
944 BundleEmitHelper(const BundleEmitHelper &) = delete; | 943 BundleEmitHelper(const BundleEmitHelper &) = delete; |
945 BundleEmitHelper &operator=(const BundleEmitHelper &) = delete; | 944 BundleEmitHelper &operator=(const BundleEmitHelper &) = delete; |
946 | 945 |
947 public: | 946 public: |
948 BundleEmitHelper(Assembler *Asm, TargetLowering *Target, | 947 BundleEmitHelper(Assembler *Asm, TargetLowering *Target, |
949 const InstList &Insts) | 948 const InstList &Insts) |
950 : Asm(Asm), Target(Target), End(Insts.end()), BundleLockStart(End), | 949 : Asm(Asm), Target(Target), End(Insts.end()), BundleLockStart(End), |
951 BundleSize(1 << Asm->getBundleAlignLog2Bytes()), | 950 BundleSize(1 << Asm->getBundleAlignLog2Bytes()), |
952 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo), | 951 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo) {} |
953 SizeSnapshotPre(0), SizeSnapshotPost(0) {} | |
954 // Check whether we're currently within a bundle_lock region. | 952 // Check whether we're currently within a bundle_lock region. |
955 bool isInBundleLockRegion() const { return BundleLockStart != End; } | 953 bool isInBundleLockRegion() const { return BundleLockStart != End; } |
956 // Check whether the current bundle_lock region has the align_to_end | 954 // Check whether the current bundle_lock region has the align_to_end |
957 // option. | 955 // option. |
958 bool isAlignToEnd() const { | 956 bool isAlignToEnd() const { |
959 assert(isInBundleLockRegion()); | 957 assert(isInBundleLockRegion()); |
960 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == | 958 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == |
961 InstBundleLock::Opt_AlignToEnd; | 959 InstBundleLock::Opt_AlignToEnd; |
962 } | 960 } |
963 // Check whether the entire bundle_lock region falls within the same | 961 // Check whether the entire bundle_lock region falls within the same |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 TargetLowering *const Target; | 1041 TargetLowering *const Target; |
1044 // End is a sentinel value such that BundleLockStart==End implies | 1042 // End is a sentinel value such that BundleLockStart==End implies |
1045 // that we are not in a bundle_lock region. | 1043 // that we are not in a bundle_lock region. |
1046 const InstList::const_iterator End; | 1044 const InstList::const_iterator End; |
1047 InstList::const_iterator BundleLockStart; | 1045 InstList::const_iterator BundleLockStart; |
1048 const intptr_t BundleSize; | 1046 const intptr_t BundleSize; |
1049 // Masking with BundleMaskLo identifies an address's bundle offset. | 1047 // Masking with BundleMaskLo identifies an address's bundle offset. |
1050 const intptr_t BundleMaskLo; | 1048 const intptr_t BundleMaskLo; |
1051 // Masking with BundleMaskHi identifies an address's bundle. | 1049 // Masking with BundleMaskHi identifies an address's bundle. |
1052 const intptr_t BundleMaskHi; | 1050 const intptr_t BundleMaskHi; |
1053 intptr_t SizeSnapshotPre; | 1051 intptr_t SizeSnapshotPre = 0; |
1054 intptr_t SizeSnapshotPost; | 1052 intptr_t SizeSnapshotPost = 0; |
1055 }; | 1053 }; |
1056 | 1054 |
1057 } // end of anonymous namespace | 1055 } // end of anonymous namespace |
1058 | 1056 |
1059 void CfgNode::emitIAS(Cfg *Func) const { | 1057 void CfgNode::emitIAS(Cfg *Func) const { |
1060 Func->setCurrentNode(this); | 1058 Func->setCurrentNode(this); |
1061 Assembler *Asm = Func->getAssembler<>(); | 1059 Assembler *Asm = Func->getAssembler<>(); |
1062 // TODO(stichnot): When sandboxing, defer binding the node label | 1060 // TODO(stichnot): When sandboxing, defer binding the node label |
1063 // until just before the first instruction is emitted, to reduce the | 1061 // until just before the first instruction is emitted, to reduce the |
1064 // chance that a padding nop is a branch target. | 1062 // chance that a padding nop is a branch target. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 InstIntrinsicCall *Inst = InstIntrinsicCall::create( | 1266 InstIntrinsicCall *Inst = InstIntrinsicCall::create( |
1269 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); | 1267 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); |
1270 Inst->addArg(AtomicRMWOp); | 1268 Inst->addArg(AtomicRMWOp); |
1271 Inst->addArg(Counter); | 1269 Inst->addArg(Counter); |
1272 Inst->addArg(One); | 1270 Inst->addArg(One); |
1273 Inst->addArg(OrderAcquireRelease); | 1271 Inst->addArg(OrderAcquireRelease); |
1274 Insts.push_front(Inst); | 1272 Insts.push_front(Inst); |
1275 } | 1273 } |
1276 | 1274 |
1277 } // end of namespace Ice | 1275 } // end of namespace Ice |
OLD | NEW |