Commit Graph

43 Commits

Author SHA1 Message Date
Scott McMurray
6965b4a8bd Remove Rvalue::CheckedBinaryOp 2024-05-17 20:33:02 -07:00
Michael Goulet
0a67bf1b8a Make builtin_deref just return a Ty 2024-05-09 22:55:00 -04:00
bjorn3
f91bd7882f Merge commit 'fbda869b4e230c788b6bce426038ba8419956f2d' into sync_cg_clif-2024-04-05 2024-04-05 16:20:23 +00:00
Scott McMurray
629a772585 Add+Use mir::BinOp::Cmp 2024-03-23 23:23:41 -07:00
Boxy
40de0c2765 Move TyCtxt::mk_x to Ty::new_x where applicable 2023-07-05 20:27:07 +01:00
Scott McMurray
9efe5e746a Promote unchecked_add/sub/mul/shl/shr to mir::BinOp 2023-06-19 01:47:03 -07:00
bjorn3
8bf550e616 Merge commit 'ef07e8e60f994ec014d049a95591426fb92ebb79' into sync_cg_clif-2023-04-29 2023-04-29 12:00:43 +00:00
bors
e42bea9fde Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiasko
Implement checked Shl/Shr at MIR building.

This does not require any special handling by codegen backends,
as the overflow behaviour is entirely determined by the rhs (shift amount).

This allows MIR ConstProp to remove the overflow check for constant shifts.

~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).`
I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~

EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
2023-03-15 21:31:06 +00:00
bjorn3
7b3bd56ed9 Merge commit 'dec0daa8f6d0a0e1c702f169abb6bf3eee198c67' into sync_cg_clif-2023-03-15 2023-03-15 14:41:48 +00:00
Camille GILLOT
760275d81e Implement checked Shl/Shr at MIR building. 2023-02-27 19:25:16 +00:00
Nicholas Nethercote
eb84167837 Rename many interner functions.
(This is a large commit. The changes to
`compiler/rustc_middle/src/ty/context.rs` are the most important ones.)

The current naming scheme is a mess, with a mix of `_intern_`, `intern_`
and `mk_` prefixes, with little consistency. In particular, in many
cases it's easy to use an iterator interner when a (preferable) slice
interner is available.

The guiding principles of the new naming system:
- No `_intern_` prefixes.
- The `intern_` prefix is for internal operations.
- The `mk_` prefix is for external operations.
- For cases where there is a slice interner and an iterator interner,
  the former is `mk_foo` and the latter is `mk_foo_from_iter`.

Also, `slice_interners!` and `direct_interners!` can now be `pub` or
non-`pub`, which helps enforce the internal/external operations
division.

It's not perfect, but I think it's a clear improvement.

The following lists show everything that was renamed.

slice_interners
- const_list
  - mk_const_list -> mk_const_list_from_iter
  - intern_const_list -> mk_const_list
- substs
  - mk_substs -> mk_substs_from_iter
  - intern_substs -> mk_substs
  - check_substs -> check_and_mk_substs (this is a weird one)
- canonical_var_infos
  - intern_canonical_var_infos -> mk_canonical_var_infos
- poly_existential_predicates
  - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter
  - intern_poly_existential_predicates -> mk_poly_existential_predicates
  - _intern_poly_existential_predicates -> intern_poly_existential_predicates
- predicates
  - mk_predicates -> mk_predicates_from_iter
  - intern_predicates -> mk_predicates
  - _intern_predicates -> intern_predicates
- projs
  - intern_projs -> mk_projs
- place_elems
  - mk_place_elems -> mk_place_elems_from_iter
  - intern_place_elems -> mk_place_elems
- bound_variable_kinds
  - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter
  - intern_bound_variable_kinds -> mk_bound_variable_kinds

direct_interners
- region
  - intern_region (unchanged)
- const
  - mk_const_internal -> intern_const
- const_allocation
  - intern_const_alloc -> mk_const_alloc
- layout
  - intern_layout -> mk_layout
- adt_def
  - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid)
  - alloc_adt_def(!) -> mk_adt_def
- external_constraints
  - intern_external_constraints -> mk_external_constraints

Other
- type_list
  - mk_type_list -> mk_type_list_from_iter
  - intern_type_list -> mk_type_list
- tup
  - mk_tup -> mk_tup_from_iter
  - intern_tup -> mk_tup
2023-02-24 07:32:24 +11:00
Nicholas Nethercote
8fe8e53300 Replace mk_foo calls with infer_foo where possible.
There are several `mk_foo`/`intern_foo` pairs, where the former takes an
iterator and the latter takes a slice. (This naming convention is bad,
but that's a fix for another PR.)

This commit changes several `mk_foo` occurrences into `intern_foo`,
avoiding the need for some `.iter()`/`.into_iter()` calls. Affected
cases:
- mk_type_list
- mk_tup
- mk_substs
- mk_const_list
2023-02-17 22:24:31 +11:00
bjorn3
98a276b589 Merge commit '2bb3996244cf1b89878da9e39841e9f6bf061602' into sync_cg_clif-2022-12-14 2022-12-14 19:30:46 +01:00
bjorn3
9950bd1dc5 Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23 2022-10-23 16:22:55 +02:00
bjorn3
32202f20cd Merge commit 'f2cdd4a78d89c009342197cf5844a21f8aa813df' into sync_cg_clif-2022-04-22 2022-04-22 21:11:38 +02:00
bjorn3
d220159810 Merge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
Erin Power
ee570b1302 Sync rustc_codegen_cranelift 'ddd4ce25535cf71203ba3700896131ce55fde795' 2021-04-30 14:49:58 +02:00
bjorn3
07968a001d Merge commit '0969bc6dde001e01e7e1f58c8ccd7750f8a49ae1' into sync_cg_clif-2021-03-29 2021-03-29 10:45:09 +02:00
bjorn3
27886cd6b6 Merge commit '9a0c32934ebe376128230aa8da3275697b2053e7' into sync_cg_clif-2021-03-05 2021-03-05 19:12:59 +01:00
bjorn3
a75f9bc3be Merge commit 'd556c56f792756dd7cfec742b9f2e07612dc10f4' into sync_cg_clif-2021-02-01 2021-02-01 10:11:46 +01:00
bjorn3
285c7c66dc Merge commit '03f01bbe901d60b71cf2c5ec766aef5e532ab79d' into update_cg_clif-2020-11-01 2020-11-03 11:00:04 +01:00
bjorn3
0a5968dfd2 Use the new cranelift-module interface
This updates Cranelift to include bytecodealliance/wasmtime#2249
2020-10-08 19:00:21 +02:00
bjorn3
c8699076f9 Document almost all modules
Fixes #1082
2020-09-23 15:13:49 +02:00
bjorn3
217b3818b7 Rustup to rustc 1.48.0-nightly (c59199efc 2020-09-04) 2020-09-05 10:38:49 +02:00
CohenArthur
4e685a512e fmt: Run cargo fmt since it is available 2020-08-28 12:10:48 +02:00
bjorn3
cc0268fa1a Mask shift amount 2020-06-30 18:56:53 +02:00
bjorn3
5f54cc7658 Implement checked_mul
Fixes #6
2020-06-20 15:15:28 +02:00
bjorn3
ef4186a85b Use Cranelift legalization for icmp.i128
The previous translation was wrong for signed 128bit comparisions

This fixes several libcore tests
2020-06-20 13:23:31 +02:00
bjorn3
f288959c00 Limit publicness to crate where possible and remove unused imports 2020-03-27 12:14:45 +01:00
bjorn3
74c7a7b7c5 Replace unimplemented! with unreachable! when it will never be supported 2020-01-25 16:24:48 +01:00
bjorn3
217beab62a Reduce the amount of calls to layout_of 2020-01-15 13:18:54 +01:00
bjorn3
44792f1089 Rustup to rustc 1.40.0-nightly (084beb83e 2019-09-27) 2019-09-28 14:06:12 +02:00
bjorn3
77d33c1707 Fix trans_ptr_binop for fn() 2019-09-15 18:35:56 +02:00
bjorn3
c34ada7cca Fix foreign type handling 2019-09-14 17:53:36 +02:00
bjorn3
8f12b87542 Implement shl and shr overflow checks
cc #6
2019-09-14 12:13:23 +02:00
Atul Bhosale
f481a4b685
Format code using 'cargo fmt' 2019-08-31 22:58:09 +05:30
bjorn3
2a20cc0b94 Use anonymous lifetimes where possible 2019-08-18 16:52:07 +02:00
bjorn3
43e68319fa Rustup to rustc 1.39.0-nightly (2111aed0a 2019-08-17) 2019-08-18 11:30:13 +02:00
bjorn3
7c7a8e8367 Workaround for missing icmp{,_imm}.i128 legalizations
Fixes #667
2019-08-15 11:36:23 +02:00
bjorn3
9505d60a24 Cast rhs to lhs type for shl and shr 2019-08-14 15:18:05 +02:00
bjorn3
b4e55cdedd Refactor num.rs 2019-08-14 15:03:52 +02:00
bjorn3
db071db95a Calculate sign in trans{,_checked}_int_binop instead of caller 2019-08-14 13:01:55 +02:00
bjorn3
883894a07a Move trans_*_binop to num.rs 2019-08-14 11:52:39 +02:00