Some access routines for visited flags in entity.h, irnode.h,
[libfirm] / ir / tr / type.c
index 5588894..ada05cd 100644 (file)
  *   type_t.h type tpop
  *****
  */
+
+/* $Id$ */
+
 # include <stdlib.h>
 # include <stddef.h>
 # include "type_t.h"
 # include "tpop_t.h"
 # include "typegmod_t.h"
 # include "array.h"
+# include "irprog.h"
+# include "mangle.h"
+# include "tv.h"
+# include "ircons.h"
 
 /*******************************************************************/
 /** TYPE                                                          **/
@@ -162,8 +169,10 @@ void
 set_type_state(type *tp, type_state state) {
   assert(tp);
   /* For pointer and primitive always fixed. */
-  if ((tp->type_op != type_pointer) && (tp->type_op != type_primitive))
+  if ((tp->type_op != type_pointer) && (tp->type_op != type_primitive)) {
+    /* @@@ assert that the layout really is fixed!!! */
     tp->state = state;
+  }
 }
 
 unsigned long get_type_visited(type *tp) {
@@ -510,7 +519,7 @@ type *new_type_array         (ident *name, int n_dimensions,
   res->attr.aa.lower_bound  = (ir_node **) xmalloc (sizeof (ir_node *) * n_dimensions);
   res->attr.aa.upper_bound  = (ir_node **) xmalloc (sizeof (ir_node *) * n_dimensions);
   res->attr.aa.element_type = element_type;
-  new_entity(res, name, element_type);
+  new_entity(res, mangle(name, id_from_str("elem_ent", 8)), element_type);
   return res;
 }
 inline void free_array_attrs (type *array) {
@@ -524,8 +533,21 @@ int   get_array_n_dimensions (type *array) {
   assert(array && (array->type_op == type_array));
   return array->attr.aa.n_dimensions;
 }
-void  set_array_bounds       (type *array, int dimension, ir_node * lower_bound,
-                                                          ir_node * upper_bound) {
+void  set_array_bounds_int (type *array, int dimension, int lower_bound,
+                           int upper_bound) {
+  ir_graph *rem;
+  assert(array && (array->type_op == type_array));
+  rem = current_ir_graph;
+  current_ir_graph = get_const_code_irg();
+  array->attr.aa.lower_bound[dimension] =
+    new_Const(mode_I, tarval_from_long (mode_I, lower_bound));
+  array->attr.aa.upper_bound[dimension] =
+    new_Const(mode_I, tarval_from_long (mode_I, upper_bound));
+  current_ir_graph = rem;
+}
+
+void  set_array_bounds (type *array, int dimension, ir_node * lower_bound,
+                       ir_node * upper_bound) {
   assert(array && (array->type_op == type_array));
   array->attr.aa.lower_bound[dimension] = lower_bound;
   array->attr.aa.upper_bound[dimension] = upper_bound;
@@ -674,3 +696,12 @@ bool  is_primitive_type  (type *primitive) {
   assert(primitive);
   if (primitive->type_op == type_primitive) return 1; else return 0;
 }
+
+int is_atomic_type(type *tp) {
+  return (is_primitive_type(tp) || is_pointer_type(tp) ||
+         is_enumeration_type(tp));
+}
+int is_compound_type(type *tp) {
+  return (is_class_type(tp) || is_struct_type(tp) ||
+         is_array_type(tp) || is_union_type(tp));
+}