diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-10-25 17:24:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-25 17:24:06 +0000 |
commit | 0cf743d57fc67d88ecba654be8574ea9a5be40d2 (patch) | |
tree | a1fc9fccc5c3d3024b08bbed8da8ccc71c20f58e | |
parent | 6c7841a3ac51588c93543361d8906ab4daa2d034 (diff) | |
parent | 83e5265d6af48e1572cbe019b4b7f7a5603086a9 (diff) | |
download | gcc-0cf743d57fc67d88ecba654be8574ea9a5be40d2.zip gcc-0cf743d57fc67d88ecba654be8574ea9a5be40d2.tar.gz gcc-0cf743d57fc67d88ecba654be8574ea9a5be40d2.tar.bz2 |
Merge #1614
1614: intrinsics: Add rust_sorry wrapper for unimplemented intrinsics r=CohenArthur a=CohenArthur
This allows us to define intrinsics without implementing their body. This will be useful for atomic intrinsics for example, as there are a lot of them and we should work on implementing them one by one properly and slowly
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
-rw-r--r-- | gcc/rust/backend/rust-compile-intrinsic.cc | 10 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/intrinsics-3.rs | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index a418b86..2a2091c 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -93,6 +93,15 @@ prefetch_write_data (Context *ctx, TyTy::FnType *fntype) return prefetch_data_handler (ctx, fntype, Prefetch::Write); } +static inline tree +sorry_handler (Context *ctx, TyTy::FnType *fntype) +{ + rust_sorry_at (fntype->get_locus (), "intrinsic %qs is not yet implemented", + fntype->get_identifier ().c_str ()); + + return error_mark_node; +} + static const std::map<std::string, std::function<tree (Context *, TyTy::FnType *)>> generic_intrinsics = { @@ -107,6 +116,7 @@ static const std::map<std::string, {"copy_nonoverlapping", ©_nonoverlapping_handler}, {"prefetch_read_data", &prefetch_read_data}, {"prefetch_write_data", &prefetch_write_data}, + {"atomic_load", &sorry_handler}, }; Intrinsics::Intrinsics (Context *ctx) : ctx (ctx) {} diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-3.rs b/gcc/testsuite/rust/compile/torture/intrinsics-3.rs new file mode 100644 index 0000000..1acb353 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/intrinsics-3.rs @@ -0,0 +1,9 @@ +extern "rust-intrinsic" { + fn not_an_intrinsic(); + fn atomic_load(); // { dg-message "sorry, unimplemented: intrinsic .atomic_load. is not yet implemented" } +} + +fn main() { + unsafe { not_an_intrinsic() }; // { dg-error "unknown builtin intrinsic: not_an_intrinsic" } + unsafe { atomic_load() }; +} |