[PATCH] D113763: [flang][CodeGen] Transform `fir.boxchar_len` to a sequence of LLVM MLIR
Eric Schweitz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 17:23:16 PST 2021
schweitz added a comment.
In D113763#3127219 <https://reviews.llvm.org/D113763#3127219>, @awarzynski wrote:
> IIUC, both forms are correct (based on the operation definition <https://github.com/llvm/llvm-project/blob/9534e361ea12aaecde52b8ac4c947f9a301d0c9b/flang/include/flang/Optimizer/Dialect/FIROps.td#L1083-L1100>:
>
> %0 = fir.boxchar_len %arg0 : (!fir.boxchar<4>) -> i64
> %0 = fir.boxchar_len %arg0 : (!fir.boxchar<4>) -> i32
>
> As the length inside `!fir.boxchar` will be either `i32` or `i64` (this depends on the target), `!fir.boxchar` may require an integer cast on the result. Please see the tests for examples.
>
> @schweitz , could you confirm whether this is correct? There was no integer cast on fir-dev, but I added it here. But perhaps I'm missing something here?
`fir.boxchar_len` is polymorphic on the return type. Any integer type is fine and must be dealt with when generating LLVM IR.
================
Comment at: flang/lib/Optimizer/CodeGen/CodeGen.cpp:1464
+ mlir::Type returnValTy = boxCharLen.getResult().getType();
+ llvmStructTy.cast<mlir::LLVM::LLVMStructType>().getBody()[1];
+
----------------
clementval wrote:
> This line seems to be useless.
Bad merge?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113763/new/
https://reviews.llvm.org/D113763
More information about the llvm-commits
mailing list