rust/compiler/rustc_span/src
Jonathan Brouwer d7c812cb57
Rollup merge of #146900 - taiki-e:avr-target-feature, r=workingjubilee
Add avr_target_feature

This adds the following unstable target features (tracking issue: https://github.com/rust-lang/rust/issues/146889):

- The following two are particularly important for properly supporting inline assembly:
  - `tinyencoding`: AVR has devices that reduce the number of registers, similar to RISC-V's RV32E. This feature is necessary to support inline assembly in such devices. (see also https://github.com/rust-lang/rust/pull/146901)
  - `lowbytefirst`: AVR's memory access is per 8-bit, and when writing 16-bit ports, the bytes must be written in a specific order. This order depends on devices, making this feature necessary to write proper inline assembly for such use cases. (see also 2a528760bf)
- The followings help recognizing whether specific instructions are available:
  - `addsubiw`
  - `break`
  - `eijmpcall`
  - `elpm`
  - `elpmx`
  - `ijmpcall`
  - `jmpcall`
  - `lpm`
  - `lpmx`
  - `movw`
  - `mul`
  - `rmw`
  - `spm`
  - `spmx`

  Of these, all except `addsubiw`, `break`, `ijmpcall`, `lpm`, `rmw`, `spm`, and `spmx` have [corresponding conditional codes in avr-libc](https://github.com/search?q=repo%3Aavrdudes%2Favr-libc+%2F__AVR_HAVE_%2F&type=code&p=1). LLVM also has `des` feature, but I excluded it from this PR because [DES](https://en.wikipedia.org/wiki/Data_Encryption_Standard) is insecure.

- Report future-incompatible warning (https://github.com/rust-lang/rust/issues/116344) for -C target-feature=-sram and -C target-cpu=<device_without_sram> cases because SRAM is minimum requirement for non-assembly language in both avr-gcc and LLVM.
  - See https://github.com/rust-lang/rust/pull/146900#issuecomment-3323558005 for details.

LLVM also has `smallstack`, `wrappingrjmp`, and `memmappedregs` features, but I skipped them because they didn't seem to belong to either of the above categories, but I might have missed something.

(The feature names are match with [definitions in LLVM](https://github.com/llvm/llvm-project/blob/llvmorg-21.1.0/llvm/lib/Target/AVR/AVRDevices.td).)

cc @Patryk27 @Rahix
r? workingjubilee

@rustbot label +O-AVR +A-target-feature
2026-02-07 09:41:06 +01:00
..
analyze_source_file Be more accurate about calculating display_col from a BytePos 2024-07-18 20:08:38 +00:00
edit_distance update cfg(bootstrap) 2025-01-08 21:26:39 +01:00
source_map Overhaul filename handling for cross-compiler consistency 2025-12-12 07:33:09 +01:00
symbol Introduce ByteSymbol. 2025-06-30 20:42:27 +10:00
analyze_source_file.rs Add LSX accelerated implementation for source file analysis 2025-09-28 09:35:07 +08:00
caching_source_map_view.rs Hash all spans relatively to their parent 2026-01-08 21:20:17 +01:00
def_id.rs Rename trait DepNodeParams to DepNodeKey 2026-02-04 11:54:00 +11:00
edit_distance.rs use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
edition.rs split out blob decode trait 2025-12-08 00:24:28 +01:00
fatal_error.rs Move LTO to OngoingCodegen::join 2025-11-23 10:33:52 +00:00
hygiene.rs Fix control flow in assert_default_hashing_controls. 2026-02-06 09:18:18 +11:00
lib.rs Remove rustc_span::HashStableContext::hash_spans. 2026-02-06 09:18:18 +11:00
profiling.rs Overhaul filename handling for cross-compiler consistency 2025-12-12 07:33:09 +01:00
source_map.rs Overhaul filename handling for cross-compiler consistency 2025-12-12 07:33:09 +01:00
span_encoding.rs Fix doc-comment. 2025-08-10 23:01:45 +00:00
symbol.rs Add avr_target_feature 2026-02-05 19:58:41 +09:00
tests.rs fix(span): track unnormalized source len for dep-info 2025-11-15 09:05:08 -05:00