diff options
author | Than McIntosh <thanm@google.com> | 2016-11-22 22:28:05 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-11-22 22:28:05 +0000 |
commit | f3878205ddc2970e384ffaed3a95362763eee9fe (patch) | |
tree | 3f3e5efdd02fec9f6bb7a55785fb00da33b93a4a /gcc/go/gofrontend/backend.h | |
parent | 7e98cccbd85a0bc5ec6b7edf0017d98c2e96aef5 (diff) | |
download | gcc-f3878205ddc2970e384ffaed3a95362763eee9fe.zip gcc-f3878205ddc2970e384ffaed3a95362763eee9fe.tar.gz gcc-f3878205ddc2970e384ffaed3a95362763eee9fe.tar.bz2 |
compiler: relocate ID encoding utilities to gofrontend
Relocate the code that encodes/sanitizes identifiers to make them
assembler-friendly, moving it from the back end to the front end; the
decisions about when to encode an identifier and the calls to the
encoding helpers now take place entirely in gofrontend.
Reviewed-on: https://go-review.googlesource.com/33424
* go-gcc.cc (char_needs_encoding): Remove.
(needs_encoding, fetch_utf8_char, encode_id): Remove.
(Gcc_backend::global_variable): Add asm_name parameter. Don't
compute asm_name here.
(Gcc_backend::implicit_variable): Likewise.
(Gcc_backend::implicit_variable_reference): Likewise.
(Gcc_backend::immutable_struct): Likewise.
(Gcc_backend::immutable_struct_reference): Likewise.
* Make-lang.in (GO_OBJS): Add go/go-encode-id.o.
From-SVN: r242726
Diffstat (limited to 'gcc/go/gofrontend/backend.h')
-rw-r--r-- | gcc/go/gofrontend/backend.h | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/gcc/go/gofrontend/backend.h b/gcc/go/gofrontend/backend.h index dacfe48..e93cdfe 100644 --- a/gcc/go/gofrontend/backend.h +++ b/gcc/go/gofrontend/backend.h @@ -482,21 +482,19 @@ class Backend virtual Bvariable* error_variable() = 0; - // Create a global variable. PACKAGE_NAME is the name of the - // package where the variable is defined. PKGPATH is the package - // path for that package, from the -fgo-pkgpath or -fgo-prefix - // option. NAME is the name of the variable. BTYPE is the type of - // the variable. IS_EXTERNAL is true if the variable is defined in - // some other package. IS_HIDDEN is true if the variable is not - // exported (name begins with a lower case letter). - // IN_UNIQUE_SECTION is true if the variable should be put into a - // unique section if possible; this is intended to permit the linker - // to garbage collect the variable if it is not referenced. - // LOCATION is where the variable was defined. + // Create a global variable. NAME is the package-qualified name of + // the variable. ASM_NAME is the encoded identifier for the + // variable, incorporating the package, and made safe for the + // assembler. BTYPE is the type of the variable. IS_EXTERNAL is + // true if the variable is defined in some other package. IS_HIDDEN + // is true if the variable is not exported (name begins with a lower + // case letter). IN_UNIQUE_SECTION is true if the variable should + // be put into a unique section if possible; this is intended to + // permit the linker to garbage collect the variable if it is not + // referenced. LOCATION is where the variable was defined. virtual Bvariable* - global_variable(const std::string& package_name, - const std::string& pkgpath, - const std::string& name, + global_variable(const std::string& name, + const std::string& asm_name, Btype* btype, bool is_external, bool is_hidden, @@ -561,6 +559,9 @@ class Backend // // NAME is the name to use for the initialized variable this will create. // + // ASM_NAME is encoded assembler-friendly version of the name, or the + // empty string if no encoding is needed. + // // TYPE is the type of the implicit variable. // // IS_HIDDEN will be true if the descriptor should only be visible @@ -578,8 +579,9 @@ class Backend // // If ALIGNMENT is not zero, it is the desired alignment of the variable. virtual Bvariable* - implicit_variable(const std::string& name, Btype* type, bool is_hidden, - bool is_constant, bool is_common, int64_t alignment) = 0; + implicit_variable(const std::string& name, const std::string& asm_name, + Btype* type, bool is_hidden, bool is_constant, + bool is_common, int64_t alignment) = 0; // Set the initial value of a variable created by implicit_variable. @@ -597,12 +599,15 @@ class Backend 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. + // 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, ASM_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; + implicit_variable_reference(const std::string& name, + const std::string& asm_name, + Btype* type) = 0; // Create a named immutable initialized data structure. This is // used for type descriptors, map descriptors, and function @@ -612,6 +617,9 @@ class Backend // NAME is the name to use for the initialized global variable which // this call will create. // + // ASM_NAME is the encoded, assembler-friendly version of NAME, or + // the empty string if no encoding is needed. + // // IS_HIDDEN will be true if the descriptor should only be visible // within the current object. // @@ -630,7 +638,9 @@ class Backend // address. After calling this the frontend will call // immutable_struct_set_init. virtual Bvariable* - immutable_struct(const std::string& name, bool is_hidden, bool is_common, + immutable_struct(const std::string& name, + const std::string& asm_name, + bool is_hidden, bool is_common, Btype* type, Location) = 0; // Set the initial value of a variable created by immutable_struct. @@ -648,11 +658,12 @@ class Backend // Create a reference to a named immutable initialized data // structure defined in some other package. This will be a // structure created by a call to immutable_struct with the same - // NAME and TYPE and with IS_COMMON passed as false. This + // NAME, ASM_NAME and TYPE and with IS_COMMON passed as false. This // corresponds to an extern const global variable in C. virtual Bvariable* - immutable_struct_reference(const std::string& name, Btype* type, - Location) = 0; + immutable_struct_reference(const std::string& name, + const std::string& asm_name, + Btype* type, Location) = 0; // Labels. |