From f37b4dbb329604edd67ff5877161cb5322e93020 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 23 Jul 2008 15:04:03 +0000 Subject: [PATCH] - add support for opcode specific hash function - add hash function for ia32 Immediates - unified comments for all specifications [r20629] --- ir/be/TEMPLATE/TEMPLATE_spec.pl | 13 +++++++++---- ir/be/arm/arm_spec.pl | 8 ++++++-- ir/be/ia32/ia32_new_nodes.c | 9 +++++++++ ir/be/ia32/ia32_spec.pl | 12 +++++++++--- ir/be/mips/mips_spec.pl | 14 +++++++++++--- ir/be/ppc32/ppc32_spec.pl | 18 +++++++++++++----- ir/be/scripts/generate_new_opcodes.pl | 9 +++++++++ 7 files changed, 66 insertions(+), 17 deletions(-) diff --git a/ir/be/TEMPLATE/TEMPLATE_spec.pl b/ir/be/TEMPLATE/TEMPLATE_spec.pl index 86abe1a0f..3e7dfcacb 100644 --- a/ir/be/TEMPLATE/TEMPLATE_spec.pl +++ b/ir/be/TEMPLATE/TEMPLATE_spec.pl @@ -26,11 +26,16 @@ $arch = "TEMPLATE"; # comment => "any comment for constructor", # optional # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] }, # cmp_attr => "c source code for comparing node attributes", # optional -# outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts -# ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts -# mode => "mode_Iu" # optional, predefines the mode +# outs => { "out1", "out2" },# optional, creates pn_op_out1, ... consts +# ins => { "in1", "in2" }, # optional, creates n_op_in1, ... consts +# mode => "mode_Iu", # optional, predefines the mode # emit => "emit code with templates", # optional for virtual nodes -# rd_constructor => "c source code which constructs an ir_node" # optional +# attr => "attitional attribute arguments for constructor", # optional +# init_attr => "emit attribute initialization template", # optional +# rd_constructor => "c source code which constructs an ir_node", # optional +# hash_func => "name of the hash function for this operation", # optional, get the default hash function else +# latency => "latency of this operation (can be float)" # optional +# attr_type => "name of the attribute struct", # optional # }, # # ... # (all nodes you need to describe) diff --git a/ir/be/arm/arm_spec.pl b/ir/be/arm/arm_spec.pl index a17d473d8..98f49e016 100644 --- a/ir/be/arm/arm_spec.pl +++ b/ir/be/arm/arm_spec.pl @@ -28,10 +28,14 @@ $new_emit_syntax = 1; # comment => "any comment for constructor", # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] }, # cmp_attr => "c source code for comparing node attributes", +# outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts +# ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts +# mode => "mode_Iu" # optional, predefines the mode # emit => "emit code with templates", -# attr => "attitional attribute arguments for constructor" -# init_attr => "emit attribute initialization template" +# attr => "attitional attribute arguments for constructor", +# init_attr => "emit attribute initialization template", # rd_constructor => "c source code which constructs an ir_node" +# hash_func => "name of the hash function for this operation", # latency => "latency of this operation (can be float)" # attr_type => "name of the attribute struct", # }, diff --git a/ir/be/ia32/ia32_new_nodes.c b/ir/be/ia32/ia32_new_nodes.c index 3f24eea10..3804dbf5b 100644 --- a/ir/be/ia32/ia32_new_nodes.c +++ b/ir/be/ia32/ia32_new_nodes.c @@ -1231,6 +1231,15 @@ int ia32_compare_asm_attr(ir_node *a, ir_node *b) return 0; } +/** + * Hash function for Immediates + */ +static unsigned ia32_hash_Immediate(const ir_node *irn) { + const ia32_immediate_attr_t *a = get_ia32_immediate_attr_const(irn); + + return HASH_PTR(a->symconst) + (a->sc_sign << 16) + a->offset; +} + /** Compare node attributes for Immediates. */ static int ia32_compare_immediate_attr(ir_node *a, ir_node *b) diff --git a/ir/be/ia32/ia32_spec.pl b/ir/be/ia32/ia32_spec.pl index b0371f51b..64673b0fb 100644 --- a/ir/be/ia32/ia32_spec.pl +++ b/ir/be/ia32/ia32_spec.pl @@ -28,10 +28,15 @@ $arch = "ia32"; # comment => "any comment for constructor", # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] }, # cmp_attr => "c source code for comparing node attributes", +# outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts +# ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts +# mode => "mode_Iu" # optional, predefines the mode # emit => "emit code with templates", -# attr => "attitional attribute arguments for constructor" -# init_attr => "emit attribute initialization template" -# rd_constructor => "c source code which constructs an ir_node" +# attr => "attitional attribute arguments for constructor", +# init_attr => "emit attribute initialization template", +# rd_constructor => "c source code which constructs an ir_node", +# hash_func => "name of the hash function for this operation", +# latency => "latency of this operation (can be float)" # attr_type => "name of the attribute struct", # }, # @@ -318,6 +323,7 @@ Immediate => { reg_req => { out => [ "gp_NOREG" ] }, attr => "ir_entity *symconst, int symconst_sign, long offset", attr_type => "ia32_immediate_attr_t", + hash_func => "ia32_hash_Immediate", latency => 0, mode => $mode_gp, }, diff --git a/ir/be/mips/mips_spec.pl b/ir/be/mips/mips_spec.pl index bbb1e509a..9b135a276 100644 --- a/ir/be/mips/mips_spec.pl +++ b/ir/be/mips/mips_spec.pl @@ -21,11 +21,19 @@ $new_emit_syntax = 1; # { "type" => "type 2", "name" => "name 2" }, # ... # ], -# "comment" => "any comment for constructor", +# comment => "any comment for constructor", # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] }, -# "cmp_attr" => "c source code for comparing node attributes", +# cmp_attr => "c source code for comparing node attributes", +# outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts +# ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts +# mode => "mode_Iu" # optional, predefines the mode # emit => "emit code with templates", -# "rd_constructor" => "c source code which constructs an ir_node" +# attr => "attitional attribute arguments for constructor", +# init_attr => "emit attribute initialization template", +# rd_constructor => "c source code which constructs an ir_node", +# hash_func => "name of the hash function for this operation", +# latency => "latency of this operation (can be float)" +# attr_type => "name of the attribute struct", # }, # # ... # (all nodes you need to describe) diff --git a/ir/be/ppc32/ppc32_spec.pl b/ir/be/ppc32/ppc32_spec.pl index c1b05d2c8..746958d58 100644 --- a/ir/be/ppc32/ppc32_spec.pl +++ b/ir/be/ppc32/ppc32_spec.pl @@ -22,11 +22,19 @@ $new_emit_syntax = 1; # { "type" => "type 2", "name" => "name 2" }, # ... # ], -# "comment" => "any comment for constructor", -# "reg_req" => { "in" => [ "reg_class|register" ], "out" => [ "reg_class|register|in_rX" ] }, -# "cmp_attr" => "c source code for comparing node attributes", -# "emit" => "emit code with templates", -# "rd_constructor" => "c source code which constructs an ir_node" +# comment => "any comment for constructor", +# reg_req => { "in" => [ "reg_class|register" ], "out" => [ "reg_class|register|in_rX" ] }, +# cmp_attr => "c source code for comparing node attributes", +# outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts +# ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts +# mode => "mode_Iu" # optional, predefines the mode +# emit => "emit code with templates", +# attr => "attitional attribute arguments for constructor", +# init_attr => "emit attribute initialization template", +# rd_constructor => "c source code which constructs an ir_node", +# hash_func => "name of the hash function for this operation", +# latency => "latency of this operation (can be float)" +# attr_type => "name of the attribute struct", # }, # # ... # (all nodes you need to describe) diff --git a/ir/be/scripts/generate_new_opcodes.pl b/ir/be/scripts/generate_new_opcodes.pl index bbbec00af..59d784bf5 100755 --- a/ir/be/scripts/generate_new_opcodes.pl +++ b/ir/be/scripts/generate_new_opcodes.pl @@ -265,6 +265,12 @@ foreach my $op (keys(%nodes)) { $attr_type = $default_attr_type; } + # determine hash function + my $hash_func; + if (exists($n{"hash_func"})) { + $hash_func = $n{"hash_func"}; + } + # determine compare function my $cmp_attr_func; if (exists($n{"cmp_attr"})) { @@ -575,6 +581,9 @@ foreach my $op (keys(%nodes)) { if (defined($copy_attr_func)) { push(@obst_new_irop, "\tops.copy_attr = ${copy_attr_func};\n"); } + if (defined($hash_func)) { + push(@obst_new_irop, "\tops.hash = ${hash_func};\n"); + } $n_opcodes++; my $n_res = $out_arity; -- 2.20.1