/* BEGIN fort_opt_utilities.incl.pl1 */ /* Created: December 18, 1979 by Richard A. Barnes for register optimizer. */ get_opt_space: proc(nwords) returns(ptr); dcl nwords fixed bin(18); /* size of allocation */ dcl p ptr; /* allocates all space for fort_optimizer */ retry: p = addr(opt(next_free_opt)); next_free_opt = next_free_opt + nwords; if next_free_opt < opt_max_len then return(p); else do; opt_base = get_next_temp_segment(shared_globals.opt_base,next_free_opt); go to retry; end; end /* get_opt_space */; create_chain: proc() returns(ptr); dcl p ptr; /* allocates chain nodes */ if free(size(chain)) = null then return(get_opt_space(size(chain))); else do; p = free(size(chain)); free(size(chain)) = free(size(chain)) -> chain.next; return(p); end; end /* create_chain */; get_quad_space: proc(amt) returns(fixed bin(18)); dcl amt fixed bin(18); /* amount to allocate */ dcl place fixed bin(18); place = next_free_quad; next_free_quad = next_free_quad + amt; if next_free_quad >= quad_max_len then do; call print_message(414,"The quadruple region",ltrim(char(quad_max_len))); return(0); end; return(place); end /* get_quad_space */; chain_input: proc(p,o,i); /* adds o to p's input list */ dcl p ptr, /* ptr to temporary or array_ref that is input */ o ptr, /* ptr to operator that p is input to */ i fixed bin(18); /* which operand */ dcl qoff fixed bin(18); dcl (q,last) ptr; q = create_input_to(); q -> input_to.next = null; q -> input_to.operator = o; q -> input_to.which = i; qoff = fixed(rel(q),18); if p -> temporary.end_input_to = 0 then p -> temporary.start_input_to = qoff; else do; last = addr(polish(p -> temporary.end_input_to)); last -> input_to.next = q; end; p -> temporary.end_input_to = qoff; end /* chain_input */; create_input_to: proc() returns(ptr); dcl q ptr; if freei = null then q = get_polish_space(size(input_to)); else do; q = freei; freei = freei -> input_to.next; end; return(q); end /* create_input_to */; get_polish_space: proc(nwords) returns(ptr); dcl nwords fixed bin(18); /* size of allocation */ dcl p ptr; /* allocates polish space for input_to nodes */ p = addr(polish(next_free_polish)); next_free_polish = next_free_polish + nwords; if next_free_polish < polish_max_len then return(p); else do; call print_message(414,"The polish region",ltrim(char(polish_max_len))); return(null); end; end /* get_polish_space */; /* derives insert_* fields in back target */ derive_insert_for_bt: proc(bt); dcl bt ptr; /* -> back target */ dcl (bt_statement, next_statement) fixed bin(18); dcl (o, btst) ptr; bt_statement = bt -> flow_unit.last_statement; btst = addr(quad(bt_statement)); o = addr(quad(btst -> opt_statement.first_operator)); if o -> operator.op_code = jump_op then do; bt -> flow_unit.insert_statement = fixed(btst -> opt_statement.back, 18); bt -> flow_unit.insert_operator = btst -> opt_statement.prev_operator; end; else do; bt -> flow_unit.insert_statement = bt_statement; next_statement = fixed(btst -> opt_statement.next, 18); bt -> flow_unit.insert_operator = addr(quad(next_statement)) -> opt_statement.prev_operator; end; end /* derive_insert_for_bt */; /* unthreads operator nodes. The operator to be unthreaded must not be the first or last operator in a chain. */ unthread: proc(o); dcl (o,nextp,backp) ptr; dcl nullx fixed bin(18) int static options(constant) init(262142); if o -> operator.next = nullx /* if already unthreaded, don't bother. */ then return; nextp = addr(quad(o -> operator.next)); backp = addr(quad(o -> operator.back)); nextp -> operator.back = o -> operator.back; backp -> operator.next = o -> operator.next; /* Make sure nobody uses the threading words again. An invalid use will cause a fault. */ o -> operator.next, o -> operator.back = nullx; end /* unthread */ ; put_in_loop_end: proc(pt,lp); dcl (p, pt) ptr, /* -> temp to be put in loop end chain */ lp ptr; /* -> loop in whose chain temp is to be inserted */ dcl fu_to_put ptr; /* -> flow_unit in whose chain temp is to be inserted */ dcl c ptr; p = pt; fu_to_put = lp -> loop.last_unit; /* add to loop end chain */ c = create_chain(); c -> lchain.next = fu_to_put -> flow_unit.loop_end_chain; c -> lchain.value = fixed(rel(p),18); fu_to_put -> flow_unit.loop_end_chain = c; fu_to_put -> flow_unit.n_in_loop_end = fu_to_put -> flow_unit.n_in_loop_end + 1; /* increment the reference count */ p -> temporary.ref_count = p -> temporary.ref_count + 1; /* add an input item for this operand */ call chain_input(p,c,-1); p -> temporary.loop_end_fu_pos = fu_to_put -> flow_unit.position; end /* put_in_loop_end */; connect_expression: proc(opnd,op,p_which); dcl opnd fixed bin(18), /* operand to be connectged to op */ op fixed bin(18), /* operator to which opnd becomes an operand */ (p_which,which) fixed bin(18); /* operand number that opnd becomes */ dcl (o, p) ptr; which = p_which; o = addr(quad(op)); o -> operator.operand(which) = opnd; p = addr(rands(opnd)); if p -> node.node_type = array_ref_node | p -> node.node_type = temporary_node then do; p -> temporary.ref_count = p -> temporary.ref_count + 1; p -> temporary.ref_count_copy = p -> temporary.ref_count_copy + 1; call chain_input(p,o,which); end; end /* connect_expression */; disconnect_temporary: proc(pt,p_o); dcl (p,pt) ptr, /* ptr to temp being disconnected */ (o,p_o) ptr; /* ptr to operator from which p is disconnected */ dcl (inp,last) ptr; dcl found bit(1) aligned; p = pt; o = p_o; last = null; found = "0"b; inp = addr(polish(p -> temporary.start_input_to)); do while(^ found & inp ^= null); if inp -> input_to.operator = o then found = "1"b; else do; last = inp; inp = inp -> input_to.next; end; end; if ^ found then do; call print_message(386); return; end; if last ^= null then do; last -> input_to.next = inp -> input_to.next; if inp -> input_to.next = null then p -> temporary.end_input_to = fixed(rel(last),18); end; else if inp -> input_to.next = null then p -> temporary.start_input_to, p -> temporary.end_input_to = 0; else p -> temporary.start_input_to = fixed(rel(inp -> input_to.next),18); p -> temporary.ref_count = p -> temporary.ref_count - 1; p -> temporary.ref_count_copy = p -> temporary.ref_count_copy - 1; end /* disconnect_temporary */; in_namelist: proc(o,variable) returns(bit(1) aligned); dcl o ptr, /* -> to {read|write}_namelist operator */ variable fixed bin(18); /* variable being searched for */ dcl (var,i,ipol) fixed bin(18); var = variable; ipol = addr(rands(o -> operator.operand(1))) -> symbol.initial; do i = 1 to polish(ipol); if polish(ipol+i) = variable then return("1"b); end; return("0"b); end /* in_namelist */; /* END fort_opt_utilities.incl.pl1 */ */ ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group Bull including Bull HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell Bull Inc., Groupe Bull and Bull HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, Bull or Bull HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by Bull HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved */