Commit Graph

87 Commits

Author SHA1 Message Date
Eduard-Mihai Burtescu
08f9f134fd rustc: hide details in Layout in favor of Abi or FieldPlacement. 2017-11-19 02:14:31 +02:00
Eduard-Mihai Burtescu
bd51a2bc19 rustc: move size/alignment from Layout into layout::Abi. 2017-11-19 02:14:31 +02:00
Eduard-Mihai Burtescu
d318b9c27b rustc: move CEnum's signedness into Primitive::Int. 2017-11-19 02:14:30 +02:00
Eduard-Mihai Burtescu
61c2bd9ca4 rustc: use Primitive instead of Integer for CEnum and General discriminants. 2017-11-19 02:14:30 +02:00
Eduard-Mihai Burtescu
335bd8ea1b rustc: do not track non_zero in Layout. 2017-11-19 02:14:30 +02:00
Eduard-Mihai Burtescu
caef91d7c6 rustc: introduce layout::Abi for reduced general ABI "passing style". 2017-11-19 02:14:30 +02:00
Eduard-Mihai Burtescu
9a0efea4c2 rustc: pre-compute field placements out of Layout. 2017-11-19 02:14:29 +02:00
Eduard-Mihai Burtescu
8c4d5af52b rustc: remove Ty::layout and move everything to layout_of. 2017-11-19 02:14:29 +02:00
Eduard-Mihai Burtescu
8864668d53 rustc: re-complicate the TyLayout API and use better names. 2017-11-19 02:14:29 +02:00
Eduard-Mihai Burtescu
bc8e1f7efa rustc: use an offset instead of a field path in Layout::StructWrappedNullablePointer. 2017-11-19 02:14:29 +02:00
Eduard-Mihai Burtescu
84b5a3d84d rustc_trans: remove the in_memory_type_of distinction. 2017-11-19 02:14:28 +02:00
Eduard-Mihai Burtescu
5b1fdaeb80 rustc_trans: use more of the trans::mir and ty::layout APIs throughout. 2017-11-19 02:14:28 +02:00
Eduard-Mihai Burtescu
f44b099187 rustc_trans: avoid working with sizes/offsets and alignments as integers. 2017-11-19 02:14:24 +02:00
Björn Steinbrink
6bfecd41cc Avoid unnecessary allocas for indirect function arguments
The extra alloca was only necessary because it made LLVM implicitly
handle the necessary deref to get to the actual value. The same happens
for indirect arguments that have the byval attribute. But the Rust ABI
does not use the byval attribute and so we need to manually add the
deref operation to the debuginfo.
2017-10-18 12:58:15 +02:00
bors
97554e4b28 Auto merge of #45033 - eddyb:capture-me-not, r=nikomatsakis
rustc_trans: do not set NoCapture for anonymous lifetime &T arguments.

This was both unsound (due to lifetime elision & unsafe code) and dead code (we erase lifetimes).

r? @nikomatsakis
2017-10-09 00:18:51 +00:00
Eduard-Mihai Burtescu
ac25a4ac32 rustc_trans: do not set NoCapture for anonymous lifetime &T arguments. 2017-10-05 01:06:14 +03:00
Alexis Beingessner
a6dea41d64 Make -Cpanic=abort imply -Zmutable-noalias 2017-10-04 17:29:37 -04:00
Alexis Beingessner
36471293e6 Add -Zmutable-noalias flag 2017-10-03 19:49:45 -04:00
bors
3a7b960731 Auto merge of #44441 - tamird:cargo-bitflags, r=alexcrichton
Remove rustc_bitflags; use the bitflags crate

r? @alexcrichton
2017-09-18 07:00:28 +00:00
Tamir Duberstein
231d9e7e5d
Remove rustc_bitflags; use the bitflags crate 2017-09-17 14:19:24 -04:00
Alex Crichton
c72240acf7 rustc_trans: Refactor collection to use tcx
This commit refactors the `collect_crate_translation_items` function to only
require the `TyCtxt` instead of a `SharedCrateContext` in preparation for
query-ifying this portion of trans.
2017-09-17 09:41:43 -07:00
Eduard-Mihai Burtescu
3ce31eb990 rustc: replace usize with u64 and ConstUsize. 2017-09-11 08:41:15 +03:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Josh Stone
5c6ccdc37c Correct the spelling of "homogeneous" 2017-07-21 18:08:40 -07:00
Ariel Ben-Yehuda
24c1a07c72 refactor trans::mir::block to trans all calls through the same code 2017-05-28 10:43:24 +03:00
Nathan Froyd
9a2e2450f9 add thiscall calling convention support
This support is needed for bindgen to work well on 32-bit Windows, and
also enables people to begin experimenting with C++ FFI support on that
platform.

