@@ -1019,38 +1019,40 @@ ValueOwnershipKind::getForwardingOperandOwnership(bool allowUnowned) const {
10191019// / A formal SIL reference to a value, suitable for use as a stored
10201020// / operand.
10211021class Operand {
1022+ public:
1023+ enum { numCustomBits = 8 };
1024+ enum { maxBitfieldID = std::numeric_limits<uint64_t >::max () >> numCustomBits };
1025+
1026+ private:
10221027 template <class , class > friend class SILBitfield ;
10231028
1024- // / The value used as this operand combined with three bits we use for
1025- // / `customBits`.
1026- llvm::PointerIntPair<SILValue, 3 > TheValueAndThreeBits = {SILValue (), 0 };
1029+ // / The value used as this operand.
1030+ SILValue TheValue;
10271031
1028- // / The next operand in the use-chain. Note that the chain holds every use of
1029- // / the current ValueBase, not just those of the designated result.
1030- // /
1031- // / We use 3 bits of the pointer for customBits.
1032- llvm::PointerIntPair<Operand *, 3 > NextUseAndThreeBits = {nullptr , 0 };
1032+ // / The next operand in the use-chain. Note that the chain holds
1033+ // / every use of the current ValueBase, not just those of the
1034+ // / designated result.
1035+ Operand *NextUse = nullptr ;
10331036
10341037 // / A back-pointer in the use-chain, required for fast patching
10351038 // / of use-chains.
1036- // /
1037- // / We use 2 bits of the pointer for customBits.
1038- llvm::PointerIntPair<Operand **, 3 > BackAndThreeBits = {nullptr , 0 };
1039+ Operand **Back = nullptr ;
10391040
10401041 // / The owner of this operand.
10411042 // / FIXME: this could be space-compressed.
10421043 SILInstruction *Owner;
10431044
1044- // / Used by `OperandBitfield`
1045- enum { numCustomBits = 8 };
1045+ uint64_t customBits : numCustomBits;
10461046
1047- // / Used by `OperandBitfield`
1048- int64_t lastInitializedBitfieldID = 0 ;
1047+ // For details see SILNode::lastInitializedBitfieldID
1048+ uint64_t lastInitializedBitfieldID : ( 64 - numCustomBits) ;
10491049
10501050public:
1051- Operand (SILInstruction *owner) : Owner(owner) {}
1051+ Operand (SILInstruction *owner)
1052+ : Owner(owner), customBits(0 ), lastInitializedBitfieldID(0 ) {}
10521053 Operand (SILInstruction *owner, SILValue theValue)
1053- : TheValueAndThreeBits(theValue), Owner(owner) {
1054+ : TheValue(theValue), Owner(owner),
1055+ customBits (0 ), lastInitializedBitfieldID(0 ) {
10541056 insertIntoCurrent ();
10551057 }
10561058
@@ -1062,14 +1064,14 @@ class Operand {
10621064 Operand &operator =(Operand &&) = default ;
10631065
10641066 // / Return the current value being used by this operand.
1065- SILValue get () const { return TheValueAndThreeBits. getPointer () ; }
1067+ SILValue get () const { return TheValue ; }
10661068
10671069 // / Set the current value being used by this operand.
10681070 void set (SILValue newValue) {
10691071 // It's probably not worth optimizing for the case of switching
10701072 // operands on a single value.
10711073 removeFromCurrent ();
1072- TheValueAndThreeBits. setPointer ( newValue) ;
1074+ TheValue = newValue;
10731075 insertIntoCurrent ();
10741076 }
10751077
@@ -1083,9 +1085,9 @@ class Operand {
10831085 // / Remove this use of the operand.
10841086 void drop () {
10851087 removeFromCurrent ();
1086- TheValueAndThreeBits = { SILValue (), 0 } ;
1087- NextUseAndThreeBits = { nullptr , 0 } ;
1088- BackAndThreeBits = { nullptr , 0 } ;
1088+ TheValue = SILValue ();
1089+ NextUse = nullptr ;
1090+ Back = nullptr ;
10891091 Owner = nullptr ;
10901092 }
10911093
@@ -1097,7 +1099,7 @@ class Operand {
10971099 SILInstruction *getUser () { return Owner; }
10981100 const SILInstruction *getUser () const { return Owner; }
10991101
1100- Operand *getNextUse () const { return NextUseAndThreeBits. getPointer () ; }
1102+ Operand *getNextUse () const { return NextUse ; }
11011103
11021104 // / Return true if this operand is a type dependent operand.
11031105 // /
@@ -1147,63 +1149,36 @@ class Operand {
11471149 SILBasicBlock *getParentBlock () const ;
11481150 SILFunction *getParentFunction () const ;
11491151
1150- unsigned getCustomBits () const {
1151- unsigned bits = 0 ;
1152- bits |= TheValueAndThreeBits.getInt ();
1153- bits |= NextUseAndThreeBits.getInt () << 3 ;
1154- bits |= BackAndThreeBits.getInt () << 2 ;
1155- return bits;
1156- }
1157-
1158- void setCustomBits (unsigned bits) {
1159- assert (bits < 256 && " Can only store a byte?!" );
1160- TheValueAndThreeBits.setInt (bits & 0x7 );
1161- NextUseAndThreeBits.setInt ((bits >> 3 ) & 0x7 );
1162- BackAndThreeBits.setInt ((bits >> 6 ) & 0x3 );
1163- }
1152+ unsigned getCustomBits () const { return customBits; }
1153+ void setCustomBits (unsigned bits) {customBits = bits; }
11641154
11651155 // Called when transferring basic blocks from one function to another.
11661156 void resetBitfields () {
11671157 lastInitializedBitfieldID = 0 ;
11681158 }
11691159
1170- void markAsDeleted () {
1171- lastInitializedBitfieldID = -1 ;
1172- }
1173-
1174- bool isMarkedAsDeleted () const { return lastInitializedBitfieldID < 0 ; }
1175-
11761160 SILFunction *getFunction () const ;
11771161
11781162 void print (llvm::raw_ostream &os) const ;
11791163 SWIFT_DEBUG_DUMP;
11801164
11811165private:
11821166 void removeFromCurrent () {
1183- auto *back = getBack ();
1184- if (!back)
1185- return ;
1186- auto *nextUse = getNextUse ();
1187- *back = nextUse;
1188- if (nextUse)
1189- nextUse->setBack (back);
1167+ if (!Back)
1168+ return ;
1169+ *Back = NextUse;
1170+ if (NextUse)
1171+ NextUse->Back = Back;
11901172 }
11911173
11921174 void insertIntoCurrent () {
1193- auto **firstUse = &get ()->FirstUse ;
1194- setBack (firstUse);
1195- setNextUse (*firstUse);
1196- if (auto *nextUse = getNextUse ())
1197- nextUse->setBack (NextUseAndThreeBits.getAddrOfPointer ());
1198- get ()->FirstUse = this ;
1175+ Back = &TheValue->FirstUse ;
1176+ NextUse = TheValue->FirstUse ;
1177+ if (NextUse)
1178+ NextUse->Back = &NextUse;
1179+ TheValue->FirstUse = this ;
11991180 }
12001181
1201- void setNextUse (Operand *op) { NextUseAndThreeBits.setPointer (op); }
1202-
1203- Operand **getBack () const { return BackAndThreeBits.getPointer (); }
1204-
1205- void setBack (Operand **newValue) { BackAndThreeBits.setPointer (newValue); }
1206-
12071182 friend class ValueBase ;
12081183 friend class ValueBaseUseIterator ;
12091184 friend class ConsumingUseIterator ;
0 commit comments