Added code to run some initialization routines only once, even if they were called...
authorAndreas Schösser <andi@ipd.info.uni-karlsruhe.de>
Fri, 9 Mar 2007 11:16:56 +0000 (11:16 +0000)
committerAndreas Schösser <andi@ipd.info.uni-karlsruhe.de>
Fri, 9 Mar 2007 11:16:56 +0000 (11:16 +0000)
ir/be/scripts/generate_new_opcodes.pl
ir/be/scripts/generate_regalloc_if.pl

index 121b645..9b8e9ba 100755 (executable)
@@ -465,8 +465,15 @@ void $arch\_create_opcodes(void) {
 #define O   irop_flag_machine_op
 #define R   (irop_flag_user << 0)
 
-       ir_op_ops ops;
-       int cur_opcode = get_next_ir_opcodes(iro_$arch\_last);
+       ir_op_ops  ops;
+       int        cur_opcode;
+       static int run_once = 0;
+
+       if (run_once)
+               return;
+       run_once = 1;
+
+       cur_opcode = get_next_ir_opcodes(iro_$arch\_last);
 
        $arch\_opcode_start = cur_opcode;
 ENDOFMAIN
index c29dc5d..3481218 100755 (executable)
@@ -108,6 +108,12 @@ push(@obst_classdef, "enum reg_classes {\n");
 
 my $class_mode;
 
+# assure, the initialization is done only once
+push(@obst_reginit, "  static int run_once = 0;\n");
+push(@obst_reginit, "\n");
+push(@obst_reginit, "  if (run_once)\n    return;\n");
+push(@obst_reginit, "  run_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"} };