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
390bd81c
Commit
390bd81c
authored
Jul 22, 2010
by
Matthias Braun
Browse files
cleanup sparc attribute getters+setters
[r27781]
parent
a281d22b
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/be/sparc/sparc_new_nodes.c
View file @
390bd81c
...
...
@@ -45,6 +45,36 @@
#include
"sparc_new_nodes.h"
#include
"gen_sparc_regalloc_if.h"
static
bool
has_symconst_attr
(
const
ir_node
*
node
)
{
return
is_sparc_SymConst
(
node
)
||
is_sparc_FrameAddr
(
node
);
}
static
bool
has_load_store_attr
(
const
ir_node
*
node
)
{
return
is_sparc_Ld
(
node
)
||
is_sparc_St
(
node
);
}
static
bool
has_cmp_attr
(
const
ir_node
*
node
)
{
return
is_sparc_Cmp
(
node
)
||
is_sparc_Tst
(
node
);
}
static
bool
has_jmp_cond_attr
(
const
ir_node
*
node
)
{
return
is_sparc_BXX
(
node
);
}
static
bool
has_jmp_switch_attr
(
const
ir_node
*
node
)
{
return
is_sparc_SwitchJmp
(
node
);
}
static
bool
has_save_attr
(
const
ir_node
*
node
)
{
return
is_sparc_Save
(
node
);
}
/**
* Dumper interface for dumping sparc nodes in vcg.
* @param F the output file
...
...
@@ -53,49 +83,32 @@
*/
static
void
sparc_dump_node
(
FILE
*
F
,
ir_node
*
n
,
dump_reason_t
reason
)
{
ir_mode
*
mode
=
NULL
;
switch
(
reason
)
{
case
dump_node_opcode_txt
:
fprintf
(
F
,
"%s"
,
get_irn_opname
(
n
));
case
dump_node_opcode_txt
:
fprintf
(
F
,
"%s"
,
get_irn_opname
(
n
));
break
;
case
dump_node_mode_txt
:
mode
=
get_irn_mode
(
n
);
if
(
mode
)
{
fprintf
(
F
,
"[%s]"
,
get_mode_name
(
mode
));
}
else
{
fprintf
(
F
,
"[?NOMODE?]"
);
}
case
dump_node_mode_txt
:
break
;
case
dump_node_info_txt
:
arch_dump_reqs_and_registers
(
F
,
n
);
case
dump_node_info_txt
:
arch_dump_reqs_and_registers
(
F
,
n
);
break
;
case
dump_node_nodeattr_txt
:
/* TODO: dump some attributes which should show up */
/* in node name in dump (e.g. consts or the like) */
//fputs("\n", F);
if
(
is_sparc_FrameAddr
(
n
))
{
const
sparc_symconst_attr_t
*
attr
=
get_sparc_symconst_attr_const
(
n
);
fprintf
(
F
,
"fp_offset: 0x%X
\n
"
,
attr
->
fp_offset
);
}
if
(
is_sparc_Ld
(
n
)
||
is_sparc_St
(
n
))
{
const
sparc_load_store_attr_t
*
attr
=
get_sparc_load_store_attr_const
(
n
);
fprintf
(
F
,
"offset: 0x%lX
\n
"
,
attr
->
offset
);
fprintf
(
F
,
"is_frame_entity: %s
\n
"
,
attr
->
is_frame_entity
==
true
?
"true"
:
"false"
);
}
case
dump_node_nodeattr_txt
:
if
(
has_symconst_attr
(
n
))
{
const
sparc_symconst_attr_t
*
attr
=
get_sparc_symconst_attr_const
(
n
);
fprintf
(
F
,
"fp_offset: 0x%X
\n
"
,
attr
->
fp_offset
);
}
if
(
has_load_store_attr
(
n
))
{
const
sparc_load_store_attr_t
*
attr
=
get_sparc_load_store_attr_const
(
n
);
fprintf
(
F
,
"offset: 0x%lX
\n
"
,
attr
->
offset
);
fprintf
(
F
,
"is_frame_entity: %s
\n
"
,
attr
->
is_frame_entity
==
true
?
"true"
:
"false"
);
}
break
;
}
}
/* ATTRIBUTE INIT SETTERS / HELPERS */
static
void
sparc_set_attr_imm
(
ir_node
*
res
,
int
immediate_value
)
{
sparc_attr_t
*
attr
=
get_irn_generic_attr
(
res
);
...
...
@@ -140,95 +153,88 @@ long get_sparc_jmp_switch_default_proj_num(const ir_node *node)
return
attr
->
default_proj_num
;
}
/* ATTRIBUTE GETTERS */
sparc_attr_t
*
get_sparc_attr
(
ir_node
*
node
)
{
assert
(
is_sparc_irn
(
node
)
&&
"need sparc node to get attributes"
);
return
(
sparc_attr_t
*
)
get_irn_generic_attr
(
node
);
assert
(
is_sparc_irn
(
node
));
return
(
sparc_attr_t
*
)
get_irn_generic_attr
(
node
);
}
const
sparc_attr_t
*
get_sparc_attr_const
(
const
ir_node
*
node
)
{
assert
(
is_sparc_irn
(
node
)
&&
"need sparc node to get attributes"
);
return
(
const
sparc_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
is_sparc_irn
(
node
));
return
(
const
sparc_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
sparc_load_store_attr_t
*
get_sparc_load_store_attr
(
ir_node
*
node
)
{
assert
(
is_sparc_irn
(
node
)
&&
"need sparc node to get attributes"
);
return
(
sparc_load_store_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
has_load_store_attr
(
node
)
);
return
(
sparc_load_store_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
const
sparc_load_store_attr_t
*
get_sparc_load_store_attr_const
(
const
ir_node
*
node
)
{
assert
(
is_sparc_irn
(
node
)
&&
"need sparc node to get attributes"
);
return
(
const
sparc_load_store_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
has_load_store_attr
(
node
)
);
return
(
const
sparc_load_store_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
sparc_symconst_attr_t
*
get_sparc_symconst_attr
(
ir_node
*
node
)
{
assert
(
(
i
s_s
parc_S
ym
C
onst
(
node
)
||
is_sparc_FrameAddr
(
node
))
&&
"need sparc SymConst/FrameAddr node to get attributes"
);
return
(
sparc_symconst_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
ha
s_sym
c
onst
_attr
(
node
));
return
(
sparc_symconst_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
const
sparc_symconst_attr_t
*
get_sparc_symconst_attr_const
(
const
ir_node
*
node
)
{
assert
(
(
i
s_s
parc_S
ym
C
onst
(
node
)
||
is_sparc_FrameAddr
(
node
))
&&
"need sparc SymConst/FrameAddr node to get attributes"
);
return
(
const
sparc_symconst_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
ha
s_sym
c
onst
_attr
(
node
));
return
(
const
sparc_symconst_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
sparc_jmp_cond_attr_t
*
get_sparc_jmp_cond_attr
(
ir_node
*
node
)
{
assert
(
is_sparc_BXX
(
node
)
&&
"need sparc B node to get attributes"
);
return
(
sparc_jmp_cond_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
has_jmp_cond_attr
(
node
)
);
return
(
sparc_jmp_cond_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
const
sparc_jmp_cond_attr_t
*
get_sparc_jmp_cond_attr_const
(
const
ir_node
*
node
)
{
assert
(
is_sparc_BXX
(
node
)
&&
"need sparc B node to get attributes"
);
return
(
const
sparc_jmp_cond_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
has_jmp_cond_attr
(
node
)
);
return
(
const
sparc_jmp_cond_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
sparc_jmp_switch_attr_t
*
get_sparc_jmp_switch_attr
(
ir_node
*
node
)
{
assert
(
is_sparc_SwitchJmp
(
node
)
&&
"need sparc SwitchJmp node to get attributes"
);
return
(
sparc_jmp_switch_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
has_jmp_switch_attr
(
node
)
);
return
(
sparc_jmp_switch_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
const
sparc_jmp_switch_attr_t
*
get_sparc_jmp_switch_attr_const
(
const
ir_node
*
node
)
{
assert
(
is_sparc_SwitchJmp
(
node
)
&&
"need sparc SwitchJmp node to get attributes"
);
return
(
const
sparc_jmp_switch_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
has_jmp_switch_attr
(
node
)
);
return
(
const
sparc_jmp_switch_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
sparc_cmp_attr_t
*
get_sparc_cmp_attr
(
ir_node
*
node
)
{
assert
(
is_sparc_irn
(
node
)
&&
"need sparc node to get attributes"
);
return
(
sparc_cmp_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
has_cmp_attr
(
node
)
);
return
(
sparc_cmp_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
const
sparc_cmp_attr_t
*
get_sparc_cmp_attr_const
(
const
ir_node
*
node
)
{
assert
(
is_sparc_irn
(
node
)
&&
"need sparc node to get attributes"
);
return
(
const
sparc_cmp_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
has_cmp_attr
(
node
)
);
return
(
const
sparc_cmp_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
sparc_save_attr_t
*
get_sparc_save_attr
(
ir_node
*
node
)
{
assert
(
i
s_s
parc_Save
(
node
)
&&
"need sparc Save node to get attributes"
);
return
(
sparc_save_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
ha
s_s
ave_attr
(
node
)
);
return
(
sparc_save_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
const
sparc_save_attr_t
*
get_sparc_save_attr_const
(
const
ir_node
*
node
)
{
assert
(
i
s_s
parc_Save
(
node
)
&&
"need sparc Save node to get attributes"
);
return
(
const
sparc_save_attr_t
*
)
get_irn_generic_attr_const
(
node
);
assert
(
ha
s_s
ave_attr
(
node
)
);
return
(
const
sparc_save_attr_t
*
)
get_irn_generic_attr_const
(
node
);
}
/**
...
...
@@ -287,7 +293,7 @@ static void init_sparc_load_store_attributes(ir_node *res, ir_mode *ls_mode,
int
entity_sign
,
long
offset
,
bool
is_frame_entity
)
{
sparc_load_store_attr_t
*
attr
=
get_
irn_generic
_attr
(
res
);
sparc_load_store_attr_t
*
attr
=
get_
sparc_load_store
_attr
(
res
);
attr
->
load_store_mode
=
ls_mode
;
attr
->
entity
=
entity
;
attr
->
entity_sign
=
entity_sign
;
...
...
@@ -298,21 +304,21 @@ static void init_sparc_load_store_attributes(ir_node *res, ir_mode *ls_mode,
static
void
init_sparc_cmp_attr
(
ir_node
*
res
,
bool
ins_permuted
,
bool
is_unsigned
)
{
sparc_cmp_attr_t
*
attr
=
get_
irn_generic
_attr
(
res
);
sparc_cmp_attr_t
*
attr
=
get_
sparc_cmp
_attr
(
res
);
attr
->
ins_permuted
=
ins_permuted
;
attr
->
is_unsigned
=
is_unsigned
;
}
static
void
init_sparc_symconst_attributes
(
ir_node
*
res
,
ir_entity
*
entity
)
{
sparc_symconst_attr_t
*
attr
=
get_
irn_generic
_attr
(
res
);
sparc_symconst_attr_t
*
attr
=
get_
sparc_symconst
_attr
(
res
);
attr
->
entity
=
entity
;
attr
->
fp_offset
=
0
;
}
static
void
init_sparc_save_attr
(
ir_node
*
res
,
int
initial_stacksize
)
{
sparc_save_attr_t
*
attr
=
get_
irn_generic
_attr
(
res
);
sparc_save_attr_t
*
attr
=
get_
sparc_save
_attr
(
res
);
attr
->
initial_stacksize
=
initial_stacksize
;
}
...
...
@@ -335,7 +341,6 @@ static void sparc_copy_attr(ir_graph *irg, const ir_node *old_node,
DUP_ARR_D
(
reg_out_info_t
,
obst
,
old_info
->
out_infos
);
}
/**
* compare some node's attributes
*/
...
...
ir/be/sparc/sparc_spec.pl
View file @
390bd81c
...
...
@@ -236,7 +236,6 @@ HiImm => {
outs
=>
[
"
res
"
],
mode
=>
$mode_gp
,
reg_req
=>
{
in
=>
[]
,
out
=>
[
"
gp
"
]
},
#attr_type => "sparc_load_store_attr_t",
attr
=>
"
int immediate_value
",
custominit
=>
"
sparc_set_attr_imm(res, immediate_value);
",
},
...
...
@@ -248,7 +247,6 @@ LoImm => {
outs
=>
[
"
res
"
],
mode
=>
$mode_gp
,
reg_req
=>
{
in
=>
[
"
gp
"
],
out
=>
[
"
gp
"
]
},
#attr_type => "sparc_load_store_attr_t",
attr
=>
"
int immediate_value
",
custominit
=>
"
sparc_set_attr_imm(res, immediate_value);
",
},
...
...
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