rust/src
Scott McMurray 06817d1bb3 Add unsigned_offset_from on pointers
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`.  Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`.

As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives.  That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change.

This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE.  It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-11 17:16:25 -07:00
..
abi Merge commit '370c397ec9' into sync_cg_clif-2022-03-20 2022-03-20 16:55:21 +01:00
bin Merge commit '370c397ec9' into sync_cg_clif-2022-03-20 2022-03-20 16:55:21 +01:00
debuginfo Merge commit '370c397ec9' into sync_cg_clif-2022-03-20 2022-03-20 16:55:21 +01:00
driver check_doc_keyword: don't alloc string for emptiness check 2022-04-08 11:45:57 +03:00
intrinsics Add unsigned_offset_from on pointers 2022-05-11 17:16:25 -07:00
optimize Merge commit '35d9c6bf25' into sync_cg_clif-2022-02-23 2022-02-23 11:49:34 +01:00
allocator.rs Add -Z oom={panic,abort} command-line option 2022-03-03 12:58:38 +00:00
analyze.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
archive.rs Unconditionally update symbols 2022-02-10 18:27:18 +01:00
base.rs Merge commit 'f2cdd4a78d' into sync_cg_clif-2022-04-22 2022-04-22 21:11:38 +02:00
cast.rs Merge commit 'f2cdd4a78d' into sync_cg_clif-2022-04-22 2022-04-22 21:11:38 +02:00
codegen_i128.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
common.rs Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them. 2022-04-05 13:18:21 +00:00
compiler_builtins.rs Merge commit '370c397ec9' into sync_cg_clif-2022-03-20 2022-03-20 16:55:21 +01:00
config.rs Merge commit 'f2cdd4a78d' into sync_cg_clif-2022-04-22 2022-04-22 21:11:38 +02:00
constant.rs Add new Deinit statement kind 2022-04-11 08:55:03 -04:00
discriminant.rs Merge commit 'f2cdd4a78d' into sync_cg_clif-2022-04-22 2022-04-22 21:11:38 +02:00
inline_asm.rs Take CodegenFnAttrs into account when validating asm! register operands 2022-02-21 18:28:22 +00:00
lib.rs Merge commit 'f2cdd4a78d' into sync_cg_clif-2022-04-22 2022-04-22 21:11:38 +02:00
linkage.rs Sync rustc_codegen_cranelift 'ddd4ce2553' 2021-04-30 14:49:58 +02:00
main_shim.rs Normalize main return type during mono item collection & codegen 2022-02-23 22:33:50 +01:00
num.rs Merge commit 'f2cdd4a78d' into sync_cg_clif-2022-04-22 2022-04-22 21:11:38 +02:00
pointer.rs Merge commit '0969bc6dde' into sync_cg_clif-2021-03-29 2021-03-29 10:45:09 +02:00
pretty_clif.rs Addressed comments by @compiler-errors and @bjorn3 2022-03-30 17:04:46 -04:00
toolchain.rs Unify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}. 2021-06-05 21:59:41 -07:00
trap.rs Merge commit '370c397ec9' into sync_cg_clif-2022-03-20 2022-03-20 16:55:21 +01:00
unsize.rs Improve AdtDef interning. 2022-03-11 13:31:24 +11:00
value_and_place.rs Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them. 2022-04-05 13:18:21 +00:00
vtable.rs Turn tcx.vtable_allocation() into a query. 2021-10-07 20:03:00 +02:00