- add support for opcode specific hash function
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 23 Jul 2008 15:04:03 +0000 (15:04 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 23 Jul 2008 15:04:03 +0000 (15:04 +0000)
- add hash function for ia32 Immediates
- unified comments for all specifications

[r20629]

ir/be/TEMPLATE/TEMPLATE_spec.pl
ir/be/arm/arm_spec.pl
ir/be/ia32/ia32_new_nodes.c
ir/be/ia32/ia32_spec.pl
ir/be/mips/mips_spec.pl
ir/be/ppc32/ppc32_spec.pl
ir/be/scripts/generate_new_opcodes.pl

index 86abe1a..3e7dfca 100644 (file)
@@ -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)
index a17d473..98f49e0 100644 (file)
@@ -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",
 # },
index 3f24eea..3804dbf 100644 (file)
@@ -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)
index b0371f5..64673b0 100644 (file)
@@ -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,
 },
index bbb1e50..9b135a2 100644 (file)
@@ -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)
index c1b05d2..746958d 100644 (file)
@@ -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)
index bbbec00..59d784b 100755 (executable)
@@ -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;