aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-item.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-01-19 12:03:01 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-01-20 09:59:22 +0000
commitf6d33adc6656839aebb4dca02df8efc8be6aedd2 (patch)
tree9d4bc5c4da1a45c82bd2bb9e73d1c000071e9b4d /gcc/rust/backend/rust-compile-item.h
parentcb44a8feb815ee31946b33e713c62ac2d333d7be (diff)
downloadgcc-f6d33adc6656839aebb4dca02df8efc8be6aedd2.zip
gcc-f6d33adc6656839aebb4dca02df8efc8be6aedd2.tar.gz
gcc-f6d33adc6656839aebb4dca02df8efc8be6aedd2.tar.bz2
Fix bug using ADT types as return types to functions
When we use anything other than builtin types for returns or parameters the type resolver was missing the NodeId mappings meaning it would alawys fail to resolve them. Then in gimple conversion we need to be able to reference the already created RECORD types instead of always creating new instances.
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.h')
-rw-r--r--gcc/rust/backend/rust-compile-item.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h
index c8cffc7..82dbc9b 100644
--- a/gcc/rust/backend/rust-compile-item.h
+++ b/gcc/rust/backend/rust-compile-item.h
@@ -127,16 +127,16 @@ public:
return;
}
- TyTy::TyBase *fnType;
+ TyTy::TyBase *fntype;
if (!ctx->get_tyctx ()->lookup_type (function.get_mappings ().get_hirid (),
- &fnType))
+ &fntype))
{
rust_fatal_error (function.locus, "failed to lookup function type");
return;
}
// convert to the actual function type
- auto compiled_fn_type = TyTyCompile::compile (ctx->get_backend (), fnType);
+ ::Btype *compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype);
unsigned int flags = 0;
bool is_main_fn = function.function_name.compare ("main") == 0;
@@ -159,15 +159,14 @@ public:
ctx->insert_function_decl (function.get_mappings ().get_hirid (), fndecl);
// setup the params
- TyTy::TyBase *tyret = TyTyExtractRetFromFnType::compile (fnType);
+ TyTy::TyBase *tyret = TyTyExtractRetFromFnType::compile (fntype);
std::vector<TyTy::ParamType *> typarams
- = TyTyExtractParamsFromFnType::compile (fnType);
+ = TyTyExtractParamsFromFnType::compile (fntype);
std::vector<Bvariable *> param_vars;
for (auto &it : typarams)
{
- auto compiled_param
- = TyTyCompileParam::compile (ctx->get_backend (), fndecl, it);
+ auto compiled_param = TyTyCompileParam::compile (ctx, fndecl, it);
param_vars.push_back (compiled_param);
ctx->insert_var_decl (it->get_ref (), compiled_param);
@@ -226,7 +225,7 @@ public:
Bvariable *return_address = nullptr;
if (function.has_function_return_type ())
{
- Btype *return_type = TyTyCompile::compile (ctx->get_backend (), tyret);
+ Btype *return_type = TyTyResolveCompile::compile (ctx, tyret);
bool address_is_taken = false;
Bstatement *ret_var_stmt = nullptr;