| Issue |
241056
|
| Summary |
Unhandled instructions in m68k inline assembly parsing
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
workingjubilee
|
From @ketsuban in https://github.com/rust-lang/rust/issues/165239:
> The following 68000 instructions produce an "unexpected token parsing operands" error when used in inline assembly.
>
> * [DBRA, DBF](https://68k.hax.com/DBccDBRA) (I assume all condition codes would fail similarly)
> * [ADDI](https://68k.hax.com/ADDI), [SUBI](https://68k.hax.com/SUBI) (I assume [ANDI](https://68k.hax.com/ANDI), [ORI](https://68k.hax.com/ORI), [EORI](https://68k.hax.com/EORI) and [CMPI](https://68k.hax.com/CMPI) would fail similarly)
> * [ADDQ](https://68k.hax.com/ADDQ), [SUBQ](https://68k.hax.com/SUBQ) (I assume [MOVEQ](https://68k.hax.com/MOVEQ) would fail similarly)
LLVMIR:
```llvm
; ModuleID = 'm68k.e6a4e67468a75b11-cgu.0'
source_filename = "m68k.e6a4e67468a75b11-cgu.0"
target datalayout = "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16"
target triple = "m68k"
; Function Attrs: nounwind
define dso_local void @entrypoint() unnamed_addr #0 !guid !1 {
start:
%0 = tail call { i32, i32, i32 } asm sideeffect alignstack ".global _sidata\0A.global _sdata\0A.global _edata\0Amove.l #_edata, %d0\0Asubi.l #_sdata, %d0\0Asubq.l #1, %d0\0Abmi.s 2f\0Alea _sdata, %a0\0Alea _sidata, %a1\0A1:\0Amove.b (%a1)+, (%a0)+\0Adbra %d0, 1b\0A2:", "=&{a0},=&{a1},=&{d0},~{ccr},~{memory}"() #1, !srcloc !2
%1 = tail call { i32, i32 } asm sideeffect alignstack ".global _sbss\0A.global _ebss\0Amove.l #_ebss, %d0\0Asubi.l #_sbss, %d0\0Asubq.l #1, %d0\0Abmi.s 2f\0Alea _sbss, %a0\0A1:\0Aclr.b (%a0)+\0Adbra %d0, 1b\0A2:", "=&{a0},=&{d0},~{ccr},~{memory}"() #1, !srcloc !3
ret void
}
attributes #0 = { nounwind "target-cpu"="M68010" }
attributes #1 = { nounwind }
!llvm.ident = !{!0}
!0 = !{!"rustc version 1.101.0-nightly (92ffebece 2026-10-28)"}
!1 = !{i64 -7939022165058540050}
!2 = !{i64 704374636693, i64 833223655604, i64 962072674514, i64 1112396529904, i64 1262720385299, i64 1391569404214, i64 1494648619348, i64 1627792605548, i64 1765231559051, i64 1842540970411, i64 2001454760381, i64 2121713844706, i64 2199023256062}
!3 = !{i64 2890512990868, i64 3015067042481, i64 3161095930574, i64 3307124818672, i64 3435973837586, i64 3539053052720, i64 3667902071624, i64 3745211482982, i64 3865470567288, i64 3985729651604, i64 4063039062960}
```
Errors were originally surfaced from running rustc (or more specifically, `cargo build -Zbuild-std --target=m68k-unknown-none-elf --release`) on this code, and then dumping the LLVMIR.
```rust
#![no_std]
#![feature(asm_experimental_arch)]
#[unsafe(no_mangle)]
pub unsafe fn entrypoint() {
unsafe {
core::arch::asm! {
".global _sidata",
".global _sdata",
".global _edata",
"move.l #_edata, %d0",
"subi.l #_sdata, %d0",
"subq.l #1, %d0",
"bmi.s 2f",
"lea _sdata, %a0",
"lea _sidata, %a1",
"1:",
"move.b (%a1)+, (%a0)+",
"dbra %d0, 1b",
"2:",
out("a0") _,
out("a1") _,
out("d0") _,
}
}
unsafe {
core::arch::asm! {
".global _sbss",
".global _ebss",
"move.l #_ebss, %d0",
"subi.l #_sbss, %d0",
"subq.l #1, %d0",
"bmi.s 2f",
"lea _sbss, %a0",
"1:",
"clr.b (%a0)+",
"dbra %d0, 1b",
"2:",
out("a0") _,
out("d0") _,
}
}
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs