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/go-encode-id.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/go-encode-id.h')
-rw-r--r-- | gcc/go/gofrontend/go-encode-id.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/go-encode-id.h b/gcc/go/gofrontend/go-encode-id.h new file mode 100644 index 0000000..b95d97d --- /dev/null +++ b/gcc/go/gofrontend/go-encode-id.h @@ -0,0 +1,30 @@ +// go-encode-id.h -- Go identifier encoding utilities -*- C++ -*- + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#ifndef GO_ENCODE_ID_H +#define GO_ENCODE_ID_H + +#include "backend.h" + +// Given an identifier corresponding to a function or variable, +// this helper returns TRUE if the identifier needs special +// encoding to be used as an ASM name (symbol), FALSE if the name +// is OK as is. +extern bool +go_id_needs_encoding(const std::string& str); + +// Encodes the specified identifier for ASM name safety, returning a +// string with the encoded value. +extern std::string +go_encode_id(const std::string &id); + +// Returns the empty string if the specified name needs encoding, +// otherwise invokes go_encode_id() on the name and returns the +// result. +extern std::string +go_selectively_encode_id(const std::string &id); + +#endif // !defined(GO_ENCODE_ID_H) |