class VectorType;
class ConstantRange;
class APInt;
-class ParamAttrsList;
//===----------------------------------------------------------------------===//
// AllocationInst Class
///
class CallInst : public Instruction {
- const ParamAttrsList *ParamAttrs; ///< parameter attributes for call
+ PAListPtr ParamAttrs; ///< parameter attributes for call
CallInst(const CallInst &CI);
void init(Value *Func, Value* const *Params, unsigned NumParams);
void init(Value *Func, Value *Actual1, Value *Actual2);
SubclassData = (SubclassData & 1) | (CC << 1);
}
- /// Obtains a pointer to the ParamAttrsList object which holds the
- /// parameter attributes information, if any.
- /// @returns 0 if no attributes have been set.
- /// @brief Get the parameter attributes.
- const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+ /// getParamAttrs - Return the parameter attributes for this call.
+ ///
+ const PAListPtr &getParamAttrs() const { return ParamAttrs; }
- /// Sets the parameter attributes for this CallInst. To construct a
- /// ParamAttrsList, see ParameterAttributes.h
- /// @brief Set the parameter attributes.
- void setParamAttrs(const ParamAttrsList *attrs);
+ /// setParamAttrs - Sets the parameter attributes for this call.
+ void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
/// @brief Determine whether the call or the callee has the given attribute.
- bool paramHasAttr(uint16_t i, unsigned attr) const;
+ bool paramHasAttr(unsigned i, unsigned attr) const;
/// @brief Extract the alignment for a call or parameter (0=unknown).
- uint16_t getParamAlignment(uint16_t i) const;
+ unsigned getParamAlignment(unsigned i) const {
+ return ParamAttrs.getParamAlignment(i);
+ }
/// @brief Determine if the call does not access memory.
- bool doesNotAccessMemory() const;
+ bool doesNotAccessMemory() const {
+ return paramHasAttr(0, ParamAttr::ReadNone);
+ }
/// @brief Determine if the call does not access or only reads memory.
- bool onlyReadsMemory() const;
+ bool onlyReadsMemory() const {
+ return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+ }
/// @brief Determine if the call cannot return.
- bool doesNotReturn() const;
+ bool doesNotReturn() const {
+ return paramHasAttr(0, ParamAttr::NoReturn);
+ }
/// @brief Determine if the call cannot unwind.
- bool doesNotThrow() const;
+ bool doesNotThrow() const {
+ return paramHasAttr(0, ParamAttr::NoUnwind);
+ }
void setDoesNotThrow(bool doesNotThrow = true);
- /// @brief Determine if the call returns a structure.
- bool isStructReturn() const;
+ /// @brief Determine if the call returns a structure through first
+ /// pointer argument.
+ bool hasStructRetAttr() const {
+ // Be friendly and also check the callee.
+ return paramHasAttr(1, ParamAttr::StructRet);
+ }
/// @brief Determine if any call argument is an aggregate passed by value.
- bool hasByValArgument() const;
+ bool hasByValArgument() const {
+ return ParamAttrs.hasAttrSomewhere(ParamAttr::ByVal);
+ }
/// getCalledFunction - Return the function being called by this instruction
/// if it is a direct call. If it is a call through a function pointer,
virtual ReturnInst *clone() const;
- Value *getReturnValue(unsigned n = 0) const {
- if (n == 0)
+ Value *getOperand(unsigned n = 0) const {
+ if (getNumOperands() > 1)
+ return TerminatorInst::getOperand(n);
+ else
return RetVal;
+ }
+
+ Value *getReturnValue(unsigned n = 0) const {
return getOperand(n);
}
/// calling convention of the call.
///
class InvokeInst : public TerminatorInst {
- const ParamAttrsList *ParamAttrs;
+ PAListPtr ParamAttrs;
InvokeInst(const InvokeInst &BI);
void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
Value* const *Args, unsigned NumArgs);
SubclassData = CC;
}
- /// Obtains a pointer to the ParamAttrsList object which holds the
- /// parameter attributes information, if any.
- /// @returns 0 if no attributes have been set.
- /// @brief Get the parameter attributes.
- const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+ /// getParamAttrs - Return the parameter attributes for this invoke.
+ ///
+ const PAListPtr &getParamAttrs() const { return ParamAttrs; }
- /// Sets the parameter attributes for this InvokeInst. To construct a
- /// ParamAttrsList, see ParameterAttributes.h
- /// @brief Set the parameter attributes.
- void setParamAttrs(const ParamAttrsList *attrs);
+ /// setParamAttrs - Set the parameter attributes for this invoke.
+ ///
+ void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
/// @brief Determine whether the call or the callee has the given attribute.
- bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+ bool paramHasAttr(unsigned i, ParameterAttributes attr) const;
/// @brief Extract the alignment for a call or parameter (0=unknown).
- uint16_t getParamAlignment(uint16_t i) const;
+ unsigned getParamAlignment(unsigned i) const {
+ return ParamAttrs.getParamAlignment(i);
+ }
/// @brief Determine if the call does not access memory.
- bool doesNotAccessMemory() const;
+ bool doesNotAccessMemory() const {
+ return paramHasAttr(0, ParamAttr::ReadNone);
+ }
/// @brief Determine if the call does not access or only reads memory.
- bool onlyReadsMemory() const;
+ bool onlyReadsMemory() const {
+ return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+ }
/// @brief Determine if the call cannot return.
- bool doesNotReturn() const;
+ bool doesNotReturn() const {
+ return paramHasAttr(0, ParamAttr::NoReturn);
+ }
/// @brief Determine if the call cannot unwind.
- bool doesNotThrow() const;
+ bool doesNotThrow() const {
+ return paramHasAttr(0, ParamAttr::NoUnwind);
+ }
void setDoesNotThrow(bool doesNotThrow = true);
- /// @brief Determine if the call returns a structure.
- bool isStructReturn() const;
+ /// @brief Determine if the call returns a structure through first
+ /// pointer argument.
+ bool hasStructRetAttr() const {
+ // Be friendly and also check the callee.
+ return paramHasAttr(1, ParamAttr::StructRet);
+ }
/// getCalledFunction - Return the function called, or null if this is an
/// indirect function invocation.