llvm.org GIT mirror llvm / 08e78b1
Pass alignment on ByVal parameters, from FE, all the way through. It is now used for codegen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47484 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 12 years ago
9 changed file(s) with 65 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
165165 /// @brief Determine whether the function has the given attribute.
166166 bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
167167
168 /// @brief Extract the alignment for a call or parameter (0=unknown).
169 uint16_t getParamAlignment(uint16_t i) const;
170
168171 /// @brief Determine if the function cannot return.
169172 bool doesNotReturn() const;
170173
940940 /// @brief Determine whether the call or the callee has the given attribute.
941941 bool paramHasAttr(uint16_t i, unsigned attr) const;
942942
943 /// @brief Extract the alignment for a call or parameter (0=unknown).
944 uint16_t getParamAlignment(uint16_t i) const;
945
943946 /// @brief Determine if the call does not access memory.
944947 bool doesNotAccessMemory() const;
945948
17371740 /// @brief Determine whether the call or the callee has the given attribute.
17381741 bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
17391742
1743 /// @brief Extract the alignment for a call or parameter (0=unknown).
1744 uint16_t getParamAlignment(uint16_t i) const;
1745
17401746 /// @brief Determine if the call does not access memory.
17411747 bool doesNotAccessMemory() const;
17421748
6767
6868 /// @brief Which attributes cannot be applied to a type.
6969 Attributes typeIncompatible (const Type *Ty);
70
71 /// This turns an int alignment (a power of 2, normally) into the
72 /// form used internally in ParameterAttributes.
73 ParamAttr::Attributes inline constructAlignmentFromInt(uint32_t i) {
74 return (i << 16);
75 }
7076
7177 } // end namespace ParamAttr
7278
175181 bool paramHasAttr(uint16_t i, ParameterAttributes attr) const {
176182 return getParamAttrs(i) & attr;
177183 }
184
185 /// This extracts the alignment for the \p ith function parameter.
186 /// @returns 0 if unknown, else the alignment in bytes
187 /// @brief Extract the Alignment
188 uint16_t getParamAlignment(uint16_t i) const {
189 return (getParamAttrs(i) & ParamAttr::Alignment) >> 16;
190 }
178191
179192 /// This returns whether the given attribute is set for at least one
180193 /// parameter or for the return value.
6666
6767 /// paramHasAttr - whether the call or the callee has the given attribute.
6868 bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
69
70 /// @brief Extract the alignment for a call or parameter (0=unknown).
71 uint16_t getParamAlignment(uint16_t i) const;
6972
7073 /// @brief Determine if the call does not access memory.
7174 bool doesNotAccessMemory() const;
917917 bool isSRet;
918918 bool isNest;
919919 bool isByVal;
920 uint16_t Alignment;
920921
921922 ArgListEntry() : isSExt(false), isZExt(false), isInReg(false),
922 isSRet(false), isNest(false), isByVal(false) { }
923 isSRet(false), isNest(false), isByVal(false), Alignment(0) { }
923924 };
924925 typedef std::vector ArgListTy;
925926 virtual std::pair
12331233 | NOALIAS { $$ = ParamAttr::NoAlias; }
12341234 | BYVAL { $$ = ParamAttr::ByVal; }
12351235 | NEST { $$ = ParamAttr::Nest; }
1236 | ALIGN EUINT64VAL { $$ = $2 << 16; }
1236 | ALIGN EUINT64VAL { $$ =
1237 ParamAttr::constructAlignmentFromInt($2); }
12371238 ;
12381239
12391240 OptParamAttrs : /* empty */ { $$ = ParamAttr::None; }
31173117 Entry.isSRet = CS.paramHasAttr(attrInd, ParamAttr::StructRet);
31183118 Entry.isNest = CS.paramHasAttr(attrInd, ParamAttr::Nest);
31193119 Entry.isByVal = CS.paramHasAttr(attrInd, ParamAttr::ByVal);
3120 Entry.Alignment = CS.getParamAlignment(attrInd);
31203121 Args.push_back(Entry);
31213122 }
31223123
41454146 const Type *ElementTy = Ty->getElementType();
41464147 unsigned FrameAlign = Log2_32(getByValTypeAlignment(ElementTy));
41474148 unsigned FrameSize = getTargetData()->getABITypeSize(ElementTy);
4149 // For ByVal, alignment should be passed from FE. BE will guess if
4150 // this info is not there but there are cases it cannot get right.
4151 if (F.getParamAlignment(j))
4152 FrameAlign = Log2_32(F.getParamAlignment(j));
41484153 Flags |= (FrameAlign << ISD::ParamFlags::ByValAlignOffs);
41494154 Flags |= (FrameSize << ISD::ParamFlags::ByValSizeOffs);
41504155 }
42544259 const Type *ElementTy = Ty->getElementType();
42554260 unsigned FrameAlign = Log2_32(getByValTypeAlignment(ElementTy));
42564261 unsigned FrameSize = getTargetData()->getABITypeSize(ElementTy);
4262 // For ByVal, alignment should come from FE. BE will guess if this
4263 // info is not there but there are cases it cannot get right.
4264 if (Args[i].Alignment)
4265 FrameAlign = Log2_32(Args[i].Alignment);
42574266 Flags |= (FrameAlign << ISD::ParamFlags::ByValAlignOffs);
42584267 Flags |= (FrameSize << ISD::ParamFlags::ByValSizeOffs);
42594268 }
140140 /// @brief Determine whether the function has the given attribute.
141141 bool Function::paramHasAttr(uint16_t i, ParameterAttributes attr) const {
142142 return ParamAttrs && ParamAttrs->paramHasAttr(i, attr);
143 }
144
145 /// @brief Extract the alignment for a call or parameter (0=unknown).
146 uint16_t Function::getParamAlignment(uint16_t i) const {
147 return ParamAttrs ? ParamAttrs->getParamAlignment(i) : 0;
143148 }
144149
145150 /// @brief Determine if the function cannot return.
6060 else
6161 return cast(I)->paramHasAttr(i, attr);
6262 }
63 uint16_t CallSite::getParamAlignment(uint16_t i) const {
64 if (CallInst *CI = dyn_cast(I))
65 return CI->getParamAlignment(i);
66 else
67 return cast(I)->getParamAlignment(i);
68 }
69
6370 bool CallSite::doesNotAccessMemory() const {
6471 if (CallInst *CI = dyn_cast(I))
6572 return CI->doesNotAccessMemory();
383390 return false;
384391 }
385392
393 uint16_t CallInst::getParamAlignment(uint16_t i) const {
394 if (ParamAttrs && ParamAttrs->getParamAlignment(i))
395 return ParamAttrs->getParamAlignment(i);
396 if (const Function *F = getCalledFunction())
397 return F->getParamAlignment(i);
398 return 0;
399 }
400
386401 /// @brief Determine if the call does not access memory.
387402 bool CallInst::doesNotAccessMemory() const {
388403 return paramHasAttr(0, ParamAttr::ReadNone);
507522 return false;
508523 }
509524
525 uint16_t InvokeInst::getParamAlignment(uint16_t i) const {
526 if (ParamAttrs && ParamAttrs->getParamAlignment(i))
527 return ParamAttrs->getParamAlignment(i);
528 if (const Function *F = getCalledFunction())
529 return F->getParamAlignment(i);
530 return 0;
531 }
510532
511533 /// @brief Determine if the call does not access memory.
512534 bool InvokeInst::doesNotAccessMemory() const {