mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-26 09:18:56 +00:00
Added MemIntrinsicNode which is useful to represent target intrinsics that
touches memory and need an associated MemOperand git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57712 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -3334,6 +3334,46 @@ SDValue SelectionDAG::getMergeValues(const SDValue *Ops, unsigned NumOps,
|
||||
return getNode(ISD::MERGE_VALUES, getVTList(&VTs[0], NumOps), Ops, NumOps);
|
||||
}
|
||||
|
||||
SDValue
|
||||
SelectionDAG::getMemIntrinsicNode(unsigned Opcode,
|
||||
const MVT *VTs, unsigned NumVTs,
|
||||
const SDValue *Ops, unsigned NumOps,
|
||||
MVT MemVT, const Value *srcValue, int SVOff,
|
||||
unsigned Align, bool Vol,
|
||||
bool ReadMem, bool WriteMem) {
|
||||
return getMemIntrinsicNode(Opcode, makeVTList(VTs, NumVTs), Ops, NumOps,
|
||||
MemVT, srcValue, SVOff, Align, Vol,
|
||||
ReadMem, WriteMem);
|
||||
}
|
||||
|
||||
SDValue
|
||||
SelectionDAG::getMemIntrinsicNode(unsigned Opcode, SDVTList VTList,
|
||||
const SDValue *Ops, unsigned NumOps,
|
||||
MVT MemVT, const Value *srcValue, int SVOff,
|
||||
unsigned Align, bool Vol,
|
||||
bool ReadMem, bool WriteMem) {
|
||||
// Memoize the node unless it returns a flag.
|
||||
MemIntrinsicSDNode *N;
|
||||
if (VTList.VTs[VTList.NumVTs-1] != MVT::Flag) {
|
||||
FoldingSetNodeID ID;
|
||||
AddNodeIDNode(ID, Opcode, VTList, Ops, NumOps);
|
||||
void *IP = 0;
|
||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||
return SDValue(E, 0);
|
||||
|
||||
N = NodeAllocator.Allocate<MemIntrinsicSDNode>();
|
||||
new (N) MemIntrinsicSDNode(Opcode, VTList, Ops, NumOps, MemVT,
|
||||
srcValue, SVOff, Align, Vol, ReadMem, WriteMem);
|
||||
CSEMap.InsertNode(N, IP);
|
||||
} else {
|
||||
N = NodeAllocator.Allocate<MemIntrinsicSDNode>();
|
||||
new (N) MemIntrinsicSDNode(Opcode, VTList, Ops, NumOps, MemVT,
|
||||
srcValue, SVOff, Align, Vol, ReadMem, WriteMem);
|
||||
}
|
||||
AllNodes.push_back(N);
|
||||
return SDValue(N, 0);
|
||||
}
|
||||
|
||||
SDValue
|
||||
SelectionDAG::getCall(unsigned CallingConv, bool IsVarArgs, bool IsTailCall,
|
||||
bool IsInreg, SDVTList VTs,
|
||||
@@ -4678,6 +4718,7 @@ void MemSDNode::ANCHOR() {}
|
||||
void LoadSDNode::ANCHOR() {}
|
||||
void StoreSDNode::ANCHOR() {}
|
||||
void AtomicSDNode::ANCHOR() {}
|
||||
void MemIntrinsicSDNode::ANCHOR() {}
|
||||
void CallSDNode::ANCHOR() {}
|
||||
|
||||
HandleSDNode::~HandleSDNode() {
|
||||
@@ -4707,6 +4748,17 @@ MemSDNode::MemSDNode(unsigned Opc, SDVTList VTs, MVT memvt,
|
||||
assert(isVolatile() == vol && "Volatile representation error!");
|
||||
}
|
||||
|
||||
MemSDNode::MemSDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops,
|
||||
unsigned NumOps, MVT memvt, const Value *srcValue,
|
||||
int SVO, unsigned alignment, bool vol)
|
||||
: SDNode(Opc, VTs, Ops, NumOps),
|
||||
MemoryVT(memvt), SrcValue(srcValue), SVOffset(SVO),
|
||||
Flags(vol | ((Log2_32(alignment) + 1) << 1)) {
|
||||
assert(isPowerOf2_32(alignment) && "Alignment is not a power of 2!");
|
||||
assert(getAlignment() == alignment && "Alignment representation error!");
|
||||
assert(isVolatile() == vol && "Volatile representation error!");
|
||||
}
|
||||
|
||||
/// getMemOperand - Return a MachineMemOperand object describing the memory
|
||||
/// reference performed by this memory reference.
|
||||
MachineMemOperand MemSDNode::getMemOperand() const {
|
||||
@@ -4715,10 +4767,15 @@ MachineMemOperand MemSDNode::getMemOperand() const {
|
||||
Flags = MachineMemOperand::MOLoad;
|
||||
else if (isa<StoreSDNode>(this))
|
||||
Flags = MachineMemOperand::MOStore;
|
||||
else {
|
||||
assert(isa<AtomicSDNode>(this) && "Unknown MemSDNode opcode!");
|
||||
else if (isa<AtomicSDNode>(this)) {
|
||||
Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
|
||||
}
|
||||
else {
|
||||
const MemIntrinsicSDNode* MemIntrinNode = dyn_cast<MemIntrinsicSDNode>(this);
|
||||
assert(MemIntrinNode && "Unknown MemSDNode opcode!");
|
||||
if (MemIntrinNode->readMem()) Flags |= MachineMemOperand::MOLoad;
|
||||
if (MemIntrinNode->writeMem()) Flags |= MachineMemOperand::MOStore;
|
||||
}
|
||||
|
||||
int Size = (getMemoryVT().getSizeInBits() + 7) >> 3;
|
||||
if (isVolatile()) Flags |= MachineMemOperand::MOVolatile;
|
||||
|
Reference in New Issue
Block a user