[llvm-commits] [dragonegg] r154741 - in /dragonegg/trunk: include/dragonegg/Trees.h include/x86/dragonegg/Target.h src/Convert.cpp src/Debug.cpp src/DefaultABI.cpp src/Types.cpp

Duncan Sands baldrick at free.fr
Sat Apr 14 03:20:20 PDT 2012


Author: baldrick
Date: Sat Apr 14 05:20:20 2012
New Revision: 154741

URL: http://llvm.org/viewvc/llvm-project?rev=154741&view=rev
Log:
Introduce helper "tree codes" for expressing convenient concepts.

Modified:
    dragonegg/trunk/include/dragonegg/Trees.h
    dragonegg/trunk/include/x86/dragonegg/Target.h
    dragonegg/trunk/src/Convert.cpp
    dragonegg/trunk/src/Debug.cpp
    dragonegg/trunk/src/DefaultABI.cpp
    dragonegg/trunk/src/Types.cpp

Modified: dragonegg/trunk/include/dragonegg/Trees.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Trees.h?rev=154741&r1=154740&r2=154741&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Trees.h (original)
+++ dragonegg/trunk/include/dragonegg/Trees.h Sat Apr 14 05:20:20 2012
@@ -36,10 +36,21 @@
 // headers (and this one, as it may include GCC headers) are always included
 // last.
 
+/// dragonegg_tree_code - Fake helper tree codes.
+enum dragonegg_tree_code {
+  STRUCT_TYPE, // A record, union or qualified union type.
+};
+
 /// isa - Return true if the given tree has the specified code.
 template<enum tree_code code> bool isa(const_tree t) {
   return TREE_CODE(t) == code;
 }
+template<enum dragonegg_tree_code code> bool isa(const_tree t) {
+  switch (code) {
+  case STRUCT_TYPE:
+    return isa<RECORD_TYPE>(t) || isa<UNION_TYPE>(t) || isa<QUAL_UNION_TYPE>(t);
+  }
+}
 
 /// 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

Modified: dragonegg/trunk/include/x86/dragonegg/Target.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/x86/dragonegg/Target.h?rev=154741&r1=154740&r2=154741&view=diff
==============================================================================
--- dragonegg/trunk/include/x86/dragonegg/Target.h (original)
+++ dragonegg/trunk/include/x86/dragonegg/Target.h Sat Apr 14 05:20:20 2012
@@ -70,7 +70,7 @@
                                       local_fp_regparm)         \
   {                                                             \
     if (!TARGET_64BIT) {                                        \
-      if (TREE_CODE(Type) == REAL_TYPE &&                       \
+      if (isa<REAL_TYPE>(Type) &&                               \
           (TYPE_PRECISION(Type)==32 ||                          \
            TYPE_PRECISION(Type)==64)) {                         \
           local_fp_regparm -= 1;                                \

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=154741&r1=154740&r2=154741&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Sat Apr 14 05:20:20 2012
@@ -6003,9 +6003,7 @@
   tree FieldDecl = TREE_OPERAND(exp, 1);
   unsigned LVAlign = StructAddrLV.getAlignment();
 
-  assert((isa<RECORD_TYPE>(DECL_CONTEXT(FieldDecl)) ||
-          isa<UNION_TYPE>(DECL_CONTEXT(FieldDecl)) ||
-          isa<QUAL_UNION_TYPE>(DECL_CONTEXT(FieldDecl))));
+  assert(isa<STRUCT_TYPE>(DECL_CONTEXT(FieldDecl)));
 
   Type *StructTy = ConvertType(DECL_CONTEXT(FieldDecl));
 

Modified: dragonegg/trunk/src/Debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Debug.cpp?rev=154741&r1=154740&r2=154741&view=diff
==============================================================================
--- dragonegg/trunk/src/Debug.cpp (original)
+++ dragonegg/trunk/src/Debug.cpp Sat Apr 14 05:20:20 2012
@@ -828,9 +828,7 @@
       continue;
 
     /* Ignore nameless fields.  */
-    if (DECL_NAME (Member) == NULL_TREE
-        && !(isa<UNION_TYPE>(TREE_TYPE(Member)) ||
-             isa<RECORD_TYPE>(TREE_TYPE(Member))))
+    if (DECL_NAME (Member) == NULL_TREE && !isa<STRUCT_TYPE>(TREE_TYPE(Member)))
       continue;
 
     // Field type is the declared type of the field.

Modified: dragonegg/trunk/src/DefaultABI.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/DefaultABI.cpp?rev=154741&r1=154740&r2=154741&view=diff
==============================================================================
--- dragonegg/trunk/src/DefaultABI.cpp (original)
+++ dragonegg/trunk/src/DefaultABI.cpp Sat Apr 14 05:20:20 2012
@@ -117,9 +117,7 @@
 /// isZeroSizedStructOrUnion - Returns true if this is a struct or union
 /// which is zero bits wide.
 bool isZeroSizedStructOrUnion(tree type) {
-  if (!isa<RECORD_TYPE>(type) &&
-      !isa<UNION_TYPE>(type) &&
-      !isa<QUAL_UNION_TYPE>(type))
+  if (!isa<STRUCT_TYPE>(type))
     return false;
   return int_size_in_bytes(type) == 0;
 }

Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=154741&r1=154740&r2=154741&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Sat Apr 14 05:20:20 2012
@@ -939,8 +939,7 @@
 
     // If the pointee is a record or union type then return a pointer to its
     // placeholder type.  Otherwise return {}*.
-    if (isa<QUAL_UNION_TYPE>(pointee) || isa<RECORD_TYPE>(pointee) ||
-        isa<UNION_TYPE>(pointee))
+    if (isa<STRUCT_TYPE>(pointee))
       PointeeTy = getCachedType(pointee);
     else
       PointeeTy = StructType::get(Context);
@@ -1566,9 +1565,7 @@
     // the nasty {}* type we are obliged to return in general.
     for (size_t i = 0, e = SCC.size(); i != e; ++i) {
       tree some_type = SCC[i];
-      if (!isa<QUAL_UNION_TYPE>(some_type) &&
-          !isa<RECORD_TYPE>(some_type) &&
-          !isa<UNION_TYPE>(some_type)) {
+      if (!isa<STRUCT_TYPE>(some_type)) {
         assert(!getCachedType(some_type) && "Type already converted!");
         continue;
       }





More information about the llvm-commits mailing list