On Sat, 2025-02-15 at 16:02 -0500, James K. Lowden wrote:
> From 5d53920602e234e4d99ae2d502e662ee3699978e 4 Oct 2024 12:01:22 -
> 0400
> From: "James K. Lowden" <jklow...@symas.com>
> Date: Sat 15 Feb 2025 12:50:53 PM EST
> Subject: [PATCH] 3 new 'cobol' FE files
> 
> gcc/cobol/ChangeLog
>       * gengen.cc: New file.
>       * genmath.cc: New file.
>       * genutil.cc: New file.


+// These are globally useful constants
+tree char_nodes[256];
+
+tree pvoid_type_node;
+tree integer_minusone_node;
+tree integer_two_node;
+tree integer_eight_node;
+tree size_t_zero_node;
+tree int128_zero_node;
+tree int128_five_node;
+tree int128_ten_node;
+tree char_ptr_type_node;
+tree uchar_ptr_type_node;
+tree wchar_ptr_type_node;
+tree long_double_ten_node;
+tree sizeof_size_t;
+tree sizeof_pointer;
+
+tree bool_true_node;
+tree bool_false_node;

As in the comments on earlier patches, should these be GTY marked?

+static
+std::unordered_map<std::string, tree> fndecl_from_name;

Same here

+tree
+gg_call_expr(tree return_type, const char *function_name, ...)
+  {
+  // Generalized caller. Params are terminated with NULL_TREE
+
+  // Use this routine to call function_name when you need the return value.
+  // Typically you will do something like
+
+  //      tree call_expr = gg_call_expr(...);
+  //      gg_assign( dest, call_expr );
+
+  // Note that everyt time call_expr is laid down, the function will be called,
+  // so you probably don't want to do things like
+  //      gg_assign( dest1, call_expr );
+  //      gg_assign( dest2, call_expr );
+
+  int nargs = 0;
+  static tree arg_types[ARG_LIMIT+1];
+  static tree args[ARG_LIMIT+1];

Even more insidiously, IIRC function-static vars can’t be GTY marked -
but perhaps these tree vars need to be.  Gahhhh...



+tree var_decl_exception_code;         // int         __gg__exception_code;
+tree var_decl_exception_handled;      // int         __gg__exception_handled;
+tree var_decl_exception_file_number;  // int         
__gg__exception_file_number;
+tree var_decl_exception_file_status;  // int         
__gg__exception_file_status;
+tree var_decl_exception_file_name;    // const char *__gg__exception_file_name;
+tree var_decl_exception_statement;    // const char *__gg__exception_statement;
+tree var_decl_exception_source_file;  // const char 
*__gg__exception_source_file;
+tree var_decl_exception_line_number;  // int         
__gg__exception_line_number;
+tree var_decl_exception_program_id;   // const char 
*__gg__exception_program_id;
+tree var_decl_exception_section;      // const char *__gg__exception_section;
+tree var_decl_exception_paragraph;    // const char *__gg__exception_paragraph;
+
+tree var_decl_default_compute_error;  // int         
__gg__default_compute_error;
+tree var_decl_rdigits;                // int         __gg__rdigits;
+tree var_decl_odo_violation;          // int         __gg__odo_violation;
+tree var_decl_unique_prog_id;         // size_t      __gg__unique_prog_id;
+
+tree var_decl_entry_location;         // This is for managing ENTRY statements
+tree var_decl_exit_address;           // This is for implementing 
pseudo_return_pop
+
+tree var_decl_call_parameter_signature; // char   
*__gg__call_parameter_signature
+tree var_decl_call_parameter_count;     // int __gg__call_parameter_count
+tree var_decl_call_parameter_lengths;   // size_t *__gg__call_parameter_count
+
+tree var_decl_return_code;             // short __gg__data_return_code
+
+tree var_decl_arithmetic_rounds_size;  // size_t __gg__arithmetic_rounds_size;
+tree var_decl_arithmetic_rounds;       // int*   __gg__arithmetic_rounds;
+tree var_decl_fourplet_flags_size;     // size_t __gg__fourplet_flags_size;
+tree var_decl_fourplet_flags;          // int*   __gg__fourplet_flags;
+
+tree var_decl_treeplet_1f; // cblc_field_pp_type_node , "__gg__treeplet_1f"
+tree var_decl_treeplet_1o; // SIZE_T_P                , "__gg__treeplet_1o"
+tree var_decl_treeplet_1s; // SIZE_T_P                , "__gg__treeplet_1s"
+tree var_decl_treeplet_2f; // cblc_field_pp_type_node , "__gg__treeplet_2f"
+tree var_decl_treeplet_2o; // SIZE_T_P                , "__gg__treeplet_2o"
+tree var_decl_treeplet_2s; // SIZE_T_P                , "__gg__treeplet_2s"
+tree var_decl_treeplet_3f; // cblc_field_pp_type_node , "__gg__treeplet_3f"
+tree var_decl_treeplet_3o; // SIZE_T_P                , "__gg__treeplet_3o"
+tree var_decl_treeplet_3s; // SIZE_T_P                , "__gg__treeplet_3s"
+tree var_decl_treeplet_4f; // cblc_field_pp_type_node , "__gg__treeplet_4f"
+tree var_decl_treeplet_4o; // SIZE_T_P                , "__gg__treeplet_4o"
+tree var_decl_treeplet_4s; // SIZE_T_P                , "__gg__treeplet_4s"
+
+// There are times when I need to insert a NOP into the code, mainly to force
+// a .loc directive into the assembly language so that the GDB-COBOL debugger
+// can show the COBOL source code.  This is true, for example, the CONTINUE
+// statement which otherwise would produce no assembly language. Since I
+// wasn't successful figuring out how to create an actual NOP assembly language
+// instruction, I instead gg_assign(var_decl_nop, integer_zero_node)
+tree var_decl_nop;                // int         __gg__nop;
+tree var_decl_main_called;        // int         __gg__main_called;

Lots more here.

Can the garbage-collector run during the time these variables are in use?


Dave

Reply via email to