forked from OSchip/llvm-project
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. llvm-svn: 55058
This commit is contained in:
parent
3ad7e96f8a
commit
2da2bedc72
|
@ -19,6 +19,7 @@
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class Value;
|
class Value;
|
||||||
|
class FoldingSetNodeID;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// MachineMemOperand - A description of a memory reference used in the backend.
|
/// MachineMemOperand - A description of a memory reference used in the backend.
|
||||||
|
@ -74,6 +75,10 @@ public:
|
||||||
bool isLoad() const { return Flags & MOLoad; }
|
bool isLoad() const { return Flags & MOLoad; }
|
||||||
bool isStore() const { return Flags & MOStore; }
|
bool isStore() const { return Flags & MOStore; }
|
||||||
bool isVolatile() const { return Flags & MOVolatile; }
|
bool isVolatile() const { return Flags & MOVolatile; }
|
||||||
|
|
||||||
|
/// Profile - Gather unique data for the object.
|
||||||
|
///
|
||||||
|
void Profile(FoldingSetNodeID &ID) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
|
@ -1266,7 +1266,7 @@ public:
|
||||||
|
|
||||||
/// Profile - Gather unique data for the node.
|
/// Profile - Gather unique data for the node.
|
||||||
///
|
///
|
||||||
void Profile(FoldingSetNodeID &ID);
|
void Profile(FoldingSetNodeID &ID) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class SelectionDAG;
|
friend class SelectionDAG;
|
||||||
|
@ -1499,6 +1499,10 @@ public:
|
||||||
return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
|
return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getRawFlags - Represent the flags as a bunch of bits.
|
||||||
|
///
|
||||||
|
unsigned getRawFlags() const { return Flags; }
|
||||||
|
|
||||||
// Methods to support isa and dyn_cast
|
// Methods to support isa and dyn_cast
|
||||||
static bool classof(const MemSDNode *) { return true; }
|
static bool classof(const MemSDNode *) { return true; }
|
||||||
static bool classof(const SDNode *N) {
|
static bool classof(const SDNode *N) {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "llvm/Support/LeakDetector.h"
|
#include "llvm/Support/LeakDetector.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
|
#include "llvm/ADT/FoldingSet.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
@ -250,6 +251,15 @@ MachineMemOperand::MachineMemOperand(const Value *v, unsigned int f,
|
||||||
assert((isLoad() || isStore()) && "Not a load/store!");
|
assert((isLoad() || isStore()) && "Not a load/store!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Profile - Gather unique data for the object.
|
||||||
|
///
|
||||||
|
void MachineMemOperand::Profile(FoldingSetNodeID &ID) const {
|
||||||
|
ID.AddInteger(Offset);
|
||||||
|
ID.AddInteger(Size);
|
||||||
|
ID.AddPointer(V);
|
||||||
|
ID.AddInteger(Flags);
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// MachineInstr Implementation
|
// MachineInstr Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
|
@ -351,7 +351,7 @@ static void AddNodeIDNode(FoldingSetNodeID &ID,
|
||||||
|
|
||||||
/// AddNodeIDNode - Generic routine for adding a nodes info to the NodeID
|
/// AddNodeIDNode - Generic routine for adding a nodes info to the NodeID
|
||||||
/// data.
|
/// data.
|
||||||
static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
|
static void AddNodeIDNode(FoldingSetNodeID &ID, const SDNode *N) {
|
||||||
AddNodeIDOpcode(ID, N->getOpcode());
|
AddNodeIDOpcode(ID, N->getOpcode());
|
||||||
// Add the return value info.
|
// Add the return value info.
|
||||||
AddNodeIDValueTypes(ID, N->getVTList());
|
AddNodeIDValueTypes(ID, N->getVTList());
|
||||||
|
@ -377,7 +377,7 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
|
||||||
case ISD::GlobalAddress:
|
case ISD::GlobalAddress:
|
||||||
case ISD::TargetGlobalTLSAddress:
|
case ISD::TargetGlobalTLSAddress:
|
||||||
case ISD::GlobalTLSAddress: {
|
case ISD::GlobalTLSAddress: {
|
||||||
GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(N);
|
const GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(N);
|
||||||
ID.AddPointer(GA->getGlobal());
|
ID.AddPointer(GA->getGlobal());
|
||||||
ID.AddInteger(GA->getOffset());
|
ID.AddInteger(GA->getOffset());
|
||||||
break;
|
break;
|
||||||
|
@ -400,11 +400,7 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
|
||||||
break;
|
break;
|
||||||
case ISD::MEMOPERAND: {
|
case ISD::MEMOPERAND: {
|
||||||
const MachineMemOperand &MO = cast<MemOperandSDNode>(N)->MO;
|
const MachineMemOperand &MO = cast<MemOperandSDNode>(N)->MO;
|
||||||
ID.AddPointer(MO.getValue());
|
MO.Profile(ID);
|
||||||
ID.AddInteger(MO.getFlags());
|
|
||||||
ID.AddInteger(MO.getOffset());
|
|
||||||
ID.AddInteger(MO.getSize());
|
|
||||||
ID.AddInteger(MO.getAlignment());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISD::FrameIndex:
|
case ISD::FrameIndex:
|
||||||
|
@ -417,7 +413,7 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
|
||||||
break;
|
break;
|
||||||
case ISD::ConstantPool:
|
case ISD::ConstantPool:
|
||||||
case ISD::TargetConstantPool: {
|
case ISD::TargetConstantPool: {
|
||||||
ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(N);
|
const ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(N);
|
||||||
ID.AddInteger(CP->getAlignment());
|
ID.AddInteger(CP->getAlignment());
|
||||||
ID.AddInteger(CP->getOffset());
|
ID.AddInteger(CP->getOffset());
|
||||||
if (CP->isMachineConstantPoolEntry())
|
if (CP->isMachineConstantPoolEntry())
|
||||||
|
@ -427,21 +423,19 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISD::LOAD: {
|
case ISD::LOAD: {
|
||||||
LoadSDNode *LD = cast<LoadSDNode>(N);
|
const LoadSDNode *LD = cast<LoadSDNode>(N);
|
||||||
ID.AddInteger(LD->getAddressingMode());
|
ID.AddInteger(LD->getAddressingMode());
|
||||||
ID.AddInteger(LD->getExtensionType());
|
ID.AddInteger(LD->getExtensionType());
|
||||||
ID.AddInteger(LD->getMemoryVT().getRawBits());
|
ID.AddInteger(LD->getMemoryVT().getRawBits());
|
||||||
ID.AddInteger(LD->getAlignment());
|
ID.AddInteger(LD->getRawFlags());
|
||||||
ID.AddInteger(LD->isVolatile());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISD::STORE: {
|
case ISD::STORE: {
|
||||||
StoreSDNode *ST = cast<StoreSDNode>(N);
|
const StoreSDNode *ST = cast<StoreSDNode>(N);
|
||||||
ID.AddInteger(ST->getAddressingMode());
|
ID.AddInteger(ST->getAddressingMode());
|
||||||
ID.AddInteger(ST->isTruncatingStore());
|
ID.AddInteger(ST->isTruncatingStore());
|
||||||
ID.AddInteger(ST->getMemoryVT().getRawBits());
|
ID.AddInteger(ST->getMemoryVT().getRawBits());
|
||||||
ID.AddInteger(ST->getAlignment());
|
ID.AddInteger(ST->getRawFlags());
|
||||||
ID.AddInteger(ST->isVolatile());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISD::ATOMIC_CMP_SWAP:
|
case ISD::ATOMIC_CMP_SWAP:
|
||||||
|
@ -456,14 +450,20 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
|
||||||
case ISD::ATOMIC_LOAD_MAX:
|
case ISD::ATOMIC_LOAD_MAX:
|
||||||
case ISD::ATOMIC_LOAD_UMIN:
|
case ISD::ATOMIC_LOAD_UMIN:
|
||||||
case ISD::ATOMIC_LOAD_UMAX: {
|
case ISD::ATOMIC_LOAD_UMAX: {
|
||||||
AtomicSDNode *AT = cast<AtomicSDNode>(N);
|
const AtomicSDNode *AT = cast<AtomicSDNode>(N);
|
||||||
ID.AddInteger(AT->getAlignment());
|
ID.AddInteger(AT->getRawFlags());
|
||||||
ID.AddInteger(AT->isVolatile());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end switch (N->getOpcode())
|
} // end switch (N->getOpcode())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// encodeMemSDNodeFlags - Generic routine for computing a value for use in
|
||||||
|
/// the CSE map that carries both alignment and volatility information.
|
||||||
|
///
|
||||||
|
static unsigned encodeMemSDNodeFlags(bool isVolatile, unsigned Alignment) {
|
||||||
|
return isVolatile | ((Log2_32(Alignment) + 1) << 1);
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// SelectionDAG Class
|
// SelectionDAG Class
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -722,14 +722,12 @@ SDNode *SelectionDAG::FindModifiedNodeSlot(SDNode *N,
|
||||||
ID.AddInteger(LD->getAddressingMode());
|
ID.AddInteger(LD->getAddressingMode());
|
||||||
ID.AddInteger(LD->getExtensionType());
|
ID.AddInteger(LD->getExtensionType());
|
||||||
ID.AddInteger(LD->getMemoryVT().getRawBits());
|
ID.AddInteger(LD->getMemoryVT().getRawBits());
|
||||||
ID.AddInteger(LD->getAlignment());
|
ID.AddInteger(LD->getRawFlags());
|
||||||
ID.AddInteger(LD->isVolatile());
|
|
||||||
} else if (const StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
|
} else if (const StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
|
||||||
ID.AddInteger(ST->getAddressingMode());
|
ID.AddInteger(ST->getAddressingMode());
|
||||||
ID.AddInteger(ST->isTruncatingStore());
|
ID.AddInteger(ST->isTruncatingStore());
|
||||||
ID.AddInteger(ST->getMemoryVT().getRawBits());
|
ID.AddInteger(ST->getMemoryVT().getRawBits());
|
||||||
ID.AddInteger(ST->getAlignment());
|
ID.AddInteger(ST->getRawFlags());
|
||||||
ID.AddInteger(ST->isVolatile());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return CSEMap.FindNodeOrInsertPos(ID, InsertPos);
|
return CSEMap.FindNodeOrInsertPos(ID, InsertPos);
|
||||||
|
@ -1110,11 +1108,7 @@ SDValue SelectionDAG::getMemOperand(const MachineMemOperand &MO) {
|
||||||
|
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
AddNodeIDNode(ID, ISD::MEMOPERAND, getVTList(MVT::Other), 0, 0);
|
AddNodeIDNode(ID, ISD::MEMOPERAND, getVTList(MVT::Other), 0, 0);
|
||||||
ID.AddPointer(v);
|
MO.Profile(ID);
|
||||||
ID.AddInteger(MO.getFlags());
|
|
||||||
ID.AddInteger(MO.getOffset());
|
|
||||||
ID.AddInteger(MO.getSize());
|
|
||||||
ID.AddInteger(MO.getAlignment());
|
|
||||||
|
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||||
|
@ -3225,8 +3219,7 @@ SelectionDAG::getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
|
||||||
ID.AddInteger(AM);
|
ID.AddInteger(AM);
|
||||||
ID.AddInteger(ExtType);
|
ID.AddInteger(ExtType);
|
||||||
ID.AddInteger(EVT.getRawBits());
|
ID.AddInteger(EVT.getRawBits());
|
||||||
ID.AddInteger(Alignment);
|
ID.AddInteger(encodeMemSDNodeFlags(isVolatile, Alignment));
|
||||||
ID.AddInteger(isVolatile);
|
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||||
return SDValue(E, 0);
|
return SDValue(E, 0);
|
||||||
|
@ -3285,8 +3278,7 @@ SDValue SelectionDAG::getStore(SDValue Chain, SDValue Val,
|
||||||
ID.AddInteger(ISD::UNINDEXED);
|
ID.AddInteger(ISD::UNINDEXED);
|
||||||
ID.AddInteger(false);
|
ID.AddInteger(false);
|
||||||
ID.AddInteger(VT.getRawBits());
|
ID.AddInteger(VT.getRawBits());
|
||||||
ID.AddInteger(Alignment);
|
ID.AddInteger(encodeMemSDNodeFlags(isVolatile, Alignment));
|
||||||
ID.AddInteger(isVolatile);
|
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||||
return SDValue(E, 0);
|
return SDValue(E, 0);
|
||||||
|
@ -3322,8 +3314,7 @@ SDValue SelectionDAG::getTruncStore(SDValue Chain, SDValue Val,
|
||||||
ID.AddInteger(ISD::UNINDEXED);
|
ID.AddInteger(ISD::UNINDEXED);
|
||||||
ID.AddInteger(1);
|
ID.AddInteger(1);
|
||||||
ID.AddInteger(SVT.getRawBits());
|
ID.AddInteger(SVT.getRawBits());
|
||||||
ID.AddInteger(Alignment);
|
ID.AddInteger(encodeMemSDNodeFlags(isVolatile, Alignment));
|
||||||
ID.AddInteger(isVolatile);
|
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||||
return SDValue(E, 0);
|
return SDValue(E, 0);
|
||||||
|
@ -3348,8 +3339,7 @@ SelectionDAG::getIndexedStore(SDValue OrigStore, SDValue Base,
|
||||||
ID.AddInteger(AM);
|
ID.AddInteger(AM);
|
||||||
ID.AddInteger(ST->isTruncatingStore());
|
ID.AddInteger(ST->isTruncatingStore());
|
||||||
ID.AddInteger(ST->getMemoryVT().getRawBits());
|
ID.AddInteger(ST->getMemoryVT().getRawBits());
|
||||||
ID.AddInteger(ST->getAlignment());
|
ID.AddInteger(ST->getRawFlags());
|
||||||
ID.AddInteger(ST->isVolatile());
|
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||||
return SDValue(E, 0);
|
return SDValue(E, 0);
|
||||||
|
@ -4496,7 +4486,7 @@ MemSDNode::MemSDNode(unsigned Opc, SDVTList VTs, MVT memvt,
|
||||||
const Value *srcValue, int SVO,
|
const Value *srcValue, int SVO,
|
||||||
unsigned alignment, bool vol)
|
unsigned alignment, bool vol)
|
||||||
: SDNode(Opc, VTs), MemoryVT(memvt), SrcValue(srcValue), SVOffset(SVO),
|
: SDNode(Opc, VTs), MemoryVT(memvt), SrcValue(srcValue), SVOffset(SVO),
|
||||||
Flags(vol | ((Log2_32(alignment) + 1) << 1)) {
|
Flags(encodeMemSDNodeFlags(vol, alignment)) {
|
||||||
|
|
||||||
assert(isPowerOf2_32(alignment) && "Alignment is not a power of 2!");
|
assert(isPowerOf2_32(alignment) && "Alignment is not a power of 2!");
|
||||||
assert(getAlignment() == alignment && "Alignment representation error!");
|
assert(getAlignment() == alignment && "Alignment representation error!");
|
||||||
|
@ -4532,7 +4522,7 @@ MachineMemOperand MemSDNode::getMemOperand() const {
|
||||||
|
|
||||||
/// Profile - Gather unique data for the node.
|
/// Profile - Gather unique data for the node.
|
||||||
///
|
///
|
||||||
void SDNode::Profile(FoldingSetNodeID &ID) {
|
void SDNode::Profile(FoldingSetNodeID &ID) const {
|
||||||
AddNodeIDNode(ID, this);
|
AddNodeIDNode(ID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue