m4rs-mt / ILGPU

ILGPU JIT Compiler for high-performance .Net GPU programs
http://www.ilgpu.net
Other
1.34k stars 115 forks source link

[NativeAOT] Implement IRExporter API #1214

Closed IsaMorphic closed 3 months ago

IsaMorphic commented 4 months ago

As the first part of the long deliberated NativeAOT feature implementation, I have created the following set of internal APIs that ILGPU consumes in order to provide a uniform, flattened representation of the IR graph to the end user:

Additionally, the following public APIs are exposed to end users of the ILGPU compiler for this purpose:

The intended use-case for this API is for the end user to inject IRExporterHook into their desired backend via the provided DI mechanism, and from that extract IRExporterHook.CurrentContext.ExportContainer once the initial code generation / optimization phase is completed.

Runtime recovery of an IRContext from this exported representation will be written in the next PR (link pending!)

TODOs:

IsaMorphic commented 3 months ago

I believe this should all build now, I even went in and substituted the C# 12.0 specific "Collection initializers" feature for proper array initializers so that everything backports OK to net6.0. I will also be opening a draft PR containing the IRImporter class.