@@ -431,6 +431,39 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
431
431
/* associated=*/ nullptr );
432
432
}
433
433
434
+ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertVectorType (
435
+ fir::VectorType vecTy, mlir::LLVM::DIFileAttr fileAttr,
436
+ mlir::LLVM::DIScopeAttr scope, fir::cg::XDeclareOp declOp) {
437
+ mlir::MLIRContext *context = module.getContext ();
438
+
439
+ llvm::SmallVector<mlir::LLVM::DINodeAttr> elements;
440
+ mlir::LLVM::DITypeAttr elemTy =
441
+ convertType (vecTy.getEleTy (), fileAttr, scope, declOp);
442
+ auto intTy = mlir::IntegerType::get (context, 64 );
443
+ auto countAttr =
444
+ mlir::IntegerAttr::get (intTy, llvm::APInt (64 , vecTy.getLen ()));
445
+ auto subrangeTy = mlir::LLVM::DISubrangeAttr::get (
446
+ context, countAttr, /* lowerBound=*/ nullptr , /* upperBound=*/ nullptr ,
447
+ /* stride=*/ nullptr );
448
+ elements.push_back (subrangeTy);
449
+ mlir::Type llvmTy = llvmTypeConverter.convertType (vecTy.getEleTy ());
450
+ uint64_t sizeInBits = dataLayout->getTypeSize (llvmTy) * vecTy.getLen () * 8 ;
451
+ std::string name (" vector" );
452
+ // The element type of the vector must be integer or real so it will be a
453
+ // DIBasicTypeAttr.
454
+ if (auto ty = mlir::dyn_cast_if_present<mlir::LLVM::DIBasicTypeAttr>(elemTy))
455
+ name += " " + ty.getName ().str ();
456
+
457
+ name += " (" + std::to_string (vecTy.getLen ()) + " )" ;
458
+ return mlir::LLVM::DICompositeTypeAttr::get (
459
+ context, llvm::dwarf::DW_TAG_array_type,
460
+ mlir::StringAttr::get (context, name),
461
+ /* file=*/ nullptr , /* line=*/ 0 , /* scope=*/ nullptr , elemTy,
462
+ mlir::LLVM::DIFlags::Vector, sizeInBits, /* alignInBits=*/ 0 , elements,
463
+ /* dataLocation=*/ nullptr , /* rank=*/ nullptr , /* allocated=*/ nullptr ,
464
+ /* associated=*/ nullptr );
465
+ }
466
+
434
467
mlir::LLVM::DITypeAttr DebugTypeGenerator::convertCharacterType (
435
468
fir::CharacterType charTy, mlir::LLVM::DIFileAttr fileAttr,
436
469
mlir::LLVM::DIScopeAttr scope, fir::cg::XDeclareOp declOp,
@@ -546,6 +579,8 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
546
579
return convertPointerLikeType (elTy, fileAttr, scope, declOp,
547
580
/* genAllocated=*/ false ,
548
581
/* genAssociated=*/ false );
582
+ } else if (auto vecTy = mlir::dyn_cast_or_null<fir::VectorType>(Ty)) {
583
+ return convertVectorType (vecTy, fileAttr, scope, declOp);
549
584
} else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(Ty)) {
550
585
auto elTy = boxTy.getElementType ();
551
586
if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(elTy))
0 commit comments