- cleaned up irp functions a bit
[libfirm] / ir / tr / type.c
index 0c3109f..037568a 100644 (file)
@@ -113,7 +113,7 @@ void (inc_master_type_visited)(void)             { _inc_master_type_visited(); }
  * Creates a new type representation.
  */
 ir_type *
-new_type(tp_op *type_op, ir_mode *mode, ident *name, dbg_info *db) {
+new_type(const tp_op *type_op, ir_mode *mode, ident *name, dbg_info *db) {
        ir_type *res;
        int node_size;
 
@@ -1326,6 +1326,26 @@ ir_entity *get_method_value_param_ent(ir_type *method, int pos) {
        return method->attr.ma.params[pos].ent;
 }
 
+/*
+ * Sets the type that represents the copied value arguments.
+ */
+void set_method_value_param_type(ir_type *method, ir_type *tp) {
+       int i, n;
+
+       assert(method && (method->type_op == type_method));
+       assert(is_value_param_type(tp));
+       assert(get_method_n_params(method) == get_struct_n_members(tp));
+
+       method->attr.ma.value_params = tp;
+
+       n = get_struct_n_members(tp);
+       for (i = 0; i < n; i++)
+       {
+               ir_entity *ent = get_struct_member(tp, i);
+               method->attr.ma.params[i].ent = ent;
+       }
+}
+
 /*
  * Returns a type that represents the copied value arguments.
  */
@@ -2041,6 +2061,18 @@ int is_lowered_type(const ir_type *tp) {
        return tp->flags & tf_lowered_type;
 }
 
+/* Makes a new value type. */
+ir_type *new_type_value(ident *name) {
+       ir_type *res = new_type_struct(name);
+
+       res->flags |= tf_value_param_type;
+
+       /* Remove type from type list.  Must be treated differently than other types. */
+       remove_irp_type(res);
+
+       return res;
+}
+
 /* Makes a new frame type. */
 ir_type *new_type_frame(ident *name) {
        ir_type *res = new_type_class(name);