Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6c19a10

Browse files
committedMar 27, 2020
Auto merge of #68404 - Amanieu:llvm-asm, r=estebank
Rename asm! to llvm_asm! As per rust-lang/rfcs#2843, this PR renames `asm!` to `llvm_asm!`. It also renames the compiler's internal `InlineAsm` data structures to `LlvmInlineAsm` in preparation for the new `asm!` functionality specified in rust-lang/rfcs#2850. This PR doesn't actually deprecate `asm!` yet, it just makes it redirect to `llvm_asm!`. This is necessary because we first need to update the submodules (in particular stdarch) to use `llvm_asm!`.
2 parents 7b73d14 + 1cc521e commit 6c19a10

File tree

136 files changed

+634
-588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+634
-588
lines changed
 

‎src/doc/unstable-book/src/library-features/asm.md renamed to ‎src/doc/unstable-book/src/library-features/llvm-asm.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# `asm`
1+
# `llvm_asm`
22

3-
The tracking issue for this feature is: [#29722]
3+
The tracking issue for this feature is: [#70173]
44

5-
[#29722]: https://github.com/rust-lang/rust/issues/29722
5+
[#70173]: https://github.com/rust-lang/rust/issues/70173
66

77
------------------------
88

99
For extremely low-level manipulations and performance reasons, one
1010
might wish to control the CPU directly. Rust supports using inline
11-
assembly to do this via the `asm!` macro.
11+
assembly to do this via the `llvm_asm!` macro.
1212

1313
```rust,ignore
14-
asm!(assembly template
14+
llvm_asm!(assembly template
1515
: output operands
1616
: input operands
1717
: clobbers
1818
: options
1919
);
2020
```
2121

22-
Any use of `asm` is feature gated (requires `#![feature(asm)]` on the
22+
Any use of `llvm_asm` is feature gated (requires `#![feature(llvm_asm)]` on the
2323
crate to allow) and of course requires an `unsafe` block.
2424

2525
> **Note**: the examples here are given in x86/x86-64 assembly, but
@@ -31,12 +31,12 @@ The `assembly template` is the only required parameter and must be a
3131
literal string (i.e. `""`)
3232

3333
```rust
34-
#![feature(asm)]
34+
#![feature(llvm_asm)]
3535

3636
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3737
fn foo() {
3838
unsafe {
39-
asm!("NOP");
39+
llvm_asm!("NOP");
4040
}
4141
}
4242

@@ -51,16 +51,16 @@ fn main() {
5151
}
5252
```
5353

54-
(The `feature(asm)` and `#[cfg]`s are omitted from now on.)
54+
(The `feature(llvm_asm)` and `#[cfg]`s are omitted from now on.)
5555

5656
Output operands, input operands, clobbers and options are all optional
5757
but you must add the right number of `:` if you skip them:
5858

5959
```rust
60-
# #![feature(asm)]
60+
# #![feature(llvm_asm)]
6161
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
6262
# fn main() { unsafe {
63-
asm!("xor %eax, %eax"
63+
llvm_asm!("xor %eax, %eax"
6464
:
6565
:
6666
: "eax"
@@ -73,10 +73,10 @@ asm!("xor %eax, %eax"
7373
Whitespace also doesn't matter:
7474

7575
```rust
76-
# #![feature(asm)]
76+
# #![feature(llvm_asm)]
7777
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
7878
# fn main() { unsafe {
79-
asm!("xor %eax, %eax" ::: "eax");
79+
llvm_asm!("xor %eax, %eax" ::: "eax");
8080
# } }
8181
# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
8282
# fn main() {}
@@ -89,12 +89,12 @@ Input and output operands follow the same format: `:
8989
expressions must be mutable lvalues, or not yet assigned:
9090

9191
```rust
92-
# #![feature(asm)]
92+
# #![feature(llvm_asm)]
9393
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
9494
fn add(a: i32, b: i32) -> i32 {
9595
let c: i32;
9696
unsafe {
97-
asm!("add $2, $0"
97+
llvm_asm!("add $2, $0"
9898
: "=r"(c)
9999
: "0"(a), "r"(b)
100100
);
@@ -116,11 +116,11 @@ operand. This is useful for very low level programming, where
116116
which register you use is important:
117117

118118
```rust
119-
# #![feature(asm)]
119+
# #![feature(llvm_asm)]
120120
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
121121
# unsafe fn read_byte_in(port: u16) -> u8 {
122122
let result: u8;
123-
asm!("in %dx, %al" : "={al}"(result) : "{dx}"(port));
123+
llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}"(port));
124124
result
125125
# }
126126
```
@@ -133,11 +133,11 @@ compiler not to assume any values loaded into those registers will
133133
stay valid.
134134

135135
```rust
136-
# #![feature(asm)]
136+
# #![feature(llvm_asm)]
137137
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
138138
# fn main() { unsafe {
139139
// Put the value 0x200 in eax:
140-
asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "eax");
140+
llvm_asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "eax");
141141
# } }
142142
# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
143143
# fn main() {}
@@ -167,12 +167,12 @@ Current valid options are:
167167
3. *intel* - use intel syntax instead of the default AT&T.
168168

169169
```rust
170-
# #![feature(asm)]
170+
# #![feature(llvm_asm)]
171171
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
172172
# fn main() {
173173
let result: i32;
174174
unsafe {
175-
asm!("mov eax, 2" : "={eax}"(result) : : : "intel")
175+
llvm_asm!("mov eax, 2" : "={eax}"(result) : : : "intel")
176176
}
177177
println!("eax is currently {}", result);
178178
# }
@@ -182,12 +182,12 @@ println!("eax is currently {}", result);
182182

183183
## More Information
184184

185-
The current implementation of the `asm!` macro is a direct binding to [LLVM's
185+
The current implementation of the `llvm_asm!` macro is a direct binding to [LLVM's
186186
inline assembler expressions][llvm-docs], so be sure to check out [their
187187
documentation as well][llvm-docs] for more information about clobbers,
188188
constraints, etc.
189189

190190
[llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions
191191

192192
If you need more power and don't mind losing some of the niceties of
193-
`asm!`, check out [global_asm](global-asm.md).
193+
`llvm_asm!`, check out [global_asm](global-asm.md).

‎src/libcore/hint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn black_box<T>(dummy: T) -> T {
113113
// box. This isn't the greatest implementation since it probably deoptimizes
114114
// more than we want, but it's so far good enough.
115115
unsafe {
116-
asm!("" : : "r"(&dummy));
116+
llvm_asm!("" : : "r"(&dummy));
117117
dummy
118118
}
119119
}

0 commit comments

Comments
 (0)
Please sign in to comment.