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 /// \file | 10 /// \file |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1100 BundleSize(1 << Asm->getBundleAlignLog2Bytes()), | 1100 BundleSize(1 << Asm->getBundleAlignLog2Bytes()), |
1101 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo) {} | 1101 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo) {} |
1102 // Check whether we're currently within a bundle_lock region. | 1102 // Check whether we're currently within a bundle_lock region. |
1103 bool isInBundleLockRegion() const { return BundleLockStart != End; } | 1103 bool isInBundleLockRegion() const { return BundleLockStart != End; } |
1104 // Check whether the current bundle_lock region has the align_to_end option. | 1104 // Check whether the current bundle_lock region has the align_to_end option. |
1105 bool isAlignToEnd() const { | 1105 bool isAlignToEnd() const { |
1106 assert(isInBundleLockRegion()); | 1106 assert(isInBundleLockRegion()); |
1107 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == | 1107 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == |
1108 InstBundleLock::Opt_AlignToEnd; | 1108 InstBundleLock::Opt_AlignToEnd; |
1109 } | 1109 } |
1110 bool isPadToEnd() const { | |
1111 assert(isInBundleLockRegion()); | |
1112 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == | |
1113 InstBundleLock::Opt_PadToEnd; | |
1114 } | |
1110 // Check whether the entire bundle_lock region falls within the same bundle. | 1115 // Check whether the entire bundle_lock region falls within the same bundle. |
1111 bool isSameBundle() const { | 1116 bool isSameBundle() const { |
1112 assert(isInBundleLockRegion()); | 1117 assert(isInBundleLockRegion()); |
1113 return SizeSnapshotPre == SizeSnapshotPost || | 1118 return SizeSnapshotPre == SizeSnapshotPost || |
1114 (SizeSnapshotPre & BundleMaskHi) == | 1119 (SizeSnapshotPre & BundleMaskHi) == |
1115 ((SizeSnapshotPost - 1) & BundleMaskHi); | 1120 ((SizeSnapshotPost - 1) & BundleMaskHi); |
1116 } | 1121 } |
1117 // Get the bundle alignment of the first instruction of the bundle_lock | 1122 // Get the bundle alignment of the first instruction of the bundle_lock |
1118 // region. | 1123 // region. |
1119 intptr_t getPreAlignment() const { | 1124 intptr_t getPreAlignment() const { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1165 // sequences ends precisely at a bundle boundary. | 1170 // sequences ends precisely at a bundle boundary. |
1166 void padForAlignToEnd() { | 1171 void padForAlignToEnd() { |
1167 assert(isInBundleLockRegion()); | 1172 assert(isInBundleLockRegion()); |
1168 if (isAlignToEnd()) { | 1173 if (isAlignToEnd()) { |
1169 if (intptr_t Offset = getPostAlignment()) { | 1174 if (intptr_t Offset = getPostAlignment()) { |
1170 Asm->padWithNop(BundleSize - Offset); | 1175 Asm->padWithNop(BundleSize - Offset); |
1171 SizeSnapshotPre = Asm->getBufferSize(); | 1176 SizeSnapshotPre = Asm->getBufferSize(); |
1172 } | 1177 } |
1173 } | 1178 } |
1174 } | 1179 } |
1175 // Update bookkeeping when rolling back for the second pass. | 1180 // If pad_to_end is specified, add padding such that the first instruction |
1181 // after the instruction sequence starts starts at a bundle boundary. | |
Jim Stichnoth
2016/01/14 00:09:52
starts starts
John
2016/01/14 23:18:25
Done.
| |
1182 void padForPadToEnd() { | |
1183 assert(isInBundleLockRegion()); | |
1184 if (isPadToEnd()) { | |
1185 if (intptr_t Offset = getPostAlignment()) { | |
1186 Asm->padWithNop(BundleSize - Offset); | |
1187 SizeSnapshotPre = Asm->getBufferSize(); | |
1188 } | |
1189 } | |
1190 } // Update bookkeeping when rolling back for the second pass. | |
1176 void rollback() { | 1191 void rollback() { |
1177 assert(isInBundleLockRegion()); | 1192 assert(isInBundleLockRegion()); |
1178 Asm->setBufferSize(SizeSnapshotPre); | 1193 Asm->setBufferSize(SizeSnapshotPre); |
1179 Asm->setPreliminary(false); | 1194 Asm->setPreliminary(false); |
1180 } | 1195 } |
1181 | 1196 |
1182 private: | 1197 private: |
1183 Assembler *const Asm; | 1198 Assembler *const Asm; |
1184 // End is a sentinel value such that BundleLockStart==End implies that we are | 1199 // End is a sentinel value such that BundleLockStart==End implies that we are |
1185 // not in a bundle_lock region. | 1200 // not in a bundle_lock region. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1254 } | 1269 } |
1255 | 1270 |
1256 if (llvm::isa<InstBundleUnlock>(I)) { | 1271 if (llvm::isa<InstBundleUnlock>(I)) { |
1257 Helper.enterBundleUnlock(); | 1272 Helper.enterBundleUnlock(); |
1258 if (Retrying) { | 1273 if (Retrying) { |
1259 // Make sure all instructions are in the same bundle. | 1274 // Make sure all instructions are in the same bundle. |
1260 assert(Helper.isSameBundle()); | 1275 assert(Helper.isSameBundle()); |
1261 // If align_to_end is specified, make sure the next instruction begins | 1276 // If align_to_end is specified, make sure the next instruction begins |
1262 // the bundle. | 1277 // the bundle. |
1263 assert(!Helper.isAlignToEnd() || Helper.getPostAlignment() == 0); | 1278 assert(!Helper.isAlignToEnd() || Helper.getPostAlignment() == 0); |
1279 Helper.padForPadToEnd(); | |
1264 Helper.leaveBundleLockRegion(); | 1280 Helper.leaveBundleLockRegion(); |
1265 Retrying = false; | 1281 Retrying = false; |
1266 } else { | 1282 } else { |
1267 // This is the first pass, so roll back for the retry pass. | 1283 // This is the first pass, so roll back for the retry pass. |
1268 Helper.rollback(); | 1284 Helper.rollback(); |
1269 // Pad to the next bundle if the instruction sequence crossed a bundle | 1285 // Pad to the next bundle if the instruction sequence crossed a bundle |
1270 // boundary. | 1286 // boundary. |
1271 Helper.padToNextBundle(); | 1287 Helper.padToNextBundle(); |
1272 // Insert additional padding to make AlignToEnd work. | 1288 // Insert additional padding to make AlignToEnd work. |
1273 Helper.padForAlignToEnd(); | 1289 Helper.padForAlignToEnd(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1410 auto *Inst = InstIntrinsicCall::create( | 1426 auto *Inst = InstIntrinsicCall::create( |
1411 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); | 1427 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); |
1412 Inst->addArg(AtomicRMWOp); | 1428 Inst->addArg(AtomicRMWOp); |
1413 Inst->addArg(Counter); | 1429 Inst->addArg(Counter); |
1414 Inst->addArg(One); | 1430 Inst->addArg(One); |
1415 Inst->addArg(OrderAcquireRelease); | 1431 Inst->addArg(OrderAcquireRelease); |
1416 Insts.push_front(Inst); | 1432 Insts.push_front(Inst); |
1417 } | 1433 } |
1418 | 1434 |
1419 } // end of namespace Ice | 1435 } // end of namespace Ice |
OLD | NEW |