Skip to content

cranelift: Add support for BPF code generation #14236

Description

@oddcoder

Feature

I need BPF back end code generator that is not a 100MB in size, cranelift looks ideal (based on AI prototypes).

BPF is small RISC style ISA that should be relatively straightforward to implement.

Benefit

I am working on a scripting language that compiles down to BPF and is meant to be stapable to production systems. I need a lightweight optimizing JIT capable of producting BPF assembly to be loaded in relatively constrained environments.

Currently the alternatives are one of the following:

A- compile down to bpf byte code and ship it. Sometimes that can be impractical when having diverse machines with diverse kernel versions.

B- Strap a full LLVM toolchain to to the script so that it compiles on target

Implementation

I have no idea yet how to do it yet. I hope you would surprise me by saying this a) exists b) is WIP and is fully resourced.

If not, AI was able to prototype an implementation via traversing IR and generating assembly. So least I know it is doable.

I read a bit about ISLE, and I am kind of familiar with term rewriting in general due to previous experience with proof tactics in coq.

I patched cranelift to expose its internals for an out of tree implementation of a backend. I will be doing my own implementation in traqilet/crates/bpf, by copying alot from the structure of existing backends and will PR the back-end bit by bit.

Alternatives

I am not aware of any reasonable alternatives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions