Large mechanical patch.

s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage 
- to implement function notes as function attributes and 
- to distinguish between function attributes and return value attributes.

This requires corresponding changes in llvm-gcc and clang.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2008-09-25 21:00:45 +00:00
parent 32b952a2a6
commit 0598866c05
53 changed files with 1168 additions and 1169 deletions

View File

@ -83,18 +83,18 @@ typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
typedef enum {
LLVMZExtParamAttr = 1<<0,
LLVMSExtParamAttr = 1<<1,
LLVMNoReturnParamAttr = 1<<2,
LLVMInRegParamAttr = 1<<3,
LLVMStructRetParamAttr = 1<<4,
LLVMNoUnwindParamAttr = 1<<5,
LLVMNoAliasParamAttr = 1<<6,
LLVMByValParamAttr = 1<<7,
LLVMNestParamAttr = 1<<8,
LLVMReadNoneParamAttr = 1<<9,
LLVMReadOnlyParamAttr = 1<<10
} LLVMParamAttr;
LLVMZExtAttribute = 1<<0,
LLVMSExtAttribute = 1<<1,
LLVMNoReturnAttribute = 1<<2,
LLVMInRegAttribute = 1<<3,
LLVMStructRetAttribute = 1<<4,
LLVMNoUnwindAttribute = 1<<5,
LLVMNoAliasAttribute = 1<<6,
LLVMByValAttribute = 1<<7,
LLVMNestAttribute = 1<<8,
LLVMReadNoneAttribute = 1<<9,
LLVMReadOnlyAttribute = 1<<10
} LLVMAttribute;
typedef enum {
LLVMVoidTypeKind, /**< type with no size */
@ -423,8 +423,8 @@ LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA);
void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA);
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
/* Operations on basic blocks */
@ -454,9 +454,9 @@ LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
/* Operations on call sites */
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index, LLVMParamAttr);
void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index,
LLVMParamAttr);
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute);
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
unsigned align);

View File

@ -60,10 +60,10 @@ public:
/// its containing function.
bool hasStructRetAttr() const;
/// addAttr - Add a ParamAttr to an argument
/// addAttr - Add a Attribute to an argument
void addAttr(Attributes);
/// removeAttr - Remove a ParamAttr from an argument
/// removeAttr - Remove a Attribute from an argument
void removeAttr(Attributes);
/// classof - Methods for support type inquiry through isa, cast, and

View File

@ -1,4 +1,4 @@
//===-- llvm/Attributes.h - Container for ParamAttrs ---*---------- C++ -*-===//
//===-- llvm/Attributes.h - Container for Attributes ---*---------- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -7,29 +7,29 @@
//
//===----------------------------------------------------------------------===//
//
// This file contains the simple types necessary to represent the parameter
// This file contains the simple types necessary to represent the
// attributes associated with functions and their calls.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_PARAMETER_ATTRIBUTES_H
#define LLVM_PARAMETER_ATTRIBUTES_H
#ifndef LLVM_ATTRIBUTES_H
#define LLVM_ATTRIBUTES_H
#include <string>
namespace llvm {
class Type;
/// Attributes - A bitset of attributes for a parameter.
/// Attributes - A bitset of attributes.
typedef unsigned Attributes;
namespace ParamAttr {
namespace Attribute {
/// Function parameters and results can have attributes to indicate how they
/// should be treated by optimizations and code generation. This enumeration
/// lists the attributes that can be associated with parameters or function
/// results.
/// @brief Function parameter attributes.
/// lists the attributes that can be associated with parameters, function
/// results or the function itself.
/// @brief Function attributes.
const Attributes None = 0; ///< No attributes have been set
const Attributes ZExt = 1<<0; ///< Zero extended before/after call
@ -43,6 +43,9 @@ const Attributes ByVal = 1<<7; ///< Pass structure by value
const Attributes Nest = 1<<8; ///< Nested function static chain
const Attributes ReadNone = 1<<9; ///< Function does not access memory
const Attributes ReadOnly = 1<<10; ///< Function only reads from memory
const Attributes NoInline = 1<<11; // inline=never
const Attributes AlwaysInline = 1<<12; // inline=always
const Attributes OptimizeForSize = 1<<13; // opt_size
const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter (16 bits)
// 0 = unknown, else in clear (not log)
@ -74,27 +77,23 @@ inline Attributes constructAlignmentFromInt(unsigned i) {
/// The set of Attributes set in Attributes is converted to a
/// string of equivalent mnemonics. This is, presumably, for writing out
/// the mnemonics for the assembly writer.
/// @brief Convert parameter attribute bits to text
/// @brief Convert attribute bits to text
std::string getAsString(Attributes Attrs);
} // end namespace ParamAttr
} // end namespace Attribute
namespace FnAttr {
/// Function notes are implemented as attributes stored at index ~0 in
/// parameter attribute list.
const Attributes None = 0;
const Attributes NoInline = 1<<0; // inline=never
const Attributes AlwaysInline = 1<<1; // inline=always
const Attributes OptimizeForSize = 1<<2; // opt_size
} // end namespace FnAttr
namespace Attribute {
} // end namespace Attribute
/// This is just a pair of values to associate a set of parameter attributes
/// with a parameter index.
struct FnAttributeWithIndex {
/// This is just a pair of values to associate a set of attributes
/// with an index.
struct AttributeWithIndex {
Attributes Attrs; ///< The attributes that are set, or'd together.
unsigned Index; ///< Index of the parameter for which the attributes apply.
///< Index 0 is used for return value attributes.
///< Index ~0U is used for function attributes.
static FnAttributeWithIndex get(unsigned Idx, Attributes Attrs) {
FnAttributeWithIndex P;
static AttributeWithIndex get(unsigned Idx, Attributes Attrs) {
AttributeWithIndex P;
P.Index = Idx;
P.Attrs = Attrs;
return P;
@ -102,66 +101,66 @@ struct FnAttributeWithIndex {
};
//===----------------------------------------------------------------------===//
// PAListPtr Smart Pointer
// AttrListPtr Smart Pointer
//===----------------------------------------------------------------------===//
class AttributeListImpl;
/// PAListPtr - This class manages the ref count for the opaque
/// AttrListPtr - This class manages the ref count for the opaque
/// AttributeListImpl object and provides accessors for it.
class PAListPtr {
/// PAList - The parameter attributes that we are managing. This can be null
/// to represent the empty parameter attributes list.
AttributeListImpl *PAList;
class AttrListPtr {
/// AttrList - The attributes that we are managing. This can be null
/// to represent the empty attributes list.
AttributeListImpl *AttrList;
public:
PAListPtr() : PAList(0) {}
PAListPtr(const PAListPtr &P);
const PAListPtr &operator=(const PAListPtr &RHS);
~PAListPtr();
AttrListPtr() : AttrList(0) {}
AttrListPtr(const AttrListPtr &P);
const AttrListPtr &operator=(const AttrListPtr &RHS);
~AttrListPtr();
//===--------------------------------------------------------------------===//
// Parameter Attribute List Construction and Mutation
// Attribute List Construction and Mutation
//===--------------------------------------------------------------------===//
/// get - Return a ParamAttrs list with the specified parameter in it.
static PAListPtr get(const FnAttributeWithIndex *Attr, unsigned NumAttrs);
/// get - Return a Attributes list with the specified parameter in it.
static AttrListPtr get(const AttributeWithIndex *Attr, unsigned NumAttrs);
/// get - Return a ParamAttr list with the parameters specified by the
/// get - Return a Attribute list with the parameters specified by the
/// consecutive random access iterator range.
template <typename Iter>
static PAListPtr get(const Iter &I, const Iter &E) {
if (I == E) return PAListPtr(); // Empty list.
static AttrListPtr get(const Iter &I, const Iter &E) {
if (I == E) return AttrListPtr(); // Empty list.
return get(&*I, static_cast<unsigned>(E-I));
}
/// addAttr - Add the specified attribute at the specified index to this
/// attribute list. Since parameter attribute lists are immutable, this
/// attribute list. Since attribute lists are immutable, this
/// returns the new list.
PAListPtr addAttr(unsigned Idx, Attributes Attrs) const;
AttrListPtr addAttr(unsigned Idx, Attributes Attrs) const;
/// removeAttr - Remove the specified attribute at the specified index from
/// this attribute list. Since parameter attribute lists are immutable, this
/// this attribute list. Since attribute lists are immutable, this
/// returns the new list.
PAListPtr removeAttr(unsigned Idx, Attributes Attrs) const;
AttrListPtr removeAttr(unsigned Idx, Attributes Attrs) const;
//===--------------------------------------------------------------------===//
// Parameter Attribute List Accessors
// Attribute List Accessors
//===--------------------------------------------------------------------===//
/// getParamAttrs - The parameter attributes for the specified parameter are
/// returned. Parameters for the result are denoted with Idx = 0.
Attributes getParamAttrs(unsigned Idx) const;
/// getAttributes - The attributes for the specified index are
/// returned. Attributes for the result are denoted with Idx = 0.
Attributes getAttributes(unsigned Idx) const;
/// paramHasAttr - Return true if the specified parameter index has the
/// specified attribute set.
bool paramHasAttr(unsigned Idx, Attributes Attr) const {
return getParamAttrs(Idx) & Attr;
return getAttributes(Idx) & Attr;
}
/// getParamAlignment - Return the alignment for the specified function
/// parameter.
unsigned getParamAlignment(unsigned Idx) const {
return (getParamAttrs(Idx) & ParamAttr::Alignment) >> 16;
return (getAttributes(Idx) & Attribute::Alignment) >> 16;
}
/// hasAttrSomewhere - Return true if the specified attribute is set for at
@ -169,29 +168,29 @@ public:
bool hasAttrSomewhere(Attributes Attr) const;
/// operator==/!= - Provide equality predicates.
bool operator==(const PAListPtr &RHS) const { return PAList == RHS.PAList; }
bool operator!=(const PAListPtr &RHS) const { return PAList != RHS.PAList; }
bool operator==(const AttrListPtr &RHS) const { return AttrList == RHS.AttrList; }
bool operator!=(const AttrListPtr &RHS) const { return AttrList != RHS.AttrList; }
void dump() const;
//===--------------------------------------------------------------------===//
// Parameter Attribute List Introspection
// Attribute List Introspection
//===--------------------------------------------------------------------===//
/// getRawPointer - Return a raw pointer that uniquely identifies this
/// parameter attribute list.
/// attribute list.
void *getRawPointer() const {
return PAList;
return AttrList;
}
// Parameter attributes are stored as a dense set of slots, where there is one
// Attributes are stored as a dense set of slots, where there is one
// slot for each argument that has an attribute. This allows walking over the
// dense set instead of walking the sparse list of attributes.
/// isEmpty - Return true if no parameters have an attribute.
/// isEmpty - Return true if there are no attributes.
///
bool isEmpty() const {
return PAList == 0;
return AttrList == 0;
}
/// getNumSlots - Return the number of slots used in this attribute list.
@ -199,12 +198,12 @@ public:
/// (including the function itself).
unsigned getNumSlots() const;
/// getSlot - Return the FnAttributeWithIndex at the specified slot. This
/// holds a parameter number plus a set of attributes.
const FnAttributeWithIndex &getSlot(unsigned Slot) const;
/// getSlot - Return the AttributeWithIndex at the specified slot. This
/// holds a index number plus a set of attributes.
const AttributeWithIndex &getSlot(unsigned Slot) const;
private:
explicit PAListPtr(AttributeListImpl *L);
explicit AttrListPtr(AttributeListImpl *L);
};
} // End llvm namespace

View File

@ -64,7 +64,7 @@ namespace bitc {
};
/// PARAMATTR blocks have code for defining a parameter attribute set.
enum ParamAttrCodes {
enum AttributeCodes {
PARAMATTR_CODE_ENTRY = 1 // ENTRY: [paramidx0, attr0, paramidx1, attr1...]
};

View File

@ -69,7 +69,7 @@ private:
BasicBlockListType BasicBlocks; ///< The basic blocks
mutable ArgumentListType ArgumentList; ///< The formal arguments
ValueSymbolTable *SymTab; ///< Symbol table of args/instructions
PAListPtr ParamAttrs; ///< Parameter attributes
AttrListPtr AttributeList; ///< Parameter attributes
// The Calling Convention is stored in Value::SubclassData.
/*unsigned CallingConvention;*/
@ -140,13 +140,13 @@ public:
SubclassData = (SubclassData & 1) | (CC << 1);
}
/// getParamAttrs - Return the parameter attributes for this Function.
/// getAttributes - Return the parameter attributes for this Function.
///
const PAListPtr &getParamAttrs() const { return ParamAttrs; }
const AttrListPtr &getAttributes() const { return AttributeList; }
/// setParamAttrs - Set the parameter attributes for this Function.
/// setAttributes - Set the parameter attributes for this Function.
///
void setParamAttrs(const PAListPtr &attrs) { ParamAttrs = attrs; }
void setAttributes(const AttrListPtr &attrs) { AttributeList = attrs; }
/// hasNote - Return true if this function has given note.
@ -159,7 +159,7 @@ public:
///
void setNotes(const Attributes N) {
// Notes are stored at ~0 index in parameter attribute list
addParamAttr(~0, N);
addAttribute(~0, N);
}
/// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
@ -171,60 +171,60 @@ public:
/// @brief Determine whether the function has the given attribute.
bool paramHasAttr(unsigned i, Attributes attr) const {
return ParamAttrs.paramHasAttr(i, attr);
return AttributeList.paramHasAttr(i, attr);
}
/// addParamAttr - adds the attribute to the list of attributes.
void addParamAttr(unsigned i, Attributes attr);
/// addAttribute - adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attributes attr);
/// removeParamAttr - removes the attribute from the list of attributes.
void removeParamAttr(unsigned i, Attributes attr);
/// removeAttribute - removes the attribute from the list of attributes.
void removeAttribute(unsigned i, Attributes attr);
/// @brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
return ParamAttrs.getParamAlignment(i);
return AttributeList.getParamAlignment(i);
}
/// @brief Determine if the function does not access memory.
bool doesNotAccessMemory() const {
return paramHasAttr(0, ParamAttr::ReadNone);
return paramHasAttr(0, Attribute::ReadNone);
}
void setDoesNotAccessMemory(bool DoesNotAccessMemory = true) {
if (DoesNotAccessMemory) addParamAttr(0, ParamAttr::ReadNone);
else removeParamAttr(0, ParamAttr::ReadNone);
if (DoesNotAccessMemory) addAttribute(0, Attribute::ReadNone);
else removeAttribute(0, Attribute::ReadNone);
}
/// @brief Determine if the function does not access or only reads memory.
bool onlyReadsMemory() const {
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
return doesNotAccessMemory() || paramHasAttr(0, Attribute::ReadOnly);
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addParamAttr(0, ParamAttr::ReadOnly);
else removeParamAttr(0, ParamAttr::ReadOnly | ParamAttr::ReadNone);
if (OnlyReadsMemory) addAttribute(0, Attribute::ReadOnly);
else removeAttribute(0, Attribute::ReadOnly | Attribute::ReadNone);
}
/// @brief Determine if the function cannot return.
bool doesNotReturn() const {
return paramHasAttr(0, ParamAttr::NoReturn);
return paramHasAttr(0, Attribute::NoReturn);
}
void setDoesNotReturn(bool DoesNotReturn = true) {
if (DoesNotReturn) addParamAttr(0, ParamAttr::NoReturn);
else removeParamAttr(0, ParamAttr::NoReturn);
if (DoesNotReturn) addAttribute(0, Attribute::NoReturn);
else removeAttribute(0, Attribute::NoReturn);
}
/// @brief Determine if the function cannot unwind.
bool doesNotThrow() const {
return paramHasAttr(0, ParamAttr::NoUnwind);
return paramHasAttr(0, Attribute::NoUnwind);
}
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addParamAttr(0, ParamAttr::NoUnwind);
else removeParamAttr(0, ParamAttr::NoUnwind);
if (DoesNotThrow) addAttribute(0, Attribute::NoUnwind);
else removeAttribute(0, Attribute::NoUnwind);
}
/// @brief Determine if the function returns a structure through first
/// pointer argument.
bool hasStructRetAttr() const {
return paramHasAttr(1, ParamAttr::StructRet);
return paramHasAttr(1, Attribute::StructRet);
}
/// copyAttributesFrom - copy all additional attributes (those not needed to

View File

@ -973,7 +973,7 @@ public:
///
class CallInst : public Instruction {
PAListPtr ParamAttrs; ///< parameter attributes for call
AttrListPtr AttributeList; ///< 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);
@ -1073,73 +1073,73 @@ public:
SubclassData = (SubclassData & 1) | (CC << 1);
}
/// getParamAttrs - Return the parameter attributes for this call.
/// getAttributes - Return the parameter attributes for this call.
///
const PAListPtr &getParamAttrs() const { return ParamAttrs; }
const AttrListPtr &getAttributes() const { return AttributeList; }
/// setParamAttrs - Sets the parameter attributes for this call.
void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
/// setAttributes - Sets the parameter attributes for this call.
void setAttributes(const AttrListPtr &Attrs) { AttributeList = Attrs; }
/// addParamAttr - adds the attribute to the list of attributes.
void addParamAttr(unsigned i, Attributes attr);
/// addAttribute - adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attributes attr);
/// removeParamAttr - removes the attribute from the list of attributes.
void removeParamAttr(unsigned i, Attributes attr);
/// removeAttribute - removes the attribute from the list of attributes.
void removeAttribute(unsigned i, Attributes attr);
/// @brief Determine whether the call or the callee has the given attribute.
bool paramHasAttr(unsigned i, unsigned attr) const;
/// @brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
return ParamAttrs.getParamAlignment(i);
return AttributeList.getParamAlignment(i);
}
/// @brief Determine if the call does not access memory.
bool doesNotAccessMemory() const {
return paramHasAttr(0, ParamAttr::ReadNone);
return paramHasAttr(0, Attribute::ReadNone);
}
void setDoesNotAccessMemory(bool NotAccessMemory = true) {
if (NotAccessMemory) addParamAttr(0, ParamAttr::ReadNone);
else removeParamAttr(0, ParamAttr::ReadNone);
if (NotAccessMemory) addAttribute(0, Attribute::ReadNone);
else removeAttribute(0, Attribute::ReadNone);
}
/// @brief Determine if the call does not access or only reads memory.
bool onlyReadsMemory() const {
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
return doesNotAccessMemory() || paramHasAttr(0, Attribute::ReadOnly);
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addParamAttr(0, ParamAttr::ReadOnly);
else removeParamAttr(0, ParamAttr::ReadOnly | ParamAttr::ReadNone);
if (OnlyReadsMemory) addAttribute(0, Attribute::ReadOnly);
else removeAttribute(0, Attribute::ReadOnly | Attribute::ReadNone);
}
/// @brief Determine if the call cannot return.
bool doesNotReturn() const {
return paramHasAttr(0, ParamAttr::NoReturn);
return paramHasAttr(0, Attribute::NoReturn);
}
void setDoesNotReturn(bool DoesNotReturn = true) {
if (DoesNotReturn) addParamAttr(0, ParamAttr::NoReturn);
else removeParamAttr(0, ParamAttr::NoReturn);
if (DoesNotReturn) addAttribute(0, Attribute::NoReturn);
else removeAttribute(0, Attribute::NoReturn);
}
/// @brief Determine if the call cannot unwind.
bool doesNotThrow() const {
return paramHasAttr(0, ParamAttr::NoUnwind);
return paramHasAttr(0, Attribute::NoUnwind);
}
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addParamAttr(0, ParamAttr::NoUnwind);
else removeParamAttr(0, ParamAttr::NoUnwind);
if (DoesNotThrow) addAttribute(0, Attribute::NoUnwind);
else removeAttribute(0, Attribute::NoUnwind);
}
/// @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);
return paramHasAttr(1, Attribute::StructRet);
}
/// @brief Determine if any call argument is an aggregate passed by value.
bool hasByValArgument() const {
return ParamAttrs.hasAttrSomewhere(ParamAttr::ByVal);
return AttributeList.hasAttrSomewhere(Attribute::ByVal);
}
/// getCalledFunction - Return the function being called by this instruction
@ -2353,7 +2353,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SwitchInst, Value)
/// calling convention of the call.
///
class InvokeInst : public TerminatorInst {
PAListPtr ParamAttrs;
AttrListPtr AttributeList;
InvokeInst(const InvokeInst &BI);
void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
Value* const *Args, unsigned NumArgs);
@ -2431,69 +2431,69 @@ public:
SubclassData = CC;
}
/// getParamAttrs - Return the parameter attributes for this invoke.
/// getAttributes - Return the parameter attributes for this invoke.
///
const PAListPtr &getParamAttrs() const { return ParamAttrs; }
const AttrListPtr &getAttributes() const { return AttributeList; }
/// setParamAttrs - Set the parameter attributes for this invoke.
/// setAttributes - Set the parameter attributes for this invoke.
///
void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
void setAttributes(const AttrListPtr &Attrs) { AttributeList = Attrs; }
/// @brief Determine whether the call or the callee has the given attribute.
bool paramHasAttr(unsigned i, Attributes attr) const;
/// addParamAttr - adds the attribute to the list of attributes.
void addParamAttr(unsigned i, Attributes attr);
/// addAttribute - adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attributes attr);
/// removeParamAttr - removes the attribute from the list of attributes.
void removeParamAttr(unsigned i, Attributes attr);
/// removeAttribute - removes the attribute from the list of attributes.
void removeAttribute(unsigned i, Attributes attr);
/// @brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
return ParamAttrs.getParamAlignment(i);
return AttributeList.getParamAlignment(i);
}
/// @brief Determine if the call does not access memory.
bool doesNotAccessMemory() const {
return paramHasAttr(0, ParamAttr::ReadNone);
return paramHasAttr(0, Attribute::ReadNone);
}
void setDoesNotAccessMemory(bool NotAccessMemory = true) {
if (NotAccessMemory) addParamAttr(0, ParamAttr::ReadNone);
else removeParamAttr(0, ParamAttr::ReadNone);
if (NotAccessMemory) addAttribute(0, Attribute::ReadNone);
else removeAttribute(0, Attribute::ReadNone);
}
/// @brief Determine if the call does not access or only reads memory.
bool onlyReadsMemory() const {
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
return doesNotAccessMemory() || paramHasAttr(0, Attribute::ReadOnly);
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addParamAttr(0, ParamAttr::ReadOnly);
else removeParamAttr(0, ParamAttr::ReadOnly | ParamAttr::ReadNone);
if (OnlyReadsMemory) addAttribute(0, Attribute::ReadOnly);
else removeAttribute(0, Attribute::ReadOnly | Attribute::ReadNone);
}
/// @brief Determine if the call cannot return.
bool doesNotReturn() const {
return paramHasAttr(0, ParamAttr::NoReturn);
return paramHasAttr(0, Attribute::NoReturn);
}
void setDoesNotReturn(bool DoesNotReturn = true) {
if (DoesNotReturn) addParamAttr(0, ParamAttr::NoReturn);
else removeParamAttr(0, ParamAttr::NoReturn);
if (DoesNotReturn) addAttribute(0, Attribute::NoReturn);
else removeAttribute(0, Attribute::NoReturn);
}
/// @brief Determine if the call cannot unwind.
bool doesNotThrow() const {
return paramHasAttr(0, ParamAttr::NoUnwind);
return paramHasAttr(0, Attribute::NoUnwind);
}
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addParamAttr(0, ParamAttr::NoUnwind);
else removeParamAttr(0, ParamAttr::NoUnwind);
if (DoesNotThrow) addAttribute(0, Attribute::NoUnwind);
else removeAttribute(0, Attribute::NoUnwind);
}
/// @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);
return paramHasAttr(1, Attribute::StructRet);
}
/// getCalledFunction - Return the function called, or null if this is an

View File

@ -24,7 +24,7 @@ class Type;
class FunctionType;
class Function;
class Module;
class PAListPtr;
class AttrListPtr;
/// Intrinsic Namespace - This namespace contains an enum with a value for
/// every intrinsic/builtin function known by LLVM. These enum values are
@ -49,9 +49,9 @@ namespace Intrinsic {
///
const FunctionType *getType(ID id, const Type **Tys = 0, unsigned numTys = 0);
/// Intrinsic::getParamAttrs(ID) - Return the attributes for an intrinsic.
/// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic.
///
PAListPtr getParamAttrs(ID id);
AttrListPtr getAttributes(ID id);
/// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function
/// declaration for an intrinsic, and return it.

View File

@ -62,10 +62,10 @@ public:
unsigned getCallingConv() const;
void setCallingConv(unsigned CC);
/// getParamAttrs/setParamAttrs - get or set the parameter attributes of
/// getAttributes/setAttributes - get or set the parameter attributes of
/// the call.
const PAListPtr &getParamAttrs() const;
void setParamAttrs(const PAListPtr &PAL);
const AttrListPtr &getAttributes() const;
void setAttributes(const AttrListPtr &PAL);
/// paramHasAttr - whether the call or the callee has the given attribute.
bool paramHasAttr(uint16_t i, Attributes attr) const;

File diff suppressed because it is too large Load Diff

View File

@ -366,7 +366,7 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 970 "/Users/echristo/sources/llvm/lib/AsmParser/llvmAsmParser.y"
#line 970 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
{
llvm::Module *ModuleVal;
llvm::Function *FunctionVal;
@ -394,7 +394,7 @@ typedef union YYSTYPE
llvm::GlobalValue::LinkageTypes Linkage;
llvm::GlobalValue::VisibilityTypes Visibility;
llvm::Attributes ParamAttrs;
llvm::Attributes Attributes;
llvm::APInt *APIntVal;
int64_t SInt64Val;
uint64_t UInt64Val;

View File

@ -994,7 +994,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
llvm::GlobalValue::LinkageTypes Linkage;
llvm::GlobalValue::VisibilityTypes Visibility;
llvm::Attributes ParamAttrs;
llvm::Attributes Attributes;
llvm::APInt *APIntVal;
int64_t SInt64Val;
uint64_t UInt64Val;
@ -1088,10 +1088,10 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
%token X86_SSECALLCC_TOK
%token DATALAYOUT
%type <UIntVal> OptCallingConv LocalNumber
%type <ParamAttrs> OptParamAttrs ParamAttr
%type <ParamAttrs> OptFuncAttrs FuncAttr
%type <ParamAttrs> OptFuncNotes FuncNote
%type <ParamAttrs> FuncNoteList
%type <Attributes> OptAttributes Attribute
%type <Attributes> OptFuncAttrs FuncAttr
%type <Attributes> OptFuncNotes FuncNote
%type <Attributes> FuncNoteList
// Basic Block Terminating Operators
%token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
@ -1260,35 +1260,35 @@ OptCallingConv : /*empty*/ { $$ = CallingConv::C; } |
CHECK_FOR_ERROR
};
ParamAttr : ZEROEXT { $$ = ParamAttr::ZExt; }
| ZEXT { $$ = ParamAttr::ZExt; }
| SIGNEXT { $$ = ParamAttr::SExt; }
| SEXT { $$ = ParamAttr::SExt; }
| INREG { $$ = ParamAttr::InReg; }
| SRET { $$ = ParamAttr::StructRet; }
| NOALIAS { $$ = ParamAttr::NoAlias; }
| BYVAL { $$ = ParamAttr::ByVal; }
| NEST { $$ = ParamAttr::Nest; }
Attribute : ZEROEXT { $$ = Attribute::ZExt; }
| ZEXT { $$ = Attribute::ZExt; }
| SIGNEXT { $$ = Attribute::SExt; }
| SEXT { $$ = Attribute::SExt; }
| INREG { $$ = Attribute::InReg; }
| SRET { $$ = Attribute::StructRet; }
| NOALIAS { $$ = Attribute::NoAlias; }
| BYVAL { $$ = Attribute::ByVal; }
| NEST { $$ = Attribute::Nest; }
| ALIGN EUINT64VAL { $$ =
ParamAttr::constructAlignmentFromInt($2); }
Attribute::constructAlignmentFromInt($2); }
;
OptParamAttrs : /* empty */ { $$ = ParamAttr::None; }
| OptParamAttrs ParamAttr {
OptAttributes : /* empty */ { $$ = Attribute::None; }
| OptAttributes Attribute {
$$ = $1 | $2;
}
;
FuncAttr : NORETURN { $$ = ParamAttr::NoReturn; }
| NOUNWIND { $$ = ParamAttr::NoUnwind; }
| INREG { $$ = ParamAttr::InReg; }
| ZEROEXT { $$ = ParamAttr::ZExt; }
| SIGNEXT { $$ = ParamAttr::SExt; }
| READNONE { $$ = ParamAttr::ReadNone; }
| READONLY { $$ = ParamAttr::ReadOnly; }
FuncAttr : NORETURN { $$ = Attribute::NoReturn; }
| NOUNWIND { $$ = Attribute::NoUnwind; }
| INREG { $$ = Attribute::InReg; }
| ZEROEXT { $$ = Attribute::ZExt; }
| SIGNEXT { $$ = Attribute::SExt; }
| READNONE { $$ = Attribute::ReadNone; }
| READONLY { $$ = Attribute::ReadOnly; }
;
OptFuncAttrs : /* empty */ { $$ = ParamAttr::None; }
OptFuncAttrs : /* empty */ { $$ = Attribute::None; }
| OptFuncAttrs FuncAttr {
$$ = $1 | $2;
}
@ -1297,23 +1297,23 @@ OptFuncAttrs : /* empty */ { $$ = ParamAttr::None; }
FuncNoteList : FuncNote { $$ = $1; }
| FuncNoteList ',' FuncNote {
unsigned tmp = $1 | $3;
if ($3 == FnAttr::NoInline
&& ($1 & FnAttr::AlwaysInline))
if ($3 == Attribute::NoInline
&& ($1 & Attribute::AlwaysInline))
GEN_ERROR("Function Notes may include only one inline notes!")
if ($3 == FnAttr::AlwaysInline
&& ($1 & FnAttr::NoInline))
if ($3 == Attribute::AlwaysInline
&& ($1 & Attribute::NoInline))
GEN_ERROR("Function Notes may include only one inline notes!")
$$ = tmp;
CHECK_FOR_ERROR
}
;
FuncNote : INLINE '=' NEVER { $$ = FnAttr::NoInline; }
| INLINE '=' ALWAYS { $$ = FnAttr::AlwaysInline; }
| OPTIMIZEFORSIZE { $$ = FnAttr::OptimizeForSize; }
FuncNote : INLINE '=' NEVER { $$ = Attribute::NoInline; }
| INLINE '=' ALWAYS { $$ = Attribute::AlwaysInline; }
| OPTIMIZEFORSIZE { $$ = Attribute::OptimizeForSize; }
;
OptFuncNotes : /* empty */ { $$ = FnAttr::None; }
OptFuncNotes : /* empty */ { $$ = Attribute::None; }
| FNNOTE '(' FuncNoteList ')' {
$$ = $3;
}
@ -1509,11 +1509,11 @@ Types
;
ArgType
: Types OptParamAttrs {
: Types OptAttributes {
// Allow but ignore attributes on function types; this permits auto-upgrade.
// FIXME: remove in LLVM 3.0.
$$.Ty = $1;
$$.Attrs = ParamAttr::None;
$$.Attrs = Attribute::None;
}
;
@ -1545,14 +1545,14 @@ ArgTypeListI
: ArgTypeList
| ArgTypeList ',' DOTDOTDOT {
$$=$1;
TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
TWA.Ty = new PATypeHolder(Type::VoidTy);
$$->push_back(TWA);
CHECK_FOR_ERROR
}
| DOTDOTDOT {
$$ = new TypeWithAttrsList;
TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
TWA.Ty = new PATypeHolder(Type::VoidTy);
$$->push_back(TWA);
CHECK_FOR_ERROR
@ -2285,7 +2285,7 @@ LibList : LibList ',' STRINGCONSTANT {
// Rules to match Function Headers
//===----------------------------------------------------------------------===//
ArgListH : ArgListH ',' Types OptParamAttrs OptLocalName {
ArgListH : ArgListH ',' Types OptAttributes OptLocalName {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
if (!(*$3)->isFirstClassType())
@ -2295,7 +2295,7 @@ ArgListH : ArgListH ',' Types OptParamAttrs OptLocalName {
$1->push_back(E);
CHECK_FOR_ERROR
}
| Types OptParamAttrs OptLocalName {
| Types OptAttributes OptLocalName {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription());
if (!(*$1)->isFirstClassType())
@ -2315,7 +2315,7 @@ ArgList : ArgListH {
struct ArgListEntry E;
E.Ty = new PATypeHolder(Type::VoidTy);
E.Name = 0;
E.Attrs = ParamAttr::None;
E.Attrs = Attribute::None;
$$->push_back(E);
CHECK_FOR_ERROR
}
@ -2324,7 +2324,7 @@ ArgList : ArgListH {
struct ArgListEntry E;
E.Ty = new PATypeHolder(Type::VoidTy);
E.Name = 0;
E.Attrs = ParamAttr::None;
E.Attrs = Attribute::None;
$$->push_back(E);
CHECK_FOR_ERROR
}
@ -2347,9 +2347,9 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
GEN_ERROR("Invalid result type for LLVM function");
std::vector<const Type*> ParamTypeList;
SmallVector<FnAttributeWithIndex, 8> Attrs;
if ($7 != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(0, $7));
SmallVector<AttributeWithIndex, 8> Attrs;
if ($7 != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(0, $7));
if ($5) { // If there are arguments...
unsigned index = 1;
for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I, ++index) {
@ -2357,17 +2357,17 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
ParamTypeList.push_back(Ty);
if (Ty != Type::VoidTy && I->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, I->Attrs));
if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
}
}
bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
if (isVarArg) ParamTypeList.pop_back();
PAListPtr PAL;
AttrListPtr PAL;
if (!Attrs.empty())
PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg);
const PointerType *PFT = PointerType::getUnqual(FT);
@ -2386,7 +2386,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
// Move the function to the end of the list, from whereever it was
// previously inserted.
Fn = cast<Function>(FWRef);
assert(Fn->getParamAttrs().isEmpty() &&
assert(Fn->getAttributes().isEmpty() &&
"Forward reference has parameter attributes!");
CurModule.CurrentModule->getFunctionList().remove(Fn);
CurModule.CurrentModule->getFunctionList().push_back(Fn);
@ -2396,7 +2396,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
// The existing function doesn't have the same type. This is an overload
// error.
GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
} else if (Fn->getParamAttrs() != PAL) {
} else if (Fn->getAttributes() != PAL) {
// The existing function doesn't have the same parameter attributes.
// This is an overload error.
GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
@ -2426,7 +2426,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
Fn->setVisibility(CurFun.Visibility);
}
Fn->setCallingConv($1);
Fn->setParamAttrs(PAL);
Fn->setAttributes(PAL);
Fn->setAlignment($9);
if ($8) {
Fn->setSection(*$8);
@ -2861,9 +2861,9 @@ BBTerminatorInst :
BasicBlock *Except = getBBVal($14);
CHECK_FOR_ERROR
SmallVector<FnAttributeWithIndex, 8> Attrs;
if ($8 != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(0, $8));
SmallVector<AttributeWithIndex, 8> Attrs;
if ($8 != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(0, $8));
// Check the arguments
ValueList Args;
@ -2885,30 +2885,30 @@ BBTerminatorInst :
GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
(*I)->getDescription() + "'");
Args.push_back(ArgI->Val);
if (ArgI->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, ArgI->Attrs));
if (ArgI->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
}
if (Ty->isVarArg()) {
if (I == E)
for (; ArgI != ArgE; ++ArgI, ++index) {
Args.push_back(ArgI->Val); // push the remaining varargs
if (ArgI->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, ArgI->Attrs));
if (ArgI->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
}
} else if (I != E || ArgI != ArgE)
GEN_ERROR("Invalid number of parameters detected");
}
PAListPtr PAL;
AttrListPtr PAL;
if (!Attrs.empty())
PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
// Create the InvokeInst
InvokeInst *II = InvokeInst::Create(V, Normal, Except,
Args.begin(), Args.end());
II->setCallingConv($2);
II->setParamAttrs(PAL);
II->setAttributes(PAL);
$$ = II;
delete $6;
CHECK_FOR_ERROR
@ -2991,8 +2991,8 @@ PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
};
ParamList : Types OptParamAttrs ValueRef OptParamAttrs {
// FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
ParamList : Types OptAttributes ValueRef OptAttributes {
// FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription());
// Used for call and invoke instructions
@ -3002,16 +3002,16 @@ ParamList : Types OptParamAttrs ValueRef OptParamAttrs {
delete $1;
CHECK_FOR_ERROR
}
| LABEL OptParamAttrs ValueRef OptParamAttrs {
// FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
| LABEL OptAttributes ValueRef OptAttributes {
// FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
// Labels are only valid in ASMs
$$ = new ParamList();
ParamListEntry E; E.Attrs = $2 | $4; E.Val = getBBVal($3);
$$->push_back(E);
CHECK_FOR_ERROR
}
| ParamList ',' Types OptParamAttrs ValueRef OptParamAttrs {
// FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
| ParamList ',' Types OptAttributes ValueRef OptAttributes {
// FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
$$ = $1;
@ -3020,8 +3020,8 @@ ParamList : Types OptParamAttrs ValueRef OptParamAttrs {
delete $3;
CHECK_FOR_ERROR
}
| ParamList ',' LABEL OptParamAttrs ValueRef OptParamAttrs {
// FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
| ParamList ',' LABEL OptAttributes ValueRef OptAttributes {
// FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
$$ = $1;
ParamListEntry E; E.Attrs = $4 | $6; E.Val = getBBVal($5);
$$->push_back(E);
@ -3258,10 +3258,10 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
theF->getName() + "'");
}
// Set up the ParamAttrs for the function
SmallVector<FnAttributeWithIndex, 8> Attrs;
if ($8 != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(0, $8));
// Set up the Attributes for the function
SmallVector<AttributeWithIndex, 8> Attrs;
if ($8 != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(0, $8));
// Check the arguments
ValueList Args;
if ($6->empty()) { // Has no arguments?
@ -3282,30 +3282,30 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
(*I)->getDescription() + "'");
Args.push_back(ArgI->Val);
if (ArgI->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, ArgI->Attrs));
if (ArgI->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
}
if (Ty->isVarArg()) {
if (I == E)
for (; ArgI != ArgE; ++ArgI, ++index) {
Args.push_back(ArgI->Val); // push the remaining varargs
if (ArgI->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, ArgI->Attrs));
if (ArgI->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
}
} else if (I != E || ArgI != ArgE)
GEN_ERROR("Invalid number of parameters detected");
}
// Finish off the ParamAttrs and check them
PAListPtr PAL;
// Finish off the Attributes and check them
AttrListPtr PAL;
if (!Attrs.empty())
PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
// Create the call node
CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
CI->setTailCall($1);
CI->setCallingConv($2);
CI->setParamAttrs(PAL);
CI->setAttributes(PAL);
$$ = CI;
delete $6;
delete $3;

View File

@ -994,7 +994,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
llvm::GlobalValue::LinkageTypes Linkage;
llvm::GlobalValue::VisibilityTypes Visibility;
llvm::Attributes ParamAttrs;
llvm::Attributes Attributes;
llvm::APInt *APIntVal;
int64_t SInt64Val;
uint64_t UInt64Val;
@ -1088,10 +1088,10 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
%token X86_SSECALLCC_TOK
%token DATALAYOUT
%type <UIntVal> OptCallingConv LocalNumber
%type <ParamAttrs> OptParamAttrs ParamAttr
%type <ParamAttrs> OptFuncAttrs FuncAttr
%type <ParamAttrs> OptFuncNotes FuncNote
%type <ParamAttrs> FuncNoteList
%type <Attributes> OptAttributes Attribute
%type <Attributes> OptFuncAttrs FuncAttr
%type <Attributes> OptFuncNotes FuncNote
%type <Attributes> FuncNoteList
// Basic Block Terminating Operators
%token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
@ -1260,35 +1260,35 @@ OptCallingConv : /*empty*/ { $$ = CallingConv::C; } |
CHECK_FOR_ERROR
};
ParamAttr : ZEROEXT { $$ = ParamAttr::ZExt; }
| ZEXT { $$ = ParamAttr::ZExt; }
| SIGNEXT { $$ = ParamAttr::SExt; }
| SEXT { $$ = ParamAttr::SExt; }
| INREG { $$ = ParamAttr::InReg; }
| SRET { $$ = ParamAttr::StructRet; }
| NOALIAS { $$ = ParamAttr::NoAlias; }
| BYVAL { $$ = ParamAttr::ByVal; }
| NEST { $$ = ParamAttr::Nest; }
Attribute : ZEROEXT { $$ = Attribute::ZExt; }
| ZEXT { $$ = Attribute::ZExt; }
| SIGNEXT { $$ = Attribute::SExt; }
| SEXT { $$ = Attribute::SExt; }
| INREG { $$ = Attribute::InReg; }
| SRET { $$ = Attribute::StructRet; }
| NOALIAS { $$ = Attribute::NoAlias; }
| BYVAL { $$ = Attribute::ByVal; }
| NEST { $$ = Attribute::Nest; }
| ALIGN EUINT64VAL { $$ =
ParamAttr::constructAlignmentFromInt($2); }
Attribute::constructAlignmentFromInt($2); }
;
OptParamAttrs : /* empty */ { $$ = ParamAttr::None; }
| OptParamAttrs ParamAttr {
OptAttributes : /* empty */ { $$ = Attribute::None; }
| OptAttributes Attribute {
$$ = $1 | $2;
}
;
FuncAttr : NORETURN { $$ = ParamAttr::NoReturn; }
| NOUNWIND { $$ = ParamAttr::NoUnwind; }
| INREG { $$ = ParamAttr::InReg; }
| ZEROEXT { $$ = ParamAttr::ZExt; }
| SIGNEXT { $$ = ParamAttr::SExt; }
| READNONE { $$ = ParamAttr::ReadNone; }
| READONLY { $$ = ParamAttr::ReadOnly; }
FuncAttr : NORETURN { $$ = Attribute::NoReturn; }
| NOUNWIND { $$ = Attribute::NoUnwind; }
| INREG { $$ = Attribute::InReg; }
| ZEROEXT { $$ = Attribute::ZExt; }
| SIGNEXT { $$ = Attribute::SExt; }
| READNONE { $$ = Attribute::ReadNone; }
| READONLY { $$ = Attribute::ReadOnly; }
;
OptFuncAttrs : /* empty */ { $$ = ParamAttr::None; }
OptFuncAttrs : /* empty */ { $$ = Attribute::None; }
| OptFuncAttrs FuncAttr {
$$ = $1 | $2;
}
@ -1297,23 +1297,23 @@ OptFuncAttrs : /* empty */ { $$ = ParamAttr::None; }
FuncNoteList : FuncNote { $$ = $1; }
| FuncNoteList ',' FuncNote {
unsigned tmp = $1 | $3;
if ($3 == FnAttr::NoInline
&& ($1 & FnAttr::AlwaysInline))
if ($3 == Attribute::NoInline
&& ($1 & Attribute::AlwaysInline))
GEN_ERROR("Function Notes may include only one inline notes!")
if ($3 == FnAttr::AlwaysInline
&& ($1 & FnAttr::NoInline))
if ($3 == Attribute::AlwaysInline
&& ($1 & Attribute::NoInline))
GEN_ERROR("Function Notes may include only one inline notes!")
$$ = tmp;
CHECK_FOR_ERROR
}
;
FuncNote : INLINE '=' NEVER { $$ = FnAttr::NoInline; }
| INLINE '=' ALWAYS { $$ = FnAttr::AlwaysInline; }
| OPTIMIZEFORSIZE { $$ = FnAttr::OptimizeForSize; }
FuncNote : INLINE '=' NEVER { $$ = Attribute::NoInline; }
| INLINE '=' ALWAYS { $$ = Attribute::AlwaysInline; }
| OPTIMIZEFORSIZE { $$ = Attribute::OptimizeForSize; }
;
OptFuncNotes : /* empty */ { $$ = FnAttr::None; }
OptFuncNotes : /* empty */ { $$ = Attribute::None; }
| FNNOTE '(' FuncNoteList ')' {
$$ = $3;
}
@ -1509,11 +1509,11 @@ Types
;
ArgType
: Types OptParamAttrs {
: Types OptAttributes {
// Allow but ignore attributes on function types; this permits auto-upgrade.
// FIXME: remove in LLVM 3.0.
$$.Ty = $1;
$$.Attrs = ParamAttr::None;
$$.Attrs = Attribute::None;
}
;
@ -1545,14 +1545,14 @@ ArgTypeListI
: ArgTypeList
| ArgTypeList ',' DOTDOTDOT {
$$=$1;
TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
TWA.Ty = new PATypeHolder(Type::VoidTy);
$$->push_back(TWA);
CHECK_FOR_ERROR
}
| DOTDOTDOT {
$$ = new TypeWithAttrsList;
TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
TypeWithAttrs TWA; TWA.Attrs = Attribute::None;
TWA.Ty = new PATypeHolder(Type::VoidTy);
$$->push_back(TWA);
CHECK_FOR_ERROR
@ -2285,7 +2285,7 @@ LibList : LibList ',' STRINGCONSTANT {
// Rules to match Function Headers
//===----------------------------------------------------------------------===//
ArgListH : ArgListH ',' Types OptParamAttrs OptLocalName {
ArgListH : ArgListH ',' Types OptAttributes OptLocalName {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
if (!(*$3)->isFirstClassType())
@ -2295,7 +2295,7 @@ ArgListH : ArgListH ',' Types OptParamAttrs OptLocalName {
$1->push_back(E);
CHECK_FOR_ERROR
}
| Types OptParamAttrs OptLocalName {
| Types OptAttributes OptLocalName {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription());
if (!(*$1)->isFirstClassType())
@ -2315,7 +2315,7 @@ ArgList : ArgListH {
struct ArgListEntry E;
E.Ty = new PATypeHolder(Type::VoidTy);
E.Name = 0;
E.Attrs = ParamAttr::None;
E.Attrs = Attribute::None;
$$->push_back(E);
CHECK_FOR_ERROR
}
@ -2324,7 +2324,7 @@ ArgList : ArgListH {
struct ArgListEntry E;
E.Ty = new PATypeHolder(Type::VoidTy);
E.Name = 0;
E.Attrs = ParamAttr::None;
E.Attrs = Attribute::None;
$$->push_back(E);
CHECK_FOR_ERROR
}
@ -2347,9 +2347,9 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
GEN_ERROR("Invalid result type for LLVM function");
std::vector<const Type*> ParamTypeList;
SmallVector<FnAttributeWithIndex, 8> Attrs;
if ($7 != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(0, $7));
SmallVector<AttributeWithIndex, 8> Attrs;
if ($7 != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(0, $7));
if ($5) { // If there are arguments...
unsigned index = 1;
for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I, ++index) {
@ -2357,17 +2357,17 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
ParamTypeList.push_back(Ty);
if (Ty != Type::VoidTy && I->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, I->Attrs));
if (Ty != Type::VoidTy && I->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, I->Attrs));
}
}
bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
if (isVarArg) ParamTypeList.pop_back();
PAListPtr PAL;
AttrListPtr PAL;
if (!Attrs.empty())
PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg);
const PointerType *PFT = PointerType::getUnqual(FT);
@ -2386,7 +2386,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
// Move the function to the end of the list, from whereever it was
// previously inserted.
Fn = cast<Function>(FWRef);
assert(Fn->getParamAttrs().isEmpty() &&
assert(Fn->getAttributes().isEmpty() &&
"Forward reference has parameter attributes!");
CurModule.CurrentModule->getFunctionList().remove(Fn);
CurModule.CurrentModule->getFunctionList().push_back(Fn);
@ -2396,7 +2396,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
// The existing function doesn't have the same type. This is an overload
// error.
GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
} else if (Fn->getParamAttrs() != PAL) {
} else if (Fn->getAttributes() != PAL) {
// The existing function doesn't have the same parameter attributes.
// This is an overload error.
GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
@ -2426,7 +2426,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
Fn->setVisibility(CurFun.Visibility);
}
Fn->setCallingConv($1);
Fn->setParamAttrs(PAL);
Fn->setAttributes(PAL);
Fn->setAlignment($9);
if ($8) {
Fn->setSection(*$8);
@ -2861,9 +2861,9 @@ BBTerminatorInst :
BasicBlock *Except = getBBVal($14);
CHECK_FOR_ERROR
SmallVector<FnAttributeWithIndex, 8> Attrs;
if ($8 != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(0, $8));
SmallVector<AttributeWithIndex, 8> Attrs;
if ($8 != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(0, $8));
// Check the arguments
ValueList Args;
@ -2885,30 +2885,30 @@ BBTerminatorInst :
GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
(*I)->getDescription() + "'");
Args.push_back(ArgI->Val);
if (ArgI->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, ArgI->Attrs));
if (ArgI->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
}
if (Ty->isVarArg()) {
if (I == E)
for (; ArgI != ArgE; ++ArgI, ++index) {
Args.push_back(ArgI->Val); // push the remaining varargs
if (ArgI->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, ArgI->Attrs));
if (ArgI->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
}
} else if (I != E || ArgI != ArgE)
GEN_ERROR("Invalid number of parameters detected");
}
PAListPtr PAL;
AttrListPtr PAL;
if (!Attrs.empty())
PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
// Create the InvokeInst
InvokeInst *II = InvokeInst::Create(V, Normal, Except,
Args.begin(), Args.end());
II->setCallingConv($2);
II->setParamAttrs(PAL);
II->setAttributes(PAL);
$$ = II;
delete $6;
CHECK_FOR_ERROR
@ -2991,8 +2991,8 @@ PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
};
ParamList : Types OptParamAttrs ValueRef OptParamAttrs {
// FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
ParamList : Types OptAttributes ValueRef OptAttributes {
// FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription());
// Used for call and invoke instructions
@ -3002,16 +3002,16 @@ ParamList : Types OptParamAttrs ValueRef OptParamAttrs {
delete $1;
CHECK_FOR_ERROR
}
| LABEL OptParamAttrs ValueRef OptParamAttrs {
// FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
| LABEL OptAttributes ValueRef OptAttributes {
// FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
// Labels are only valid in ASMs
$$ = new ParamList();
ParamListEntry E; E.Attrs = $2 | $4; E.Val = getBBVal($3);
$$->push_back(E);
CHECK_FOR_ERROR
}
| ParamList ',' Types OptParamAttrs ValueRef OptParamAttrs {
// FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
| ParamList ',' Types OptAttributes ValueRef OptAttributes {
// FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
$$ = $1;
@ -3020,8 +3020,8 @@ ParamList : Types OptParamAttrs ValueRef OptParamAttrs {
delete $3;
CHECK_FOR_ERROR
}
| ParamList ',' LABEL OptParamAttrs ValueRef OptParamAttrs {
// FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
| ParamList ',' LABEL OptAttributes ValueRef OptAttributes {
// FIXME: Remove trailing OptAttributes in LLVM 3.0, it was a mistake in 2.0
$$ = $1;
ParamListEntry E; E.Attrs = $4 | $6; E.Val = getBBVal($5);
$$->push_back(E);
@ -3258,10 +3258,10 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
theF->getName() + "'");
}
// Set up the ParamAttrs for the function
SmallVector<FnAttributeWithIndex, 8> Attrs;
if ($8 != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(0, $8));
// Set up the Attributes for the function
SmallVector<AttributeWithIndex, 8> Attrs;
if ($8 != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(0, $8));
// Check the arguments
ValueList Args;
if ($6->empty()) { // Has no arguments?
@ -3282,30 +3282,30 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
(*I)->getDescription() + "'");
Args.push_back(ArgI->Val);
if (ArgI->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, ArgI->Attrs));
if (ArgI->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
}
if (Ty->isVarArg()) {
if (I == E)
for (; ArgI != ArgE; ++ArgI, ++index) {
Args.push_back(ArgI->Val); // push the remaining varargs
if (ArgI->Attrs != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(index, ArgI->Attrs));
if (ArgI->Attrs != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(index, ArgI->Attrs));
}
} else if (I != E || ArgI != ArgE)
GEN_ERROR("Invalid number of parameters detected");
}
// Finish off the ParamAttrs and check them
PAListPtr PAL;
// Finish off the Attributes and check them
AttrListPtr PAL;
if (!Attrs.empty())
PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
// Create the call node
CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
CI->setTailCall($1);
CI->setCallingConv($2);
CI->setParamAttrs(PAL);
CI->setAttributes(PAL);
$$ = CI;
delete $6;
delete $3;

View File

@ -32,7 +32,7 @@ void BitcodeReader::FreeState() {
std::vector<PATypeHolder>().swap(TypeList);
ValueList.clear();
std::vector<PAListPtr>().swap(ParamAttrs);
std::vector<AttrListPtr>().swap(Attributes);
std::vector<BasicBlock*>().swap(FunctionBBs);
std::vector<Function*>().swap(FunctionsWithBodies);
DeferredFunctionInfo.clear();
@ -313,16 +313,16 @@ const Type *BitcodeReader::getTypeByID(unsigned ID, bool isTypeTable) {
// Functions for parsing blocks from the bitcode file
//===----------------------------------------------------------------------===//
bool BitcodeReader::ParseParamAttrBlock() {
bool BitcodeReader::ParseAttributeBlock() {
if (Stream.EnterSubBlock(bitc::PARAMATTR_BLOCK_ID))
return Error("Malformed block record");
if (!ParamAttrs.empty())
if (!Attributes.empty())
return Error("Multiple PARAMATTR blocks found!");
SmallVector<uint64_t, 64> Record;
SmallVector<FnAttributeWithIndex, 8> Attrs;
SmallVector<AttributeWithIndex, 8> Attrs;
// Read all the records.
while (1) {
@ -356,11 +356,11 @@ bool BitcodeReader::ParseParamAttrBlock() {
return Error("Invalid ENTRY record");
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
if (Record[i+1] != ParamAttr::None)
Attrs.push_back(FnAttributeWithIndex::get(Record[i], Record[i+1]));
if (Record[i+1] != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(Record[i], Record[i+1]));
}
ParamAttrs.push_back(PAListPtr::get(Attrs.begin(), Attrs.end()));
Attributes.push_back(AttrListPtr::get(Attrs.begin(), Attrs.end()));
Attrs.clear();
break;
}
@ -1030,7 +1030,7 @@ bool BitcodeReader::ParseModule(const std::string &ModuleID) {
return Error("Malformed BlockInfoBlock");
break;
case bitc::PARAMATTR_BLOCK_ID:
if (ParseParamAttrBlock())
if (ParseAttributeBlock())
return true;
break;
case bitc::TYPE_BLOCK_ID:
@ -1183,7 +1183,7 @@ bool BitcodeReader::ParseModule(const std::string &ModuleID) {
Func->setCallingConv(Record[1]);
bool isProto = Record[2];
Func->setLinkage(GetDecodedLinkage(Record[3]));
Func->setParamAttrs(getParamAttrs(Record[4]));
Func->setAttributes(getAttributes(Record[4]));
Func->setAlignment((1 << Record[5]) >> 1);
if (Record[6]) {
@ -1695,7 +1695,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
case bitc::FUNC_CODE_INST_INVOKE: {
// INVOKE: [attrs, cc, normBB, unwindBB, fnty, op0,op1,op2, ...]
if (Record.size() < 4) return Error("Invalid INVOKE record");
PAListPtr PAL = getParamAttrs(Record[0]);
AttrListPtr PAL = getAttributes(Record[0]);
unsigned CCInfo = Record[1];
BasicBlock *NormalBB = getBasicBlock(Record[2]);
BasicBlock *UnwindBB = getBasicBlock(Record[3]);
@ -1736,7 +1736,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
I = InvokeInst::Create(Callee, NormalBB, UnwindBB,
Ops.begin(), Ops.end());
cast<InvokeInst>(I)->setCallingConv(CCInfo);
cast<InvokeInst>(I)->setParamAttrs(PAL);
cast<InvokeInst>(I)->setAttributes(PAL);
break;
}
case bitc::FUNC_CODE_INST_UNWIND: // UNWIND
@ -1834,7 +1834,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
if (Record.size() < 3)
return Error("Invalid CALL record");
PAListPtr PAL = getParamAttrs(Record[0]);
AttrListPtr PAL = getAttributes(Record[0]);
unsigned CCInfo = Record[1];
unsigned OpNum = 2;
@ -1874,7 +1874,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
I = CallInst::Create(Callee, Args.begin(), Args.end());
cast<CallInst>(I)->setCallingConv(CCInfo>>1);
cast<CallInst>(I)->setTailCall(CCInfo & 1);
cast<CallInst>(I)->setParamAttrs(PAL);
cast<CallInst>(I)->setAttributes(PAL);
break;
}
case bitc::FUNC_CODE_INST_VAARG: { // VAARG: [valistty, valist, instty]

View File

@ -136,10 +136,10 @@ class BitcodeReader : public ModuleProvider {
std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits;
std::vector<std::pair<GlobalAlias*, unsigned> > AliasInits;
/// ParamAttrs - The set of parameter attributes by index. Index zero in the
/// Attributes - The set of parameter attributes by index. Index zero in the
/// file is for null, and is thus not represented here. As such all indices
/// are off by one.
std::vector<PAListPtr> ParamAttrs;
std::vector<AttrListPtr> Attributes;
/// FunctionBBs - While parsing a function body, this is a list of the basic
/// blocks for the function.
@ -203,10 +203,10 @@ private:
if (ID >= FunctionBBs.size()) return 0; // Invalid ID
return FunctionBBs[ID];
}
PAListPtr getParamAttrs(unsigned i) const {
if (i-1 < ParamAttrs.size())
return ParamAttrs[i-1];
return PAListPtr();
AttrListPtr getAttributes(unsigned i) const {
if (i-1 < Attributes.size())
return Attributes[i-1];
return AttrListPtr();
}
/// getValueTypePair - Read a value/type pair out of the specified record from
@ -239,7 +239,7 @@ private:
bool ParseModule(const std::string &ModuleID);
bool ParseParamAttrBlock();
bool ParseAttributeBlock();
bool ParseTypeTable();
bool ParseTypeSymbolTable();
bool ParseValueSymbolTable();

View File

@ -108,18 +108,18 @@ static void WriteStringRecord(unsigned Code, const std::string &Str,
}
// Emit information about parameter attributes.
static void WriteParamAttrTable(const ValueEnumerator &VE,
static void WriteAttributeTable(const ValueEnumerator &VE,
BitstreamWriter &Stream) {
const std::vector<PAListPtr> &Attrs = VE.getParamAttrs();
const std::vector<AttrListPtr> &Attrs = VE.getAttributes();
if (Attrs.empty()) return;
Stream.EnterSubblock(bitc::PARAMATTR_BLOCK_ID, 3);
SmallVector<uint64_t, 64> Record;
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
const PAListPtr &A = Attrs[i];
const AttrListPtr &A = Attrs[i];
for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
const FnAttributeWithIndex &PAWI = A.getSlot(i);
const AttributeWithIndex &PAWI = A.getSlot(i);
Record.push_back(PAWI.Index);
Record.push_back(PAWI.Attrs);
}
@ -407,7 +407,7 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE,
Vals.push_back(F->getCallingConv());
Vals.push_back(F->isDeclaration());
Vals.push_back(getEncodedLinkage(F));
Vals.push_back(VE.getParamAttrID(F->getParamAttrs()));
Vals.push_back(VE.getAttributeID(F->getAttributes()));
Vals.push_back(Log2_32(F->getAlignment())+1);
Vals.push_back(F->hasSection() ? SectionMap[F->getSection()] : 0);
Vals.push_back(getEncodedVisibility(F));
@ -818,7 +818,7 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
Code = bitc::FUNC_CODE_INST_INVOKE;
const InvokeInst *II = cast<InvokeInst>(&I);
Vals.push_back(VE.getParamAttrID(II->getParamAttrs()));
Vals.push_back(VE.getAttributeID(II->getAttributes()));
Vals.push_back(II->getCallingConv());
Vals.push_back(VE.getValueID(I.getOperand(1))); // normal dest
Vals.push_back(VE.getValueID(I.getOperand(2))); // unwind dest
@ -892,7 +892,7 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
Code = bitc::FUNC_CODE_INST_CALL;
const CallInst *CI = cast<CallInst>(&I);
Vals.push_back(VE.getParamAttrID(CI->getParamAttrs()));
Vals.push_back(VE.getAttributeID(CI->getAttributes()));
Vals.push_back((CI->getCallingConv() << 1) | unsigned(CI->isTailCall()));
PushValueAndType(CI->getOperand(0), InstID, Vals, VE); // Callee
@ -1226,7 +1226,7 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream) {
WriteBlockInfo(VE, Stream);
// Emit information about parameter attributes.
WriteParamAttrTable(VE, Stream);
WriteAttributeTable(VE, Stream);
// Emit information describing all of the types in the module.
WriteTypeTable(VE, Stream);

View File

@ -47,7 +47,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
// Enumerate the functions.
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) {
EnumerateValue(I);
EnumerateParamAttrs(cast<Function>(I)->getParamAttrs());
EnumerateAttributes(cast<Function>(I)->getAttributes());
}
// Enumerate the aliases.
@ -90,9 +90,9 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
EnumerateOperandType(*OI);
EnumerateType(I->getType());
if (const CallInst *CI = dyn_cast<CallInst>(I))
EnumerateParamAttrs(CI->getParamAttrs());
EnumerateAttributes(CI->getAttributes());
else if (const InvokeInst *II = dyn_cast<InvokeInst>(I))
EnumerateParamAttrs(II->getParamAttrs());
EnumerateAttributes(II->getAttributes());
}
}
@ -247,14 +247,14 @@ void ValueEnumerator::EnumerateOperandType(const Value *V) {
}
}
void ValueEnumerator::EnumerateParamAttrs(const PAListPtr &PAL) {
void ValueEnumerator::EnumerateAttributes(const AttrListPtr &PAL) {
if (PAL.isEmpty()) return; // null is always 0.
// Do a lookup.
unsigned &Entry = ParamAttrMap[PAL.getRawPointer()];
unsigned &Entry = AttributeMap[PAL.getRawPointer()];
if (Entry == 0) {
// Never saw this before, add it.
ParamAttrs.push_back(PAL);
Entry = ParamAttrs.size();
Attributes.push_back(PAL);
Entry = Attributes.size();
}
}
@ -303,7 +303,7 @@ void ValueEnumerator::incorporateFunction(const Function &F) {
// Add the function's parameter attributes so they are available for use in
// the function's instruction.
EnumerateParamAttrs(F.getParamAttrs());
EnumerateAttributes(F.getAttributes());
FirstInstID = Values.size();

View File

@ -25,7 +25,7 @@ class Value;
class BasicBlock;
class Function;
class Module;
class PAListPtr;
class AttrListPtr;
class TypeSymbolTable;
class ValueSymbolTable;
@ -45,9 +45,9 @@ private:
ValueMapType ValueMap;
ValueList Values;
typedef DenseMap<void*, unsigned> ParamAttrMapType;
ParamAttrMapType ParamAttrMap;
std::vector<PAListPtr> ParamAttrs;
typedef DenseMap<void*, unsigned> AttributeMapType;
AttributeMapType AttributeMap;
std::vector<AttrListPtr> Attributes;
/// BasicBlocks - This contains all the basic blocks for the currently
/// incorporated function. Their reverse mapping is stored in ValueMap.
@ -76,10 +76,10 @@ public:
return I->second-1;
}
unsigned getParamAttrID(const PAListPtr &PAL) const {
unsigned getAttributeID(const AttrListPtr &PAL) const {
if (PAL.isEmpty()) return 0; // Null maps to zero.
ParamAttrMapType::const_iterator I = ParamAttrMap.find(PAL.getRawPointer());
assert(I != ParamAttrMap.end() && "ParamAttr not in ValueEnumerator!");
AttributeMapType::const_iterator I = AttributeMap.find(PAL.getRawPointer());
assert(I != AttributeMap.end() && "Attribute not in ValueEnumerator!");
return I->second;
}
@ -95,8 +95,8 @@ public:
const std::vector<const BasicBlock*> &getBasicBlocks() const {
return BasicBlocks;
}
const std::vector<PAListPtr> &getParamAttrs() const {
return ParamAttrs;
const std::vector<AttrListPtr> &getAttributes() const {
return Attributes;
}
/// PurgeAggregateValues - If there are any aggregate values at the end of the
@ -116,7 +116,7 @@ private:
void EnumerateValue(const Value *V);
void EnumerateType(const Type *T);
void EnumerateOperandType(const Value *V);
void EnumerateParamAttrs(const PAListPtr &PAL);
void EnumerateAttributes(const AttrListPtr &PAL);
void EnumerateTypeSymbolTable(const TypeSymbolTable &ST);
void EnumerateValueSymbolTable(const ValueSymbolTable &ST);

View File

@ -927,9 +927,9 @@ void SelectionDAGLowering::visitRet(ReturnInst &I) {
ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
const Function *F = I.getParent()->getParent();
if (F->paramHasAttr(0, ParamAttr::SExt))
if (F->paramHasAttr(0, Attribute::SExt))
ExtendKind = ISD::SIGN_EXTEND;
else if (F->paramHasAttr(0, ParamAttr::ZExt))
else if (F->paramHasAttr(0, Attribute::ZExt))
ExtendKind = ISD::ZERO_EXTEND;
getCopyToParts(DAG, SDValue(RetOp.getNode(), RetOp.getResNo() + j),
@ -937,7 +937,7 @@ void SelectionDAGLowering::visitRet(ReturnInst &I) {
// 'inreg' on function refers to return value
ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy();
if (F->paramHasAttr(0, ParamAttr::InReg))
if (F->paramHasAttr(0, Attribute::InReg))
Flags.setInReg();
for (unsigned i = 0; i < NumParts; ++i) {
NewValues.push_back(Parts[i]);
@ -4100,12 +4100,12 @@ void SelectionDAGLowering::LowerCallTo(CallSite CS, SDValue Callee,
Entry.Node = ArgNode; Entry.Ty = (*i)->getType();
unsigned attrInd = i - CS.arg_begin() + 1;
Entry.isSExt = CS.paramHasAttr(attrInd, ParamAttr::SExt);
Entry.isZExt = CS.paramHasAttr(attrInd, ParamAttr::ZExt);
Entry.isInReg = CS.paramHasAttr(attrInd, ParamAttr::InReg);
Entry.isSRet = CS.paramHasAttr(attrInd, ParamAttr::StructRet);
Entry.isNest = CS.paramHasAttr(attrInd, ParamAttr::Nest);
Entry.isByVal = CS.paramHasAttr(attrInd, ParamAttr::ByVal);
Entry.isSExt = CS.paramHasAttr(attrInd, Attribute::SExt);
Entry.isZExt = CS.paramHasAttr(attrInd, Attribute::ZExt);
Entry.isInReg = CS.paramHasAttr(attrInd, Attribute::InReg);
Entry.isSRet = CS.paramHasAttr(attrInd, Attribute::StructRet);
Entry.isNest = CS.paramHasAttr(attrInd, Attribute::Nest);
Entry.isByVal = CS.paramHasAttr(attrInd, Attribute::ByVal);
Entry.Alignment = CS.getParamAlignment(attrInd);
Args.push_back(Entry);
}
@ -4122,8 +4122,8 @@ void SelectionDAGLowering::LowerCallTo(CallSite CS, SDValue Callee,
std::pair<SDValue,SDValue> Result =
TLI.LowerCallTo(getRoot(), CS.getType(),
CS.paramHasAttr(0, ParamAttr::SExt),
CS.paramHasAttr(0, ParamAttr::ZExt),
CS.paramHasAttr(0, Attribute::SExt),
CS.paramHasAttr(0, Attribute::ZExt),
FTy->isVarArg(), CS.getCallingConv(),
IsTailCall && PerformTailCallOpt,
Callee, Args, DAG);
@ -5126,15 +5126,15 @@ void TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG,
unsigned OriginalAlignment =
getTargetData()->getABITypeAlignment(ArgTy);
if (F.paramHasAttr(j, ParamAttr::ZExt))
if (F.paramHasAttr(j, Attribute::ZExt))
Flags.setZExt();
if (F.paramHasAttr(j, ParamAttr::SExt))
if (F.paramHasAttr(j, Attribute::SExt))
Flags.setSExt();
if (F.paramHasAttr(j, ParamAttr::InReg))
if (F.paramHasAttr(j, Attribute::InReg))
Flags.setInReg();
if (F.paramHasAttr(j, ParamAttr::StructRet))
if (F.paramHasAttr(j, Attribute::StructRet))
Flags.setSRet();
if (F.paramHasAttr(j, ParamAttr::ByVal)) {
if (F.paramHasAttr(j, Attribute::ByVal)) {
Flags.setByVal();
const PointerType *Ty = cast<PointerType>(I->getType());
const Type *ElementTy = Ty->getElementType();
@ -5147,7 +5147,7 @@ void TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG,
Flags.setByValAlign(FrameAlign);
Flags.setByValSize(FrameSize);
}
if (F.paramHasAttr(j, ParamAttr::Nest))
if (F.paramHasAttr(j, Attribute::Nest))
Flags.setNest();
Flags.setOrigAlign(OriginalAlignment);
@ -5214,9 +5214,9 @@ void TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG,
Parts[j] = SDValue(Result, i++);
ISD::NodeType AssertOp = ISD::DELETED_NODE;
if (F.paramHasAttr(Idx, ParamAttr::SExt))
if (F.paramHasAttr(Idx, Attribute::SExt))
AssertOp = ISD::AssertSext;
else if (F.paramHasAttr(Idx, ParamAttr::ZExt))
else if (F.paramHasAttr(Idx, Attribute::ZExt))
AssertOp = ISD::AssertZext;
ArgValues.push_back(getCopyFromParts(DAG, &Parts[0], NumParts, PartVT, VT,

View File

@ -728,7 +728,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
unsigned j = 1;
for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end();
I != E; ++I, ++j)
if (Fn.paramHasAttr(j, ParamAttr::ByVal)) {
if (Fn.paramHasAttr(j, Attribute::ByVal)) {
if (EnableFastISelVerbose || EnableFastISelAbort)
cerr << "FastISel skips entry block due to byval argument\n";
SuppressFastISel = true;

View File

@ -162,7 +162,7 @@ namespace {
Args.begin(), Args.end(),
CI->getName(), CallBB);
II->setCallingConv(CI->getCallingConv());
II->setParamAttrs(CI->getParamAttrs());
II->setAttributes(CI->getAttributes());
CI->replaceAllUsesWith(II);
delete CI;
}

View File

@ -909,9 +909,9 @@ void Interpreter::visitCallSite(CallSite CS) {
// according to the parameter attributes
const Type *Ty = V->getType();
if (Ty->isInteger() && (ArgVals.back().IntVal.getBitWidth() < 32)) {
if (CS.paramHasAttr(pNum, ParamAttr::ZExt))
if (CS.paramHasAttr(pNum, Attribute::ZExt))
ArgVals.back().IntVal = ArgVals.back().IntVal.zext(32);
else if (CS.paramHasAttr(pNum, ParamAttr::SExt))
else if (CS.paramHasAttr(pNum, Attribute::SExt))
ArgVals.back().IntVal = ArgVals.back().IntVal.sext(32);
}
}

View File

@ -131,12 +131,12 @@ namespace {
bool isSigned = false,
const std::string &VariableName = "",
bool IgnoreName = false,
const PAListPtr &PAL = PAListPtr());
const AttrListPtr &PAL = AttrListPtr());
std::ostream &printType(std::ostream &Out, const Type *Ty,
bool isSigned = false,
const std::string &VariableName = "",
bool IgnoreName = false,
const PAListPtr &PAL = PAListPtr());
const AttrListPtr &PAL = AttrListPtr());
raw_ostream &printSimpleType(raw_ostream &Out, const Type *Ty,
bool isSigned,
const std::string &NameSoFar = "");
@ -145,7 +145,7 @@ namespace {
const std::string &NameSoFar = "");
void printStructReturnPointerFunctionType(raw_ostream &Out,
const PAListPtr &PAL,
const AttrListPtr &PAL,
const PointerType *Ty);
/// writeOperandDeref - Print the result of dereferencing the specified
@ -408,7 +408,7 @@ bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) {
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
/// print it as "Struct (*)(...)", for struct return functions.
void CWriter::printStructReturnPointerFunctionType(raw_ostream &Out,
const PAListPtr &PAL,
const AttrListPtr &PAL,
const PointerType *TheTy) {
const FunctionType *FTy = cast<FunctionType>(TheTy->getElementType());
std::stringstream FunctionInnards;
@ -422,12 +422,12 @@ void CWriter::printStructReturnPointerFunctionType(raw_ostream &Out,
if (PrintedType)
FunctionInnards << ", ";
const Type *ArgTy = *I;
if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
assert(isa<PointerType>(ArgTy));
ArgTy = cast<PointerType>(ArgTy)->getElementType();
}
printType(FunctionInnards, ArgTy,
/*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt), "");
/*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt), "");
PrintedType = true;
}
if (FTy->isVarArg()) {
@ -439,7 +439,7 @@ void CWriter::printStructReturnPointerFunctionType(raw_ostream &Out,
FunctionInnards << ')';
std::string tstr = FunctionInnards.str();
printType(Out, RetTy,
/*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
/*isSigned=*/PAL.paramHasAttr(0, Attribute::SExt), tstr);
}
raw_ostream &
@ -537,7 +537,7 @@ CWriter::printSimpleType(std::ostream &Out, const Type *Ty, bool isSigned,
//
raw_ostream &CWriter::printType(raw_ostream &Out, const Type *Ty,
bool isSigned, const std::string &NameSoFar,
bool IgnoreName, const PAListPtr &PAL) {
bool IgnoreName, const AttrListPtr &PAL) {
if (Ty->isPrimitiveType() || Ty->isInteger() || isa<VectorType>(Ty)) {
printSimpleType(Out, Ty, isSigned, NameSoFar);
return Out;
@ -558,14 +558,14 @@ raw_ostream &CWriter::printType(raw_ostream &Out, const Type *Ty,
for (FunctionType::param_iterator I = FTy->param_begin(),
E = FTy->param_end(); I != E; ++I) {
const Type *ArgTy = *I;
if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
assert(isa<PointerType>(ArgTy));
ArgTy = cast<PointerType>(ArgTy)->getElementType();
}
if (I != FTy->param_begin())
FunctionInnards << ", ";
printType(FunctionInnards, ArgTy,
/*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt), "");
/*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt), "");
++Idx;
}
if (FTy->isVarArg()) {
@ -577,7 +577,7 @@ raw_ostream &CWriter::printType(raw_ostream &Out, const Type *Ty,
FunctionInnards << ')';
std::string tstr = FunctionInnards.str();
printType(Out, FTy->getReturnType(),
/*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
/*isSigned=*/PAL.paramHasAttr(0, Attribute::SExt), tstr);
return Out;
}
case Type::StructTyID: {
@ -642,7 +642,7 @@ raw_ostream &CWriter::printType(raw_ostream &Out, const Type *Ty,
//
std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
bool isSigned, const std::string &NameSoFar,
bool IgnoreName, const PAListPtr &PAL) {
bool IgnoreName, const AttrListPtr &PAL) {
if (Ty->isPrimitiveType() || Ty->isInteger() || isa<VectorType>(Ty)) {
printSimpleType(Out, Ty, isSigned, NameSoFar);
return Out;
@ -663,14 +663,14 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
for (FunctionType::param_iterator I = FTy->param_begin(),
E = FTy->param_end(); I != E; ++I) {
const Type *ArgTy = *I;
if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
assert(isa<PointerType>(ArgTy));
ArgTy = cast<PointerType>(ArgTy)->getElementType();
}
if (I != FTy->param_begin())
FunctionInnards << ", ";
printType(FunctionInnards, ArgTy,
/*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt), "");
/*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt), "");
++Idx;
}
if (FTy->isVarArg()) {
@ -682,7 +682,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
FunctionInnards << ')';
std::string tstr = FunctionInnards.str();
printType(Out, FTy->getReturnType(),
/*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
/*isSigned=*/PAL.paramHasAttr(0, Attribute::SExt), tstr);
return Out;
}
case Type::StructTyID: {
@ -2162,7 +2162,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
// Loop over the arguments, printing them...
const FunctionType *FT = cast<FunctionType>(F->getFunctionType());
const PAListPtr &PAL = F->getParamAttrs();
const AttrListPtr &PAL = F->getAttributes();
std::stringstream FunctionInnards;
@ -2191,12 +2191,12 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
else
ArgName = "";
const Type *ArgTy = I->getType();
if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
ArgTy = cast<PointerType>(ArgTy)->getElementType();
ByValParams.insert(I);
}
printType(FunctionInnards, ArgTy,
/*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt),
/*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt),
ArgName);
PrintedArg = true;
++Idx;
@ -2218,12 +2218,12 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
for (; I != E; ++I) {
if (PrintedArg) FunctionInnards << ", ";
const Type *ArgTy = *I;
if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
assert(isa<PointerType>(ArgTy));
ArgTy = cast<PointerType>(ArgTy)->getElementType();
}
printType(FunctionInnards, ArgTy,
/*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt));
/*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt));
PrintedArg = true;
++Idx;
}
@ -2251,7 +2251,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
// Print out the return type and the signature built above.
printType(Out, RetTy,
/*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt),
/*isSigned=*/PAL.paramHasAttr(0, Attribute::SExt),
FunctionInnards.str());
}
@ -2844,7 +2844,7 @@ void CWriter::visitCallInst(CallInst &I) {
// If this is a call to a struct-return function, assign to the first
// parameter instead of passing it to the call.
const PAListPtr &PAL = I.getParamAttrs();
const AttrListPtr &PAL = I.getAttributes();
bool hasByVal = I.hasByValArgument();
bool isStructRet = I.hasStructRetAttr();
if (isStructRet) {
@ -2912,11 +2912,11 @@ void CWriter::visitCallInst(CallInst &I) {
(*AI)->getType() != FTy->getParamType(ArgNo)) {
Out << '(';
printType(Out, FTy->getParamType(ArgNo),
/*isSigned=*/PAL.paramHasAttr(ArgNo+1, ParamAttr::SExt));
/*isSigned=*/PAL.paramHasAttr(ArgNo+1, Attribute::SExt));
Out << ')';
}
// Check if the argument is expected to be passed by value.
if (I.paramHasAttr(ArgNo+1, ParamAttr::ByVal))
if (I.paramHasAttr(ArgNo+1, Attribute::ByVal))
writeOperandDeref(*AI);
else
writeOperand(*AI);

View File

@ -133,7 +133,7 @@ namespace {
std::string getCppName(const Value* val);
inline void printCppName(const Value* val);
void printParamAttrs(const PAListPtr &PAL, const std::string &name);
void printAttributes(const AttrListPtr &PAL, const std::string &name);
bool printTypeInternal(const Type* Ty);
inline void printType(const Type* Ty);
void printTypes(const Module* M);
@ -428,46 +428,46 @@ namespace {
printEscapedString(getCppName(val));
}
void CppWriter::printParamAttrs(const PAListPtr &PAL,
void CppWriter::printAttributes(const AttrListPtr &PAL,
const std::string &name) {
Out << "PAListPtr " << name << "_PAL;";
Out << "AttrListPtr " << name << "_PAL;";
nl(Out);
if (!PAL.isEmpty()) {
Out << '{'; in(); nl(Out);
Out << "SmallVector<FnAttributeWithIndex, 4> Attrs;"; nl(Out);
Out << "FnAttributeWithIndex PAWI;"; nl(Out);
Out << "SmallVector<AttributeWithIndex, 4> Attrs;"; nl(Out);
Out << "AttributeWithIndex PAWI;"; nl(Out);
for (unsigned i = 0; i < PAL.getNumSlots(); ++i) {
uint16_t index = PAL.getSlot(i).Index;
Attributes attrs = PAL.getSlot(i).Attrs;
Out << "PAWI.Index = " << index << "; PAWI.Attrs = 0 ";
if (attrs & ParamAttr::SExt)
Out << " | ParamAttr::SExt";
if (attrs & ParamAttr::ZExt)
Out << " | ParamAttr::ZExt";
if (attrs & ParamAttr::StructRet)
Out << " | ParamAttr::StructRet";
if (attrs & ParamAttr::InReg)
Out << " | ParamAttr::InReg";
if (attrs & ParamAttr::NoReturn)
Out << " | ParamAttr::NoReturn";
if (attrs & ParamAttr::NoUnwind)
Out << " | ParamAttr::NoUnwind";
if (attrs & ParamAttr::ByVal)
Out << " | ParamAttr::ByVal";
if (attrs & ParamAttr::NoAlias)
Out << " | ParamAttr::NoAlias";
if (attrs & ParamAttr::Nest)
Out << " | ParamAttr::Nest";
if (attrs & ParamAttr::ReadNone)
Out << " | ParamAttr::ReadNone";
if (attrs & ParamAttr::ReadOnly)
Out << " | ParamAttr::ReadOnly";
if (attrs & Attribute::SExt)
Out << " | Attribute::SExt";
if (attrs & Attribute::ZExt)
Out << " | Attribute::ZExt";
if (attrs & Attribute::StructRet)
Out << " | Attribute::StructRet";
if (attrs & Attribute::InReg)
Out << " | Attribute::InReg";
if (attrs & Attribute::NoReturn)
Out << " | Attribute::NoReturn";
if (attrs & Attribute::NoUnwind)
Out << " | Attribute::NoUnwind";
if (attrs & Attribute::ByVal)
Out << " | Attribute::ByVal";
if (attrs & Attribute::NoAlias)
Out << " | Attribute::NoAlias";
if (attrs & Attribute::Nest)
Out << " | Attribute::Nest";
if (attrs & Attribute::ReadNone)
Out << " | Attribute::ReadNone";
if (attrs & Attribute::ReadOnly)
Out << " | Attribute::ReadOnly";
Out << ";";
nl(Out);
Out << "Attrs.push_back(PAWI);";
nl(Out);
}
Out << name << "_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());";
Out << name << "_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());";
nl(Out);
out(); nl(Out);
Out << '}'; nl(Out);
@ -1127,8 +1127,8 @@ namespace {
nl(Out) << iName << "->setCallingConv(";
printCallingConv(inv->getCallingConv());
Out << ");";
printParamAttrs(inv->getParamAttrs(), iName);
Out << iName << "->setParamAttrs(" << iName << "_PAL);";
printAttributes(inv->getAttributes(), iName);
Out << iName << "->setAttributes(" << iName << "_PAL);";
nl(Out);
break;
}
@ -1390,8 +1390,8 @@ namespace {
nl(Out) << iName << "->setTailCall("
<< (call->isTailCall() ? "true":"false");
Out << ");";
printParamAttrs(call->getParamAttrs(), iName);
Out << iName << "->setParamAttrs(" << iName << "_PAL);";
printAttributes(call->getAttributes(), iName);
Out << iName << "->setAttributes(" << iName << "_PAL);";
nl(Out);
break;
}
@ -1614,9 +1614,9 @@ namespace {
Out << "}";
nl(Out);
}
printParamAttrs(F->getParamAttrs(), getCppName(F));
printAttributes(F->getAttributes(), getCppName(F));
printCppName(F);
Out << "->setParamAttrs(" << getCppName(F) << "_PAL);";
Out << "->setAttributes(" << getCppName(F) << "_PAL);";
nl(Out);
}

View File

@ -1392,7 +1392,7 @@ void MSILWriter::printStaticInitializerList() {
void MSILWriter::printFunction(const Function& F) {
bool isSigned = F.paramHasAttr(0, ParamAttr::SExt);
bool isSigned = F.paramHasAttr(0, Attribute::SExt);
Out << "\n.method static ";
Out << (F.hasInternalLinkage() ? "private " : "public ");
if (F.isVarArg()) Out << "vararg ";
@ -1403,7 +1403,7 @@ void MSILWriter::printFunction(const Function& F) {
unsigned ArgIdx = 1;
for (Function::const_arg_iterator I = F.arg_begin(), E = F.arg_end(); I!=E;
++I, ++ArgIdx) {
isSigned = F.paramHasAttr(ArgIdx, ParamAttr::SExt);
isSigned = F.paramHasAttr(ArgIdx, Attribute::SExt);
if (I!=F.arg_begin()) Out << ", ";
Out << getTypeName(I->getType(),isSigned) << getValueName(I);
}

View File

@ -71,7 +71,7 @@ static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
const Type* Ty = AI->getType();
// 'Dereference' type in case of byval parameter attribute
if (F->paramHasAttr(argNum, ParamAttr::ByVal))
if (F->paramHasAttr(argNum, Attribute::ByVal))
Ty = cast<PointerType>(Ty)->getElementType();
// Size should be aligned to DWORD boundary
@ -154,7 +154,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
SwitchToSection(TAI->SectionForGlobal(F));
unsigned FnAlign = OptimizeForSize ? 1 : 4;
if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize))
FnAlign = 1;
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");

View File

@ -54,7 +54,7 @@ static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
const Type* Ty = AI->getType();
// 'Dereference' type in case of byval parameter attribute
if (F->paramHasAttr(argNum, ParamAttr::ByVal))
if (F->paramHasAttr(argNum, Attribute::ByVal))
Ty = cast<PointerType>(Ty)->getElementType();
// Size should be aligned to DWORD boundary
@ -141,7 +141,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
SwitchToTextSection("_text", F);
unsigned FnAlign = OptimizeForSize ? 1 : 4;
if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize))
FnAlign = 1;
switch (F->getLinkage()) {
default: assert(0 && "Unsupported linkage type!");

View File

@ -898,16 +898,16 @@ bool X86FastISel::X86SelectCall(Instruction *I) {
return false;
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
if (CS.paramHasAttr(AttrInd, ParamAttr::SExt))
if (CS.paramHasAttr(AttrInd, Attribute::SExt))
Flags.setSExt();
if (CS.paramHasAttr(AttrInd, ParamAttr::ZExt))
if (CS.paramHasAttr(AttrInd, Attribute::ZExt))
Flags.setZExt();
// FIXME: Only handle *easy* calls for now.
if (CS.paramHasAttr(AttrInd, ParamAttr::InReg) ||
CS.paramHasAttr(AttrInd, ParamAttr::StructRet) ||
CS.paramHasAttr(AttrInd, ParamAttr::Nest) ||
CS.paramHasAttr(AttrInd, ParamAttr::ByVal))
if (CS.paramHasAttr(AttrInd, Attribute::InReg) ||
CS.paramHasAttr(AttrInd, Attribute::StructRet) ||
CS.paramHasAttr(AttrInd, Attribute::Nest) ||
CS.paramHasAttr(AttrInd, Attribute::ByVal))
return false;
const Type *ArgTy = (*i)->getType();

View File

@ -5757,7 +5757,7 @@ SDValue X86TargetLowering::LowerTRAMPOLINE(SDValue Op,
// Check that ECX wasn't needed by an 'inreg' parameter.
const FunctionType *FTy = Func->getFunctionType();
const PAListPtr &Attrs = Func->getParamAttrs();
const AttrListPtr &Attrs = Func->getAttributes();
if (!Attrs.isEmpty() && !Func->isVarArg()) {
unsigned InRegCount = 0;
@ -5765,7 +5765,7 @@ SDValue X86TargetLowering::LowerTRAMPOLINE(SDValue Op,
for (FunctionType::param_iterator I = FTy->param_begin(),
E = FTy->param_end(); I != E; ++I, ++Idx)
if (Attrs.paramHasAttr(Idx, ParamAttr::InReg))
if (Attrs.paramHasAttr(Idx, Attribute::InReg))
// FIXME: should only count parameters that are lowered to integers.
InRegCount += (TD->getTypeSizeInBits(*I) + 31) / 32;

View File

@ -105,10 +105,10 @@ bool AddReadAttrs::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
MadeChange = true;
// Clear out any existing attributes.
F->removeParamAttr(0, ParamAttr::ReadOnly | ParamAttr::ReadNone);
F->removeAttribute(0, Attribute::ReadOnly | Attribute::ReadNone);
// Add in the new attribute.
F->addParamAttr(0, ReadsMemory ? ParamAttr::ReadOnly : ParamAttr::ReadNone);
F->addAttribute(0, ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone);
if (ReadsMemory)
NumReadOnly++;

View File

@ -144,7 +144,7 @@ bool ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
SmallPtrSet<Argument*, 8> ArgsToPromote;
SmallPtrSet<Argument*, 8> ByValArgsToTransform;
for (unsigned i = 0; i != PointerArgs.size(); ++i) {
bool isByVal = F->paramHasAttr(PointerArgs[i].second+1, ParamAttr::ByVal);
bool isByVal = F->paramHasAttr(PointerArgs[i].second+1, Attribute::ByVal);
// If this is a byval argument, and if the aggregate type is small, just
// pass the elements, which is always safe.
@ -501,15 +501,15 @@ Function *ArgPromotion::DoPromotion(Function *F,
// what the new GEP/Load instructions we are inserting look like.
std::map<IndicesVector, LoadInst*> OriginalLoads;
// ParamAttrs - Keep track of the parameter attributes for the arguments
// Attributes - Keep track of the parameter attributes for the arguments
// that we are *not* promoting. For the ones that we do promote, the parameter
// attributes are lost
SmallVector<FnAttributeWithIndex, 8> ParamAttrsVec;
const PAListPtr &PAL = F->getParamAttrs();
SmallVector<AttributeWithIndex, 8> AttributesVec;
const AttrListPtr &PAL = F->getAttributes();
// Add any return attributes.
if (Attributes attrs = PAL.getParamAttrs(0))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, attrs));
if (Attributes attrs = PAL.getAttributes(0))
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
// First, determine the new argument list
unsigned ArgIndex = 1;
@ -525,8 +525,8 @@ Function *ArgPromotion::DoPromotion(Function *F,
} else if (!ArgsToPromote.count(I)) {
// Unchanged argument
Params.push_back(I->getType());
if (Attributes attrs = PAL.getParamAttrs(ArgIndex))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(Params.size(), attrs));
if (Attributes attrs = PAL.getAttributes(ArgIndex))
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), attrs));
} else if (I->use_empty()) {
// Dead argument (which are always marked as promotable)
++NumArgumentsDead;
@ -597,8 +597,8 @@ Function *ArgPromotion::DoPromotion(Function *F,
// Recompute the parameter attributes list based on the new arguments for
// the function.
NF->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end()));
ParamAttrsVec.clear();
NF->setAttributes(AttrListPtr::get(AttributesVec.begin(), AttributesVec.end()));
AttributesVec.clear();
F->getParent()->getFunctionList().insert(F, NF);
NF->takeName(F);
@ -618,11 +618,11 @@ Function *ArgPromotion::DoPromotion(Function *F,
while (!F->use_empty()) {
CallSite CS = CallSite::get(F->use_back());
Instruction *Call = CS.getInstruction();
const PAListPtr &CallPAL = CS.getParamAttrs();
const AttrListPtr &CallPAL = CS.getAttributes();
// Add any return attributes.
if (Attributes attrs = CallPAL.getParamAttrs(0))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, attrs));
if (Attributes attrs = CallPAL.getAttributes(0))
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
// Loop over the operands, inserting GEP and loads in the caller as
// appropriate.
@ -633,8 +633,8 @@ Function *ArgPromotion::DoPromotion(Function *F,
if (!ArgsToPromote.count(I) && !ByValArgsToTransform.count(I)) {
Args.push_back(*AI); // Unmodified argument
if (Attributes Attrs = CallPAL.getParamAttrs(ArgIndex))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(Args.size(), Attrs));
if (Attributes Attrs = CallPAL.getAttributes(ArgIndex))
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
} else if (ByValArgsToTransform.count(I)) {
// Emit a GEP and load for each element of the struct.
@ -688,8 +688,8 @@ Function *ArgPromotion::DoPromotion(Function *F,
// Push any varargs arguments on the list
for (; AI != CS.arg_end(); ++AI, ++ArgIndex) {
Args.push_back(*AI);
if (Attributes Attrs = CallPAL.getParamAttrs(ArgIndex))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(Args.size(), Attrs));
if (Attributes Attrs = CallPAL.getAttributes(ArgIndex))
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
}
Instruction *New;
@ -697,18 +697,18 @@ Function *ArgPromotion::DoPromotion(Function *F,
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
Args.begin(), Args.end(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(),
ParamAttrsVec.end()));
cast<InvokeInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(),
AttributesVec.end()));
} else {
New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(),
ParamAttrsVec.end()));
cast<CallInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(),
AttributesVec.end()));
if (cast<CallInst>(Call)->isTailCall())
cast<CallInst>(New)->setTailCall();
}
Args.clear();
ParamAttrsVec.clear();
AttributesVec.clear();
// Update the alias analysis implementation to know that we are replacing
// the old call with a new one.

View File

@ -224,12 +224,12 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
Args.assign(CS.arg_begin(), CS.arg_begin()+NumArgs);
// Drop any attributes that were on the vararg arguments.
PAListPtr PAL = CS.getParamAttrs();
AttrListPtr PAL = CS.getAttributes();
if (!PAL.isEmpty() && PAL.getSlot(PAL.getNumSlots() - 1).Index > NumArgs) {
SmallVector<FnAttributeWithIndex, 8> ParamAttrsVec;
SmallVector<AttributeWithIndex, 8> AttributesVec;
for (unsigned i = 0; PAL.getSlot(i).Index <= NumArgs; ++i)
ParamAttrsVec.push_back(PAL.getSlot(i));
PAL = PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end());
AttributesVec.push_back(PAL.getSlot(i));
PAL = AttrListPtr::get(AttributesVec.begin(), AttributesVec.end());
}
Instruction *New;
@ -237,11 +237,11 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
Args.begin(), Args.end(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setParamAttrs(PAL);
cast<InvokeInst>(New)->setAttributes(PAL);
} else {
New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setParamAttrs(PAL);
cast<CallInst>(New)->setAttributes(PAL);
if (cast<CallInst>(Call)->isTailCall())
cast<CallInst>(New)->setTailCall();
}
@ -589,11 +589,11 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
std::vector<const Type*> Params;
// Set up to build a new list of parameter attributes.
SmallVector<FnAttributeWithIndex, 8> ParamAttrsVec;
const PAListPtr &PAL = F->getParamAttrs();
SmallVector<AttributeWithIndex, 8> AttributesVec;
const AttrListPtr &PAL = F->getAttributes();
// The existing function return attributes.
Attributes RAttrs = PAL.getParamAttrs(0);
Attributes RAttrs = PAL.getAttributes(0);
// Find out the new return value.
@ -655,13 +655,13 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// here. Currently, this should not be possible, but special handling might be
// required when new return value attributes are added.
if (NRetTy == Type::VoidTy)
RAttrs &= ~ParamAttr::typeIncompatible(NRetTy);
RAttrs &= ~Attribute::typeIncompatible(NRetTy);
else
assert((RAttrs & ParamAttr::typeIncompatible(NRetTy)) == 0
assert((RAttrs & Attribute::typeIncompatible(NRetTy)) == 0
&& "Return attributes no longer compatible?");
if (RAttrs)
ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, RAttrs));
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
// Remember which arguments are still alive.
SmallVector<bool, 10> ArgAlive(FTy->getNumParams(), false);
@ -678,8 +678,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Get the original parameter attributes (skipping the first one, that is
// for the return value.
if (Attributes Attrs = PAL.getParamAttrs(i + 1))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(Params.size(), Attrs));
if (Attributes Attrs = PAL.getAttributes(i + 1))
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), Attrs));
} else {
++NumArgumentsEliminated;
DOUT << "DAE - Removing argument " << i << " (" << I->getNameStart()
@ -687,8 +687,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
}
}
// Reconstruct the ParamAttrsList based on the vector we constructed.
PAListPtr NewPAL = PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end());
// Reconstruct the AttributesList based on the vector we constructed.
AttrListPtr NewPAL = AttrListPtr::get(AttributesVec.begin(), AttributesVec.end());
// Work around LLVM bug PR56: the CWriter cannot emit varargs functions which
// have zero fixed arguments.
@ -712,7 +712,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, F->getLinkage());
NF->copyAttributesFrom(F);
NF->setParamAttrs(NewPAL);
NF->setAttributes(NewPAL);
// Insert the new function before the old function, so we won't be processing
// it again.
F->getParent()->getFunctionList().insert(F, NF);
@ -726,15 +726,15 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
CallSite CS = CallSite::get(F->use_back());
Instruction *Call = CS.getInstruction();
ParamAttrsVec.clear();
const PAListPtr &CallPAL = CS.getParamAttrs();
AttributesVec.clear();
const AttrListPtr &CallPAL = CS.getAttributes();
// The call return attributes.
Attributes RAttrs = CallPAL.getParamAttrs(0);
Attributes RAttrs = CallPAL.getAttributes(0);
// Adjust in case the function was changed to return void.
RAttrs &= ~ParamAttr::typeIncompatible(NF->getReturnType());
RAttrs &= ~Attribute::typeIncompatible(NF->getReturnType());
if (RAttrs)
ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, RAttrs));
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
// Declare these outside of the loops, so we can reuse them for the second
// loop, which loops the varargs.
@ -746,8 +746,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
if (ArgAlive[i]) {
Args.push_back(*I);
// Get original parameter attributes, but skip return attributes.
if (Attributes Attrs = CallPAL.getParamAttrs(i + 1))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(Args.size(), Attrs));
if (Attributes Attrs = CallPAL.getAttributes(i + 1))
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
}
if (ExtraArgHack)
@ -756,24 +756,24 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Push any varargs arguments on the list. Don't forget their attributes.
for (CallSite::arg_iterator E = CS.arg_end(); I != E; ++I, ++i) {
Args.push_back(*I);
if (Attributes Attrs = CallPAL.getParamAttrs(i + 1))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(Args.size(), Attrs));
if (Attributes Attrs = CallPAL.getAttributes(i + 1))
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
}
// Reconstruct the ParamAttrsList based on the vector we constructed.
PAListPtr NewCallPAL = PAListPtr::get(ParamAttrsVec.begin(),
ParamAttrsVec.end());
// Reconstruct the AttributesList based on the vector we constructed.
AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec.begin(),
AttributesVec.end());
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
Args.begin(), Args.end(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setParamAttrs(NewCallPAL);
cast<InvokeInst>(New)->setAttributes(NewCallPAL);
} else {
New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setParamAttrs(NewCallPAL);
cast<CallInst>(New)->setAttributes(NewCallPAL);
if (cast<CallInst>(Call)->isTailCall())
cast<CallInst>(New)->setTailCall();
}

View File

@ -1627,23 +1627,23 @@ static void ChangeCalleesToFastCall(Function *F) {
}
}
static PAListPtr StripNest(const PAListPtr &Attrs) {
static AttrListPtr StripNest(const AttrListPtr &Attrs) {
for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
if ((Attrs.getSlot(i).Attrs & ParamAttr::Nest) == 0)
if ((Attrs.getSlot(i).Attrs & Attribute::Nest) == 0)
continue;
// There can be only one.
return Attrs.removeAttr(Attrs.getSlot(i).Index, ParamAttr::Nest);
return Attrs.removeAttr(Attrs.getSlot(i).Index, Attribute::Nest);
}
return Attrs;
}
static void RemoveNestAttribute(Function *F) {
F->setParamAttrs(StripNest(F->getParamAttrs()));
F->setAttributes(StripNest(F->getAttributes()));
for (Value::use_iterator UI = F->use_begin(), E = F->use_end(); UI != E;++UI){
CallSite User(cast<Instruction>(*UI));
User.setParamAttrs(StripNest(User.getParamAttrs()));
User.setAttributes(StripNest(User.getAttributes()));
}
}
@ -1670,7 +1670,7 @@ bool GlobalOpt::OptimizeFunctions(Module &M) {
Changed = true;
}
if (F->getParamAttrs().hasAttrSomewhere(ParamAttr::Nest) &&
if (F->getAttributes().hasAttrSomewhere(Attribute::Nest) &&
OnlyCalledDirectly(F)) {
// The function is not used by a trampoline intrinsic, so it is safe
// to remove the 'nest' attribute.

View File

@ -63,7 +63,7 @@ bool AlwaysInliner::doInitialization(CallGraph &CG) {
for (Module::iterator I = M.begin(), E = M.end();
I != E; ++I)
if (!I->isDeclaration() && !I->hasNote(FnAttr::AlwaysInline))
if (!I->isDeclaration() && !I->hasNote(Attribute::AlwaysInline))
NeverInline.insert(I);
return false;

View File

@ -65,7 +65,7 @@ bool SimpleInliner::doInitialization(CallGraph &CG) {
for (Module::iterator I = M.begin(), E = M.end();
I != E; ++I)
if (!I->isDeclaration() && I->hasNote(FnAttr::NoInline))
if (!I->isDeclaration() && I->hasNote(Attribute::NoInline))
NeverInline.insert(I);
// Get llvm.noinline

View File

@ -141,7 +141,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
int CurrentThreshold = InlineThreshold;
Function *Fn = CS.getCaller();
if (Fn && !Fn->isDeclaration() && Fn->hasNote(FnAttr::OptimizeForSize)
if (Fn && !Fn->isDeclaration() && Fn->hasNote(Attribute::OptimizeForSize)
&& InlineThreshold != 50) {
CurrentThreshold = 50;
}

View File

@ -474,7 +474,7 @@ void LowerSetJmp::visitCallInst(CallInst& CI)
InvokeInst::Create(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
Params.begin(), Params.end(), CI.getName(), Term);
II->setCallingConv(CI.getCallingConv());
II->setParamAttrs(CI.getParamAttrs());
II->setAttributes(CI.getAttributes());
// Replace the old call inst with the invoke inst and remove the call.
CI.replaceAllUsesWith(II);

View File

@ -125,18 +125,18 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
// If the SCC doesn't unwind or doesn't throw, note this fact.
if (!SCCMightUnwind || !SCCMightReturn)
for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
Attributes NewAttributes = ParamAttr::None;
Attributes NewAttributes = Attribute::None;
if (!SCCMightUnwind)
NewAttributes |= ParamAttr::NoUnwind;
NewAttributes |= Attribute::NoUnwind;
if (!SCCMightReturn)
NewAttributes |= ParamAttr::NoReturn;
NewAttributes |= Attribute::NoReturn;
const PAListPtr &PAL = SCC[i]->getFunction()->getParamAttrs();
const PAListPtr &NPAL = PAL.addAttr(0, NewAttributes);
const AttrListPtr &PAL = SCC[i]->getFunction()->getAttributes();
const AttrListPtr &NPAL = PAL.addAttr(0, NewAttributes);
if (PAL != NPAL) {
MadeChange = true;
SCC[i]->getFunction()->setParamAttrs(NPAL);
SCC[i]->getFunction()->setAttributes(NPAL);
}
}
@ -169,7 +169,7 @@ bool PruneEH::SimplifyFunction(Function *F) {
Args.begin(), Args.end(), "", II);
Call->takeName(II);
Call->setCallingConv(II->getCallingConv());
Call->setParamAttrs(II->getParamAttrs());
Call->setAttributes(II->getAttributes());
// Anything that used the value produced by the invoke instruction
// now uses the value produced by the call instruction.

View File

@ -205,13 +205,13 @@ Function *SRETPromotion::cloneFunctionBody(Function *F,
const FunctionType *FTy = F->getFunctionType();
std::vector<const Type*> Params;
// ParamAttrs - Keep track of the parameter attributes for the arguments.
SmallVector<FnAttributeWithIndex, 8> ParamAttrsVec;
const PAListPtr &PAL = F->getParamAttrs();
// Attributes - Keep track of the parameter attributes for the arguments.
SmallVector<AttributeWithIndex, 8> AttributesVec;
const AttrListPtr &PAL = F->getAttributes();
// Add any return attributes.
if (Attributes attrs = PAL.getParamAttrs(0))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(0, attrs));
if (Attributes attrs = PAL.getAttributes(0))
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
// Skip first argument.
Function::arg_iterator I = F->arg_begin(), E = F->arg_end();
@ -221,8 +221,8 @@ Function *SRETPromotion::cloneFunctionBody(Function *F,
unsigned ParamIndex = 2;
while (I != E) {
Params.push_back(I->getType());
if (Attributes Attrs = PAL.getParamAttrs(ParamIndex))
ParamAttrsVec.push_back(FnAttributeWithIndex::get(ParamIndex - 1, Attrs));
if (Attributes Attrs = PAL.getAttributes(ParamIndex))
AttributesVec.push_back(AttributeWithIndex::get(ParamIndex - 1, Attrs));
++I;
++ParamIndex;
}
@ -231,7 +231,7 @@ Function *SRETPromotion::cloneFunctionBody(Function *F,
Function *NF = Function::Create(NFTy, F->getLinkage());
NF->takeName(F);
NF->copyAttributesFrom(F);
NF->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end()));
NF->setAttributes(AttrListPtr::get(AttributesVec.begin(), AttributesVec.end()));
F->getParent()->getFunctionList().insert(F, NF);
NF->getBasicBlockList().splice(NF->begin(), F->getBasicBlockList());
@ -255,17 +255,17 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) {
CallGraph &CG = getAnalysis<CallGraph>();
SmallVector<Value*, 16> Args;
// ParamAttrs - Keep track of the parameter attributes for the arguments.
SmallVector<FnAttributeWithIndex, 8> ArgAttrsVec;
// Attributes - Keep track of the parameter attributes for the arguments.
SmallVector<AttributeWithIndex, 8> ArgAttrsVec;
while (!F->use_empty()) {
CallSite CS = CallSite::get(*F->use_begin());
Instruction *Call = CS.getInstruction();
const PAListPtr &PAL = F->getParamAttrs();
const AttrListPtr &PAL = F->getAttributes();
// Add any return attributes.
if (Attributes attrs = PAL.getParamAttrs(0))
ArgAttrsVec.push_back(FnAttributeWithIndex::get(0, attrs));
if (Attributes attrs = PAL.getAttributes(0))
ArgAttrsVec.push_back(AttributeWithIndex::get(0, attrs));
// Copy arguments, however skip first one.
CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
@ -276,14 +276,14 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) {
unsigned ParamIndex = 2;
while (AI != AE) {
Args.push_back(*AI);
if (Attributes Attrs = PAL.getParamAttrs(ParamIndex))
ArgAttrsVec.push_back(FnAttributeWithIndex::get(ParamIndex - 1, Attrs));
if (Attributes Attrs = PAL.getAttributes(ParamIndex))
ArgAttrsVec.push_back(AttributeWithIndex::get(ParamIndex - 1, Attrs));
++ParamIndex;
++AI;
}
PAListPtr NewPAL = PAListPtr::get(ArgAttrsVec.begin(), ArgAttrsVec.end());
AttrListPtr NewPAL = AttrListPtr::get(ArgAttrsVec.begin(), ArgAttrsVec.end());
// Build new call instruction.
Instruction *New;
@ -291,11 +291,11 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) {
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
Args.begin(), Args.end(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setParamAttrs(NewPAL);
cast<InvokeInst>(New)->setAttributes(NewPAL);
} else {
New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setParamAttrs(NewPAL);
cast<CallInst>(New)->setAttributes(NewPAL);
if (cast<CallInst>(Call)->isTailCall())
cast<CallInst>(New)->setTailCall();
}

View File

@ -8999,7 +8999,7 @@ static bool isSafeToEliminateVarargsCast(const CallSite CS,
// The size of ByVal arguments is derived from the type, so we
// can't change to a type with a different size. If the size were
// passed explicitly we could avoid this check.
if (!CS.paramHasAttr(ix, ParamAttr::ByVal))
if (!CS.paramHasAttr(ix, Attribute::ByVal))
return true;
const Type* SrcTy =
@ -9099,7 +9099,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
return false;
Function *Callee = cast<Function>(CE->getOperand(0));
Instruction *Caller = CS.getInstruction();
const PAListPtr &CallerPAL = CS.getParamAttrs();
const AttrListPtr &CallerPAL = CS.getAttributes();
// Okay, this is a cast from a function to a different type. Unless doing so
// would cause a type conversion of one of our arguments, change this call to
@ -9127,8 +9127,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
return false; // Cannot transform this return value.
if (!CallerPAL.isEmpty() && !Caller->use_empty()) {
Attributes RAttrs = CallerPAL.getParamAttrs(0);
if (RAttrs & ParamAttr::typeIncompatible(NewRetTy))
Attributes RAttrs = CallerPAL.getAttributes(0);
if (RAttrs & Attribute::typeIncompatible(NewRetTy))
return false; // Attribute not compatible with transformed value.
}
@ -9157,7 +9157,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (!CastInst::isCastable(ActTy, ParamTy))
return false; // Cannot transform this parameter value.
if (CallerPAL.getParamAttrs(i + 1) & ParamAttr::typeIncompatible(ParamTy))
if (CallerPAL.getAttributes(i + 1) & Attribute::typeIncompatible(ParamTy))
return false; // Attribute not compatible with transformed value.
// Converting from one pointer type to another or between a pointer and an
@ -9181,7 +9181,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (CallerPAL.getSlot(i - 1).Index <= FT->getNumParams())
break;
Attributes PAttrs = CallerPAL.getSlot(i - 1).Attrs;
if (PAttrs & ParamAttr::VarArgsIncompatible)
if (PAttrs & Attribute::VarArgsIncompatible)
return false;
}
@ -9189,19 +9189,19 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// inserting cast instructions as necessary...
std::vector<Value*> Args;
Args.reserve(NumActualArgs);
SmallVector<FnAttributeWithIndex, 8> attrVec;
SmallVector<AttributeWithIndex, 8> attrVec;
attrVec.reserve(NumCommonArgs);
// Get any return attributes.
Attributes RAttrs = CallerPAL.getParamAttrs(0);
Attributes RAttrs = CallerPAL.getAttributes(0);
// If the return value is not being used, the type may not be compatible
// with the existing attributes. Wipe out any problematic attributes.
RAttrs &= ~ParamAttr::typeIncompatible(NewRetTy);
RAttrs &= ~Attribute::typeIncompatible(NewRetTy);
// Add the new return attributes.
if (RAttrs)
attrVec.push_back(FnAttributeWithIndex::get(0, RAttrs));
attrVec.push_back(AttributeWithIndex::get(0, RAttrs));
AI = CS.arg_begin();
for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
@ -9216,8 +9216,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
}
// Add any parameter attributes.
if (Attributes PAttrs = CallerPAL.getParamAttrs(i + 1))
attrVec.push_back(FnAttributeWithIndex::get(i + 1, PAttrs));
if (Attributes PAttrs = CallerPAL.getAttributes(i + 1))
attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs));
}
// If the function takes more arguments than the call was taking, add them
@ -9246,8 +9246,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
}
// Add any parameter attributes.
if (Attributes PAttrs = CallerPAL.getParamAttrs(i + 1))
attrVec.push_back(FnAttributeWithIndex::get(i + 1, PAttrs));
if (Attributes PAttrs = CallerPAL.getAttributes(i + 1))
attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs));
}
}
}
@ -9255,7 +9255,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (NewRetTy == Type::VoidTy)
Caller->setName(""); // Void type should not have a name.
const PAListPtr &NewCallerPAL = PAListPtr::get(attrVec.begin(),attrVec.end());
const AttrListPtr &NewCallerPAL = AttrListPtr::get(attrVec.begin(),attrVec.end());
Instruction *NC;
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
@ -9263,7 +9263,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
Args.begin(), Args.end(),
Caller->getName(), Caller);
cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv());
cast<InvokeInst>(NC)->setParamAttrs(NewCallerPAL);
cast<InvokeInst>(NC)->setAttributes(NewCallerPAL);
} else {
NC = CallInst::Create(Callee, Args.begin(), Args.end(),
Caller->getName(), Caller);
@ -9271,7 +9271,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (CI->isTailCall())
cast<CallInst>(NC)->setTailCall();
cast<CallInst>(NC)->setCallingConv(CI->getCallingConv());
cast<CallInst>(NC)->setParamAttrs(NewCallerPAL);
cast<CallInst>(NC)->setAttributes(NewCallerPAL);
}
// Insert a cast of the return type as necessary.
@ -9311,11 +9311,11 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
Value *Callee = CS.getCalledValue();
const PointerType *PTy = cast<PointerType>(Callee->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
const PAListPtr &Attrs = CS.getParamAttrs();
const AttrListPtr &Attrs = CS.getAttributes();
// If the call already has the 'nest' attribute somewhere then give up -
// otherwise 'nest' would occur twice after splicing in the chain.
if (Attrs.hasAttrSomewhere(ParamAttr::Nest))
if (Attrs.hasAttrSomewhere(Attribute::Nest))
return 0;
IntrinsicInst *Tramp =
@ -9325,19 +9325,19 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
const PointerType *NestFPTy = cast<PointerType>(NestF->getType());
const FunctionType *NestFTy = cast<FunctionType>(NestFPTy->getElementType());
const PAListPtr &NestAttrs = NestF->getParamAttrs();
const AttrListPtr &NestAttrs = NestF->getAttributes();
if (!NestAttrs.isEmpty()) {
unsigned NestIdx = 1;
const Type *NestTy = 0;
Attributes NestAttr = ParamAttr::None;
Attributes NestAttr = Attribute::None;
// Look for a parameter marked with the 'nest' attribute.
for (FunctionType::param_iterator I = NestFTy->param_begin(),
E = NestFTy->param_end(); I != E; ++NestIdx, ++I)
if (NestAttrs.paramHasAttr(NestIdx, ParamAttr::Nest)) {
if (NestAttrs.paramHasAttr(NestIdx, Attribute::Nest)) {
// Record the parameter type and any other attributes.
NestTy = *I;
NestAttr = NestAttrs.getParamAttrs(NestIdx);
NestAttr = NestAttrs.getAttributes(NestIdx);
break;
}
@ -9346,15 +9346,15 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
std::vector<Value*> NewArgs;
NewArgs.reserve(unsigned(CS.arg_end()-CS.arg_begin())+1);
SmallVector<FnAttributeWithIndex, 8> NewAttrs;
SmallVector<AttributeWithIndex, 8> NewAttrs;
NewAttrs.reserve(Attrs.getNumSlots() + 1);
// Insert the nest argument into the call argument list, which may
// mean appending it. Likewise for attributes.
// Add any function result attributes.
if (Attributes Attr = Attrs.getParamAttrs(0))
NewAttrs.push_back(FnAttributeWithIndex::get(0, Attr));
if (Attributes Attr = Attrs.getAttributes(0))
NewAttrs.push_back(AttributeWithIndex::get(0, Attr));
{
unsigned Idx = 1;
@ -9366,7 +9366,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
if (NestVal->getType() != NestTy)
NestVal = new BitCastInst(NestVal, NestTy, "nest", Caller);
NewArgs.push_back(NestVal);
NewAttrs.push_back(FnAttributeWithIndex::get(NestIdx, NestAttr));
NewAttrs.push_back(AttributeWithIndex::get(NestIdx, NestAttr));
}
if (I == E)
@ -9374,9 +9374,9 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
// Add the original argument and attributes.
NewArgs.push_back(*I);
if (Attributes Attr = Attrs.getParamAttrs(Idx))
if (Attributes Attr = Attrs.getAttributes(Idx))
NewAttrs.push_back
(FnAttributeWithIndex::get(Idx + (Idx >= NestIdx), Attr));
(AttributeWithIndex::get(Idx + (Idx >= NestIdx), Attr));
++Idx, ++I;
} while (1);
@ -9417,7 +9417,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
FunctionType::get(FTy->getReturnType(), NewTypes, FTy->isVarArg());
Constant *NewCallee = NestF->getType() == PointerType::getUnqual(NewFTy) ?
NestF : ConstantExpr::getBitCast(NestF, PointerType::getUnqual(NewFTy));
const PAListPtr &NewPAL = PAListPtr::get(NewAttrs.begin(),NewAttrs.end());
const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(),NewAttrs.end());
Instruction *NewCaller;
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
@ -9426,7 +9426,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
NewArgs.begin(), NewArgs.end(),
Caller->getName(), Caller);
cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv());
cast<InvokeInst>(NewCaller)->setParamAttrs(NewPAL);
cast<InvokeInst>(NewCaller)->setAttributes(NewPAL);
} else {
NewCaller = CallInst::Create(NewCallee, NewArgs.begin(), NewArgs.end(),
Caller->getName(), Caller);
@ -9434,7 +9434,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
cast<CallInst>(NewCaller)->setTailCall();
cast<CallInst>(NewCaller)->
setCallingConv(cast<CallInst>(Caller)->getCallingConv());
cast<CallInst>(NewCaller)->setParamAttrs(NewPAL);
cast<CallInst>(NewCaller)->setAttributes(NewPAL);
}
if (Caller->getType() != Type::VoidTy && !Caller->use_empty())
Caller->replaceAllUsesWith(NewCaller);

View File

@ -430,7 +430,7 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){
Function *F = loopHeader->getParent();
// Do not unswitch if the function is optimized for size.
if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize))
return false;
// Check to see if it would be profitable to unswitch current loop.

View File

@ -83,7 +83,7 @@ static void ChangeToCall(InvokeInst *II) {
Args.end(), "", II);
NewCall->takeName(II);
NewCall->setCallingConv(II->getCallingConv());
NewCall->setParamAttrs(II->getParamAttrs());
NewCall->setAttributes(II->getAttributes());
II->replaceAllUsesWith(NewCall);
// Follow the call by a branch to the normal destination.

View File

@ -222,7 +222,7 @@ int InlineCostAnalyzer::getInlineCost(CallSite CS,
if (CalleeFI.NeverInline)
return 2000000000;
if (!Callee->isDeclaration() && Callee->hasNote(FnAttr::AlwaysInline))
if (!Callee->isDeclaration() && Callee->hasNote(Attribute::AlwaysInline))
return -2000000000;
// Add to the inline quality for properties that make the call valuable to

View File

@ -88,7 +88,7 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
InvokeArgs.begin(), InvokeArgs.end(),
CI->getName(), BB->getTerminator());
II->setCallingConv(CI->getCallingConv());
II->setParamAttrs(CI->getParamAttrs());
II->setAttributes(CI->getAttributes());
// Make sure that anything using the call now uses the invoke!
CI->replaceAllUsesWith(II);
@ -246,7 +246,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// by them explicit. However, we don't do this if the callee is readonly
// or readnone, because the copy would be unneeded: the callee doesn't
// modify the struct.
if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal) &&
if (CalledFunc->paramHasAttr(ArgNo+1, Attribute::ByVal) &&
!CalledFunc->onlyReadsMemory()) {
const Type *AggTy = cast<PointerType>(I->getType())->getElementType();
const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);

View File

@ -227,7 +227,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) {
CallArgs.begin(), CallArgs.end(), "",II);
NewCall->takeName(II);
NewCall->setCallingConv(II->getCallingConv());
NewCall->setParamAttrs(II->getParamAttrs());
NewCall->setAttributes(II->getAttributes());
II->replaceAllUsesWith(NewCall);
// Insert an unconditional branch to the normal destination.
@ -296,7 +296,7 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
II);
NewCall->takeName(II);
NewCall->setCallingConv(II->getCallingConv());
NewCall->setParamAttrs(II->getParamAttrs());
NewCall->setAttributes(II->getAttributes());
II->replaceAllUsesWith(NewCall);
// Replace the invoke with an uncond branch.

View File

@ -1845,7 +1845,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
Args.begin(), Args.end(),
II->getName(), BI);
CI->setCallingConv(II->getCallingConv());
CI->setParamAttrs(II->getParamAttrs());
CI->setAttributes(II->getAttributes());
// If the invoke produced a value, the Call now does instead
II->replaceAllUsesWith(CI);
delete II;
@ -2019,7 +2019,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
Args.begin(), Args.end(),
II->getName(), BI);
CI->setCallingConv(II->getCallingConv());
CI->setParamAttrs(II->getParamAttrs());
CI->setAttributes(II->getAttributes());
// If the invoke produced a value, the Call does now instead.
II->replaceAllUsesWith(CI);
delete II;

View File

@ -1134,8 +1134,8 @@ void AssemblyWriter::writeParamOperand(const Value *Operand,
// Print the type
printType(Operand->getType());
// Print parameter attributes list
if (Attrs != ParamAttr::None)
Out << ' ' << ParamAttr::getAsString(Attrs);
if (Attrs != Attribute::None)
Out << ' ' << Attribute::getAsString(Attrs);
Out << ' ';
// Print the operand
WriteAsOperandInternal(Out, Operand, TypeNames, &Machine);
@ -1356,7 +1356,7 @@ void AssemblyWriter::printFunction(const Function *F) {
}
const FunctionType *FT = F->getFunctionType();
const PAListPtr &Attrs = F->getParamAttrs();
const AttrListPtr &Attrs = F->getAttributes();
printType(F->getReturnType());
Out << ' ';
if (F->hasName())
@ -1375,7 +1375,7 @@ void AssemblyWriter::printFunction(const Function *F) {
I != E; ++I) {
// Insert commas as we go... the first arg doesn't get a comma
if (I != F->arg_begin()) Out << ", ";
printArgument(I, Attrs.getParamAttrs(Idx));
printArgument(I, Attrs.getAttributes(Idx));
Idx++;
}
} else {
@ -1387,9 +1387,9 @@ void AssemblyWriter::printFunction(const Function *F) {
// Output type...
printType(FT->getParamType(i));
Attributes ArgAttrs = Attrs.getParamAttrs(i+1);
if (ArgAttrs != ParamAttr::None)
Out << ' ' << ParamAttr::getAsString(ArgAttrs);
Attributes ArgAttrs = Attrs.getAttributes(i+1);
if (ArgAttrs != Attribute::None)
Out << ' ' << Attribute::getAsString(ArgAttrs);
}
}
@ -1399,9 +1399,9 @@ void AssemblyWriter::printFunction(const Function *F) {
Out << "..."; // Output varargs portion of signature!
}
Out << ')';
Attributes RetAttrs = Attrs.getParamAttrs(0);
if (RetAttrs != ParamAttr::None)
Out << ' ' << ParamAttr::getAsString(Attrs.getParamAttrs(0));
Attributes RetAttrs = Attrs.getAttributes(0);
if (RetAttrs != Attribute::None)
Out << ' ' << Attribute::getAsString(Attrs.getAttributes(0));
if (F->hasSection())
Out << " section \"" << F->getSection() << '"';
if (F->getAlignment())
@ -1413,12 +1413,12 @@ void AssemblyWriter::printFunction(const Function *F) {
} else {
bool insideNotes = false;
if (F->hasNote(FnAttr::AlwaysInline)) {
if (F->hasNote(Attribute::AlwaysInline)) {
Out << "notes(";
insideNotes = true;
Out << "inline=always";
}
if (F->hasNote(FnAttr::NoInline)) {
if (F->hasNote(Attribute::NoInline)) {
if (insideNotes)
Out << ",";
else {
@ -1427,7 +1427,7 @@ void AssemblyWriter::printFunction(const Function *F) {
}
Out << "inline=never";
}
if (F->hasNote(FnAttr::OptimizeForSize)) {
if (F->hasNote(Attribute::OptimizeForSize)) {
if (insideNotes)
Out << ",";
else {
@ -1460,8 +1460,8 @@ void AssemblyWriter::printArgument(const Argument *Arg,
printType(Arg->getType());
// Output parameter attributes list
if (Attrs != ParamAttr::None)
Out << ' ' << ParamAttr::getAsString(Attrs);
if (Attrs != Attribute::None)
Out << ' ' << Attribute::getAsString(Attrs);
// Output name, if available...
if (Arg->hasName()) {
@ -1642,7 +1642,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
const PointerType *PTy = cast<PointerType>(Operand->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
const Type *RetTy = FTy->getReturnType();
const PAListPtr &PAL = CI->getParamAttrs();
const AttrListPtr &PAL = CI->getAttributes();
// If possible, print out the short form of the call instruction. We can
// only do this if the first argument is a pointer to a nonvararg function,
@ -1662,16 +1662,16 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
for (unsigned op = 1, Eop = I.getNumOperands(); op < Eop; ++op) {
if (op > 1)
Out << ", ";
writeParamOperand(I.getOperand(op), PAL.getParamAttrs(op));
writeParamOperand(I.getOperand(op), PAL.getAttributes(op));
}
Out << ')';
if (PAL.getParamAttrs(0) != ParamAttr::None)
Out << ' ' << ParamAttr::getAsString(PAL.getParamAttrs(0));
if (PAL.getAttributes(0) != Attribute::None)
Out << ' ' << Attribute::getAsString(PAL.getAttributes(0));
} else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
const PointerType *PTy = cast<PointerType>(Operand->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
const Type *RetTy = FTy->getReturnType();
const PAListPtr &PAL = II->getParamAttrs();
const AttrListPtr &PAL = II->getAttributes();
// Print the calling convention being used.
switch (II->getCallingConv()) {
@ -1702,12 +1702,12 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
for (unsigned op = 3, Eop = I.getNumOperands(); op < Eop; ++op) {
if (op > 3)
Out << ", ";
writeParamOperand(I.getOperand(op), PAL.getParamAttrs(op-2));
writeParamOperand(I.getOperand(op), PAL.getAttributes(op-2));
}
Out << ')';
if (PAL.getParamAttrs(0) != ParamAttr::None)
Out << ' ' << ParamAttr::getAsString(PAL.getParamAttrs(0));
if (PAL.getAttributes(0) != Attribute::None)
Out << ' ' << Attribute::getAsString(PAL.getAttributes(0));
Out << "\n\t\t\tto ";
writeOperand(II->getNormalDest(), true);
Out << " unwind ";

View File

@ -1,4 +1,4 @@
//===-- Attributes.cpp - Implement ParamAttrsList -------------------------===//
//===-- Attributes.cpp - Implement AttributesList -------------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
// This file implements the ParamAttrsList class and ParamAttr utilities.
// This file implements the AttributesList class and Attribute utilities.
//
//===----------------------------------------------------------------------===//
@ -20,36 +20,36 @@
using namespace llvm;
//===----------------------------------------------------------------------===//
// ParamAttr Function Definitions
// Attribute Function Definitions
//===----------------------------------------------------------------------===//
std::string ParamAttr::getAsString(Attributes Attrs) {
std::string Attribute::getAsString(Attributes Attrs) {
std::string Result;
if (Attrs & ParamAttr::ZExt)
if (Attrs & Attribute::ZExt)
Result += "zeroext ";
if (Attrs & ParamAttr::SExt)
if (Attrs & Attribute::SExt)
Result += "signext ";
if (Attrs & ParamAttr::NoReturn)
if (Attrs & Attribute::NoReturn)
Result += "noreturn ";
if (Attrs & ParamAttr::NoUnwind)
if (Attrs & Attribute::NoUnwind)
Result += "nounwind ";
if (Attrs & ParamAttr::InReg)
if (Attrs & Attribute::InReg)
Result += "inreg ";
if (Attrs & ParamAttr::NoAlias)
if (Attrs & Attribute::NoAlias)
Result += "noalias ";
if (Attrs & ParamAttr::StructRet)
if (Attrs & Attribute::StructRet)
Result += "sret ";
if (Attrs & ParamAttr::ByVal)
if (Attrs & Attribute::ByVal)
Result += "byval ";
if (Attrs & ParamAttr::Nest)
if (Attrs & Attribute::Nest)
Result += "nest ";
if (Attrs & ParamAttr::ReadNone)
if (Attrs & Attribute::ReadNone)
Result += "readnone ";
if (Attrs & ParamAttr::ReadOnly)
if (Attrs & Attribute::ReadOnly)
Result += "readonly ";
if (Attrs & ParamAttr::Alignment) {
if (Attrs & Attribute::Alignment) {
Result += "align ";
Result += utostr((Attrs & ParamAttr::Alignment) >> 16);
Result += utostr((Attrs & Attribute::Alignment) >> 16);
Result += " ";
}
// Trim the trailing space.
@ -57,7 +57,7 @@ std::string ParamAttr::getAsString(Attributes Attrs) {
return Result;
}
Attributes ParamAttr::typeIncompatible(const Type *Ty) {
Attributes Attribute::typeIncompatible(const Type *Ty) {
Attributes Incompatible = None;
if (!Ty->isInteger())
@ -79,14 +79,14 @@ namespace llvm {
class AttributeListImpl : public FoldingSetNode {
unsigned RefCount;
// ParamAttrsList is uniqued, these should not be publicly available.
// AttributesList is uniqued, these should not be publicly available.
void operator=(const AttributeListImpl &); // Do not implement
AttributeListImpl(const AttributeListImpl &); // Do not implement
~AttributeListImpl(); // Private implementation
public:
SmallVector<FnAttributeWithIndex, 4> Attrs;
SmallVector<AttributeWithIndex, 4> Attrs;
AttributeListImpl(const FnAttributeWithIndex *Attr, unsigned NumAttrs)
AttributeListImpl(const AttributeWithIndex *Attr, unsigned NumAttrs)
: Attrs(Attr, Attr+NumAttrs) {
RefCount = 0;
}
@ -97,7 +97,7 @@ public:
void Profile(FoldingSetNodeID &ID) const {
Profile(ID, &Attrs[0], Attrs.size());
}
static void Profile(FoldingSetNodeID &ID, const FnAttributeWithIndex *Attr,
static void Profile(FoldingSetNodeID &ID, const AttributeWithIndex *Attr,
unsigned NumAttrs) {
for (unsigned i = 0; i != NumAttrs; ++i)
ID.AddInteger(uint64_t(Attr[i].Attrs) << 32 | unsigned(Attr[i].Index));
@ -105,24 +105,24 @@ public:
};
}
static ManagedStatic<FoldingSet<AttributeListImpl> > ParamAttrsLists;
static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
AttributeListImpl::~AttributeListImpl() {
ParamAttrsLists->RemoveNode(this);
AttributesLists->RemoveNode(this);
}
PAListPtr PAListPtr::get(const FnAttributeWithIndex *Attrs, unsigned NumAttrs) {
// If there are no attributes then return a null ParamAttrsList pointer.
AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs) {
// If there are no attributes then return a null AttributesList pointer.
if (NumAttrs == 0)
return PAListPtr();
return AttrListPtr();
#ifndef NDEBUG
for (unsigned i = 0; i != NumAttrs; ++i) {
assert(Attrs[i].Attrs != ParamAttr::None &&
"Pointless parameter attribute!");
assert(Attrs[i].Attrs != Attribute::None &&
"Pointless attribute!");
assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
"Misordered ParamAttrsList!");
"Misordered AttributesList!");
}
#endif
@ -131,78 +131,78 @@ PAListPtr PAListPtr::get(const FnAttributeWithIndex *Attrs, unsigned NumAttrs) {
AttributeListImpl::Profile(ID, Attrs, NumAttrs);
void *InsertPos;
AttributeListImpl *PAL =
ParamAttrsLists->FindNodeOrInsertPos(ID, InsertPos);
AttributesLists->FindNodeOrInsertPos(ID, InsertPos);
// If we didn't find any existing attributes of the same shape then
// create a new one and insert it.
if (!PAL) {
PAL = new AttributeListImpl(Attrs, NumAttrs);
ParamAttrsLists->InsertNode(PAL, InsertPos);
AttributesLists->InsertNode(PAL, InsertPos);
}
// Return the ParamAttrsList that we found or created.
return PAListPtr(PAL);
// Return the AttributesList that we found or created.
return AttrListPtr(PAL);
}
//===----------------------------------------------------------------------===//
// PAListPtr Method Implementations
// AttrListPtr Method Implementations
//===----------------------------------------------------------------------===//
PAListPtr::PAListPtr(AttributeListImpl *LI) : PAList(LI) {
AttrListPtr::AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {
if (LI) LI->AddRef();
}
PAListPtr::PAListPtr(const PAListPtr &P) : PAList(P.PAList) {
if (PAList) PAList->AddRef();
AttrListPtr::AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {
if (AttrList) AttrList->AddRef();
}
const PAListPtr &PAListPtr::operator=(const PAListPtr &RHS) {
if (PAList == RHS.PAList) return *this;
if (PAList) PAList->DropRef();
PAList = RHS.PAList;
if (PAList) PAList->AddRef();
const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
if (AttrList == RHS.AttrList) return *this;
if (AttrList) AttrList->DropRef();
AttrList = RHS.AttrList;
if (AttrList) AttrList->AddRef();
return *this;
}
PAListPtr::~PAListPtr() {
if (PAList) PAList->DropRef();
AttrListPtr::~AttrListPtr() {
if (AttrList) AttrList->DropRef();
}
/// getNumSlots - Return the number of slots used in this attribute list.
/// This is the number of arguments that have an attribute set on them
/// (including the function itself).
unsigned PAListPtr::getNumSlots() const {
return PAList ? PAList->Attrs.size() : 0;
unsigned AttrListPtr::getNumSlots() const {
return AttrList ? AttrList->Attrs.size() : 0;
}
/// getSlot - Return the FnAttributeWithIndex at the specified slot. This
/// holds a parameter number plus a set of attributes.
const FnAttributeWithIndex &PAListPtr::getSlot(unsigned Slot) const {
assert(PAList && Slot < PAList->Attrs.size() && "Slot # out of range!");
return PAList->Attrs[Slot];
/// getSlot - Return the AttributeWithIndex at the specified slot. This
/// holds a number plus a set of attributes.
const AttributeWithIndex &AttrListPtr::getSlot(unsigned Slot) const {
assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
return AttrList->Attrs[Slot];
}
/// getParamAttrs - The parameter attributes for the specified parameter are
/// returned. Parameters for the result are denoted with Idx = 0.
/// getAttributes - The attributes for the specified index are
/// returned. Attributes for the result are denoted with Idx = 0.
/// Function notes are denoted with idx = ~0.
Attributes PAListPtr::getParamAttrs(unsigned Idx) const {
if (PAList == 0) return ParamAttr::None;
Attributes AttrListPtr::getAttributes(unsigned Idx) const {
if (AttrList == 0) return Attribute::None;
const SmallVector<FnAttributeWithIndex, 4> &Attrs = PAList->Attrs;
const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
if (Attrs[i].Index == Idx)
return Attrs[i].Attrs;
return ParamAttr::None;
return Attribute::None;
}
/// hasAttrSomewhere - Return true if the specified attribute is set for at
/// least one parameter or for the return value.
bool PAListPtr::hasAttrSomewhere(Attributes Attr) const {
if (PAList == 0) return false;
bool AttrListPtr::hasAttrSomewhere(Attributes Attr) const {
if (AttrList == 0) return false;
const SmallVector<FnAttributeWithIndex, 4> &Attrs = PAList->Attrs;
const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
if (Attrs[i].Attrs & Attr)
return true;
@ -210,13 +210,13 @@ bool PAListPtr::hasAttrSomewhere(Attributes Attr) const {
}
PAListPtr PAListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
Attributes OldAttrs = getParamAttrs(Idx);
AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
Attributes OldAttrs = getAttributes(Idx);
#ifndef NDEBUG
// FIXME it is not obvious how this should work for alignment.
// For now, say we can't change a known alignment.
Attributes OldAlign = OldAttrs & ParamAttr::Alignment;
Attributes NewAlign = Attrs & ParamAttr::Alignment;
Attributes OldAlign = OldAttrs & Attribute::Alignment;
Attributes NewAlign = Attrs & Attribute::Alignment;
assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
"Attempt to change alignment!");
#endif
@ -225,11 +225,11 @@ PAListPtr PAListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
if (NewAttrs == OldAttrs)
return *this;
SmallVector<FnAttributeWithIndex, 8> NewAttrList;
if (PAList == 0)
NewAttrList.push_back(FnAttributeWithIndex::get(Idx, Attrs));
SmallVector<AttributeWithIndex, 8> NewAttrList;
if (AttrList == 0)
NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
else {
const SmallVector<FnAttributeWithIndex, 4> &OldAttrList = PAList->Attrs;
const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
unsigned i = 0, e = OldAttrList.size();
// Copy attributes for arguments before this one.
for (; i != e && OldAttrList[i].Index < Idx; ++i)
@ -241,7 +241,7 @@ PAListPtr PAListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
++i;
}
NewAttrList.push_back(FnAttributeWithIndex::get(Idx, Attrs));
NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
// Copy attributes for arguments after this one.
NewAttrList.insert(NewAttrList.end(),
@ -251,21 +251,21 @@ PAListPtr PAListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
return get(&NewAttrList[0], NewAttrList.size());
}
PAListPtr PAListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
#ifndef NDEBUG
// FIXME it is not obvious how this should work for alignment.
// For now, say we can't pass in alignment, which no current use does.
assert(!(Attrs & ParamAttr::Alignment) && "Attempt to exclude alignment!");
assert(!(Attrs & Attribute::Alignment) && "Attempt to exclude alignment!");
#endif
if (PAList == 0) return PAListPtr();
if (AttrList == 0) return AttrListPtr();
Attributes OldAttrs = getParamAttrs(Idx);
Attributes OldAttrs = getAttributes(Idx);
Attributes NewAttrs = OldAttrs & ~Attrs;
if (NewAttrs == OldAttrs)
return *this;
SmallVector<FnAttributeWithIndex, 8> NewAttrList;
const SmallVector<FnAttributeWithIndex, 4> &OldAttrList = PAList->Attrs;
SmallVector<AttributeWithIndex, 8> NewAttrList;
const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
unsigned i = 0, e = OldAttrList.size();
// Copy attributes for arguments before this one.
@ -277,7 +277,7 @@ PAListPtr PAListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
Attrs = OldAttrList[i].Attrs & ~Attrs;
++i;
if (Attrs) // If any attributes left for this parameter, add them.
NewAttrList.push_back(FnAttributeWithIndex::get(Idx, Attrs));
NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
// Copy attributes for arguments after this one.
NewAttrList.insert(NewAttrList.end(),
@ -286,10 +286,10 @@ PAListPtr PAListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
return get(&NewAttrList[0], NewAttrList.size());
}
void PAListPtr::dump() const {
void AttrListPtr::dump() const {
cerr << "PAL[ ";
for (unsigned i = 0; i < getNumSlots(); ++i) {
const FnAttributeWithIndex &PAWI = getSlot(i);
const AttributeWithIndex &PAWI = getSlot(i);
cerr << "{" << PAWI.Index << "," << PAWI.Attrs << "} ";
}

View File

@ -218,7 +218,7 @@ bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) {
if (NewFn)
F = NewFn;
if (unsigned id = F->getIntrinsicID(true))
F->setParamAttrs(Intrinsic::getParamAttrs((Intrinsic::ID)id));
F->setAttributes(Intrinsic::getAttributes((Intrinsic::ID)id));
return Upgraded;
}
@ -383,8 +383,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
// Handle any uses of the old CallInst.
if (!CI->use_empty()) {
// Check for sign extend parameter attributes on the return values.
bool SrcSExt = NewFn->getParamAttrs().paramHasAttr(0, ParamAttr::SExt);
bool DestSExt = F->getParamAttrs().paramHasAttr(0, ParamAttr::SExt);
bool SrcSExt = NewFn->getAttributes().paramHasAttr(0, Attribute::SExt);
bool DestSExt = F->getAttributes().paramHasAttr(0, Attribute::SExt);
// Construct an appropriate cast from the new return type to the old.
CastInst *RetCast = CastInst::Create(

View File

@ -790,17 +790,17 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) {
return wrap(--I);
}
void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) {
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
unwrap<Argument>(Arg)->addAttr(PA);
}
void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) {
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
unwrap<Argument>(Arg)->removeAttr(PA);
}
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
unwrap<Argument>(Arg)->addAttr(
ParamAttr::constructAlignmentFromInt(align));
Attribute::constructAlignmentFromInt(align));
}
/*--.. Operations on basic blocks ..........................................--*/
@ -941,26 +941,26 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
assert(0 && "LLVMSetInstructionCallConv applies only to call and invoke!");
}
void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index,
LLVMParamAttr PA) {
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
Call.setParamAttrs(
Call.getParamAttrs().addAttr(index, PA));
Call.setAttributes(
Call.getAttributes().addAttr(index, PA));
}
void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index,
LLVMParamAttr PA) {
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
LLVMAttribute PA) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
Call.setParamAttrs(
Call.getParamAttrs().removeAttr(index, PA));
Call.setAttributes(
Call.getAttributes().removeAttr(index, PA));
}
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
unsigned align) {
CallSite Call = CallSite(unwrap<Instruction>(Instr));
Call.setParamAttrs(
Call.getParamAttrs().addAttr(index,
ParamAttr::constructAlignmentFromInt(align)));
Call.setAttributes(
Call.getAttributes().addAttr(index,
Attribute::constructAlignmentFromInt(align)));
}
/*--.. Operations on call instructions (only) ..............................--*/

View File

@ -92,14 +92,14 @@ unsigned Argument::getArgNo() const {
/// in its containing function.
bool Argument::hasByValAttr() const {
if (!isa<PointerType>(getType())) return false;
return getParent()->paramHasAttr(getArgNo()+1, ParamAttr::ByVal);
return getParent()->paramHasAttr(getArgNo()+1, Attribute::ByVal);
}
/// hasNoAliasAttr - Return true if this argument has the noalias attribute on
/// it in its containing function.
bool Argument::hasNoAliasAttr() const {
if (!isa<PointerType>(getType())) return false;
return getParent()->paramHasAttr(getArgNo()+1, ParamAttr::NoAlias);
return getParent()->paramHasAttr(getArgNo()+1, Attribute::NoAlias);
}
/// hasSRetAttr - Return true if this argument has the sret attribute on
@ -108,17 +108,17 @@ bool Argument::hasStructRetAttr() const {
if (!isa<PointerType>(getType())) return false;
if (this != getParent()->arg_begin())
return false; // StructRet param must be first param
return getParent()->paramHasAttr(1, ParamAttr::StructRet);
return getParent()->paramHasAttr(1, Attribute::StructRet);
}
/// addAttr - Add a ParamAttr to an argument
/// addAttr - Add a Attribute to an argument
void Argument::addAttr(Attributes attr) {
getParent()->addParamAttr(getArgNo() + 1, attr);
getParent()->addAttribute(getArgNo() + 1, attr);
}
/// removeAttr - Remove a ParamAttr from an argument
/// removeAttr - Remove a Attribute from an argument
void Argument::removeAttr(Attributes attr) {
getParent()->removeParamAttr(getArgNo() + 1, attr);
getParent()->removeAttribute(getArgNo() + 1, attr);
}
@ -172,7 +172,7 @@ Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
// Ensure intrinsics have the right parameter attributes.
if (unsigned IID = getIntrinsicID(true))
setParamAttrs(Intrinsic::getParamAttrs(Intrinsic::ID(IID)));
setAttributes(Intrinsic::getAttributes(Intrinsic::ID(IID)));
}
@ -229,16 +229,16 @@ void Function::dropAllReferences() {
BasicBlocks.clear(); // Delete all basic blocks...
}
void Function::addParamAttr(unsigned i, Attributes attr) {
PAListPtr PAL = getParamAttrs();
void Function::addAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
PAL = PAL.addAttr(i, attr);
setParamAttrs(PAL);
setAttributes(PAL);
}
void Function::removeParamAttr(unsigned i, Attributes attr) {
PAListPtr PAL = getParamAttrs();
void Function::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
PAL = PAL.removeAttr(i, attr);
setParamAttrs(PAL);
setAttributes(PAL);
}
// Maintain the GC name for each function in an on-the-side table. This saves
@ -286,7 +286,7 @@ void Function::copyAttributesFrom(const GlobalValue *Src) {
GlobalValue::copyAttributesFrom(Src);
const Function *SrcF = cast<Function>(Src);
setCallingConv(SrcF->getCallingConv());
setParamAttrs(SrcF->getParamAttrs());
setAttributes(SrcF->getAttributes());
if (SrcF->hasGC())
setGC(SrcF->getGC());
else
@ -355,18 +355,18 @@ const FunctionType *Intrinsic::getType(ID id, const Type **Tys,
return FunctionType::get(ResultTy, ArgTys, IsVarArg);
}
PAListPtr Intrinsic::getParamAttrs(ID id) {
Attributes Attr = ParamAttr::None;
AttrListPtr Intrinsic::getAttributes(ID id) {
Attributes Attr = Attribute::None;
#define GET_INTRINSIC_ATTRIBUTES
#include "llvm/Intrinsics.gen"
#undef GET_INTRINSIC_ATTRIBUTES
// Intrinsics cannot throw exceptions.
Attr |= ParamAttr::NoUnwind;
Attr |= Attribute::NoUnwind;
FnAttributeWithIndex PAWI = FnAttributeWithIndex::get(0, Attr);
return PAListPtr::get(&PAWI, 1);
AttributeWithIndex PAWI = AttributeWithIndex::get(0, Attr);
return AttrListPtr::get(&PAWI, 1);
}
Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys,

View File

@ -41,17 +41,17 @@ void CallSite::setCallingConv(unsigned CC) {
else
cast<InvokeInst>(I)->setCallingConv(CC);
}
const PAListPtr &CallSite::getParamAttrs() const {
const AttrListPtr &CallSite::getAttributes() const {
if (CallInst *CI = dyn_cast<CallInst>(I))
return CI->getParamAttrs();
return CI->getAttributes();
else
return cast<InvokeInst>(I)->getParamAttrs();
return cast<InvokeInst>(I)->getAttributes();
}
void CallSite::setParamAttrs(const PAListPtr &PAL) {
void CallSite::setAttributes(const AttrListPtr &PAL) {
if (CallInst *CI = dyn_cast<CallInst>(I))
CI->setParamAttrs(PAL);
CI->setAttributes(PAL);
else
cast<InvokeInst>(I)->setParamAttrs(PAL);
cast<InvokeInst>(I)->setAttributes(PAL);
}
bool CallSite::paramHasAttr(uint16_t i, Attributes attr) const {
if (CallInst *CI = dyn_cast<CallInst>(I))
@ -394,7 +394,7 @@ CallInst::CallInst(const CallInst &CI)
: Instruction(CI.getType(), Instruction::Call,
OperandTraits<CallInst>::op_end(this) - CI.getNumOperands(),
CI.getNumOperands()) {
setParamAttrs(CI.getParamAttrs());
setAttributes(CI.getAttributes());
SubclassData = CI.SubclassData;
Use *OL = OperandList;
Use *InOL = CI.OperandList;
@ -402,20 +402,20 @@ CallInst::CallInst(const CallInst &CI)
OL[i] = InOL[i];
}
void CallInst::addParamAttr(unsigned i, Attributes attr) {
PAListPtr PAL = getParamAttrs();
void CallInst::addAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
PAL = PAL.addAttr(i, attr);
setParamAttrs(PAL);
setAttributes(PAL);
}
void CallInst::removeParamAttr(unsigned i, Attributes attr) {
PAListPtr PAL = getParamAttrs();
void CallInst::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
PAL = PAL.removeAttr(i, attr);
setParamAttrs(PAL);
setAttributes(PAL);
}
bool CallInst::paramHasAttr(unsigned i, Attributes attr) const {
if (ParamAttrs.paramHasAttr(i, attr))
if (AttributeList.paramHasAttr(i, attr))
return true;
if (const Function *F = getCalledFunction())
return F->paramHasAttr(i, attr);
@ -456,7 +456,7 @@ InvokeInst::InvokeInst(const InvokeInst &II)
OperandTraits<InvokeInst>::op_end(this)
- II.getNumOperands(),
II.getNumOperands()) {
setParamAttrs(II.getParamAttrs());
setAttributes(II.getAttributes());
SubclassData = II.SubclassData;
Use *OL = OperandList, *InOL = II.OperandList;
for (unsigned i = 0, e = II.getNumOperands(); i != e; ++i)
@ -474,23 +474,23 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
}
bool InvokeInst::paramHasAttr(unsigned i, Attributes attr) const {
if (ParamAttrs.paramHasAttr(i, attr))
if (AttributeList.paramHasAttr(i, attr))
return true;
if (const Function *F = getCalledFunction())
return F->paramHasAttr(i, attr);
return false;
}
void InvokeInst::addParamAttr(unsigned i, Attributes attr) {
PAListPtr PAL = getParamAttrs();
void InvokeInst::addAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
PAL = PAL.addAttr(i, attr);
setParamAttrs(PAL);
setAttributes(PAL);
}
void InvokeInst::removeParamAttr(unsigned i, Attributes attr) {
PAListPtr PAL = getParamAttrs();
void InvokeInst::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes();
PAL = PAL.removeAttr(i, attr);
setParamAttrs(PAL);
setAttributes(PAL);
}

View File

@ -270,7 +270,7 @@ namespace {
unsigned Count, ...);
void VerifyAttrs(Attributes Attrs, const Type *Ty,
bool isReturnValue, const Value *V);
void VerifyFunctionAttrs(const FunctionType *FT, const PAListPtr &Attrs,
void VerifyFunctionAttrs(const FunctionType *FT, const AttrListPtr &Attrs,
const Value *V);
void WriteValue(const Value *V) {
@ -408,38 +408,38 @@ void Verifier::verifyTypeSymbolTable(TypeSymbolTable &ST) {
// value of the specified type. The value V is printed in error messages.
void Verifier::VerifyAttrs(Attributes Attrs, const Type *Ty,
bool isReturnValue, const Value *V) {
if (Attrs == ParamAttr::None)
if (Attrs == Attribute::None)
return;
if (isReturnValue) {
Attributes RetI = Attrs & ParamAttr::ParameterOnly;
Assert1(!RetI, "Attribute " + ParamAttr::getAsString(RetI) +
Attributes RetI = Attrs & Attribute::ParameterOnly;
Assert1(!RetI, "Attribute " + Attribute::getAsString(RetI) +
" does not apply to return values!", V);
} else {
Attributes ParmI = Attrs & ParamAttr::ReturnOnly;
Assert1(!ParmI, "Attribute " + ParamAttr::getAsString(ParmI) +
Attributes ParmI = Attrs & Attribute::ReturnOnly;
Assert1(!ParmI, "Attribute " + Attribute::getAsString(ParmI) +
" only applies to return values!", V);
}
for (unsigned i = 0;
i < array_lengthof(ParamAttr::MutuallyIncompatible); ++i) {
Attributes MutI = Attrs & ParamAttr::MutuallyIncompatible[i];
i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
Attributes MutI = Attrs & Attribute::MutuallyIncompatible[i];
Assert1(!(MutI & (MutI - 1)), "Attributes " +
ParamAttr::getAsString(MutI) + " are incompatible!", V);
Attribute::getAsString(MutI) + " are incompatible!", V);
}
Attributes TypeI = Attrs & ParamAttr::typeIncompatible(Ty);
Attributes TypeI = Attrs & Attribute::typeIncompatible(Ty);
Assert1(!TypeI, "Wrong type for attribute " +
ParamAttr::getAsString(TypeI), V);
Attribute::getAsString(TypeI), V);
Attributes ByValI = Attrs & ParamAttr::ByVal;
Attributes ByValI = Attrs & Attribute::ByVal;
if (const PointerType *PTy = dyn_cast<PointerType>(Ty)) {
Assert1(!ByValI || PTy->getElementType()->isSized(),
"Attribute " + ParamAttr::getAsString(ByValI) +
"Attribute " + Attribute::getAsString(ByValI) +
" does not support unsized types!", V);
} else {
Assert1(!ByValI,
"Attribute " + ParamAttr::getAsString(ByValI) +
"Attribute " + Attribute::getAsString(ByValI) +
" only applies to parameters with pointer type!", V);
}
}
@ -447,7 +447,7 @@ void Verifier::VerifyAttrs(Attributes Attrs, const Type *Ty,
// VerifyFunctionAttrs - Check parameter attributes against a function type.
// The value V is printed in error messages.
void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
const PAListPtr &Attrs,
const AttrListPtr &Attrs,
const Value *V) {
if (Attrs.isEmpty())
return;
@ -455,7 +455,7 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
bool SawNest = false;
for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
const FnAttributeWithIndex &Attr = Attrs.getSlot(i);
const AttributeWithIndex &Attr = Attrs.getSlot(i);
const Type *Ty;
if (Attr.Index == 0)
@ -467,17 +467,17 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
VerifyAttrs(Attr.Attrs, Ty, Attr.Index == 0, V);
if (Attr.Attrs & ParamAttr::Nest) {
if (Attr.Attrs & Attribute::Nest) {
Assert1(!SawNest, "More than one parameter has attribute nest!", V);
SawNest = true;
}
if (Attr.Attrs & ParamAttr::StructRet)
if (Attr.Attrs & Attribute::StructRet)
Assert1(Attr.Index == 1, "Attribute sret not on first parameter!", V);
}
}
static bool VerifyAttributeCount(const PAListPtr &Attrs, unsigned Params) {
static bool VerifyAttributeCount(const AttrListPtr &Attrs, unsigned Params) {
if (Attrs.isEmpty())
return true;
@ -508,7 +508,7 @@ void Verifier::visitFunction(Function &F) {
Assert1(!F.hasStructRetAttr() || F.getReturnType() == Type::VoidTy,
"Invalid struct return type!", &F);
const PAListPtr &Attrs = F.getParamAttrs();
const AttrListPtr &Attrs = F.getAttributes();
Assert1(VerifyAttributeCount(Attrs, FT->getNumParams()),
"Attributes after last parameter!", &F);
@ -965,7 +965,7 @@ void Verifier::VerifyCallSite(CallSite CS) {
"Call parameter type does not match function signature!",
CS.getArgument(i), FTy->getParamType(i), I);
const PAListPtr &Attrs = CS.getParamAttrs();
const AttrListPtr &Attrs = CS.getAttributes();
Assert1(VerifyAttributeCount(Attrs, CS.arg_size()),
"Attributes after last parameter!", I);
@ -976,12 +976,12 @@ void Verifier::VerifyCallSite(CallSite CS) {
if (FTy->isVarArg())
// Check attributes on the varargs part.
for (unsigned Idx = 1 + FTy->getNumParams(); Idx <= CS.arg_size(); ++Idx) {
Attributes Attr = Attrs.getParamAttrs(Idx);
Attributes Attr = Attrs.getAttributes(Idx);
VerifyAttrs(Attr, CS.getArgument(Idx-1)->getType(), false, I);
Attributes VArgI = Attr & ParamAttr::VarArgsIncompatible;
Assert1(!VArgI, "Attribute " + ParamAttr::getAsString(VArgI) +
Attributes VArgI = Attr & Attribute::VarArgsIncompatible;
Assert1(!VArgI, "Attribute " + Attribute::getAsString(VArgI) +
" cannot be used for vararg call arguments!", I);
}
@ -1523,7 +1523,7 @@ void Verifier::VerifyIntrinsicPrototype(Intrinsic::ID ID,
}
// Check parameter attributes.
Assert1(F->getParamAttrs() == Intrinsic::getParamAttrs(ID),
Assert1(F->getAttributes() == Intrinsic::getAttributes(ID),
"Intrinsic has wrong parameter attributes!", F);
}

View File

@ -314,7 +314,7 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
break;
}
}
OS << " Attr |= ParamAttr::ReadNone; // These do not access memory.\n";
OS << " Attr |= Attribute::ReadNone; // These do not access memory.\n";
OS << " break;\n";
for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
switch (Ints[i].ModRef) {
@ -325,7 +325,7 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
break;
}
}
OS << " Attr |= ParamAttr::ReadOnly; // These do not write memory.\n";
OS << " Attr |= Attribute::ReadOnly; // These do not write memory.\n";
OS << " break;\n";
OS << " }\n";
OS << "#endif\n\n";