Add avr_target_feature by taiki-e · Pull Request #146900 · rust-lang/rust (original) (raw)
This adds the following unstable target features (tracking issue: #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 Support AVRTiny devices in AVR inline assembly #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 llvm/llvm-project@2a52876)
- The followings help recognizing whether specific instructions are available:
addsubiwbreakeijmpcallelpmelpmxijmpcalljmpcalllpmlpmxmovwmulrmwspmspmxsram
Of these, all exceptaddsubiw,break,ijmpcall,lpm,rmw,spm,spmx, andsramhave corresponding conditional codes in avr-libc. LLVM also hasdesfeature, but I excluded it from this PR because DES is insecure.
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.)
cc @Patryk27 @Rahix
r? workingjubilee
@rustbot label +O-AVR +A-target-feature