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
93647e70
Commit
93647e70
authored
May 06, 2013
by
Matthias Braun
Browse files
cleanup/refactor arch_opcode code
parent
715ea9b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/be/ia32/ia32_x87.c
View file @
93647e70
...
...
@@ -1251,30 +1251,32 @@ static ir_node *create_Copy(x87_state *state, ir_node *n)
const
arch_register_t
*
op1
;
/* Do not copy constants, recreate them. */
switch
(
get_ia32_irn_opcode
(
pred
))
{
case
iro_ia32_fldz
:
cnstr
=
new_bd_ia32_fldz
;
break
;
case
iro_ia32_fld1
:
cnstr
=
new_bd_ia32_fld1
;
break
;
case
iro_ia32_fldpi
:
cnstr
=
new_bd_ia32_fldpi
;
break
;
case
iro_ia32_fldl2e
:
cnstr
=
new_bd_ia32_fldl2e
;
break
;
case
iro_ia32_fldl2t
:
cnstr
=
new_bd_ia32_fldl2t
;
break
;
case
iro_ia32_fldlg2
:
cnstr
=
new_bd_ia32_fldlg2
;
break
;
case
iro_ia32_fldln2
:
cnstr
=
new_bd_ia32_fldln2
;
break
;
default:
break
;
if
(
is_ia32_irn
(
pred
))
{
switch
(
get_ia32_irn_opcode
(
pred
))
{
case
iro_ia32_fldz
:
cnstr
=
new_bd_ia32_fldz
;
break
;
case
iro_ia32_fld1
:
cnstr
=
new_bd_ia32_fld1
;
break
;
case
iro_ia32_fldpi
:
cnstr
=
new_bd_ia32_fldpi
;
break
;
case
iro_ia32_fldl2e
:
cnstr
=
new_bd_ia32_fldl2e
;
break
;
case
iro_ia32_fldl2t
:
cnstr
=
new_bd_ia32_fldl2t
;
break
;
case
iro_ia32_fldlg2
:
cnstr
=
new_bd_ia32_fldlg2
;
break
;
case
iro_ia32_fldln2
:
cnstr
=
new_bd_ia32_fldln2
;
break
;
default:
break
;
}
}
out
=
x87_get_irn_register
(
n
);
...
...
ir/be/scripts/generate_new_opcodes.pl
View file @
93647e70
...
...
@@ -542,7 +542,8 @@ foreach my $op (keys(%nodes)) {
# Create opcode
$obst_opvar
.=
"
ir_op *op_
$op
= NULL;
\n
";
$obst_get_opvar
.=
"
bool is_
$op
(const ir_node *n) {
\n
";
$obst_get_opvar
.=
"
bool is_
$op
(const ir_node *n)
\n
";
$obst_get_opvar
.=
"
{
\n
";
$obst_get_opvar
.=
"
\t
return get_irn_op(n) == op_
$op
;
\n
";
$obst_get_opvar
.=
"
}
\n\n
";
...
...
@@ -568,7 +569,8 @@ EOF
if
(
exists
(
$n
{"
cmp_attr
"}))
{
my
$cmpcode
=
$n
{"
cmp_attr
"};
$obst_cmp_attr
.=
"
static int cmp_attr_
$op
(const ir_node *a, const ir_node *b) {
\n
";
$obst_cmp_attr
.=
"
static int cmp_attr_
$op
(const ir_node *a, const ir_node *b)
\n
";
$obst_cmp_attr
.=
"
{
\n
";
if
(
$cmpcode
=~
m/attr_a/
)
{
$obst_cmp_attr
.=
"
\t
const
${attr_type}
*attr_a = get_irn_generic_attr_const(a);
\n
";
}
else
{
...
...
@@ -703,7 +705,6 @@ $obst_opvar
$obst_get_opvar
static int $arch\_opcode_start = -1;
static int $arch\_opcode_end = -1;
EOF
...
...
@@ -729,33 +730,25 @@ if (length($arch) >= 4) {
print
OUT
<<END;
/** A tag for the $arch opcodes.
Note that the address is used as a tag value, NOT the FOURCC code.
*/
/** A tag for the $arch opcodes. */
#define $arch\_op_tag FOURCC('$a', '$b', '$c', '$d')
/** Return the opcode number of the first $arch opcode. */
int get_$arch\_opcode_first(void) {
return $arch\_opcode_start;
}
/** Return the opcode number of the last $arch opcode + 1. */
int get_$arch\_opcode_last(void) {
return $arch\_opcode_end;
}
/** Return 1 if the given opcode is a $arch machine op, 0 otherwise */
int is_$arch\_op(const ir_op *op) {
int is_$arch\_op(const ir_op *op)
{
return get_op_tag(op) == $arch\_op_tag;
}
/** Return 1 if the given node is a $arch machine node, 0 otherwise */
int is_$arch\_irn(const ir_node *node) {
int is_$arch\_irn(const ir_node *node)
{
return is_$arch\_op(get_irn_op(node));
}
int get_$arch\_irn_opcode(const ir_node *node)
{
if (is_$arch\_irn(node))
return get_irn_opcode(node) - $arch\_opcode_start
;
return
-1
;
int get_$arch\_irn_opcode(const ir_node *node)
{
assert(is_$arch\_irn(node))
;
return
get_irn_opcode(node) - $arch\_opcode_start
;
}
#ifdef BIT
...
...
@@ -778,7 +771,6 @@ void $arch\_create_opcodes(const arch_irn_ops_t *be_ops)
$arch\_opcode_start = cur_opcode;
$obst_new_irop
$arch\_opcode_end = cur_opcode + iro_$arch\_last;
}
void $arch\_free_opcodes(void)
...
...
@@ -810,8 +802,6 @@ $obst_enum_op
int is_${arch}_irn(const ir_node *node);
int is_${arch}_op(const ir_op *op);
int get_${arch}_opcode_first(void);
int get_${arch}_opcode_last(void);
int get_${arch}_irn_opcode(const ir_node *node);
${obst_header}
${obst_proj}
...
...
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