module CGTDEFS // This module defines enumeration types used by the code generator to // describe the data structures used to drive code generation. // There are two major data bases used: the patterns that are matched against // C-code generated by walking the program tree, and the actions to perform // when a match is found. // The patterns are created by TABLES, stored in CGTABLES, and interpreted by // CGMAIN. Conceptually the patterns are a simple list of pattern lines, // with each pattern line composed of pattern elements that match exactly one // C-code item. In actuallity, the patterns are stored as a sort of tree // that eliminates the redundancy from one pattern line to the next; this // reduces the storage cost and reduces the time to search the set of // patterns for a match. The pattern elements (for matching individual // C-code items) are described by the structure Pattern, while the tree is // composed of Pattern_tree_node's that contain pattern elements. // The actions are created by TABLES, stored in CGTABLES, and interpreted by // CGACTION. The actions are stored in an array of 8 bit bytes using an // opcode/operand representation. When a pattern line is matched, it // contains the offset in the action table at which to start "execution". // Execution continues until a stop opcode is encountered. // Modifications: --- version 7.2 // 10/13/84 Tim Sherman Changed sys_symbols to be unique to // six characters. // 10/31/84 Fred Holloway Increased Pattern_tree_max // 06-Dec-1984 Fred Holloway Increased Action_max for PDP // Pattern_tree_max for VAX // 07-Dec-1984 Tony De Groot Increased Action_max for PDP // 10-Dec-1984 F. Holloway Added P$AIFLEX for PDP runtime support // 12-Dec-1984 Tony De Groot Added ccode_eq_ccode, ccode_ne_ccode export action_type, Pattern_tag, Pattern, Pattern_tree_node, Pattern_tree_max, Pattern_tree_index, Action_max, Action_index, Action_datum, Pattern_line_max, Pattern_line_index, local_index, table_ccode_tag, sys_names, sys_symbols, sys_strings import address_mode, code_symbol from OPERND import C_code_tag from CCODE declare Pattern_tag is [ stack, // &n element, // specific C-code tag % if VAX or PDP11 iuop, // unary operator implemented by 2-operand % endif // instruction on VAX or 1-operand // instruction on PDP11 % if VAX ibop2, // binary operator implemented by VAX // 2-operand instruction ibop3, // binary operator implemented by VAX // 3-operand instruction % orif PDP11 ibop, ibopr, ifrop, % endif % if VAX or PDP11 revop, // reversible operator irop, // relational implemented by VAX CMPx % orif PDP10 revop, // reversible operator op_x_op, // ccode with 10 opcode op_y_op, // ccode with 10 opcode into reg op_m_op, // ccode with 10 opcode into memory % endif operand_mode, // operand with specific address_mode % if PDP11 or PDP10 any_literal, // literal operand % endif nonnegative_literal, negative_literal, % if PDP10 immediate_literal, // 0 <= N < 2**18 power_of_2_literal, // 1, 2, 4, ..., 2**35 % endif specific_literal, ptrange, // range of C-code items class, // operator class temporary ] Pattern_line_max = 9 Pattern_line_index is 0..Pattern_line_max Pattern is structure Ptag: Pattern_tag invert: boolean initially false // invert sense of test // if actual is an operand // thus NT matches any operand // that is not a temporary, but // not an operator select Ptag from case stack: n: Pattern_line_index case element: Ctag: C_code_tag case operand_mode: mode: address_mode case specific_literal: literal_value: integer case ptrange: lo, hi: C_code_tag case class: class: integer // index into table of classes endselect endstructure % if VAX Pattern_tree_max = 300 // was 260 -- version 7.2 -- FH Action_max = 3200 // maximum number of actions this // program will handle % orif PDP11 Pattern_tree_max = 400 Action_max = 5000 // was 4000 -- version 7.2 -- FH % orif PDP10 Pattern_tree_max = 400 Action_max = 3000 % endif Pattern_tree_index is 0..Pattern_tree_max Action_index is 1..Action_max // index into Action_table Action_datum is 8 bit integer // type of Action_table elements Pattern_tree_node is structure down: Pattern_tree_index right: 0..Action_max // 0 ==> next moves right // non-0 ==> action pattern: Pattern endstructure local_index is 1..5 // for labels and temporary names // within an action // Actions that are to be obeyed after a template match. action_type is [ end_action, // end of CG stop_action, // done withthis template newtemp_action, // get a new temp cell newlabel_action, // get a new label placelabel_action, // place a label push_action, // push onto the CG stack release_action, // release a register simple_instruction_action, // instruction with specific opcode type_instruction_action, // instruction with opcode computed // from type (byte, word, float, etc.) operator_instruction_action, // instruction with opcode computed // from C-code tag assign_action, // assign an absolute register moff_action, // make C_operand base offsettable // (for HI() and LO()). // followed by stack offset do_access_action, // handle C_access do_indirect_action, // handle C_indirect do_machine_action, // handle C_machine do_select_action, // handle C_selectx do_semicolon_action, // handle C_semicolon do_stack_adjust_action, // handle C_stack_adjust do_subscript_action, // handle C_subscript do_entry_action, // handle C_entry % if VAX Do_cvt_v_action, vlass_action, vrass_action, % endif % if PDP11 Do_fortran_call_action, Do_fortran_entry_action, Do_ref_action, Do_push_m_action, Do_cvt_v_action, vlass_action, vrass_action, % endif % if PDP10 do_adjust_frame, // adjust CG's stack pointer do_assign_pack, // assign into packed field do_ass_v_action, do_cvt_v_action, % endif % if VAX do_scpent, do_scplve, % endif not_implemented_action ] // Ccode specifier opcodes -- used in action processing to create Ccode. table_ccode_tag is [ stack_ccode, // &n simple_ccode, // operand is C-code with specific tag ccode_ccode, // followed by table number, // C-code specifier. Operates // on the C-code specifier. type_ccode, // take size of stack item // following 2 are local to a // single template local_label_ccode, // a local label local_temporary_ccode, // a local temporary register_ccode, // Rn - followed by register number operand_ccode, // VAX operand constructor - followed // by C-code specifier for register // and the address mode sys_name_ccode, // assembler symbol // functions that appear in action part ccode_label_ccode, // the "label" function ccode_colon_ccode, // place a label ccode_len_ccode, // return length of operand in bits ccode_blen_ccode, // return length of operand in bytes ccode_wlen_ccode, // return length of operand in words % if PDP11 or PDP10 ccode_a_ccode, // address operator % endif ccode_pos_ccode, // position ccode_args_ccode, // number of arguments of CALLS ccode_ref_ccode, // make ccode operand indirect ccode_not_ccode, // 1's complement of literal ccode_neg_ccode, // 2's complement of literal ccode_size_ccode, // Setup size of 1st arg to be second % if PDP10 ccode_log2_ccode, // shifts for mult by power of 2 ccode_addr_of_end_ccode, // address of last word of multiple % endif ccode_gt_ccode, // the > operator constructor ccode_lt_ccode, // the < operator constructor ccode_ge_ccode, // the >= operator constructor ccode_le_ccode, // the <= operator constructor //--- version 7.2 ----------------------------------------------- // add the following: ccode_eq_ccode, // the = operator constructor ccode_ne_ccode, // the <> operator constructor //--------------------------------------------------------------- ccode_lo_ccode, // LO() ccode_hi_ccode, // HI() literal_ccode, // #n ccode_off_ccode, // ?? ccode_nlref_ccode ] sys_names is [ % if PDP11 or PDP10 prx_init, // initialize PRAXIS program prx_savr1, // save registers % if PDP11 prx_savrf, // save normal and floating registers prx_ient, // interrupt entry prx_vtrp, // virtual to real pointer prx_mull, // 32 bit multiply prx_sdivl, // 32 bit signed divide prx_setlck, // set a lock prx_clrlck, // clear a lock % endif % endif prx_udivl, // 32 bit unsigned divide prx_alloc, // free storage allocation routine prx_ainit, // allocate and init prx_free, // deallocation routine prx_flist, // stack adjust for fail prx_assert, // assertion handler prx_raise, // unwind stack for raise prx_range, // raise range exception prx_nilptr, // nil-pointer exception prx_oflow, // overflow exception prx_flex, // allocate flexible array //------------------------version 7.2 ------ FH ------------------------ % if PDP11 prx_flex_init, // allocate and init a flexible array % endif prx_fround, // round a real to integer prx_dround, // round a long_real to integer prx_ffloor, // floor a real to integer prx_dfloor, // floor a long_real to integer prx_fceiling, // ceiling a real to integer prx_dceiling // ceiling a long_real to integer % if PDP10 // the following are functions in the Fortran library , fort_dfl_0, // convert integer to double fort_idf_0, // convert double to integer fort_sng_0, // convert double to float prx_jbhrl, // last code location used, for stack // other type conversion routines prx_cvt_sld, // convert signed long to double prx_cvt_dsl, // ... prx_cvt_slf, prx_cvt_fsl, prx_sav1r, prx_sav2r, prx_sav3r, prx_sav4r, prx_sav5r % endif ] sys_symbols: static array[sys_names] of code_symbol char_initially_space is char initially $ snx is array[sys_names] of packed array[1..12] of char_initially_space sys_strings = snx ( //----------------------V7.2---FH----------------------- %if VAX [prx_udivl]: "prx$udivl ", [prx_alloc]: "prx$alloc ", [prx_ainit]: "prx$ainit ", [prx_free]: "prx$free ", [prx_flist]: "prx$flist ", [prx_assert]: "prx$assert ", [prx_raise]: "prx$raise ", [prx_range]: "prx$range ", [prx_nilptr]: "prx$nilptr ", [prx_oflow]: "prx$oflow ", [prx_flex]: "prx$aflex ", [prx_fround]: "prx$fround ", [prx_dround]: "prx$dround ", [prx_ffloor]: "prx$ffloor ", [prx_dfloor]: "prx$dfloor ", [prx_fceiling]: "prx$fceil ", [prx_dceiling]: "prx$dceil ") %orif PDP10 [prx_init]: "prx$init ", [prx_savr1]: ".savr1 ", [prx_udivl]: "prx$udivl ", [prx_alloc]: "prx$alloc ", [prx_ainit]: "prx$ainit ", [prx_free]: "prx$free ", [prx_flist]: "prx$flist ", [prx_assert]: "prx$assert ", [prx_raise]: "prx$raise ", [prx_range]: "prx$rnge ", [prx_nilptr]: "prx$nilptr ", [prx_oflow]: "prx$oflow ", [prx_flex]: "prx$aflex ", [prx_fround]: "prx$fround ", [prx_dround]: "prx$dround ", [prx_ffloor]: "prx$ffloor ", [prx_dfloor]: "prx$dfloor ", [prx_fceiling]: "prx$fceil ", [prx_dceiling]: "prx$dceil ", [fort_dfl_0]: "dfl.0 ", [fort_idf_0]: "idf.0 ", [fort_sng_0]: "sng.0 ", [prx_cvt_sld]: "cv$sld ", [prx_cvt_dsl]: "cv$dsl ", [prx_cvt_slf]: "cv$slf ", [prx_cvt_fsl]: "cv$fsl ", [prx_jbhrl]: ".jbhrl ", [prx_sav1r]: ".sav1r ", [prx_sav2r]: ".sav2r ", [prx_sav3r]: ".sav3r ", [prx_sav4r]: ".sav4r ", [prx_sav5r]: ".sav5r ") %orif PDP11 [prx_init]: "p$init ", [prx_savr1]: "p$rsav ", [prx_savrf]: "p$fsav ", [prx_ient]: "p$isav ", [prx_vtrp]: "$vtrp ", [prx_mull]: "p$lmul ", [prx_sdivl]: "p$sldiv ", [prx_udivl]: "p$uldiv ", [prx_setlck]: "p$lckset ", [prx_clrlck]: "p$lckclr ", [prx_alloc]: "p$alloc ", [prx_ainit]: "p$ainit ", [prx_flex]: "p$aflex ", // ----------version 7.2 -------------------FH [prx_flex_init]:"p$aiflex ", //------------------------------------------ [prx_free]: "p$free ", [prx_flist]: "p$flist ", [prx_assert]: "p$assert ", [prx_raise]: "p$raise ", [prx_range]: "p$range ", [prx_nilptr]: "p$nilptr ", [prx_oflow]: "p$oflow ", [prx_fround]: "p$fround ", [prx_dround]: "p$dround ", [prx_ffloor]: "p$ffloor ", [prx_dfloor]: "p$dfloor ", [prx_fceiling]: "p$fceiling ", [prx_dceiling]: "p$dceiling ") %endif %if false % if PDP11 or PDP10 [prx_init]: "prx$init ", [prx_savr1]: ".savr1 ", % if PDP11 [prx_savrf]: "prx$savrf ", [prx_ient]: ".ient ", [prx_vtrp]: "$vtrp ", [prx_mull]: "prx$mull ", [prx_sdivl]: "prx$sdivl ", [prx_setlck]: "prx$setlck ", [prx_clrlck]: "prx$clrlck ", % endif % endif [prx_udivl]: "prx$udivl ", [prx_alloc]: "prx$alloc ", [prx_ainit]: "prx$ainit ", [prx_free]: "prx$free ", [prx_flist]: "prx$flist ", [prx_assert]: "prx$assert ", [prx_raise]: "prx$raise ", % if PDP10 or PDP11 [prx_range]: "prx$rnge ", % otherwise [prx_range]: "prx$range ", % endif [prx_nilptr]: "prx$nilptr ", [prx_oflow]: "prx$oflow ", [prx_flex]: "prx$aflex ", [prx_fround]: "prx$fround ", [prx_dround]: "prx$dround ", [prx_ffloor]: "prx$ffloor ", [prx_dfloor]: "prx$dfloor ", [prx_fceiling]: "prx$fceil ", [prx_dceiling]: "prx$dceil " % if PDP10 , [fort_dfl_0]: "dfl.0 ", [fort_idf_0]: "idf.0 ", [fort_sng_0]: "sng.0 ", [prx_cvt_sld]: "cv$sld ", [prx_cvt_dsl]: "cv$dsl ", [prx_cvt_slf]: "cv$slf ", [prx_cvt_fsl]: "cv$fsl ", [prx_jbhrl]: ".jbhrl ", [prx_sav1r]: ".sav1r ", [prx_sav2r]: ".sav2r ", [prx_sav3r]: ".sav3r ", [prx_sav4r]: ".sav4r ", [prx_sav5r]: ".sav5r " % endif ) %endif //----------------------------------------------------------- enddeclare endmodule