about summary refs log tree commit diff
path: root/compiler/rustc_target/src/asm/mod.rs
AgeCommit message (Collapse)AuthorLines
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+2
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-11-28Support `clobber_abi` for AVR inline assemblyJulian Frimmel-0/+22
This commit adds the relevant registers to the list of clobbered regis- ters (part of #93335). This follows the [ABI documentation] of AVR-GCC: > The [...] call-clobbered general purpose registers (GPRs) are > registers that might be destroyed (clobbered) by a function call. > > - **R18–R27, R30, R31** > > These GPRs are call clobbered. An ordinary function may use them > without restoring the contents. [...] > > - **R0, T-Flag** > > The temporary register and the T-flag in SREG are also call- > clobbered, but this knowledge is not exposed explicitly to the > compiler (R0 is a fixed register). Therefore this commit lists the aforementioned registers `r18–r27`, `r30` and `r31` as clobbered registers. Since the `r0` register (listed above as well) is not available in inline assembly at all (potentially because the AVR-GCC considers it a fixed register causing the register to never be used in register allocation and LLVM adopting this), there is no need to list it in the clobber list (the `r0`-variant is not even available). A comment was added to ensure, that the `r0` gets added to the clobber-list once the register gets usable in inline ASM. Since the SREG is normally considered clobbered anyways (unless the user supplies the `preserve_flags`-option), there is no need to explicitly list a bit in this register (which is not possible to list anyways). Note, that this commit completely ignores the case of interrupts (that are described in the ABI-specification), since every register touched in an ISR need to be saved anyways. [ABI documentation]: https://gcc.gnu.org/wiki/avr-gcc#Call-Used_Registers
2024-11-28Rollup merge of #133463 - taiki-e:aarch64-asm-x18, r=AmanieuGuillaume Gomez-5/+7
Fix handling of x18 in AArch64 inline assembly on ohos/trusty or with -Zfixed-x18 Currently AArch64 inline assembly allows using x18 on ohos/trusty or with -Zfixed-x18. https://github.com/rust-lang/rust/blob/7db7489f9bc274cb60c4956bfa56de0185eb1b9b/compiler/rustc_target/src/asm/aarch64.rs#L74-L76 However, x18 is reserved in these environments and should not be allowed in the input/output operands of inline assemblies as it is in Android, Windows, etc.. https://github.com/rust-lang/rust/blob/7db7489f9bc274cb60c4956bfa56de0185eb1b9b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs#L19 https://github.com/rust-lang/rust/blob/7db7489f9bc274cb60c4956bfa56de0185eb1b9b/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs#L18 https://github.com/rust-lang/rust/blob/7db7489f9bc274cb60c4956bfa56de0185eb1b9b/compiler/rustc_codegen_llvm/src/llvm_util.rs#L764-L771 (As for ohos, +reserve-x18 is [redundant](https://github.com/llvm/llvm-project/commit/c417b7a695704d5bc3be23f34d1bfa505f5172de#diff-0ddf23e0bf2b28b2d05f842f087d1e6f694e8e06d1765e8d0f10d47fddcdff9c) since https://github.com/rust-lang/rust/commit/7a966b918870485e9b364e77f50c511f8c2cc275 that starting using llvm's ohos targets. So removed it from target-spec.) This fix may potentially break the code for tier 2 target (aarch64-unknown-linux-ohos). (As for others, aarch64-unknown-trusty is tier 3 and -Zfixed-x18 is unstable so breaking them should be fine.) However, in any case, it seems suspicious that the code that is broken by this was sound. r? `@Amanieu` `@rustbot` label O-AArch64 +A-inline-assembly
2024-11-28Rollup merge of #133422 - taiki-e:riscv-e-clobber-abi, r=AmanieuGuillaume Gomez-1/+32
Fix clobber_abi in RV32E and RV64E inline assembly Currently clobber_abi in RV32E and RV64E inline assembly is implemented using InlineAsmClobberAbi::RiscV, but broken since x16-x31 cannot be used in RV32E and RV64E. ``` error: cannot use register `x16`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x17`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x28`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x29`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x30`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x31`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ ``` r? `@Amanieu` `@rustbot` label O-riscv +A-inline-assembly
2024-11-26Fix handling of x18 in AArch64 inline assembly on ohos/trusty or with ↵Taiki Endo-5/+8
-Zfixed-x18
2024-11-25Fix clobber_abi in RV32E and RV64E inline assemblyTaiki Endo-1/+32
2024-11-24Make s390x non-clobber-only vector register support unstableTaiki Endo-3/+10
2024-11-07Auto merge of #132472 - taiki-e:sparc-asm, r=Amanieubors-0/+30
Basic inline assembly support for SPARC and SPARC64 This implements asm_experimental_arch (tracking issue https://github.com/rust-lang/rust/issues/93335) for SPARC and SPARC64. This PR includes: - General-purpose registers `r[0-31]` (`reg` register class, LLVM/GCC constraint `r`) Supported types: i8, i16, i32, i64 (SPARC64-only) Aliases: `g[0-7]` (`r[0-7]`), `o[0-7]` (`r[8-15]`), `l[0-7]` (`r[16-23]`), `i[0-7]` (`r[24-31]`) - `y` register (clobber-only, needed for clobber_abi) - preserves_flags: Integer condition codes (`icc`, `xcc`) and floating-point condition codes (`fcc*`) The following are *not* included: - 64-bit integer support on SPARC-V8+'s global or out registers (`g[0-7]`, `o[0-7]`): GCC's `h` constraint (it seems that there is no corresponding constraint in LLVM?) - Floating-point registers (LLVM/GCC constraint `e`/`f`): I initially tried to implement this, but postponed it for now because there seemed to be several parts in LLVM that behaved differently than in the LangRef's description. - clobber_abi: Support for floating-point registers is needed. Refs: - LLVM - Reserved registers https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/SparcRegisterInfo.cpp#L52 - Register definitions https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/SparcRegisterInfo.td - Supported constraints https://llvm.org/docs/LangRef.html#supported-constraint-code-list - GCC - Reserved registers https://github.com/gcc-mirror/gcc/blob/63b6967b06b5387821c4e5f2c113da6aaeeae2b7/gcc/config/sparc/sparc.h#L633-L658 - Supported constraints https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html - SPARC ISA/ABI - (64-bit ISA) The SPARC Architecture Manual, Version 9 (32-bit ISA) The SPARC Architecture Manual, Version 8 (64-bit ABI) System V Application Binary Interface SPARC Version 9 Processor Supplement, Rev 1.35 (32-bit ABI) System V Application Binary Interface SPARC Processor Supplement, Third Edition The above docs can be downloaded from https://sparc.org/technical-documents - (32-bit V8+ ABI) The V8+ Technical Specification https://temlib.org/pub/SparcStation/Standards/V8plus.pdf cc `@thejpster` (sparc-unknown-none-elf target maintainer) (AFAIK, other sparc/sprac64 targets don't have target maintainers) r? `@Amanieu` `@rustbot` label +O-SPARC +A-inline-assembly
2024-11-07Add links about clobber_abi on PowerPCTaiki Endo-0/+15
2024-11-07Remove fixme comment about clobber_abi on PowerPCTaiki Endo-2/+0
2024-11-07Basic inline assembly support for SPARC and SPARC64Taiki Endo-0/+30
2024-11-02Support clobber_abi and vector registers (clobber-only) in PowerPC inline ↵Taiki Endo-0/+30
assembly
2024-10-14Fix clobber_abi and disallow SVE-related registers in Arm64EC inline assemblyTaiki Endo-2/+15
2024-10-06Support clobber_abi in MSP430 inline assemblyTaiki Endo-0/+10
2024-09-21Support clobber_abi and vector/access registers (clobber-only) in s390x ↵Taiki Endo-1/+28
inline assembly
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+6
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-13Add `f16` and `f128` inline ASM support for `x86` and `x86-64`beetrees-0/+12
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-3/+3
2024-04-11Rollup merge of #123740 - veera-sivarajan:reduce-size-of-modifierinfo, ↵Matthias Krüger-3/+3
r=petrochenkov Reduce Size of `ModifierInfo` I added `ModifierInfo` in #121940 and had used a `u64` for the `size` field even though the largest value it holds is `512`. This PR changes the type of the `size` field to `u16`.
2024-04-10Reduce size of `ModifierInfo`Veera-3/+3
2024-04-10Add support for Arm64EC inline assemblyDaniel Paoliello-3/+13
2024-03-13Improve styleVeera-2/+2
2024-03-03Mention Register Size in `#[warn(asm_sub_register)]`Veera-6/+14
Fixes #121593
2023-08-14add a csky-unknown-linux-gnuabiv2 targetDirreke-0/+24
2023-07-18support for mips32r6 as a target_arch valuechenx97-1/+1
2023-07-18merge patternschenx97-2/+1
2023-07-18support for mips64r6 as a target_arch valuechenx97-0/+1
2023-05-12asm: loongarch64: Drop efiapiWANG Rui-2/+2
2023-05-05asm: loongarch64: Implementation of clobber_abiWANG Rui-0/+20
2023-04-25Add loongarch64 asm! supportzhaixiaojuan-0/+26
2023-04-12Add inline assembly support for m68kIan Douglas Scott-0/+24
2023-03-01Use FxIndexSet instead of FxHashSet for asm_target_features query.Michael Woerister-10/+11
2023-01-14Fix some missed double spaces.André Vennberg-1/+1
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-7/+7
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-07-08Collapse some weirdly-wrapping derivesMichael Goulet-48/+8
2022-05-17Add ABI clobbersConnor Horman-0/+2
2022-04-19asm: Add a kreg0 register class on x86 which includes k0Amanieu d'Antras-3/+3
Previously we only exposed a kreg register class which excludes the k0 register since it can't be used in many instructions. However k0 is a valid register and we need to have a way of marking it as clobbered for clobber_abi. Fixes #94977
2022-02-21Take CodegenFnAttrs into account when validating asm! register operandsAmanieu d'Antras-113/+87
Checking of asm! register operands now properly takes function attributes such as #[target_feature] and #[instruction_set] into account.
2022-02-21On ARM, use relocation_model to detect whether r9 should be reservedAmanieu d'Antras-32/+37
The previous approach of checking for the reserve-r9 target feature didn't actually work because LLVM only sets this feature very late when initializing the per-function subtarget.
2022-02-18asm: Allow the use of r8-r14 as clobbers on Thumb1Amanieu d'Antras-37/+71
Previously these were entirely disallowed, except for r11 which was allowed by accident.
2022-01-31Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726Matthias Krüger-1/+1
Improve terminology around "after typeck" Closes #70258.
2022-01-22Add preliminary support for inline assembly for msp430.William D. Jones-0/+25
2022-01-17Pass target_features set instead of has_feature closurebjorn3-34/+34
This avoids unnecessary monomorphizations in codegen backends
2022-01-17Use Symbol for target features in asm handlingbjorn3-8/+8
This saves a couple of Symbol::intern calls
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-14/+14
2021-12-10asm: Allow using r9 (ARM) and x18 (AArch64) if they are not reserved byAmanieu d'Antras-4/+30
the current target.
2021-12-06Implement inline asm! for AVR platformAndrew Dona-Couch-0/+25
2021-11-10Update more rustc/libtest things for wasm64Alex Crichton-3/+7
* Add wasm64 variants for inline assembly along the same lines as wasm32 * Update a few directives in libtest to check for `target_family` instead of `target_arch` * Update some rustc codegen and typechecks specialized for wasm32 to also work for wasm64.
2021-11-06Improve terminology around "after typeck"pierwill-1/+1
2021-09-01Rollup merge of #88350 - programmerjake:add-ppc-cr-xer-clobbers, r=AmanieuMara Bos-1/+1
add support for clobbering xer, cr, and cr[0-7] for asm! on OpenPower/PowerPC Fixes #88315