Abstraction raising

I am working on raising the abstraction level from imported C-code.

Basically, we compile snippets representing interpreter instruction behavior (these are implemented in C, with language specific intrinsics) to LLVM IR, then import that in the MLIR LLVM dialect and from there apply the conversion framework to turn this into another dialect which is higher level to some extent. The dialect does expect to convert intrinsics to instructions. On the other hand some of our dialect is inspired by Generic Machine IR, so we have low level instructions as well in it.

The usecase is to generate a code generator for our interpreter with faster code generation speed (but naturally lower optimization level) than ORCjit can provide, for use in a tier 1 JITter for our project. ORCjit can still be used at a higher tier.

In any case, has anyone else worked with raising abstraction levels in MLIR, maybe there are some lessions learned available?

I am taking notes and will append these to this thread, I think we already had some issues when deleting function arguments for example, but I will come back with more info later.

There are 2 contributions in that area that I know of:

and

1 Like

Drive by: All these stages, are we really expecting this to be faster (wrt. compile time) than ORCJit? If you do this, would be very interesting to let people know how it turned out.

Yes this is expected, because we are using MLIR offline for generating a code generator that will be emitting machine code directly; we will not emit IR for processing at runtime.

Of-course, this means that only trivial optimisations are applied that can be done quickly, like some naive register allocation, constant evaluation and some isel level stuff like strength reduction of multiplies / divides with power of two constants.

Iā€™d be very interested in seeing what you are doing on the topic, to the extent it is public!

I am sure we will write a paper about this in a couple of months :slight_smile:

The code is here https://github.com/wsmoses/Polygeist. Most of the raising stuff I am aware of does not use the conversion framework.

1 Like