These operations implement the optional copy of a non contiguous
variable into a temporary before a call, and the copy back from the
temporary after the call.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
All builds and tests correctly, but it looks like some changes are needed to HLFIROps.td.
flang/include/flang/Optimizer/HLFIR/HLFIROps.td | ||
---|---|---|
533 | Should this be "copies the data"? | |
534–537 | I didn't understand this sentence. | |
541 | Should read "In such cases ..." | |
579–587 | "getHandleNullBox()" is not used anywhere. Do we need it? Both of these functions would read more clearly if their names evoked the fact that they return bools. For example, "handlesNullAddr". I couldn't find a definition of "getHandleOptional" anywhere. |
flang/include/flang/Optimizer/HLFIR/HLFIROps.td | ||
---|---|---|
530 | nit: maybe mention the return value (result(0)) in this case, so that "Otherwise" below does not look lonely. | |
560 | Can you please document this parameter? Is the intended usage to produce !fir.box, when the temporary value is "don't care" after the call, and !fir.ref otherwise? | |
577 | nit: it seems a two-bit enum could have been more clear, but I can accept bool for this purpose as well :) | |
598 | typo? $var is provided **and** $was_copied is true? |
Simplify the operation and answers comments:
- Instead of indicating with a flag how a variable can be optional (null box or null address in box), pass an extra boolean value when the input is optional to indicate if it is present.
- Instead of allowing the operation to return a raw address of box, always returns a box: the box is always created, and it is needed anway when there is a copy-back.
flang/include/flang/Optimizer/HLFIR/HLFIROps.td | ||
---|---|---|
534–537 | Rephrased the sentence and removed the part in parenthesis that brings little here. | |
560 | I changed the operation to always return a fir.box because it made things a lot simpler, so I removed this boolean. | |
577 | Fair point, an MLIR enum would have save custom printing/parsing. I anyway removed this while simplifying the operation. | |
579–587 | I removed those while reworking the operation. This patch is like adding am API for review, the actual usage of the API will come in a later patch.
MLIR generates getters automatically for all the names after "let arguments = " it convert the snake case .td name syntax (handle_optional) to camel case (getHandleOptional). See https://mlir.llvm.org/docs/DefiningDialects/Operations/#operation-arguments for more details. |
nit: maybe mention the return value (result(0)) in this case, so that "Otherwise" below does not look lonely.