| Age | Commit message (Collapse) | Author | Lines | |
|---|---|---|---|---|
| 2020-05-19 | Auto merge of #69171 - Amanieu:new-asm, r=nagisa,nikomatsakis | bors | -7/+104 | |
| Implement new asm! syntax from RFC 2850 This PR implements the new `asm!` syntax proposed in https://github.com/rust-lang/rfcs/pull/2850. # Design A large part of this PR revolves around taking an `asm!` macro invocation and plumbing it through all of the compiler layers down to LLVM codegen. Throughout the various stages, an `InlineAsm` generally consists of 3 components: - The template string, which is stored as an array of `InlineAsmTemplatePiece`. Each piece represents either a literal or a placeholder for an operand (just like format strings). ```rust pub enum InlineAsmTemplatePiece { String(String), Placeholder { operand_idx: usize, modifier: Option<char>, span: Span }, } ``` - The list of operands to the `asm!` (`in`, `[late]out`, `in[late]out`, `sym`, `const`). These are represented differently at each stage of lowering, but follow a common pattern: - `in`, `out` and `inout` all have an associated register class (`reg`) or explicit register (`"eax"`). - `inout` has 2 forms: one with a single expression that is both read from and written to, and one with two separate expressions for the input and output parts. - `out` and `inout` have a `late` flag (`lateout` / `inlateout`) to indicate that the register allocator is allowed to reuse an input register for this output. - `out` and the split variant of `inout` allow `_` to be specified for an output, which means that the output is discarded. This is used to allocate scratch registers for assembly code. - `sym` is a bit special since it only accepts a path expression, which must point to a `static` or a `fn`. - The options set at the end of the `asm!` macro. The only one that is particularly of interest to rustc is `NORETURN` which makes `asm!` return `!` instead of `()`. ```rust bitflags::bitflags! { pub struct InlineAsmOptions: u8 { const PURE = 1 << 0; const NOMEM = 1 << 1; const READONLY = 1 << 2; const PRESERVES_FLAGS = 1 << 3; const NORETURN = 1 << 4; const NOSTACK = 1 << 5; } } ``` ## AST `InlineAsm` is represented as an expression in the AST: ```rust pub struct InlineAsm { pub template: Vec<InlineAsmTemplatePiece>, pub operands: Vec<(InlineAsmOperand, Span)>, pub options: InlineAsmOptions, } pub enum InlineAsmRegOrRegClass { Reg(Symbol), RegClass(Symbol), } pub enum InlineAsmOperand { In { reg: InlineAsmRegOrRegClass, expr: P<Expr>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<P<Expr>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: P<Expr>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: P<Expr>, out_expr: Option<P<Expr>>, }, Const { expr: P<Expr>, }, Sym { expr: P<Expr>, }, } ``` The `asm!` macro is implemented in librustc_builtin_macros and outputs an `InlineAsm` AST node. The template string is parsed using libfmt_macros, positional and named operands are resolved to explicit operand indicies. Since target information is not available to macro invocations, validation of the registers and register classes is deferred to AST lowering. ## HIR `InlineAsm` is represented as an expression in the HIR: ```rust pub struct InlineAsm<'hir> { pub template: &'hir [InlineAsmTemplatePiece], pub operands: &'hir [InlineAsmOperand<'hir>], pub options: InlineAsmOptions, } pub enum InlineAsmRegOrRegClass { Reg(InlineAsmReg), RegClass(InlineAsmRegClass), } pub enum InlineAsmOperand<'hir> { In { reg: InlineAsmRegOrRegClass, expr: Expr<'hir>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<Expr<'hir>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: Expr<'hir>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: Expr<'hir>, out_expr: Option<Expr<'hir>>, }, Const { expr: Expr<'hir>, }, Sym { expr: Expr<'hir>, }, } ``` AST lowering is where `InlineAsmRegOrRegClass` is converted from `Symbol`s to an actual register or register class. If any modifiers are specified for a template string placeholder, these are validated against the set allowed for that operand type. Finally, explicit registers for inputs and outputs are checked for conflicts (same register used for different operands). ## Type checking Each register class has a whitelist of types that it may be used with. After the types of all operands have been determined, the `intrinsicck` pass will check that these types are in the whitelist. It also checks that split `inout` operands have compatible types and that `const` operands are integers or floats. Suggestions are emitted where needed if a template modifier should be used for an operand based on the type that was passed into it. ## HAIR `InlineAsm` is represented as an expression in the HAIR: ```rust crate enum ExprKind<'tcx> { // [..] InlineAsm { template: &'tcx [InlineAsmTemplatePiece], operands: Vec<InlineAsmOperand<'tcx>>, options: InlineAsmOptions, }, } crate enum InlineAsmOperand<'tcx> { In { reg: InlineAsmRegOrRegClass, expr: ExprRef<'tcx>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<ExprRef<'tcx>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: ExprRef<'tcx>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: ExprRef<'tcx>, out_expr: Option<ExprRef<'tcx>>, }, Const { expr: ExprRef<'tcx>, }, SymFn { expr: ExprRef<'tcx>, }, SymStatic { expr: ExprRef<'tcx>, }, } ``` The only significant change compared to HIR is that `Sym` has been lowered to either a `SymFn` whose `expr` is a `Literal` ZST of the `fn`, or a `SymStatic` whose `expr` is a `StaticRef`. ## MIR `InlineAsm` is represented as a `Terminator` in the MIR: ```rust pub enum TerminatorKind<'tcx> { // [..] /// Block ends with an inline assembly block. This is a terminator since /// inline assembly is allowed to diverge. InlineAsm { /// The template for the inline assembly, with placeholders. template: &'tcx [InlineAsmTemplatePiece], /// The operands for the inline assembly, as `Operand`s or `Place`s. operands: Vec<InlineAsmOperand<'tcx>>, /// Miscellaneous options for the inline assembly. options: InlineAsmOptions, /// Destination block after the inline assembly returns, unless it is /// diverging (InlineAsmOptions::NORETURN). destination: Option<BasicBlock>, }, } pub enum InlineAsmOperand<'tcx> { In { reg: InlineAsmRegOrRegClass, value: Operand<'tcx>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, place: Option<Place<'tcx>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, in_value: Operand<'tcx>, out_place: Option<Place<'tcx>>, }, Const { value: Operand<'tcx>, }, SymFn { value: Box<Constant<'tcx>>, }, SymStatic { value: Box<Constant<'tcx>>, }, } ``` As part of HAIR lowering, `InOut` and `SplitInOut` operands are lowered to a split form with a separate `in_value` and `out_place`. Semantically, the `InlineAsm` terminator is similar to the `Call` terminator except that it has multiple output places where a `Call` only has a single return place output. The constant promotion pass is used to ensure that `const` operands are actually constants (using the same logic as `#[rustc_args_required_const]`). ## Codegen Operands are lowered one more time before being passed to LLVM codegen: ```rust pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> { In { reg: InlineAsmRegOrRegClass, value: OperandRef<'tcx, B::Value>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, place: Option<PlaceRef<'tcx, B::Value>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, in_value: OperandRef<'tcx, B::Value>, out_place: Option<PlaceRef<'tcx, B::Value>>, }, Const { string: String, }, SymFn { instance: Instance<'tcx>, }, SymStatic { def_id: DefId, }, } ``` The operands are lowered to LLVM operands and constraint codes as follow: - `out` and the output part of `inout` operands are added first, as required by LLVM. Late output operands have a `=` prefix added to their constraint code, non-late output operands have a `=&` prefix added to their constraint code. - `in` operands are added normally. - `inout` operands are tied to the matching output operand. - `sym` operands are passed as function pointers or pointers, using the `"s"` constraint. - `const` operands are formatted to a string and directly inserted in the template string. The template string is converted to LLVM form: - `$` characters are escaped as `$$`. - `const` operands are converted to strings and inserted directly. - Placeholders are formatted as `${X:M}` where `X` is the operand index and `M` is the modifier character. Modifiers are converted from the Rust form to the LLVM form. The various options are converted to clobber constraints or LLVM attributes, refer to the [RFC](https://github.com/Amanieu/rfcs/blob/inline-asm/text/0000-inline-asm.md#mapping-to-llvm-ir) for more details. Note that LLVM is sometimes rather picky about what types it accepts for certain constraint codes so we sometimes need to insert conversions to/from a supported type. See the target-specific ISelLowering.cpp files in LLVM for details. # Adding support for new architectures Adding inline assembly support to an architecture is mostly a matter of defining the registers and register classes for that architecture. All the definitions for register classes are located in `src/librustc_target/asm/`. Additionally you will need to implement lowering of these register classes to LLVM constraint codes in `src/librustc_codegen_llvm/asm.rs`. | ||||
| 2020-05-19 | Auto merge of #68717 - petrochenkov:stabexpat, r=varkor | bors | -3/+2 | |
| Stabilize fn-like proc macros in expression, pattern and statement positions I.e. all the positions in which stable `macro_rules` macros are supported. Depends on https://github.com/rust-lang/rust/pull/68716 ("Stabilize `Span::mixed_site`"). cc https://github.com/rust-lang/rust/issues/54727 cc https://github.com/rust-lang/rust/issues/54727#issuecomment-580647446 Stabilization report: https://github.com/rust-lang/rust/pull/68717#issuecomment-623197503. | ||||
| 2020-05-18 | Handle InlineAsm in clippy | Amanieu d'Antras | -7/+104 | |
| 2020-05-18 | Add remote-test-client help text | Tom Eccles | -5/+51 | |
| 2020-05-17 | Merge commit 'e214ea82ad0a751563acf67e1cd9279cf302db3a' into clippyup | flip1995 | -1102/+1770 | |
| 2020-05-16 | Rollup merge of #72047 - ↵ | Ralf Jung | -2/+2 | |
| Julian-Wollersberger:literal_error_reporting_cleanup, r=petrochenkov Literal error reporting cleanup While doing some performance work, I noticed some code duplication in `librustc_parser/lexer/mod.rs`, so I cleaned it up. This PR is probably best reviewed commit by commit. I'm not sure what the API stability practices for `librustc_lexer` are. Four public methods in `unescape.rs` can be removed, but two are used by clippy, so I left them in for now. I could open a PR for Rust-Analyzer when this one lands. But how do I open a PR for clippy? (Git submodules are frustrating to work with) | ||||
| 2020-05-16 | Rollup merge of #71919 - Xanewok:bump-syn-1, r=Xanewok | Dylan DPC | -1/+1 | |
| Update transitive dependency to work towards removing syn <1.0 dep This bumps a couple of transitive dependencies in hopes of eventually not transitively depending on syn <1.0 and friends. The only upstream changes that this is blocked on seems to be https://github.com/mattico/elasticlunr-rs/pull/27 and https://github.com/rust-lang/mdBook/pull/1210. While working on https://github.com/rust-lang/rust/pull/71875 I noticed we still use syn 0.15 here and there so this is a drive-by PR which aims to help with things a bit. | ||||
| 2020-05-16 | Rollup merge of #72090 - RalfJung:rustc_driver-exit-code, r=oli-obk | Dylan DPC | -3/+1 | |
| rustc_driver: factor out computing the exit code In a recent Miri PR I [added a convenience wrapper](https://github.com/rust-lang/miri/pull/1405/files#diff-c3d602c5c8035a16699ce9c015bfeceaR125) around `catch_fatal_errors` and `run_compiler` that @oli-obk suggested I could upstream. However, after seeing what could be shared between `rustc_driver::main`, clippy and Miri, really the only thing I found is computing the exit code -- so that's what this PR does. What prevents using the Miri convenience function in `rustc_driver::main` and clippy is that they do extra work inside `catch_fatal_errors`, and while I could abstract that away, clippy actually *computes the callbacks* inside there, and I fond no good way to abstract that and thus gave up. Maybe the clippy thing could be moved out, I am not sure if it ever can actually raise a `FatalErrorMarker` -- someone more knowledgeable in clippy would have to do that. | ||||
| 2020-05-16 | Rollup merge of #71948 - csmoe:issue-61076, r=oli-obk | Dylan DPC | -16/+2 | |
| Suggest to await future before ? operator Closes https://github.com/rust-lang/rust/issues/71811 cc #61076 | ||||
| 2020-05-16 | Rollup merge of #71724 - GuillaumeGomez:doc-alias-improvements, r=ollie27 | Dylan DPC | -37/+68 | |
| Doc alias improvements After [this message](https://github.com/rust-lang/rust/issues/50146#issuecomment-496601755), I realized that the **doc alias**. So this PR does the followings: * Align the alias discovery on items added into the search-index. It brings a few nice advantages: * Instead of cloning the data between the two (in rustdoc source code), we now have the search-index one and aliases which reference to the first one. So we go from one big map containing a lot of duplicated data to just integers... * In the front-end (main.js), I improved the code around aliases to allow them to go through the same transformation as other items when we show the search results. * Improve the search tester in order to perform multiple requests into one file (I think it's better in this case than having a file for each case considering how many there are...) * I also had to add the new function inside the tester (`handleAliases`) Once this PR is merged, I intend to finally stabilize this feature. r? @ollie27 cc @rust-lang/rustdoc | ||||
| 2020-05-15 | implement type_implments_trait query | csmoe | -16/+2 | |
| 2020-05-14 | Make current crate aliases go first | Guillaume Gomez | -2/+4 | |
| 2020-05-14 | Auto merge of #72058 - RalfJung:no-dist-lldb, r=Mark-Simulacrum | bors | -18/+0 | |
| bootstrap: remove lldb dist packaging The lldb-preview rustup package is missing on every single target, and has never been shipped beyond x86_64-apple-darwin. It was removed in #62592 which landed around a year ago, and there's not been demand that we re-enable it since, so we're now removing support entirely to cleanup the code a bit. The hope is that this will also kill the useless "lldb-preview" row on https://rust-lang.github.io/rustup-components-history/. | ||||
| 2020-05-13 | Auto merge of #72118 - flip1995:clippyup, r=oli-obk | bors | -257/+1574 | |
| Update Clippy to 43a1777 Updates Clippy to https://github.com/rust-lang/rust-clippy/commit/43a1777b89cf6791f9e20878b4e5e3ae907867a5 We should establish a process on how often and when to update Clippy. (After X feature PRs? Once per week? Only on bug fixes and in the release week? ...?) r? @oli-obk | ||||
| 2020-05-13 | Replace some usages of the old `unescape_` functions in AST, clippy and tests. | Julian Wollersberger | -2/+2 | |
| 2020-05-12 | Auto merge of #72091 - RalfJung:miri, r=RalfJung | bors | -7/+7 | |
| update miri Fixes https://github.com/rust-lang/rust/issues/72037 Cc @rust-lang/miri r? @ghost | ||||
| 2020-05-11 | Merge commit '43a1777b89cf6791f9e20878b4e5e3ae907867a5' into clippyup | flip1995 | -257/+1574 | |
| 2020-05-11 | Auto merge of #72089 - Mark-Simulacrum:error-is-really-an-error, r=pietroalbini | bors | -1/+4 | |
| Fail if I/O error occurs during testing First known case of this is in https://github.com/rust-lang/rust/pull/72053#issuecomment-626364402 but may have happened before then. r? @pietroalbini | ||||
| 2020-05-11 | rustbook: Bump mdbook dependency | Igor Matuszewski | -1/+1 | |
| 2020-05-11 | update miri some more | Ralf Jung | -11/+7 | |
| 2020-05-10 | update miri | Ralf Jung | -7/+11 | |
| 2020-05-10 | rustc_driver: factor out computing the exit code | Ralf Jung | -3/+1 | |
| 2020-05-10 | Fail if I/O error occurs during testing | Mark Rousskov | -1/+4 | |
| 2020-05-10 | remove lldb package from bootstrap, config and build-manifest | Ralf Jung | -18/+0 | |
| it's not been built since a long time ago | ||||
| 2020-05-09 | Auto merge of #72041 - RalfJung:rollup-xivrvy2, r=RalfJung | bors | -31/+42 | |
| Rollup of 5 pull requests Successful merges: - #69406 (upgrade chalk and use chalk-solve/chalk-ir/chalk-rust-ir) - #71185 (Move tests from `test/run-fail` to UI) - #71234 (rustllvm: Use .init_array rather than .ctors) - #71508 (Simplify the `tcx.alloc_map` API) - #71555 (Remove ast::{Ident, Name} reexports.) Failed merges: r? @ghost | ||||
| 2020-05-09 | Rollup merge of #71555 - cjgillot:nameless, r=matthewjasper | Ralf Jung | -31/+31 | |
| Remove ast::{Ident, Name} reexports. The reexport of `Symbol` into `Name` confused me. | ||||
| 2020-05-09 | Rollup merge of #69406 - jackh726:chalk-upgrade, r=nikomatsakis | Ralf Jung | -0/+11 | |
| upgrade chalk and use chalk-solve/chalk-ir/chalk-rust-ir Reintegrate chalk into rustc. r? @nikomatsakis cc. @rust-lang/wg-traits | ||||
| 2020-05-09 | submodules: update cargo from f534844c2 to cb06cb269 | Matthias Krüger | -0/+0 | |
| Changes: ```` more clippy fixes Document that bench is unstable in the man page. Update assertions in LTO calculations Updated comments in resolve.rs to reflect actual data strcture used. Try to remove secrets from http.debug. Revert always computing filename Metadata. clean -p: call `get_many` once. Implement new `clean -p` using globs. Rework how Cargo computes the rustc file outputs. Add CrateType to replace LibKind. ```` | ||||
| 2020-05-08 | Fix clippy. | Camille GILLOT | -31/+31 | |
| 2020-05-08 | update miri | Ralf Jung | -7/+7 | |
| 2020-05-07 | Fix nit and cargo.lock | Jack Huey | -0/+7 | |
| 2020-05-07 | Reintegrate chalk using chalk-solve | Jack Huey | -0/+4 | |
| 2020-05-07 | Merge aliases and search-index | Guillaume Gomez | -6/+3 | |
| 2020-05-07 | Extend rustdoc-js tester to allow to test multiple queries in one file | Guillaume Gomez | -33/+65 | |
| 2020-05-07 | Auto merge of #71925 - ehuss:update-cargo, r=ehuss | bors | -0/+0 | |
| Update cargo 7 commits in 258c89644c4587273a3ed3ee9522d2640facba43..f534844c25cacc5e004404cea835ac85e35ca3fd 2020-04-30 21:48:21 +0000 to 2020-05-06 14:39:10 +0000 - Avoid testing git-specific error messages (rust-lang/cargo#8212) - features: allow activated_features_unverified to communicate not-present (rust-lang/cargo#8194) - Don't force rustc to do codegen for LTO builds (rust-lang/cargo#8192) - Hint git-fetch-with-cli on git errors (rust-lang/cargo#8166) - ¬∃x. ¬y => ∀x. y (rust-lang/cargo#8205) - clippy fixes (rust-lang/cargo#8189) - Rename bitcode-in-rlib flag to embed-bitcode (rust-lang/cargo#8204) | ||||
| 2020-05-07 | Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk | bors | -0/+2 | |
| Prevent compiler stack overflow for deeply recursive code I was unable to write a test that 1. runs in under 1s 2. overflows on my machine without this patch The following reproduces the issue, but I don't think it's sensible to include a test that takes 30s to compile. We can now easily squash newly appearing overflows by the strategic insertion of calls to `ensure_sufficient_stack`. ```rust // compile-pass #![recursion_limit="1000000"] macro_rules! chain { (EE $e:expr) => {$e.sin()}; (RECURSE $i:ident $e:expr) => {chain!($i chain!($i chain!($i chain!($i $e))))}; (Z $e:expr) => {chain!(RECURSE EE $e)}; (Y $e:expr) => {chain!(RECURSE Z $e)}; (X $e:expr) => {chain!(RECURSE Y $e)}; (A $e:expr) => {chain!(RECURSE X $e)}; (B $e:expr) => {chain!(RECURSE A $e)}; (C $e:expr) => {chain!(RECURSE B $e)}; // causes overflow on x86_64 linux // less than 1 second until overflow on test machine // after overflow has been fixed, takes 30s to compile :/ (D $e:expr) => {chain!(RECURSE C $e)}; (E $e:expr) => {chain!(RECURSE D $e)}; (F $e:expr) => {chain!(RECURSE E $e)}; // more than 10 seconds (G $e:expr) => {chain!(RECURSE F $e)}; (H $e:expr) => {chain!(RECURSE G $e)}; (I $e:expr) => {chain!(RECURSE H $e)}; (J $e:expr) => {chain!(RECURSE I $e)}; (K $e:expr) => {chain!(RECURSE J $e)}; (L $e:expr) => {chain!(RECURSE L $e)}; } fn main() { let x = chain!(D 42.0_f32); } ``` fixes #55471 fixes #41884 fixes #40161 fixes #34844 fixes #32594 cc @alexcrichton @rust-lang/compiler I looked at all code that checks the recursion limit and inserted stack growth calls where appropriate. | ||||
| 2020-05-06 | Update cargo | Eric Huss | -0/+0 | |
| 2020-05-05 | Auto merge of #71875 - Xanewok:update-rls, r=tmandry | bors | -2/+6 | |
| Update RLS In addition to fixing the toolstate, this also changes the default compilation model to the out-of-process one, which should hopefully target considerable memory usage for long-running instances of the RLS. Fixes #71753 r? @ghost | ||||
| 2020-05-05 | Unify winapi features for tools | Tyler Mandry | -1/+2 | |
| 2020-05-05 | Unify some syn 1.0 et al. features for tools | Igor Matuszewski | -1/+4 | |
| 2020-05-05 | Update RLS | Igor Matuszewski | -0/+0 | |
| In addition to fixing the toolstate, this also changes the default compilation model to the out-of-process one, which should hopefully target considerable memory usage for long-running instances of the RLS. | ||||
| 2020-05-05 | Rollup merge of #71830 - oli-obk:subrepo_funness, r=Mark-Simulacrum | Dylan DPC | -5/+0 | |
| Remove clippy from some leftover lists of "possibly failing" tools https://github.com/rust-lang/rust/pull/70655 successfully made clippy get built and tested on CI on every merge, but the lack of emitted toolstate info caused the toolstate to get updated to test-fail. We should remove clippy entirely from toolstate, as it now is always test-pass. The changes made in this PR reflect what we do for `rustdoc`, which is our preexisting tool that is gated on CI. r? @Mark-Simulacrum | ||||
| 2020-05-03 | Update clippy lint | Dylan MacKenzie | -1/+1 | |
| 2020-05-03 | Stabilize fn-like proc macros in expression, pattern and statement positions | Vadim Petrochenkov | -3/+2 | |
| 2020-05-03 | Remove clippy from some leftover lists of "possibly failing" tools | Oliver Scherer | -5/+0 | |
| 2020-05-02 | Auto merge of #71794 - RalfJung:miri, r=RalfJung | bors | -7/+7 | |
| update Miri This contains the concurrency support by @vakaras :) Fixes https://github.com/rust-lang/rust/issues/71729 r? @ghost Cc @rust-lang/miri | ||||
| 2020-05-02 | Add `psm` to the crate whitelist | Oliver Scherer | -0/+2 | |
| 2020-05-02 | update Miri | Ralf Jung | -7/+7 | |
| 2020-05-02 | Add 'src/tools/clippy/' from commit 'd2708873ef711ec8ab45df1e984ecf24a96cd369' | Oliver Scherer | -0/+114475 | |
| git-subtree-dir: src/tools/clippy git-subtree-mainline: 06c44816c1532e5ff08ad072f581fc068eb60e2e git-subtree-split: d2708873ef711ec8ab45df1e984ecf24a96cd369 | ||||
| 2020-05-02 | Delete the clippy submodule | Oliver Scherer | -11/+0 | |