Fixes #42044.
2017-05-24 16:40:03 -04:00
Michael Wu
c558a2ae37 Add Hexagon support
This requires an updated LLVM with D31999 and D32000 to build libcore.

A basic hello world builds and runs successfully on the hexagon simulator.
2017-04-25 01:56:44 -04:00
bors
6d841da4a0 Auto merge of #39999 - bitshifter:struct_align, r=eddyb
Implementation of repr struct alignment RFC 1358.

The main changes around rustc::ty::Layout::struct:
* Added abi_align field which stores abi alignment before repr align is applied
* align field contains transitive repr alignment
* Added padding vec which stores padding required after fields

The main user of this information is rustc_trans::adt::struct_llfields
which determines the LLVM fields to be used by LLVM, including padding
fields.

A possible future optimisation would be to put the padding Vec in an Option, since it will be unused unless you are using repr align.
2017-04-22 11:50:40 +00:00
Cameron Hart
4358e35fda Implementation of repr struct alignment RFC 1358.
The main changes around rustc::ty::Layout::struct and rustc_trans:adt:
* Added primitive_align field which stores alignment before repr align
* Always emit field padding when generating the LLVM struct fields
* Added methods for adjusting field indexes from the layout index to the
  LLVM struct field index

The main user of this information is rustc_trans::adt::struct_llfields
which determines the LLVM fields to be used by LLVM, including padding
fields.
2017-04-21 07:32:32 +10:00
Eduard-Mihai Burtescu
6563374ed2 rustc: replace interior_unsafe with a Freeze trait. 2017-04-20 14:39:31 +03:00
Eduard-Mihai Burtescu
0303a3364b Fix pairs of doubles using an illegal <8 x i8> vector. 2017-04-11 11:33:30 +03:00
Eduard-Mihai Burtescu
f0636b61c7 rustc_trans: use ty::layout for ABI computation instead of LLVM types. 2017-04-09 16:06:56 +03:00
Eduard-Mihai Burtescu
43b227f3bd rustc: add some abstractions to ty::layout for a more concise API. 2017-04-08 23:41:18 +03:00
Eduard-Mihai Burtescu
c977daf97c rustc_trans: avoid sizing_type_of everywhere possible. 2017-04-08 23:40:54 +03:00
Niko Matsakis
6a47fa1d3d remove unneeded & that now fails to coerce
cc https://github.com/rust-lang/rust/issues/40924
2017-03-30 07:55:29 -04:00
Oliver Schneider
eb447f4ef4
Fix various useless derefs and slicings 2017-03-27 08:58:00 +02:00
Ariel Ben-Yehuda
f2c7917402 translate drop glue using MIR
Drop of arrays is now translated in trans::block in an ugly way that I
should clean up in a later PR, and does not handle panics in the middle
of an array drop, but this commit & PR are growing too big.
2017-03-18 02:53:08 +02:00
Ariel Ben-Yehuda
65a4266f1f refactor away callee::Callee and translate virtual calls through a MIR shim
These changes are in the same commit to avoid needing to adapt
meth::trans_object_shim to the new scheme.

One codegen-units test is broken because we instantiate the shims even
when they are not needed. This will be fixed in the next PR.
2017-03-18 02:53:07 +02:00
Philipp Oppermann
b44805875e Add support for x86-interrupt calling convention
Tracking issue: https://github.com/rust-lang/rust/issues/40180

This calling convention can be used for definining interrupt handlers on
32-bit and 64-bit x86 targets. The compiler then uses `iret` instead of
`ret` for returning and ensures that all registers are restored to their
original values.

Usage:

```
extern "x86-interrupt" fn handler(stack_frame: &ExceptionStackFrame) {…}
```

for interrupts and exceptions without error code and

```
extern "x86-interrupt" fn page_fault_handler(stack_frame: &ExceptionStackFrame,
                                             error_code: u64) {…}
```

