mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-13 23:25:06 +00:00
Add addrspacecast instruction.
Patch by Michele Scandale! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1507,6 +1507,26 @@ SDValue SelectionDAG::getMDNode(const MDNode *MD) {
|
||||
return SDValue(N, 0);
|
||||
}
|
||||
|
||||
/// getAddrSpaceCast - Return an AddrSpaceCastSDNode.
|
||||
SDValue SelectionDAG::getAddrSpaceCast(SDLoc dl, EVT VT, SDValue Ptr,
|
||||
unsigned SrcAS, unsigned DestAS) {
|
||||
SDValue Ops[] = {Ptr};
|
||||
FoldingSetNodeID ID;
|
||||
AddNodeIDNode(ID, ISD::ADDRSPACECAST, getVTList(VT), &Ops[0], 1);
|
||||
ID.AddInteger(SrcAS);
|
||||
ID.AddInteger(DestAS);
|
||||
|
||||
void *IP = 0;
|
||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||
return SDValue(E, 0);
|
||||
|
||||
SDNode *N = new (NodeAllocator) AddrSpaceCastSDNode(dl.getIROrder(),
|
||||
dl.getDebugLoc(),
|
||||
VT, Ptr, SrcAS, DestAS);
|
||||
CSEMap.InsertNode(N, IP);
|
||||
AllNodes.push_back(N);
|
||||
return SDValue(N, 0);
|
||||
}
|
||||
|
||||
/// getShiftAmountOperand - Return the specified value casted to
|
||||
/// the target's desired shift amount type.
|
||||
@@ -5978,6 +5998,12 @@ GlobalAddressSDNode::GlobalAddressSDNode(unsigned Opc, unsigned Order,
|
||||
TheGlobal = GA;
|
||||
}
|
||||
|
||||
AddrSpaceCastSDNode::AddrSpaceCastSDNode(unsigned Order, DebugLoc dl, EVT VT,
|
||||
SDValue X, unsigned SrcAS,
|
||||
unsigned DestAS)
|
||||
: UnarySDNode(ISD::ADDRSPACECAST, Order, dl, getSDVTList(VT), X),
|
||||
SrcAddrSpace(SrcAS), DestAddrSpace(DestAS) {}
|
||||
|
||||
MemSDNode::MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
|
||||
EVT memvt, MachineMemOperand *mmo)
|
||||
: SDNode(Opc, Order, dl, VTs), MemoryVT(memvt), MMO(mmo) {
|
||||
|
@@ -2938,6 +2938,21 @@ void SelectionDAGBuilder::visitBitCast(const User &I) {
|
||||
setValue(&I, N); // noop cast.
|
||||
}
|
||||
|
||||
void SelectionDAGBuilder::visitAddrSpaceCast(const User &I) {
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
const Value *SV = I.getOperand(0);
|
||||
SDValue N = getValue(SV);
|
||||
EVT DestVT = TM.getTargetLowering()->getValueType(I.getType());
|
||||
|
||||
unsigned SrcAS = SV->getType()->getPointerAddressSpace();
|
||||
unsigned DestAS = I.getType()->getPointerAddressSpace();
|
||||
|
||||
if (!TLI.isNoopAddrSpaceCast(SrcAS, DestAS))
|
||||
N = DAG.getAddrSpaceCast(getCurSDLoc(), DestVT, N, SrcAS, DestAS);
|
||||
|
||||
setValue(&I, N);
|
||||
}
|
||||
|
||||
void SelectionDAGBuilder::visitInsertElement(const User &I) {
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
SDValue InVec = getValue(I.getOperand(0));
|
||||
|
@@ -26,6 +26,7 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class AddrSpaceCastInst;
|
||||
class AliasAnalysis;
|
||||
class AllocaInst;
|
||||
class BasicBlock;
|
||||
@@ -720,6 +721,7 @@ private:
|
||||
void visitPtrToInt(const User &I);
|
||||
void visitIntToPtr(const User &I);
|
||||
void visitBitCast(const User &I);
|
||||
void visitAddrSpaceCast(const User &I);
|
||||
|
||||
void visitExtractElement(const User &I);
|
||||
void visitInsertElement(const User &I);
|
||||
|
@@ -224,6 +224,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
|
||||
case ISD::FP_TO_SINT: return "fp_to_sint";
|
||||
case ISD::FP_TO_UINT: return "fp_to_uint";
|
||||
case ISD::BITCAST: return "bitcast";
|
||||
case ISD::ADDRSPACECAST: return "addrspacecast";
|
||||
case ISD::FP16_TO_FP32: return "fp16_to_fp32";
|
||||
case ISD::FP32_TO_FP16: return "fp32_to_fp16";
|
||||
|
||||
@@ -485,6 +486,13 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
|
||||
OS << " " << offset;
|
||||
if (unsigned int TF = BA->getTargetFlags())
|
||||
OS << " [TF=" << TF << ']';
|
||||
} else if (const AddrSpaceCastSDNode *ASC =
|
||||
dyn_cast<AddrSpaceCastSDNode>(this)) {
|
||||
OS << '['
|
||||
<< ASC->getSrcAddressSpace()
|
||||
<< " -> "
|
||||
<< ASC->getDestAddressSpace()
|
||||
<< ']';
|
||||
}
|
||||
|
||||
if (unsigned Order = getIROrder())
|
||||
|
@@ -1288,6 +1288,7 @@ int TargetLoweringBase::InstructionOpcodeToISD(unsigned Opcode) const {
|
||||
case PtrToInt: return ISD::BITCAST;
|
||||
case IntToPtr: return ISD::BITCAST;
|
||||
case BitCast: return ISD::BITCAST;
|
||||
case AddrSpaceCast: return ISD::ADDRSPACECAST;
|
||||
case ICmp: return ISD::SETCC;
|
||||
case FCmp: return ISD::SETCC;
|
||||
case PHI: return 0;
|
||||
|
Reference in New Issue
Block a user