public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Support mangling *const ptr and slices like *const [T]
@ 2022-06-08 12:26 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:26 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6fb118f3e2ed4a189198936a82e0f68ccf954044
commit 6fb118f3e2ed4a189198936a82e0f68ccf954044
Author: Philip Herron <philip.herron@embecosm.com>
Date: Fri Apr 8 15:16:04 2022 +0100
Support mangling *const ptr and slices like *const [T]
The legacy mangling scheme needs to convert the canonical path containing
* for pointers and the [] brackets representing slices into:
* = $BP$
[ = $u5b$
] = $u5d$
These symbols are not allowed in asm symbols.
Addresses #849
Diff:
---
gcc/rust/backend/rust-mangle.cc | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/gcc/rust/backend/rust-mangle.cc b/gcc/rust/backend/rust-mangle.cc
index eaf78146464..82f643a1b90 100644
--- a/gcc/rust/backend/rust-mangle.cc
+++ b/gcc/rust/backend/rust-mangle.cc
@@ -11,6 +11,9 @@ static const std::string kMangledSubstBegin = "$LT$";
static const std::string kMangledSubstEnd = "$GT$";
static const std::string kMangledSpace = "$u20$";
static const std::string kMangledRef = "$RF$";
+static const std::string kMangledPtr = "$BP$";
+static const std::string kMangledLeftSqParen = "$u5b$"; // [
+static const std::string kMangledRightSqParen = "$u5d$"; // ]
static const std::string kQualPathBegin = "_" + kMangledSubstBegin;
namespace Rust {
@@ -29,8 +32,15 @@ legacy_mangle_name (const std::string &name)
// <example::Bar as example::A>::fooA:
// _ZN43_$LT$example..Bar$u20$as$u20$example..A$GT$4fooA17hfc615fa76c7db7a0E:
//
+ // core::ptr::const_ptr::<impl *const T>::cast:
+ // _ZN4core3ptr9const_ptr33_$LT$impl$u20$$BP$const$u20$T$GT$4cast17hb79f4617226f1d55E:
+ //
+ // core::ptr::const_ptr::<impl *const [T]>::as_ptr:
+ // _ZN4core3ptr9const_ptr43_$LT$impl$u20$$BP$const$u20$$u5b$T$u5d$$GT$6as_ptr17he16e0dcd9473b04fE:
+ //
// example::Foo<T>::new:
// _ZN7example12Foo$LT$T$GT$3new17h9a2aacb7fd783515E:
+
std::string buffer;
for (size_t i = 0; i < name.size (); i++)
{
@@ -47,6 +57,12 @@ legacy_mangle_name (const std::string &name)
m = kMangledSubstBegin;
else if (c == '>')
m = kMangledSubstEnd;
+ else if (c == '*')
+ m = kMangledPtr;
+ else if (c == '[')
+ m = kMangledLeftSqParen;
+ else if (c == ']')
+ m = kMangledRightSqParen;
else if (c == ':')
{
rust_assert (i + 1 < name.size ());
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:26 [gcc/devel/rust/master] Support mangling *const ptr and slices like *const [T] Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).