From 20c1182abbf7dde0d2888f757fc0ade0b0f24cfb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20Sch=C3=B6sser?= Date: Fri, 9 Mar 2007 11:16:56 +0000 Subject: [PATCH] Added code to run some initialization routines only once, even if they were called several times. --- ir/be/scripts/generate_new_opcodes.pl | 11 +++++++++-- ir/be/scripts/generate_regalloc_if.pl | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ir/be/scripts/generate_new_opcodes.pl b/ir/be/scripts/generate_new_opcodes.pl index 121b6459a..9b8e9ba08 100755 --- a/ir/be/scripts/generate_new_opcodes.pl +++ b/ir/be/scripts/generate_new_opcodes.pl @@ -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 diff --git a/ir/be/scripts/generate_regalloc_if.pl b/ir/be/scripts/generate_regalloc_if.pl index c29dc5d0d..3481218c9 100755 --- a/ir/be/scripts/generate_regalloc_if.pl +++ b/ir/be/scripts/generate_regalloc_if.pl @@ -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"} }; -- 2.20.1