globals.mac 20.42 KiB
/*
 * $Id$
 */
/*
 * File : globals.mac
 * This file should contain the definitions of all global variables
 * used in the implementation of the sac2c compiler which are not restricted
 * to the use within one particular file.
 * However, the usage of global variables should be as limited as possible
 * since a functional programming style is preferred in the SAC project. The
 * major application of global variables therefore is the storage of such
 * global information as determined by the command line arguments of a sac2c
 * compiler call.
#include "config.h"
#ifndef GLOBALtype
#define GLOBALtype(type)
#endif
#ifndef GLOBALname
#define GLOBALname(name)
#endif
#ifndef GLOBALinit
#define GLOBALinit(init)
#endif
#define GLOBAL(type, name, init) GLOBALtype (type) GLOBALname (name) GLOBALinit (init)
 * Memory allocation
#ifdef SHOW_MALLOC
GLOBAL (unsigned int, current_allocated_mem, 0)
GLOBAL (unsigned int, max_allocated_mem, 0)
#endif
 * Tool type
GLOBAL (tool_t, tool, TOOL_sac2c)
GLOBAL (char *, toolname, NULL)
 * Syntax tree root
GLOBAL (node *, syntax_tree, NULL)
 * Parsing
GLOBAL (int, start_token, 0)
 *  Version control
GLOBAL (const char *, version_id, "v1.00-beta (Live CD Edition)")
 * version string
*/ GLOBAL (const char *, target_platform, OS "_" ARCH) /* * operating system platform string */ /* * Standard prelude name */ GLOBAL (const char *, preludename, SAC_PRELUDE_NAME) /* * Flag to enable/disable loading of prelude */ GLOBAL (bool, loadprelude, TRUE) /* * File handling */ GLOBAL (FILE *, outfile, NULL) /* * stream to write result to */ GLOBAL (char *, sacfilename, NULL) /* * name of file to be compiled */ GLOBAL (char *, puresacfilename, "stdin") /* * sacfilename without path specification */ GLOBAL (char *, outfilename, NULL) /* * name of executable */ GLOBAL (char *, modulename, NULL) /* * name of module/class which is compiled */ GLOBAL (namespace_t *, modulenamespace, NULL) /* * namespace of module/class which is compiled */ GLOBAL (char *, cfilename, NULL) /* * name of C source code file */ GLOBAL (char *, targetdir, NULL) /* * name of C source code file */ GLOBAL (file_type, filetype, F_prog) /* * kind of file: F_PROG, F_MODIMP or F_CLASSIMP */ GLOBAL (char *, tmp_dirname, NULL) /* * directory for storing temporary files
*/ GLOBAL (stringset_t *, exported_modules, NULL) /* * list of modules that will be exported by sac4c */ GLOBAL (bool, printldflags, FALSE) /* * enables printing of ldflags in sac4c */ GLOBAL (bool, printccflags, FALSE) /* * enables printing of ccflags in sac4c */ GLOBAL (char *, lib_dirname, NULL) /* * directory for wrapper file generated by sac4c */ GLOBAL (char *, inc_dirname, NULL) /* * directory for include file generated by sac4c */ /* * Command line arguments */ GLOBAL (int, argc, 0) GLOBAL (char **, argv, NULL) /* * Target architecture description */ GLOBAL (char *, target_name, "default") /* * name of target architecture selected by -target option */ /* * Dynamic-sized arrays option */ GLOBAL (bool, dynamic_shapes, FALSE) /* * Dynamic shapes are disabled by default */ /* * Extended LaC fun option */ GLOBAL (bool, elf, FALSE) /* * Extended LaC fun option disabled per default */ /* * SIMD options */ GLOBAL (bool, simd, FALSE) /* * SIMD code generation disabled per default */
/* * Multi-thread options */ GLOBAL (mtmode_t, mtmode, MT_none) /* * Multi-thread mode set according to -mt and -mtmode compiler flags */ GLOBAL (int, num_threads, 1) /* * Number of threads to be generated. * 0 : dynamic number of threads, specified as first command line argument * on application program startup. * 1 : sequential program * >1 : exact number of threads to be started */ GLOBAL (bool, no_fold_parallel, FALSE) /* * Switch whether or not to parallelize fold with-loops. */ GLOBAL (int, max_sync_fold, -1) /* * Maximum number of fold operations in a single synchronisation block. * -1 => value of infered needed_sync_fold will be used * 0 => no fold-with-loops, will be executed concurrently, * because no fold are allowed to be contained in a spmd/sync-block. * >0 => as much folds will be contained in one sync-block as maximum. */ GLOBAL (int, needed_sync_fold, 0) /* * Maximum number of fold operations in a single synchronisation block, * will be infered mechanically. */ GLOBAL (int, max_threads, 32) /* * Maximum number of threads if exact number is determined dynamically. */ GLOBAL (int, min_parallel_size, 250) /* * Minimum generator size for parallel execution of with-loops. */ GLOBAL (int, max_replication_size, 250) /* * Maximum size of array for replication, otherwise the calculation will be * executed single-threaded. */ GLOBAL (int, max_schedulers, 0) /* * This variable is used to collect the maximum number of schedulers in a * single SPMD block/function in order to generate an appropriate number * of local data structure sets for the scheduler implementations. */ GLOBAL (int, min_parallel_size_per_thread, 8) /* * Minimum generator size per thread for parallel execution of with-loops * e.g., max_threads = 4, min_parallel_size_per_thread=8 * => generator size must be >= 32 to be executed parallel */ /* * Preprocessor options
* * refer to -D, -cppI command line options: */ GLOBAL (char *, cpp_options, NULL); /* * C compiler options */ GLOBAL (bool, cc_debug, FALSE) /* Enable/disable inclusion of debug code into object files. */ #ifdef PRODUCTION GLOBAL (int, cc_optimize, 3) #else /* PRODUCTION */ GLOBAL (int, cc_optimize, 0) #endif /* PRODUCTION */ /* C compiler level of optimization */ /* * Optimization counters */ GLOBAL (optimize_counter_t, optcounters, optimize_counter_init) /* * Command line options for triggering optimizations */ GLOBAL (optimize_flags_t, optimize_developer, optimize_developer_init) GLOBAL (optimize_flags_t, optimize_production, optimize_production_init) GLOBAL (optimize_flags_t, optimize_all, optimize_all_init) GLOBAL (optimize_flags_t, optimize_none, optimize_none_init) #ifdef PRODUCTION GLOBAL (optimize_flags_t, optimize, optimize_production_init) #else /* PRODUCTION */ GLOBAL (optimize_flags_t, optimize, optimize_developer_init) #endif /* PRODUCTION */ /* * Command line options for triggering optimization parameters */ GLOBAL (bool, valid_ssaform, FALSE) /* * Flag indicating whether ast is in valid ssa form */ GLOBAL (int, ssaform_phase, 0) /* * Counter indicating how often the ssa form has been created FROM * SCRATCH(!), i.e., how often UndoSSATransform has been called. */ GLOBAL (bool, wls_aggressive, FALSE) /* * Per default do not use aggressive WLS * except the inner WL has <= wls_bound elems */ GLOBAL (int, maxwls, 1) /* * Apply aggressive withloop scalarization regardless of wls_aggressive * as long as the size of the inner withloop does not exceed maxwls. */ GLOBAL (bool, enforce_ieee, FALSE) /* * Restrict symbolic optimizations on floating point numbers according to
* IEEE-754 standard */ GLOBAL (int, maxspec, 20) /* * Maximum number of specializations per function */ GLOBAL (ivetype_t, ive, IVE_all) /* * IVE_all: If IVE is enabled, apply it to AKS and AKD arrays * This is the normal setting. * IVE_akd: Treat AKS arrays as AKD within IVE * IVE_aks: Perform IVE on AKS arrays only. */ GLOBAL (iveotype_t, iveo, IVEO_all) /* * IVEO_all: do all ive optimisations * This is the normal setting. * IVEO_wlidx: do wlidx only * IVEO_idxs: use idxs2offset * IVEO_copt: optimize computations */ GLOBAL (sigspec_mode_t, sigspec_mode, SSP_aks) GLOBAL (char **, sigspec_mode_str, sigspec_mode_str_init) /* * strategy for specilization of function signatures */ GLOBAL (spec_mode_t, spec_mode, SS_aks) GLOBAL (char **, spec_mode_str, spec_mode_str_init) /* * Command line options for specifying particular side conditions * for the (new) type inference. */ GLOBAL (int, max_recursive_inlining, 0) GLOBAL (int, unrnum, 2) GLOBAL (int, wlunrnum, 9) GLOBAL (int, minarray, 4) GLOBAL (int, max_optcycles, 10) GLOBAL (int, max_newgens, 100) GLOBAL (bool, no_fold_fusion, FALSE) /* * Command line options for specifying particular side conditions * for some optimizations. */ GLOBAL (int, initial_master_heapsize, 1024) GLOBAL (int, initial_worker_heapsize, 64) GLOBAL (int, initial_unified_heapsize, 0) /* * Command line options for specifying particular side conditions * of the private heap manager. * * Why is the default initial top arena size 0? * * Unfortunately, it turned out that pthread_key_create() allocates * some amount of memory, actually one page, without using malloc() * but by direct manipulation of the process' break value via sbrk(). * Since in multi-threaded execution malloc() is always called upon * program startup, early intitialization of the heap manager's internal * data structures is enforced. * Subsequent manipulation of the break value, however, leads to memory * fragmentation as the initial top arena cannot be extended smoothly * due to the missing page on top of the initially requested heap memory. * * As long as there is no elegant solution to this problem, there should
* be no initialization of the top arena, except when an upper boundary * for the total memory consumption is known and used for initialization. */ /* * Primitive function info tables */ GLOBAL (const char **, prf_name, prf_name_init) GLOBAL (const arg_encoding_t *, prf_arg_encoding, prf_arg_encoding_init) /* * This array contains string representations of primitive function names. */ /* * Runtime options */ GLOBAL (bool, print_after_break, TRUE) GLOBAL (bool, dotrace, FALSE) GLOBAL (bool, dousertrace, FALSE) /* * whether to enable the stuff tog does (-: */ GLOBAL (bool, dotogstuff, FALSE) GLOBAL (bool, insertconformitychecks, FALSE) GLOBAL (bool, stripconformitychecks, FALSE) GLOBAL (trace_flags_t, trace, trace_init) GLOBAL (trace_flags_t, trace_all, trace_all_init) GLOBAL (trace_flags_t, trace_none, trace_none_init) GLOBAL (bool, doruntimecheck, FALSE) GLOBAL (runtimecheck_flags_t, runtimecheck, runtimecheck_init) GLOBAL (runtimecheck_flags_t, runtimecheck_all, runtimecheck_all_init) GLOBAL (runtimecheck_flags_t, runtimecheck_none, runtimecheck_none_init) GLOBAL (bool, doprint, FALSE) GLOBAL (print_flags_t, print, print_init) GLOBAL (print_flags_t, print_all, print_all_init) GLOBAL (print_flags_t, print_none, print_none_init) GLOBAL (bool, doprofile, FALSE) GLOBAL (profile_flags_t, profile, profile_init) GLOBAL (profile_flags_t, profile_all, profile_all_init) GLOBAL (profile_flags_t, profile_none, profile_none_init) GLOBAL (bool, docachesim, FALSE) GLOBAL (cachesim_flags_t, cachesim, cachesim_init) GLOBAL (cachesim_flags_t, cachesim_all, cachesim_all_init) GLOBAL (cachesim_flags_t, cachesim_none, cachesim_none_init) GLOBAL (char *, cachesim_host, (char *)MEMmalloc (MAX_FILE_NAME)) GLOBAL (char *, cachesim_file, (char *)MEMmalloc (MAX_FILE_NAME)) GLOBAL (char *, cachesim_dir, (char *)MEMmalloc (MAX_FILE_NAME)) /* * Profiling information storage facilities */ GLOBAL (int, profile_funcntr, 0) GLOBAL (char **, profile_funnme, (char **)MEMmalloc (PF_MAXFUN * sizeof (char *)))
GLOBAL (int *, profile_funapcntr, (int *)MEMmalloc (PF_MAXFUN * sizeof (int))) GLOBAL (int **, profile_funapline, BuildFunApLine (PF_MAXFUN, PF_MAXFUNAP)) GLOBAL (int **, profile_parentfunno, BuildFunApLine (PF_MAXFUN, PF_MAXFUNAP)) GLOBAL (int, profile_funapmax, 1) /* * Compile time options */ GLOBAL (bool, treecheck, FALSE) /* * check syntax tree for consistency with xml specification */ #ifdef PRODUCTION GLOBAL (bool, sancheck, FALSE) #else /* PRODUCTION */ GLOBAL (bool, sancheck, FALSE) #endif /* PRODUCTION */ /* * check syntax tree for structural consistency */ #ifdef SHOW_MALLOC GLOBAL (bool, memcheck, global.memcheck) /* * check syntaxtree for memoryproblems with xml specification * * CAUTION: * memcheck requires initiatilisation BEFORE anything else. * Therefore, we look for -d memcheck in presetup options * and set global.memcheck there accordingly. We re-initialise * global.memcheck to its existing value here for purely technical * reasons. */ #endif /* SHOW_MALLOC */ GLOBAL (bool, use_efence, FALSE) /* * link executable with ElectricFence (Malloc Debugger) */ /* GLOBAL( int, linksetsize, INT_MAX) */ GLOBAL (int, linksetsize, 10) /* * number of functions written to the same file when creating library * Zero means unlimited. */ GLOBAL (bool, cleanup, TRUE) /* * Don't remove temporary files and directory when compiling * module/class implementations. */ GLOBAL (bool, libstat, FALSE) /* * Don't actually compile, but display library information. */ GLOBAL (bool, print_resources, FALSE) /* * Don't actually compile, but display resource information. */ GLOBAL (bool, makedeps, FALSE) /* * Don't actually compile, but infer module dependencies. */
GLOBAL (bool, makelibdeps, FALSE) /* * Don't actually compile, but infer extended module dependencies. */ GLOBAL (bool, gen_cccall, FALSE) /* * Generate shell script '.sac2c' in current directory * that contains the C compiler call produced by sac2c. */ GLOBAL (bool, show_syscall, FALSE) /* * Show system calls during compilation. */ GLOBAL (bool, lacinline, TRUE) /* * Inline LAC functions */ GLOBAL (compiler_phase_t, break_after_phase, PH_undefined) /* * Stop compilation process after given phase. */ GLOBAL (compiler_phase_t, break_after_subphase, PH_undefined) /* * Stop compilation process after given subphase. */ GLOBAL (compiler_phase_t, break_after_cyclephase, PH_undefined) /* * Stop compilation process after given cycle optimization. */ GLOBAL (int, break_cycle_specifier, 1) /* * Additional break specifier that allows a designated break within * a particular (optimization) loop. */ GLOBAL (genlib_flags_t, genlib, genlib_init) /* * Specify interfaces to generate from SAC modules. * Init: nothing, but changed to default standard SAC library * if commandline switch is not used. */ GLOBAL (int, padding_overhead_limit, 10) /* * Limit for additional resource allocation due to array padding in * percentage. Can be modified via -aplimit option. */ GLOBAL (bool, apdiag, FALSE) /* * Diagnostics of array padding may be written into a file. * Per default no information is written. Use -apdiag to enable * output to "modulename.ap". */ GLOBAL (int, apdiag_limit, 20000) /* * Limit for size of diagnostic output given in approximate number of lines. * This avoids the creation of extremely huge diagnostic output files. */ /* * Compile time information system parameters
*/ GLOBAL (te_info *, act_info_chn, NULL) /* * Info chain for extended error messages during TC */ #ifdef PRODUCTION GLOBAL (int, verbose_level, 1) #else /* PRODUCTION */ GLOBAL (int, verbose_level, 3) #endif /* PRODUCTION */ /* * Verbosity of compile time output */ GLOBAL (compiler_phase_t, compiler_phase, PH_initial) /* * Counter for compilation phases */ GLOBAL (compiler_phase_t, compiler_subphase, PH_initial) /* * Counter for compilation subphases */ GLOBAL (compiler_phase_t, compiler_cyclephase, PH_initial) /* * Counter for cycle optimizations */ GLOBAL (compiler_phase_t, compiler_anyphase, PH_initial) /* * Counter for any kind of compiler phase/subphase/cyclephase */ GLOBAL (node *, current_fundef, NULL) /* * Counter for any kind of compiler phase/subphase/cyclephase */ GLOBAL (bool, run_stabilization_cycle, FALSE) /* * only run stabilization cycle if main cycle pass limit exhausted */ GLOBAL (int, linenum, 1) /* * Current line number */ GLOBAL (char *, filename, NULL) /* * Current file name */ /* * DBUG options */ GLOBAL (compiler_phase_t, my_dbug_from, PH_initial) GLOBAL (compiler_phase_t, my_dbug_to, PH_final) GLOBAL (bool, my_dbug, FALSE) GLOBAL (bool, my_dbug_active, FALSE) GLOBAL (char *, my_dbug_str, NULL) /* * for arg tags */
GLOBAL (bool *, argtag_has_shp, argtag_has_shp_init) GLOBAL (bool *, argtag_has_rc, argtag_has_rc_init) GLOBAL (bool *, argtag_has_desc, argtag_has_desc_init) GLOBAL (bool *, argtag_is_in, argtag_is_in_init) GLOBAL (bool *, argtag_is_out, argtag_is_out_init) GLOBAL (bool *, argtag_is_inout, argtag_is_inout_init) GLOBAL (const char **, argtag_string, argtag_string_init) /* * Special purpose global variables */ GLOBAL (bool, print_objdef_for_header_file, FALSE) /* * This global variable serves a very special purpose. * When generating separate C-files for functions and global variables, * a header file is required which contains declarations of them all. * In this case the ICM ND_KS_DECL_GLOBAL_ARRAY must be written * differently. This global variable triggers the respective print * function defined in icm2c.c. It is set by PrintModul. */ GLOBAL (int, object_counter, 0) /* * This global variable is used whenever the objectinitflags of a module * are written to separate files. */ GLOBAL (int, indent, 0) /* * This global variable is used for indenting while printing SAC-code. * It has to be made global since printing is not only done in the printing- * directory but from within icm2c_xxx.c as well! */ GLOBAL (const int *, basetype_size, basetype_size_init) /* * This array of integers keeps the lengths of all simpletypes. * It at least is used in compile.c, tile_size_inference.c, and constants.c! */ GLOBAL (min_array_rep_t, min_array_rep, MAR_scl_aks) /* * This global variable can be used to restrict the set of * array representations used by the backend */ /* * Name tuples */ GLOBAL (char **, nt_shape_string, nt_shape_string_init) GLOBAL (char **, nt_hidden_string, nt_hidden_string_init) GLOBAL (char **, nt_unique_string, nt_unique_string_init) /* * These character arrays are the macro-name-parts used to select * array class and array uniqueness properties. */ /* * Primitive zip function tables, previously defined in zipcv.c */ GLOBAL (const zipcvfunptr *, zipcv_plus, zipcv_plus_init) GLOBAL (const zipcvfunptr *, zipcv_minus, zipcv_minus_init) GLOBAL (const zipcvfunptr *, zipcv_mul, zipcv_mul_init) GLOBAL (const zipcvfunptr *, zipcv_div, zipcv_div_init) GLOBAL (const zipcvfunptr *, zipcv_mod, zipcv_mod_init) GLOBAL (const zipcvfunptr *, zipcv_min, zipcv_min_init) GLOBAL (const zipcvfunptr *, zipcv_max, zipcv_max_init)
GLOBAL (const zipcvfunptr *, zipcv_and, zipcv_and_init) GLOBAL (const zipcvfunptr *, zipcv_or, zipcv_or_init) GLOBAL (const zipcvfunptr *, zipcv_eq, zipcv_eq_init) GLOBAL (const zipcvfunptr *, zipcv_neq, zipcv_neq_init) GLOBAL (const zipcvfunptr *, zipcv_le, zipcv_le_init) GLOBAL (const zipcvfunptr *, zipcv_lt, zipcv_lt_init) GLOBAL (const zipcvfunptr *, zipcv_gt, zipcv_gt_init) GLOBAL (const zipcvfunptr *, zipcv_ge, zipcv_ge_init) GLOBAL (const zipcvfunptr *, zipcv_not, zipcv_not_init) GLOBAL (const zipcvfunptr *, zipcv_toi, zipcv_toi_init) GLOBAL (const zipcvfunptr *, zipcv_tof, zipcv_tof_init) GLOBAL (const zipcvfunptr *, zipcv_tod, zipcv_tod_init) GLOBAL (const zipcvfunptr *, zipcv_abs, zipcv_abs_init) GLOBAL (const zipcvfunptr *, zipcv_neg, zipcv_neg_init) /* * Primitive base function tables, previously defined in basecv.c */ GLOBAL (const basecvfunptr *, basecv_zero, basecv_zero_init) GLOBAL (const basecvfunptr *, basecv_one, basecv_one_init) /* * Constant vector copying function table, previously defined in cv2cv.c */ GLOBAL (const cv2cvfunptr *, cv2cv, cv2cv_init) /* * Constant vector to scalar conversion function table, previously defined in cv2scalar.c */ GLOBAL (const cv2scalarfunptr *, cv2scalar, cv2scalar_init) /* * Constant vector to string conversion function table, previously defined in cv2str.c */ GLOBAL (const cv2strfunptr *, cv2str, cv2str_init) /* * Debug string tables */ GLOBAL (const char **, mdb_nodetype, mdb_nodetype_init) GLOBAL (const char **, mdb_type, mdb_type_init) /* * Type to string conversion tables */ GLOBAL (const char **, type_string, type_string_init); GLOBAL (const char **, rename_type, rename_type_init); /* * Resource / configuration management */ GLOBAL (target_list_t *, target_list, NULL) /* * When the configuration files are parsed, a dynamic tree like structure * is generated and its root is stored in target_list. This dynamic structure * is afterwards processed, the relevant information is stored in the static * structure config, and the target_list is finally released. */ GLOBAL (configuration_t, config, config_init) /* * This global variable permanently stores the desired configuration * which is read from the sac2crc file.
*/ /* * Storing module dependencies */ GLOBAL (stringset_t *, dependencies, NULL); #undef GLOBALtype #undef GLOBALname #undef GLOBALinit #undef GLOBAL