llvm.org GIT mirror llvm / e695808
DAG: propagate whether an arg is a pointer for CallingConv decisions. The arm64_32 ABI specifies that pointers (despite being 32-bits) should be zero-extended to 64-bits when passed in registers for efficiency reasons. This means that the SelectionDAG needs to be able to tell the backend that an argument was originally a pointer, which is implmented here. Additionally, some memory intrinsics need to be declared as taking an i8* instead of an iPTR. There should be no CodeGen change yet, but it will be triggered when AArch64 backend support for ILP32 is added. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358398 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 5 months ago
4 changed file(s) with 52 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
4444 unsigned IsInConsecutiveRegsLast : 1;
4545 unsigned IsInConsecutiveRegs : 1;
4646 unsigned IsCopyElisionCandidate : 1; ///< Argument copy elision candidate
47 unsigned IsPointer : 1;
4748
4849 unsigned ByValSize; ///< Byval struct size
50
51 unsigned PointerAddrSpace; ///< Address space of pointer argument
4952
5053 public:
5154 ArgFlagsTy()
5457 IsSwiftSelf(0), IsSwiftError(0), IsHva(0), IsHvaStart(0),
5558 IsSecArgPass(0), ByValAlign(0), OrigAlign(0),
5659 IsInConsecutiveRegsLast(0), IsInConsecutiveRegs(0),
57 IsCopyElisionCandidate(0), ByValSize(0) {
58 static_assert(sizeof(*this) == 2 * sizeof(unsigned), "flags are too big");
60 IsCopyElisionCandidate(0), IsPointer(0), ByValSize(0),
61 PointerAddrSpace(0) {
62 static_assert(sizeof(*this) == 3 * sizeof(unsigned), "flags are too big");
5963 }
6064
6165 bool isZExt() const { return IsZExt; }
111115
112116 bool isCopyElisionCandidate() const { return IsCopyElisionCandidate; }
113117 void setCopyElisionCandidate() { IsCopyElisionCandidate = 1; }
118
119 bool isPointer() const { return IsPointer; }
120 void setPointer() { IsPointer = 1; }
114121
115122 unsigned getByValAlign() const { return (1U << ByValAlign) / 2; }
116123 void setByValAlign(unsigned A) {
126133
127134 unsigned getByValSize() const { return ByValSize; }
128135 void setByValSize(unsigned S) { ByValSize = S; }
129 };
136
137 unsigned getPointerAddrSpace() const { return PointerAddrSpace; }
138 void setPointerAddrSpace(unsigned AS) { PointerAddrSpace = AS; }
139 };
130140
131141 /// InputArg - This struct carries flags and type information about a
132142 /// single incoming (formal) argument or incoming (from the perspective
8080
8181 /// CCIfNotVarArg - If the current function is not vararg - apply the action
8282 class CCIfNotVarArg : CCIf<"!State.isVarArg()", A> {}
83
84 /// CCIfPtrAddrSpace - If the top-level parent of the current argument has
85 /// pointer type in the specified address-space.
86 class CCIfPtrAddrSpace
87 : CCIf<"(ArgFlags.isPointer() && ArgFlags.getPointerAddrSpace() == " # AS # ")", A> {}
88
89 /// CCIfPtr - If the top-level parent of the current argument had
90 /// pointer type in some address-space.
91 class CCIfPtr : CCIf<"ArgFlags.isPointer()", A> {}
8392
8493 /// CCAssignToReg - This action matches if there is a register in the specified
8594 /// list that is still available. If so, it assigns the value to the first
60926092 // Emit a library call.
60936093 TargetLowering::ArgListTy Args;
60946094 TargetLowering::ArgListEntry Entry;
6095 Entry.Ty = getDataLayout().getIntPtrType(*getContext());
6095 Entry.Ty = Type::getInt8PtrTy(*getContext());
60966096 Entry.Node = Dst; Args.push_back(Entry);
60976097 Entry.Node = Src; Args.push_back(Entry);
6098
6099 Entry.Ty = getDataLayout().getIntPtrType(*getContext());
60986100 Entry.Node = Size; Args.push_back(Entry);
60996101 // FIXME: pass in SDLoc
61006102 TargetLowering::CallLoweringInfo CLI(*this);
61946196 // Emit a library call.
61956197 TargetLowering::ArgListTy Args;
61966198 TargetLowering::ArgListEntry Entry;
6197 Entry.Ty = getDataLayout().getIntPtrType(*getContext());
6199 Entry.Ty = Type::getInt8PtrTy(*getContext());
61986200 Entry.Node = Dst; Args.push_back(Entry);
61996201 Entry.Node = Src; Args.push_back(Entry);
6202
6203 Entry.Ty = getDataLayout().getIntPtrType(*getContext());
62006204 Entry.Node = Size; Args.push_back(Entry);
62016205 // FIXME: pass in SDLoc
62026206 TargetLowering::CallLoweringInfo CLI(*this);
62896293 checkAddrSpaceIsValidForLibcall(TLI, DstPtrInfo.getAddrSpace());
62906294
62916295 // Emit a library call.
6292 Type *IntPtrTy = getDataLayout().getIntPtrType(*getContext());
62936296 TargetLowering::ArgListTy Args;
62946297 TargetLowering::ArgListEntry Entry;
6295 Entry.Node = Dst; Entry.Ty = IntPtrTy;
6298 Entry.Node = Dst; Entry.Ty = Type::getInt8PtrTy(*getContext());
62966299 Args.push_back(Entry);
62976300 Entry.Node = Src;
62986301 Entry.Ty = Src.getValueType().getTypeForEVT(*getContext());
62996302 Args.push_back(Entry);
63006303 Entry.Node = Size;
6301 Entry.Ty = IntPtrTy;
6304 Entry.Ty = getDataLayout().getIntPtrType(*getContext());
63026305 Args.push_back(Entry);
63036306
63046307 // FIXME: pass in SDLoc
18441844 ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy();
18451845 if (RetInReg)
18461846 Flags.setInReg();
1847
1848 if (I.getOperand(0)->getType()->isPointerTy()) {
1849 Flags.setPointer();
1850 Flags.setPointerAddrSpace(
1851 cast(I.getOperand(0)->getType())->getAddressSpace());
1852 }
18471853
18481854 // Propagate extension type if any
18491855 if (ExtendKind == ISD::SIGN_EXTEND)
88338839 CLI.CallConv, VT);
88348840 for (unsigned i = 0; i != NumRegs; ++i) {
88358841 ISD::InputArg MyFlags;
8842 MyFlags.Flags = Flags;
88368843 MyFlags.VT = RegisterVT;
88378844 MyFlags.ArgVT = VT;
88388845 MyFlags.Used = CLI.IsReturnValueUsed;
8846 if (CLI.RetTy->isPointerTy()) {
8847 MyFlags.Flags.setPointer();
8848 MyFlags.Flags.setPointerAddrSpace(
8849 cast(CLI.RetTy)->getAddressSpace());
8850 }
88398851 if (CLI.RetSExt)
88408852 MyFlags.Flags.setSExt();
88418853 if (CLI.RetZExt)
88868898 // specify the alignment it wants.
88878899 unsigned OriginalAlignment = getABIAlignmentForCallingConv(ArgTy, DL);
88888900
8901 if (Args[i].Ty->isPointerTy()) {
8902 Flags.setPointer();
8903 Flags.setPointerAddrSpace(
8904 cast(Args[i].Ty)->getAddressSpace());
8905 }
88898906 if (Args[i].IsZExt)
88908907 Flags.setZExt();
88918908 if (Args[i].IsSExt)
93749391 unsigned OriginalAlignment =
93759392 TLI->getABIAlignmentForCallingConv(ArgTy, DL);
93769393
9394 if (Arg.getType()->isPointerTy()) {
9395 Flags.setPointer();
9396 Flags.setPointerAddrSpace(
9397 cast(Arg.getType())->getAddressSpace());
9398 }
93779399 if (Arg.hasAttribute(Attribute::ZExt))
93789400 Flags.setZExt();
93799401 if (Arg.hasAttribute(Attribute::SExt))