PIPS
|
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "text.h"
#include "constants.h"
#include "text-util.h"
#include "misc.h"
#include "properties.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "pipsdbm.h"
#include "pips-libs.h"
#include "pipsmake.h"
#include "preprocessor.h"
#include "syntheses.h"
Go to the source code of this file.
Macros | |
#define | FILE_WARNING |
#define | C_FILE_WARNING_EFFECT |
#define | C_FILE_WARNING |
Functions | |
void | compilation_unit_parser (_UNUSED_ const string s) |
static string | nth_formal_name (int n) |
Generate a string as "f42" for the number 42 for example. More... | |
static sentence | stub_var_decl (parameter p, int n, bool is_fortran) |
Generate an entry for one formal parameter of a stub declaration. More... | |
static sentence | stub_head (entity f, bool is_fortran) |
Generate the head of a stub source for a missing source. More... | |
static text | stub_text (entity module, bool is_fortran) |
Generate the text for a missing module. More... | |
static text | compilation_unit_text (entity cu, entity module) |
Generate the text of a compilation unit for a missing C module. More... | |
void | add_new_compilation_unit (const char *compilation_unit_name, bool is_fortran, entity module) |
Warning! Do not modify this file that is automatically generated! More... | |
bool | add_new_module_from_text (const char *module_name, text code_text, bool is_fortran, const char *compilation_unit_name) |
Add the new resource files associated to a module with its more-or-less correct code. More... | |
bool | add_new_module (const char *module_name, entity module, statement stat, bool is_fortran) |
Add the new resource files associated to a module with its more-or-less correct code. More... | |
static bool | missing_file_initializer (const char *module_name, bool is_fortran) |
Generate a source file for a module, if none available. More... | |
static bool | module_in_user_file_p (const char *module, bool is_fortran) |
void | set_internal_missing_module_resolver_handler (string(*_internal_resolver)(const char *)) |
static bool | retrieve_a_missing_file_using_internal_resolver (const char *module, bool is_fortran) |
static bool | retrieve_a_missing_file_using_external_resolver (const char *module, bool is_fortran) |
static bool | ask_a_missing_file (const char *module, bool is_fortran) |
Generate a new module by asking some files to the user. More... | |
static bool | generic_initializer (const char *module_name, bool is_fortran) |
There is no real rule to produce source or user files when there is no corresponding file; so the initializer was introduced by Remi Triolet to deal with source and user files as with any other kind of resources. More... | |
bool | fortran_initializer (const string module_name) |
Create a module with its related file resources when there is no Fortran source for it. More... | |
bool | initializer (const string module_name) |
A phase that creates a module with its related file resources when there is no Fortran source for it. More... | |
bool | c_initializer (const string module_name) |
A phase that creates a module with its related file resources when there is no C source for it. More... | |
Variables | |
static string(* | internal_resolver )(const char *)=0 |
#define C_FILE_WARNING |
Definition at line 71 of file initializer.c.
#define C_FILE_WARNING_EFFECT |
Definition at line 64 of file initializer.c.
#define FILE_WARNING |
Definition at line 57 of file initializer.c.
void add_new_compilation_unit | ( | const char * | compilation_unit_name, |
bool | is_fortran, | ||
entity | module | ||
) |
Warning! Do not modify this file that is automatically generated!
Modify src/Libs/syntheses/syntheses-local.h instead, to add your own modifications. header file built by cproto syntheses-local.h SYNTHESES Library: Passes and functions generating new modules, or removing modules, such as initializer, clone, inlining and outlining cproto-generated files initializer.c
Add the compilation unit files
Builds the compilation unit stub: it can be empty or include module_name declaration as an extern function.
Put it in the source file and link the initial file.
compilation_unit_name | ompilation_unit_name |
is_fortran | s_fortran |
module | odule |
Definition at line 367 of file initializer.c.
References asprintf, compilation_unit_name, compilation_unit_text(), db_build_file_resource_name(), db_get_current_workspace_directory(), db_make_subdirectory, DB_PUT_FILE_RESOURCE, entity_undefined_p, f(), file_exists_p(), file_name, FindEntity(), free(), free_text(), full_name, make_text(), MakeCompilationUnitEntity(), module, NIL, pips_assert, print_text(), safe_fclose(), safe_fopen(), strdup(), string_undefined_p, TOP_LEVEL_MODULE_NAME, user_log(), and WORKSPACE_TMP_SPACE.
Referenced by add_new_module_from_text(), and outliner_compilation_unit().
Add the new resource files associated to a module with its more-or-less correct code.
The idea is to prettyprint the module to some file resources and to parse it later in order to have a full-fledge module with all the PIPS structured up-to-date.
Useful for code generation, out-lining...
There is still some redundancy with module_name, module and stat
Get a text code for the new module
module_name | odule_name |
module | odule |
stat | tat |
is_fortran | text heading |
Definition at line 553 of file initializer.c.
References add_new_module_from_text(), free_text(), module, module_name(), ret, string_undefined, and text_module().
Referenced by create_module_with_statement().
bool add_new_module_from_text | ( | const char * | module_name, |
text | code_text, | ||
bool | is_fortran, | ||
const char * | compilation_unit_name | ||
) |
Add the new resource files associated to a module with its more-or-less correct code.
The idea is to prettyprint the module to some file resources and to parse it later in order to have a full-fledge module with all the PIPS data structures up-to-date.
Useful for code generation, out-lining, stub generation...
Should be checked with different module with the same name... Maybe a conflict in WORKSPACE_TMP_SPACE ?
relative to the current directory
For C only: compilation unit cu and compilation unit name cun
depending on output language, build compilation unit, select prettyprinter choose out file name
pips' current directory is just above the workspace
Put the code text in the temporary source file
A PIPS database may be partly incoherent after a core dump but still usable (Cathare 2, FI). So delete a previously finit_name file.
The initial file is linked to the newly generated temporary file:
Add the new generated file as a file resource with its local name... should only put a new user file, I guess?
The user file dwells in the WORKSPACE_TMP_SPACE
module_name | odule_name |
code_text | ode_text |
is_fortran | s_fortran |
compilation_unit_name | ompilation_unit_name |
Definition at line 431 of file initializer.c.
References add_new_compilation_unit(), asprintf, compilation_unit_name, compilation_unit_of_module(), db_build_file_resource_name(), db_get_current_workspace_directory(), db_make_subdirectory, DB_PUT_FILE_RESOURCE, entity_local_name(), entity_undefined, entity_undefined_p, f(), file_exists_p(), file_name, FILE_SEP, FILE_SEP_STRING, FindEntity(), free(), full_name, is_language_c, is_language_fortran, local_name_to_top_level_entity(), MakeCompilationUnitEntity(), module_name(), module_name_to_entity(), pips_user_error, print_text(), safe_fclose(), safe_fopen(), safe_link(), safe_unlink(), set_prettyprint_language_tag(), strdup(), string_undefined, string_undefined_p, strndup(), TOP_LEVEL_MODULE_NAME, user_log(), and WORKSPACE_TMP_SPACE.
Referenced by add_new_module(), create_module_with_statement(), missing_file_initializer(), outliner_file(), outliner_independent_recursively(), and simd_memory_packing().
Generate a new module by asking some files to the user.
Can also generate a stub if replied as so by the user.
Loop until we get the module, or the user abort (quit)
Definition at line 716 of file initializer.c.
References free(), missing_file_initializer(), module, module_in_user_file_p(), pips_internal_error, pips_user_warning, process_user_file(), same_string_p, and user_request().
Referenced by generic_initializer().
A phase that creates a module with its related file resources when there is no C source for it.
module_name | odule_name |
Definition at line 853 of file initializer.c.
References debug_off, debug_on, generic_initializer(), and module_name().
Definition at line 48 of file initializer.c.
References pips_internal_error.
Referenced by generic_initializer().
Generate the text of a compilation unit for a missing C module.
Eliminate multiple occurrences. The first one must be preserved to preserve the dependencies. Might be more efficient to CONS and then to reverse nsel, or even better to update sel. I keep the most intuitive version.
Do not declare dummy structures, unions and enumerations, which must be part of another declaration, either a typedef or a name structure, union or enumeration.
Definition at line 281 of file initializer.c.
References ADD_SENTENCE_TO_TEXT, C_FILE_WARNING, c_text_entity(), CAR, CONS, DUMMY_ENUM_PREFIX, DUMMY_STRUCT_PREFIX, DUMMY_UNION_PREFIX, ENDP, ENTITY, entity_name, entity_type, entity_user_name(), FOREACH, fprintf(), functional_type_supporting_entities(), gen_free_list(), gen_in_list_p(), gen_nconc(), gen_once_p(), ifdebug, is_sentence_formatted, list_undefined, make_sentence(), make_text(), MERGE_TEXTS, module, NIL, pips_assert, pips_debug, pips_user_error, POP, prettyprint_language_is_c_p(), print_entities(), print_text(), sentence_undefined, strdup(), text_undefined, type_functional, type_functional_p, and type_undefined_p.
Referenced by add_new_compilation_unit().
Create a module with its related file resources when there is no Fortran source for it.
module_name | odule_name |
Definition at line 831 of file initializer.c.
References generic_initializer(), and module_name().
There is no real rule to produce source or user files when there is no corresponding file; so the initializer was introduced by Remi Triolet to deal with source and user files as with any other kind of resources.
According to the PREPROCESSOR_MISSING_FILE_HANDLING property :
Definition at line 783 of file initializer.c.
References ask_a_missing_file(), bootstrap_stubs(), compilation_unit_of_module(), compilation_unit_parser(), db_resource_p(), flag_as_stub(), get_bool_property(), get_string_property(), missing_file_initializer(), module_name(), pips_user_error, retrieve_a_missing_file_using_external_resolver(), retrieve_a_missing_file_using_internal_resolver(), and same_string_p.
Referenced by c_initializer(), fortran_initializer(), and initializer().
A phase that creates a module with its related file resources when there is no Fortran source for it.
module_name | odule_name |
Definition at line 839 of file initializer.c.
References debug_off, debug_on, generic_initializer(), and module_name().
Generate a source file for a module, if none available.
Builds a stub code text for the missing module
Definition at line 572 of file initializer.c.
References add_new_module_from_text(), entity_undefined_p, free_text(), is_language_c, is_language_fortran, local_name_to_top_level_entity(), module_name(), pips_user_error, pips_user_warning, ret, set_prettyprint_language_tag(), string_undefined, stub_text(), and text_undefined.
Referenced by ask_a_missing_file(), and generic_initializer().
Definition at line 605 of file initializer.c.
References db_resource_p(), and module.
Referenced by ask_a_missing_file(), retrieve_a_missing_file_using_external_resolver(), and retrieve_a_missing_file_using_internal_resolver().
Generate a string as "f42" for the number 42 for example.
Definition at line 78 of file initializer.c.
References concatenate(), free(), int2a(), and strdup().
Referenced by stub_head(), and stub_var_decl().
|
static |
Definition at line 650 of file initializer.c.
References asprintf, buffer, empty_string_p(), free(), get_string_property(), module, module_in_user_file_p(), pips_internal_error, pips_user_error, process_user_file(), ret, strchrnul(), and strdup().
Referenced by generic_initializer().
|
static |
Definition at line 618 of file initializer.c.
References internal_resolver, module, module_in_user_file_p(), pips_user_error, and process_user_file().
Referenced by generic_initializer().
void set_internal_missing_module_resolver_handler | ( | string(*)(const char *) | _internal_resolver | ) |
Definition at line 612 of file initializer.c.
References internal_resolver.
Referenced by set_python_missing_module_resolver_handler().
Generate the head of a stub source for a missing source.
is it a subroutine or a function?
generate the formal parameter list.
close if necessary.
close
Definition at line 134 of file initializer.c.
References basic_to_string(), CAR, CONS, entity_type, f(), functional_parameters, functional_result, gen_length(), gen_nreverse(), is_sentence_unformatted, make_sentence(), make_unformatted(), module_local_name(), NIL, nth_formal_name(), PARAMETER, parameter_type, pips_assert, strdup(), STRING, string_undefined, type_functional, type_functional_p, type_variable, type_variable_p, type_void_p, and variable_basic.
Referenced by stub_text().
Generate the text for a missing module.
of sentence
FI: The result should be good because pdl wil be set to NIL and the types used for the parameter will simply be declared but not defined
assume is_C
SG: this just a few samples to show the possibility of the system A better idea would be to analyse arguments to guess which part of the memory could be touched. For instance, use a variable to represent the `‘foreign state’' of the generated functions, and deduce from the argument type the kind of effects e can safely assume
FI: I do not know what to use to initialize pdl usefully
Definition at line 196 of file initializer.c.
References ADD_SENTENCE_TO_TEXT, C_FILE_WARNING_EFFECT, c_text_entity_simple(), CHAIN_SWORD, CONS, entity_name, entity_type, entity_undefined, entity_user_name(), FILE_WARNING, FOREACH, functional_parameters, gen_free_list(), gen_nconc(), gen_nreverse(), generic_c_words_entity(), get_bool_property(), ifdebug, is_sentence_formatted, is_sentence_unformatted, make_sentence(), make_text(), make_unformatted(), module, NIL, PARAMETER, parameter_type, PIPS_IO_BARRIER_OPERATOR_NAME, PIPS_MEMORY_BARRIER_OPERATOR_NAME, pips_user_error, print_text(), SENTENCE, strdup(), STRING, string_undefined, stub_head(), stub_var_decl(), text_sentences, text_undefined, type_functional, type_functional_p, type_supporting_entities(), type_undefined_p, and type_void_p.
Referenced by missing_file_initializer().
Generate an entry for one formal parameter of a stub declaration.
Definition at line 87 of file initializer.c.
References basic_overloaded_p, basic_to_string(), comment(), concatenate(), free(), gen_make_list(), is_sentence_formatted, is_sentence_unformatted, make_sentence(), make_unformatted(), nth_formal_name(), parameter_type, pips_internal_error, sentence_undefined, strdup(), string_domain, string_undefined, type_tag, type_varargs_p, type_variable, type_variable_p, type_void_p, and variable_basic.
Referenced by stub_text().
|
static |
Definition at line 611 of file initializer.c.
Referenced by retrieve_a_missing_file_using_internal_resolver(), and set_internal_missing_module_resolver_handler().