about summary refs log tree commit diff
path: root/src/test/ui/asm
AgeCommit message (Collapse)AuthorLines
2021-03-27Rollup merge of #83328 - tmiasko:asm-test, r=joshtriplettYuki Okushi-2/+2
Fixes to inline assmebly tests * Join test thread to make assertion effective in sym.rs test case * Use a single codegen unit to reduce non-determinism in srcloc.rs test #82886
2021-03-26Rollup merge of #83485 - Amanieu:asm_llvm10, r=joshtriplettDylan DPC-3/+3
Mark asm tests as requiring LLVM 10.0.1
2021-03-25Mark inline asm tests as requiring LLVM 10.0.1Amanieu d'Antras-3/+3
2021-03-25Refactor #82270 as lint instead of an errorAmanieu d'Antras-46/+103
2021-03-20add arm llvm requirementasquared31415-8/+9
2021-03-20Join test thread to make assertion effective in sym.rs test caseTomasz Miąsko-1/+1
2021-03-20Use a single codegen unit to reduce non-determinism in srcloc.rs testTomasz Miąsko-1/+1
When building with multiple codegen units the test case can fail with only a subset of all errors. Use a single codegen unit as a workaround.
2021-03-08Test x86 and arm outputsasquared31415-13/+42
2021-02-20Take into account target default syntaxasquared31415-12/+35
2021-02-18Emit error when trying to use assembler syntax directives in `asm!`asquared31415-0/+50
2020-12-07Validate naked functions definitionsTomasz Miąsko-95/+469
2020-12-01Auto merge of #78684 - devsnek:inline-asm-wasm, r=Amanieubors-2/+2
Add wasm32 support to inline asm There is some contention around inline asm and wasm, and I really only made this to figure out the process of hacking on rustc, but I figured as long as the code existed, it was worth uploading. cc `@Amanieu`
2020-12-01Add wasm32 support to inline asmGus Caplan-2/+2
2020-11-26Bless test.Camille GILLOT-8/+8
2020-11-25Validate use of parameters in naked functionsTomasz Miąsko-0/+95
* Reject use of parameters inside naked function body. * Reject use of patterns inside function parameters, to emphasize role of parameters a signature declaration (mirroring existing behaviour for function declarations) and avoid generating code introducing specified bindings.
2020-11-24Validate that `#[naked]` is applied to a function definitionTomasz Miąsko-0/+93
2020-10-06builtin_macros: Fix use of interpolated identifiers in `asm!`Vadim Petrochenkov-0/+75
2020-09-02pretty: trim paths of unique symbolsDan Aloni-9/+9
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-08-09tests: Mark `ui/asm/bad-arch.rs` as requiring wasm llvm backendVadim Petrochenkov-1/+2
2020-08-06Fix ICE when using asm! on an unsupported architectureAmanieu d'Antras-0/+26
Fixes #75220
2020-07-14Remove `Sized` `on_unimplemented` noteEsteban Küber-3/+0
2020-07-10Avoid "whitelist"Tamir Duberstein-1/+1
Other terms are more inclusive and precise.
2020-06-30Stabilize `#[track_caller]`.Adam Perry-1/+1
Does not yet make its constness stable, though. Use of `Location::caller` in const contexts is still gated by `#![feature(const_caller_location)]`.
2020-06-20Fix duplicate options errorCamelid-9/+9
The UI isn't glitching anymore.
2020-06-20Make suggestion machine-applicableCamelid-10/+37
2020-06-20Add more to duplicate options testCamelid-1/+26
2020-06-20Use `span_suggestion` instead of `span_label`Camelid-6/+6
2020-06-20Update duplicate options testCamelid-53/+11
2020-06-20Make warning an error; use help instead of suggestion; clean up codeCamelid-25/+66
For some reason, the help message is now in a separate message, which adds a lot of noise. I would like to try to get it back to one message.
2020-06-20Add UI test for duplicate `asm!` options warningCamelid-0/+57
2020-06-20Update testsCamelid-41/+12
2020-06-15asm: Allow multiple template strings; interpret them as newline-separatedJosh Triplett-5/+325
Allow the `asm!` macro to accept a series of template arguments, and interpret them as if they were concatenated with a '\n' between them. This allows writing an `asm!` where each line of assembly appears in a separate template string argument. This syntax makes it possible for rustfmt to reliably format and indent each line of assembly, without risking changes to the inside of a template string. It also avoids the complexity of having the user carefully format and indent a multi-line string (including where to put the surrounding quotes), and avoids the extra indentation and lines of a call to `concat!`. For example, rewriting the second example from the [blog post on the new inline assembly syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html) using multiple template strings: ```rust fn main() { let mut bits = [0u8; 64]; for value in 0..=1024u64 { let popcnt; unsafe { asm!( " popcnt {popcnt}, {v}", "2:", " blsi rax, {v}", " jz 1f", " xor {v}, rax", " tzcnt rax, rax", " stosb", " jmp 2b", "1:", v = inout(reg) value => _, popcnt = out(reg) popcnt, out("rax") _, // scratch inout("rdi") bits.as_mut_ptr() => _, ); } println!("bits of {}: {:?}", value, &bits[0..popcnt]); } } ``` Note that all the template strings must appear before all other arguments; you cannot, for instance, provide a series of template strings intermixed with the corresponding operands. In order to get srcloc mappings right for macros that generate multi-line string literals, create one line_span for each line in the string literal, each pointing to the macro. Make `rustc_parse_format::Parser::curarg` `pub`, so that we can propagate it from one template string argument to the next.
2020-06-12Rollup merge of #73033 - Amanieu:asm-tls, r=oli-obkDylan DPC-5/+47
Fix #[thread_local] statics as asm! sym operands The `asm!` RFC specifies that `#[thread_local]` statics may be used as `sym` operands for inline assembly. This also fixes a regression in the handling of `#[thread_local]` during monomorphization which caused link-time errors with multiple codegen units, most likely introduced by #71192. r? @oli-obk
2020-06-11Rollup merge of #73230 - Amanieu:asm-unused2, r=petrochenkovDylan DPC-1/+21
Suggest including unused asm arguments in a comment to avoid error We require all arguments to an `asm!` to be used in the template string, just like format strings. However in some cases (e.g. `black_box`) it may be desirable to have `asm!` arguments that are not used in the template string. Currently this is a hard error rather than a lint since `#[allow]` does not work on macros (#63221), so this PR suggests using the unused arguments in an asm comment as a workaround. r? @petrochenkov
2020-06-11Add a suggestion to use unused asm arguments in commentsAmanieu d'Antras-1/+21
2020-06-09Handle assembler warnings properlyAmanieu d'Antras-1/+16
2020-06-06Fix #[thread_local] statics as asm! sym operandsAmanieu d'Antras-5/+47
2020-06-05add test for #72960Matthias Krüger-1/+3
Fixes #72960
2020-05-31Clarify errors and warnings about the transition to the new asm!Amanieu d'Antras-6/+12
2020-05-30Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkovRalf Jung-0/+115
Improve inline asm error diagnostics Previously we were just using the raw LLVM error output (with line, caret, etc) as the diagnostic message, which ends up looking rather out of place with our existing diagnostics. The new diagnostics properly format the diagnostics and also take advantage of LLVM's per-line `srcloc` attribute to map an error in inline assembly directly to the relevant line of source code. Incidentally also fixes #71639 by disabling `srcloc` metadata during LTO builds since we don't know what crate it might have come from. We can only resolve `srcloc`s from the currently crate since it indexes into the source map for the current crate. Fixes #72664 Fixes #71639 r? @petrochenkov ### Old style ```rust #![feature(llvm_asm)] fn main() { unsafe { let _x: i32; llvm_asm!( "mov $0, $1 invalid_instruction $0, $1 mov $0, $1" : "=&r" (_x) : "r" (0) :: "intel" ); } } ``` ``` error: <inline asm>:3:14: error: invalid instruction mnemonic 'invalid_instruction' invalid_instruction ecx, eax ^~~~~~~~~~~~~~~~~~~ --> src/main.rs:6:9 | 6 | / llvm_asm!( 7 | | "mov $0, $1 8 | | invalid_instruction $0, $1 9 | | mov $0, $1" ... | 12 | | :: "intel" 13 | | ); | |__________^ ``` ### New style ```rust #![feature(asm)] fn main() { unsafe { asm!( "mov {0}, {1} invalid_instruction {0}, {1} mov {0}, {1}", out(reg) _, in(reg) 0i64, ); } } ``` ``` error: invalid instruction mnemonic 'invalid_instruction' --> test.rs:7:14 | 7 | invalid_instruction {0}, {1} | ^ | note: instantiated into assembly here --> <inline asm>:3:14 | 3 | invalid_instruction rax, rcx | ^^^^^^^^^^^^^^^^^^^ ```
2020-05-30Rollup merge of #72607 - Amanieu:fix-72570, r=oli-obkRalf Jung-0/+18
Eagerly lower asm sub-expressions to HIR even if there is an error Fixes #72570 r? @oli-obk
2020-05-29Improve inline asm error diagnosticsAmanieu d'Antras-0/+115
2020-05-26Fix testAmanieu d'Antras-0/+11
2020-05-26Eagerly lower asm sub-expressions to HIR even if there is an errorAmanieu d'Antras-0/+7
Fixes #72570
2020-05-24Properly handle InlineAsmOperand::SymFn when collecting monomorphized itemsAmanieu d'Antras-0/+38
Fixes #72484
2020-05-18Fix const handling and add tests for const operandsAmanieu d'Antras-0/+56
2020-05-18Add borrow-check testAmanieu d'Antras-1/+50
2020-05-18Implement att_syntax optionAmanieu d'Antras-4/+4
2020-05-18Add support for high byte registers on x86Amanieu d'Antras-46/+40
2020-05-18Apply review feedbackAmanieu d'Antras-18/+33