comments
[libfirm] / ir / be / scripts / generate_regalloc_if.pl
index 2227190..72c06bb 100755 (executable)
@@ -1,5 +1,24 @@
 #!/usr/bin/perl -w
 
+#
+# Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+#
+# This file is part of libFirm.
+#
+# This file may be distributed and/or modified under the terms of the
+# GNU General Public License version 2 as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL included in the
+# packaging of this file.
+#
+# Licensees holding valid libFirm Professional Edition licenses may use
+# this file in accordance with the libFirm Commercial License.
+# Agreement provided with the Software.
+#
+# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE.
+#
+
 # This script generates C code which creates ands sets up functions and
 # data structures for the register allocator.
 # Creation: 2005/11/14
@@ -24,9 +43,9 @@ my $return;
 
 use strict "subs";
 unless ($return = do $specfile) {
-       die "couldn't parse $specfile: $@" if $@;
-       die "couldn't do $specfile: $!"    unless defined $return;
-       die "couldn't run $specfile"       unless $return;
+       die "Fatal error: couldn't parse $specfile: $@" if $@;
+       die "Fatal error: couldn't do $specfile: $!"    unless defined $return;
+       die "Fatal error: couldn't run $specfile"       unless $return;
 }
 use strict "subs";
 
@@ -97,13 +116,6 @@ push(@obst_classdef, "enum reg_classes {\n");
 
 my $class_mode;
 
-# assure, the initialization is done only once
-push(@obst_reginit, "\tstatic int run_once = 0;\n");
-push(@obst_reginit, "\n");
-push(@obst_reginit, "\tif (run_once)\n");
-push(@obst_reginit, "\t\treturn;\n");
-push(@obst_reginit, "\trun_once = 1;\n");
-
 # generate register type and class variable, init function and default requirements
 foreach my $class_name (keys(%reg_classes)) {
        my @class         = @{ $reg_classes{"$class_name"} };
@@ -199,7 +211,7 @@ foreach my $op (keys(%nodes)) {
 
 
 # generate header _t (internal usage) file
-open(OUT, ">$target_h_t") || die("Could not open $target_h_t, reason: $!\n");
+open(OUT, ">$target_h_t") || die("Fatal error: Could not open $target_h_t, reason: $!\n");
 
 my $creation_time = localtime(time());
 
@@ -207,15 +219,15 @@ $tmp = uc($arch);
 
 print OUT<<EOF;
 /**
- * Generated register classes from spec.
- *
- * DO NOT EDIT THIS FILE, your changes will be lost.
- * Edit $specfile instead.
- * created by: $0 $specfile $target_dir
- * date:       $creation_time
+ * \@file
+ * \@brief    Generated register classes from spec.
+ * \@note     DO NOT EDIT THIS FILE, your changes will be lost.
+ *           Edit $specfile instead.
+ *           created by: $0 $specfile $target_dir
+ * \$date     $creation_time
  */
-#ifndef _GEN_${tmp}_REGALLOC_IF_T_H_
-#define _GEN_${tmp}_REGALLOC_IF_T_H_
+#ifndef FIRM_BE_${tmp}_GEN_${tmp}_REGALLOC_IF_T_H
+#define FIRM_BE_${tmp}_GEN_${tmp}_REGALLOC_IF_T_H
 
 #include "gen_${arch}_regalloc_if.h"
 
@@ -223,26 +235,25 @@ EOF
 
 print OUT @obst_header_t;
 
-print OUT "\n#endif /* _GEN_$tmp\_REGALLOC_IF_T_H_ */\n";
-
+print OUT "\n#endif\n";
 
 
 # generate header (external usage) file
-open(OUT, ">$target_h") || die("Could not open $target_h, reason: $!\n");
+open(OUT, ">$target_h") || die("Fatal error: Could not open $target_h, reason: $!\n");
 
 $creation_time = localtime(time());
 
 print OUT<<EOF;
 /**
- * Contains additional external requirements defs for external includes.
- *
- * DO NOT EDIT THIS FILE, your changes will be lost.
- * Edit $specfile instead.
- * created by: $0 $specfile $target_dir
- * date:       $creation_time
+ * \@file
+ * \@brief Contains additional external requirements defs for external includes.
+ * \@note   DO NOT EDIT THIS FILE, your changes will be lost.
+ *         Edit $specfile instead.
+ *         created by: $0 $specfile $target_dir
+ * \@date   $creation_time
  */
-#ifndef _GEN_${tmp}_REGALLOC_IF_H_
-#define _GEN_${tmp}_REGALLOC_IF_H_
+#ifndef FIRM_BE_${tmp}_GEN_${tmp}_REGALLOC_IF_H
+#define FIRM_BE_${tmp}_GEN_${tmp}_REGALLOC_IF_H
 
 #include "../bearch.h"
 #include "${arch}_nodes_attr.h"
@@ -257,31 +268,31 @@ print OUT @obst_regtypes_decl, "\n";
 
 print OUT "extern arch_register_class_t $arch\_reg_classes[N_CLASSES];\n\n";
 
-print OUT "void ".$arch."_register_init(void *isa_ptr);\n\n";
+print OUT "void ".$arch."_register_init(void);\n\n";
 
 print OUT @obst_header_all, "\n";
 
-print OUT "\n#endif /* _GEN_$tmp\_REGALLOC_IF_H_ */\n";
+print OUT "\n#endif\n";
 
 close(OUT);
 
 
 
 # generate c file
-open(OUT, ">$target_c") || die("Could not open $target_c, reason: $!\n");
+open(OUT, ">$target_c") || die("Fatal error: Could not open $target_c, reason: $!\n");
 
 $creation_time = localtime(time());
 
 print OUT<<EOF;
 /**
- * The generated interface for the register allocator.
- * Contains register classes and types and register constraints
- * for all nodes where constraints were given in spec.
- *
- * DO NOT EDIT THIS FILE, your changes will be lost.
- * Edit $specfile instead.
- * created by: $0 $specfile $target_dir
- * date:       $creation_time
+ * \@file
+ * \@brief  The generated interface for the register allocator.
+ *          Contains register classes and types and register constraints
+ *          for all nodes where constraints were given in spec.
+ * \@note    DO NOT EDIT THIS FILE, your changes will be lost.
+ *          Edit $specfile instead.
+ *          created by: $0 $specfile $target_dir
+ * \$date    $creation_time
  */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -304,7 +315,7 @@ print OUT "arch_register_class_t ${arch}_reg_classes[] = {\n\t".join(",\n\t", @o
 
 print OUT @obst_regtypes_def, "\n";
 
-print OUT "void ${arch}_register_init(void *isa_ptr) {\n";
+print OUT "void ${arch}_register_init(void) {\n";
 print OUT @obst_reginit;
 print OUT "}\n\n";
 
@@ -344,7 +355,7 @@ GET_CLASS:          foreach my $reg (@regs) {
                                        else {
                                                $class = get_reg_class($reg);
                                                if (!defined $class) {
-                                                       die("Could not get ".uc($inout)." register class for '$op' pos $idx (reg $reg) ... exiting.\n");
+                                                       die("Fatal error: Could not get ".uc($inout)." register class for '$op' pos $idx (reg $reg) ... exiting.\n");
                                                }
                                                else {
                                                        last GET_CLASS;
@@ -421,7 +432,7 @@ sub generate_requirements {
                        my ($class, $has_limit, $same_pos, $different_pos) = build_subset_class_func($n, $op, $idx, (($inout eq "in") ? 1 : 0), $reqs[$idx]);
 
                        if (!defined($class)) {
-                               die("Could not build subset for ".uc($inout)." requirements '$op' pos $idx ... exiting.\n");
+                               die("Fatal error: Could not build subset for ".uc($inout)." requirements '$op' pos $idx ... exiting.\n");
                        }
 
                        if ($has_limit) {