Open RalfJung opened 2 years ago
unchecked_add is also required for the minimizer to transpile range loops like
for i in 0..n {}
- [x] offset and wrapping_offset
Is wrapping_offset
already supported?
I get an error if I try to minimize the following code:
int main() {
let _ = (&42 as *const i32).wrapping_offset(1);
}
error message:
thread 'rustc' panicked at minimize/src/bb.rs:202:25:
unsupported Rust intrinsic `arith_offset`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
It is supported in MiniRust, but not in minimize.
Rust intrinsics are basically primitive operations of the language. So I think it makes most sense to add them as (unary or binary) operators to MiniRust, or possibly as statements of they don't return anything. The unary vs binary split is a bit annoying but maybe not too bad...
So, we should probably make a list of intrinsics that we should support. I'm just going to start writing down a few but this is surely not exhaustive yet.
Other intrinsics can probably be implemented as regular MiniRust functions and don't need to be primitives -- we can define their semantics via lower-level MiniRust code: