Commit 2576b281 authored by Matthias Braun's avatar Matthias Braun
Browse files

amd64: enumerate commutative binops in spec file, add missing xXorp to list

parent d582c836
......@@ -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);
......
......@@ -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,
......
......@@ -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",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment