mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	Add SelectionDAG::getTargetIndex.
This adds support for TargetIndex operands during isel. The meaning of these (index, offset, flags) operands is entirely defined by the target. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161453 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -126,6 +126,11 @@ namespace ISD { | |||||||
|     TargetExternalSymbol, |     TargetExternalSymbol, | ||||||
|     TargetBlockAddress, |     TargetBlockAddress, | ||||||
|  |  | ||||||
|  |     /// TargetIndex - Like a constant pool entry, but with completely | ||||||
|  |     /// target-dependent semantics. Holds target flags, a 32-bit index, and a | ||||||
|  |     /// 64-bit index. Targets can use this however they like. | ||||||
|  |     TargetIndex, | ||||||
|  |  | ||||||
|     /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) |     /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) | ||||||
|     /// This node represents a target intrinsic function with no side effects. |     /// This node represents a target intrinsic function with no side effects. | ||||||
|     /// The first operand is the ID number of the intrinsic from the |     /// The first operand is the ID number of the intrinsic from the | ||||||
|   | |||||||
| @@ -422,6 +422,8 @@ public: | |||||||
|                                   int Offset = 0, unsigned char TargetFlags=0) { |                                   int Offset = 0, unsigned char TargetFlags=0) { | ||||||
|     return getConstantPool(C, VT, Align, Offset, true, TargetFlags); |     return getConstantPool(C, VT, Align, Offset, true, TargetFlags); | ||||||
|   } |   } | ||||||
|  |   SDValue getTargetIndex(int Index, EVT VT, int64_t Offset = 0, | ||||||
|  |                          unsigned char TargetFlags = 0); | ||||||
|   // When generating a branch to a BB, we don't in general know enough |   // When generating a branch to a BB, we don't in general know enough | ||||||
|   // to provide debug info for the BB at that time, so keep this one around. |   // to provide debug info for the BB at that time, so keep this one around. | ||||||
|   SDValue getBasicBlock(MachineBasicBlock *MBB); |   SDValue getBasicBlock(MachineBasicBlock *MBB); | ||||||
|   | |||||||
| @@ -1343,6 +1343,29 @@ public: | |||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | /// Completely target-dependent object reference. | ||||||
|  | class TargetIndexSDNode : public SDNode { | ||||||
|  |   unsigned char TargetFlags; | ||||||
|  |   int Index; | ||||||
|  |   int64_t Offset; | ||||||
|  |   friend class SelectionDAG; | ||||||
|  | public: | ||||||
|  |  | ||||||
|  |   TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF) | ||||||
|  |     : SDNode(ISD::TargetIndex, DebugLoc(), getSDVTList(VT)), | ||||||
|  |       TargetFlags(TF), Index(Idx), Offset(Ofs) {} | ||||||
|  | public: | ||||||
|  |  | ||||||
|  |   unsigned char getTargetFlags() const { return TargetFlags; } | ||||||
|  |   int getIndex() const { return Index; } | ||||||
|  |   int64_t getOffset() const { return Offset; } | ||||||
|  |  | ||||||
|  |   static bool classof(const TargetIndexSDNode*) { return true; } | ||||||
|  |   static bool classof(const SDNode *N) { | ||||||
|  |     return N->getOpcode() == ISD::TargetIndex; | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  |  | ||||||
| class BasicBlockSDNode : public SDNode { | class BasicBlockSDNode : public SDNode { | ||||||
|   MachineBasicBlock *MBB; |   MachineBasicBlock *MBB; | ||||||
|   friend class SelectionDAG; |   friend class SelectionDAG; | ||||||
|   | |||||||
| @@ -411,6 +411,10 @@ void InstrEmitter::AddOperand(MachineInstr *MI, SDValue Op, | |||||||
|   } else if (BlockAddressSDNode *BA = dyn_cast<BlockAddressSDNode>(Op)) { |   } else if (BlockAddressSDNode *BA = dyn_cast<BlockAddressSDNode>(Op)) { | ||||||
|     MI->addOperand(MachineOperand::CreateBA(BA->getBlockAddress(), |     MI->addOperand(MachineOperand::CreateBA(BA->getBlockAddress(), | ||||||
|                                             BA->getTargetFlags())); |                                             BA->getTargetFlags())); | ||||||
|  |   } else if (TargetIndexSDNode *TI = dyn_cast<TargetIndexSDNode>(Op)) { | ||||||
|  |     MI->addOperand(MachineOperand::CreateTargetIndex(TI->getIndex(), | ||||||
|  |                                                      TI->getOffset(), | ||||||
|  |                                                      TI->getTargetFlags())); | ||||||
|   } else { |   } else { | ||||||
|     assert(Op.getValueType() != MVT::Other && |     assert(Op.getValueType() != MVT::Other && | ||||||
|            Op.getValueType() != MVT::Glue && |            Op.getValueType() != MVT::Glue && | ||||||
|   | |||||||
| @@ -61,6 +61,7 @@ namespace llvm { | |||||||
|       if (isa<BasicBlockSDNode>(Node))     return true; |       if (isa<BasicBlockSDNode>(Node))     return true; | ||||||
|       if (isa<FrameIndexSDNode>(Node))     return true; |       if (isa<FrameIndexSDNode>(Node))     return true; | ||||||
|       if (isa<ConstantPoolSDNode>(Node))   return true; |       if (isa<ConstantPoolSDNode>(Node))   return true; | ||||||
|  |       if (isa<TargetIndexSDNode>(Node))    return true; | ||||||
|       if (isa<JumpTableSDNode>(Node))      return true; |       if (isa<JumpTableSDNode>(Node))      return true; | ||||||
|       if (isa<ExternalSymbolSDNode>(Node)) return true; |       if (isa<ExternalSymbolSDNode>(Node)) return true; | ||||||
|       if (isa<BlockAddressSDNode>(Node))   return true; |       if (isa<BlockAddressSDNode>(Node))   return true; | ||||||
|   | |||||||
| @@ -439,6 +439,13 @@ static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) { | |||||||
|     ID.AddInteger(CP->getTargetFlags()); |     ID.AddInteger(CP->getTargetFlags()); | ||||||
|     break; |     break; | ||||||
|   } |   } | ||||||
|  |   case ISD::TargetIndex: { | ||||||
|  |     const TargetIndexSDNode *TI = cast<TargetIndexSDNode>(N); | ||||||
|  |     ID.AddInteger(TI->getIndex()); | ||||||
|  |     ID.AddInteger(TI->getOffset()); | ||||||
|  |     ID.AddInteger(TI->getTargetFlags()); | ||||||
|  |     break; | ||||||
|  |   } | ||||||
|   case ISD::LOAD: { |   case ISD::LOAD: { | ||||||
|     const LoadSDNode *LD = cast<LoadSDNode>(N); |     const LoadSDNode *LD = cast<LoadSDNode>(N); | ||||||
|     ID.AddInteger(LD->getMemoryVT().getRawBits()); |     ID.AddInteger(LD->getMemoryVT().getRawBits()); | ||||||
| @@ -1213,6 +1220,24 @@ SDValue SelectionDAG::getConstantPool(MachineConstantPoolValue *C, EVT VT, | |||||||
|   return SDValue(N, 0); |   return SDValue(N, 0); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | SDValue SelectionDAG::getTargetIndex(int Index, EVT VT, int64_t Offset, | ||||||
|  |                                      unsigned char TargetFlags) { | ||||||
|  |   FoldingSetNodeID ID; | ||||||
|  |   AddNodeIDNode(ID, ISD::TargetIndex, getVTList(VT), 0, 0); | ||||||
|  |   ID.AddInteger(Index); | ||||||
|  |   ID.AddInteger(Offset); | ||||||
|  |   ID.AddInteger(TargetFlags); | ||||||
|  |   void *IP = 0; | ||||||
|  |   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) | ||||||
|  |     return SDValue(E, 0); | ||||||
|  |  | ||||||
|  |   SDNode *N = new (NodeAllocator) TargetIndexSDNode(Index, VT, Offset, | ||||||
|  |                                                     TargetFlags); | ||||||
|  |   CSEMap.InsertNode(N, IP); | ||||||
|  |   AllNodes.push_back(N); | ||||||
|  |   return SDValue(N, 0); | ||||||
|  | } | ||||||
|  |  | ||||||
| SDValue SelectionDAG::getBasicBlock(MachineBasicBlock *MBB) { | SDValue SelectionDAG::getBasicBlock(MachineBasicBlock *MBB) { | ||||||
|   FoldingSetNodeID ID; |   FoldingSetNodeID ID; | ||||||
|   AddNodeIDNode(ID, ISD::BasicBlock, getVTList(MVT::Other), 0, 0); |   AddNodeIDNode(ID, ISD::BasicBlock, getVTList(MVT::Other), 0, 0); | ||||||
|   | |||||||
| @@ -100,6 +100,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const { | |||||||
|   case ISD::EH_SJLJ_SETJMP:             return "EH_SJLJ_SETJMP"; |   case ISD::EH_SJLJ_SETJMP:             return "EH_SJLJ_SETJMP"; | ||||||
|   case ISD::EH_SJLJ_LONGJMP:            return "EH_SJLJ_LONGJMP"; |   case ISD::EH_SJLJ_LONGJMP:            return "EH_SJLJ_LONGJMP"; | ||||||
|   case ISD::ConstantPool:               return "ConstantPool"; |   case ISD::ConstantPool:               return "ConstantPool"; | ||||||
|  |   case ISD::TargetIndex:                return "TargetIndex"; | ||||||
|   case ISD::ExternalSymbol:             return "ExternalSymbol"; |   case ISD::ExternalSymbol:             return "ExternalSymbol"; | ||||||
|   case ISD::BlockAddress:               return "BlockAddress"; |   case ISD::BlockAddress:               return "BlockAddress"; | ||||||
|   case ISD::INTRINSIC_WO_CHAIN: |   case ISD::INTRINSIC_WO_CHAIN: | ||||||
| @@ -409,6 +410,10 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const { | |||||||
|       OS << " " << offset; |       OS << " " << offset; | ||||||
|     if (unsigned int TF = CP->getTargetFlags()) |     if (unsigned int TF = CP->getTargetFlags()) | ||||||
|       OS << " [TF=" << TF << ']'; |       OS << " [TF=" << TF << ']'; | ||||||
|  |   } else if (const TargetIndexSDNode *TI = dyn_cast<TargetIndexSDNode>(this)) { | ||||||
|  |     OS << "<" << TI->getIndex() << '+' << TI->getOffset() << ">"; | ||||||
|  |     if (unsigned TF = TI->getTargetFlags()) | ||||||
|  |       OS << " [TF=" << TF << ']'; | ||||||
|   } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(this)) { |   } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(this)) { | ||||||
|     OS << "<"; |     OS << "<"; | ||||||
|     const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock(); |     const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user