mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-19 08:32:33 +00:00
rexcode: re-house ISA packages under core:rexcode/isa/<arch>
Move all ten ISA packages (x86, arm32, arm64, mips, riscv, ppc, ppc_vle, rsp, mos6502, mos65816) from core/rexcode/<arch> to core/rexcode/isa/<arch>, so the import pattern is now `import "core:rexcode/isa/x86"`. The shared core stays at core:rexcode/isa. Mechanical: relative `import "../isa"` / "../../isa" -> absolute "core:rexcode/isa" (the only path that survives the move; the "../" and "../.." self/generated imports move with their packages). build.lua now builds paths as <root>/isa/<name>; stale `cd <arch>` hints in the verify tools and the doc.odin paths updated. WASM stays at core/rexcode/wasm for now -- it is an IR, not an ISA, and will move under the forthcoming core:rexcode/ir once that layer lands. All 10 arches gen/builders/check/test green; import core:rexcode/isa/x86 verified working; wasm still compiles.
This commit is contained in:
@@ -202,7 +202,8 @@ end
|
||||
-- ----------------------------------------------------------------------------
|
||||
local ODIN, ROOT, OUT -- set in main
|
||||
|
||||
local function pkg(isa, sub) return ROOT .. "/" .. isa.name .. (sub and ("/"..sub) or "") end
|
||||
-- ISA packages live under <root>/isa/<name> (the shared isa package is <root>/isa).
|
||||
local function pkg(isa, sub) return ROOT .. "/isa/" .. isa.name .. (sub and ("/"..sub) or "") end
|
||||
|
||||
local function odin_run(target) return q(ODIN).." run "..q(target).." -out:"..q(OUT) end
|
||||
local function odin_check(target)return q(ODIN).." check "..q(target).." -no-entry-point" end
|
||||
|
||||
@@ -48,15 +48,15 @@ emits committed binary blobs that the library `#load`s into `@(rodata)` at
|
||||
compile time — no table is built during a normal library build:
|
||||
|
||||
```sh
|
||||
odin run <arch>/tablegen # ENCODING_TABLE -> generated Odin + <arch>/tables.odin
|
||||
odin run <arch>/tablegen/generated # -> <arch>/tables/<arch>.*.bin
|
||||
odin run isa/<arch>/tablegen # ENCODING_TABLE -> generated Odin + tables.odin
|
||||
odin run isa/<arch>/tablegen/generated # -> isa/<arch>/tables/<arch>.*.bin
|
||||
```
|
||||
Regenerate after editing `ENCODING_TABLE`. See `docs/table_migration.md`.
|
||||
|
||||
## Usage
|
||||
|
||||
```odin
|
||||
import "x86"
|
||||
import x86 "core:rexcode/isa/x86"
|
||||
|
||||
instructions := []x86.Instruction{
|
||||
x86.inst_r_r(.MOV, x86.RAX, x86.RDI),
|
||||
@@ -179,21 +179,21 @@ Tasks: `--gen` (table metaprograms), `--builders` (regenerate each ISA's
|
||||
Each package has its own test suite:
|
||||
|
||||
```sh
|
||||
odin run x86/tests
|
||||
odin run arm32/tests
|
||||
odin run arm64/tests
|
||||
odin run mips/tests
|
||||
odin run mos6502/tests
|
||||
odin run mos65816/tests
|
||||
odin run ppc/tests
|
||||
odin run ppc_vle/tests
|
||||
odin run riscv/tests
|
||||
odin run rsp/tests
|
||||
odin run isa/x86/tests
|
||||
odin run isa/arm32/tests
|
||||
odin run isa/arm64/tests
|
||||
odin run isa/mips/tests
|
||||
odin run isa/mos6502/tests
|
||||
odin run isa/mos65816/tests
|
||||
odin run isa/ppc/tests
|
||||
odin run isa/ppc_vle/tests
|
||||
odin run isa/riscv/tests
|
||||
odin run isa/rsp/tests
|
||||
```
|
||||
|
||||
## Verification harnesses
|
||||
|
||||
Each arch has a verification harness under `<arch>/tools/`:
|
||||
Each arch has a verification harness under `isa/<arch>/tools/`:
|
||||
- `dump_verify_input.odin` — emits the per-entry hex/asm manifest.
|
||||
- `verify_against_<tool>.*` — runs the canonical external assembler/
|
||||
disassembler and compares. LLVM-mc for the seven modern archs, plus
|
||||
@@ -203,24 +203,27 @@ Each arch has a verification harness under `<arch>/tools/`:
|
||||
|
||||
```
|
||||
rexcode/
|
||||
isa/ # shared core: labels, status, print framework, label-inference
|
||||
isa/ # shared ISA core: labels, status, print framework, label-inference
|
||||
x86/ # x86-64 / i386
|
||||
arm32/ # AArch32
|
||||
arm64/ # AArch64
|
||||
mips/ # MIPS (R1..R6 + ASEs + coprocessors)
|
||||
mos6502/ # NMOS 6502 family
|
||||
mos65816/ # W65C816S
|
||||
ppc/ # PowerPC (Power ISA 3.1)
|
||||
ppc_vle/ # Freescale VLE (sibling of ppc)
|
||||
riscv/ # RISC-V
|
||||
rsp/ # N64 RSP
|
||||
wasm/ # WebAssembly (an IR; destined for ir/wasm once the IR layer settles)
|
||||
docs/ # cross-arch design + per-arch design docs
|
||||
x86/ # x86-64 / i386
|
||||
arm32/ # AArch32
|
||||
arm64/ # AArch64
|
||||
mips/ # MIPS (R1..R6 + ASEs + coprocessors)
|
||||
mos6502/ # NMOS 6502 family
|
||||
mos65816/ # W65C816S
|
||||
ppc/ # PowerPC (Power ISA 3.1)
|
||||
ppc_vle/ # Freescale VLE (sibling of ppc)
|
||||
riscv/ # RISC-V
|
||||
rsp/ # N64 RSP
|
||||
```
|
||||
|
||||
Per-package layout (canonical, enforced by the cross-arch contract):
|
||||
Each ISA is imported as `core:rexcode/isa/<arch>` (e.g. `core:rexcode/isa/x86`); the
|
||||
shared core is `core:rexcode/isa`. Per-package layout (canonical, enforced by the
|
||||
cross-arch contract):
|
||||
|
||||
```
|
||||
<arch>/
|
||||
isa/<arch>/
|
||||
encoder.odin # encode() — two-pass, label/reloc-aware
|
||||
decoder.odin # decode()
|
||||
printer.odin # sb/sbln/print/println/aprint/aprintln/tprint/tprintln/bprint/bprintln/fprint/fprintln/wprint/wprintln
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package rexcode_arm32
|
||||
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// AArch32 DECODER
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package rexcode_arm32
|
||||
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// AArch32 ENCODING FUNDAMENTALS
|
||||
@@ -7,7 +7,7 @@ import "core:fmt"
|
||||
import "core:io"
|
||||
import "core:os"
|
||||
import "core:reflect"
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// AArch32 PRINTER
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
@@ -17,7 +17,7 @@ package main
|
||||
// /tmp/rexcode_arm32_t32w.hex / _meta.txt -- T32 32-bit (high half first)
|
||||
// /tmp/rexcode_arm32_t16.hex / _meta.txt -- T16 16-bit (2-byte halfword)
|
||||
//
|
||||
// Run: cd arm32 && odin run tools/dump_verify_input.odin -file
|
||||
// Run: cd isa/arm32 && odin run tools/dump_verify_input.odin -file
|
||||
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
@@ -87,7 +87,7 @@ main :: proc() {
|
||||
fmt.println(" llvm-mc --disassemble -triple=arm-none-eabi -mattr=+armv8,+neon,+vfp4,+crc,+crypto < /tmp/rexcode_arm32_a32.hex > /tmp/rexcode_arm32_a32_llvm.txt 2>&1")
|
||||
fmt.println(" llvm-mc --disassemble -triple=thumbv8-none-eabi -mattr=+v8.1m.main,+mve.fp,+fp.dp,+vfp4 < /tmp/rexcode_arm32_t32w.hex > /tmp/rexcode_arm32_t32w_llvm.txt 2>&1")
|
||||
fmt.println(" llvm-mc --disassemble -triple=thumbv8-none-eabi -mattr=+v8.1m.main,+mve.fp,+fp.dp,+vfp4 < /tmp/rexcode_arm32_t16.hex > /tmp/rexcode_arm32_t16_llvm.txt 2>&1")
|
||||
fmt.println("Then: cd arm32 && odin run tools/verify_against_llvm.odin -file")
|
||||
fmt.println("Then: cd isa/arm32 && odin run tools/verify_against_llvm.odin -file")
|
||||
}
|
||||
|
||||
// Fill in safe non-zero values for operand fields so LLVM can decode without
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package rexcode_arm64
|
||||
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// AArch64 DECODER
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package rexcode_arm64
|
||||
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// AArch64 ENCODING FUNDAMENTALS
|
||||
@@ -6,7 +6,7 @@ import "core:strings"
|
||||
import "core:reflect"
|
||||
import "core:os"
|
||||
import "core:io"
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// AArch64 PRINTER
|
||||
@@ -11,7 +11,7 @@ package rexcode_arm64_tests
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
import a "../"
|
||||
import "../../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
@(private="file") rpasses := 0
|
||||
@(private="file") rfailures := 0
|
||||
@@ -15,7 +15,7 @@ package main
|
||||
//
|
||||
// Then verify_against_llvm.odin reads meta + llvm output and reports mismatches.
|
||||
//
|
||||
// Run: cd arm64 && odin run tools/dump_verify_input.odin -file
|
||||
// Run: cd isa/arm64 && odin run tools/dump_verify_input.odin -file
|
||||
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
@@ -59,5 +59,5 @@ main :: proc() {
|
||||
fmt.println(" < /tmp/rexcode_aarch64_input.hex \\")
|
||||
fmt.println(" > /tmp/rexcode_aarch64_llvm.txt 2>&1")
|
||||
fmt.println("Then:")
|
||||
fmt.println(" cd arm64 && odin run tools/verify_against_llvm.odin -file")
|
||||
fmt.println(" cd isa/arm64 && odin run tools/verify_against_llvm.odin -file")
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package main
|
||||
// /tmp/rexcode_aarch64_verify_report.txt -- full report
|
||||
// /tmp/rexcode_aarch64_verify_mismatches.txt -- just the mismatches
|
||||
//
|
||||
// Run: cd arm64 && odin run tools/verify_against_llvm.odin -file
|
||||
// Run: cd isa/arm64 && odin run tools/verify_against_llvm.odin -file
|
||||
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package rexcode_mips
|
||||
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// MIPS DECODER
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package rexcode_mips
|
||||
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// MIPS ENCODING FUNDAMENTALS
|
||||
@@ -6,7 +6,7 @@ import "core:strings"
|
||||
import "core:reflect"
|
||||
import "core:os"
|
||||
import "core:io"
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// MIPS PRINTER
|
||||
@@ -13,7 +13,7 @@ package main
|
||||
// MIPS u32 instruction words go on the wire big-endian; llvm-mc's
|
||||
// `-triple=mips` consumes hex bytes in that order, so we emit byte 3,2,1,0.
|
||||
//
|
||||
// Run: cd mips && odin run tools/dump_verify_input.odin -file
|
||||
// Run: cd isa/mips && odin run tools/dump_verify_input.odin -file
|
||||
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package rexcode_mos6502
|
||||
|
||||
import "../isa"
|
||||
import "core:rexcode/isa"
|
||||
|
||||
// =============================================================================
|
||||
// MOS 6502 DECODER
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user