diff --git a/gcc/cobol/ccc/many b/gcc/cobol/ccc/many index d37141152ff68f5b301fe693565b1dee02e6f0b4..2b231f4fb12674496c0841d510ac8c1e6233b2d7 100755 --- a/gcc/cobol/ccc/many +++ b/gcc/cobol/ccc/many @@ -1,5 +1,10 @@ #!/usr/bin/python +# This one builds a simple cobol program with many variables, and a simple +# C program that parallels the data structure of those variables. It was part +# of an effort to figure out why it takes the GCC middle end so long to just +# build the .S for the variables. + import sys fout = None diff --git a/gcc/cobol/ccc/many2 b/gcc/cobol/ccc/many2 new file mode 100755 index 0000000000000000000000000000000000000000..427a1e65ec33f7270e1317665ce6dca1438d8983 --- /dev/null +++ b/gcc/cobol/ccc/many2 @@ -0,0 +1,160 @@ +#!/usr/bin/python + +import sys + +fout = None + +def xprint(str): + global fout + # print(str) + fout.write(str.rstrip()) + fout.write("\n") + +def cobol_code(): + global fout + # print("We are doing ", sys.argv[1]) + nlines = int(sys.argv[1]) + + fout = open("test.cbl", "w") + + xprint(" identification division.") + xprint(" program-id. nlines_cobol.") + xprint(" data division.") + xprint(" working-storage section.") + + for i in range(1, nlines+1): + xprint(" 77 var{:d} pic 9999v9999 comp-5.".format(i)) + + xprint(" procedure division.") + + for i in range(1, nlines+1): + xprint(" display var{:d}".format(i)) + + xprint(" stop run.") + xprint(" end program nlines_cobol.") + + fout.close(); + +def c_code(): + global fout + + # To make the generation of C similar to the generation of COBOL, we add 14 + # variables to compensate for the COBOL boilerplate of + # counter 1 DEBUG-ITEM + # counter 2 DEBUG-LINE + # counter 3 FILLER + # counter 4 DEBUG-NAME + # counter 5 FILLER + # counter 6 DEBUG-SUB-1 + # counter 7 FILLER + # counter 8 DEBUG-SUB-2 + # counter 9 FILLER + # counter 10 DEBUG-SUB-3 + # counter 11 FILLER + # counter 12 DEBUG-CONTENTS + # counter 13 _literaln_1 "1" + # counter 14 _literaln_2 "0" + nlines = int(sys.argv[1]) + 14 + + fout = open("ccc.c", "w") + + xprint("#include <stdio.h>") + xprint("#include <stdlib.h>") + xprint("#include <string.h>") + + # Establish the structure ") + xprint("typedef struct cblc_field_t ") + xprint(" { ") + xprint(" // This structure must match the code in structs.cc ") + xprint(" unsigned char *data; // The runtime data. There is no null terminator ") + xprint(" unsigned long capacity; // The size of data ") + xprint(" unsigned long allocated; // The number of bytes available for capacity ") + xprint(" unsigned long offset; // Offset from our ancestor (see note below) ") + xprint(" char *name; // The null-terminated name of this variable ") + xprint(" char *picture; // The null-terminated picture string. ") + xprint(" char *initial; // The null_terminated initial value ") + xprint(" struct cblc_field_t *parent; // This field's immediate parent field ") + xprint(" struct cblc_field_t *depending_on;// The subject of a DEPENDING ON clause ") + xprint(" struct cblc_field_t *depends_on; // Points downward in heirachy to the subordinate DEPENDING ON ") + xprint(" unsigned long occurs_lower; // non-zero for a table ") + xprint(" unsigned long occurs_upper; // non-zero for a table ") + xprint(" unsigned long attr; // See cbl_field_attr_t ") + xprint(" signed char type; // A one-byte copy of cbl_field_type_t ") + xprint(" signed char level; // This variable's level in the naming heirarchy ") + xprint(" signed char digits; // Digits specified in PIC string; e.g. 5 for 99v999 ") + xprint(" signed char rdigits; // Digits to the right of the decimal point. 3 for 99v999 ") + xprint(" int dummy; // Fills out to a four-byte boundary ") + xprint(" } cblc_field_t; ") + + # Establish the initializer + xprint("unsigned long ") + xprint("__gg__initialize_variable(cblc_field_t *var_ref, ") + xprint(" int is_redefined, ") + xprint(" unsigned int nsubscripts, ") + xprint(" int explicitly) ") + xprint(" { ") + xprint("#if 1 ") + xprint(" // This code emulates the call GCOBOL has to make to libgcobol.so in order ") + xprint(" // to create and iniailize a variable ") + xprint(" // It is based on an environment variable, which means that the ") + xprint(" // C optimizer can't easily just wish it away. ") + xprint(" unsigned long retval; ") + xprint(" int n = atoi(getenv(\"banana\")); ") + xprint(" switch(n) ") + xprint(" { ") + xprint(" case 1: ") + xprint(" retval = (unsigned long)(&var_ref); ") + xprint(" break; ") + xprint(" case 2: ") + xprint(" retval = is_redefined; ") + xprint(" break; ") + xprint(" case 3: ") + xprint(" retval = nsubscripts; ") + xprint(" break; ") + xprint(" default: ") + xprint(" retval = explicitly; ") + xprint(" break; ") + xprint(" } ") + xprint("#endif ") + xprint(" } ") + + # Establish the principal routine() + xprint("int nlines_c()") + xprint(" {") + xprint(" int i = atoi(getenv(\"banana\"));") + + for i in range(1, nlines+1): + xprint(" static unsigned char vardata{:d}[4];".format(i)) + + for i in range(1, nlines+1): + xprint(" static unsigned char var_{:d}[sizeof(cblc_field_t)];".format(i)) + + for i in range(1, nlines+1): + xprint(" static cblc_field_t *var{0:d} = (cblc_field_t *)(&var_{0:d});".format(i)) + + + for i in range(1, nlines+1): + xprint(" var{0:d}->data = vardata{0:d};".format(i)) +# +# xprint(" unsigned long n = 0;") +# xprint(" n += 0") +# +# for i in range(1, nlines+1): +# xprint(" + __gg__initialize_variable(var{:d}, i?1:0, 3, i?4:5)".format(i)) +# xprint(" ;") +# xprint(" return n") +# +# for i in range(1, nlines+1): +# xprint(" + (unsigned long)(&var{:d}) ".format(i)) +# xprint(" ;") + xprint(" }") + + xprint("") + xprint("int main(){nlines_c();}") + xprint("") + + fout.close(); + +cobol_code() +c_code() + diff --git a/gcc/cobol/ccc/many3 b/gcc/cobol/ccc/many3 new file mode 100755 index 0000000000000000000000000000000000000000..f3879423a07aa5777d04429a8ce4f4e7e67defdf --- /dev/null +++ b/gcc/cobol/ccc/many3 @@ -0,0 +1,168 @@ +#!/usr/bin/python + +# This is a test platform; it creates the C program using a hierarchical +# data structure more like that of GnuCOBOL + + +import sys + +fout = None + +def xprint(str): + global fout + # print(str) + fout.write(str.rstrip()) + fout.write("\n") + +def cobol_code(): + global fout + # print("We are doing ", sys.argv[1]) + nlines = int(sys.argv[1]) + + fout = open("test.cbl", "w") + + xprint(" identification division.") + xprint(" program-id. nlines_cobol.") + xprint(" data division.") + xprint(" working-storage section.") + + for i in range(1, nlines+1): + xprint(" 77 var{:d} pic 9999v9999 comp-5.".format(i)) + + xprint(" procedure division.") + + for i in range(1, nlines+1): + xprint(" display var{:d}".format(i)) + + xprint(" stop run.") + xprint(" end program nlines_cobol.") + + fout.close(); + +def c_code(): + global fout + + # To make the generation of C similar to the generation of COBOL, we add 14 + # variables to compensate for the COBOL boilerplate of + # counter 1 DEBUG-ITEM + # counter 2 DEBUG-LINE + # counter 3 FILLER + # counter 4 DEBUG-NAME + # counter 5 FILLER + # counter 6 DEBUG-SUB-1 + # counter 7 FILLER + # counter 8 DEBUG-SUB-2 + # counter 9 FILLER + # counter 10 DEBUG-SUB-3 + # counter 11 FILLER + # counter 12 DEBUG-CONTENTS + # counter 13 _literaln_1 "1" + # counter 14 _literaln_2 "0" + nlines = int(sys.argv[1]) + 14 + + fout = open("ccc.c", "w") + + xprint("#include <stdio.h>") + xprint("#include <stdlib.h>") + xprint("#include <string.h>") + + # Establish the structures + xprint("typedef struct cblc_field_attr_t ") + xprint(" { ") + xprint(" // This structure must match the code in structs.cc ") + xprint(" unsigned long allocated; // The number of bytes available for capacity ") + xprint(" unsigned long offset; // Offset from our ancestor (see note below) ") + xprint(" char *name; // The null-terminated name of this variable ") + xprint(" char *picture; // The null-terminated picture string. ") + xprint(" char *initial; // The null_terminated initial value ") + xprint(" struct cblc_field_t *parent; // This field's immediate parent field ") + xprint(" struct cblc_field_t *depending_on;// The subject of a DEPENDING ON clause ") + xprint(" struct cblc_field_t *depends_on; // Points downward in heirachy to the subordinate DEPENDING ON ") + xprint(" unsigned long occurs_lower; // non-zero for a table ") + xprint(" unsigned long occurs_upper; // non-zero for a table ") + xprint(" unsigned long attr; // See cbl_field_attr_t ") + xprint(" signed char type; // A one-byte copy of cbl_field_type_t ") + xprint(" signed char level; // This variable's level in the naming heirarchy ") + xprint(" signed char digits; // Digits specified in PIC string; e.g. 5 for 99v999 ") + xprint(" signed char rdigits; // Digits to the right of the decimal point. 3 for 99v999 ") + xprint(" int dummy; // Fills out to a four-byte boundary ") + xprint(" } cblc_field_attr_t; ") + xprint("typedef struct cblc_field_t ") + xprint(" { ") + xprint(" // This structure must match the code in structs.cc ") + xprint(" unsigned char *data; // The runtime data. There is no null terminator ") + xprint(" unsigned long capacity; // The size of data ") + xprint(" cblc_field_attr_t *fattr; // Points to this variable's attributes: ") + xprint(" } cblc_field_t; ") + + # Establish the initializer + xprint("unsigned long ") + xprint("__gg__initialize_variable(cblc_field_t *var_ref, ") + xprint(" int is_redefined, ") + xprint(" unsigned int nsubscripts, ") + xprint(" int explicitly) ") + xprint(" { ") + xprint("#if 1 ") + xprint(" // This code emulates the call GCOBOL has to make to libgcobol.so in order ") + xprint(" // to create and iniailize a variable ") + xprint(" // It is based on an environment variable, which means that the ") + xprint(" // C optimizer can't easily just wish it away. ") + xprint(" unsigned long retval; ") + xprint(" int n = atoi(getenv(\"banana\")); ") + xprint(" switch(n) ") + xprint(" { ") + xprint(" case 1: ") + xprint(" retval = (unsigned long)(&var_ref); ") + xprint(" break; ") + xprint(" case 2: ") + xprint(" retval = is_redefined; ") + xprint(" break; ") + xprint(" case 3: ") + xprint(" retval = nsubscripts; ") + xprint(" break; ") + xprint(" default: ") + xprint(" retval = explicitly; ") + xprint(" break; ") + xprint(" } ") + xprint("#endif ") + xprint(" } ") + + # Establish the principal routine() + xprint("int nlines_c()") + xprint(" {") + xprint(" static cblc_field_attr_t attr1 = {4, 0, \"name\", 0, 0, 0, 0, 0, 0, 0, 0, 6, 77, 8, 4};") + + xprint(" int i = atoi(getenv(\"banana\"));") + + for i in range(1, nlines+1): + xprint(" static unsigned char vardata{:d}[4];".format(i)) + + for i in range(1, nlines+1): + xprint(" static cblc_field_t var{0:d} = {{vardata1, 4, &attr1}};".format(i)) + + xprint(" unsigned long n = 0;") + xprint(" n += 0") + + for i in range(1, nlines+1): + xprint(" __gg__initialize_variable(&var{:d}, i?1:0, 3, i?4:5);".format(i)) + + +# for i in range(1, nlines+1): +# xprint(" + __gg__initialize_variable(&var{:d}, i?1:0, 3, i?4:5)".format(i)) +# xprint(" ;") +# xprint(" return n") +# +# for i in range(1, nlines+1): +# xprint(" + (unsigned long)(&var{:d}) ".format(i)) +# xprint(" ;") + xprint(" }") + + xprint("") + xprint("int main(){nlines_c();}") + xprint("") + + fout.close(); + +cobol_code() +c_code() + diff --git a/gcc/cobol/ccc/perf.stat b/gcc/cobol/ccc/perf.stat deleted file mode 100644 index f920a90b4edcce1121c0243bbbfe03910f484d33..0000000000000000000000000000000000000000 --- a/gcc/cobol/ccc/perf.stat +++ /dev/null @@ -1,18 +0,0 @@ - - Performance counter stats for '/home/bob/repos/gcc-cobol/build/gcc/gcobol -B /home/bob/repos/gcc-cobol/build/gcc -L /home/bob/repos/gcc-cobol/build/x86_64-linux-gnu/libstdc++-v3/src/.libs -L /home/bob/repos/gcc-cobol/build/x86_64-linux-gnu/libgcobol/.libs/ -ggdb -O0 -S -o test.s test.cbl': - - 1,304,772.96 msec task-clock # 1.000 CPUs utilized - 5,981 context-switches # 4.584 /sec - 7 cpu-migrations # 0.005 /sec - 3,561,311 page-faults # 2.729 K/sec - 7,741,017,659,594 cycles # 5.933 GHz -12,323,052,786,851 instructions # 1.59 insn per cycle - 1,636,199,774,886 branches # 1.254 G/sec - 1,375,794,395 branch-misses # 0.08% of all branches - - 1304.944194025 seconds time elapsed - - 1302.280417000 seconds user - 2.487884000 seconds sys - - diff --git a/gcc/cobol/ccc/results.txt b/gcc/cobol/ccc/results.txt deleted file mode 100644 index 8b137891791fe96927ad78e64b0aad7bded08bdc..0000000000000000000000000000000000000000 --- a/gcc/cobol/ccc/results.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/gcc/cobol/ccc/run b/gcc/cobol/ccc/run index 3e6fde5cb9e98080caef5fc41d21cf2005f6c743..9501f2da604f43f1ace3d06e725457ace8b63359 100755 --- a/gcc/cobol/ccc/run +++ b/gcc/cobol/ccc/run @@ -3,11 +3,11 @@ function dolines { LLINES=$LINES -./many $LLINES +./many3 $LLINES perf stat > perf.stat 2>&1 -- /home/bob/repos/gcc-cobol/build/gcc/xgcc -B /home/bob/repos/gcc-cobol/build/gcc -ggdb -O0 -o ccc.s ccc.c -S INSC=$(grep instructions perf.stat | sed -E 's/^[ ]+([^ ]+).*$/\1/g') -perf stat > perf.stat 2>&1 -- /home/bob/repos/gcc-cobol/build/gcc/gcobol -B /home/bob/repos/gcc-cobol/build/gcc -L /home/bob/repos/gcc-cobol/build/x86_64-linux-gnu/libstdc++-v3/src/.libs -L /home/bob/repos/gcc-cobol/build/x86_64-linux-gnu/libgcobol/.libs/ -ggdb -O0 -S -o test.s test.cbl -INSCOBOL=$(grep instructions perf.stat | sed -E 's/^[ ]+([^ ]+).*$/\1/g') +#perf stat > perf.stat 2>&1 -- /home/bob/repos/gcc-cobol/build/gcc/gcobol -B /home/bob/repos/gcc-cobol/build/gcc -L /home/bob/repos/gcc-cobol/build/x86_64-linux-gnu/libstdc++-v3/src/.libs -L /home/bob/repos/gcc-cobol/build/x86_64-linux-gnu/libgcobol/.libs/ -ggdb -O0 -S -o test.s test.cbl +#INSCOBOL=$(grep instructions perf.stat | sed -E 's/^[ ]+([^ ]+).*$/\1/g') echo $LLINES $INSC $INSCOBOL } diff --git a/gcc/cobol/nist/Makefile.regression b/gcc/cobol/nist/Makefile.regression deleted file mode 100644 index a798cb926d9f61ba4297938c647576b4d200f466..0000000000000000000000000000000000000000 --- a/gcc/cobol/nist/Makefile.regression +++ /dev/null @@ -1,76 +0,0 @@ -GROUP=.* - -REGRESSION1=$(shell grep -v "^\#.*" catalog | grep -v EXEC85 | grep "OK" | grep -v "IC" | grep "$(GROUP)" | sed 's|^\(..\)\([^ \t]*\).*$$|\1/\1\2|g') - -REGRESSION=$(REGRESSION1) - -DONES=$(addsuffix .rdone,$(REGRESSION1)) - -# $(info ) -# $(info REFRESSION $(REGRESSION)) -# $(info ) -# $(info DONES: $(DONES)) -# $(info ) - -.PHONY: all $(REGRESSION) $(DONES) -all: regress - -regress: $(DONES) -$(DONES): - UPSI=01 $(MAKE) -f Makefile testv SOURCE_FILE=$(basename $@) REPORTT=$(notdir $(basename $@)).report EXEC_FILE=$(notdir $(basename $@)).exe - touch $@ - -IX/IX102A.cbl.rdone: IX/IX101A.cbl.rdone -IX/IX103A.cbl.rdone: IX/IX102A.cbl.rdone - -IX/IX110A.cbl.rdone: IX/IX109A.cbl.rdone -IX/IX111A.cbl.rdone: IX/IX110A.cbl.rdone - -IX/IX114A.cbl.rdone: IX/IX113A.cbl.rdone -IX/IX115A.cbl.rdone: IX/IX114A.cbl.rdone -IX/IX116A.cbl.rdone: IX/IX115A.cbl.rdone -IX/IX117A.cbl.rdone: IX/IX116A.cbl.rdone -IX/IX118A.cbl.rdone: IX/IX117A.cbl.rdone -IX/IX119A.cbl.rdone: IX/IX118A.cbl.rdone -IX/IX120A.cbl.rdone: IX/IX119A.cbl.rdone - -IX/IX202A.cbl.rdone: IX/IX201A.cbl.rdone -IX/IX203A.cbl.rdone: IX/IX202A.cbl.rdone - -RL/RL102A.cbl.rdone: RL/RL101A.cbl.rdone -RL/RL103A.cbl.rdone: RL/RL102A.cbl.rdone - -RL/RL109A.cbl.rdone: RL/RL108A.cbl.rdone -RL/RL110A.cbl.rdone: RL/RL109A.cbl.rdone - -RL/RL202A.cbl.rdone: RL/RL201A.cbl.rdone -RL/RL203A.cbl.rdone: RL/RL202A.cbl.rdone - -RL/RL207A.cbl.rdone: RL/RL206A.cbl.rdone -RL/RL208A.cbl.rdone: RL/RL207A.cbl.rdone - -RL/RL213A.cbl.rdone: RL/RL212A.cbl.rdone - -SM/SM102A.cbl.rdone: SM/SM101A.cbl.rdone -SM/SM104A.cbl.rdone: SM/SM103A.cbl.rdone - -SM/SM202A.cbl.rdone: SM/SM201A.cbl.rdone -SM/SM204A.cbl.rdone: SM/SM203A.cbl.rdone - -SQ/SQ203A.cbl.rdone: SQ/SQ202A.cbl.rdone - -ST/ST102A.cbl.rdone: ST/ST101A.cbl.rdone -ST/ST103A.cbl.rdone: ST/ST102A.cbl.rdone -ST/ST105A.cbl.rdone: ST/ST104A.cbl.rdone -ST/ST107A.cbl.rdone: ST/ST106A.cbl.rdone -ST/ST110A.cbl.rdone: ST/ST109A.cbl.rdone -ST/ST111A.cbl.rdone: ST/ST110A.cbl.rdone -ST/ST113M.cbl.rdone: ST/ST112M.cbl.rdone -ST/ST114M.cbl.rdone: ST/ST113M.cbl.rdone -ST/ST116A.cbl.rdone: ST/ST115A.cbl.rdone -ST/ST117A.cbl.rdone: ST/ST116A.cbl.rdone -ST/ST120A.cbl.rdone: ST/ST119A.cbl.rdone -ST/ST121A.cbl.rdone: ST/ST120A.cbl.rdone -ST/ST123A.cbl.rdone: ST/ST122A.cbl.rdone -ST/ST124A.cbl.rdone: ST/ST123A.cbl.rdone -ST/ST126A.cbl.rdone: ST/ST125A.cbl.rdone