Commit 38535d73 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

tr: Simplify {get,set}_method_variadicity() to {is,set}_method_variadic().

parent c9fb3f91
......@@ -1347,24 +1347,11 @@ FIRM_API ir_type *get_method_res_type(const ir_type *method, size_t pos);
/** Sets the type of the result at position pos of a method. */
FIRM_API void set_method_res_type(ir_type *method, size_t pos, ir_type *tp);
/**
* This enum flags the variadicity of methods (methods with a
* variable amount of arguments (e.g. C's printf). Default is
* non_variadic.
*/
typedef enum ir_variadicity {
variadicity_non_variadic, /**< non variadic */
variadicity_variadic /**< variadic */
} ir_variadicity;
/** Returns the null-terminated name of this variadicity. */
FIRM_API const char *get_variadicity_name(ir_variadicity vari);
/** Returns the variadicity of a method. */
FIRM_API ir_variadicity get_method_variadicity(const ir_type *method);
FIRM_API int is_method_variadic(ir_type const *method);
/** Sets the variadicity of a method. */
FIRM_API void set_method_variadicity(ir_type *method, ir_variadicity vari);
FIRM_API void set_method_variadic(ir_type *method, int is_variadic);
/** Returns the mask of the additional graph properties. */
FIRM_API mtp_additional_properties get_method_additional_properties(const ir_type *method);
......
......@@ -216,8 +216,7 @@ ptr_access_kind get_method_param_access(ir_entity *ent, size_t pos)
{
#ifndef NDEBUG
ir_type *mtp = get_entity_type(ent);
bool is_variadic = get_method_variadicity(mtp) == variadicity_variadic;
assert(is_variadic || pos < get_method_n_params(mtp));
assert(is_method_variadic(mtp) || pos < get_method_n_params(mtp));
#endif
if (ent->attr.mtd_attr.param_access) {
......
......@@ -934,7 +934,7 @@ static void update_calls_to_private(ir_node *call, void *env)
/* clear mismatches in variadicity that can happen in obscure C
* programs and break when changing to private calling convention. */
ir_type *entity_ctp = get_entity_type(callee);
set_method_variadicity(ctp, get_method_variadicity(entity_ctp));
set_method_variadic(ctp, is_method_variadic(entity_ctp));
set_Call_type(call, ctp);
DB((dbgcall, LEVEL_1,
"changed call to private method %+F using cloned type %+F\n",
......
......@@ -1636,7 +1636,7 @@ static ir_node *gen_Call(ir_node *node)
++in_arity;
/* vararg calls need the number of SSE registers used */
if (get_method_variadicity(type) == variadicity_variadic) {
if (is_method_variadic(type)) {
amd64_imm64_t const imm = {
.kind = X86_IMM_VALUE,
.offset = cconv->n_xmm_regs,
......
......@@ -166,7 +166,7 @@ calling_convention_t *sparc_decide_calling_convention(ir_type *function_type,
omit_fp = be_options.omit_fp;
/* our current vaarg handling needs the standard space to store the
* args 0-5 in it */
if (get_method_variadicity(function_type) == variadicity_variadic)
if (is_method_variadic(function_type))
omit_fp = false;
/* The pointer to the aggregate return value belongs to the 92 magic bytes.
* Thus, if the called functions increases the stack size,
......
......@@ -165,7 +165,7 @@ bool sparc_variadic_fixups(ir_graph *irg, calling_convention_t *cconv)
{
ir_entity *entity = get_irg_entity(irg);
ir_type *mtp = get_entity_type(entity);
if (get_method_variadicity(mtp) != variadicity_variadic)
if (!is_method_variadic(mtp))
return false;
if (cconv->n_param_regs >= SPARC_N_PARAM_REGS)
......@@ -269,7 +269,7 @@ static ir_type *compute_arg_type(ir_graph *irg, calling_convention_t *cconv,
* original number of parameters */
ir_type *non_lowered = get_higher_type(mtp);
size_t orig_n_params = get_method_n_params(non_lowered);
assert(get_method_variadicity(mtp) == variadicity_variadic);
assert(is_method_variadic(mtp));
long offset;
if (orig_n_params < n_params) {
assert(param_map[orig_n_params] != NULL);
......
......@@ -738,7 +738,7 @@ void dump_type_to_file(FILE *const F, const ir_type *const tp)
if (verbosity & dump_verbosity_typeattrs) {
mtp_additional_properties mtp = get_method_additional_properties(tp);
unsigned cconv = get_method_calling_convention(tp);
fprintf(F, "\n variadicity: %s", get_variadicity_name(get_method_variadicity(tp)));
fprintf(F, "\n variadic: %s", is_method_variadic(tp) ? "yes" : "no");
fprintf(F, "\n return types: %lu",
(unsigned long) get_method_n_ress(tp));
for (size_t i = 0; i < get_method_n_ress(tp); ++i) {
......@@ -752,14 +752,13 @@ void dump_type_to_file(FILE *const F, const ir_type *const tp)
const ir_type *ptp = get_method_param_type(tp, i);
ir_fprintf(F, "\n %+F", ptp);
}
if (is_method_variadic(tp))
fprintf(F, "\n ...");
fprintf(F, "\n properties:");
print_bitflags(F, mtp_property_names, (unsigned)mtp);
fprintf(F, "\n calling convention:");
print_bitflags(F, cc_names, (unsigned)cconv);
if (get_method_variadicity(tp)) {
fprintf(F, "\n ...");
}
fprintf(F, "\n");
}
break;
......
......@@ -640,7 +640,7 @@ static void write_type_method(write_env_t *env, ir_type *tp)
write_type_ref(env, get_method_param_type(tp, i));
for (size_t i = 0; i < nresults; i++)
write_type_ref(env, get_method_res_type(tp, i));
write_unsigned(env, get_method_variadicity(tp));
write_unsigned(env, is_method_variadic(tp));
fputc('\n', env->file);
}
......@@ -1693,8 +1693,8 @@ static void read_type(read_env_t *env)
set_method_res_type(type, i, restype);
}
ir_variadicity variadicity = (ir_variadicity) read_long(env);
set_method_variadicity(type, variadicity);
int const variadic = read_long(env);
set_method_variadic(type, variadic);
set_method_calling_convention(type, callingconv);
set_method_additional_properties(type, addprops);
......
......@@ -622,8 +622,7 @@ static int verify_node_Call(const ir_node *n)
if ((size_t)get_Call_n_params(n) < get_method_n_params(mt)) {
warn(n, "call has fewer arguments than method type");
return false;
} else if ((size_t)get_Call_n_params(n) > get_method_n_params(mt) &&
get_method_variadicity(mt) != variadicity_variadic) {
} else if ((size_t)get_Call_n_params(n) > get_method_n_params(mt) && !is_method_variadic(mt)) {
warn(n, "call has more arguments than method type");
return false;
} else {
......
......@@ -187,7 +187,7 @@ static ir_type *lower_mtp(compound_call_lowering_flags flags, ir_type *mtp)
for (size_t i = 0; i < nn_ress; ++i)
set_method_res_type(lowered, i, results[i]);
set_method_variadicity(lowered, get_method_variadicity(mtp));
set_method_variadic(lowered, is_method_variadic(mtp));
unsigned cconv = get_method_calling_convention(mtp);
if (nn_params > n_params) {
......
......@@ -680,14 +680,14 @@ void set_struct_mode(ir_type *tp, ir_mode *mode)
ir_type *new_type_method(size_t n_param, size_t n_res)
{
ir_type *res = new_type(type_method, mode_P);
res->flags |= tf_layout_fixed;
res->size = get_mode_size_bytes(mode_P);
res->attr.ma.n_params = n_param;
res->attr.ma.params = XMALLOCNZ(ir_type*, n_param);
res->attr.ma.n_res = n_res;
res->attr.ma.res_type = XMALLOCNZ(ir_type*, n_res);
res->attr.ma.variadicity = variadicity_non_variadic;
res->attr.ma.properties = mtp_no_property;
res->flags |= tf_layout_fixed;
res->size = get_mode_size_bytes(mode_P);
res->attr.ma.n_params = n_param;
res->attr.ma.params = XMALLOCNZ(ir_type*, n_param);
res->attr.ma.n_res = n_res;
res->attr.ma.res_type = XMALLOCNZ(ir_type*, n_res);
res->attr.ma.variadic = false;
res->attr.ma.properties = mtp_no_property;
set_type_alignment_bytes(res, 1);
hook_new_type(res);
return res;
......@@ -712,7 +712,7 @@ ir_type *clone_type_method(ir_type *tp)
res->attr.ma.n_res = n_res;
res->attr.ma.res_type = XMALLOCN(ir_type*, n_res);
MEMCPY(res->attr.ma.res_type, tp->attr.ma.res_type, n_res);
res->attr.ma.variadicity = tp->attr.ma.variadicity;
res->attr.ma.variadic = tp->attr.ma.variadic;
res->attr.ma.properties = tp->attr.ma.properties;
res->attr.ma.irg_calling_conv = tp->attr.ma.irg_calling_conv;
set_type_alignment_bytes(res, get_type_alignment_bytes(tp));
......@@ -767,28 +767,16 @@ void set_method_res_type(ir_type *method, size_t pos, ir_type *tp)
method->attr.ma.res_type[pos] = tp;
}
const char *get_variadicity_name(ir_variadicity vari)
{
#define X(a) case a: return #a
switch (vari) {
X(variadicity_non_variadic);
X(variadicity_variadic);
default:
return "BAD VALUE";
}
#undef X
}
ir_variadicity get_method_variadicity(const ir_type *method)
int is_method_variadic(ir_type const *const method)
{
assert(is_Method_type(method));
return method->attr.ma.variadicity;
return method->attr.ma.variadic;
}
void set_method_variadicity(ir_type *method, ir_variadicity vari)
void set_method_variadic(ir_type *const method, int const is_variadic)
{
assert(is_Method_type(method));
method->attr.ma.variadicity = vari;
method->attr.ma.variadic = is_variadic;
}
mtp_additional_properties (get_method_additional_properties)(const ir_type *method)
......
......@@ -71,7 +71,7 @@ typedef struct {
ir_type **params; /**< Array of parameter types. */
size_t n_res; /**< Number of results. */
ir_type **res_type; /**< Array of result types. */
ir_variadicity variadicity; /**< The variadicity of the method. */
bool variadic; /**< The variadicity of the method. */
mtp_additional_properties properties; /**< Set of additional method properties. */
unsigned irg_calling_conv; /**< A set of calling convention flags. */
} mtd_attr;
......@@ -414,7 +414,7 @@ ir_type *new_type_segment(ident *name, type_flags flags);
static inline void copy_method_properties(ir_type *const dst, ir_type const *const src)
{
set_method_variadicity(dst, get_method_variadicity(src));
set_method_variadic(dst, is_method_variadic(src));
set_method_calling_convention(dst, get_method_calling_convention(src));
set_method_additional_properties(dst, get_method_additional_properties(src));
}
......
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