Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
38535d73
Commit
38535d73
authored
Aug 01, 2015
by
Christoph Mallon
Browse files
tr: Simplify {get,set}_method_variadicity() to {is,set}_method_variadic().
parent
c9fb3f91
Changes
12
Hide whitespace changes
Inline
Side-by-side
include/libfirm/typerep.h
View file @
38535d73
...
...
@@ -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
i
r_variadicity
get
_method_variadic
ity
(
const
ir_type
*
method
);
FIRM_API
i
nt
is
_method_variadic
(
ir_type
const
*
method
);
/** Sets the variadicity of a method. */
FIRM_API
void
set_method_variadic
ity
(
ir_type
*
method
,
i
r
_variadic
ity
vari
);
FIRM_API
void
set_method_variadic
(
ir_type
*
method
,
i
nt
is
_variadic
);
/** Returns the mask of the additional graph properties. */
FIRM_API
mtp_additional_properties
get_method_additional_properties
(
const
ir_type
*
method
);
...
...
ir/ana/analyze_irg_args.c
View file @
38535d73
...
...
@@ -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
)
{
...
...
ir/ana/irmemory.c
View file @
38535d73
...
...
@@ -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_variadic
ity
(
ctp
,
get
_method_variadic
ity
(
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
"
,
...
...
ir/be/amd64/amd64_transform.c
View file @
38535d73
...
...
@@ -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_variadic
ity
(
type
)
==
variadicity_variadic
)
{
if
(
is
_method_variadic
(
type
))
{
amd64_imm64_t
const
imm
=
{
.
kind
=
X86_IMM_VALUE
,
.
offset
=
cconv
->
n_xmm_regs
,
...
...
ir/be/sparc/sparc_cconv.c
View file @
38535d73
...
...
@@ -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_variadic
ity
(
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,
...
...
ir/be/sparc/sparc_stackframe.c
View file @
38535d73
...
...
@@ -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_variadic
ity
(
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_variadic
ity
(
mtp
)
==
variadicity_variadic
);
assert
(
is
_method_variadic
(
mtp
));
long
offset
;
if
(
orig_n_params
<
n_params
)
{
assert
(
param_map
[
orig_n_params
]
!=
NULL
);
...
...
ir/ir/irdumptxt.c
View file @
38535d73
...
...
@@ -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
variadic
ity
: %s"
,
get_variadicity_name
(
get
_method_variadic
ity
(
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
;
...
...
ir/ir/irio.c
View file @
38535d73
...
...
@@ -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_variadic
ity
(
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
);
}
i
r_variadicity
variadicity
=
(
ir_variadicity
)
read_long
(
env
);
set_method_variadic
ity
(
type
,
variadic
ity
);
i
nt
const
variadic
=
read_long
(
env
);
set_method_variadic
(
type
,
variadic
);
set_method_calling_convention
(
type
,
callingconv
);
set_method_additional_properties
(
type
,
addprops
);
...
...
ir/ir/irverify.c
View file @
38535d73
...
...
@@ -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
{
...
...
ir/lower/lower_calls.c
View file @
38535d73
...
...
@@ -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_variadic
ity
(
lowered
,
get
_method_variadic
ity
(
mtp
));
set_method_variadic
(
lowered
,
is
_method_variadic
(
mtp
));
unsigned
cconv
=
get_method_calling_convention
(
mtp
);
if
(
nn_params
>
n_params
)
{
...
...
ir/tr/type.c
View file @
38535d73
...
...
@@ -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
.
variadic
ity
=
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
.
variadic
ity
=
tp
->
attr
.
ma
.
variadic
ity
;
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
.
variadic
ity
;
return
method
->
attr
.
ma
.
variadic
;
}
void
set_method_variadic
ity
(
ir_type
*
method
,
i
r
_variadic
ity
vari
)
void
set_method_variadic
(
ir_type
*
const
method
,
i
nt
const
is
_variadic
)
{
assert
(
is_Method_type
(
method
));
method
->
attr
.
ma
.
variadic
ity
=
vari
;
method
->
attr
.
ma
.
variadic
=
is_variadic
;
}
mtp_additional_properties
(
get_method_additional_properties
)(
const
ir_type
*
method
)
...
...
ir/tr/type_t.h
View file @
38535d73
...
...
@@ -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
variadic
ity
;
/**< 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_variadic
ity
(
dst
,
get
_method_variadic
ity
(
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
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment