@@ -271,7 +271,7 @@ def LLVM_DILanguageParameter : LLVM_DIParameter<
271
271
>;
272
272
273
273
def LLVM_DITagParameter : LLVM_DIParameter<
274
- "tag", /*default=*/"0 ", "Tag", /*errorCase=*/"llvm::dwarf::DW_TAG_invalid"
274
+ "tag", /*default=*/"", "Tag", /*errorCase=*/"llvm::dwarf::DW_TAG_invalid"
275
275
>;
276
276
277
277
def LLVM_DIOperationEncodingParameter : LLVM_DIParameter<
@@ -375,17 +375,14 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
375
375
[LLVM_DIRecursiveTypeAttrInterface],
376
376
"DITypeAttr"> {
377
377
let parameters = (ins
378
- // DIRecursiveTypeAttrInterface specific parameters.
379
- OptionalParameter<"DistinctAttr">:$recId,
380
- OptionalParameter<"bool">:$isRecSelf,
381
- // DICompositeType specific parameters.
382
378
LLVM_DITagParameter:$tag,
379
+ OptionalParameter<"DistinctAttr">:$recId,
383
380
OptionalParameter<"StringAttr">:$name,
384
381
OptionalParameter<"DIFileAttr">:$file,
385
382
OptionalParameter<"uint32_t">:$line,
386
383
OptionalParameter<"DIScopeAttr">:$scope,
387
384
OptionalParameter<"DITypeAttr">:$baseType,
388
- OptionalParameter<"DIFlags">:$flags,
385
+ OptionalParameter<"DIFlags", "DIFlags::Zero" >:$flags,
389
386
OptionalParameter<"uint64_t">:$sizeInBits,
390
387
OptionalParameter<"uint64_t">:$alignInBits,
391
388
OptionalArrayRefParameter<"DINodeAttr">:$elements,
@@ -394,26 +391,14 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
394
391
OptionalParameter<"DIExpressionAttr">:$allocated,
395
392
OptionalParameter<"DIExpressionAttr">:$associated
396
393
);
397
- let builders = [
398
- AttrBuilder<(ins
399
- "unsigned":$tag, "StringAttr":$name, "DIFileAttr":$file,
400
- "uint32_t":$line, "DIScopeAttr":$scope, "DITypeAttr":$baseType,
401
- "DIFlags":$flags, "uint64_t":$sizeInBits, "uint64_t":$alignInBits,
402
- "ArrayRef<DINodeAttr>":$elements, "DIExpressionAttr":$dataLocation,
403
- "DIExpressionAttr":$rank, "DIExpressionAttr":$allocated,
404
- "DIExpressionAttr":$associated
405
- ), [{
406
- return $_get($_ctxt, /*recId=*/nullptr, /*isRecSelf=*/nullptr,
407
- tag, name, file, line, scope, baseType, flags, sizeInBits,
408
- alignInBits, elements, dataLocation, rank, allocated,
409
- associated);
410
- }]>
411
- ];
412
394
let assemblyFormat = "`<` struct(params) `>`";
413
395
let extraClassDeclaration = [{
414
396
/// Requirements of DIRecursiveTypeAttrInterface.
415
397
/// @{
416
398
399
+ /// Get whether this attr describes a recursive self reference.
400
+ bool isRecSelf() { return getTag() == 0; }
401
+
417
402
/// Get a copy of this type attr but with the recursive ID set to `recId`.
418
403
DIRecursiveTypeAttrInterface withRecId(DistinctAttr recId);
419
404
@@ -569,51 +554,36 @@ def LLVM_DILocalVariableAttr : LLVM_Attr<"DILocalVariable", "di_local_variable",
569
554
//===----------------------------------------------------------------------===//
570
555
571
556
def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
572
- [LLVM_DIRecursiveTypeAttrInterface],
573
- "DIScopeAttr"> {
557
+ /*traits=*/[], "DIScopeAttr"> {
574
558
let parameters = (ins
575
- // DIRecursiveTypeAttrInterface specific parameters.
576
- OptionalParameter<"DistinctAttr">:$recId,
577
- OptionalParameter<"bool">:$isRecSelf,
578
- // DISubprogramAttr specific parameters.
579
559
OptionalParameter<"DistinctAttr">:$id,
580
560
OptionalParameter<"DICompileUnitAttr">:$compileUnit,
581
- OptionalParameter< "DIScopeAttr"> :$scope,
561
+ "DIScopeAttr":$scope,
582
562
OptionalParameter<"StringAttr">:$name,
583
563
OptionalParameter<"StringAttr">:$linkageName,
584
- OptionalParameter< "DIFileAttr"> :$file,
564
+ "DIFileAttr":$file,
585
565
OptionalParameter<"unsigned">:$line,
586
566
OptionalParameter<"unsigned">:$scopeLine,
587
567
OptionalParameter<"DISubprogramFlags">:$subprogramFlags,
588
568
OptionalParameter<"DISubroutineTypeAttr">:$type,
589
569
OptionalArrayRefParameter<"DINodeAttr">:$retainedNodes
590
570
);
591
571
let builders = [
592
- AttrBuilder <(ins
572
+ AttrBuilderWithInferredContext <(ins
593
573
"DistinctAttr":$id, "DICompileUnitAttr":$compileUnit,
594
- "DIScopeAttr":$scope, "StringAttr ":$name, "StringAttr ":$linkageName,
574
+ "DIScopeAttr":$scope, "StringRef ":$name, "StringRef ":$linkageName,
595
575
"DIFileAttr":$file, "unsigned":$line, "unsigned":$scopeLine,
596
576
"DISubprogramFlags":$subprogramFlags, "DISubroutineTypeAttr":$type,
597
577
"ArrayRef<DINodeAttr>":$retainedNodes
598
578
), [{
599
- return $_get($_ctxt, /*recId=*/nullptr, /*isRecSelf=*/false, id, compileUnit,
600
- scope, name, linkageName, file, line, scopeLine,
601
- subprogramFlags, type, retainedNodes);
579
+ MLIRContext *ctx = file.getContext();
580
+ return $_get(ctx, id, compileUnit, scope, StringAttr::get(ctx, name),
581
+ StringAttr::get(ctx, linkageName), file, line,
582
+ scopeLine, subprogramFlags, type, retainedNodes);
602
583
}]>
603
584
];
604
- let assemblyFormat = "`<` struct(params) `>`";
605
- let extraClassDeclaration = [{
606
- /// Requirements of DIRecursiveTypeAttrInterface.
607
- /// @{
608
-
609
- /// Get a copy of this type attr but with the recursive ID set to `recId`.
610
- DIRecursiveTypeAttrInterface withRecId(DistinctAttr recId);
611
585
612
- /// Build a rec-self instance using the provided `recId`.
613
- static DIRecursiveTypeAttrInterface getRecSelf(DistinctAttr recId);
614
-
615
- /// @}
616
- }];
586
+ let assemblyFormat = "`<` struct(params) `>`";
617
587
}
618
588
619
589
//===----------------------------------------------------------------------===//
@@ -657,9 +627,13 @@ def LLVM_DINamespaceAttr : LLVM_Attr<"DINamespace", "di_namespace",
657
627
658
628
def LLVM_DIImportedEntityAttr : LLVM_Attr<"DIImportedEntity", "di_imported_entity",
659
629
/*traits=*/[], "DINodeAttr"> {
630
+ /// TODO: DIImportedEntity has a 'scope' field which represents the scope where
631
+ /// this entity is imported. Currently, we are not adding a 'scope' field in
632
+ /// DIImportedEntityAttr to avoid cyclic dependency. As DIImportedEntityAttr
633
+ /// entries will be contained inside a scope entity (e.g. DISubprogramAttr),
634
+ /// the scope can easily be inferred.
660
635
let parameters = (ins
661
636
LLVM_DITagParameter:$tag,
662
- "DIScopeAttr":$scope,
663
637
"DINodeAttr":$entity,
664
638
OptionalParameter<"DIFileAttr">:$file,
665
639
OptionalParameter<"unsigned">:$line,
0 commit comments