for exceptions that push an error code (e.g., page faults or general
protection faults). The programmer must ensure that the correct version
is used for each interrupt.

For more details see the [LLVM PR][1] and the corresponding [proposal][2].

[1]: https://reviews.llvm.org/D15567
[2]: http://lists.llvm.org/pipermail/cfe-dev/2015-September/045171.html
2017-03-02 19:01:15 +01:00
Eduard-Mihai Burtescu
91374f8fe4 rustc: combine BareFnTy and ClosureTy into FnSig. 2017-02-25 17:47:15 +02:00
James Miller
7af3406a49 Set metadata for vtable-related loads
Give LLVM much more information about vtable pointers. Without the extra
information, LLVM has to be rather pessimistic about vtables, preventing
a number of obvious optimisations.

* Makes the vtable pointer argument noalias and readonly.
* Marks loads of the vtable pointer as nonnull.
* Marks load from the vtable with `!invariant.load` metadata.

Fixes #39992
2017-02-21 21:08:06 +13:00
Andrew Cann
2cc84df44c Add warning for () to ! switch 2017-02-03 18:48:15 +08:00
Vadim Petrochenkov
ffba0cea62 Merge ty::TyBox into ty::TyAdt 2017-01-30 23:14:15 +03:00
Jorge Aparicio
6296d52ba6 calling convention for MSP430 interrupts
This calling convention is used to define interrup handlers on MSP430
microcontrollers. Usage looks like this:

``` rust
#[no_mangle]
#[link_section = "__interrupt_vector_10"]
pub static TIM0_VECTOR: unsafe extern "msp430-interrupt" fn() = tim0;

unsafe extern "msp430-interrupt" fn tim0() {
  P1OUT.write(0x00);
}
```

which generates the following assembly:

``` asm
Disassembly of section __interrupt_vector_10:

0000fff2 <TIM0_VECTOR>:
    fff2:       10 c0           interrupt service routine at 0xc010

Disassembly of section .text:

0000c010 <_ZN3msp4tim017h3193b957fd6a4fd4E>:
    c010:       c2 43 21 00     mov.b   #0,     &0x0021 ;r3 As==00
    c014:       00 13           reti
        ...
```
2017-01-18 20:42:54 -05:00
Mark Simulacrum
ba37c91831 Fix style nit 2017-01-04 11:38:10 -07:00
Mark Simulacrum
1be170b01a Replace BlockAndBuilder with Builder. 2017-01-04 11:33:31 -07:00
bors
d40d01bd0e Auto merge of #38670 - dotdash:transmute_align, r=eddyb
Fix transmute::<T, U> where T requires a bigger alignment than U

For transmute::<T, U> we simply pointercast the destination from a U
pointer to a T pointer, without providing any alignment information,
thus LLVM assumes that the destination is aligned to hold a value of
type T, which is not necessarily true. This can lead to LLVM emitting
machine instructions that assume said alignment, and thus cause aborts.

To fix this, we need to provide the actual alignment to store_operand()
and in turn to store() so they can set the proper alignment information
on the stores and LLVM can emit the proper machine instructions.

Fixes #32947
2017-01-04 14:26:17 +00:00
Seo Sanghyeon
b14785d3d0 Merge branch 'master' into sparc64 2017-01-01 12:40:10 +09:00
Björn Steinbrink
71a11a0b10 Fix transmute::<T, U> where T requires a bigger alignment than U
For transmute::<T, U> we simply pointercast the destination from a U
pointer to a T pointer, without providing any alignment information,
thus LLVM assumes that the destination is aligned to hold a value of
type T, which is not necessarily true. This can lead to LLVM emitting
machine instructions that assume said alignment, and thus cause aborts.

To fix this, we need to provide the actual alignment to store_operand()
and in turn to store() so they can set the proper alignment information
on the stores and LLVM can emit the proper machine instructions.

Fixes #32947
2016-12-31 13:13:30 +01:00
Simonas Kazlauskas
ee69cd7925 Calculate discriminant bounds within 64 bits
Since discriminants do not support i128 yet, lets just calculate the boundaries within the 64 bits
that are supported. This also avoids an issue with bootstrapping on 32 bit systems due to #38727.
2016-12-31 04:55:29 +02:00