Skip to content

ILGPU v2.0: New AOT, new IR, new Backends, new Roslyn frontend - #1577

Open
m4rs-mt wants to merge 257 commits into
masterfrom
new_aot
Open

m4rs-mt wants to merge 257 commits into
masterfrom
new_aot

Conversation

@m4rs-mt

@m4rs-mt m4rs-mt commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Delivers a complete IR rewrite and the AOT compiler pipeline that runs on top of the runtime library from PRs #1355 and #1576. This is the largest of the four PRs by content and the core of the new compilation model. All changes land under Src/ILGPUC/.

The first commit is a PR-merge placeholder representing the runtime-library PRs; once that lands on master this placeholder is replaced by the real merge.

A note on authorship - AI warning

Some bits of the Roslyn-frontend work in this PR was done with AI-assistant pair programming (Claude via Claude Code).

What's in this PR

The IR is rewritten from scratch

  • Old IR retired. The legacy IR/Construction builders (25 files), IR/Types type system (16 files), and IR/Values value nodes (28 files) are removed. All in total 69 files dropped — these had grown organically and did not fit the new pure-value / basic-block-value / method-value layering that the rest of the pipeline needs.
  • New IR value hierarchy introduced. Four new families, totalling 68 new files:
    • IR/ModuleValues/ — module-level values including Module, MethodHandle, primitive / void / pointer / structure / array / handle / kind / object / padding type values, builders, and the Undefined sentinel.
    • IR/MethodValues/ — method-scope parameters, return values, method calls, invocations.
    • IR/PureValues/ — the new side-effect-free value layer: arithmetic, cast, convert, compare, predicate, structure, array, view, primitive, constant, bitwise, interop, IO, thread, intrinsic, language, memory-read, load, and friends.
    • IR/BasicBlockValues/ — block-local values (phi, method call, load/store, atomic, debug, language, terminators, branches).
  • Analyses, rewriting, and transformations modernised. New dominator-tree, call-graph, loop-info, reachability, CFG, value-use, liveness, address-space, and alignment analyses. New rewriter infrastructure (Rewriter, BlockRewriter, ValueRewriter, MethodRewriter). New transformation base classes (Transformation, ModuleTransform, MethodTransform, BasicBlockTransform, PureValueTransform) plus SSA builder / cleanup, collective-op recognition, group / warp collective lowering, custom-atomic lowering, GC-init lowering, dead-load elimination, closure elimination, debug setter, and Metal kernel / split-view lowering. Obsolete passes retired (CleanupBlocks, CodePlacement, DeadCodeElimination, LoopInvariantCodeMotion, LoopUnrolling, UnreachableCodeElimination, LowerStructures, ImplementIntrinsics, and the legacy Transformation.cs).

The frontend is updated end-to-end

  • IL code generator refined. The 12-file Frontend/CodeGenerator/ subsystem is updated to emit the new IR node kinds (arithmetic, comparison, cast, memory, branches, calls, structures, arrays, phi resolution).
  • Intrinsic registry reorganised. Frontend/Intrinsic/ grows a new bitwise handler and refines the registry (Intrinsics, InterinsicProvider), the thread-hierarchy intrinsics (Accelerator, Grid, Group, Warp), math / compare / convert / atomic / arrays / views / activator / interop / compiler-services / debug / utility handlers.
  • Legacy ILGPUC/Intrinsic/ retired — its handlers have moved into the frontend structure above.

