mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-15 07:33:18 +00:00
For PR950:
Add a new feature to FunctionType, Parameter Attributes. This allows tags such as "sext" and "zext" to be associated with a faunction's arguments or return type. This allows signedness information to be carried forward from the frontend to the backend for arguments and result types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32776 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f306293815
commit
57a0342e96
@ -75,21 +75,40 @@ public:
|
|||||||
/// FunctionType - Class to represent function types
|
/// FunctionType - Class to represent function types
|
||||||
///
|
///
|
||||||
class FunctionType : public DerivedType {
|
class FunctionType : public DerivedType {
|
||||||
|
public:
|
||||||
|
/// Function parameters can have attributes to indicate how they should be
|
||||||
|
/// treated by optimizations and code generation. This enumeration lists the
|
||||||
|
/// set of possible attributes.
|
||||||
|
/// @brief Function parameter attributes enumeration.
|
||||||
|
enum ParameterAttributes {
|
||||||
|
NoAttributeSet = 0, ///< No attribute value has been set on the parameter
|
||||||
|
ZExtAttribute = 1, ///< The parameter should be zero extended before call
|
||||||
|
SExtAttribute = 2 ///< The parameter should be sign extended before call
|
||||||
|
};
|
||||||
|
typedef std::vector<ParameterAttributes> ParamAttrsList;
|
||||||
|
private:
|
||||||
friend class TypeMap<FunctionValType, FunctionType>;
|
friend class TypeMap<FunctionValType, FunctionType>;
|
||||||
bool isVarArgs;
|
bool isVarArgs;
|
||||||
|
ParamAttrsList *ParamAttrs;
|
||||||
|
|
||||||
FunctionType(const FunctionType &); // Do not implement
|
FunctionType(const FunctionType &); // Do not implement
|
||||||
const FunctionType &operator=(const FunctionType &); // Do not implement
|
const FunctionType &operator=(const FunctionType &); // Do not implement
|
||||||
FunctionType(const Type *Result, const std::vector<const Type*> &Params,
|
FunctionType(const Type *Result, const std::vector<const Type*> &Params,
|
||||||
bool IsVarArgs);
|
bool IsVarArgs, const ParamAttrsList &Attrs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// FunctionType::get - This static method is the primary way of constructing
|
/// FunctionType::get - This static method is the primary way of constructing
|
||||||
/// a FunctionType
|
/// a FunctionType.
|
||||||
///
|
///
|
||||||
static FunctionType *get(const Type *Result,
|
static FunctionType *get(
|
||||||
const std::vector<const Type*> &Params,
|
const Type *Result, ///< The result type
|
||||||
bool isVarArg);
|
const std::vector<const Type*> &Params, ///< The types of the parameters
|
||||||
|
bool isVarArg, ///< Whether this is a variable argument length function
|
||||||
|
const ParamAttrsList & Attrs = ParamAttrsList()
|
||||||
|
///< Indicates the parameter attributes to use, if any. The 0th entry
|
||||||
|
///< in the list refers to the return type. Parameters are numbered
|
||||||
|
///< starting at 1.
|
||||||
|
);
|
||||||
|
|
||||||
inline bool isVarArg() const { return isVarArgs; }
|
inline bool isVarArg() const { return isVarArgs; }
|
||||||
inline const Type *getReturnType() const { return ContainedTys[0]; }
|
inline const Type *getReturnType() const { return ContainedTys[0]; }
|
||||||
@ -106,6 +125,25 @@ public:
|
|||||||
///
|
///
|
||||||
unsigned getNumParams() const { return unsigned(ContainedTys.size()-1); }
|
unsigned getNumParams() const { return unsigned(ContainedTys.size()-1); }
|
||||||
|
|
||||||
|
/// The parameter attributes for the \p ith parameter are returned. The 0th
|
||||||
|
/// parameter refers to the return type of the function.
|
||||||
|
/// @returns The ParameterAttributes for the \p ith parameter.
|
||||||
|
/// @brief Get the attributes for a parameter
|
||||||
|
ParameterAttributes getParamAttrs(unsigned i) const;
|
||||||
|
|
||||||
|
/// @brief Determine if a parameter attribute is set
|
||||||
|
bool paramHasAttr(unsigned i, ParameterAttributes attr) const {
|
||||||
|
return getParamAttrs(i) & attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Return the number of parameter attributes this type has.
|
||||||
|
unsigned getNumAttrs() const {
|
||||||
|
return (ParamAttrs ? unsigned(ParamAttrs->size()) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Convert a ParameterAttribute into its assembly text
|
||||||
|
static const char * getParamAttrsText(ParameterAttributes Attr);
|
||||||
|
|
||||||
// Implement the AbstractTypeUser interface.
|
// Implement the AbstractTypeUser interface.
|
||||||
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
||||||
virtual void typeBecameConcrete(const DerivedType *AbsTy);
|
virtual void typeBecameConcrete(const DerivedType *AbsTy);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user