[llvm-commits] [dragonegg] r153388 - in /dragonegg/trunk: include/dragonegg/Trees.h src/Trees.cpp

Duncan Sands baldrick at free.fr
Sat Mar 24 11:18:03 PDT 2012


Author: baldrick
Date: Sat Mar 24 13:18:03 2012
New Revision: 153388

URL: http://llvm.org/viewvc/llvm-project?rev=153388&view=rev
Log:
These methods are read-only on the tree node so have them take a const_tree
rather than a tree.

Modified:
    dragonegg/trunk/include/dragonegg/Trees.h
    dragonegg/trunk/src/Trees.cpp

Modified: dragonegg/trunk/include/dragonegg/Trees.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Trees.h?rev=153388&r1=153387&r2=153388&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Trees.h (original)
+++ dragonegg/trunk/include/dragonegg/Trees.h Sat Mar 24 13:18:03 2012
@@ -35,50 +35,53 @@
 /// getDescriptiveName - Return a helpful name for the given tree, or an empty
 /// string if no sensible name was found.  These names are used to make the IR
 /// more readable, and have no official status.
-std::string getDescriptiveName(tree t);
+std::string getDescriptiveName(const_tree t);
 
 /// main_type - Return the main variant of the given tree's type.
 inline tree main_type(tree exp) {
   return TYPE_MAIN_VARIANT(TREE_TYPE(exp));
 }
+inline const_tree main_type(const_tree exp) {
+  return TYPE_MAIN_VARIANT(TREE_TYPE(exp));
+}
 
 /// hasNUW - Return whether overflowing unsigned operations on this type result
 /// in undefined behaviour.
-inline bool hasNUW(tree type) {
+inline bool hasNUW(const_tree type) {
   return TYPE_UNSIGNED(type) && TYPE_OVERFLOW_UNDEFINED(type);
 }
 
 /// hasNSW - Return whether overflowing signed operations on this type result
 /// in undefined behaviour.
-inline bool hasNSW(tree type) {
+inline bool hasNSW(const_tree type) {
   return !TYPE_UNSIGNED(type) && TYPE_OVERFLOW_UNDEFINED(type);
 }
 
 /// getIntegerValue - Return the specified INTEGER_CST as an APInt.
-llvm::APInt getIntegerValue(tree exp);
+llvm::APInt getIntegerValue(const_tree exp);
 
 /// isInt64 - Return true if t is an INTEGER_CST that fits in a 64 bit integer.
 /// If Unsigned is false, returns whether it fits in a int64_t.  If Unsigned is
 /// true, returns whether the value is non-negative and fits in a uint64_t.
 /// Always returns false for overflowed constants or if t is NULL.
-bool isInt64(tree t, bool Unsigned);
+bool isInt64(const_tree t, bool Unsigned);
 
 /// getInt64 - Extract the value of an INTEGER_CST as a 64 bit integer.  If
 /// Unsigned is false, the value must fit in a int64_t.  If Unsigned is true,
 /// the value must be non-negative and fit in a uint64_t.  Must not be used on
 /// overflowed constants.  These conditions can be checked by calling isInt64.
-uint64_t getInt64(tree t, bool Unsigned);
+uint64_t getInt64(const_tree t, bool Unsigned);
 
 /// OffsetIsLLVMCompatible - Return true if the given field is offset from the
 /// start of the record by a constant amount which is not humongously big.
-inline bool OffsetIsLLVMCompatible(tree field_decl) {
+inline bool OffsetIsLLVMCompatible(const_tree field_decl) {
   return isInt64(DECL_FIELD_OFFSET(field_decl), true);
 }
 
 /// getFieldOffsetInBits - Return the bit offset of a FIELD_DECL in a structure.
-uint64_t getFieldOffsetInBits(tree field);
+uint64_t getFieldOffsetInBits(const_tree field);
 
 /// isBitfield - Returns whether to treat the specified field as a bitfield.
-bool isBitfield(tree field_decl);
+bool isBitfield(const_tree field_decl);
 
 #endif /* DRAGONEGG_TREES_H */

Modified: dragonegg/trunk/src/Trees.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Trees.cpp?rev=153388&r1=153387&r2=153388&view=diff
==============================================================================
--- dragonegg/trunk/src/Trees.cpp (original)
+++ dragonegg/trunk/src/Trees.cpp Sat Mar 24 13:18:03 2012
@@ -57,7 +57,7 @@
 /// getDescriptiveName - Return a helpful name for the given tree, or an empty
 /// string if no sensible name was found.  These names are used to make the IR
 /// more readable, and have no official status.
-std::string getDescriptiveName(tree t) {
+std::string getDescriptiveName(const_tree t) {
   if (!t) return std::string(); // Occurs when recursing.
 
   // Name identifier nodes after their contents.  This gives the desired effect
@@ -132,7 +132,7 @@
 }
 
 /// getIntegerValue - Return the specified INTEGER_CST as an APInt.
-APInt getIntegerValue(tree exp) {
+APInt getIntegerValue(const_tree exp) {
   double_int val = tree_to_double_int(exp);
   unsigned NumBits = TYPE_PRECISION(TREE_TYPE(exp));
 
@@ -150,7 +150,7 @@
 /// If Unsigned is false, returns whether it fits in a int64_t.  If Unsigned is
 /// true, returns whether the value is non-negative and fits in a uint64_t.
 /// Always returns false for overflowed constants.
-bool isInt64(tree t, bool Unsigned) {
+bool isInt64(const_tree t, bool Unsigned) {
   if (!t)
     return false;
   if (HOST_BITS_PER_WIDE_INT == 64)
@@ -170,7 +170,7 @@
 /// Unsigned is false, the value must fit in a int64_t.  If Unsigned is true,
 /// the value must be non-negative and fit in a uint64_t.  Must not be used on
 /// overflowed constants.  These conditions can be checked by calling isInt64.
-uint64_t getInt64(tree t, bool Unsigned) {
+uint64_t getInt64(const_tree t, bool Unsigned) {
   assert(isInt64(t, Unsigned) && "invalid constant!");
   (void)Unsigned; // Otherwise unused if asserts off - avoid compiler warning.
   unsigned HOST_WIDE_INT LO = (unsigned HOST_WIDE_INT)TREE_INT_CST_LOW(t);
@@ -185,7 +185,7 @@
 }
 
 /// getFieldOffsetInBits - Return the bit offset of a FIELD_DECL in a structure.
-uint64_t getFieldOffsetInBits(tree field) {
+uint64_t getFieldOffsetInBits(const_tree field) {
   assert(OffsetIsLLVMCompatible(field) && "Offset is not constant!");
   uint64_t Result = getInt64(DECL_FIELD_BIT_OFFSET(field), true);
   Result += getInt64(DECL_FIELD_OFFSET(field), true) * BITS_PER_UNIT;
@@ -193,7 +193,7 @@
 }
 
 /// isBitfield - Returns whether to treat the specified field as a bitfield.
-bool isBitfield(tree_node *field_decl) {
+bool isBitfield(const_tree field_decl) {
   if (!DECL_BIT_FIELD(field_decl))
     return false;
 





More information about the llvm-commits mailing list