Commit a88bcf9f authored by Matthias Braun's avatar Matthias Braun
Browse files

remove pointless first_variadic_param attribute from method types

parent 8f7699e7
......@@ -1649,23 +1649,6 @@ FIRM_API ir_variadicity get_method_variadicity(const ir_type *method);
/** Sets the variadicity of a method. */
FIRM_API void set_method_variadicity(ir_type *method, ir_variadicity vari);
/**
* Returns the first variadic parameter index of a type.
* If this index was NOT set, the index of the last parameter
* of the method type plus one is returned for variadic functions.
* Non-variadic function types always return -1 here.
*/
FIRM_API size_t get_method_first_variadic_param_index(const ir_type *method);
/**
* Sets the first variadic parameter index. This allows to specify
* a complete call type (containing the type of all parameters)
* but still have the knowledge, which parameter must be passed as
* variadic one.
*/
FIRM_API void set_method_first_variadic_param_index(ir_type *method,
size_t index);
/** Returns the mask of the additional graph properties. */
FIRM_API mtp_additional_properties get_method_additional_properties(const ir_type *method);
......
......@@ -582,7 +582,7 @@ static void export_type_post(io_env_t *env, ir_type *tp)
write_long(env, get_type_nr(get_method_param_type(tp, i)));
for (i = 0; i < nresults; i++)
write_long(env, get_type_nr(get_method_res_type(tp, i)));
ir_fprintf(f, "%zu ", get_method_first_variadic_param_index(tp));
ir_fprintf(f, "%u ", get_method_variadicity(tp));
break;
}
......@@ -1412,7 +1412,7 @@ static void import_type(io_env_t *env)
mtp_additional_properties addprops = (mtp_additional_properties) read_long(env);
int nparams = (int) read_long(env);
int nresults = (int) read_long(env);
int variaindex;
int variadicity;
type = new_type_method(nparams, nresults);
......@@ -1429,12 +1429,8 @@ static void import_type(io_env_t *env)
set_method_res_type(type, i, restype);
}
variaindex = (int) read_long(env);
if (variaindex != -1) {
set_method_variadicity(type, variadicity_variadic);
if (variaindex != nparams)
set_method_first_variadic_param_index(type, variaindex);
}
variadicity = (int) read_long(env);
set_method_variadicity(type, variadicity);
set_method_calling_convention(type, callingconv);
set_method_additional_properties(type, addprops);
......
......@@ -5730,9 +5730,6 @@ static ir_node *transform_node_Call(ir_node *call)
}
var = get_method_variadicity(mtp);
set_method_variadicity(ctp, var);
if (var == variadicity_variadic) {
set_method_first_variadic_param_index(ctp, get_method_first_variadic_param_index(mtp) + 1);
}
/* When we resolve a trampoline, the function must be called by a this-call */
set_method_calling_convention(ctp, get_method_calling_convention(mtp) | cc_this_call);
set_method_additional_properties(ctp, get_method_additional_properties(mtp));
......
......@@ -79,7 +79,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
ir_type **params, **results, *res_tp;
size_t *param_map;
ir_mode *modes[MAX_REGISTER_RET_VAL];
size_t n_ress, n_params, nn_ress, nn_params, i, first_variadic;
size_t n_ress, n_params, nn_ress, nn_params, i;
add_hidden hidden_params;
int changed = 0;
ir_variadicity var;
......@@ -101,8 +101,6 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
NEW_ARR_A(size_t, param_map, n_params + n_ress);
first_variadic = get_method_first_variadic_param_index(mtp);
hidden_params = lp->hidden_params;
if (hidden_params == ADD_HIDDEN_SMART &&
get_method_variadicity(mtp) == variadicity_variadic)
......@@ -140,9 +138,6 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
}
}
/* move the index of the first variadic parameter */
first_variadic += nn_params;
for (i = 0; i < n_params; ++i, ++nn_params) {
params[nn_params] = get_method_param_type(mtp, i);
param_map[nn_params] = i;
......@@ -181,8 +176,6 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
var = get_method_variadicity(mtp);
set_method_variadicity(lowered, var);
if (var == variadicity_variadic)
set_method_first_variadic_param_index(lowered, first_variadic);
/* associate the lowered type with the original one for easier access */
if (changed) {
......
......@@ -132,9 +132,6 @@ static void process_call(ir_node *call, ir_entity *callee, q_set *hmap)
* magic
*/
mtp = get_Call_type(call);
if (get_method_variadicity(mtp) != variadicity_non_variadic) {
n_params = get_method_first_variadic_param_index(mtp) - 1;
}
/* In this for loop we collect the calls, that have
an constant parameter. */
......
......@@ -526,13 +526,8 @@ int equal_type(ir_type *typ1, ir_type *typ2)
if (get_method_calling_convention(typ1) !=
get_method_calling_convention(typ2)) return 0;
if (get_method_variadicity(typ1) == variadicity_non_variadic) {
n_param1 = get_method_n_params(typ1);
n_param2 = get_method_n_params(typ2);
} else {
n_param1 = get_method_first_variadic_param_index(typ1);
n_param2 = get_method_first_variadic_param_index(typ2);
}
n_param1 = get_method_n_params(typ1);
n_param2 = get_method_n_params(typ2);
if (n_param1 != n_param2) return 0;
......@@ -643,13 +638,8 @@ int smaller_type(ir_type *st, ir_type *lt)
if (get_method_calling_convention(st) !=
get_method_calling_convention(lt)) return 0;
if (get_method_variadicity(st) == variadicity_non_variadic) {
n_param1 = get_method_n_params(st);
n_param2 = get_method_n_params(lt);
} else {
n_param1 = get_method_first_variadic_param_index(st);
n_param2 = get_method_first_variadic_param_index(lt);
}
n_param1 = get_method_n_params(st);
n_param2 = get_method_n_params(lt);
if (n_param1 != n_param2) return 0;
......@@ -1209,7 +1199,6 @@ ir_type *new_d_type_method(size_t n_param, size_t n_res, type_dbg_info *db)
res->attr.ma.res_type = XMALLOCNZ(tp_ent_pair, n_res);
res->attr.ma.value_ress = NULL;
res->attr.ma.variadicity = variadicity_non_variadic;
res->attr.ma.first_variadic_param = -1;
res->attr.ma.additional_properties = mtp_no_property;
hook_new_type(res);
return res;
......@@ -1249,7 +1238,6 @@ ir_type *clone_type_method(ir_type *tp)
memcpy(res->attr.ma.res_type, tp->attr.ma.res_type, n_res * sizeof(res->attr.ma.res_type[0]));
res->attr.ma.value_ress = tp->attr.ma.value_ress;
res->attr.ma.variadicity = tp->attr.ma.variadicity;
res->attr.ma.first_variadic_param = tp->attr.ma.first_variadic_param;
res->attr.ma.additional_properties = tp->attr.ma.additional_properties;
res->attr.ma.irg_calling_conv = tp->attr.ma.irg_calling_conv;
hook_new_type(res);
......@@ -1447,26 +1435,6 @@ void set_method_variadicity(ir_type *method, ir_variadicity vari)
method->attr.ma.variadicity = vari;
}
size_t get_method_first_variadic_param_index(const ir_type *method)
{
assert(method->type_op == type_method);
if (method->attr.ma.variadicity == variadicity_non_variadic)
return (size_t)-1;
if (method->attr.ma.first_variadic_param == (size_t)-1)
return get_method_n_params(method);
return method->attr.ma.first_variadic_param;
}
void set_method_first_variadic_param_index(ir_type *method, size_t index)
{
assert(method->type_op == type_method);
assert(index <= get_method_n_params(method));
method->attr.ma.first_variadic_param = index;
}
mtp_additional_properties (get_method_additional_properties)(const ir_type *method)
{
return _get_method_additional_properties(method);
......
......@@ -75,8 +75,7 @@ typedef struct {
tp_ent_pair *res_type; /**< Array of result type/value ir_entity pairs. */
ir_type *value_ress; /**< A type whose entities represent copied value results. */
ir_variadicity variadicity; /**< The variadicity of the method. */
size_t first_variadic_param; /**< The index of the first variadic parameter or -1 if non-variadic .*/
mtp_additional_properties additional_properties; /**< Set of additional method properties. */
mtp_additional_properties additional_properties; /**< Set of additional method properties. */
unsigned irg_calling_conv; /**< A set of calling convention flags. */
} mtd_attr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment