Commit 44352760 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

bescripts: Automatically determine the mode of nodes by default and add the...

bescripts: Automatically determine the mode of nodes by default and add the option "first" to use the mode of the first output requirement.
parent e1552352
......@@ -17,7 +17,7 @@ $mode_fp = "mode_F"; # mode used by floatingpoint registers
# out_reqs => [ "reg_class|register|in_rX" ] | "...",
# ins => { "in1", "in2" }, # optional, creates n_op_in1, ... consts
# outs => { "out1", "out2" },# optional, creates pn_op_out1, ... consts
# mode => "mode_Iu", # optional, predefines the mode
# mode => "first" | "<mode>" # optional, determines the mode, auto-detected by default
# emit => "emit code with templates", # optional for virtual nodes
# attr => "additional attribute arguments for constructor", # optional
# init => "emit attribute initialization template", # optional
......@@ -77,27 +77,23 @@ my $binop = {
irn_flags => [ "rematerializable" ],
in_reqs => [ "gp", "gp" ],
out_reqs => [ "gp" ],
mode => $mode_gp,
};
my $constop = {
op_flags => [ "constlike" ],
irn_flags => [ "rematerializable" ],
out_reqs => [ "gp" ],
mode => $mode_gp,
};
my $fbinop = {
in_reqs => [ "fp", "fp" ],
out_reqs => [ "fp" ],
mode => $mode_fp,
};
my $unop = {
irn_flags => [ "rematerializable" ],
in_reqs => [ "gp" ],
out_reqs => [ "gp" ],
mode => $mode_gp,
};
%nodes = (
......@@ -168,7 +164,6 @@ Jmp => {
op_flags => [ "cfopcode" ],
irn_flags => [ "simple_jump" ],
out_reqs => [ "exec" ],
mode => "mode_X",
},
Start => {
......@@ -186,7 +181,6 @@ Return => {
out_reqs => [ "exec" ],
ins => [ "mem", "stack", "first_result" ],
outs => [ "X" ],
mode => "mode_X",
},
# Load / Store
......@@ -210,7 +204,6 @@ Store => {
out_reqs => [ "mem" ],
ins => [ "mem", "ptr", "val" ],
outs => [ "M" ],
mode => "mode_M",
emit => '(%S1) = store %S2',
},
......@@ -243,7 +236,6 @@ fMinus => {
in_reqs => [ "fp" ],
out_reqs => [ "fp" ],
emit => '%D0 = fneg %S0',
mode => $mode_fp,
},
fConst => {
......@@ -251,7 +243,6 @@ fConst => {
irn_flags => [ "rematerializable" ],
out_reqs => [ "fp" ],
emit => '%D0 = fconst %I',
mode => $mode_fp,
},
# Load / Store
......@@ -275,7 +266,6 @@ fStore => {
out_reqs => [ "mem" ],
ins => [ "mem", "ptr", "val" ],
outs => [ "M" ],
mode => "mode_M",
emit => '(%S1) = fstore %S2',
},
......
......@@ -348,7 +348,6 @@ mov_imm => {
attr_type => "amd64_movimm_attr_t",
attr => "amd64_insn_mode_t insn_mode, const amd64_imm64_t *imm",
emit => 'mov%MM $%C, %D0',
mode => $mode_gp,
},
movs => {
......@@ -386,7 +385,6 @@ jmp => {
op_flags => [ "cfopcode" ],
out_reqs => [ "exec" ],
fixed => "amd64_op_mode_t op_mode = AMD64_OP_IMM32;",
mode => "mode_X",
},
cmp => {
......@@ -409,7 +407,6 @@ lea => {
attr => "amd64_insn_mode_t insn_mode, amd64_addr_t addr",
fixed => "amd64_op_mode_t op_mode = AMD64_OP_ADDR;\n",
emit => "lea%M %A, %D0",
mode => $mode_gp,
},
jcc => {
......@@ -431,7 +428,6 @@ mov_store => {
outs => [ "M" ],
attr_type => "amd64_binop_addr_attr_t",
attr => "const amd64_binop_addr_attr_t *attr_init",
mode => "mode_M",
emit => "mov%M %S0, %A",
},
......@@ -472,7 +468,6 @@ ret => {
out_reqs => [ "exec" ],
ins => [ "mem", "stack", "first_result" ],
fixed => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
mode => "mode_X",
emit => "ret",
},
......@@ -507,7 +502,6 @@ movs_store_xmm => {
outs => [ "M" ],
attr_type => "amd64_binop_addr_attr_t",
attr => "const amd64_binop_addr_attr_t *attr_init",
mode => "mode_M",
emit => "movs%MX %^S0, %A",
},
......@@ -534,7 +528,6 @@ xorpd_0 => {
outs => [ "res" ],
fixed => "amd64_op_mode_t op_mode = AMD64_OP_REG_REG;",
emit => "xorpd %^D0, %^D0",
mode => $mode_xmm,
},
xorp => {
......@@ -548,7 +541,6 @@ movd_xmm_gp => {
outs => [ "res" ],
in_reqs => [ "xmm" ],
out_reqs => [ "gp" ],
mode => $mode_gp,
attr_type => "amd64_addr_attr_t",
attr => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
emit => "movd %S0, %D0"
......@@ -560,7 +552,6 @@ movd_gp_xmm => {
outs => [ "res" ],
in_reqs => [ "gp" ],
out_reqs => [ "xmm" ],
mode => $mode_xmm,
attr_type => "amd64_addr_attr_t",
attr => "amd64_insn_mode_t insn_mode, amd64_op_mode_t op_mode, amd64_addr_t addr",
emit => "movd %S0, %D0"
......@@ -626,7 +617,6 @@ movdqu_store => {
outs => [ "M" ],
attr_type => "amd64_binop_addr_attr_t",
attr => "const amd64_binop_addr_attr_t *attr_init",
mode => "mode_M",
emit => "movdqu %^S0, %A",
},
......
......@@ -73,7 +73,6 @@ $default_copy_attr = "arm_copy_attr";
my $unop_shifter_operand = {
irn_flags => [ "rematerializable" ],
mode => $mode_gp,
attr_type => "arm_shifter_operand_t",
out_reqs => [ "gp" ],
constructors => {
......@@ -104,7 +103,6 @@ my $unop_shifter_operand = {
my $binop_shifter_operand = {
irn_flags => [ "rematerializable" ],
mode => $mode_gp,
attr_type => "arm_shifter_operand_t",
out_reqs => [ "gp" ],
constructors => {
......@@ -169,7 +167,6 @@ my $binop_shifter_operand_setflags = {
my $binop_shifter_operand_flags = {
#irn_flags => [ "rematerializable" ],
attr_type => "arm_shifter_operand_t",
mode => $mode_gp,
out_reqs => [ "gp" ],
constructors => {
imm => {
......@@ -201,7 +198,6 @@ my $binop_shifter_operand_flags = {
my $cmp_shifter_operand = {
irn_flags => [ "rematerializable", "modify_flags" ],
emit => 'cmp %S0, %O',
mode => $mode_flags,
attr_type => "arm_cmp_attr_t",
out_reqs => [ "flags" ],
constructors => {
......@@ -253,7 +249,6 @@ my $binopf = {
out_reqs => [ "fpa" ],
attr_type => "arm_farith_attr_t",
attr => "ir_mode *op_mode",
mode => $mode_fp,
};
......@@ -278,7 +273,6 @@ Mul => {
irn_flags => [ "rematerializable" ],
in_reqs => [ "gp", "gp" ],
emit => 'mul %D0, %S0, %S1',
mode => $mode_gp,
constructors => {
"" => { out_reqs => [ "gp" ] },
# TODO: !in_r1 for out constraints the register allocator more than
......@@ -303,7 +297,6 @@ Mla => {
in_reqs => [ "gp", "gp", "gp" ],
ins => [ "left", "right", "add" ],
emit => 'mla %D0, %S0, %S1, %S2',
mode => $mode_gp,
constructors => {
"" => { out_reqs => [ "gp" ] },
# See comments for Mul_v5 out register constraint
......@@ -317,7 +310,6 @@ Mls => {
out_reqs => [ "gp" ],
ins => [ "left", "right", "sub" ],
emit => 'mls %D0, %S0, %S1, %S2',
mode => $mode_gp,
},
And => {
......@@ -333,7 +325,6 @@ Or => {
OrPl => {
#irn_flags => [ "rematerializable" ],
emit => 'orrpl %D0, %S2, %O',
mode => $mode_gp,
attr_type => "arm_shifter_operand_t",
in_reqs => [ "gp", "flags", "gp", "gp" ],
out_reqs => [ "in_r3" ],
......@@ -407,7 +398,6 @@ Clz => {
in_reqs => [ "gp" ],
out_reqs => [ "gp" ],
emit => 'clz %D0, %S0',
mode => $mode_gp,
},
# mov lr, pc\n mov pc, XXX -- This combination is used for calls to function
......@@ -456,7 +446,6 @@ FrameAddr => {
out_reqs => [ "gp" ],
ins => [ "base" ],
attr_type => "arm_Address_attr_t",
mode => $mode_gp,
},
Address => {
......@@ -465,7 +454,6 @@ Address => {
attr => "ir_entity *entity, int offset",
out_reqs => [ "gp" ],
attr_type => "arm_Address_attr_t",
mode => $mode_gp,
},
Cmn => {
......@@ -486,7 +474,6 @@ Tst => {
B => {
op_flags => [ "cfopcode", "forking" ],
state => "pinned",
mode => "mode_T",
in_reqs => [ "flags" ],
out_reqs => [ "exec", "exec" ],
ins => [ "flags" ],
......@@ -500,13 +487,11 @@ Jmp => {
op_flags => [ "cfopcode" ],
irn_flags => [ "simple_jump" ],
out_reqs => [ "exec" ],
mode => "mode_X",
},
SwitchJmp => {
op_flags => [ "cfopcode", "forking" ],
state => "pinned",
mode => "mode_T",
attr => "const ir_switch_table *table",
init => "init_arm_SwitchJmp_attributes(res, table);",
in_reqs => [ "gp" ],
......@@ -534,7 +519,6 @@ Str => {
in_reqs => [ "gp", "gp", "mem" ],
out_reqs => [ "mem" ],
emit => 'str%MS %S1, [%S0, #%o]',
mode => "mode_M",
attr_type => "arm_load_store_attr_t",
attr => "ir_mode *ls_mode, ir_entity *entity, int entity_sign, long offset, bool is_frame_entity",
},
......@@ -562,7 +546,7 @@ Dvf => {
outs => [ "res", "M" ],
attr_type => "arm_farith_attr_t",
attr => "ir_mode *op_mode",
mode => $mode_fp,
mode => "first",
},
Mvf => {
......@@ -572,7 +556,6 @@ Mvf => {
emit => 'mvf%MA %S0, %D0',
attr_type => "arm_farith_attr_t",
attr => "ir_mode *op_mode",
mode => $mode_fp,
},
FltX => {
......@@ -582,12 +565,10 @@ FltX => {
emit => 'flt%MA %D0, %S0',
attr_type => "arm_farith_attr_t",
attr => "ir_mode *op_mode",
mode => $mode_fp,
},
Cmfe => {
irn_flags => [ "rematerializable", "modify_flags" ],
mode => $mode_flags,
attr_type => "arm_cmp_attr_t",
attr => "bool ins_permuted",
init => "init_arm_cmp_attr(res, ins_permuted, false);",
......@@ -613,7 +594,6 @@ Stf => {
state => "exc_pinned",
ins => [ "ptr", "val", "mem" ],
outs => [ "M" ],
mode => "mode_M",
in_reqs => [ "gp", "fpa", "mem" ],
out_reqs => [ "mem" ],
emit => 'stf%MF %S1, [%S0, #%o]',
......@@ -627,7 +607,6 @@ fConst => {
irn_flags => [ "rematerializable" ],
attr => "ir_tarval *tv",
init => "attr->tv = tv;",
mode => $mode_fp,
out_reqs => [ "fpa" ],
attr_type => "arm_fConst_attr_t",
},
......@@ -645,7 +624,6 @@ Return => {
op_flags => [ "cfopcode" ],
in_reqs => "...",
ins => [ "mem", "sp", "first_result" ],
mode => "mode_X",
out_reqs => [ "exec" ],
emit => "bx lr",
},
......
......@@ -131,7 +131,7 @@ my $binop_commutative = {
ins => [ "base", "index", "mem", "left", "right" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
mode => $mode_gp,
mode => "first",
};
my $binop_flags = {
......@@ -147,7 +147,7 @@ my $binop_flags = {
am => "source,binary",
attr => "bool ins_permuted",
init => "attr->ins_permuted = ins_permuted;",
mode => $mode_flags,
mode => "first",
};
my $binop_mem = {
......@@ -168,7 +168,7 @@ my $shiftop = {
out_reqs => [ "in_r1 !in_r2", "flags" ],
ins => [ "val", "count" ],
outs => [ "res", "flags" ],
mode => $mode_gp,
mode => "first",
};
my $shiftop_mem = {
......@@ -192,7 +192,7 @@ my $shiftop_double = {
},
ins => [ "val_high", "val_low", "count" ],
outs => [ "res", "flags" ],
mode => $mode_gp,
mode => "first",
};
my $divop = {
......@@ -224,7 +224,7 @@ my $unop = {
out_reqs => [ "in_r1", "flags" ],
ins => [ "val" ],
outs => [ "res", "flags" ],
mode => $mode_gp,
mode => "first",
};
my $unop_no_flags = {
......@@ -234,7 +234,6 @@ my $unop_no_flags = {
out_reqs => [ "in_r1" ],
ins => [ "val" ],
outs => [ "res" ],
mode => $mode_gp,
};
my $unop_from_mem = {
......@@ -245,7 +244,7 @@ my $unop_from_mem = {
ins => [ "base", "index", "mem", "operand" ],
outs => [ "res", "flags", "M" ],
am => "source,unary",
mode => $mode_gp,
mode => "first",
};
my $unop_mem = {
......@@ -262,7 +261,6 @@ my $memop = {
in_reqs => [ "mem" ],
out_reqs => [ "mem" ],
ins => [ "mem" ],
mode => "mode_M",
};
my $prefetchop = {
......@@ -270,7 +268,6 @@ my $prefetchop = {
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem" ],
out_reqs => [ "mem" ],
mode => mode_M,
ins => [ "base", "index", "mem" ],
outs => [ "M" ],
};
......@@ -283,7 +280,7 @@ my $fbinop = {
ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
outs => [ "res", "dummy", "M" ],
am => "source,binary",
mode => $mode_fp87,
mode => "first",
attr_type => "ia32_x87_attr_t",
};
......@@ -293,7 +290,6 @@ my $funop = {
out_reqs => [ "fp" ],
ins => [ "value" ],
init => "attr->ls_mode = ia32_mode_E;",
mode => $mode_fp87,
};
my $fconstop = {
......@@ -303,7 +299,6 @@ my $fconstop = {
outs => [ "res" ],
init => "attr->ls_mode = ia32_mode_E;",
fixed => $x87sim,
mode => $mode_fp87,
};
my $valueop = {
......@@ -311,7 +306,6 @@ my $valueop = {
irn_flags => [ "rematerializable" ],
out_reqs => [ "gp" ],
outs => [ "res" ],
mode => $mode_gp,
};
my $fpopop = {
......@@ -319,7 +313,6 @@ my $fpopop = {
out_reqs => [ "none" ],
attrs_equal => "attrs_equal_false",
attr_type => "ia32_x87_attr_t",
mode => "mode_ANY",
};
my $xbinop = {
......@@ -330,7 +323,7 @@ my $xbinop = {
ins => [ "base", "index", "mem", "left", "right" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
mode => $mode_xmm,
mode => "first",
};
my $xbinop_commutative = {
......@@ -341,7 +334,7 @@ my $xbinop_commutative = {
ins => [ "base", "index", "mem", "left", "right" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
mode => $mode_xmm,
mode => "first",
};
my $xconv_i2f = {
......@@ -350,14 +343,12 @@ my $xconv_i2f = {
out_reqs => [ "xmm" ],
ins => [ "base", "index", "mem", "val" ],
am => "source,unary",
mode => $mode_xmm
};
my $xshiftop = {
irn_flags => [ "rematerializable" ],
in_reqs => [ "xmm", "xmm" ],
out_reqs => [ "in_r1 !in_r2" ],
mode => $mode_xmm,
};
my $xvalueop = {
......@@ -365,7 +356,6 @@ my $xvalueop = {
irn_flags => [ "rematerializable" ],
out_reqs => [ "xmm" ],
outs => [ "res" ],
mode => $mode_xmm,
};
my $carry_user_op = {
......@@ -391,7 +381,6 @@ Immediate => {
attr_type => "ia32_immediate_attr_t",
hash_func => "ia32_hash_Immediate",
latency => 0,
mode => $mode_gp,
},
Add => {
......@@ -416,7 +405,7 @@ Adc => {
emit => "adc%M %B",
am => "source,binary",
latency => 1,
mode => $mode_gp,
mode => "first",
},
l_Add => {
......@@ -508,7 +497,7 @@ Xor0 => {
outs => [ "res", "flags" ],
emit => "xor%M %D0, %D0",
latency => 1,
mode => $mode_gp,
mode => "first",
},
XorMem => {
......@@ -527,7 +516,7 @@ Sub => {
am => "source,binary",
emit => "sub%M %B",
latency => 1,
mode => $mode_gp,
mode => "first",
},
SubMem => {
......@@ -546,7 +535,7 @@ Sbb => {
am => "source,binary",
emit => "sbb%M %B",
latency => 1,
mode => $mode_gp,
mode => "first",
},
Sbb0 => {
......@@ -558,7 +547,7 @@ Sbb0 => {
outs => [ "res", "flags" ],
emit => "sbb%M %D0, %D0",
latency => 1,
mode => $mode_gp,
mode => "first",
},
l_Sub => {
......@@ -734,7 +723,6 @@ Cmc => {
out_reqs => [ "flags" ],
emit => "cmc",
latency => 1,
mode => $mode_flags,
},
Stc => {
......@@ -742,7 +730,6 @@ Stc => {
out_reqs => [ "flags" ],
emit => "stc",
latency => 1,
mode => $mode_flags,
},
Cmp => {
......@@ -784,7 +771,6 @@ Setcc => {
"\t\t/* attr->latency = 3; */\n".
"\t}\n",
latency => 1,
mode => $mode_gp,
},
SetccMem => {
......@@ -798,7 +784,6 @@ SetccMem => {
init => "set_ia32_ls_mode(res, mode_Bu);\n",
emit => "set%P3 %AM",
latency => 1,
mode => "mode_M",
},
CMovcc => {
......@@ -815,7 +800,7 @@ CMovcc => {
attr => "x86_condition_code_t condition_code",
emit => "cmov%P5 %#AS4, %#D0",
latency => 1,
mode => $mode_gp,
mode => "first",
},
Jcc => {
......@@ -847,7 +832,6 @@ Jmp => {
op_flags => [ "cfopcode" ],
out_reqs => [ "exec" ],
latency => 1,
mode => "mode_X",
},
IJmp => {
......@@ -860,7 +844,7 @@ IJmp => {
am => "source,unary",
emit => "jmp %*AS3",
latency => 1,
mode => "mode_X",
mode => "first",
},
Const => {
......@@ -888,14 +872,12 @@ NoReg_GP => {
template => $noregop,
out_reqs => [ "gp_NOREG:I" ],
latency => 0,
mode => $mode_gp
},
NoReg_FP => {
template => $noregop,
out_reqs => [ "fp_NOREG:I" ],
fixed => $x87sim,
mode => $mode_fp87,
latency => 0,
},
......@@ -903,13 +885,11 @@ NoReg_XMM => {
template => $noregop,
out_reqs => [ "xmm_NOREG:I" ],
latency => 0,
mode => $mode_xmm,
},
ChangeCW => {
template => $noregop,
out_reqs => [ "fpcw" ],
mode => $mode_fpcw,
latency => 3,
},
......@@ -921,7 +901,6 @@ FldCW => {
ins => [ "base", "index", "mem" ],
latency => 5,
emit => "fldcw %AM",
mode => $mode_fpcw,
},
FnstCW => {
......@@ -932,7 +911,6 @@ FnstCW => {
ins => [ "base", "index", "mem", "fpcw" ],
latency => 5,
emit => "fnstcw %AM",
mode => "mode_M",
},
FnstCWNOP => {
......@@ -943,7 +921,6 @@ FnstCWNOP => {
ins => [ "fpcw" ],
latency => 0,
emit => "",
mode => "mode_M",
},
Cltd => {
......@@ -953,7 +930,6 @@ Cltd => {
ins => [ "val" ],
emit => "cltd",
latency => 1,
mode => $mode_gp,
init => "arch_set_additional_pressure(res, &ia32_reg_classes[CLASS_ia32_gp], 1);",
},
......@@ -997,7 +973,6 @@ Lea => {
outs => [ "res" ],
emit