[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h added (r1.1)
---
Log message:

For PR1146: http://llvm.org/PR1146 :
New header file to provide parameter attribute declarations.


---
Diffs of the changes:  (+148 -0)

 ParameterAttributes.h |  148 ++
 1 files changed, 148 insertions(+)


Index: llvm/include/llvm/ParameterAttributes.h
diff -c /dev/null llvm/include/llvm/ParameterAttributes.h:1.1
*** /dev/null   Sun Apr  8 09:47:00 2007
--- llvm/include/llvm/ParameterAttributes.h Sun Apr  8 09:46:50 2007
***
*** 0 
--- 1,148 
+ //===-- llvm/ParameterAttributes.h - Container for Param Attrs --*- C++ 
-*-===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Reid Spencer and is distributed under the 
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ 
//===--===//
+ //
+ // This file contains the types necessary to represent the parameter 
attributes
+ // associated with functions and their calls.
+ //
+ // The implementations of these classes live in lib/VMCore/Function.cpp.
+ //
+ 
//===--===//
+ 
+ #ifndef LLVM_PARAMETER_ATTRIBUTES_H
+ #define LLVM_PARAMETER_ATTRIBUTES_H
+ 
+ #include 
+ 
+ namespace llvm {
+ 
+ /// Function parameters 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.
+ enum ParameterAttributes {
+   NoAttributeSet = 0,  ///< No attributes have been set
+   ZExtAttribute  = 1 << 0, ///< zero extended before/after call
+   SExtAttribute  = 1 << 1, ///< sign extended before/after call
+   NoReturnAttribute  = 1 << 2, ///< mark the function as not returning
+   InRegAttribute = 1 << 3, ///< force argument to be passed in register
+   StructRetAttribute = 1 << 4, ///< hidden pointer to structure to return
+   NoUnwindAttribute  = 1 << 5  ///< Function doesn't unwind stack
+ };
+ 
+ /// This class is used by Function and CallInst to represent the set of 
+ /// parameter attributes used. It represents a list of pairs of uint16_t, one
+ /// for the parameter index, and one a set of ParameterAttributes bits.
+ /// Parameters that have no attributes are not present in the list. The list
+ /// may also be empty, but this doesn't occur in practice.  The list 
constructs
+ /// as empty and is filled by the insert method. The list can be turned into 
+ /// a string of mnemonics suitable for LLVM Assembly output. Various accessors
+ /// are provided to obtain information about the attributes.
+ /// @brief A List of ParameterAttributes.
+ class ParamAttrsList {
+   /// @name Accessors
+   /// @{
+   public:
+ /// Returns the parameter index of a particular parameter attribute in 
this
+ /// list of attributes. Note that the attr_index is an index into this 
+ /// class's list of attributes, not the index of the parameter. The result
+ /// is the index of the parameter. 
+ /// @brief Get a parameter index
+ uint16_t getParamIndex(unsigned attr_index) const {
+   return attrs[attr_index].index;
+ }
+ 
+ /// The parameter attributes for the \p indexth parameter are returned. 
+ /// The 0th parameter refers to the return type of the function. Note that
+ /// the \p param_index is an index into the function's parameters, not an
+ /// index into this class's list of attributes. The result of 
getParamIndex
+ /// is always suitable input to this function.
+ /// @returns The all the ParameterAttributes for the \p indexth parameter
+ /// as a uint16_t of enumeration values OR'd together.
+ /// @brief Get the attributes for a parameter
+ uint16_t getParamAttrs(uint16_t param_index) const;
+ 
+ /// This checks to see if the \p ith function parameter has the parameter
+ /// attribute given by \p attr set.
+ /// @returns true if the parameter attribute is set
+ /// @brief Determine if a ParameterAttributes is set
+ bool paramHasAttr(uint16_t i, ParameterAttributes attr) const {
+   return getParamAttrs(i) & attr;
+ }
+ 
+ /// Determines how many parameter attributes are set in this 
ParamAttrsList.
+ /// This says nothing about how many parameters the function has. It also
+ /// says nothing about the highest parameter index that has attributes.
+ /// @returns the number of parameter attributes in this ParamAttrsList.
+ /// @brief Return the number of parameter attributes this type has.
+ unsigned size() const { return attrs.size(); }
+ 
+ /// @returns true if this ParamAttrsList is empty.
+ /// @brief Determine emptiness of ParamAttrsList.
+ unsigned empty() const { r

[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.1 -> 1.2
---
Log message:

Implement review feedback.


---
Diffs of the changes:  (+4 -5)

 ParameterAttributes.h |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.1 
llvm/include/llvm/ParameterAttributes.h:1.2
--- llvm/include/llvm/ParameterAttributes.h:1.1 Sun Apr  8 09:46:50 2007
+++ llvm/include/llvm/ParameterAttributes.h Sun Apr  8 17:05:44 2007
@@ -17,7 +17,7 @@
 #ifndef LLVM_PARAMETER_ATTRIBUTES_H
 #define LLVM_PARAMETER_ATTRIBUTES_H
 
-#include 
+#include "llvm/ADT/SmallVector.h"
 
 namespace llvm {
 
@@ -121,11 +121,10 @@
   /// @{
   public:
 /// This adds a pair to the list of parameter index and attribute pairs 
-/// represented by this class. No check is made to determine whether 
-/// param_index exists already. This pair is just added to the end. It is
-/// the user's responsibility to insert the pairs wisely.
+/// represented by this class. If the parameter index already exists then
+/// its attributes are overwritten. Otherwise it is added to the list.
 /// @brief Insert ParameterAttributes for an index
-void insert(uint16_t param_index, uint16_t attrs);
+void setAttributes(uint16_t param_index, uint16_t attrs);
 
   /// @}
   /// @name Data



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.2 -> 1.3
---
Log message:

Implement more feedback:
* Allow attributes to be added and removed singly or jointly so that in
  the future something like -pruneh can manipulate them more easily.
* Move functions generally only useful for LLVM internals to the end of
  the accessors list instead of the beginning.


---
Diffs of the changes:  (+54 -24)

 ParameterAttributes.h |   78 ++
 1 files changed, 54 insertions(+), 24 deletions(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.2 
llvm/include/llvm/ParameterAttributes.h:1.3
--- llvm/include/llvm/ParameterAttributes.h:1.2 Sun Apr  8 17:05:44 2007
+++ llvm/include/llvm/ParameterAttributes.h Sun Apr  8 17:30:27 2007
@@ -48,15 +48,6 @@
   /// @name Accessors
   /// @{
   public:
-/// Returns the parameter index of a particular parameter attribute in this
-/// list of attributes. Note that the attr_index is an index into this 
-/// class's list of attributes, not the index of the parameter. The result
-/// is the index of the parameter. 
-/// @brief Get a parameter index
-uint16_t getParamIndex(unsigned attr_index) const {
-  return attrs[attr_index].index;
-}
-
 /// The parameter attributes for the \p indexth parameter are returned. 
 /// The 0th parameter refers to the return type of the function. Note that
 /// the \p param_index is an index into the function's parameters, not an
@@ -75,17 +66,6 @@
   return getParamAttrs(i) & attr;
 }
 
-/// Determines how many parameter attributes are set in this 
ParamAttrsList.
-/// This says nothing about how many parameters the function has. It also
-/// says nothing about the highest parameter index that has attributes.
-/// @returns the number of parameter attributes in this ParamAttrsList.
-/// @brief Return the number of parameter attributes this type has.
-unsigned size() const { return attrs.size(); }
-
-/// @returns true if this ParamAttrsList is empty.
-/// @brief Determine emptiness of ParamAttrsList.
-unsigned empty() const { return attrs.empty(); }
-
 /// The set of ParameterAttributes set in Attributes is converted to a
 /// string of equivalent mnemonics. This is, presumably, for writing out
 /// the mnemonics for the assembly writer. 
@@ -116,15 +96,65 @@
   }
   return false;
 }
+
+/// Returns the parameter index of a particular parameter attribute in this
+/// list of attributes. Note that the attr_index is an index into this 
+/// class's list of attributes, not the index of a parameter. The result
+/// is the index of the parameter. Clients generally should not use this
+/// method. It is used internally by LLVM.
+/// @brief Get a parameter index
+uint16_t getParamIndex(unsigned attr_index) const {
+  return attrs[attr_index].index;
+}
+
+/// Determines how many parameter attributes are set in this 
ParamAttrsList.
+/// This says nothing about how many parameters the function has. It also
+/// says nothing about the highest parameter index that has attributes. 
+/// Clients generally should not use this method. It is used internally by
+/// LLVM.
+/// @returns the number of parameter attributes in this ParamAttrsList.
+/// @brief Return the number of parameter attributes this type has.
+unsigned size() const { return attrs.size(); }
+
+/// Clients generally should not use this method. It is used internally by
+/// LLVM.
+/// @returns true if this ParamAttrsList is empty.
+/// @brief Determine emptiness of ParamAttrsList.
+unsigned empty() const { return attrs.empty(); }
+
   /// @}
   /// @name Mutators
   /// @{
   public:
-/// This adds a pair to the list of parameter index and attribute pairs 
-/// represented by this class. If the parameter index already exists then
-/// its attributes are overwritten. Otherwise it is added to the list.
+/// This method will add the \p attr to the parameter with index
+/// \p param_index. If the parameter index does not exist it will be 
created
+/// and the \p will be the only attribute set. Otherwise, any existing
+/// attributes for the specified parameter remain set and the attribute
+/// given by \p attr is also set.
+/// @brief Add a single ParameterAttribute
+void addAttribute(uint16_t param_index, ParameterAttribute attr);
+
+/// This method will remove the \p attr to the parameter with index
+/// \p param_index. If the parameter index does not exist in the list,  
+/// an assertion will occur. If the specified attribute is the last 
+/// attribute set for the specified parameter index, the attributes for 
+/// that index are removed completely from the list (size is decremented).
+/// Otherwise, the specified attribute

[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.3 -> 1.4
---
Log message:

Fix a typo.


---
Diffs of the changes:  (+2 -2)

 ParameterAttributes.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.3 
llvm/include/llvm/ParameterAttributes.h:1.4
--- llvm/include/llvm/ParameterAttributes.h:1.3 Sun Apr  8 17:30:27 2007
+++ llvm/include/llvm/ParameterAttributes.h Sun Apr  8 17:50:29 2007
@@ -132,7 +132,7 @@
 /// attributes for the specified parameter remain set and the attribute
 /// given by \p attr is also set.
 /// @brief Add a single ParameterAttribute
-void addAttribute(uint16_t param_index, ParameterAttribute attr);
+void addAttribute(uint16_t param_index, ParameterAttributes attr);
 
 /// This method will remove the \p attr to the parameter with index
 /// \p param_index. If the parameter index does not exist in the list,  
@@ -142,7 +142,7 @@
 /// Otherwise, the specified attribute is removed from the set of 
attributes
 /// for the given index.
 /// @brief Remove a single ParameterAttribute
-void removeAttribute(uint16_t param_index, ParameterAttribute attr);
+void removeAttribute(uint16_t param_index, ParameterAttributes attr);
 
 /// This is identical to addAttribute but permits you to set multiple
 /// attributes at the same time. The \p attrs value is expected to be a



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.4 -> 1.5
---
Log message:

Remove redundancy.


---
Diffs of the changes:  (+11 -23)

 ParameterAttributes.h |   34 +++---
 1 files changed, 11 insertions(+), 23 deletions(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.4 
llvm/include/llvm/ParameterAttributes.h:1.5
--- llvm/include/llvm/ParameterAttributes.h:1.4 Sun Apr  8 17:50:29 2007
+++ llvm/include/llvm/ParameterAttributes.h Sun Apr  8 20:26:02 2007
@@ -126,34 +126,22 @@
   /// @name Mutators
   /// @{
   public:
-/// This method will add the \p attr to the parameter with index
+/// This method will add the \p attrs to the parameter with index
 /// \p param_index. If the parameter index does not exist it will be 
created
-/// and the \p will be the only attribute set. Otherwise, any existing
-/// attributes for the specified parameter remain set and the attribute
-/// given by \p attr is also set.
-/// @brief Add a single ParameterAttribute
-void addAttribute(uint16_t param_index, ParameterAttributes attr);
+/// and the \p attrs will be the only attributes set. Otherwise, any 
+/// existing attributes for the specified parameter remain set and the 
+/// attributes given by \p attrs are also set.
+/// @brief Add ParameterAttributes.
+void addAttributes(uint16_t param_index, uint16_t attrs);
 
-/// This method will remove the \p attr to the parameter with index
+/// This method will remove the \p attrs to the parameter with index
 /// \p param_index. If the parameter index does not exist in the list,  
-/// an assertion will occur. If the specified attribute is the last 
-/// attribute set for the specified parameter index, the attributes for 
+/// an assertion will occur. If the specified attributes are the last 
+/// attributes set for the specified parameter index, the attributes for 
 /// that index are removed completely from the list (size is decremented).
-/// Otherwise, the specified attribute is removed from the set of 
attributes
-/// for the given index.
+/// Otherwise, the specified attributes are removed from the set of 
+/// attributes for the given index, retaining any others.
 /// @brief Remove a single ParameterAttribute
-void removeAttribute(uint16_t param_index, ParameterAttributes attr);
-
-/// This is identical to addAttribute but permits you to set multiple
-/// attributes at the same time. The \p attrs value is expected to be a
-/// bitwise OR of the attributes you would like to have added.
-/// @brief Insert ParameterAttributes for an index
-void addAttributes(uint16_t param_index, uint16_t attrs);
-
-/// This is identical to removeAttribute but permits you to remove multiple
-/// attributes at the same time. The\p attrs value is expected to be a
-/// bitwise OR of the attribute syou would like to have removed.
-/// @brief Remove ParameterAttributes for an index
 void removeAttributes(uint16_t param_index, uint16_t attrs);
 
   /// @}



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.5 -> 1.6
---
Log message:

Chris convinced me that the default size of the SmallVector (2) was too 
small.  Since it doesn't cost much to have 2 more (8 bytes), but not having
them would require a malloc as soon as the third one is needed. Setting 
the default to 4 delays the malloc until the 5th parameter attribute.


---
Diffs of the changes:  (+1 -1)

 ParameterAttributes.h |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.5 
llvm/include/llvm/ParameterAttributes.h:1.6
--- llvm/include/llvm/ParameterAttributes.h:1.5 Sun Apr  8 20:26:02 2007
+++ llvm/include/llvm/ParameterAttributes.h Sun Apr  8 20:53:54 2007
@@ -156,7 +156,7 @@
   uint16_t index; ///< Index of the parameter for which the attributes 
apply
 };
 
-SmallVector attrs; ///< The list of attributes
+SmallVector attrs; ///< The list of attributes
   /// @}
 };
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-10 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.6 -> 1.7
---
Log message:

For PR1146: http://llvm.org/PR1146 :
Put the parameter attributes in their own ParamAttr name space. Adjust the
rest of llvm as a result.


---
Diffs of the changes:  (+49 -18)

 ParameterAttributes.h |   67 --
 1 files changed, 49 insertions(+), 18 deletions(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.6 
llvm/include/llvm/ParameterAttributes.h:1.7
--- llvm/include/llvm/ParameterAttributes.h:1.6 Sun Apr  8 20:53:54 2007
+++ llvm/include/llvm/ParameterAttributes.h Tue Apr 10 21:44:19 2007
@@ -1,4 +1,4 @@
-//===-- llvm/ParameterAttributes.h - Container for Param Attrs --*- C++ 
-*-===//
+//===-- llvm/ParameterAttributes.h - Container for ParamAttrs ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -25,16 +25,22 @@
 /// treated by optimizations and code generation. This enumeration lists the
 /// attributes that can be associated with parameters or function results.
 /// @brief Function parameter attributes.
-enum ParameterAttributes {
-  NoAttributeSet = 0,  ///< No attributes have been set
-  ZExtAttribute  = 1 << 0, ///< zero extended before/after call
-  SExtAttribute  = 1 << 1, ///< sign extended before/after call
-  NoReturnAttribute  = 1 << 2, ///< mark the function as not returning
-  InRegAttribute = 1 << 3, ///< force argument to be passed in register
-  StructRetAttribute = 1 << 4, ///< hidden pointer to structure to return
-  NoUnwindAttribute  = 1 << 5  ///< Function doesn't unwind stack
+namespace ParamAttr {
+
+enum Attributes {
+  None   = 0,  ///< No attributes have been set
+  ZExt   = 1 << 0, ///< zero extended before/after call
+  SExt   = 1 << 1, ///< sign extended before/after call
+  NoReturn   = 1 << 2, ///< mark the function as not returning
+  InReg  = 1 << 3, ///< force argument to be passed in register
+  StructRet  = 1 << 4, ///< hidden pointer to structure to return
+  NoUnwind   = 1 << 5  ///< Function doesn't unwind stack
 };
 
+}
+
+typedef ParamAttr::Attributes ParameterAttributes;
+
 /// This class is used by Function and CallInst to represent the set of 
 /// parameter attributes used. It represents a list of pairs of uint16_t, one
 /// for the parameter index, and one a set of ParameterAttributes bits.
@@ -45,6 +51,39 @@
 /// are provided to obtain information about the attributes.
 /// @brief A List of ParameterAttributes.
 class ParamAttrsList {
+  //void operator=(const ParamAttrsList &); // Do not implement
+  //ParamAttrsList(const ParamAttrsList &); // Do not implement
+
+  /// @name Types
+  /// @{
+  public:
+/// This is an internal structure used to associate the ParameterAttributes
+/// with a parameter index. 
+/// @brief ParameterAttributes with a parameter index.
+struct ParamAttrsWithIndex {
+  uint16_t attrs; ///< The attributes that are set, |'d together
+  uint16_t index; ///< Index of the parameter for which the attributes 
apply
+};
+
+/// @brief A vector of attribute/index pairs.
+typedef SmallVector ParamAttrsVector;
+
+  /// @}
+  /// @name Construction
+  /// @{
+  public:
+/// @brief Construct an empty ParamAttrsList
+ParamAttrsList() {}
+
+/// This method ensures the uniqueness of ParamAttrsList instances. The
+/// argument is a vector of attribute/index pairs as represented by the
+/// ParamAttrsWithIndex structure. The vector is used in the construction 
of
+/// the ParamAttrsList instance. If an instance with identical vector pairs
+/// exists, it will be returned instead of creating a new instance.
+/// @brief Get a ParamAttrsList instance.
+ParamAttrsList *get(const ParamAttrsVector &attrVec);
+
+  /// @}
   /// @name Accessors
   /// @{
   public:
@@ -148,15 +187,7 @@
   /// @name Data
   /// @{
   private:
-/// This is an internal structure used to associate the ParameterAttributes
-/// with a parameter index. 
-/// @brief ParameterAttributes with a parameter index.
-struct ParamAttrsWithIndex {
-  uint16_t attrs; ///< The attributes that are set, |'d together
-  uint16_t index; ///< Index of the parameter for which the attributes 
apply
-};
-
-SmallVector attrs; ///< The list of attributes
+ParamAttrsVector attrs; ///< The list of attributes
   /// @}
 };
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-22 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.9 -> 1.10
---
Log message:

Undo premature commit.


---
Diffs of the changes:  (+1 -4)

 ParameterAttributes.h |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.9 
llvm/include/llvm/ParameterAttributes.h:1.10
--- llvm/include/llvm/ParameterAttributes.h:1.9 Sun Apr 22 11:29:35 2007
+++ llvm/include/llvm/ParameterAttributes.h Sun Apr 22 11:30:47 2007
@@ -70,7 +70,7 @@
 void operator=(const ParamAttrsList &); // Do not implement
 ParamAttrsList(const ParamAttrsList &); // Do not implement
 ParamAttrsList();   // Do not implement
-~ParamAttrsList();
+~ParamAttrsList() {}// Not public!
 
 /// @brief Construct an ParamAttrsList from a ParamAttrsVector
 explicit ParamAttrsList(const ParamAttrsVector &attrVec) : attrs(attrVec) 
{}
@@ -162,15 +162,12 @@
   public:
 void Profile(FoldingSetNodeID &ID) const;
 void dump() const;
-void addRef() const { refCount++; }
-void dropRef() const { if (--refCount == 0) delete this; }
 
   /// @}
   /// @name Data
   /// @{
   private:
 ParamAttrsVector attrs; ///< The list of attributes
-mutable unsigned refCount;  ///< The number of references to this 
object
   /// @}
 };
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-22 Thread Reid Spencer


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.8 -> 1.9
---
Log message:

Terminate file with newline.


---
Diffs of the changes:  (+4 -1)

 ParameterAttributes.h |5 -
 1 files changed, 4 insertions(+), 1 deletion(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.8 
llvm/include/llvm/ParameterAttributes.h:1.9
--- llvm/include/llvm/ParameterAttributes.h:1.8 Sun Apr 22 00:46:44 2007
+++ llvm/include/llvm/ParameterAttributes.h Sun Apr 22 11:29:35 2007
@@ -70,7 +70,7 @@
 void operator=(const ParamAttrsList &); // Do not implement
 ParamAttrsList(const ParamAttrsList &); // Do not implement
 ParamAttrsList();   // Do not implement
-~ParamAttrsList() {}// Not public!
+~ParamAttrsList();
 
 /// @brief Construct an ParamAttrsList from a ParamAttrsVector
 explicit ParamAttrsList(const ParamAttrsVector &attrVec) : attrs(attrVec) 
{}
@@ -162,12 +162,15 @@
   public:
 void Profile(FoldingSetNodeID &ID) const;
 void dump() const;
+void addRef() const { refCount++; }
+void dropRef() const { if (--refCount == 0) delete this; }
 
   /// @}
   /// @name Data
   /// @{
   private:
 ParamAttrsVector attrs; ///< The list of attributes
+mutable unsigned refCount;  ///< The number of references to this 
object
   /// @}
 };
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-05-03 Thread Chris Lattner


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.11 -> 1.12
---
Log message:

add a helper


---
Diffs of the changes:  (+4 -0)

 ParameterAttributes.h |4 
 1 files changed, 4 insertions(+)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.11 
llvm/include/llvm/ParameterAttributes.h:1.12
--- llvm/include/llvm/ParameterAttributes.h:1.11Sun Apr 22 12:28:03 2007
+++ llvm/include/llvm/ParameterAttributes.h Thu May  3 22:13:39 2007
@@ -161,6 +161,10 @@
   return attrs[attr_index].index;
 }
 
+uint16_t getParamAttrsAtIndex(unsigned attr_index) const {
+  return attrs[attr_index].attrs;
+}
+
 /// Determines how many parameter attributes are set in this 
ParamAttrsList.
 /// This says nothing about how many parameters the function has. It also
 /// says nothing about the highest parameter index that has attributes. 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-06-04 Thread Zhou Sheng


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.12 -> 1.13
---
Log message:

Commit first round work of PR1373: http://llvm.org/PR1373 . "noalias" is now 
fully supported in 
VMCore, BitCode, and Assembly. Documentation and test case paramattrs.ll
updated also.


---
Diffs of the changes:  (+2 -1)

 ParameterAttributes.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.12 
llvm/include/llvm/ParameterAttributes.h:1.13
--- llvm/include/llvm/ParameterAttributes.h:1.12Thu May  3 22:13:39 2007
+++ llvm/include/llvm/ParameterAttributes.h Tue Jun  5 00:28:25 2007
@@ -35,7 +35,8 @@
   NoReturn   = 1 << 2, ///< mark the function as not returning
   InReg  = 1 << 3, ///< force argument to be passed in register
   StructRet  = 1 << 4, ///< hidden pointer to structure to return
-  NoUnwind   = 1 << 5  ///< Function doesn't unwind stack
+  NoUnwind   = 1 << 5, ///< Function doesn't unwind stack
+  NoAlias= 1 << 6  ///< Considered to not alias after call.
 };
 
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-06-18 Thread Chris Lattner


Changes in directory llvm/include/llvm:

ParameterAttributes.h updated: 1.13 -> 1.14
---
Log message:

add helper


---
Diffs of the changes:  (+7 -0)

 ParameterAttributes.h |7 +++
 1 files changed, 7 insertions(+)


Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.13 
llvm/include/llvm/ParameterAttributes.h:1.14
--- llvm/include/llvm/ParameterAttributes.h:1.13Tue Jun  5 00:28:25 2007
+++ llvm/include/llvm/ParameterAttributes.h Mon Jun 18 16:50:49 2007
@@ -47,6 +47,13 @@
 struct ParamAttrsWithIndex {
   uint16_t attrs; ///< The attributes that are set, |'d together
   uint16_t index; ///< Index of the parameter for which the attributes apply
+  
+  static ParamAttrsWithIndex get(uint16_t idx, uint16_t attrs) {
+ParamAttrsWithIndex P;
+P.index = idx;
+P.attrs = attrs;
+return P;
+  }
 };
 
 /// @brief A vector of attribute/index pairs.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Chris Lattner
> + #ifndef LLVM_PARAMETER_ATTRIBUTES_H
> + #define LLVM_PARAMETER_ATTRIBUTES_H
> +
> + #include 

Please use ""'s instead of <>'s.

> +   public:
> + /// Returns the parameter index of a particular parameter  
> attribute in this
> + /// list of attributes. Note that the attr_index is an index  
> into this
> + /// class's list of attributes, not the index of the  
> parameter. The result
> + /// is the index of the parameter.
> + /// @brief Get a parameter index
> + uint16_t getParamIndex(unsigned attr_index) const {
> +   return attrs[attr_index].index;
> + }

What is this used for?  I'd expect getParamAttrs to be the main  
useful api for this class.

> + /// The parameter attributes for the \p indexth parameter are  
> returned.
> + /// The 0th parameter refers to the return type of the  
> function. Note that
> + /// the \p param_index is an index into the function's  
> parameters, not an
> + /// index into this class's list of attributes. The result of  
> getParamIndex
> + /// is always suitable input to this function.
> + /// @returns The all the ParameterAttributes for the \p  
> indexth parameter
> + /// as a uint16_t of enumeration values OR'd together.
> + /// @brief Get the attributes for a parameter
> + uint16_t getParamAttrs(uint16_t param_index) const;

Did you forget to check in the .cpp file?

> + /// Determines how many parameter attributes are set in this  
> ParamAttrsList.
> + /// This says nothing about how many parameters the function  
> has. It also
> + /// says nothing about the highest parameter index that has  
> attributes.
> + /// @returns the number of parameter attributes in this  
> ParamAttrsList.
> + /// @brief Return the number of parameter attributes this  
> type has.
> + unsigned size() const { return attrs.size(); }

What is this useful for?

> + /// The set of ParameterAttributes 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
> + static std::string getParamAttrsText(uint16_t Attributes);


This requires #include'ing 

> + /// The \p Indexth parameter attribute is converted to string.
> + /// @brief Get the text for the parmeter attributes for one  
> parameter.
> + std::string getParamAttrsTextByIndex(uint16_t Index) const {
> +   return getParamAttrsText(getParamAttrs(Index));
> + }

I think indexes into the array should be an implementation detail of  
the class, not exposed to users.

> + /// @brief Comparison operator for ParamAttrsList
> + bool operator < (const ParamAttrsList& that) const {
> +   if (this->attrs.size() < that.attrs.size())
> + return true;
> +   if (this->attrs.size() > that.attrs.size())
> + return false;
> +   for (unsigned i = 0; i < attrs.size(); ++i) {
> + if (attrs[i].index < that.attrs[i].index)
> +   return true;
> + if (attrs[i].index > that.attrs[i].index)
> +   return false;
> + if (attrs[i].attrs < that.attrs[i].attrs)
> +   return true;
> + if (attrs[i].attrs > that.attrs[i].attrs)
> +   return false;
> +   }

It seems more straight-forward to implement operator< for smallvector  
and ParamAttrsWithIndex.

> +   public:
> + /// This adds a pair to the list of parameter index and  
> attribute pairs
> + /// represented by this class. No check is made to determine  
> whether
> + /// param_index exists already. This pair is just added to  
> the end. It is
> + /// the user's responsibility to insert the pairs wisely.
> + /// @brief Insert ParameterAttributes for an index
> + void insert(uint16_t param_index, uint16_t attrs);

I don't like this API.  I think the class should take care of merging  
attributes for parameters.  Also, should this be named "addAttributes 
()" or something?  Logically this is a bucket of attributes, not a  
sequence, so I don't think 'insert' is a good name.

> + SmallVector attrs; ///< The list of  
> attributes

Obviously random/subjective, but I'd suggest bumping this up to  
having storage for 4 or 6 attributes.

Thanks for tackling this Reid!

-Chris



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Reid Spencer
On Sun, 2007-04-08 at 14:29 -0700, Chris Lattner wrote:
> > + #ifndef LLVM_PARAMETER_ATTRIBUTES_H
> > + #define LLVM_PARAMETER_ATTRIBUTES_H
> > +
> > + #include 
> 
> Please use ""'s instead of <>'s.

Okay.

> 
> > +   public:
> > + /// Returns the parameter index of a particular parameter  
> > attribute in this
> > + /// list of attributes. Note that the attr_index is an index  
> > into this
> > + /// class's list of attributes, not the index of the  
> > parameter. The result
> > + /// is the index of the parameter.
> > + /// @brief Get a parameter index
> > + uint16_t getParamIndex(unsigned attr_index) const {
> > +   return attrs[attr_index].index;
> > + }
> 
> What is this used for?  I'd expect getParamAttrs to be the main  
> useful api for this class.

Sole client: Bytecode Writer. Its useful in situations where you want to
traverse the attributes and get the index/attr pairs.

> 
> > + /// The parameter attributes for the \p indexth parameter are  
> > returned.
> > + /// The 0th parameter refers to the return type of the  
> > function. Note that
> > + /// the \p param_index is an index into the function's  
> > parameters, not an
> > + /// index into this class's list of attributes. The result of  
> > getParamIndex
> > + /// is always suitable input to this function.
> > + /// @returns The all the ParameterAttributes for the \p  
> > indexth parameter
> > + /// as a uint16_t of enumeration values OR'd together.
> > + /// @brief Get the attributes for a parameter
> > + uint16_t getParamAttrs(uint16_t param_index) const;
> 
> Did you forget to check in the .cpp file?

No. This is a preview for you to review, which you've done :)

This isn't #included anywhere.

> 
> > + /// Determines how many parameter attributes are set in this  
> > ParamAttrsList.
> > + /// This says nothing about how many parameters the function  
> > has. It also
> > + /// says nothing about the highest parameter index that has  
> > attributes.
> > + /// @returns the number of parameter attributes in this  
> > ParamAttrsList.
> > + /// @brief Return the number of parameter attributes this  
> > type has.
> > + unsigned size() const { return attrs.size(); }
> 
> What is this useful for?

Bytecode writer.

> 
> > + /// The set of ParameterAttributes 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
> > + static std::string getParamAttrsText(uint16_t Attributes);
> 
> 
> This requires #include'ing 

No, its only #Included into .cpp files, never a .h file. String is
invariably already included. I can add it if you like, but its
redundant. For that matter, smallvector probably is too, I didn't check.

> 
> > + /// The \p Indexth parameter attribute is converted to string.
> > + /// @brief Get the text for the parmeter attributes for one  
> > parameter.
> > + std::string getParamAttrsTextByIndex(uint16_t Index) const {
> > +   return getParamAttrsText(getParamAttrs(Index));
> > + }
> 
> I think indexes into the array should be an implementation detail of  
> the class, not exposed to users.

It seems like overkill to make iterators and expose the index/value
pair.

> 
> > + /// @brief Comparison operator for ParamAttrsList
> > + bool operator < (const ParamAttrsList& that) const {
> > +   if (this->attrs.size() < that.attrs.size())
> > + return true;
> > +   if (this->attrs.size() > that.attrs.size())
> > + return false;
> > +   for (unsigned i = 0; i < attrs.size(); ++i) {
> > + if (attrs[i].index < that.attrs[i].index)
> > +   return true;
> > + if (attrs[i].index > that.attrs[i].index)
> > +   return false;
> > + if (attrs[i].attrs < that.attrs[i].attrs)
> > +   return true;
> > + if (attrs[i].attrs > that.attrs[i].attrs)
> > +   return false;
> > +   }
> 
> It seems more straight-forward to implement operator< for smallvector  
> and ParamAttrsWithIndex.

Perhaps but this is temporary code. It goes away when FunctionTypes are
no longer using this to determine type equality. *shrug*

> 
> > +   public:
> > + /// This adds a pair to the list of parameter index and  
> > attribute pairs
> > + /// represented by this class. No check is made to determine  
> > whether
> > + /// param_index exists already. This pair is just added to  
> > the end. It is
> > + /// the user's responsibility to insert the pairs wisely.
> > + /// @brief Insert ParameterAttributes for an index
> > + void insert(uint16_t param_index, uint16_t attrs);
> 
> I don't like this API.  I think the class should take care of merging  
> attributes for parameters.  Also, should this be named "addAttributes 
> ()" or somethin

Re: [llvm-commits] CVS: llvm/include/llvm/ParameterAttributes.h

2007-04-08 Thread Chris Lattner
>> What is this used for?  I'd expect getParamAttrs to be the main
>> useful api for this class.
>
> Sole client: Bytecode Writer. Its useful in situations where you  
> want to
> traverse the attributes and get the index/attr pairs.

Gotcha, ok.  Please move these methods lower in the class definition  
to de-emphasize them, and add comments saying that clients should use  
the other methods.
>> Did you forget to check in the .cpp file?
>
> No. This is a preview for you to review, which you've done :)

Gotcha :)


> This isn't #included anywhere.

Yep, I know.

>>> + /// The set of ParameterAttributes 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
>>> + static std::string getParamAttrsText(uint16_t Attributes);
>>
>>
>> This requires #include'ing 
>
> No, its only #Included into .cpp files, never a .h file. String is
> invariably already included. I can add it if you like, but its
> redundant. For that matter, smallvector probably is too, I didn't  
> check.

Header files should be self contained :).

>>> + /// The \p Indexth parameter attribute is converted to string.
>>> + /// @brief Get the text for the parmeter attributes for one
>>> parameter.
>>> + std::string getParamAttrsTextByIndex(uint16_t Index) const {
>>> +   return getParamAttrsText(getParamAttrs(Index));
>>> + }
>>
>> I think indexes into the array should be an implementation detail of
>> the class, not exposed to users.
>
> It seems like overkill to make iterators and expose the index/value
> pair.

Sounds fine, I didn't think about the bcwriter.

>>> + /// @brief Comparison operator for ParamAttrsList
>>> + bool operator < (const ParamAttrsList& that) const {
>>> +   if (this->attrs.size() < that.attrs.size())
>>> + return true;
>>> +   if (this->attrs.size() > that.attrs.size())
>>> + return false;
>>> +   for (unsigned i = 0; i < attrs.size(); ++i) {
>>> + if (attrs[i].index < that.attrs[i].index)
>>> +   return true;
>>> + if (attrs[i].index > that.attrs[i].index)
>>> +   return false;
>>> + if (attrs[i].attrs < that.attrs[i].attrs)
>>> +   return true;
>>> + if (attrs[i].attrs > that.attrs[i].attrs)
>>> +   return false;
>>> +   }
>>
>> It seems more straight-forward to implement operator< for smallvector
>> and ParamAttrsWithIndex.
>
> Perhaps but this is temporary code. It goes away when FunctionTypes  
> are
> no longer using this to determine type equality. *shrug*

Ok.

>>> +   public:
>>> + /// This adds a pair to the list of parameter index and
>>> attribute pairs
>>> + /// represented by this class. No check is made to determine
>>> whether
>>> + /// param_index exists already. This pair is just added to
>>> the end. It is
>>> + /// the user's responsibility to insert the pairs wisely.
>>> + /// @brief Insert ParameterAttributes for an index
>>> + void insert(uint16_t param_index, uint16_t attrs);
>>
>> I don't like this API.  I think the class should take care of merging
>> attributes for parameters.  Also, should this be named "addAttributes
>> ()" or something?  Logically this is a bucket of attributes, not a
>> sequence, so I don't think 'insert' is a good name.
>
> Okay. If you "add" an attribute does it OR it with existing  
> contents or
> replace existing contents?

It should OR it in.

> It is this way because there are 0 uses of anyone trying to set  
> multiple
> attributes on a given parameter at different points. Generally what is
> done is the bit mask is OR'd together and then insert is called.

RIght.  I'm thinking of things like "pruneeh", which can determine  
that a function never throws.  In that case, it wants to add on the  
"nothrow" attribute.

> Renaming to setAttributes would be acceptable.

"addAttribute" sounds good.  We should probably also have  
'removeAttribute' for symmetry.

>>
>>> + SmallVector attrs; ///< The list of
>>> attributes
>>
>> Obviously random/subjective, but I'd suggest bumping this up to
>> having storage for 4 or 6 attributes.
>
> Why? The typical use case that I have seen is 1-2 (sret/sext).  Why do
> you think 4-6 is typical?

I'd expect to see an attribute for every integer argument smaller  
than int, no?

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits