-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.c
11753 lines (10753 loc) · 456 KB
/
gen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
FILE NAME: gen.c
Copyright (C) 1997-2016 Vladimir Makarov.
Written by Vladimir Makarov <vmakarov@gcc.gnu.org>
This file is part of the tool SPRUT.
This is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
TITLE: Standard procedural interface (SPI) generator
of SPRUT (internal representation description translator)
DESCRIPTION: This file generates SPI.
SPECIAL CONSIDERATION:
The generator is to be called after SPRUT semantic analyzer only
if any error was not fixed.
Defining macro `NDEBUG' (e.g. by option `-D' in C compiler
command line) during the file compilation disables to fix
some internal errors of the generator.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* #ifdef HAVE_CONFIG_H */
#include <ctype.h>
#include <stdio.h>
#include "allocate.h"
#include "vlobject.h"
#include "position.h"
#include "errors.h"
#include "ird.h"
#include "common.h"
#include "tab.h"
#include "gen.h"
#include <limits.h>
#include <assert.h>
/* This page contains macros common for all generator. */
/* The following macro value is string which represents type of a
vlaue of graph pass number. */
#define GRAPH_PASS_NUMBER_TYPE_NAME "int"
/* The following macro value is string used in SPI instead of name `%root'. */
#define ROOT_NAME "_root"
/* The following macro value is string used in SPI for error nodes and their
type. */
#define ERROR_NAME "_error"
/* The rest macros represent names of members of the following structure
which implements double linked fields
typedef struct _IR_double_link *IR_double_link_t;
struct _IR_double_link
{
IR_node_t field_itself;
IR_node_t link_owner;
void (* set_function) (IR_node_t, IR_node_t);
IR_double_link_t previous_link;
IR_double_link_t next_link;
}
or
typedef class _IR_double_link *IR_double_link_t;
class _IR_double_link
{
IR_node_t field_itself;
IR_node_t link_owner;
void (IR_node::*set_function) (IR_node_t);
class _IR_double_link *previous_link;
class _IR_double_link *next_link;
public:
IR_double_link_t IR__next_double_link (void);
IR_double_link_t IR__previous_double_link (void);
IR_node_t IR__owner (void);
void IR__set_double_link (IR_node_t value, int disp, int flag);
}
*/
/* The following macro value is name of member representing field itself
for double linked field. The double linked field is represented
by structure. */
#define DOUBLE_LINK_FIELD_NAME "field_itself"
/* The following macro value is name of member representing pointer to
node in which the double linked field is placed. */
#define DOUBLE_LINK_OWNER_NAME "link_owner"
/* The following macro value is pointer to function for modification
of this double linked field value. */
#define DOUBLE_LINK_SET_FUNCTION_NAME "set_function"
/* The following macro value is name of member representing pointer to
previous double linked field which refers to the same node, i.e.
has the same value of member representing field itself. */
#define DOUBLE_LINK_PREVIOUS_NAME "previous_link"
/* The following macro value is name of member representing pointer to
next double linked field which refers to the same node, i.e.
has the same value of member representing field itself. */
#define DOUBLE_LINK_NEXT_NAME "next_link"
/* This page contains functions used by the generator for traversing
internal representations. */
/* The following variable contains path of node types which are being
processed during traversing node types (with the aid of all
traversing functions). */
static vlo_t traverse_node_type_path;
/* The following function initiates traversing internal
representation. */
static void
initiate_traversing_internal_representation (void)
{
VLO_CREATE (traverse_node_type_path, 0);
}
/* This function processes all node types of current (one-level)
description. Remember that one level description contains only
node type declarations which are in the table of types and such
node type declarations contains all fields of the description (see
file `anal.c'). */
static void
traverse_node_types (void (*applied_function) (IR_node_t node_type))
{
IR_node_t node_type;
if (IR_last_type (current_description_part) == NULL)
return;
for (node_type = IR_next_type (IR_last_type (current_description_part));;
node_type = IR_next_type (node_type))
{
if (IR_NODE_MODE (node_type) == IR_NM_node_type)
{
VLO_ADD_MEMORY (traverse_node_type_path,
&node_type, sizeof (node_type));
(*applied_function) (node_type);
VLO_SHORTEN (traverse_node_type_path, sizeof (node_type));
}
else
assert (IR_NODE_MODE (node_type) == IR_NM_predefined_type);
if (node_type == IR_last_type (current_description_part))
break;
}
}
/* This function processes all fields of current (one-level)
description. Remember that one level description contains only
node type declarations which are in the table of types and such
node type declarations contains all fields of the description (see
file `anal.c'). */
static void
traverse_all_fields (void (*applied_function) (IR_node_t field))
{
IR_node_t node_type;
IR_node_t current_field;
if (IR_last_type (current_description_part) == NULL)
return;
for (node_type = IR_next_type (IR_last_type (current_description_part));;
node_type = IR_next_type (node_type))
{
if (IR_NODE_MODE (node_type) == IR_NM_node_type)
{
VLO_ADD_MEMORY (traverse_node_type_path,
&node_type, sizeof (node_type));
if (IR_last_field (node_type) != NULL)
for (current_field = IR_next_field (IR_last_field (node_type));;
current_field = IR_next_field (current_field))
{
if (IR_NODE_MODE (current_field) == IR_NM_field)
(*applied_function) (current_field);
else
assert (IR_NODE_MODE (current_field) == IR_NM_action
|| IR_NODE_MODE (current_field) == IR_NM_constraint);
if (current_field == IR_last_field (node_type))
break;
}
VLO_SHORTEN (traverse_node_type_path, sizeof (node_type));
}
else
assert (IR_NODE_MODE (node_type) == IR_NM_predefined_type);
if (node_type == IR_last_type (current_description_part))
break;
}
}
/* This function processes all fields of given node type. The
function must be called (through several intermediate functions)
only from function `traverse_all_node_types'. */
static void
traverse_all_node_type_fields (IR_node_t node_type,
void (*applied_function) (IR_node_t field))
{
IR_node_t super_type;
IR_node_t current_field;
IR_node_t curr_supertype_list_element;
for (curr_supertype_list_element
= IR_first_super_type_list_element (node_type);
curr_supertype_list_element != NULL;
curr_supertype_list_element
= IR_next_super_type_list_element (curr_supertype_list_element))
if (IR_immediate_super_type (curr_supertype_list_element) != NULL)
{
super_type = IR_immediate_super_type (curr_supertype_list_element);
VLO_ADD_MEMORY (traverse_node_type_path,
&super_type, sizeof (super_type));
traverse_all_node_type_fields (super_type, applied_function);
VLO_SHORTEN (traverse_node_type_path, sizeof (super_type));
}
if (IR_last_field (node_type) != NULL)
for (current_field = IR_next_field (IR_last_field (node_type));;
current_field = IR_next_field (current_field))
{
assert (IR_NODE_MODE (current_field) == IR_NM_field
|| IR_NODE_MODE (current_field) == IR_NM_action
|| IR_NODE_MODE (current_field) == IR_NM_constraint);
(*applied_function) (current_field);
if (current_field == IR_last_field (node_type))
break;
}
}
/* This function processes all fields of given node type in reverse
order (the last declared field is processed by the first). The
function must be called (through several intermediate functions)
only from function `traverse_all_node_types'. */
static void
reverse_traverse_all_node_type_fields
(IR_node_t node_type, void (*applied_function) (IR_node_t field))
{
IR_node_t super_type;
IR_node_t current_field;
IR_node_t *current_field_ref;
IR_node_t curr_supertype_list_element;
vlo_t fields_in_reverse_order;
assert (VLO_LENGTH (traverse_node_type_path) != 0);
/* Output node type field definitions */
if (IR_last_field (node_type) != NULL)
{
VLO_CREATE (fields_in_reverse_order, 40);
for (current_field = IR_next_field (IR_last_field (node_type));;
current_field = IR_next_field (current_field))
{
VLO_ADD_MEMORY (fields_in_reverse_order, ¤t_field,
sizeof (current_field));
if (current_field == IR_last_field (node_type))
break;
}
current_field_ref
= (IR_node_t *) ((char *) VLO_END (fields_in_reverse_order)
+ 1 - sizeof (current_field));
for (;;current_field_ref--)
{
assert (IR_NODE_MODE (*current_field_ref) == IR_NM_field
|| IR_NODE_MODE (*current_field_ref) == IR_NM_action
|| IR_NODE_MODE (*current_field_ref) == IR_NM_constraint);
(*applied_function) (*current_field_ref);
if (current_field_ref
== (IR_node_t *) VLO_BEGIN (fields_in_reverse_order))
break;
}
VLO_DELETE (fields_in_reverse_order);
}
for (curr_supertype_list_element
= IR_first_super_type_list_element (node_type);
curr_supertype_list_element != NULL;
curr_supertype_list_element
= IR_next_super_type_list_element (curr_supertype_list_element))
if (IR_immediate_super_type (curr_supertype_list_element) != NULL)
{
super_type = IR_immediate_super_type (curr_supertype_list_element);
VLO_ADD_MEMORY (traverse_node_type_path,
&super_type, sizeof (super_type));
reverse_traverse_all_node_type_fields (super_type, applied_function);
VLO_SHORTEN (traverse_node_type_path, sizeof (super_type));
}
}
/* The following function finishes traversing internal
representation. */
static void
finish_traversing_internal_representation (void)
{
VLO_DELETE (traverse_node_type_path);
}
/* This page contains function used for searching last field in super
types of given node type. */
/* This recursive function used for searching for the last (class or
non-class) field in super types of given node type. The function
returns The last (class or non-class) field in super types of given
node type. */
static IR_node_t
last_field_in_super_type (IR_node_t node_type, int class_field_flag)
{
IR_node_t current_field;
vlo_t super_types_in_reverse_order;
IR_node_t result;
IR_node_t curr_supertype_list_element;
IR_node_t *curr_supertype_list_element_ref;
VLO_CREATE (super_types_in_reverse_order, 40);
for (curr_supertype_list_element
= IR_first_super_type_list_element (node_type);
curr_supertype_list_element != NULL;
curr_supertype_list_element
= IR_next_super_type_list_element (curr_supertype_list_element))
VLO_ADD_MEMORY (super_types_in_reverse_order,
&curr_supertype_list_element,
sizeof (curr_supertype_list_element));
curr_supertype_list_element_ref
= (IR_node_t *) ((char *) VLO_END (super_types_in_reverse_order)
+ 1 - sizeof (curr_supertype_list_element));
result = NULL;
if (IR_first_super_type_list_element (node_type) != NULL)
for (;;curr_supertype_list_element_ref--)
{
node_type = IR_immediate_super_type (*curr_supertype_list_element_ref);
if (node_type != NULL)
{
if (IR_last_field (node_type) != NULL)
for (current_field = IR_next_field (IR_last_field (node_type));;
current_field = IR_next_field (current_field))
{
if (IR_NODE_MODE (current_field) == IR_NM_field)
{
if ((IR_declaration_part (current_field) != DP_CLASS)
== !class_field_flag)
result = current_field;
}
else
assert
(IR_NODE_MODE (current_field) == IR_NM_action
|| IR_NODE_MODE (current_field) == IR_NM_constraint);
if (current_field == IR_last_field (node_type))
break;
}
if (result == NULL)
result = last_field_in_super_type (node_type, class_field_flag);
else
break;
}
if (curr_supertype_list_element_ref
== (IR_node_t *) VLO_BEGIN (super_types_in_reverse_order))
break;
}
VLO_DELETE (super_types_in_reverse_order);
return result;
}
/* This page contains functions which are used to output SPI. These
function are used to fix output errors in time. All output of SPI is
made only through these function. */
/* The following variable value is number of current line in the
interface file. */
static int current_interface_file_line;
/* The following variable value is number of current line in the
implementation file. */
static int current_implementation_file_line;
/* This function outputs string onto interface or implementation file
and fixes output errors. */
static void
output_string (FILE *f, const char *string)
{
for (; *string != '\0'; string++)
{
if (fputc (*string, f) == EOF)
{
if (f == output_interface_file)
system_error (TRUE, no_position, "fatal_error -- %s: ",
output_interface_file_name);
else
{
assert (f == output_implementation_file);
system_error (TRUE, no_position, "fatal_error -- %s: ",
output_implementation_file_name);
}
}
if (*string == '\n')
{
if (f == output_interface_file)
current_interface_file_line++;
else if (f == output_implementation_file)
current_implementation_file_line++;
}
}
}
/* This function outputs character onto interface or implementation
file and fixes output errors. */
static void
output_char (int ch, FILE *f)
{
if (fputc (ch, f) == EOF)
{
if (f == output_interface_file)
system_error (TRUE, no_position, "fatal_error -- %s: ",
output_interface_file_name);
else
{
assert (f == output_implementation_file);
system_error (TRUE, no_position, "fatal_error -- %s: ",
output_implementation_file_name);
}
}
if (ch == '\n')
{
if (f == output_interface_file)
current_interface_file_line++;
else if (f == output_implementation_file)
current_implementation_file_line++;
}
}
/* This function outputs integer number according to format `%d' onto
interface or implementation file and fixes output errors. */
static void
output_decimal_number (FILE *f, int number)
{
if (fprintf (f, "%d", number) == EOF)
{
if (f == output_interface_file)
system_error (TRUE, no_position, "fatal_error -- %s: ",
output_interface_file_name);
else
{
assert (f == output_implementation_file);
system_error (TRUE, no_position, "fatal_error -- %s: ",
output_implementation_file_name);
}
}
}
static void
initiate_output (void)
{
current_interface_file_line = 1;
current_implementation_file_line = 1;
output_interface_file = fopen (output_interface_file_name, "w");
if (output_interface_file == NULL)
system_error (TRUE, no_position,
"fatal error -- %s: ", output_interface_file_name);
output_implementation_file = fopen (output_implementation_file_name, "w");
if (output_implementation_file == NULL)
system_error (TRUE, no_position,
"fatal error -- %s: ", output_implementation_file_name);
}
/* This page contains functions which are used to output parameterized names
of SPI objects. Usually the parameter is prefix given in SPRUT command
line (see commentaries for variable `prefix'). */
/* Base name of debug macro parameter used to separate debug code in
SPI. Full name of the macro parameter is `__IR_DEBUG__' (see function
`output_ifdef_parameter_name'). */
#define DEBUG_PARAMETER_NAME "DEBUG"
/* This function outputs name of debug macro parameter used to
separate debug code in SPI. The name is output as
`__<prefix><base_name>__' where prefix is value of variable
`prefix' and base name is value of the second parameter. */
static void
output_ifdef_parameter_name (FILE *f, const char *ifdef_parameter_name)
{
output_string (f, "__");
output_string (f, prefix);
output_string (f, ifdef_parameter_name);
output_string (f, "__");
}
/* This function outputs name of macro used to evaluation of member
offset in structure. The name is output as `_<prefix>offsetof'
where prefix is value of variable `prefix'. */
static void
output_offsetof_macro_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "offsetof");
}
/* This function outputs name of enumeration constant which represents
node type (mode) with given name. The name is output as
`<prefix>NM_<node_type_name>' where prefix is value of variable
`prefix', and `node_type_name' is value of the second parameter. */
static void
output_node_mode_type_value (FILE *f, const char *node_type_name)
{
output_string (f, prefix);
output_string (f, "NM_");
output_string (f, node_type_name);
}
/* This function outputs name of enumeration which represents all node
types (modes). The name is output as `<prefix>node_mode_enum'
where prefix is value of variable `prefix'. */
static void
output_node_mode_enumeration_name (FILE *f)
{
output_string (f, prefix);
output_string (f, "node_mode_enum");
}
/* This function outputs name of enumeration type which represents all
node types (modes). The name is output as `<prefix>node_mode_t'
where prefix is value of variable `prefix'. */
static void
output_node_mode_t_name (FILE *f)
{
output_string (f, prefix);
output_string (f, "node_mode_t");
}
/* This function outputs name of structure which describes double
linked fields. The name is output as `_<prefix>double_link' where
prefix is value of variable `prefix'. */
static void
output_double_link_structure_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "double_link");
}
/* This function outputs name of type (typedef) which describes double
linked fields. The name is output as `<prefix>double_link_t'
where prefix is value of variable `prefix'. */
static void
output_double_link_t_name (FILE *f)
{
output_string (f, prefix);
output_string (f, "double_link_t");
}
/* This function outputs name of macro or inline function whose value
of node mode. The name is output as `<prefix>NODE_MODE' or
`<prefix>node_mode' where prefix is value of variable `prefix'. */
static void
output_node_mode_name (FILE *f)
{
output_string (f, prefix);
if (!cpp_flag)
output_string (f, "NODE_MODE");
else
output_string (f, "node_mode");
}
/* This function outputs name of member of structure representing node
whose value is node mode. The name is output as
`_<prefix>node_mode' where prefix is value of variable
`prefix'. */
static void
output_node_mode_member_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "node_mode");
}
/* This function outputs name of macro or inline function whose value
is description declaration level of given node (type) mode. The
name is output as `<prefix>NODE_LEVEL' or `<prefix>node_level'
where prefix is value of variable `prefix'. */
static void
output_node_level_name (FILE *f)
{
output_string (f, prefix);
output_string (f, cpp_flag ? "node_level" : "NODE_LEVEL");
}
/* This function outputs name of array which is used for evaluation of
macro or function whose value is description declaration level of
given node type (mode). The name is output as
`_<prefix>node_level' where prefix is value of variable
`prefix'. */
static void
output_node_level_array_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "node_level");
}
/* This function outputs name of variable or parameter representing
guard function for traversing graph continuation. This function is
used by functions for traversing graphs. The name is output as
`_<prefix>traverse_guard_function_variable' or
`_<prefix>traverse_guard_function_parameter' where prefix is value
of variable `prefix'. */
static void
output_name_of_traverse_guard_function (FILE *f, int variable_flag)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "traverse_guard_function_");
if (variable_flag)
output_string (f, "variable");
else
output_string (f, "parameter");
}
/* This function outputs name of variable representing current pass
number. This variable is used by functions for traversing graphs.
The name is output as `_<prefix>current_graph_pass_number' where
prefix is value of variable `prefix'. */
static void
output_current_graph_pass_number_variable_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "current_graph_pass_number");
}
/* This function outputs name of member of structure representing
node. This member is used by functions for traversing graphs. The
name is output as `_<prefix>last_graph_pass_number' where prefix
is value of variable `prefix'. */
static void
output_last_graph_pass_number_member_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "last_graph_pass_number");
}
/* This function outputs name of member of structure representing
node. This member is used by functions for traversing graphs. The
name is output as `_<prefix>temporary' where prefix is value of
variable `prefix'. */
static void
output_temporary_member_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "temporary");
}
/* This function outputs name of member of structure representing
given super type. The name is output as `_<prefix>M_<given super
type name>' where prefix is value of variable `prefix'. */
static void
output_super_type_member_name (FILE *f, const char *super_type_name)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "M_");
output_string (f, super_type_name);
}
/* This function outputs name of member of structure representing
double node. This member value is pointer to first double linked
field which refers to given node. The name is output as
`_<prefix>first_link' where prefix is value of variable
`prefix'. */
static void
output_first_link_member_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "first_link");
}
/* This function outputs name of type (typedef) which represents any
node. The name is output as `<prefix>node_t' where prefix is
value of variable `prefix'. */
static void
output_node_t_name (FILE *f)
{
output_string (f, prefix);
output_string (f, "node_t");
}
/* This function outputs name of structure (class) which represents
root node. The name is output as `<prefix>node' where
prefix is value of variable `prefix'. */
static void
output_root_struct_class_name (FILE *f)
{
output_string (f, prefix);
output_string (f, "node");
}
/* This function outputs name of type (typedef) of structure which
represents node with given node type name. The name is output as
`_<prefix><node_type_name>' where prefix is value of variable
`prefix', and `node_type_name' is value of the second parameter. */
static void
output_node_type_name (FILE *f, const char *node_type_name)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, node_type_name);
}
/* This function outputs name of structure which represents node with
given node type name. The name is output as
`_<prefix>S_<node_type_name>' where prefix is value of variable
`prefix', and `node_type_name' is value of the second parameter. */
static void
output_node_structure_name (FILE *f, const char *node_type_name)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "S_");
output_string (f, node_type_name);
}
/* This function outputs name of structure which represents class
fields of node type with given name. The name is output as
`_<prefix>CF_<node_type_name>' where prefix is value of variable
`prefix', and `node_type_name' is value of the second parameter. */
static void
output_node_type_class_structure_name (FILE *f, const char *node_type_name)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "CF_");
output_string (f, node_type_name);
}
/* This function outputs name of array which contains pointers to all
structure representing class fields. The name is output as
`_<prefix>class_structure' where prefix is value of variable
`prefix'. */
static void
output_class_structure_array_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "class_structure_array");
}
/* This function outputs name of array which contains sizes of
structures describing all node types. The name is output as
`<prefix>node_size' where prefix is value of variable `prefix'. */
static void
output_node_size_array_name (FILE *f)
{
output_string (f, prefix);
output_string (f, "node_size");
}
/* This function outputs name of array which contains names of all
node types. The name is output as `<prefix>node_name' where
prefix is value of variable `prefix'. */
static void
output_node_name_array_name (FILE *f)
{
output_string (f, prefix);
output_string (f, "node_name");
}
/* This function outputs name of array which exists for each synonym
field (i.e. for each field name which is name of more one field)
and contains displacements of the field for each node mode. The
name is output as `_<prefix>D_<field_name>' where prefix is value
of variable `prefix', and `field_name' is name of the synonym
field. */
static void
output_different_displacement_field_displacement_array_name
(FILE *f, const char *field_name)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "D_");
output_string (f, field_name);
}
/* This function outputs name of array which exists for each node mode
and contains flags of that given node type is super type of
corresponding node mode. The name is output as
`_<prefix>SF_<node_type_name>' where prefix is value of variable
`prefix', and `node_type_name' is value of the second parameter. */
static void
output_subtype_flag_array_name (FILE *f, const char *node_type_name)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "SF_");
output_string (f, node_type_name);
}
/* This function outputs name of array which contains pointers to all
subtype flag arrays. This array is used to evaluation macro
`IR_IS_TYPE' or function `IR_is_type'. The name is output as
`_<prefix>is_type' where prefix is value of variable `prefix'. */
static void
output_is_type_array_name (FILE *f)
{
output_char ('_', f);
output_string (f, prefix);
output_string (f, "is_type");
}
/* This function outputs name of macro `IR_IS_TYPE' or inline function
`IR_is_type'. The name is output as `<prefix>IS_TYPE' or
`<prefix>is_type' where prefix is value of variable `prefix'. */
static void
output_is_type_name (FILE *f)
{
output_string (f, prefix);
output_string (f, cpp_flag ? "is_type" : "IS_TYPE");
}
/* This function outputs name of macro `IR_IS_OF_TYPE' or inline
function `IR_is_of_type'. The name is output as
`<prefix>IS_OF_TYPE' or `<prefix>is_of_type' where prefix is value
of variable `prefix'. */
static void
output_is_of_type_name (FILE *f)
{
output_string (f, prefix);
output_string (f, cpp_flag ? "is_of_type" : "IS_OF_TYPE");
}
/* This function outputs name of modification function for field with
given name. The name is output as `<prefix>set_<field_name>' or
`<prefix>F_set_<field_name>' where prefix is value of variable
`prefix', and `field_name' is name of thefield. */
static void
output_name_of_set_function (FILE *f, const char *field_name,
int function_prefix_flag)
{
output_string (f, prefix);
if (function_prefix_flag)
output_string (f, "F_");
output_string (f, "set_");
output_string (f, field_name);
}
/* This function outputs name of function for getting first double
linked field. The name is output as `<prefix>_first_double_link'
where prefix is value of variable `prefix'. */
static void
output_name_of_first_double_link_function (FILE *f)
{
output_string (f, prefix);
output_string (f, "_first_double_link");
}
/* This function outputs name of function for getting next double
linked field. The name is output as `<prefix>next_double_link'
or `<prefix>F__next_double_link' where prefix is value of variable
`prefix'. */
static void
output_name_of_next_double_link_function (FILE *f, int function_prefix_flag)
{
output_string (f, prefix);
if (function_prefix_flag)
output_string (f, "F__next_double_link");
else
output_string (f, "_next_double_link");
}
/* This function outputs name of function for getting previous double
linked field. The name is output as
`<prefix>_previous_double_link' or
`<prefix>F__previous_double_link' where prefix is value of variable
`prefix'. */
static void
output_name_of_previous_double_link_function (FILE *f,
int function_prefix_flag)
{
output_string (f, prefix);
if (function_prefix_flag)
output_string (f, "F__previous_double_link");
else
output_string (f, "_previous_double_link");
}
/* This function outputs name of function for getting node which
contains given double linked field. The name is output as
`<prefix>_owner' or `<prefix>F__owner' where prefix is value of
variable `prefix'. */
static void
output_name_of_owner_function (FILE *f, int function_prefix_flag)
{
output_string (f, prefix);
if (function_prefix_flag)
output_string (f, "F__owner");
else
output_string (f, "_owner");
}
/* This function outputs name of function for getting node which
contains given double linked field. The name is output as
`<prefix>_set_double_link' where prefix is value of variable
`prefix'. */
static void
output_name_of_set_double_link_function (FILE *f)
{
output_string (f, prefix);
output_string (f, "_set_double_link");
}
/* This function outputs name of function for setting up value of
double linked field. The name is output as
`_<prefix>set_double_field_value' where prefix is value of