aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-item.h
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-11 17:46:10 +0000
committerGitHub <noreply@github.com>2021-05-11 17:46:10 +0000
commit5134aaa9f0b37ea372cb185fe7aa6c26fe0a4c2e (patch)
tree95c03868e9d05a84000e29187e2e5ccba431cd35 /gcc/rust/backend/rust-compile-item.h
parent299d98d8e6fcb8d014b299adc426d93cf0c8050f (diff)
parent58e108c7c6d0fa3c9ebc7eeb681851924e22ddd5 (diff)
downloadgcc-5134aaa9f0b37ea372cb185fe7aa6c26fe0a4c2e.zip
gcc-5134aaa9f0b37ea372cb185fe7aa6c26fe0a4c2e.tar.gz
gcc-5134aaa9f0b37ea372cb185fe7aa6c26fe0a4c2e.tar.bz2
Merge #425
425: Basic implementation of legacy symbol mangling r=philberty a=philberty Implement basic rustc legacy symbol mangling Rust supports two different symbol mangling methods legacy and V0. V0 is the goal but its not yet stable. This implements the legacy method but with a dummy hash value since it requires a sip128 implementation to generate the apropriate hash which can be done in a sperate change. This change allows us to actually assemble generic functions and avoid bad symbol duplications. Addresses #305 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.h')
-rw-r--r--gcc/rust/backend/rust-compile-item.h21
1 files changed, 5 insertions, 16 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h
index 2bbfe4c..5a7d846 100644
--- a/gcc/rust/backend/rust-compile-item.h
+++ b/gcc/rust/backend/rust-compile-item.h
@@ -53,8 +53,7 @@ public:
Bexpression *value = CompileExpr::Compile (var.get_expr (), ctx);
std::string name = var.get_identifier ();
- // FIXME need name mangling
- std::string asm_name = "__" + var.get_identifier ();
+ std::string asm_name = ctx->mangle_item (name);
bool is_external = false;
bool is_hidden = false;
@@ -147,21 +146,11 @@ public:
std::string ir_symbol_name = function.get_function_name ();
std::string asm_name = function.get_function_name ();
- if (!is_main_fn)
- {
- // FIXME need name mangling
- if (concrete == nullptr)
- asm_name = "__" + function.get_function_name ();
- else
- {
- ir_symbol_name
- = function.get_function_name () + fntype->subst_as_string ();
- asm_name = "__" + function.get_function_name ();
- for (auto &sub : fntype->get_substs ())
- asm_name += "G" + sub.as_string ();
- }
- }
+ // we don't mangle the main fn since we haven't implemented the main shim
+ // yet
+ if (!is_main_fn)
+ asm_name = ctx->mangle_item (ir_symbol_name);
Bfunction *fndecl
= ctx->get_backend ()->function (compiled_fn_type, ir_symbol_name,