File tree Expand file tree Collapse file tree 4 files changed +122
-4
lines changed
src/doc/unstable-book/src Expand file tree Collapse file tree 4 files changed +122
-4
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,38 @@ The tracking issue for this feature is: [#38487]
55[ #38487 ] : https://github.com/rust-lang/rust/issues/38487
66
77------------------------
8+
9+ In the MSP430 architecture, interrupt handlers have a special calling
10+ convention. You can use the ` "msp430-interrupt" ` ABI to make the compiler apply
11+ the right calling convention to the interrupt handlers you define.
12+
13+ <!-- NOTE(ignore) this example is specific to the msp430 target -->
14+
15+ ``` rust,ignore
16+ #![feature(abi_msp430_interrupt)]
17+ #![no_std]
18+
19+ // Place the interrupt handler at the appropriate memory address
20+ // (Alternatively, you can use `#[used]` and remove `pub` and `#[no_mangle]`)
21+ #[link_section = "__interrupt_vector_10"]
22+ #[no_mangle]
23+ pub static TIM0_VECTOR: extern "msp430-interrupt" fn() = tim0;
24+
25+ // The interrupt handler
26+ extern "msp430-interrupt" fn tim0() {
27+ // ..
28+ }
29+ ```
30+
31+ ``` text
32+ $ msp430-elf-objdump -CD ./target/msp430/release/app
33+ Disassembly of section __interrupt_vector_10:
34+
35+ 0000fff2 <TIM0_VECTOR>:
36+ fff2: 00 c0 interrupt service routine at 0xc000
37+
38+ Disassembly of section .text:
39+
40+ 0000c000 <int::tim0>:
41+ c000: 00 13 reti
42+ ```
Original file line number Diff line number Diff line change 11# ` abi_ptx `
22
3- The tracking issue for this feature is: None.
3+ The tracking issue for this feature
4+ is: [ 38788] ( https://github.com/rust-lang/rust/issues/38788 )
45
56------------------------
7+
8+ When emitting PTX code, all vanilla Rust functions (` fn ` ) get translated to
9+ "device" functions. These functions are * not* callable from the host via the
10+ CUDA API so a crate with only device functions is not too useful!
11+
12+ OTOH, "global" functions * can* be called by the host; you can think of them
13+ as the real public API of your crate. To produce a global function use the
14+ ` "ptx-kernel" ` ABI.
15+
16+ <!-- NOTE(ignore) this example is specific to the nvptx targets -->
17+
18+ ``` rust,ignore
19+ #![feature(abi_ptx)]
20+ #![no_std]
21+
22+ pub unsafe extern "ptx-kernel" fn global_function() {
23+ device_function();
24+ }
25+
26+ pub fn device_function() {
27+ // ..
28+ }
29+ ```
30+
31+ ``` text
32+ $ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm
33+
34+ $ cat $(find -name '*.s')
35+ //
36+ // Generated by LLVM NVPTX Back-End
37+ //
38+
39+ .version 3.2
40+ .target sm_20
41+ .address_size 64
42+
43+ // .globl _ZN6kernel15global_function17h46111ebe6516b382E
44+
45+ .visible .entry _ZN6kernel15global_function17h46111ebe6516b382E()
46+ {
47+
48+
49+ ret;
50+ }
51+
52+ // .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E
53+ .visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E()
54+ {
55+
56+
57+ ret;
58+ }
59+ ```
Original file line number Diff line number Diff line change 11# ` compiler_builtins_lib `
22
3- This feature is internal to the Rust compiler and is not intended for general use .
3+ The tracking issue for this feature is: None .
44
55------------------------
6+
7+ This feature is required to link to the ` compiler_builtins ` crate which contains
8+ "compiler intrinsics". Compiler intrinsics are software implementations of basic
9+ operations like multiplication of ` u64 ` s. These intrinsics are only required on
10+ platforms where these operations don't directly map to a hardware instruction.
11+
12+ You should never need to explicitly link to the ` compiler_builtins ` crate when
13+ building "std" programs as ` compiler_builtins ` is already in the dependency
14+ graph of ` std ` . But you may need it when building ` no_std ` ** binary** crates. If
15+ you get a * linker* error like:
16+
17+ ``` text
18+ $PWD/src/main.rs:11: undefined reference to `__aeabi_lmul'
19+ $PWD/src/main.rs:11: undefined reference to `__aeabi_uldivmod'
20+ ```
21+
22+ That means that you need to link to this crate.
23+
24+ When you link to this crate, make sure it only appears once in your crate
25+ dependency graph. Also, it doesn't matter where in the dependency graph, you
26+ place the ` compiler_builtins ` crate.
27+
28+ <!-- NOTE(ignore) doctests don't support `no_std` binaries -->
29+
30+ ``` rust,ignore
31+ #![feature(compiler_builtins_lib)]
32+ #![no_std]
33+
34+ extern crate compiler_builtins;
35+ ```
Original file line number Diff line number Diff line change 11# ` compiler_builtins `
22
3- The tracking issue for this feature is: None .
3+ This feature is internal to the Rust compiler and is not intended for general use .
44
55------------------------
6-
You can’t perform that action at this time.
0 commit comments