Added coredsl.switch - #4
Conversation
74abd8d to
24998fc
Compare
|
I tend to be forgettable. I think we already had the discussion, but I can't recall the outcome. What is the reasoning to introduce our own switch operation instead of using https://mlir.llvm.org/docs/Dialects/ControlFlowDialect/#cfswitch-cfswitchop ? Especially since the implementation seems to add quite a lot of code. |
|
The original problem I though cf.switch had was that it only seems to support values up to i32. I looked at this more closely later and this was a misunderstanding on my part. |
|
The conversion from cf to scf has to happen before lowering anyway, so I would assume there is a single cast to the index type for the scf.index_switch operation. If the transformation to a scf.If-else tree follows immediately, index types won't be practically visible. |
|
If we ever decide to support loops with break and continue functionality, then cf dialect and ControlFlowToSCFInterface is the way to go anyway |
|
Ok, then I'll work on the implementation using cf.switch. Am I right in assuming that this needs some changes in shortnail as well, such as allowing use of the cf dialect inside the coredsl dialect? |
Guess we will see :'D |
This is a modified version of scf.index_switch, which takes arbitrary integer arguments instead of the index type. This required creating the coredsl.yield operation, which is the yield statement for coredsl.switch.
Most of the code is almost the same as scf.index_switch, but there are some additional size checks for the integer arguments.