[flang-commits] [flang] [flang][debug] Allow non default array lower bounds. (PR #104467)
via flang-commits
flang-commits at lists.llvm.org
Tue Aug 20 06:14:16 PDT 2024
================
@@ -174,20 +175,22 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
elements.push_back(subrangeTy);
} else {
auto intTy = mlir::IntegerType::get(context, 64);
- // FIXME: Only supporting lower bound of 1 at the moment. The
- // 'SequenceType' has information about the shape but not the shift. In
- // cases where the conversion originated during the processing of
- // 'DeclareOp', it may be possible to pass on this information. But the
- // type conversion should ideally be based on what information present in
- // the type class so that it works from everywhere (e.g. when it is part
- // of a module or a derived type.)
+ int64_t shift = 1;
+ if (declOp && declOp.getShift().size() > index) {
+ if (auto defOp = mlir::dyn_cast<mlir::arith::ConstantOp>(
+ declOp.getShift()[index].getDefiningOp())) {
+ if (auto iattr = mlir::dyn_cast<mlir::IntegerAttr>(defOp.getValue()))
+ shift = iattr.getInt();
+ }
+ }
----------------
jeanPerier wrote:
You can also use `fir::getIntIfConstant()` to simplify the logic here.
See: https://github.com/llvm/llvm-project/blob/576b7a781aac6b1d60a72248894b50e565e9185a/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h#L145
https://github.com/llvm/llvm-project/pull/104467
More information about the flang-commits
mailing list