1 /* ***********************************************************
 2    *                                                         *
 3    * Copyright, (C) Honeywell Information Systems Inc., 1982 *
 4    *                                                         *
 5    * Copyright (c) 1972 by Massachusetts Institute of        *
 6    * Technology and Honeywell Information Systems, Inc.      *
 7    *                                                         *
 8    *********************************************************** */
 9 
10 
11 /* This procedure is called by various code generator modules to obtain
12    a reference node for temporary use.  A list of previously allocated
13    nodes is maintained and each call returns the next node on the list.
14    If the end of the list is reached, a new node is allocated.
15 
16    The program is initialized by the statement
17           cg_stat$first_ref, cg_stat$next_ref = null;
18 
19    The list of reference nodes will be re-used starting at the begining,
20    if the statement
21           cg_stat$next_ref = cg_stat$first_ref;
22    is executed.
23 
24    Initial Version:  3 Februrary 1971 by BLW
25           Modified: 30 March 1980 by RAB for reference.(padded aligned)_for_store_ref.
26                     See prepare_operand for details.        */
27 
28 get_reference: proc returns(ptr);
29 
30 dcl       (p,q) ptr,
31           n fixed bin,
32           (cg_stat$first_ref,cg_stat$next_ref,cg_stat$m_s_p) ptr ext,
33           create_list entry(fixed bin) returns(ptr),
34           create_reference entry(ptr) returns(ptr),
35           (state_man$flush_ref,state_man$flush_address) entry(ptr);
36 
37 dcl       (null,string) builtin;
38 
39 %include list;
40 %include cg_reference;
41 %include boundary;
42 
43           if cg_stat$next_ref = null
44           then do;
45                q = create_list(2);
46                p, q -> element(2) = create_reference(null);
47                q -> element(1) = cg_stat$first_ref;
48                cg_stat$first_ref = q;
49                goto l1;
50                end;
51 
52           q = cg_stat$next_ref;
53           p = q -> element(2);
54           cg_stat$next_ref = q -> element(1);
55 
56           p -> reference.offset,
57           p -> reference.symbol,
58           p -> reference.qualifier,
59           p -> reference.length = null;
60 
61           p -> reference.c_offset,
62           p -> reference.c_length,
63           p -> reference.data_type = 0;
64 
65           p -> reference.value_in.storage = "0"b;
66           p -> reference.store_ins = "0"b;
67 
68           if cg_stat$m_s_p ^= null
69           then do;
70                if string(p -> reference.address_in.b) then call state_man$flush_address(p);
71                if string(p -> reference.value_in) then call state_man$flush_ref(p);
72                end;
73 
74 l1:       string(p -> reference.bits) = "11"b;    /* padded, aligned */
75           string(p -> reference.relocation) = "0"b;
76           string(p -> reference.more_bits) = "0"b;
77 
78           p -> reference.padded_for_store_ref,
79           p -> reference.aligned_for_store_ref = "1"b;
80 
81           p -> reference.c_f_offset = 0;
82 
83           p -> reference.units = word_;
84 
85           string(p -> reference.address) = "0000000000000000000000000001"b;     /* no_address */
86           string(p -> reference.info) = "0"b;
87           p -> reference.array_ref, p -> reference.varying_ref, p -> reference.shared = "0"b;
88 
89           p -> reference.ref_count = 1;
90 
91           return(p);
92 
93           end;