LLVM MC "Dialects" / MLIR all-the-way-down compilation

This was one of the initial design goals of MLIR, but most of the work in the core repository and around is currently focused on the higher-than-LLVM levels of abstraction. It would be very interesting to see the other end.

So far, the LLVM IR dialect is treated as sink in the lowering pipeline. We don’t do any meaningful transformations at that level and defer to LLVM proper for that purpose. There exists a prototype of LLVM IR importer, and some interest in making it more robust so that we can consume optimized IR produced by LLVM (ping @sanjoy_das_google). This may be helpful for your use case to import the IR and keep lowering it down to some machine-specific format.

MLIR pattern-rewriting infrastructure that underpins most lowerings has some small heuristic mechanisms, but wasn’t designed as a global optimization problem. It can be extended or partially reused for that purpose.

@nicolasvasilache discussed [Abandoned][RFC] AVX512-specific Dialect for implementing and benchmarking XNNPack in MLIR, which later led to [RFC] Starting an AVX512 Target-Specific Dialect - Rebooted - #8 by nicolasvasilache that has been upstreamed. This dialect targets LLVM IR intrinsics, so it operates on a higher level than MC, but I suppose can be repurposed, describing operations from both sides of LLVM IR.