+
+inline ent_allocation
+get_entity_allocation (entity *ent) {
+ return ent->allocation;
+}
+
+inline void
+set_entity_allocation (entity *ent, ent_allocation al) {
+ ent->allocation = al;
+}
+
+
+inline ent_visibility
+get_entity_visibility (entity *ent) {
+ return ent->visibility;
+}
+
+inline void
+set_entity_visibility (entity *ent, ent_visibility vis) {
+ if (vis != local) assert(ent->allocation == static_allocated);
+ ent->visibility = vis;
+}
+
+inline ent_variability
+get_entity_variability (entity *ent) {
+ return ent->variability;
+}
+
+inline void
+set_entity_variability (entity *ent, ent_variability var){
+ if (var == part_constant)
+ assert(is_class_type(ent->type) || is_struct_type(ent->type));
+ if ((is_compound_type(ent->type)) &&
+ (ent->variability == uninitialized) && (var != uninitialized)) {
+ /* Allocate datastructures for constant values */
+ ent->values = NEW_ARR_F(ir_node *, 1);
+ ent->val_ents = NEW_ARR_F(entity *, 1);
+ }
+ if ((is_compound_type(ent->type)) &&
+ (var == uninitialized) && (ent->variability != uninitialized)) {
+ /* Free datastructures for constant values */
+ DEL_ARR_F(ent->values);
+ DEL_ARR_F(ent->val_ents);
+ }
+ 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;
+}
+
+inline peculiarity
+get_entity_peculiarity (entity *ent) {
+ assert (ent);
+ assert (is_method_type(ent->type));
+ return ent->peculiarity;
+}
+
+inline void
+set_entity_peculiarity (entity *ent, peculiarity pec) {
+ assert (ent);
+ assert (is_method_type(ent->type));
+ ent->peculiarity = pec;
+}
+
+/* Set has no effect for entities of type method. */
+inline ir_node *
+get_atomic_ent_value(entity *ent) {
+ assert(ent); assert(is_atomic_entity(ent)); assert((ent->variability != uninitialized));
+ return ent->value;
+}
+
+inline void
+set_atomic_ent_value(entity *ent, ir_node *val) {
+ assert(ent && is_atomic_entity(ent) && (ent->variability != uninitialized));
+ if (is_method_type(ent->type)) return;
+ 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. */
+inline void
+add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
+ assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized));
+ ARR_APP1 (ir_node *, ent->values, val);
+ ARR_APP1 (entity *, ent->val_ents, member);
+}
+
+inline int
+get_compound_ent_n_values(entity *ent) {
+ assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized));
+ return (ARR_LEN (ent->values))-1;
+}
+
+inline ir_node *
+get_compound_ent_value(entity *ent, int pos) {
+ assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized));
+ 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));
+ return ent->val_ents[pos+1];
+}
+
+inline void
+set_compound_ent_value(entity *ent, ir_node *val, entity *member, int pos) {
+ assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized));
+ ent->values[pos+1] = val;
+ ent->val_ents[pos+1] = member;
+}
+
+void
+set_array_entity_values(entity *ent, tarval **values, int num_vals) {
+ int i;
+ ir_graph *rem = current_ir_graph;
+ type *arrtp = get_entity_type(ent);
+ ir_node *val;
+
+ assert(is_array_type(arrtp));
+ assert(get_array_n_dimensions(arrtp) == 1);
+ /* One bound is sufficient, the nunmber of constant fields makes the
+ size. */
+ assert(get_array_lower_bound (arrtp, 0) || get_array_upper_bound (arrtp, 0));
+ assert(get_entity_variability(ent) != uninitialized);
+ current_ir_graph = get_const_code_irg();
+
+ for (i = 0; i < num_vals; i++) {
+ val = new_Const(get_tv_mode (values[i]), values[i]);
+ add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
+ }
+ current_ir_graph = rem;
+}
+