Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
2da93aea
Commit
2da93aea
authored
Mar 20, 2016
by
Christoph Mallon
Browse files
be: Factorise code to create a register requirement.
parent
35093541
Changes
5
Hide whitespace changes
Inline
Side-by-side
ir/be/bearch.c
View file @
2da93aea
...
...
@@ -158,6 +158,15 @@ int be_default_is_valid_clobber(char const *const clobber)
return
false
;
}
arch_register_req_t
*
be_create_cls_req
(
ir_graph
*
const
irg
,
arch_register_class_t
const
*
const
cls
,
unsigned
char
const
width
)
{
struct
obstack
*
const
obst
=
be_get_be_obst
(
irg
);
arch_register_req_t
*
const
req
=
OALLOCZ
(
obst
,
arch_register_req_t
);
req
->
cls
=
cls
;
req
->
width
=
width
;
return
req
;
}
arch_register_req_t
const
*
be_create_reg_req
(
ir_graph
*
const
irg
,
arch_register_t
const
*
const
reg
,
bool
const
ignore
)
{
if
(
!
ignore
)
...
...
ir/be/bearch.h
View file @
2da93aea
...
...
@@ -388,6 +388,8 @@ void arch_copy_irn_out_info(ir_node *dst, unsigned dst_pos, ir_node const *src);
int
be_default_is_valid_clobber
(
char
const
*
clobber
);
arch_register_req_t
*
be_create_cls_req
(
ir_graph
*
irg
,
arch_register_class_t
const
*
cls
,
unsigned
char
width
);
arch_register_req_t
const
*
be_create_reg_req
(
ir_graph
*
irg
,
arch_register_t
const
*
reg
,
bool
ignore
);
#endif
ir/be/benode.c
View file @
2da93aea
...
...
@@ -105,13 +105,6 @@ arch_register_req_t const **be_allocate_in_reqs(ir_graph *const irg, unsigned co
return
OALLOCN
(
obst
,
arch_register_req_t
const
*
,
n
);
}
static
arch_register_req_t
*
allocate_reg_req
(
ir_graph
*
const
irg
)
{
struct
obstack
*
obst
=
be_get_be_obst
(
irg
);
arch_register_req_t
*
req
=
OALLOCZ
(
obst
,
arch_register_req_t
);
return
req
;
}
static
void
be_node_set_register_req_in
(
ir_node
*
const
node
,
int
const
pos
,
arch_register_req_t
const
*
const
req
)
{
...
...
@@ -162,9 +155,7 @@ ir_node *be_new_Perm(arch_register_class_t const *const cls,
be_node_set_register_req_in
(
irn
,
i
,
cls
->
class_req
);
arch_set_irn_register_req_out
(
irn
,
i
,
cls
->
class_req
);
}
else
{
arch_register_req_t
*
const
new_req
=
allocate_reg_req
(
irg
);
new_req
->
cls
=
cls
;
new_req
->
width
=
req
->
width
;
arch_register_req_t
*
const
new_req
=
be_create_cls_req
(
irg
,
cls
,
req
->
width
);
be_node_set_register_req_in
(
irn
,
i
,
new_req
);
arch_set_irn_register_req_out
(
irn
,
i
,
new_req
);
}
...
...
@@ -202,10 +193,8 @@ static void set_copy_info(ir_node *const irn, ir_graph *const irg, ir_node *cons
be_node_set_register_req_in
(
irn
,
0
,
cls
->
class_req
);
arch_register_req_t
*
const
out_req
=
allocate_reg_req
(
irg
);
out_req
->
cls
=
cls
;
arch_register_req_t
*
const
out_req
=
be_create_cls_req
(
irg
,
cls
,
op_req
->
width
);
out_req
->
should_be_same
=
1U
<<
0
;
out_req
->
width
=
op_req
->
width
;
arch_set_irn_register_req_out
(
irn
,
0
,
out_req
);
}
...
...
ir/be/beprefalloc.c
View file @
2da93aea
...
...
@@ -1437,13 +1437,6 @@ static void assign_phi_registers(ir_node *block)
}
}
static
arch_register_req_t
*
allocate_reg_req
(
ir_graph
*
irg
)
{
struct
obstack
*
obst
=
be_get_be_obst
(
irg
);
arch_register_req_t
*
req
=
OALLOCZ
(
obst
,
arch_register_req_t
);
return
req
;
}
/**
* Walker: assign registers to all nodes of a block that
* need registers from the currently considered register class.
...
...
@@ -1514,12 +1507,8 @@ static void allocate_coalesce_block(ir_node *block, void *data)
if
(
need_phi
)
{
ir_mode
*
mode
=
get_irn_mode
(
node
);
const
arch_register_req_t
*
phi_req
=
cls
->
class_req
;
if
(
req
->
width
>
1
)
{
arch_register_req_t
*
new_req
=
allocate_reg_req
(
irg
);
new_req
->
cls
=
cls
;
new_req
->
width
=
req
->
width
;
phi_req
=
new_req
;
}
if
(
req
->
width
>
1
)
phi_req
=
be_create_cls_req
(
irg
,
cls
,
req
->
width
);
ir_node
*
phi
=
be_new_Phi
(
block
,
n_preds
,
phi_ins
,
mode
,
phi_req
);
...
...
ir/be/bessaconstr.c
View file @
2da93aea
...
...
@@ -400,12 +400,8 @@ static void determine_phi_req(be_ssa_construction_env_t *env, ir_node *value)
env
->
phi_req
=
req
->
cls
->
class_req
;
}
else
{
/* construct a new register req... */
ir_graph
*
irg
=
get_irn_irg
(
value
);
struct
obstack
*
obst
=
be_get_be_obst
(
irg
);
arch_register_req_t
*
new_req
=
OALLOCZ
(
obst
,
arch_register_req_t
);
new_req
->
cls
=
req
->
cls
;
new_req
->
width
=
req
->
width
;
env
->
phi_req
=
new_req
;
ir_graph
*
const
irg
=
get_irn_irg
(
value
);
env
->
phi_req
=
be_create_cls_req
(
irg
,
req
->
cls
,
req
->
width
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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