Ability to create and match enum types.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 27 Aug 2010 00:08:35 +0000 (20:08 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 27 Aug 2010 00:08:35 +0000 (20:08 -0400)
src/aop-type.c
src/aop-type.h
src/aop.h

index 0c5caffc46e456499f3093017b873fefb416d7c6..9066c8865eef8fb7e4087243d06d3070e88d1e1e 100644 (file)
@@ -533,6 +533,16 @@ aop_t_union (const char *tag)
   return init_aop_type (ATK_UNION, 0, tag, -1);
 }
 
+const struct aop_type *
+aop_t_enum (const char *tag)
+{
+  if (tag == NULL)
+    fatal_error ("(InterAspect) Must supply a non-NULL tag when specifying an"
+                " enum type.");
+
+  return init_aop_type (ATK_ENUM, 0, tag, -1);
+}
+
 /**
  * Return a type that will match pointers to the specified type.
  *
@@ -660,10 +670,11 @@ does_fp_type_match (tree gcc_type, int aop_size)
 static bool
 does_custom_type_match (tree gcc_type, enum aop_tykind kind, const char *tag)
 {
-  aop_assert (kind == ATK_STRUCT || kind == ATK_UNION);
+  aop_assert (kind == ATK_STRUCT || kind == ATK_UNION || kind == ATK_ENUM);
 
   if ((kind == ATK_STRUCT && TREE_CODE (gcc_type) == RECORD_TYPE)
-      || (kind == ATK_UNION && TREE_CODE (gcc_type) == UNION_TYPE))
+      || (kind == ATK_UNION && TREE_CODE (gcc_type) == UNION_TYPE)
+      || (kind == ATK_ENUM && TREE_CODE (gcc_type) == ENUMERAL_TYPE))
     {
       aop_assert (tag != NULL);
       return safe_str_equal (tag, get_type_name (gcc_type));
@@ -704,6 +715,7 @@ does_type_match (tree gcc_type, const struct aop_type *aop_type)
       return does_fp_type_match (gcc_type, aop_type->size);
     case ATK_STRUCT:
     case ATK_UNION:
+    case ATK_ENUM:
       return does_custom_type_match (gcc_type, aop_type->kind, aop_type->tag);
     default:
       aop_assert (0);
index ce37c9e7bc3793d5d2aab89e340d37dc5008abc9..5bb167e16242e666da7e82f8e4e567fcdb40b8c5 100644 (file)
@@ -26,6 +26,7 @@ enum aop_tykind {
 
   ATK_STRUCT,
   ATK_UNION,
+  ATK_ENUM,
 };
 
 /* NB: Do not update this struct without updating the correspodning
index 7536c1e98ca64a7555685bf313cc766f35902005..15695046d2dad17dc465def379b7cfb8670a6a52 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
@@ -182,6 +182,7 @@ extern const struct aop_type *aop_t_float64 ();
 extern const struct aop_type *aop_t_float128 ();
 extern const struct aop_type *aop_t_struct (const char *tag);
 extern const struct aop_type *aop_t_union (const char *tag);
+extern const struct aop_type *aop_t_enum (const char *tag);
 extern const struct aop_type *aop_t_pointer_to (const struct aop_type *type);
 
 extern void aop_register_pass (const char *pass_name, pass_callback callback);