All backends are rebuilt on a shared framework

  • PTX backend retired. All 38 files under Backends/PTX/ (backend, code generator, emitter, terminators, values, views, function generator, debug info generator, instruction data, PTX API wrappers for LibDevice / NVVM, block-schedule analyses, and the PTX intrinsic set including math sub-family) are removed.
  • Legacy IL / EntryPoints / PointerViews / SeparateViews backends retired (9 files). Top-level InvalidCodeGenerationException, NotSupportedIntrinsicException, PhiBindings, RegisterAllocator, VariableAllocator also retired (5 files).
  • Shared backend framework added (16 new). CodeGenerator, GenerationContext, MethodEmitter, ExpressionEmitter, TypeEmitter, LauncherEmitter, FlatStructLauncherEmitter, PerArgumentLauncherEmitter, CompiledKernelEmitter, CompiledKernelGenerator, CompiledKernelSourceGenerator, ControlFlowReconstructor, SSAVariableAllocator, IntrinsicEmitter, LanguageConfiguration, and RemoteCompilerManager. Backend.cs refined to use them.
  • Five new per-backend implementations (32 new files: CPU 10, CUDA 5, Metal 5, OpenCL 7, ROCm 5). Each provides a CodeGenerator, EntryPoint, CompiledKernel, IntrinsicEmitter, and per-backend specialisations.

Roslyn source generator introduced

  • Kernel discovery (Roslyn/Analysis/, 6 files) — scans user code for kernel entry points, collects methods and attributes, resolves invocations.
  • Launch-site emission (Roslyn/Generation/, 7 files) — rewrites kernel launch sites and emits strongly-typed wrappers so user code invokes the compiler-generated launcher rather than a reflection-based path.

Command-line compiler and MSBuild wiring

  • Program options (9 new files under ProgramOptions/) — ProgramOptions base, OptionParser, CompileOptions, BuildOptions, and the remaining command shapes.
  • KernelCompiler facade — bridges frontend, IR, and backends into a single entry point.
  • CLI entry point and compilation properties refined (Program.cs, CompilationProperties.cs).
  • MSBuild integration targets added under Src/ILGPUC/build/ (ILGPUC.targets, ILGPU.Kernels.targets, README.md) so downstream projects can invoke ilgpuc build transparently.

Scope boundary

No changes to testing or other infrastructure to run and validate outputs. Those will land in follow-up PRs.

Depends on

PRs #1355 and #1576.

Fixes

Fixes #847, fixes #463, fixes #1538, fixes #1539, fixes #1479, fixes #1309, fixes #1240, fixes #1361, fixes #1359, fixes #1305, closes #1476, closes #415, closed #1364

closes #1012 - The new IR provides the basic building blocks to enable this
closes #996 - The new IR provides the basic building blocks to enable this
closes #923 - The new IR provides the basic building blocks to enable this; we want to revisit reduced precision in future releases
closes #1324 - The new frontend implementation supports deriving default interface implementations natively
closes #1296 - GC holes have been assessed and removed in the compilation pipelines
closes #1232 - Native AOT support has been enabled by design using the latest compilation improvements
closes #1545 - These fixes are no longer required :)
closes #1143 - Is considered out-of-scope for now
closes #1107 - Is considered out-of-scope for now
closes #1408 - Is considered out-of-scope for now
closes #1209 - is considered out-of-scope for now

m4rs-mt added 30 commits August 5, 2025 19:25
m4rs-mt and others added 15 commits December 14, 2025 19:47
Co-Authored-By: Claude <noreply@anthropic.com>
…ation.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…kends.

Co-Authored-By: Claude <noreply@anthropic.com>
@m4rs-mt m4rs-mt added this to the v2.0 milestone Apr 19, 2026
m4rs-mt added a commit that referenced this pull request Apr 19, 2026
m4rs-mt added a commit that referenced this pull request Apr 19, 2026
@m4rs-mt
m4rs-mt force-pushed the new_aot branch 2 times, most recently from c744b51 to c14e465 Compare April 19, 2026 22:59
m4rs-mt added a commit that referenced this pull request Apr 19, 2026
m4rs-mt added a commit that referenced this pull request Apr 19, 2026
m4rs-mt added a commit that referenced this pull request Apr 20, 2026
m4rs-mt added a commit that referenced this pull request Apr 20, 2026
m4rs-mt added a commit that referenced this pull request Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment