Commit Graph

46 Commits

Author SHA1 Message Date
Andreas Liljeqvist 86ff6aeb82 Fix docstring 2021-09-09 10:41:18 +02:00
Andreas Liljeqvist da92cd6dcf Use special Debug format when start > end 2021-09-09 10:41:18 +02:00
Andreas Liljeqvist f5d8749f85 Remove contains_zero, respect the compiler 2021-09-09 10:41:18 +02:00
Andreas Liljeqvist 021c3346ed derive Copy for WrappingRange and Scalar 2021-09-09 10:41:18 +02:00
Andreas Liljeqvist 4c46296f22 fix match 2021-09-09 10:41:18 +02:00
Andreas Liljeqvist 05cd48b008 Add methods for checking for full ranges to Scalar and WrappingRange
Move *_max methods back to util

change to inline instead of inline(always)

Remove valid_range_exclusive from scalar
Use WrappingRange instead

implement always_valid_for in a safer way

Fix accidental edit
2021-09-09 10:41:17 +02:00
Eduard-Mihai Burtescu 4ce933f13f rustc_target: move LayoutOf to ty::layout. 2021-09-02 01:17:14 +03:00
Eduard-Mihai Burtescu 78778fc6aa rustc_target: remove LayoutOf bound from TyAbiInterface. 2021-08-30 00:44:12 +03:00
Eduard-Mihai Burtescu 8e6d126b7d rustc_target: TyAndLayout::field should never error. 2021-08-30 00:44:09 +03:00
Eduard-Mihai Burtescu 87d1fb747f rustc_target: require TyAbiInterface in LayoutOf. 2021-08-27 13:09:32 +03:00
Eduard-Mihai Burtescu 8486571a10 rustc_target: rename TyAndLayoutMethods to TyAbiInterface. 2021-08-27 13:09:32 +03:00
Eduard-Mihai Burtescu 83d986aa28 rustc_target: add lifetime parameter to LayoutOf. 2021-08-27 13:09:32 +03:00
Eduard-Mihai Burtescu efb4148865 #[inline] non-generic pub fns in rustc_target::abi and ty::layout. 2021-08-26 21:47:42 +03:00
bors 4b9f4b221b Auto merge of #88308 - eddyb:cooked-layouts, r=nagisa
Morph `layout_raw` query into `layout_of`.

Before this PR, `LayoutCx::layout_of` wrapped the `layout_raw` query, to:
* normalize the type, before attempting to compute the layout
* pass the layout to `record_layout_for_printing`, for `-Zprint-type-sizes`

Moving those two responsibilities into the query may reduce overhead (due to cached calls skipping those steps), but I want to do a perf run to know.

One of the changes I had to make was changing the return type of the query, to be able to both get out the type produced by normalizing inside the query *and* to match the signature of the old `TyCtxt::layout_of`. This change may be worse, perf-wise, so that's another reason I want to check.

r? `@nagisa` cc `@oli-obk`
2021-08-26 15:24:01 +00:00
Erik Desjardins 4d635fdf63 use undef for uninitialized bytes in constants 2021-08-25 17:49:28 -04:00
Eduard-Mihai Burtescu edb4b2d8c2 Morph layout_raw query into layout_of. 2021-08-24 22:04:27 +03:00
Andreas Liljeqvist f17e384a43 use convention for with_* methods 2021-08-24 19:41:58 +02:00
Andreas Liljeqvist e3f07b2e30 Force inline: small functions and single call-site 2021-08-24 10:18:07 +02:00
Andreas Liljeqvist d92810646e Simplify zero check 2021-08-23 15:52:47 +02:00
Andreas Liljeqvist 32d7e5b723 add with_start and with_end 2021-08-23 15:44:56 +02:00
Andreas Liljeqvist d230b92ba7 implement debug in similar way to RangeInclusive 2021-08-23 15:05:40 +02:00
Andreas Liljeqvist e8e6d9bd86 Rename to WrappingRange 2021-08-23 14:24:34 +02:00
Andreas Liljeqvist 70433955f4 implement contains_zero method 2021-08-23 14:20:38 +02:00
Andreas Liljeqvist d50abd0249 Use ref 2021-08-23 14:18:48 +02:00
Andreas Liljeqvist 225a4bf922 Removed fixed fixme 2021-08-23 13:56:28 +02:00
Andreas Liljeqvist 5a501f73ff Use custom wrap-around type instead of Range 2021-08-22 21:46:03 +02:00
Manish Goregaokar fd116c806a Add c_enum_min_bits to target spec 2021-08-12 09:44:16 -07:00
Smitty bdfcb88e8b Use HTTPS links where possible 2021-06-23 16:26:46 -04:00
LeSeulArtichaut e3ca81fd5a Use the now available implementation of IntoIterator for arrays 2021-06-14 23:40:09 +02:00
LingMan 07dbd4d398 Use try_into instead of asserting manually 2021-06-07 01:27:40 +02:00
Tomasz Miąsko c1f6495b8e Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
Ralf Jung 563ab4a106 add Align::ONE; add methods to access alloc.extra 2021-05-18 19:33:55 +02:00
Nikita Popov dfc4cafe8e Move decision aboute noalias into codegen_llvm
The frontend shouldn't be deciding whether or not to use mutable
noalias attributes, as this is a pure LLVM concern. Only provide
the necessary information and do the actual decision in
codegen_llvm.
2021-03-21 20:10:53 +01:00
Simonas Kazlauskas 915a04e2a4 Consider Scalar to be a bool only if its unsigned
This seems right, given that conceptually bools are unsigned, but the
implications of this change may have more action at distance that I'm
not sure how to exhaustively consider.

For instance there are a number of cases where code attaches range
metadata if `scalar.is_bool()` holds. Supposedly it would no longer be
attached to the `repr(i8)` enums? Though I'm not sure why booleans are
being special-cased here in the first place...

Fixes #80556
2021-01-30 00:49:10 +02:00
Tomasz Miąsko 83dc7fe669 Inline trivial implementation of rustc_target::abi::Align 2021-01-27 16:13:18 +01:00
Yuki Okushi 56504a00f2 Rollup merge of #80042 - sivadeilra:cold_bits, r=oli-obk
Split a func into cold/hot parts, reducing binary size

I noticed that the Size::bits function is called in many places,
and is inlined into them. On x86_64-pc-windows-msvc, this function
is inlined 527 times, and compiled separately (non-inlined) 3 times.

Each of those inlined calls contains code that panics. This commit
moves the `panic!` call into a separate function and marks that
function with `#[cold]`.

This reduces binary size by 24 KB. Not much, but it's something.
Changes like this often reduce pressure on instruction-caches,
since it reduces the amount of code that is inlined into hot code
paths. Or more precisely, it removes cold code from hot cache lines.
2021-01-12 07:59:08 +09:00
Lzu Tao fa4d8bc878 Prefer enum Endian in rustc_target::Target 2021-01-06 13:34:19 +00:00
Arlie Davis 4721b6518c Split a func into cold/hot parts, reducing binary size
I noticed that the Size::bits function is called in many places,
and is inlined into them. On x86_64-pc-windows-msvc, this function
is inlined 527 times, and compiled separately (non-inlined) 3 times.

Each of those inlined calls contains code that panics. This commit
moves the `panic!` call into a separate function and marks that
function with `#[cold]`.

This reduces binary size by 24 KB. By itself, that's not a substantial
reduction. However, changes like this often reduce pressure on
instruction-caches, since it reduces the amount of code that is inlined
into hot code paths. Or more precisely, it removes cold code from hot
cache lines. It also removes all conditionals from Size::bits(),
which is called in many places.
2021-01-05 12:52:34 -08:00
Vadim Petrochenkov dc004d4809 rustc_target: Rename some target options to avoid tautology
`target.target_endian` -> `target.endian`
`target.target_c_int_width` -> `target.c_int_width`
`target.target_os` -> `target.os`
`target.target_env` -> `target.env`
`target.target_vendor` -> `target.vendor`
`target.target_family` -> `target.os_family`
`target.target_mcount` -> `target.mcount`
2020-11-08 17:29:13 +03:00
Oli Scherer 332750f9eb Update compiler/rustc_target/src/abi/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 15:13:06 +01:00
Oli Scherer 5f087f089f Update compiler/rustc_target/src/abi/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 15:12:44 +01:00
oli abacaf2aef u128 truncation and sign extension are not just interpreter related 2020-11-04 13:41:58 +00:00
Joshua Nelson 57c6ed0c07 Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
est31 0d1aa1e034 Rename target_pointer_width to pointer_width and turn it into an u32
Rename target_pointer_width to pointer_width because it is already
member of the Target struct.

The compiler supports only three valid values for target_pointer_width:
16, 32, 64. Thus it can safely be turned into an int.
This means less allocations and clones as well as easier handling of the type.
2020-10-15 12:02:23 +02:00
Ralf Jung 6f881b3b7d might_permit_raw_init: also check aggregate fields 2020-09-26 12:29:01 +02:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00