diff options
Diffstat (limited to 'gcc/go/gofrontend/backend.h')
-rw-r--r-- | gcc/go/gofrontend/backend.h | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/gcc/go/gofrontend/backend.h b/gcc/go/gofrontend/backend.h index 323ac2e..98c36c1 100644 --- a/gcc/go/gofrontend/backend.h +++ b/gcc/go/gofrontend/backend.h @@ -545,24 +545,55 @@ class Backend Bstatement** pstatement) = 0; // Create an implicit variable that is compiler-defined. This is - // used when generating GC root variables, when storing the values - // of a slice constructor, and for the zero value of types. NAME is - // the name of the variable, either gc# for GC roots or C# for slice - // initializers. TYPE is the type of the implicit variable with an - // initial value INIT. IS_CONSTANT is true if the implicit variable - // should be treated like it is immutable. For slice initializers, - // if the values must be copied to the heap, the variable - // IS_CONSTANT. IS_COMMON is true if the implicit variable should + // used when generating GC data and roots, when storing the values + // of a slice constructor, and for the zero value of types. This returns a + // Bvariable because it corresponds to an initialized variable in C. + // + // NAME is the name to use for the initialized variable this will create. + // + // TYPE is the type of the implicit variable. + // + // IS_HIDDEN will be true if the descriptor should only be visible + // within the current object. + // + // IS_CONSTANT is true if the implicit variable should be treated like it is + // immutable. For slice initializers, if the values must be copied to the + // heap, the variable IS_CONSTANT. + // + // IS_COMMON is true if the implicit variable should // be treated as a common variable (multiple definitions with // different sizes permitted in different object files, all merged // into the largest definition at link time); this will be true for - // the zero value. If IS_COMMON is true, INIT will be NULL, and the - // variable should be initialized to all zeros. If ALIGNMENT is not - // zero, it is the desired alignment of the variable. + // the zero value. IS_HIDDEN and IS_COMMON will never both be true. + // + // If ALIGNMENT is not zero, it is the desired alignment of the variable. virtual Bvariable* - implicit_variable(const std::string& name, Btype* type, Bexpression* init, + implicit_variable(const std::string& name, Btype* type, bool is_hidden, bool is_constant, bool is_common, size_t alignment) = 0; + + // Set the initial value of a variable created by implicit_variable. + // This must be called even if there is no initializer, i.e., INIT is NULL. + // The NAME, TYPE, IS_HIDDEN, IS_CONSTANT, and IS_COMMON parameters are + // the same ones passed to implicit_variable. INIT will be a composite + // literal of type TYPE. It will not contain any function calls or anything + // else that can not be put into a read-only data section. + // It may contain the address of variables created by implicit_variable. + // + // If IS_COMMON is true, INIT will be NULL, and the + // variable should be initialized to all zeros. + virtual void + implicit_variable_set_init(Bvariable*, const std::string& name, Btype* type, + bool is_hidden, bool is_constant, bool is_common, + Bexpression* init) = 0; + + // Create a reference to a named implicit variable defined in some other + // package. This will be a variable created by a call to implicit_variable + // with the same NAME and TYPE and with IS_COMMON passed as false. This + // corresponds to an extern global variable in C. + virtual Bvariable* + implicit_variable_reference(const std::string& name, Btype* type) = 0; + // Create a named immutable initialized data structure. This is // used for type descriptors, map descriptors, and function // descriptors. This returns a Bvariable because it corresponds to |