llvm.org GIT mirror llvm / b8d2f55
Change the FoldingSetNodeID usage for objects which carry alignment and volatility information, such as loads and stores, to reduce the number of integer values added to the FoldingSetNodeID. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55058 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 12 years ago
4 changed file(s) with 46 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
1818 namespace llvm {
1919
2020 class Value;
21 class FoldingSetNodeID;
2122
2223 //===----------------------------------------------------------------------===//
2324 /// MachineMemOperand - A description of a memory reference used in the backend.
7374 bool isLoad() const { return Flags & MOLoad; }
7475 bool isStore() const { return Flags & MOStore; }
7576 bool isVolatile() const { return Flags & MOVolatile; }
77
78 /// Profile - Gather unique data for the object.
79 ///
80 void Profile(FoldingSetNodeID &ID) const;
7681 };
7782
7883 } // End llvm namespace
12651265
12661266 /// Profile - Gather unique data for the node.
12671267 ///
1268 void Profile(FoldingSetNodeID &ID);
1268 void Profile(FoldingSetNodeID &ID) const;
12691269
12701270 protected:
12711271 friend class SelectionDAG;
14981498 return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
14991499 }
15001500
1501 /// getRawFlags - Represent the flags as a bunch of bits.
1502 ///
1503 unsigned getRawFlags() const { return Flags; }
1504
15011505 // Methods to support isa and dyn_cast
15021506 static bool classof(const MemSDNode *) { return true; }
15031507 static bool classof(const SDNode *N) {
2323 #include "llvm/Support/LeakDetector.h"
2424 #include "llvm/Support/MathExtras.h"
2525 #include "llvm/Support/Streams.h"
26 #include "llvm/ADT/FoldingSet.h"
2627 #include
2728 using namespace llvm;
2829
249250 assert((isLoad() || isStore()) && "Not a load/store!");
250251 }
251252
253 /// Profile - Gather unique data for the object.
254 ///
255 void MachineMemOperand::Profile(FoldingSetNodeID &ID) const {
256 ID.AddInteger(Offset);
257 ID.AddInteger(Size);
258 ID.AddPointer(V);
259 ID.AddInteger(Flags);
260 }
261
252262 //===----------------------------------------------------------------------===//
253263 // MachineInstr Implementation
254264 //===----------------------------------------------------------------------===//
350350
351351 /// AddNodeIDNode - Generic routine for adding a nodes info to the NodeID
352352 /// data.
353 static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
353 static void AddNodeIDNode(FoldingSetNodeID &ID, const SDNode *N) {
354354 AddNodeIDOpcode(ID, N->getOpcode());
355355 // Add the return value info.
356356 AddNodeIDValueTypes(ID, N->getVTList());
376376 case ISD::GlobalAddress:
377377 case ISD::TargetGlobalTLSAddress:
378378 case ISD::GlobalTLSAddress: {
379 GlobalAddressSDNode *GA = cast(N);
379 const GlobalAddressSDNode *GA = cast(N);
380380 ID.AddPointer(GA->getGlobal());
381381 ID.AddInteger(GA->getOffset());
382382 break;
399399 break;
400400 case ISD::MEMOPERAND: {
401401 const MachineMemOperand &MO = cast(N)->MO;
402 ID.AddPointer(MO.getValue());
403 ID.AddInteger(MO.getFlags());
404 ID.AddInteger(MO.getOffset());
405 ID.AddInteger(MO.getSize());
406 ID.AddInteger(MO.getAlignment());
402 MO.Profile(ID);
407403 break;
408404 }
409405 case ISD::FrameIndex:
416412 break;
417413 case ISD::ConstantPool:
418414 case ISD::TargetConstantPool: {
419 ConstantPoolSDNode *CP = cast(N);
415 const ConstantPoolSDNode *CP = cast(N);
420416 ID.AddInteger(CP->getAlignment());
421417 ID.AddInteger(CP->getOffset());
422418 if (CP->isMachineConstantPoolEntry())
426422 break;
427423 }
428424 case ISD::LOAD: {
429 LoadSDNode *LD = cast(N);
425 const LoadSDNode *LD = cast(N);
430426 ID.AddInteger(LD->getAddressingMode());
431427 ID.AddInteger(LD->getExtensionType());
432428 ID.AddInteger(LD->getMemoryVT().getRawBits());
433 ID.AddInteger(LD->getAlignment());
434 ID.AddInteger(LD->isVolatile());
429 ID.AddInteger(LD->getRawFlags());
435430 break;
436431 }
437432 case ISD::STORE: {
438 StoreSDNode *ST = cast(N);
433 const StoreSDNode *ST = cast(N);
439434 ID.AddInteger(ST->getAddressingMode());
440435 ID.AddInteger(ST->isTruncatingStore());
441436 ID.AddInteger(ST->getMemoryVT().getRawBits());
442 ID.AddInteger(ST->getAlignment());
443 ID.AddInteger(ST->isVolatile());
437 ID.AddInteger(ST->getRawFlags());
444438 break;
445439 }
446440 case ISD::ATOMIC_CMP_SWAP:
455449 case ISD::ATOMIC_LOAD_MAX:
456450 case ISD::ATOMIC_LOAD_UMIN:
457451 case ISD::ATOMIC_LOAD_UMAX: {
458 AtomicSDNode *AT = cast(N);
459 ID.AddInteger(AT->getAlignment());
460 ID.AddInteger(AT->isVolatile());
452 const AtomicSDNode *AT = cast(N);
453 ID.AddInteger(AT->getRawFlags());
461454 break;
462455 }
463456 } // end switch (N->getOpcode())
457 }
458
459 /// encodeMemSDNodeFlags - Generic routine for computing a value for use in
460 /// the CSE map that carries both alignment and volatility information.
461 ///
462 static unsigned encodeMemSDNodeFlags(bool isVolatile, unsigned Alignment) {
463 return isVolatile | ((Log2_32(Alignment) + 1) << 1);
464464 }
465465
466466 //===----------------------------------------------------------------------===//
721721 ID.AddInteger(LD->getAddressingMode());
722722 ID.AddInteger(LD->getExtensionType());
723723 ID.AddInteger(LD->getMemoryVT().getRawBits());
724 ID.AddInteger(LD->getAlignment());
725 ID.AddInteger(LD->isVolatile());
724 ID.AddInteger(LD->getRawFlags());
726725 } else if (const StoreSDNode *ST = dyn_cast(N)) {
727726 ID.AddInteger(ST->getAddressingMode());
728727 ID.AddInteger(ST->isTruncatingStore());
729728 ID.AddInteger(ST->getMemoryVT().getRawBits());
730 ID.AddInteger(ST->getAlignment());
731 ID.AddInteger(ST->isVolatile());
729 ID.AddInteger(ST->getRawFlags());
732730 }
733731
734732 return CSEMap.FindNodeOrInsertPos(ID, InsertPos);
11091107
11101108 FoldingSetNodeID ID;
11111109 AddNodeIDNode(ID, ISD::MEMOPERAND, getVTList(MVT::Other), 0, 0);
1112 ID.AddPointer(v);
1113 ID.AddInteger(MO.getFlags());
1114 ID.AddInteger(MO.getOffset());
1115 ID.AddInteger(MO.getSize());
1116 ID.AddInteger(MO.getAlignment());
1110 MO.Profile(ID);
11171111
11181112 void *IP = 0;
11191113 if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
32243218 ID.AddInteger(AM);
32253219 ID.AddInteger(ExtType);
32263220 ID.AddInteger(EVT.getRawBits());
3227 ID.AddInteger(Alignment);
3228 ID.AddInteger(isVolatile);
3221 ID.AddInteger(encodeMemSDNodeFlags(isVolatile, Alignment));
32293222 void *IP = 0;
32303223 if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
32313224 return SDValue(E, 0);
32843277 ID.AddInteger(ISD::UNINDEXED);
32853278 ID.AddInteger(false);
32863279 ID.AddInteger(VT.getRawBits());
3287 ID.AddInteger(Alignment);
3288 ID.AddInteger(isVolatile);
3280 ID.AddInteger(encodeMemSDNodeFlags(isVolatile, Alignment));
32893281 void *IP = 0;
32903282 if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
32913283 return SDValue(E, 0);
33213313 ID.AddInteger(ISD::UNINDEXED);
33223314 ID.AddInteger(1);
33233315 ID.AddInteger(SVT.getRawBits());
3324 ID.AddInteger(Alignment);
3325 ID.AddInteger(isVolatile);
3316 ID.AddInteger(encodeMemSDNodeFlags(isVolatile, Alignment));
33263317 void *IP = 0;
33273318 if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
33283319 return SDValue(E, 0);
33473338 ID.AddInteger(AM);
33483339 ID.AddInteger(ST->isTruncatingStore());
33493340 ID.AddInteger(ST->getMemoryVT().getRawBits());
3350 ID.AddInteger(ST->getAlignment());
3351 ID.AddInteger(ST->isVolatile());
3341 ID.AddInteger(ST->getRawFlags());
33523342 void *IP = 0;
33533343 if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
33543344 return SDValue(E, 0);
44954485 const Value *srcValue, int SVO,
44964486 unsigned alignment, bool vol)
44974487 : SDNode(Opc, VTs), MemoryVT(memvt), SrcValue(srcValue), SVOffset(SVO),
4498 Flags(vol | ((Log2_32(alignment) + 1) << 1)) {
4488 Flags(encodeMemSDNodeFlags(vol, alignment)) {
44994489
45004490 assert(isPowerOf2_32(alignment) && "Alignment is not a power of 2!");
45014491 assert(getAlignment() == alignment && "Alignment representation error!");
45314521
45324522 /// Profile - Gather unique data for the node.
45334523 ///
4534 void SDNode::Profile(FoldingSetNodeID &ID) {
4524 void SDNode::Profile(FoldingSetNodeID &ID) const {
45354525 AddNodeIDNode(ID, this);
45364526 }
45374527