forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#41135 - japaric:unstable-docs, r=steveklabnik
document some existing unstable features "msp430-interrupt", "ptx-kernel" and #![compiler_builtins_lib] r? @steveklabnik
- Loading branch information
Showing
4 changed files
with
123 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,60 @@ | ||
# `abi_ptx` | ||
|
||
The tracking issue for this feature is: None. | ||
The tracking issue for this feature is: [#38788] | ||
|
||
[#38788]: https://github.com/rust-lang/rust/issues/38788 | ||
|
||
------------------------ | ||
|
||
When emitting PTX code, all vanilla Rust functions (`fn`) get translated to | ||
"device" functions. These functions are *not* callable from the host via the | ||
CUDA API so a crate with only device functions is not too useful! | ||
|
||
OTOH, "global" functions *can* be called by the host; you can think of them | ||
as the real public API of your crate. To produce a global function use the | ||
`"ptx-kernel"` ABI. | ||
|
||
<!-- NOTE(ignore) this example is specific to the nvptx targets --> | ||
|
||
``` rust,ignore | ||
#![feature(abi_ptx)] | ||
#![no_std] | ||
pub unsafe extern "ptx-kernel" fn global_function() { | ||
device_function(); | ||
} | ||
pub fn device_function() { | ||
// .. | ||
} | ||
``` | ||
|
||
``` text | ||
$ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm | ||
$ cat $(find -name '*.s') | ||
// | ||
// Generated by LLVM NVPTX Back-End | ||
// | ||
.version 3.2 | ||
.target sm_20 | ||
.address_size 64 | ||
// .globl _ZN6kernel15global_function17h46111ebe6516b382E | ||
.visible .entry _ZN6kernel15global_function17h46111ebe6516b382E() | ||
{ | ||
ret; | ||
} | ||
// .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E | ||
.visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E() | ||
{ | ||
ret; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
# `compiler_builtins_lib` | ||
|
||
This feature is internal to the Rust compiler and is not intended for general use. | ||
The tracking issue for this feature is: None. | ||
|
||
------------------------ | ||
|
||
This feature is required to link to the `compiler_builtins` crate which contains | ||
"compiler intrinsics". Compiler intrinsics are software implementations of basic | ||
operations like multiplication of `u64`s. These intrinsics are only required on | ||
platforms where these operations don't directly map to a hardware instruction. | ||
|
||
You should never need to explicitly link to the `compiler_builtins` crate when | ||
building "std" programs as `compiler_builtins` is already in the dependency | ||
graph of `std`. But you may need it when building `no_std` **binary** crates. If | ||
you get a *linker* error like: | ||
|
||
``` text | ||
$PWD/src/main.rs:11: undefined reference to `__aeabi_lmul' | ||
$PWD/src/main.rs:11: undefined reference to `__aeabi_uldivmod' | ||
``` | ||
|
||
That means that you need to link to this crate. | ||
|
||
When you link to this crate, make sure it only appears once in your crate | ||
dependency graph. Also, it doesn't matter where in the dependency graph, you | ||
place the `compiler_builtins` crate. | ||
|
||
<!-- NOTE(ignore) doctests don't support `no_std` binaries --> | ||
|
||
``` rust,ignore | ||
#![feature(compiler_builtins_lib)] | ||
#![no_std] | ||
extern crate compiler_builtins; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# `compiler_builtins` | ||
|
||
The tracking issue for this feature is: None. | ||
This feature is internal to the Rust compiler and is not intended for general use. | ||
|
||
------------------------ | ||
|