mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-20 00:52:33 +00:00
Merge origin/bill/rexcode: struct repack (#raw_union #packed), wasm arch
Merge gingerBill's latest into bill/rexcode. His changes: minimize the Instruction/Operand structs across ISAs with packed raw-unions (+ the compiler support for #raw_union #packed), the new core:rexcode/wasm arch and wasm/module, encode() now returns (byte_count, ok) instead of a Result struct, decode_one made public, and assorted formatting/inlining. Conflict: arm64/tests/pipeline_smoke.odin CSEL test -- kept the generated 4-arg inst_csel(dst,src,src2,cond) (mnemonic_builders.odin is generated, not from Bill's branch) and adopted Bill's (byte_count, success) encode signature. Required rebuilding ./odin from the merged source for the packed-union syntax. Re-validated after the repack: regenerated all artifacts (idempotent -- no spurious churn), all 10 arches gen/builders/check/test green, and byte-compared the new arm32 BF + mips PS/MMI/DSP/R6 forms to confirm no field truncation. arm64/arm32/mips still 100%.
This commit is contained in:
@@ -57,7 +57,7 @@ decode :: proc(
|
||||
label_defs: ^[dynamic]Label_Definition,
|
||||
errors: ^[dynamic]Error,
|
||||
endianness: Endianness = .BIG,
|
||||
) -> Result {
|
||||
) -> (byte_count: u32, ok: bool) {
|
||||
n_bytes := u32(len(data))
|
||||
if n_bytes & 3 != 0 {
|
||||
n_bytes &= ~u32(3) // ignore the dangling tail
|
||||
@@ -68,18 +68,17 @@ decode :: proc(
|
||||
defer delete(pending_branches)
|
||||
|
||||
// ---- PASS 1 -----------------------------------------------------------
|
||||
pc: u32 = 0
|
||||
for pc < n_bytes {
|
||||
word := read_u32(data, pc, endianness)
|
||||
for byte_count < n_bytes {
|
||||
word := read_u32(data, byte_count, endianness)
|
||||
|
||||
inst: Instruction
|
||||
info: Instruction_Info
|
||||
entry_idx := decode_one_inline(word, pc, &inst, &info)
|
||||
entry_idx := decode_one_inline(word, byte_count, &inst, &info)
|
||||
|
||||
if entry_idx < 0 {
|
||||
append(errors, Error{inst_idx = pc, code = .INVALID_OPCODE})
|
||||
append(errors, Error{inst_idx = byte_count, code = .INVALID_OPCODE})
|
||||
inst = Instruction{mnemonic = .INVALID, length = 4}
|
||||
info = Instruction_Info{offset = pc}
|
||||
info = Instruction_Info{offset = byte_count}
|
||||
} else {
|
||||
inst_idx_for_branches := u32(len(instructions))
|
||||
for slot in 0..<inst.operand_count {
|
||||
@@ -96,13 +95,14 @@ decode :: proc(
|
||||
|
||||
append(instructions, inst)
|
||||
append(inst_info, info)
|
||||
pc += 4
|
||||
byte_count += 4
|
||||
}
|
||||
|
||||
// ---- PASS 2: label inference -----------------------------------------
|
||||
isa.infer_labels_from_branches(pending_branches[:], pc, label_defs, relocs)
|
||||
isa.infer_labels_from_branches(pending_branches[:], byte_count, label_defs, relocs)
|
||||
|
||||
return Result{byte_count = pc, success = u32(len(errors)) == errors_start}
|
||||
ok = u32(len(errors)) == errors_start
|
||||
return
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user