llvm.org GIT mirror llvm / f69d717
[Alignment][NFC] TargetCallingConv::setOrigAlign and TargetLowering::getABIAlignmentForCallingConv Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Subscribers: sdardis, hiraditya, jrtc27, atanasyan, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69243 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375407 91177308-0d34-0410-b5e6-96231b3b80d8 Guillaume Chatelet 1 year, 1 month ago
11 changed file(s) with 32 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
133133 MaybeAlign A = decodeMaybeAlign(OrigAlign);
134134 return A ? A->value() : 0;
135135 }
136 void setOrigAlign(unsigned A) {
137 OrigAlign = encode(Align(A));
138 assert(getOrigAlign() == A && "bitfield overflow");
136 void setOrigAlign(Align A) {
137 OrigAlign = encode(A);
138 assert(getOrigAlign() == A.value() && "bitfield overflow");
139139 }
140140
141141 unsigned getByValSize() const { return ByValSize; }
13561356
13571357 /// Certain targets have context senstive alignment requirements, where one
13581358 /// type has the alignment requirement of another type.
1359 virtual unsigned getABIAlignmentForCallingConv(Type *ArgTy,
1360 DataLayout DL) const {
1361 return DL.getABITypeAlignment(ArgTy);
1359 virtual Align getABIAlignmentForCallingConv(Type *ArgTy,
1360 DataLayout DL) const {
1361 return Align(DL.getABITypeAlignment(ArgTy));
13621362 }
13631363
13641364 /// If true, then instruction selection should seek to shrink the FP constant
109109 }
110110 if (Attrs.hasAttribute(OpIdx, Attribute::Nest))
111111 Flags.setNest();
112 Flags.setOrigAlign(DL.getABITypeAlignment(Arg.Ty));
112 Flags.setOrigAlign(Align(DL.getABITypeAlignment(Arg.Ty)));
113113 }
114114
115115 template void
234234 if (Part == 0) {
235235 Flags.setSplit();
236236 } else {
237 Flags.setOrigAlign(1);
237 Flags.setOrigAlign(Align::None());
238238 if (Part == NumParts - 1)
239239 Flags.setSplitEnd();
240240 }
267267 if (PartIdx == 0) {
268268 Flags.setSplit();
269269 } else {
270 Flags.setOrigAlign(1);
270 Flags.setOrigAlign(Align::None());
271271 if (PartIdx == NumParts - 1)
272272 Flags.setSplitEnd();
273273 }
12181218 Flags.setNest();
12191219 if (NeedsRegBlock)
12201220 Flags.setInConsecutiveRegs();
1221 unsigned OriginalAlignment = DL.getABITypeAlignment(Arg.Ty);
1222 Flags.setOrigAlign(OriginalAlignment);
1221 Flags.setOrigAlign(Align(DL.getABITypeAlignment(Arg.Ty)));
12231222
12241223 CLI.OutVals.push_back(Arg.Val);
12251224 CLI.OutFlags.push_back(Flags);
91089108 // Certain targets (such as MIPS), may have a different ABI alignment
91099109 // for a type depending on the context. Give the target a chance to
91109110 // specify the alignment it wants.
9111 unsigned OriginalAlignment = getABIAlignmentForCallingConv(ArgTy, DL);
9111 const Align OriginalAlignment(getABIAlignmentForCallingConv(ArgTy, DL));
91129112
91139113 if (Args[i].Ty->isPointerTy()) {
91149114 Flags.setPointer();
92199219 if (NumParts > 1 && j == 0)
92209220 MyFlags.Flags.setSplit();
92219221 else if (j != 0) {
9222 MyFlags.Flags.setOrigAlign(1);
9222 MyFlags.Flags.setOrigAlign(Align::None());
92239223 if (j == NumParts - 1)
92249224 MyFlags.Flags.setSplitEnd();
92259225 }
96069606 // Certain targets (such as MIPS), may have a different ABI alignment
96079607 // for a type depending on the context. Give the target a chance to
96089608 // specify the alignment it wants.
9609 unsigned OriginalAlignment =
9610 TLI->getABIAlignmentForCallingConv(ArgTy, DL);
9609 const Align OriginalAlignment(
9610 TLI->getABIAlignmentForCallingConv(ArgTy, DL));
96119611
96129612 if (Arg.getType()->isPointerTy()) {
96139613 Flags.setPointer();
96909690 MyFlags.Flags.setSplit();
96919691 // if it isn't first piece, alignment must be 1
96929692 else if (i > 0) {
9693 MyFlags.Flags.setOrigAlign(1);
9693 MyFlags.Flags.setOrigAlign(Align::None());
96949694 if (i == NumRegs - 1)
96959695 MyFlags.Flags.setSplitEnd();
96969696 }
202202 // Even if there is no splitting to do, we still want to replace the
203203 // original type (e.g. pointer type -> integer).
204204 auto Flags = OrigArg.Flags[0];
205 unsigned OriginalAlignment = DL.getABITypeAlignment(OrigArg.Ty);
206 Flags.setOrigAlign(OriginalAlignment);
205 Flags.setOrigAlign(Align(DL.getABITypeAlignment(OrigArg.Ty)));
207206 SplitArgs.emplace_back(OrigArg.Regs[0], SplitVTs[0].getTypeForEVT(Ctx),
208207 Flags, OrigArg.IsFixed);
209208 return;
215214 Type *SplitTy = SplitVT.getTypeForEVT(Ctx);
216215 auto Flags = OrigArg.Flags[0];
217216
218 unsigned OriginalAlignment = DL.getABITypeAlignment(SplitTy);
219 Flags.setOrigAlign(OriginalAlignment);
217 Flags.setOrigAlign(Align(DL.getABITypeAlignment(SplitTy)));
220218
221219 bool NeedsConsecutiveRegisters =
222220 TLI.functionArgumentNeedsConsecutiveRegisters(
22362236 if (!isTypeLegal(ArgTy, ArgVT)) return false;
22372237
22382238 ISD::ArgFlagsTy Flags;
2239 unsigned OriginalAlignment = DL.getABITypeAlignment(ArgTy);
2240 Flags.setOrigAlign(OriginalAlignment);
2239 Flags.setOrigAlign(Align(DL.getABITypeAlignment(ArgTy)));
22412240
22422241 Args.push_back(Op);
22432242 ArgRegs.push_back(Arg);
23702369 if (!Arg.isValid())
23712370 return false;
23722371
2373 unsigned OriginalAlignment = DL.getABITypeAlignment(ArgTy);
2374 Flags.setOrigAlign(OriginalAlignment);
2372 Flags.setOrigAlign(Align(DL.getABITypeAlignment(ArgTy)));
23752373
23762374 Args.push_back(*i);
23772375 ArgRegs.push_back(Arg);
1699116991 }
1699216992
1699316993 /// Return the correct alignment for the current calling convention.
16994 unsigned
16995 ARMTargetLowering::getABIAlignmentForCallingConv(Type *ArgTy,
16996 DataLayout DL) const {
16994 Align ARMTargetLowering::getABIAlignmentForCallingConv(Type *ArgTy,
16995 DataLayout DL) const {
16996 const Align ABITypeAlign(DL.getABITypeAlignment(ArgTy));
1699716997 if (!ArgTy->isVectorTy())
16998 return DL.getABITypeAlignment(ArgTy);
16998 return ABITypeAlign;
1699916999
1700017000 // Avoid over-aligning vector parameters. It would require realigning the
1700117001 // stack and waste space for no real benefit.
17002 return std::min(DL.getABITypeAlignment(ArgTy),
17003 (unsigned)DL.getStackAlignment().value());
17002 return std::min(ABITypeAlign, DL.getStackAlignment());
1700417003 }
1700517004
1700617005 /// Return true if a type is an AAPCS-VFP homogeneous aggregate or one of
616616 void finalizeLowering(MachineFunction &MF) const override;
617617
618618 /// Return the correct alignment for the current calling convention.
619 unsigned getABIAlignmentForCallingConv(Type *ArgTy,
620 DataLayout DL) const override;
619 Align getABIAlignmentForCallingConv(Type *ArgTy,
620 DataLayout DL) const override;
621621
622622 bool isDesirableToCommuteWithShift(const SDNode *N,
623623 CombineLevel Level) const override;
689689 if (i == 0)
690690 Flags.setOrigAlign(TLI.getABIAlignmentForCallingConv(Arg.Ty, DL));
691691 else
692 Flags.setOrigAlign(1);
692 Flags.setOrigAlign(Align::None());
693693
694694 ISDArgs.emplace_back(Flags, RegisterVT, VT, true, OrigArgIndices[ArgNo],
695695 0);
303303 unsigned &NumIntermediates, MVT &RegisterVT) const override;
304304
305305 /// Return the correct alignment for the current calling convention.
306 unsigned getABIAlignmentForCallingConv(Type *ArgTy,
307 DataLayout DL) const override {
306 Align getABIAlignmentForCallingConv(Type *ArgTy,
307 DataLayout DL) const override {
308 const Align ABIAlign(DL.getABITypeAlignment(ArgTy));
308309 if (ArgTy->isVectorTy())
309 return std::min(DL.getABITypeAlignment(ArgTy), 8U);
310 return DL.getABITypeAlignment(ArgTy);
310 return std::min(ABIAlign, Align(8));
311 return ABIAlign;
311312 }
312313
313314 ISD::NodeType getExtendForAtomicOps() const override {