Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

[LLVM] Implement missing LLVM IR instructions #276

Open
16 tasks
ftynse opened this issue Nov 26, 2019 · 11 comments
Open
16 tasks

[LLVM] Implement missing LLVM IR instructions #276

ftynse opened this issue Nov 26, 2019 · 11 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ftynse
Copy link
Contributor

ftynse commented Nov 26, 2019

The following LLVM IR instructions are currently not modeled by the LLVM dialect. Each of this is a great starter bug to implement a new Op in MLIR.

  • switch (work in progress)
  • indirectbr
  • invoke
  • callbr
  • resume
  • catchswitch
  • catchret
  • cleanupret
  • fence
  • cmpxchg
  • atomicrmw
  • freeze
  • va_arg
  • landingpad
  • catchpad
  • cleanuppad
@ftynse ftynse added enhancement New feature or request good first issue Good for newcomers labels Nov 26, 2019
@uenoku
Copy link

uenoku commented Nov 27, 2019

Hi, I'm interested in this. May I work on some of these instructions?

@ftynse
Copy link
Contributor Author

ftynse commented Nov 27, 2019

You are very welcome to! Consider mentioning here which ones do you work on, in case somebody else wants to take the others.

include/Dialect/LLVMIR/LLVMOps.td has definitions of existing ops and should be fine as a template for more ops. Feel free to ping me as on the pull request when ready. Don't hesitate to reach out to the mailing list if you have questions.

@uenoku
Copy link

uenoku commented Nov 27, 2019

Thanks. Then, I'd like to work on switch instruction first.

@bondhugula
Copy link
Contributor

The following LLVM IR instructions are currently not modeled by the LLVM dialect. Each of this is a great starter bug to implement a new Op in MLIR.

  • switch
  • indirectbr
  • invoke
  • callbr
  • resume
  • catchswitch
  • catchret
  • cleanupret
  • fence
  • cmpxchg
  • atomicrmw
  • freeze
  • va_arg
  • landingpad
  • catchpad
  • cleanuppad

It would be good to add some of the useful LLVM intrinsics to this list. llvm.prefetch is already done by this PR: #225

@ftynse
Copy link
Contributor Author

ftynse commented Dec 2, 2019

Define "useful". If we count extensions like NVVM, there are literally thousands of intrinsics...

Fortunately, they are defined in Tablegen files unlike instructions, so my general thinking is that we should auto-generate all of them. I have a prototype dusting in the corner if somebody is willing to pick it up.

@bondhugula
Copy link
Contributor

Define "useful". If we count extensions like NVVM, there are literally thousands of intrinsics...

It's a bit hard to define, but what I meant was "more commonly used" or "of imminent use" based on what we hear on the MLIR mailing list / design meetings. It did appear to me that a number of things in the list you have above aren't really of immediate use. Eg: landingpad, freeze, atomic memory ordering - is there a reason to have these before things like llvm.sqrt, llvm.powi, llvm.memcpy? The question of auto-generation is separate - they still have to be added to the TableGen file, right? Or did you mean auto-generating the .td file descriptions as well?

Fortunately, they are defined in Tablegen files unlike instructions, so my general thinking is that we should auto-generate all of them. I have a prototype dusting in the corner if somebody is willing to pick it up.

@antiagainst
Copy link
Contributor

+1 to autogen the .td file. FWIW, that's the approach we are using for the SPIR-V dialect. We have a gen_spirv_dialect.py script that downloads both the HTML and JSON grammar and updates SPIRV*.td files automatically. It is very handy for defining new ops and makes it easy to stay up to date with the spec too.

@ftynse
Copy link
Contributor Author

ftynse commented Dec 2, 2019

It's a bit hard to define, but what I meant was "more commonly used" or "of imminent use" based on what we hear on the MLIR mailing list / design meetings.

I don't have data on what are the most commonly used ones, and it may depend on use cases :) Therefore, I wouldn't make a judgement call about usefulness here. If there are imminent users, they are free to add intrinsics on per-need basis. This has been the case for the LLVM dialect in the past, but as we the project grows and moves to LLVM, we aim to be feature-complete in modeling core LLVM IR.

The question of auto-generation is separate - they still have to be added to the TableGen file, right? Or did you mean auto-generating the .td file descriptions as well?

There is this file https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/IR/Intrinsics.td that defines (or transitively includes) intrinsics. Whether we generate an ODS file from it or use it directly to generate MLIR Op definitions in C++ is up for discussion.

@shraiysh
Copy link

shraiysh commented Dec 20, 2019

Hi, I would like to take up indirectbr as my first issue. Will take it up in the llvm monorepo.

@marbre
Copy link

marbre commented Jan 2, 2020

Is this issue still up to date? So far it was at least not transferred to LLVM bug tracker, as mentioned in docs.

@ftynse
Copy link
Contributor Author

ftynse commented Jan 2, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants