@@ -178,6 +178,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
178
178
179
179
mlir::Attribute getConstStructOrZeroAttr (mlir::ArrayAttr arrayAttr,
180
180
bool packed = false ,
181
+ bool padded = false ,
181
182
mlir::Type type = {}) {
182
183
llvm::SmallVector<mlir::Type, 8 > members;
183
184
auto structTy = mlir::dyn_cast<cir::StructType>(type);
@@ -193,9 +194,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
193
194
194
195
// Struct type not specified: create anon struct type from members.
195
196
if (!structTy)
196
- structTy =
197
- getType<cir::StructType>(members, packed, cir::StructType::Struct,
198
- /* ast=*/ nullptr );
197
+ structTy = getType<cir::StructType>(members, packed, padded,
198
+ cir::StructType::Struct,
199
+ /* ast=*/ nullptr );
199
200
200
201
// Return zero or anonymous constant struct.
201
202
if (isZero)
@@ -205,6 +206,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
205
206
206
207
cir::ConstStructAttr getAnonConstStruct (mlir::ArrayAttr arrayAttr,
207
208
bool packed = false ,
209
+ bool padded = false ,
208
210
mlir::Type ty = {}) {
209
211
llvm::SmallVector<mlir::Type, 4 > members;
210
212
for (auto &f : arrayAttr) {
@@ -214,7 +216,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
214
216
}
215
217
216
218
if (!ty)
217
- ty = getAnonStructTy (members, packed);
219
+ ty = getAnonStructTy (members, packed, padded );
218
220
219
221
auto sTy = mlir::dyn_cast<cir::StructType>(ty);
220
222
assert (sTy && " expected struct type" );
@@ -434,15 +436,15 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
434
436
435
437
// / Get a CIR anonymous struct type.
436
438
cir::StructType getAnonStructTy (llvm::ArrayRef<mlir::Type> members,
437
- bool packed = false ,
439
+ bool packed = false , bool padded = false ,
438
440
const clang::RecordDecl *ast = nullptr ) {
439
441
cir::ASTRecordDeclAttr astAttr = nullptr ;
440
442
auto kind = cir::StructType::RecordKind::Struct;
441
443
if (ast) {
442
444
astAttr = getAttr<cir::ASTRecordDeclAttr>(ast);
443
445
kind = getRecordKind (ast->getTagKind ());
444
446
}
445
- return getType<cir::StructType>(members, packed, kind, astAttr);
447
+ return getType<cir::StructType>(members, packed, padded, kind, astAttr);
446
448
}
447
449
448
450
// / Get a CIR record kind from a AST declaration tag.
@@ -477,6 +479,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
477
479
// / it with a different set of attributes, this method will crash.
478
480
cir::StructType getCompleteStructTy (llvm::ArrayRef<mlir::Type> members,
479
481
llvm::StringRef name, bool packed,
482
+ bool padded,
480
483
const clang::RecordDecl *ast) {
481
484
const auto nameAttr = getStringAttr (name);
482
485
cir::ASTRecordDeclAttr astAttr = nullptr ;
@@ -487,19 +490,19 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
487
490
}
488
491
489
492
// Create or get the struct.
490
- auto type =
491
- getType<cir::StructType>(members, nameAttr, packed, kind, astAttr);
493
+ auto type = getType<cir::StructType>(members, nameAttr, packed, padded,
494
+ kind, astAttr);
492
495
493
496
// Complete an incomplete struct or ensure the existing complete struct
494
497
// matches the requested attributes.
495
- type.complete (members, packed, astAttr);
498
+ type.complete (members, packed, padded, astAttr);
496
499
497
500
return type;
498
501
}
499
502
500
503
cir::StructType
501
504
getCompleteStructType (mlir::ArrayAttr fields, bool packed = false ,
502
- llvm::StringRef name = " " ,
505
+ bool padded = false , llvm::StringRef name = " " ,
503
506
const clang::RecordDecl *ast = nullptr ) {
504
507
llvm::SmallVector<mlir::Type, 8 > members;
505
508
for (auto &attr : fields) {
@@ -508,9 +511,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
508
511
}
509
512
510
513
if (name.empty ())
511
- return getAnonStructTy (members, packed, ast);
514
+ return getAnonStructTy (members, packed, padded, ast);
512
515
else
513
- return getCompleteStructTy (members, name, packed, ast);
516
+ return getCompleteStructTy (members, name, packed, padded, ast);
514
517
}
515
518
516
519
cir::ArrayType getArrayType (mlir::Type eltType, unsigned size) {
0 commit comments