llvm.org GIT mirror llvm / 056292f
Reverting r56249. On further investigation, this functionality isn't needed. Apologies for the thrashing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56251 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 11 years ago
25 changed file(s) with 153 addition(s) and 171 deletion(s). Raw diff Collapse all Expand all
277277 if (isa(Node)) return true;
278278 if (isa(Node)) return true;
279279 if (isa(Node)) return true;
280 if (isa<SymbolSDNode>(Node)) return true;
280 if (isa<ExternalSymbolSDNode>(Node)) return true;
281281 if (isa(Node)) return true;
282282 if (Node->getOpcode() == ISD::EntryToken) return true;
283283 return false;
281281 return getConstantPool(C, VT, Align, Offset, true);
282282 }
283283 SDValue getBasicBlock(MachineBasicBlock *MBB);
284 SDValue getSymbol(const char *Sym, MVT VT,
285 GlobalValue::LinkageTypes LT = GlobalValue::ExternalLinkage);
286 SDValue getTargetSymbol(const char *Sym, MVT VT,
287 GlobalValue::LinkageTypes LT =
288 GlobalValue::ExternalLinkage);
284 SDValue getExternalSymbol(const char *Sym, MVT VT);
285 SDValue getTargetExternalSymbol(const char *Sym, MVT VT);
289286 SDValue getArgFlags(ISD::ArgFlagsTy Flags);
290287 SDValue getValueType(MVT);
291288 SDValue getRegister(unsigned Reg, MVT VT);
760757
761758 std::vector ValueTypeNodes;
762759 std::map ExtendedValueTypeNodes;
763 StringMap Symbols;
764 StringMap TargetSymbols;
760 StringMap ExternalSymbols;
761 StringMap TargetExternalSymbols;
765762 };
766763
767764 template <> struct GraphTraits : public GraphTraits {
2020
2121 #include "llvm/Value.h"
2222 #include "llvm/Constants.h"
23 #include "llvm/GlobalValue.h"
2423 #include "llvm/ADT/FoldingSet.h"
2524 #include "llvm/ADT/GraphTraits.h"
2625 #include "llvm/ADT/iterator.h"
8988 BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register,
9089 Constant, ConstantFP,
9190 GlobalAddress, GlobalTLSAddress, FrameIndex,
92 JumpTable, ConstantPool, Symbol,
91 JumpTable, ConstantPool, ExternalSymbol,
9392
9493 // The address of the GOT
9594 GLOBAL_OFFSET_TABLE,
133132 TargetFrameIndex,
134133 TargetJumpTable,
135134 TargetConstantPool,
136 TargetSymbol,
135 TargetExternalSymbol,
137136
138137 /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
139138 /// This node represents a target intrinsic function with no side effects.
487486 // INLINEASM - Represents an inline asm block. This node always has two
488487 // return values: a chain and a flag result. The inputs are as follows:
489488 // Operand #0 : Input chain.
490 // Operand #1 : A SymbolSDNode with a pointer to the asm string.
489 // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string.
491490 // Operand #2n+2: A RegisterNode.
492491 // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
493492 // Operand #last: Optional, an incoming flag.
20452044 }
20462045 };
20472046
2048 class SymbolSDNode : public SDNode {
2047 class ExternalSymbolSDNode : public SDNode {
20492048 const char *Symbol;
2050 GlobalValue::LinkageTypes Linkage;
20512049 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
20522050 protected:
20532051 friend class SelectionDAG;
2054 SymbolSDNode(bool isTarget, const char *Sym, MVT VT,
2055 GlobalValue::LinkageTypes L)
2056 : SDNode(isTarget ? ISD::TargetSymbol : ISD::Symbol,
2057 getSDVTList(VT)), Symbol(Sym), Linkage(L) {}
2058 public:
2052 ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
2053 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
2054 getSDVTList(VT)), Symbol(Sym) {
2055 }
2056 public:
2057
20592058 const char *getSymbol() const { return Symbol; }
2060 GlobalValue::LinkageTypes getLinkage() const { return Linkage; }
2061
2062 static bool classof(const SymbolSDNode *) { return true; }
2059
2060 static bool classof(const ExternalSymbolSDNode *) { return true; }
20632061 static bool classof(const SDNode *N) {
2064 return N->getOpcode() == ISD::Symbol ||
2065 N->getOpcode() == ISD::TargetSymbol;
2062 return N->getOpcode() == ISD::ExternalSymbol ||
2063 N->getOpcode() == ISD::TargetExternalSymbol;
20662064 }
20672065 };
20682066
798798 case ISD::TargetConstantPool:
799799 case ISD::TargetGlobalAddress:
800800 case ISD::TargetGlobalTLSAddress:
801 case ISD::TargetSymbol:
801 case ISD::TargetExternalSymbol:
802802 case ISD::VALUETYPE:
803803 case ISD::SRCVALUE:
804804 case ISD::MEMOPERAND:
831831 case ISD::GLOBAL_OFFSET_TABLE:
832832 case ISD::GlobalAddress:
833833 case ISD::GlobalTLSAddress:
834 case ISD::Symbol:
834 case ISD::ExternalSymbol:
835835 case ISD::ConstantPool:
836836 case ISD::JumpTable: // Nothing to do.
837837 switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) {
39783978 std::pair CallResult =
39793979 TLI.LowerCallTo(Tmp1, Type::VoidTy,
39803980 false, false, false, CallingConv::C, false,
3981 DAG.getSymbol("abort", TLI.getPointerTy()),
3981 DAG.getExternalSymbol("abort", TLI.getPointerTy()),
39823982 Args, DAG);
39833983 Result = CallResult.second;
39843984 break;
52925292 Entry.isZExt = !isSigned;
52935293 Args.push_back(Entry);
52945294 }
5295
5296 SDValue Callee = DAG.getSymbol(TLI.getLibcallName(LC),
5297 TLI.getPointerTy());
5295 SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
5296 TLI.getPointerTy());
52985297
52995298 // Splice the libcall in wherever FindInputOutputChains tells us to.
53005299 const Type *RetTy = Node->getValueType(0).getTypeForMVT();
622622 Entry.isZExt = !isSigned;
623623 Args.push_back(Entry);
624624 }
625
626 SDValue Callee = DAG.getSymbol(TLI.getLibcallName(LC), TLI.getPointerTy());
625 SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
626 TLI.getPointerTy());
627627
628628 const Type *RetTy = RetVT.getTypeForMVT();
629629 std::pair CallInfo =
287287 else
288288 Idx = ConstPool->getConstantPoolIndex(CP->getConstVal(), Align);
289289 MI->addOperand(MachineOperand::CreateCPI(Idx, Offset));
290 } else if (SymbolSDNode *ES = dyn_cast<SymbolSDNode>(Op)) {
290 } else if (ExternalSymbolSDNode *ES = dyn_castSymbolSDNode>(Op)) {
291291 MI->addOperand(MachineOperand::CreateES(ES->getSymbol()));
292292 } else {
293293 assert(Op.getValueType() != MVT::Other &&
570570 MachineInstr *MI = BuildMI(*MF, TII->get(TargetInstrInfo::INLINEASM));
571571
572572 // Add the asm string as an external symbol operand.
573 const char *AsmStr = cast(Node->getOperand(1))->getSymbol();
573 const char *AsmStr =
574 cast(Node->getOperand(1))->getSymbol();
574575 MI->addOperand(MachineOperand::CreateES(AsmStr));
575576
576577 // Add all of the operand registers to the instruction.
613613 Erased = CondCodeNodes[cast(N)->get()] != 0;
614614 CondCodeNodes[cast(N)->get()] = 0;
615615 break;
616 case ISD::Symbol:
617 Erased = Symbols.erase(cast(N)->getSymbol());
618 break;
619 case ISD::TargetSymbol:
620 Erased = TargetSymbols.erase(cast(N)->getSymbol());
616 case ISD::ExternalSymbol:
617 Erased = ExternalSymbols.erase(cast(N)->getSymbol());
618 break;
619 case ISD::TargetExternalSymbol:
620 Erased =
621 TargetExternalSymbols.erase(cast(N)->getSymbol());
621622 break;
622623 case ISD::VALUETYPE: {
623624 MVT VT = cast(N)->getVT();
840841 CSEMap.clear();
841842
842843 ExtendedValueTypeNodes.clear();
843 Symbols.clear();
844 TargetSymbols.clear();
844 ExternalSymbols.clear();
845 TargetExternalSymbols.clear();
845846 std::fill(CondCodeNodes.begin(), CondCodeNodes.end(),
846847 static_cast(0));
847848 std::fill(ValueTypeNodes.begin(), ValueTypeNodes.end(),
10961097 return SDValue(N, 0);
10971098 }
10981099
1099 SDValue SelectionDAG::getSymbol(const char *Sym, MVT VT,
1100 GlobalValue::LinkageTypes LT) {
1101 SDNode *&N = Symbols[Sym];
1100 SDValue SelectionDAG::getExternalSymbol(const char *Sym, MVT VT) {
1101 SDNode *&N = ExternalSymbols[Sym];
11021102 if (N) return SDValue(N, 0);
1103 N = NodeAllocator.Allocate();
1104 new (N) SymbolSDNode(false, Sym, VT, LT);
1103 N = NodeAllocator.Allocate();
1104 new (N) ExternalSymbolSDNode(false, Sym, VT);
11051105 AllNodes.push_back(N);
11061106 return SDValue(N, 0);
11071107 }
11081108
1109 SDValue SelectionDAG::getTargetSymbol(const char *Sym, MVT VT,
1110 GlobalValue::LinkageTypes LT) {
1111 SDNode *&N = TargetSymbols[Sym];
1109 SDValue SelectionDAG::getTargetExternalSymbol(const char *Sym, MVT VT) {
1110 SDNode *&N = TargetExternalSymbols[Sym];
11121111 if (N) return SDValue(N, 0);
1113 N = NodeAllocator.Allocate();
1114 new (N) SymbolSDNode(true, Sym, VT, LT);
1112 N = NodeAllocator.Allocate();
1113 new (N) ExternalSymbolSDNode(true, Sym, VT);
11151114 AllNodes.push_back(N);
11161115 return SDValue(N, 0);
11171116 }
30983097 std::pair CallResult =
30993098 TLI.LowerCallTo(Chain, Type::VoidTy,
31003099 false, false, false, CallingConv::C, false,
3101 getSymbol("memcpy", TLI.getPointerTy()),
3100 getExternalSymbol("memcpy", TLI.getPointerTy()),
31023101 Args, *this);
31033102 return CallResult.second;
31043103 }
31433142 std::pair CallResult =
31443143 TLI.LowerCallTo(Chain, Type::VoidTy,
31453144 false, false, false, CallingConv::C, false,
3146 getSymbol("memmove", TLI.getPointerTy()),
3145 getExternalSymbol("memmove", TLI.getPointerTy()),
31473146 Args, *this);
31483147 return CallResult.second;
31493148 }
31943193 std::pair CallResult =
31953194 TLI.LowerCallTo(Chain, Type::VoidTy,
31963195 false, false, false, CallingConv::C, false,
3197 getSymbol("memset", TLI.getPointerTy()),
3196 getExternalSymbol("memset", TLI.getPointerTy()),
31983197 Args, *this);
31993198 return CallResult.second;
32003199 }
46104609 void RegisterSDNode::ANCHOR() {}
46114610 void DbgStopPointSDNode::ANCHOR() {}
46124611 void LabelSDNode::ANCHOR() {}
4613 void SymbolSDNode::ANCHOR() {}
4612 void ExternalSymbolSDNode::ANCHOR() {}
46144613 void CondCodeSDNode::ANCHOR() {}
46154614 void ARG_FLAGSSDNode::ANCHOR() {}
46164615 void VTSDNode::ANCHOR() {}
49144913 case ISD::FrameIndex: return "FrameIndex";
49154914 case ISD::JumpTable: return "JumpTable";
49164915 case ISD::GLOBAL_OFFSET_TABLE: return "GLOBAL_OFFSET_TABLE";
4917 case ISD::RETURNADDR: return "RETURNADDR";
4918 case ISD::FRAMEADDR: return "FRAMEADDR";
4916 case ISD::RETURNADDR: return "RETURNADDR";
4917 case ISD::FRAMEADDR: return "FRAMEADDR";
49194918 case ISD::FRAME_TO_ARGS_OFFSET: return "FRAME_TO_ARGS_OFFSET";
49204919 case ISD::EXCEPTIONADDR: return "EXCEPTIONADDR";
4921 case ISD::EHSELECTION: return "EHSELECTION";
4922 case ISD::EH_RETURN: return "EH_RETURN";
4920 case ISD::EHSELECTION: return "EHSELECTION";
4921 case ISD::EH_RETURN: return "EH_RETURN";
49234922 case ISD::ConstantPool: return "ConstantPool";
4924 case ISD::Symbol: return "Symbol";
4923 case ISD::ExternalSymbol: return "ExternalSymbol";
49254924 case ISD::INTRINSIC_WO_CHAIN: {
49264925 unsigned IID = cast(getOperand(0))->getZExtValue();
49274926 return Intrinsic::getName((Intrinsic::ID)IID);
49404939 case ISD::TargetFrameIndex: return "TargetFrameIndex";
49414940 case ISD::TargetJumpTable: return "TargetJumpTable";
49424941 case ISD::TargetConstantPool: return "TargetConstantPool";
4943 case ISD::TargetSymbol: return "TargetSymbol";
4942 case ISD::TargetExternalSymbol: return "TargetExternalSymbol";
49444943
49454944 case ISD::CopyToReg: return "CopyToReg";
49464945 case ISD::CopyFromReg: return "CopyFromReg";
52305229 } else {
52315230 OS << " #" << R->getReg();
52325231 }
5233 } else if (const SymbolSDNode *S =
5234 dyn_cast(this)) {
5235 OS << "'" << S->getSymbol() << "' ";
5236
5237 switch (S->getLinkage()) {
5238 default: assert(0 && "Invalid linkage type!"); break;
5239 case GlobalValue::ExternalLinkage: OS << "[external]"; break;
5240 case GlobalValue::LinkOnceLinkage: OS << "[once]"; break;
5241 case GlobalValue::WeakLinkage: OS << "[weak]"; break;
5242 case GlobalValue::AppendingLinkage: OS << "[appending]"; break;
5243 case GlobalValue::InternalLinkage: OS << "[internal]"; break;
5244 case GlobalValue::DLLImportLinkage: OS << "[dllimport]"; break;
5245 case GlobalValue::DLLExportLinkage: OS << "[dllexport]"; break;
5246 case GlobalValue::ExternalWeakLinkage: OS << "[externweak]"; break;
5247 case GlobalValue::GhostLinkage: OS << "[ghost]"; break;
5248 case GlobalValue::CommonLinkage: OS << "[common]"; break;
5249 }
5232 } else if (const ExternalSymbolSDNode *ES =
5233 dyn_cast(this)) {
5234 OS << "'" << ES->getSymbol() << "'";
52505235 } else if (const SrcValueSDNode *M = dyn_cast(this)) {
52515236 if (M->getValue())
52525237 OS << "<" << M->getValue() << ">";
42924292 if (!RenameFn)
42934293 Callee = getValue(I.getOperand(0));
42944294 else
4295 Callee = DAG.getSymbol(RenameFn, TLI.getPointerTy());
4295 Callee = DAG.getExternalSymbol(RenameFn, TLI.getPointerTy());
42964296
42974297 LowerCallTo(&I, Callee, I.isTailCall());
42984298 }
48874887 std::vector AsmNodeOperands;
48884888 AsmNodeOperands.push_back(SDValue()); // reserve space for input chain
48894889 AsmNodeOperands.push_back(
4890 DAG.getTargetSymbol(IA->getAsmString().c_str(), MVT::Other));
4890 DAG.getTargetExternalSymbol(IA->getAsmString().c_str(), MVT::Other));
48914891
48924892
48934893 // Loop over all of the inputs, copying the operand values into the
51385138
51395139 std::pair Result =
51405140 TLI.LowerCallTo(getRoot(), I.getType(), false, false, false, CallingConv::C,
5141 PerformTailCallOpt, DAG.getSymbol("malloc", IntPtr),
5141 PerformTailCallOpt, DAG.getExternalSymbol("malloc", IntPtr),
51425142 Args, DAG);
51435143 setValue(&I, Result.first); // Pointers always fit in registers
51445144 DAG.setRoot(Result.second);
51545154 std::pair Result =
51555155 TLI.LowerCallTo(getRoot(), Type::VoidTy, false, false, false,
51565156 CallingConv::C, PerformTailCallOpt,
5157 DAG.getSymbol("free", IntPtr), Args, DAG);
5157 DAG.getExternalSymbol("free", IntPtr), Args, DAG);
51585158 DAG.setRoot(Result.second);
51595159 }
51605160
185185 Op += ", isVarArg";
186186 if (C->isTailCall())
187187 Op += ", isTailCall";
188 } else if (const SymbolSDNode *S = dyn_cast(Node)) {
189 Op += "'" + std::string(S->getSymbol()) + "'";
188 } else if (const ExternalSymbolSDNode *ES =
189 dyn_cast(Node)) {
190 Op += "'" + std::string(ES->getSymbol()) + "'";
190191 } else if (const SrcValueSDNode *M = dyn_cast(Node)) {
191192 if (M->getValue())
192193 Op += "<" + M->getValue()->getName() + ">";
530530 InFlag = Chain.getValue(1);
531531 }
532532
533 // If the callee is a GlobalAddress/Symbol node (quite common, every direct
534 // call is) turn it into a TargetGlobalAddress/TargetSymbol node so that
535 // legalize doesn't hack it.
533 // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
534 // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
535 // node so that legalize doesn't hack it.
536536 bool isDirect = false;
537537 bool isARMFunc = false;
538538 bool isLocalARMFunc = false;
557557 Callee = DAG.getNode(ARMISD::PIC_ADD, getPointerTy(), Callee, PICLabel);
558558 } else
559559 Callee = DAG.getTargetGlobalAddress(GV, getPointerTy());
560 } else if (SymbolSDNode *S = dyn_cast<SymbolSDNode>(Callee)) {
560 } else if (ExternalSymbolSDNode *S = dyn_castSymbolSDNode>(Callee)) {
561561 isDirect = true;
562562 bool isStub = Subtarget->isTargetDarwin() &&
563563 getTargetMachine().getRelocationModel() != Reloc::Static;
573573 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
574574 Callee = DAG.getNode(ARMISD::PIC_ADD, getPointerTy(), Callee, PICLabel);
575575 } else
576 Callee = DAG.getTargetSymbol(Sym, getPointerTy(), S->getLinkage());
576 Callee = DAG.getTargetExternalSymbol(Sym, getPointerTy());
577577 }
578578
579579 // FIXME: handle tail calls differently.
714714 return DAG.getNode(ARMISD::RET_FLAG, MVT::Other, Copy, Copy.getValue(1));
715715 }
716716
717 // ConstantPool, JumpTable, GlobalAddress, and Symbol are lowered as their
718 // target countpart wrapped in the ARMISD::Wrapper node. Suppose N is one of the
719 // above mentioned nodes. It has to be wrapped because otherwise Select(N)
720 // returns N. So the raw TargetGlobalAddress nodes, etc. can only be used to
721 // form addressing mode. These wrapped nodes will be selected into MOVi.
717 // ConstantPool, JumpTable, GlobalAddress, and ExternalSymbol are lowered as
718 // their target countpart wrapped in the ARMISD::Wrapper node. Suppose N is
719 // one of the above mentioned nodes. It has to be wrapped because otherwise
720 // Select(N) returns N. So the raw TargetGlobalAddress nodes, etc. can only
721 // be used to form addressing mode. These wrapped nodes will be selected
722 // into MOVi.
722723 static SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) {
723724 MVT PtrVT = Op.getValueType();
724725 ConstantPoolSDNode *CP = cast(Op);
758759 std::pair CallResult =
759760 LowerCallTo(Chain, (const Type *) Type::Int32Ty, false, false, false,
760761 CallingConv::C, false,
761 DAG.getSymbol("__tls_get_addr", PtrVT), Args, DAG);
762 DAG.getExternalSymbol("__tls_get_addr", PtrVT), Args, DAG);
762763 return CallResult.first;
763764 }
764765
124124 setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
125125 setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Expand);
126126
127 // We want to legalize GlobalAddress and ConstantPool and Symbols nodes into
128 // the appropriate instructions to materialize the address.
127 // We want to legalize GlobalAddress and ConstantPool and
128 // ExternalSymbols nodes into the appropriate instructions to
129 // materialize the address.
129130 setOperationAction(ISD::GlobalAddress, MVT::i64, Custom);
130131 setOperationAction(ISD::ConstantPool, MVT::i64, Custom);
131 setOperationAction(ISD::Symbol, MVT::i64, Custom);
132 setOperationAction(ISD::ExternalSymbol, MVT::i64, Custom);
132133 setOperationAction(ISD::GlobalTLSAddress, MVT::i64, Custom);
133134
134135 setOperationAction(ISD::VASTART, MVT::Other, Custom);
489490 return DAG.getNode(AlphaISD::RelLit, MVT::i64, GA,
490491 DAG.getNode(ISD::GLOBAL_OFFSET_TABLE, MVT::i64));
491492 }
492 case ISD::Symbol: {
493 SymbolSDNode *S = cast(Op);
493 case ISD::ExternalSymbol: {
494494 return DAG.getNode(AlphaISD::RelLit, MVT::i64,
495 DAG.getTargetSymbol(S->getSymbol(), MVT::i64,
496 S->getLinkage()),
495 DAG.getTargetExternalSymbol(cast(Op)
496 ->getSymbol(), MVT::i64),
497497 DAG.getNode(ISD::GLOBAL_OFFSET_TABLE, MVT::i64));
498498 }
499
499500 case ISD::UREM:
500501 case ISD::SREM:
501502 //Expand only on constant case
524525 }
525526 SDValue Tmp1 = Op.getOperand(0),
526527 Tmp2 = Op.getOperand(1),
527 Addr = DAG.getSymbol(opstr, MVT::i64);
528 Addr = DAG.getExternalSymbol(opstr, MVT::i64);
528529 return DAG.getNode(AlphaISD::DivCall, MVT::i64, Addr, Tmp1, Tmp2);
529530 }
530531 break;
9191 || Opc == ISD::GlobalTLSAddress
9292 || Opc == ISD::JumpTable
9393 || Opc == ISD::ConstantPool
94 || Opc == ISD::Symbol
94 || Opc == ISD::ExternalSymbol
9595 || Opc == ISD::TargetGlobalAddress
9696 || Opc == ISD::TargetGlobalTLSAddress
9797 || Opc == ISD::TargetJumpTable
9898 || Opc == ISD::TargetConstantPool
99 || Opc == ISD::TargetSymbol
99 || Opc == ISD::TargetExternalSymbol
100100 || Opc == SPUISD::AFormAddr);
101101 }
102102
12001200 SmallVector Ops;
12011201 unsigned CallOpc = SPUISD::CALL;
12021202
1203 // If the callee is a GlobalAddress/Symbol node (quite common, every direct
1204 // call is) turn it into a TargetGlobalAddress/TargetSymbol node so that
1205 // legalize doesn't hack it.
1203 // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
1204 // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
1205 // node so that legalize doesn't hack it.
12061206 if (GlobalAddressSDNode *G = dyn_cast(Callee)) {
12071207 GlobalValue *GV = G->getGlobal();
12081208 MVT CalleeVT = Callee.getValueType();
12281228 // address pairs:
12291229 Callee = DAG.getNode(SPUISD::IndirectAddr, PtrVT, GA, Zero);
12301230 }
1231 } else if (SymbolSDNode *S = dyn_cast(Callee))
1232 Callee = DAG.getSymbol(S->getSymbol(), Callee.getValueType(),
1233 S->getLinkage());
1231 } else if (ExternalSymbolSDNode *S = dyn_cast(Callee))
1232 Callee = DAG.getExternalSymbol(S->getSymbol(), Callee.getValueType());
12341233 else if (SDNode *Dest = isLSAAddress(Callee, DAG)) {
12351234 // If this is an absolute destination address that appears to be a legal
12361235 // local store address, use the munged value.
328328 dyn_cast(N->getOperand(1))) {
329329 CallOpcode = IA64::BRCALL_IPREL_GA;
330330 CallOperand = CurDAG->getTargetGlobalAddress(GASD->getGlobal(), MVT::i64);
331 } else if (isa<SymbolSDNode>(N->getOperand(1))) {
331 } else if (isa<ExternalSymbolSDNode>(N->getOperand(1))) {
332332 // FIXME: we currently NEED this case for correctness, to avoid
333333 // "non-pic code with imm reloc.n against dynamic symbol" errors
334334 CallOpcode = IA64::BRCALL_IPREL_ES;
447447 }
448448
449449 /* XXX
450 case ISD::Symbol: {
451 SDValue EA = CurDAG->getTargetSymbol(
452 cast(N)->getSymbol(),
450 case ISD::ExternalSymbol: {
451 SDValue EA = CurDAG->getTargetExternalSymbol(
452 cast(N)->getSymbol(),
453453 MVT::i64);
454454 SDValue Tmp = CurDAG->getTargetNode(IA64::ADDL_EA, MVT::i64,
455455 CurDAG->getRegister(IA64::r1,
158158 return true;
159159 }
160160 } else {
161 if ((Addr.getOpcode() == ISD::TargetSymbol ||
161 if ((Addr.getOpcode() == ISD::TargetExternalSymbol ||
162162 Addr.getOpcode() == ISD::TargetGlobalAddress))
163163 return false;
164164 }
353353 SDValue InFlag(0, 0);
354354
355355 if ( (isa(Callee)) ||
356 (isa<SymbolSDNode>(Callee)) )
356 (isa<ExternalSymbolSDNode>(Callee)) )
357357 {
358358 /// Direct call for global addresses and external symbols
359359 SDValue GPReg = CurDAG->getRegister(Mips::GP, MVT::i32);
683683 InFlag = Chain.getValue(1);
684684 }
685685
686 // If the callee is a GlobalAddress/Symbol node (quite common, every direct
687 // call is) turn it into a TargetGlobalAddress/TargetSymbol node so that
688 // legalize doesn't hack it.
686 // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
687 // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
688 // node so that legalize doesn't hack it.
689689 if (GlobalAddressSDNode *G = dyn_cast(Callee))
690690 Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
691 else if (SymbolSDNode *S = dyn_cast(Callee))
692 Callee = DAG.getTargetSymbol(S->getSymbol(), getPointerTy(),
693 S->getLinkage());
691 else if (ExternalSymbolSDNode *S = dyn_cast(Callee))
692 Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
693
694694
695695 // MipsJmpLink = #chain, #target_address, #opt_in_flags...
696696 // = Chain, Callee, Reg#1, Reg#2, ...
24612461 SmallVector Ops;
24622462 unsigned CallOpc = isMachoABI? PPCISD::CALL_Macho : PPCISD::CALL_ELF;
24632463
2464 // If the callee is a GlobalAddress/Symbol node (quite common, every direct
2465 // call is) turn it into a TargetGlobalAddress/TargetSymbol node so that
2466 // legalize doesn't hack it.
2464 // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
2465 // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
2466 // node so that legalize doesn't hack it.
24672467 if (GlobalAddressSDNode *G = dyn_cast(Callee))
24682468 Callee = DAG.getTargetGlobalAddress(G->getGlobal(), Callee.getValueType());
2469 else if (SymbolSDNode *S = dyn_cast(Callee))
2470 Callee = DAG.getTargetSymbol(S->getSymbol(), Callee.getValueType(),
2471 S->getLinkage());
2469 else if (ExternalSymbolSDNode *S = dyn_cast(Callee))
2470 Callee = DAG.getTargetExternalSymbol(S->getSymbol(), Callee.getValueType());
24722471 else if (SDNode *Dest = isBLACompatibleAddress(Callee, DAG))
24732472 // If this is an absolute destination address, use the munged value.
24742473 Callee = SDValue(Dest, 0);
25932592
25942593 assert(((TargetAddress.getOpcode() == ISD::Register &&
25952594 cast(TargetAddress)->getReg() == PPC::CTR) ||
2596 TargetAddress.getOpcode() == ISD::TargetSymbol ||
2595 TargetAddress.getOpcode() == ISD::TargetExternalSymbol ||
25972596 TargetAddress.getOpcode() == ISD::TargetGlobalAddress ||
25982597 isa(TargetAddress)) &&
25992598 "Expecting an global address, external symbol, absolute value or register");
34143413 static SDValue GeneratePerfectShuffle(unsigned PFEntry, SDValue LHS,
34153414 SDValue RHS, SelectionDAG &DAG) {
34163415 unsigned OpNum = (PFEntry >> 26) & 0x0F;
3417 unsigned LHSID = (PFEntry >> 13) & ((1 << 13)-1);
3416 unsigned LHSID = (PFEntry >> 13) & ((1 << 13)-1);
34183417 unsigned RHSID = (PFEntry >> 0) & ((1 << 13)-1);
34193418
34203419 enum {
7676 Offset = CurDAG->getTargetConstant(0, MVT::i32);
7777 return true;
7878 }
79 if (Addr.getOpcode() == ISD::TargetSymbol ||
79 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
8080 Addr.getOpcode() == ISD::TargetGlobalAddress)
8181 return false; // direct calls.
8282
113113 bool SparcDAGToDAGISel::SelectADDRrr(SDValue Op, SDValue Addr,
114114 SDValue &R1, SDValue &R2) {
115115 if (Addr.getOpcode() == ISD::FrameIndex) return false;
116 if (Addr.getOpcode() == ISD::TargetSymbol ||
116 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
117117 Addr.getOpcode() == ISD::TargetGlobalAddress)
118118 return false; // direct calls.
119119
406406
407407 // If the callee is a GlobalAddress node (quite common, every direct call is)
408408 // turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
409 // Likewise Symbol -> TargetSymbol.
409 // Likewise ExternalSymbol -> TargetExternalSymbol.
410410 if (GlobalAddressSDNode *G = dyn_cast(Callee))
411411 Callee = DAG.getTargetGlobalAddress(G->getGlobal(), MVT::i32);
412 else if (SymbolSDNode *S = dyn_cast(Callee))
413 Callee = DAG.getTargetSymbol(S->getSymbol(), MVT::i32, S->getLinkage());
412 else if (ExternalSymbolSDNode *E = dyn_cast(Callee))
413 Callee = DAG.getTargetExternalSymbol(E->getSymbol(), MVT::i32);
414414
415415 std::vector NodeTys;
416416 NodeTys.push_back(MVT::Other); // Returns a chain
264264 "FrameIndexSDNode">;
265265 def tframeindex : SDNode<"ISD::TargetFrameIndex", SDTPtrLeaf, [],
266266 "FrameIndexSDNode">;
267 def externalsym : SDNode<"ISD::Symbol", SDTPtrLeaf, [],
268 "SymbolSDNode">;
269 def texternalsym: SDNode<"ISD::TargetSymbol", SDTPtrLeaf, [],
270 "SymbolSDNode">;
267 def externalsym : SDNode<"ISD::ExternalSymbol", SDTPtrLeaf, [],
268 "ExternalSymbolSDNode">;
269 def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
270 "ExternalSymbolSDNode">;
271271
272272 def add : SDNode<"ISD::ADD" , SDTIntBinOp ,
273273 [SDNPCommutative, SDNPAssociative]>;
206206 Disp = CurDAG->getTargetConstantPool(AM.CP, MVT::i32,
207207 AM.Align, AM.Disp);
208208 else if (AM.ES)
209 Disp = CurDAG->getTargetSymbol(AM.ES, MVT::i32);
209 Disp = CurDAG->getTargetExternalSymbol(AM.ES, MVT::i32);
210210 else if (AM.JT != -1)
211211 Disp = CurDAG->getTargetJumpTable(AM.JT, MVT::i32);
212212 else
834834 AM.isRIPRel = TM.getRelocationModel() != Reloc::Static &&
835835 Subtarget->isPICStyleRIPRel();
836836 return false;
837 } else if (SymbolSDNode *S = dyn_cast<SymbolSDNode>(N0)) {
837 } else if (ExternalSymbolSDNode *S =dyn_castSymbolSDNode>(N0)) {
838838 AM.ES = S->getSymbol();
839839 AM.isRIPRel = TM.getRelocationModel() != Reloc::Static &&
840840 Subtarget->isPICStyleRIPRel();
12911291 N1.getOpcode() == ISD::Constant) {
12921292 unsigned Offset = (unsigned)cast(N1)->getZExtValue();
12931293 SDValue C(0, 0);
1294 // TODO: handle SymbolSDNode.
1294 // TODO: handle ExternalSymbolSDNode.
12951295 if (GlobalAddressSDNode *G =
12961296 dyn_cast(N0.getOperand(0))) {
12971297 C = CurDAG->getTargetGlobalAddress(G->getGlobal(), PtrVT,
267267 setOperationAction(ISD::GlobalTLSAddress, MVT::i32 , Custom);
268268 if (Subtarget->is64Bit())
269269 setOperationAction(ISD::GlobalTLSAddress, MVT::i64, Custom);
270 setOperationAction(ISD::Symbol , MVT::i32 , Custom);
270 setOperationAction(ISD::ExternalSymbol , MVT::i32 , Custom);
271271 if (Subtarget->is64Bit()) {
272272 setOperationAction(ISD::ConstantPool , MVT::i64 , Custom);
273273 setOperationAction(ISD::JumpTable , MVT::i64 , Custom);
274274 setOperationAction(ISD::GlobalAddress , MVT::i64 , Custom);
275 setOperationAction(ISD::Symbol , MVT::i64 , Custom);
275 setOperationAction(ISD::ExternalSymbol, MVT::i64 , Custom);
276276 }
277277 // 64-bit addm sub, shl, sra, srl (iff 32-bit x86)
278278 setOperationAction(ISD::SHL_PARTS , MVT::i32 , Custom);
891891 assert(((TargetAddress.getOpcode() == ISD::Register &&
892892 (cast(TargetAddress)->getReg() == X86::ECX ||
893893 cast(TargetAddress)->getReg() == X86::R9)) ||
894 TargetAddress.getOpcode() == ISD::TargetSymbol ||
894 TargetAddress.getOpcode() == ISD::TargetExternalSymbol ||
895895 TargetAddress.getOpcode() == ISD::TargetGlobalAddress) &&
896896 "Expecting an global address, external symbol, or register");
897897 assert(StackAdjustment.getOpcode() == ISD::Constant &&
16071607 if (G && !G->getGlobal()->hasHiddenVisibility() &&
16081608 !G->getGlobal()->hasProtectedVisibility())
16091609 Callee = LowerGlobalAddress(Callee, DAG);
1610 else if (isa(Callee))
1611 Callee = LowerExternalSymbol(Callee, DAG);
1610 else if (isa(Callee))
1611 Callee = LowerExternalSymbol(Callee,DAG);
16121612 }
16131613
16141614 if (Is64Bit && isVarArg) {
16961696 if (!Subtarget->GVRequiresExtraLoad(G->getGlobal(),
16971697 getTargetMachine(), true))
16981698 Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
1699 } else if (SymbolSDNode *S = dyn_cast(Callee)) {
1700 Callee = DAG.getTargetSymbol(S->getSymbol(), getPointerTy(),
1701 S->getLinkage());
1699 } else if (ExternalSymbolSDNode *S = dyn_cast(Callee)) {
1700 Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
17021701 } else if (IsTailCall) {
17031702 unsigned Opc = Is64Bit ? X86::R9 : X86::ECX;
17041703
42864285 DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, AnyExt));
42874286 }
42884287
4289 // ConstantPool, JumpTable, GlobalAddress, and Symbol are lowered as their
4290 // target countpart wrapped in the X86ISD::Wrapper node. Suppose N is one of the
4291 // above mentioned nodes. It has to be wrapped because otherwise Select(N)
4292 // returns N. So the raw TargetGlobalAddress nodes, etc. can only be used to
4293 // form addressing mode. These wrapped nodes will be selected into MOV32ri.
4288 // ConstantPool, JumpTable, GlobalAddress, and ExternalSymbol are lowered as
4289 // their target countpart wrapped in the X86ISD::Wrapper node. Suppose N is
4290 // one of the above mentioned nodes. It has to be wrapped because otherwise
4291 // Select(N) returns N. So the raw TargetGlobalAddress nodes, etc. can only
4292 // be used to form addressing mode. These wrapped nodes will be selected
4293 // into MOV32ri.
42944294 SDValue
42954295 X86TargetLowering::LowerConstantPool(SDValue Op, SelectionDAG &DAG) {
42964296 ConstantPoolSDNode *CP = cast(Op);
43614361
43624362 NodeTys = DAG.getVTList(MVT::Other, MVT::Flag);
43634363 SDValue Ops1[] = { Chain,
4364 DAG.getTargetSymbol("___tls_get_addr", PtrVT),
4364 DAG.getTargetExternalSymbol("___tls_get_addr",
4365 PtrVT),
43654366 DAG.getRegister(X86::EAX, PtrVT),
43664367 DAG.getRegister(X86::EBX, PtrVT),
43674368 InFlag };
43944395
43954396 NodeTys = DAG.getVTList(MVT::Other, MVT::Flag);
43964397 SDValue Ops1[] = { Chain,
4397 DAG.getTargetSymbol("__tls_get_addr", PtrVT),
4398 DAG.getTargetExternalSymbol("__tls_get_addr",
4399 PtrVT),
43984400 DAG.getRegister(X86::RDI, PtrVT),
43994401 InFlag };
44004402 Chain = DAG.getNode(X86ISD::CALL, NodeTys, Ops1, 4);
44464448
44474449 SDValue
44484450 X86TargetLowering::LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) {
4449 SymbolSDNode *Sym = cast(Op);
4450 SDValue Result = DAG.getTargetSymbol(Sym->getSymbol(), getPointerTy(),
4451 Sym->getLinkage());
4451 const char *Sym = cast(Op)->getSymbol();
4452 SDValue Result = DAG.getTargetExternalSymbol(Sym, getPointerTy());
44524453 Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), Result);
44534454 // With PIC, the address is actually $g + Offset.
44544455 if (getTargetMachine().getRelocationModel() == Reloc::PIC_ &&
50525053
50535054 SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Flag);
50545055 SDValue Ops[] = { Chain,
5055 DAG.getTargetSymbol("_alloca", IntPtr),
5056 DAG.getTargetExternalSymbol("_alloca", IntPtr),
50565057 DAG.getRegister(X86::EAX, IntPtr),
50575058 DAG.getRegister(X86StackPtr, SPTy),
50585059 Flag };
51025103 Args.push_back(Entry);
51035104 std::pair CallResult =
51045105 LowerCallTo(Chain, Type::VoidTy, false, false, false, CallingConv::C,
5105 false, DAG.getSymbol(bzeroEntry, IntPtr),
5106 false, DAG.getExternalSymbol(bzeroEntry, IntPtr),
51065107 Args, DAG);
51075108 return CallResult.second;
51085109 }
59755976 case ISD::ConstantPool: return LowerConstantPool(Op, DAG);
59765977 case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG);
59775978 case ISD::GlobalTLSAddress: return LowerGlobalTLSAddress(Op, DAG);
5978 case ISD::Symbol: return LowerExternalSymbol(Op, DAG);
5979 case ISD::ExternalSymbol: return LowerExternalSymbol(Op, DAG);
59795980 case ISD::SHL_PARTS:
59805981 case ISD::SRA_PARTS:
59815982 case ISD::SRL_PARTS: return LowerShift(Op, DAG);
144144 /// at function entry, used for PIC code.
145145 GlobalBaseReg,
146146
147 /// Wrapper - A wrapper node for TargetConstantPool, TargetSymbol, and
148 /// TargetGlobalAddress.
147 /// Wrapper - A wrapper node for TargetConstantPool,
148 /// TargetExternalSymbol, and TargetGlobalAddress.
149149 Wrapper,
150150
151151 /// WrapperRIP - Special wrapper used under X86-64 PIC mode for RIP
11911191 // Non-Instruction Patterns
11921192 //===----------------------------------------------------------------------===//
11931193
1194 // ConstantPool GlobalAddress, Symbol, and JumpTable
1194 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
11951195 def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
11961196 (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>;
11971197 def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
27022702 // Non-Instruction Patterns
27032703 //===----------------------------------------------------------------------===//
27042704
2705 // ConstantPool GlobalAddress, Symbol, and JumpTable
2705 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
27062706 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
27072707 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
27082708 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
801801 NodeOps.push_back(Val);
802802 } else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym"){
803803 Record *Op = OperatorMap[N->getName()];
804 // Transform Symbol to TargetSymbol
804 // Transform ExternalSymbol to TargetExternalSymbol
805805 if (Op && Op->getName() == "externalsym") {
806806 std::string TmpVar = "Tmp"+utostr(ResNo);
807807 emitCode("SDValue " + TmpVar + " = CurDAG->getTarget"
808 "Symbol(cast<SymbolSDNode>(" +
808 "ExternalSymbol(castSymbolSDNode>(" +
809809 Val + ")->getSymbol(), " +
810810 getEnumName(N->getTypeNum(0)) + ");");
811811 // Add Tmp to VariableMap, so that we don't multiply select
19481948 << " case ISD::TargetConstantFP:\n"
19491949 << " case ISD::TargetConstantPool:\n"
19501950 << " case ISD::TargetFrameIndex:\n"
1951 << " case ISD::TargetSymbol:\n"
1951 << " case ISD::TargetExternalSymbol:\n"
19521952 << " case ISD::TargetJumpTable:\n"
19531953 << " case ISD::TargetGlobalTLSAddress:\n"
19541954 << " case ISD::TargetGlobalAddress: {\n"