minor changes to help with making the ajacs-jikes backend
[libfirm] / ir / tr / entity.c
index 609bb00..4af0836 100644 (file)
@@ -65,8 +65,12 @@ new_entity (type *owner, ident *name, type *type)
   res->owner = owner;
   res->name = name;
   res->type = type;
-  res->allocation = dynamic_allocated;
+  if (get_type_tpop(type) == type_method)
+    res->allocation = static_allocated;
+  else
+    res->allocation = automatic_allocated;
   res->visibility = local;
+  res->offset = -1;
   if (is_method_type(type)) {
     res->variability = constant;
     rem = current_ir_graph;
@@ -76,6 +80,7 @@ new_entity (type *owner, ident *name, type *type)
   } else {
     res->variability = uninitialized;
   }
+  res->volatility = non_volatile;
   res->ld_name = NULL;
   res->overwrites = NEW_ARR_F(entity *, 1);
 
@@ -172,6 +177,11 @@ set_entity_ld_ident (entity *ent, ident *ld_ident) {
   ent->ld_name = ld_ident;
 }
 
+inline const char *
+get_entity_ld_name (entity *ent) {
+  return id_to_str(get_entity_ld_ident(ent));
+}
+
 /*
 char  *get_entity_ld_name  (entity *);
 void   set_entity_ld_name  (entity *, char *ld_name);
@@ -234,6 +244,17 @@ set_entity_variability (entity *ent, ent_variability var){
   ent->variability = var;
 }
 
+
+inline ent_volatility
+get_entity_volatility (entity *ent) {
+  return ent->volatility;
+}
+
+inline void
+set_entity_volatility (entity *ent, ent_volatility vol) {
+  ent->volatility = vol;
+}
+
 /* Set has no effect for entities of type method. */
 inline ir_node *
 get_atomic_ent_value(entity *ent) {
@@ -248,6 +269,30 @@ set_atomic_ent_value(entity *ent, ir_node *val) {
   ent->value = val;
 }
 
+ir_node *copy_value(ir_node *n) {
+  ir_node *nn;
+  ir_mode *m;
+
+  m = get_irn_mode(n);
+  switch(get_irn_opcode(n)) {
+  case iro_Const:
+    nn = new_Const(m, get_Const_tarval(n)); break;
+  case iro_SymConst:
+    nn = new_SymConst(get_SymConst_type_or_id(n), get_SymConst_kind(n)); break;
+  case iro_Add:
+    nn = new_Add(copy_value(get_Add_left(n)), copy_value(get_Add_right(n)), m); break;
+  default:
+    assert(0 && "opdope invalid or not implemented"); break;
+  }
+  return nn;
+}
+
+/* Copies the value represented by the entity to current_block
+   in current_ir_graph. */
+ir_node *copy_atomic_ent_value(entity *ent) {
+  assert(ent && is_atomic_entity(ent) && (ent->variability != uninitialized));
+  return copy_value(ent->value);
+}
 
 /* A value of a compound entity is a pair of value and the corresponding member of
    the compound. */
@@ -270,6 +315,12 @@ get_compound_ent_value(entity *ent, int pos) {
   return ent->values[pos+1];
 }
 
+/* Copies the value i of the entity to current_block in current_ir_graph. */
+ir_node *copy_compound_ent_value(entity *ent, int pos) {
+  assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized));
+  return copy_value(ent->values[pos+1]);
+}
+
 inline entity   *
 get_compound_ent_value_member(entity *ent, int pos) {
   assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized));
@@ -346,13 +397,13 @@ set_entity_irg(entity *ent, ir_graph *irg) {
 }
 
 int is_atomic_entity(entity *ent) {
-  type* t = ent->type;
+  type* t = get_entity_type(ent);
   return (is_primitive_type(t) || is_pointer_type(t) ||
          is_enumeration_type(t) || is_method_type(t));
 }
 
 int is_compound_entity(entity *ent) {
-  type* t = ent->type;
+  type* t = get_entity_type(ent);
   return (is_class_type(t) || is_struct_type(t) ||
          is_array_type(t) || is_union_type(t));
 }