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
5f702d9e
Commit
5f702d9e
authored
Dec 27, 2014
by
Christoph Mallon
Browse files
ir: Use ARRAY_SIZE() instead of magic numbers.
parent
94ab70c7
Changes
9
Hide whitespace changes
Inline
Side-by-side
ir/be/amd64/bearch_amd64.c
View file @
5f702d9e
...
...
@@ -222,8 +222,6 @@ static void transform_MemPerm(ir_node *node)
ir_node
*
sp
=
be_get_initial_reg_value
(
irg
,
&
amd64_registers
[
REG_RSP
]);
int
arity
=
be_get_MemPerm_entity_arity
(
node
);
ir_node
**
pops
=
ALLOCAN
(
ir_node
*
,
arity
);
ir_node
*
in
[
1
];
ir_node
*
keep
;
int
i
;
/* create Pushs */
...
...
@@ -302,8 +300,8 @@ static void transform_MemPerm(ir_node *node)
pops
[
i
]
=
pop
;
}
in
[
0
]
=
sp
;
keep
=
be_new_Keep
(
block
,
1
,
in
);
ir_node
*
const
in
[]
=
{
sp
}
;
ir_node
*
const
keep
=
be_new_Keep
(
block
,
ARRAY_SIZE
(
in
)
,
in
);
sched_replace
(
node
,
keep
);
/* exchange memprojs */
...
...
ir/be/arm/arm_transform.c
View file @
5f702d9e
...
...
@@ -1154,8 +1154,8 @@ static ir_node *gen_Load(ir_node *node)
/* check for special case: the loaded value might not be used */
if
(
!
get_Proj_for_pn
(
node
,
pn_Load_res
))
{
/* add a result proj and a Keep to produce a pseudo use */
ir_node
*
proj
=
new_r_Proj
(
new_load
,
arm_mode_gp
,
pn_arm_Ldr_res
);
be_new_Keep
(
block
,
1
,
&
proj
);
ir_node
*
const
in
[]
=
{
new_r_Proj
(
new_load
,
arm_mode_gp
,
pn_arm_Ldr_res
)
}
;
be_new_Keep
(
block
,
ARRAY_SIZE
(
in
),
in
);
}
return
new_load
;
...
...
ir/be/benode.c
View file @
5f702d9e
...
...
@@ -288,7 +288,7 @@ ir_node *be_new_IncSP(const arch_register_t *sp, ir_node *bl,
return
irn
;
}
ir_node
*
be_new_CopyKeep
(
ir_node
*
bl
,
ir_node
*
src
,
int
n
,
ir_node
*
in_keep
[]
)
ir_node
*
be_new_CopyKeep
(
ir_node
*
const
bl
,
ir_node
*
const
src
,
int
const
n
,
ir_node
*
const
*
const
in_keep
)
{
ir_mode
*
mode
=
get_irn_mode
(
src
);
ir_graph
*
irg
=
get_irn_irg
(
bl
);
...
...
@@ -315,7 +315,8 @@ ir_node *be_new_CopyKeep(ir_node *bl, ir_node *src, int n, ir_node *in_keep[])
ir_node
*
be_new_CopyKeep_single
(
ir_node
*
bl
,
ir_node
*
src
,
ir_node
*
keep
)
{
return
be_new_CopyKeep
(
bl
,
src
,
1
,
&
keep
);
ir_node
*
const
in
[]
=
{
keep
};
return
be_new_CopyKeep
(
bl
,
src
,
ARRAY_SIZE
(
in
),
in
);
}
ir_node
*
be_get_CopyKeep_op
(
const
ir_node
*
cpy
)
...
...
ir/be/benode.h
View file @
5f702d9e
...
...
@@ -146,8 +146,7 @@ enum {
n_be_CopyKeep_op
,
n_be_CopyKeep_max
=
n_be_CopyKeep_op
};
ir_node
*
be_new_CopyKeep
(
ir_node
*
block
,
ir_node
*
src
,
int
n
,
ir_node
*
in_keep
[]);
ir_node
*
be_new_CopyKeep
(
ir_node
*
block
,
ir_node
*
src
,
int
n
,
ir_node
*
const
*
in_keep
);
ir_node
*
be_new_CopyKeep_single
(
ir_node
*
block
,
ir_node
*
src
,
ir_node
*
keep
);
...
...
ir/be/beprefalloc.c
View file @
5f702d9e
...
...
@@ -863,8 +863,8 @@ static void permute_values(ir_nodeset_t *live_nodes, ir_node *before,
/* exchange old_r and r2; after that old_r is a fixed point */
unsigned
r2
=
permutation
[
old_r
];
ir_node
*
in
[
2
]
=
{
assignments
[
r2
],
assignments
[
old_r
]
};
ir_node
*
perm
=
be_new_Perm
(
cls
,
block
,
2
,
in
);
ir_node
*
const
in
[]
=
{
assignments
[
r2
],
assignments
[
old_r
]
};
ir_node
*
const
perm
=
be_new_Perm
(
cls
,
block
,
ARRAY_SIZE
(
in
)
,
in
);
sched_add_before
(
before
,
perm
);
DB
((
dbg
,
LEVEL_2
,
"Perm %+F (perm %+F,%+F, before %+F)
\n
"
,
perm
,
in
[
0
],
in
[
1
],
before
));
...
...
ir/be/bespillutil.c
View file @
5f702d9e
...
...
@@ -1218,12 +1218,11 @@ static ir_node *add_to_keep(ir_node *last_keep,
if
(
last_keep
!=
NULL
)
{
be_Keep_add_node
(
last_keep
,
cls
,
node
);
}
else
{
ir_node
*
in
[
1
]
=
{
node
};
ir_node
*
block
=
get_nodes_block
(
node
);
ir_node
*
schedpoint
;
last_keep
=
be_new_Keep
(
block
,
1
,
in
);
ir_node
*
const
in
[]
=
{
node
};
ir_node
*
const
block
=
get_nodes_block
(
node
);
last_keep
=
be_new_Keep
(
block
,
ARRAY_SIZE
(
in
),
in
);
schedpoint
=
skip_Proj
(
node
);
ir_node
*
const
schedpoint
=
skip_Proj
(
node
);
if
(
sched_is_scheduled
(
schedpoint
))
{
sched_add_after
(
schedpoint
,
last_keep
);
}
...
...
ir/be/ia32/ia32_optimize.c
View file @
5f702d9e
...
...
@@ -35,6 +35,7 @@
#include
"ia32_common_transform.h"
#include
"ia32_transform.h"
#include
"ia32_architecture.h"
#include
"util.h"
DEBUG_ONLY
(
static
firm_dbg_module_t
*
dbg
=
NULL
;)
...
...
@@ -635,8 +636,8 @@ static ir_node *create_pop(dbg_info *dbgi, ir_node *block,
sched_add_before
(
schedpoint
,
pop
);
ir_node
*
in
[
1
]
=
{
val
};
ir_node
*
keep
=
be_new_Keep
(
block
,
1
,
in
);
ir_node
*
const
in
[]
=
{
val
};
ir_node
*
const
keep
=
be_new_Keep
(
block
,
ARRAY_SIZE
(
in
)
,
in
);
sched_add_before
(
schedpoint
,
keep
);
return
stack
;
...
...
ir/ir/ircons.c
View file @
5f702d9e
...
...
@@ -319,7 +319,7 @@ ir_node *new_rd_DivRL(dbg_info *dbgi, ir_node *block, ir_node * irn_mem, ir_node
{
ir_graph
*
const
irg
=
get_irn_irg
(
block
);
ir_node
*
const
in
[]
=
{
irn_mem
,
irn_left
,
irn_right
};
ir_node
*
res
=
new_ir_node
(
dbgi
,
irg
,
block
,
op_Div
,
mode_T
,
3
,
in
);
ir_node
*
res
=
new_ir_node
(
dbgi
,
irg
,
block
,
op_Div
,
mode_T
,
ARRAY_SIZE
(
in
)
,
in
);
res
->
attr
.
div
.
resmode
=
resmode
;
res
->
attr
.
div
.
no_remainder
=
1
;
res
->
attr
.
div
.
exc
.
pin_state
=
pin_state
;
...
...
ir/ir/iropt.c
View file @
5f702d9e
...
...
@@ -5767,13 +5767,10 @@ static ir_node *transform_node_shift(ir_node *n)
/* ok, we can replace it */
assert
(
modulo_shf
>=
get_mode_size_bits
(
mode
));
ir_node
*
block
=
get_nodes_block
(
n
);
ir_node
*
in
[
2
];
in
[
0
]
=
get_binop_left
(
left
);
in
[
1
]
=
new_r_Const
(
irg
,
res
);
ir_node
*
irn
=
new_ir_node
(
NULL
,
irg
,
block
,
get_irn_op
(
n
),
mode
,
2
,
in
);
ir_node
*
const
block
=
get_nodes_block
(
n
);
ir_node
*
const
val
=
get_binop_left
(
left
);
ir_node
*
const
amt
=
new_r_Const
(
irg
,
res
);
ir_node
*
const
irn
=
new_binop
(
n
,
block
,
val
,
amt
);
DBG_OPT_ALGSIM0
(
n
,
irn
,
FS_OPT_REASSOC_SHIFT
);
...
...
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