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 |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 } | 894 } |
895 | 895 |
896 // Helper class for emitIAS(). | 896 // Helper class for emitIAS(). |
897 namespace { | 897 namespace { |
898 class BundleEmitHelper { | 898 class BundleEmitHelper { |
899 BundleEmitHelper() = delete; | 899 BundleEmitHelper() = delete; |
900 BundleEmitHelper(const BundleEmitHelper &) = delete; | 900 BundleEmitHelper(const BundleEmitHelper &) = delete; |
901 BundleEmitHelper &operator=(const BundleEmitHelper &) = delete; | 901 BundleEmitHelper &operator=(const BundleEmitHelper &) = delete; |
902 | 902 |
903 public: | 903 public: |
904 BundleEmitHelper(Assembler *Asm, const InstList &Insts) | 904 BundleEmitHelper(Assembler *Asm, TargetLowering *Target, |
905 : Asm(Asm), End(Insts.end()), BundleLockStart(End), | 905 const InstList &Insts) |
| 906 : Asm(Asm), Target(Target), End(Insts.end()), BundleLockStart(End), |
906 BundleSize(1 << Asm->getBundleAlignLog2Bytes()), | 907 BundleSize(1 << Asm->getBundleAlignLog2Bytes()), |
907 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo), | 908 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo), |
908 SizeSnapshotPre(0), SizeSnapshotPost(0) {} | 909 SizeSnapshotPre(0), SizeSnapshotPost(0) {} |
909 // Check whether we're currently within a bundle_lock region. | 910 // Check whether we're currently within a bundle_lock region. |
910 bool isInBundleLockRegion() const { return BundleLockStart != End; } | 911 bool isInBundleLockRegion() const { return BundleLockStart != End; } |
911 // Check whether the current bundle_lock region has the align_to_end | 912 // Check whether the current bundle_lock region has the align_to_end |
912 // option. | 913 // option. |
913 bool isAlignToEnd() const { | 914 bool isAlignToEnd() const { |
914 assert(isInBundleLockRegion()); | 915 assert(isInBundleLockRegion()); |
915 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == | 916 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == |
(...skipping 25 matching lines...) Expand all Loading... |
941 assert(isInBundleLockRegion()); | 942 assert(isInBundleLockRegion()); |
942 return BundleLockStart; | 943 return BundleLockStart; |
943 } | 944 } |
944 // Set up bookkeeping when the bundle_lock instruction is first | 945 // Set up bookkeeping when the bundle_lock instruction is first |
945 // processed. | 946 // processed. |
946 void enterBundleLock(InstList::const_iterator I) { | 947 void enterBundleLock(InstList::const_iterator I) { |
947 assert(!isInBundleLockRegion()); | 948 assert(!isInBundleLockRegion()); |
948 BundleLockStart = I; | 949 BundleLockStart = I; |
949 SizeSnapshotPre = Asm->getBufferSize(); | 950 SizeSnapshotPre = Asm->getBufferSize(); |
950 Asm->setPreliminary(true); | 951 Asm->setPreliminary(true); |
| 952 Target->snapshotEmitState(); |
951 assert(isInBundleLockRegion()); | 953 assert(isInBundleLockRegion()); |
952 } | 954 } |
953 // Update bookkeeping when the bundle_unlock instruction is | 955 // Update bookkeeping when the bundle_unlock instruction is |
954 // processed. | 956 // processed. |
955 void enterBundleUnlock() { | 957 void enterBundleUnlock() { |
956 assert(isInBundleLockRegion()); | 958 assert(isInBundleLockRegion()); |
957 SizeSnapshotPost = Asm->getBufferSize(); | 959 SizeSnapshotPost = Asm->getBufferSize(); |
958 } | 960 } |
959 // Update bookkeeping when we are completely finished with the | 961 // Update bookkeeping when we are completely finished with the |
960 // bundle_lock region. | 962 // bundle_lock region. |
(...skipping 21 matching lines...) Expand all Loading... |
982 Asm->padWithNop(BundleSize - Offset); | 984 Asm->padWithNop(BundleSize - Offset); |
983 SizeSnapshotPre = Asm->getBufferSize(); | 985 SizeSnapshotPre = Asm->getBufferSize(); |
984 } | 986 } |
985 } | 987 } |
986 } | 988 } |
987 // Update bookkeeping when rolling back for the second pass. | 989 // Update bookkeeping when rolling back for the second pass. |
988 void rollback() { | 990 void rollback() { |
989 assert(isInBundleLockRegion()); | 991 assert(isInBundleLockRegion()); |
990 Asm->setBufferSize(SizeSnapshotPre); | 992 Asm->setBufferSize(SizeSnapshotPre); |
991 Asm->setPreliminary(false); | 993 Asm->setPreliminary(false); |
| 994 Target->rollbackEmitState(); |
992 } | 995 } |
993 | 996 |
994 private: | 997 private: |
995 Assembler *const Asm; | 998 Assembler *const Asm; |
| 999 TargetLowering *const Target; |
996 // End is a sentinel value such that BundleLockStart==End implies | 1000 // End is a sentinel value such that BundleLockStart==End implies |
997 // that we are not in a bundle_lock region. | 1001 // that we are not in a bundle_lock region. |
998 const InstList::const_iterator End; | 1002 const InstList::const_iterator End; |
999 InstList::const_iterator BundleLockStart; | 1003 InstList::const_iterator BundleLockStart; |
1000 const intptr_t BundleSize; | 1004 const intptr_t BundleSize; |
1001 // Masking with BundleMaskLo identifies an address's bundle offset. | 1005 // Masking with BundleMaskLo identifies an address's bundle offset. |
1002 const intptr_t BundleMaskLo; | 1006 const intptr_t BundleMaskLo; |
1003 // Masking with BundleMaskHi identifies an address's bundle. | 1007 // Masking with BundleMaskHi identifies an address's bundle. |
1004 const intptr_t BundleMaskHi; | 1008 const intptr_t BundleMaskHi; |
1005 intptr_t SizeSnapshotPre; | 1009 intptr_t SizeSnapshotPre; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 // Emission is done twice for each bundle_lock region. The first | 1044 // Emission is done twice for each bundle_lock region. The first |
1041 // pass is a preliminary pass, after which we can figure out what | 1045 // pass is a preliminary pass, after which we can figure out what |
1042 // nop padding is needed, then roll back, and make the final pass. | 1046 // nop padding is needed, then roll back, and make the final pass. |
1043 // | 1047 // |
1044 // Ideally, the first pass would be speculative and the second pass | 1048 // Ideally, the first pass would be speculative and the second pass |
1045 // would only be done if nop padding were needed, but the structure | 1049 // would only be done if nop padding were needed, but the structure |
1046 // of the integrated assembler makes it hard to roll back the state | 1050 // of the integrated assembler makes it hard to roll back the state |
1047 // of label bindings, label links, and relocation fixups. Instead, | 1051 // of label bindings, label links, and relocation fixups. Instead, |
1048 // the first pass just disables all mutation of that state. | 1052 // the first pass just disables all mutation of that state. |
1049 | 1053 |
1050 BundleEmitHelper Helper(Asm, Insts); | 1054 BundleEmitHelper Helper(Asm, Func->getTarget(), Insts); |
1051 InstList::const_iterator End = Insts.end(); | 1055 InstList::const_iterator End = Insts.end(); |
1052 // Retrying indicates that we had to roll back to the bundle_lock | 1056 // Retrying indicates that we had to roll back to the bundle_lock |
1053 // instruction to apply padding before the bundle_lock sequence. | 1057 // instruction to apply padding before the bundle_lock sequence. |
1054 bool Retrying = false; | 1058 bool Retrying = false; |
1055 for (InstList::const_iterator I = Insts.begin(); I != End; ++I) { | 1059 for (InstList::const_iterator I = Insts.begin(); I != End; ++I) { |
1056 if (I->isDeleted() || I->isRedundantAssign()) | 1060 if (I->isDeleted() || I->isRedundantAssign()) |
1057 continue; | 1061 continue; |
1058 | 1062 |
1059 if (llvm::isa<InstBundleLock>(I)) { | 1063 if (llvm::isa<InstBundleLock>(I)) { |
1060 // Set up the initial bundle_lock state. This should not happen | 1064 // Set up the initial bundle_lock state. This should not happen |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 if (!First) | 1194 if (!First) |
1191 Str << ", "; | 1195 Str << ", "; |
1192 First = false; | 1196 First = false; |
1193 Str << "%" << I->getName(); | 1197 Str << "%" << I->getName(); |
1194 } | 1198 } |
1195 Str << "\n"; | 1199 Str << "\n"; |
1196 } | 1200 } |
1197 } | 1201 } |
1198 | 1202 |
1199 } // end of namespace Ice | 1203 } // end of namespace Ice |
OLD | NEW |