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
2576b281
Commit
2576b281
authored
Nov 09, 2014
by
Matthias Braun
Browse files
amd64: enumerate commutative binops in spec file, add missing xXorp to list
parent
d582c836
Changes
3
Hide whitespace changes
Inline
Side-by-side
ir/be/amd64/amd64_finish.c
View file @
2576b281
...
...
@@ -37,12 +37,16 @@ static unsigned get_first_same(arch_register_req_t const *const req)
panic
(
"same position not found"
);
}
static
bool
is_commutative
(
const
ir_node
*
node
)
{
return
arch_get_irn_flags
(
node
)
&
amd64_arch_irn_flag_commutative_binop
;
}
static
bool
try_swap_inputs
(
ir_node
*
node
)
{
/* commutative operation, just switch the inputs */
if
(
is_amd64_Add
(
node
)
||
is_amd64_And
(
node
)
||
is_amd64_Or
(
node
)
||
is_amd64_Xor
(
node
)
||
is_amd64_IMul
(
node
)
||
is_amd64_xAdds
(
node
)
||
is_amd64_xMuls
(
node
))
{
if
(
is_commutative
(
node
))
{
assert
(
get_amd64_attr_const
(
node
)
->
op_mode
==
AMD64_OP_REG_REG
);
/* TODO: support Cmp input swapping */
ir_node
*
in0
=
get_irn_n
(
node
,
0
);
ir_node
*
in1
=
get_irn_n
(
node
,
1
);
...
...
ir/be/amd64/amd64_nodes_attr.h
View file @
2576b281
...
...
@@ -16,6 +16,10 @@
#include
"compiler.h"
#include
"../ia32/x86_cc.h"
enum
amd64_arch_irn_flags_t
{
amd64_arch_irn_flag_commutative_binop
=
arch_irn_flag_backend
<<
0
,
};
typedef
enum
{
INSN_MODE_64
,
INSN_MODE_32
,
...
...
ir/be/amd64/amd64_spec.pl
View file @
2576b281
...
...
@@ -56,6 +56,10 @@ sub amd64_custom_init_attr {
}
$custom_init_attr_func
=
\
&amd64_custom_init_attr
;
%custom_irn_flags
=
(
commutative
=>
"
(arch_irn_flags_t)amd64_arch_irn_flag_commutative_binop
",
);
$default_copy_attr
=
"
amd64_copy_attr
";
%init_attr
=
(
...
...
@@ -139,7 +143,7 @@ Leave => {
},
Add
=>
{
irn_flags
=>
[
"
rematerializable
"
],
irn_flags
=>
[
"
rematerializable
"
,
"
commutative
"
],
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
gp
",
"
flags
",
"
none
"
]
},
arity
=>
"
variable
",
...
...
@@ -151,7 +155,7 @@ Add => {
},
And
=>
{
irn_flags
=>
[
"
rematerializable
"
],
irn_flags
=>
[
"
rematerializable
"
,
"
commutative
"
],
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
gp
",
"
flags
",
"
none
"
]
},
arity
=>
"
variable
",
...
...
@@ -190,7 +194,7 @@ IDiv => {
},
IMul
=>
{
irn_flags
=>
[
"
rematerializable
"
],
irn_flags
=>
[
"
rematerializable
"
,
"
commutative
"
],
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
gp
",
"
flags
",
"
none
"
]
},
outs
=>
[
"
res
",
"
flags
",
"
M
"
],
...
...
@@ -203,6 +207,8 @@ IMul => {
IMul1Op
=>
{
# Do not rematerialize this node
# TODO: should mark this commutative as soon as the backend code
# can handle this special case
# It produces 2 results and has strict constraints
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
rax
",
"
flags
",
"
none
",
"
rdx
"
]
},
...
...
@@ -228,7 +234,7 @@ Mul => {
},
Or
=>
{
irn_flags
=>
[
"
rematerializable
"
],
irn_flags
=>
[
"
rematerializable
"
,
"
commutative
"
],
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
gp
",
"
flags
",
"
none
"
]
},
outs
=>
[
"
res
",
"
flags
",
"
M
"
],
...
...
@@ -323,7 +329,7 @@ Not => {
},
Xor
=>
{
irn_flags
=>
[
"
rematerializable
"
],
irn_flags
=>
[
"
rematerializable
"
,
"
commutative
"
],
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
gp
",
"
flags
",
"
none
"
]
},
arity
=>
"
variable
",
...
...
@@ -482,7 +488,7 @@ Return => {
# SSE
xAdds
=>
{
irn_flags
=>
[
"
rematerializable
"
],
irn_flags
=>
[
"
rematerializable
"
,
"
commutative
"
],
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
xmm
",
"
none
",
"
none
"
]
},
outs
=>
[
"
res
",
"
none
",
"
M
"
],
...
...
@@ -514,7 +520,7 @@ xMovs => {
},
xMuls
=>
{
irn_flags
=>
[
"
rematerializable
"
],
irn_flags
=>
[
"
rematerializable
"
,
"
commutative
"
],
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
xmm
",
"
none
",
"
none
"
]
},
outs
=>
[
"
res
",
"
none
",
"
M
"
],
...
...
@@ -571,7 +577,7 @@ xXorp0 => {
},
xXorp
=>
{
irn_flags
=>
[
"
rematerializable
"
],
irn_flags
=>
[
"
rematerializable
"
,
"
commutative
"
],
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
xmm
",
"
none
",
"
none
"
]
},
arity
=>
"
variable
",
...
...
Write
Preview
Supports
Markdown
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