Skip to content

Cranelift: make legalization groups smarter #1745

Description

@abrown

I am trying to implement a legalization for imul.i64x2 that must be a custom legalization function. It needs to have logic to look at the ISA-specific flags to determine what legalization to use; I know, I know, this would be fixed by the new backend, but in the meantime I would like to implement this legalization. I cannot find a good transform group to put this custom legalization in: if I put it in x86_narrow, the legalization search stops too soon and things like i128 (in narrow) don't get legalized. If I put it in another transform group, e.g. expand, I have to add i64x2 as a type the group legalizes, which prevents other i64x2 operations from being legalized (all of these are currently in x86_narrow). What can I do?

  • I could move all of the SIMD operations to x86_expand but when I do this I run into conflicts with other operations (e.g. ineg)
  • I could duplicate the logic from the shared narrow imul legalizations to my custom function
  • I could make transform groups smarter somehow, e.g. by registering custom functions for an instruction AND a type (not just an instruction) or by allowing custom functions to return a result indicating if they succeeded (if they do, we stop; if they don't, we continue looking in other groups)

Would appreciate some help thinking through this, @bnjbvr. CCing @iximeow and @whitequark as well since it could be remotely related to #1743.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions