aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-09-09 15:01:14 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-09-09 15:25:24 +0100
commit995bc1c9834f4b881a5d620cf4d707962c3841a7 (patch)
tree04b6329d942216060c2e81246535907e9980d06a /gcc/rust/backend
parent55f60bd6fe2db6831762e243577515824e2fca5c (diff)
downloadgcc-995bc1c9834f4b881a5d620cf4d707962c3841a7.zip
gcc-995bc1c9834f4b881a5d620cf4d707962c3841a7.tar.gz
gcc-995bc1c9834f4b881a5d620cf4d707962c3841a7.tar.bz2
Add support for choosing stdcall fastcall and cdecl in the extern options
GCC adds these as options to the function type as far as I can see, I was able to test this with linking against some C code. More testing is required here.
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-extern.h8
-rw-r--r--gcc/rust/backend/rust-compile-intrinsic.cc3
2 files changed, 7 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h
index d78a566..f0aacee 100644
--- a/gcc/rust/backend/rust-compile-extern.h
+++ b/gcc/rust/backend/rust-compile-extern.h
@@ -119,7 +119,7 @@ public:
fntype->override_context ();
}
- if (fntype->get_abi () == TyTy::FnType::ABI::INTRINSIC)
+ if (fntype->get_abi () == ABI::INTRINSIC)
{
Intrinsics compile (ctx);
Bfunction *fndecl = compile.compile (fntype);
@@ -127,19 +127,21 @@ public:
return;
}
- rust_assert (fntype->get_abi () == TyTy::FnType::ABI::C);
::Btype *compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype);
+ compiled_fn_type
+ = ctx->get_backend ()->specify_abi_attribute (compiled_fn_type,
+ fntype->get_abi ());
const unsigned int flags
= Backend::function_is_declaration | Backend::function_is_visible;
std::string ir_symbol_name = function.get_item_name ();
- // FIXME this assumes C ABI
std::string asm_name = function.get_item_name ();
Bfunction *fndecl
= ctx->get_backend ()->function (compiled_fn_type, ir_symbol_name,
asm_name, flags, function.get_locus ());
+
ctx->insert_function_decl (fntype->get_ty_ref (), fndecl, fntype);
}
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc
index 4068a7a..66d36e3 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -24,8 +24,9 @@ Intrinsics::Intrinsics (Context *ctx) : ctx (ctx) {}
Bfunction *
Intrinsics::compile (TyTy::FnType *fntype)
{
- rust_assert (fntype->get_abi () == TyTy::FnType::ABI::INTRINSIC);
+ rust_assert (fntype->get_abi () == ABI::INTRINSIC);
+ // https://github.com/rust-lang/rust/blob/master/library/core/src/intrinsics.rs
// https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_llvm/src/intrinsic.rs
// https://github.com/Rust-GCC/gccrs/issues/658