Skip to content

backend: add missing op support for LLVM translation #6073

Description

@sueszli

Add missing op support for the LLVM translation path.

The previous work in #6009 established MLIR compatibility and confidence in xdsl-translate, but many ops still lack translation support.

Conversion passes

Missing LLVM dialect ops (non-intrinsic)

Needed by conversion passes above:

  • llvm.extractelement (convert-vector-to-llvm)
  • llvm.fptrunc (convert-arith-to-llvm)
  • llvm.uitofp (convert-arith-to-llvm)
  • llvm.fptosi (convert-arith-to-llvm)
  • llvm.fptoui (convert-arith-to-llvm)
  • llvm.switch (convert-cf-to-llvm)

Other standard LLVM ops not yet in dialect:

  • llvm.freeze
  • llvm.invoke
  • llvm.landingpad
  • llvm.resume
  • llvm.phi
  • llvm.fence
  • llvm.atomicrmw
  • llvm.cmpxchg

Missing LLVM intrinsic ops

Float unary (convert-math-to-llvm)

Float binary (convert-math-to-llvm, convert-arith-to-llvm)

Float ternary

  • llvm.intr.fmuladd

Integer intrinsics (convert-arith-to-llvm)

  • llvm.intr.abs
  • llvm.intr.bitreverse
  • llvm.intr.bswap
  • llvm.intr.ctlz
  • llvm.intr.cttz
  • llvm.intr.ctpop
  • llvm.intr.smax, llvm.intr.smin, llvm.intr.umax, llvm.intr.umin
  • llvm.intr.scmp, llvm.intr.ucmp
  • Saturating: sadd.sat, uadd.sat, ssub.sat, usub.sat, sshl.sat, ushl.sat
  • With overflow: sadd.with.overflow, uadd.with.overflow, ssub.with.overflow, usub.with.overflow, smul.with.overflow, umul.with.overflow
  • Funnel shifts: llvm.intr.fshl, llvm.intr.fshr

Masked memory (convert-vector-to-llvm)

  • llvm.intr.masked.load
  • llvm.intr.masked.gather
  • llvm.intr.masked.scatter
  • llvm.intr.masked.compressstore
  • llvm.intr.masked.expandload

Vector reductions (convert-vector-to-llvm)

  • llvm.intr.vector.reduce.add, .and, .or, .xor, .mul
  • llvm.intr.vector.reduce.fadd, .fmul, .fmax, .fmin, .fmaximum, .fminimum
  • llvm.intr.vector.reduce.smax, .smin, .umax, .umin

Memory

  • llvm.intr.memcpy
  • llvm.intr.memmove
  • llvm.intr.memset
  • llvm.intr.stacksave, llvm.intr.stackrestore
  • llvm.intr.lifetime.start, llvm.intr.lifetime.end

Lower priority (VP ops, constrained FP, coroutines, debug)

MLIR defines ~70 more intrinsics (50 VP ops, 11 constrained FP ops, 10 coroutine ops, debug/annotation ops) that are not listed here. These are unlikely to be needed in the near term.

Missing backend support


Currently implemented: 58 dialect ops, 7 intrinsic ops, 14 backend type conversions, 57 backend op conversions.

⚡ = eliminates patches_xdsl_llvm.py by enabling proper index-typed IR (no more _unwrap_i64 / _loop_upper_bound_as_i64 hacks). Combined with the GEP work in #6074.
🔥 = eliminates patches_xdsl_intrinsics.py by enabling exojit to emit vector/arith/math ops instead of named llvm.CallOp intrinsics.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendCompiler backend in xDSLdialectsChanges on the dialects

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions