Skip to content

M68k rzil base - #6706

Merged
b1llow merged 5 commits into
devfrom
m68k-il-base
Oct 11, 2026
Merged

b1llow merged 5 commits into
devfrom
m68k-il-base

Conversation

@b1llow

@b1llow b1llow commented Sep 5, 2026

Copy link
Copy Markdown
Member

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository.
  • I made sure to follow the project's coding style.
  • I've documented every RZ_API function and struct this PR changes.
  • I've added tests that prove my changes are effective (required for changes to RZ_API).
  • I've updated the Rizin book with the relevant information (if needed).
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

Adds core RzIL support for M68K, CPU32, and ColdFire, split from #6547 to make review easier. FP lifting will follow separately.

Covers integer arithmetic, bit operations, data transfers, control flow, stack operations, CPU32 table interpolation, and ColdFire MAC/EMAC.

FP decoding and register metadata remain available, but FP instructions produce no IL.

AI assistance: OpenAI Codex (GPT-5), used for implementation, fixes, and tests.

Test plan

Trace testing used Rizin 691e12265854, QEMU bce9b9d04d72 (trace producer PR), and rz-tracetest a4cf3ba22a4c (M68K adapter PR).

The non-FP matrix covers 210 instruction IDs, 44,627 encoding/profile cases, and 116,831 case/path executions. ColdFire FF1 is included.

CPU IDs Clean-pass IDs Untestable IDs Failed IDs Trace tests
68000 117 105 (89.7%) 6 (5.1%) 6 (5.1%) 6,497
68010 121 106 (87.6%) 7 (5.8%) 8 (6.6%) 6,574
68020 156 115 (73.7%) 27 (17.3%) 14 (9.0%) 8,776
68030 162 115 (71.0%) 25 (15.4%) 22 (13.6%) 8,776
68040 167 52 (31.1%) 25 (15.0%) 90 (53.9%) 8,810
68060 170 114 (67.1%) 25 (14.7%) 31 (18.2%) 8,815
cpu32 150 105 (70.0%) 27 (18.0%) 18 (12.0%) 7,990
coldfire 152 49 (32.2%) 13 (8.6%) 90 (59.2%) 7,633
cfv1 143 49 (34.3%) 8 (5.6%) 86 (60.1%) 7,350
cfv2 136 25 (18.4%) 8 (5.9%) 103 (75.7%) 7,307
cfv3 136 43 (31.6%) 8 (5.9%) 85 (62.5%) 7,323
cfv4 145 49 (33.8%) 8 (5.5%) 88 (60.7%) 7,479
cfv4e 148 27 (18.2%) 9 (6.1%) 112 (75.7%) 7,625
cfv5 152 49 (32.2%) 13 (8.6%) 90 (59.2%) 7,633
  • Clean-pass: at least one passing execution and no remaining failure; explicitly skipped cases are allowed.
  • Untestable: all executions skipped.
  • Failed: at least one unresolved comparison, decode/lift/runtime failure, or infrastructure failure. This is not a count of confirmed Rizin bugs.
  • Trace tests: target-instruction post-state comparisons, excluding setup instructions, skipped or missing targets, malformed fixtures, and failures before comparison.

QEMU is not the architectural oracle; semantic adjudications use official manuals. Raw results are retained, and exclusions are qualified by specific encoding/state/trace evidence rather than mnemonic-wide skips.

Producer limitations: cpu32 uses QEMU m68020; coldfire, cfv1, cfv3, cfv4, and cfv5 use any; cfv2 uses m5208. These results are not hardware validation.

Closing issues

Related to #5847. FP lifting remains follow-up work.

@github-actions github-actions Bot added rz-test RzAnalysis RzCore RZIL AI/LLM Partially or fully AI generated. Critical thinking is advised! labels Sep 5, 2026
@codecov

codecov Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.15789% with 371 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.50%. Comparing base (4524294) to head (c497269).

Files with missing lines Patch % Lines
librz/arch/isa/m68k/m68k_cs.c 44.20% 130 Missing and 48 partials ⚠️
librz/arch/isa/m68k/m68k_il_helpers.c 72.88% 72 Missing and 50 partials ⚠️
librz/arch/p/analysis/analysis_m68k_cs.c 69.26% 39 Missing and 24 partials ⚠️
librz/arch/p/asm/asm_m68k_cs.c 70.37% 2 Missing and 6 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
librz/arch/isa/m68k/m68k_cs.h 100.00% <100.00%> (+6.25%) ⬆️
librz/arch/isa/m68k/m68k_il.c 66.07% <ø> (ø)
librz/core/cfile.c 47.87% <100.00%> (+0.27%) ⬆️
librz/arch/p/asm/asm_m68k_cs.c 71.42% <70.37%> (+12.93%) ⬆️
librz/arch/p/analysis/analysis_m68k_cs.c 79.95% <69.26%> (+1.39%) ⬆️
librz/arch/isa/m68k/m68k_il_helpers.c 72.88% <72.88%> (ø)
librz/arch/isa/m68k/m68k_cs.c 44.20% <44.20%> (ø)

... and 20 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4524294...c497269. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Rot127 Rot127 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did a quick check on the test coverage. Please add tests to check the following:

  • m68k_fill_fpu_hidden_dst
  • The uncovered code guarded by RZ_CAPSTONE_HAS_M68K_FP_FORMATS and RZ_CAPSTONE_HAS_M68K_COLDFIRE
  • Codecov is buggy and I can't see the m68k_il.c coverage. But please make sure that the most common instructions (branches etc.) are all tested.

@wargio

wargio commented Sep 8, 2026

Copy link
Copy Markdown
Member

also needs to resolve the conflicts

@Rot127 Rot127 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the wrong PR before (#6547 (review)). Sorry.
But lgtm.

@b1llow
b1llow force-pushed the m68k-il-base branch 2 times, most recently from b7a7c4a to 09aefd4 Compare October 9, 2026 13:11
@b1llow
b1llow enabled auto-merge (squash) October 10, 2026 10:20
Co-authored-by agent: Codex/GPT-5

Co-authored-by agent: Codex/GPT-6
Integrate the lifter with the M68K analysis plugin and provide shared
effective-address, register, condition-code, and stack-bank helpers.

Implement integer arithmetic, bit operations, control flow, and
privileged operations, including CPU32 table interpolation and ColdFire
MAC/EMAC instructions with CPU-specific behavior.

Add IL snapshots and execution regressions covering arithmetic flags,
effective addresses, register aliasing, exception returns, privilege
checks, and decoder edge cases. Leave floating-point instruction lifting
outside this change.

Co-authored-by agent: Codex/GPT-5

Co-authored-by agent: Codex/GPT-6
Exercise hidden FPU destinations, floating-point format metadata, ColdFire
operand values, every integer condition, and representative integer and
control-flow effects through public analysis and IL VM APIs. Register the
suite for bundled Capstone builds.

Sign-extend absolute-short memory addresses consistently in analysis values,
OPEX, and JMP/JSR targets, matching the architectural execution result.

Co-authored-by agent: Codex/GPT-6
Construct integer and fractional EV expressions only in the EMAC branch
that attaches them to the returned IL tree. Non-EMAC accumulator copies
preserve EV without allocating unused expression trees.

Add 18 accumulator-copy execution cases across ColdFire, CFv4e, and CFv5,
covering signed, unsigned, and fractional modes with both initial EV values.
The LSan unit suite reports 6912 leaked bytes before the fix and none after.

Co-authored-by agent: Codex/GPT-6
@notxvilka

Copy link
Copy Markdown
Contributor

@b1llow please resolve the conflict and feel free to merge

Preserve the M68K RzIL feature flags and filtered-list entries alongside
upstream TMS320 c28x metadata and corresponding table widths.

Co-authored-by agent: Codex/OpenAI (model unspecified)
@b1llow
b1llow merged commit e16786f into dev Oct 11, 2026
41 of 45 checks passed
@b1llow
b1llow deleted the m68k-il-base branch October 11, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants