@@ -271,7 +271,7 @@ def LLVM_DILanguageParameter : LLVM_DIParameter<
271271>;
272272
273273def 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"
275275>;
276276
277277def LLVM_DIOperationEncodingParameter : LLVM_DIParameter<
@@ -375,17 +375,14 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
375375 [LLVM_DIRecursiveTypeAttrInterface],
376376 "DITypeAttr"> {
377377 let parameters = (ins
378- // DIRecursiveTypeAttrInterface specific parameters.
379- OptionalParameter<"DistinctAttr">:$recId,
380- OptionalParameter<"bool">:$isRecSelf,
381- // DICompositeType specific parameters.
382378 LLVM_DITagParameter:$tag,
379+ OptionalParameter<"DistinctAttr">:$recId,
383380 OptionalParameter<"StringAttr">:$name,
384381 OptionalParameter<"DIFileAttr">:$file,
385382 OptionalParameter<"uint32_t">:$line,
386383 OptionalParameter<"DIScopeAttr">:$scope,
387384 OptionalParameter<"DITypeAttr">:$baseType,
388- OptionalParameter<"DIFlags">:$flags,
385+ OptionalParameter<"DIFlags", "DIFlags::Zero" >:$flags,
389386 OptionalParameter<"uint64_t">:$sizeInBits,
390387 OptionalParameter<"uint64_t">:$alignInBits,
391388 OptionalArrayRefParameter<"DINodeAttr">:$elements,
@@ -394,26 +391,14 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
394391 OptionalParameter<"DIExpressionAttr">:$allocated,
395392 OptionalParameter<"DIExpressionAttr">:$associated
396393 );
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- ];
412394 let assemblyFormat = "`<` struct(params) `>`";
413395 let extraClassDeclaration = [{
414396 /// Requirements of DIRecursiveTypeAttrInterface.
415397 /// @{
416398
399+ /// Get whether this attr describes a recursive self reference.
400+ bool isRecSelf() { return getTag() == 0; }
401+
417402 /// Get a copy of this type attr but with the recursive ID set to `recId`.
418403 DIRecursiveTypeAttrInterface withRecId(DistinctAttr recId);
419404
@@ -569,51 +554,36 @@ def LLVM_DILocalVariableAttr : LLVM_Attr<"DILocalVariable", "di_local_variable",
569554//===----------------------------------------------------------------------===//
570555
571556def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
572- [LLVM_DIRecursiveTypeAttrInterface],
573- "DIScopeAttr"> {
557+ /*traits=*/[], "DIScopeAttr"> {
574558 let parameters = (ins
575- // DIRecursiveTypeAttrInterface specific parameters.
576- OptionalParameter<"DistinctAttr">:$recId,
577- OptionalParameter<"bool">:$isRecSelf,
578- // DISubprogramAttr specific parameters.
579559 OptionalParameter<"DistinctAttr">:$id,
580560 OptionalParameter<"DICompileUnitAttr">:$compileUnit,
581- OptionalParameter< "DIScopeAttr"> :$scope,
561+ "DIScopeAttr":$scope,
582562 OptionalParameter<"StringAttr">:$name,
583563 OptionalParameter<"StringAttr">:$linkageName,
584- OptionalParameter< "DIFileAttr"> :$file,
564+ "DIFileAttr":$file,
585565 OptionalParameter<"unsigned">:$line,
586566 OptionalParameter<"unsigned">:$scopeLine,
587567 OptionalParameter<"DISubprogramFlags">:$subprogramFlags,
588568 OptionalParameter<"DISubroutineTypeAttr">:$type,
589569 OptionalArrayRefParameter<"DINodeAttr">:$retainedNodes
590570 );
591571 let builders = [
592- AttrBuilder <(ins
572+ AttrBuilderWithInferredContext <(ins
593573 "DistinctAttr":$id, "DICompileUnitAttr":$compileUnit,
594- "DIScopeAttr":$scope, "StringAttr ":$name, "StringAttr ":$linkageName,
574+ "DIScopeAttr":$scope, "StringRef ":$name, "StringRef ":$linkageName,
595575 "DIFileAttr":$file, "unsigned":$line, "unsigned":$scopeLine,
596576 "DISubprogramFlags":$subprogramFlags, "DISubroutineTypeAttr":$type,
597577 "ArrayRef<DINodeAttr>":$retainedNodes
598578 ), [{
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);
602583 }]>
603584 ];
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);
611585
612- /// Build a rec-self instance using the provided `recId`.
613- static DIRecursiveTypeAttrInterface getRecSelf(DistinctAttr recId);
614-
615- /// @}
616- }];
586+ let assemblyFormat = "`<` struct(params) `>`";
617587}
618588
619589//===----------------------------------------------------------------------===//
@@ -657,9 +627,13 @@ def LLVM_DINamespaceAttr : LLVM_Attr<"DINamespace", "di_namespace",
657627
658628def LLVM_DIImportedEntityAttr : LLVM_Attr<"DIImportedEntity", "di_imported_entity",
659629 /*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.
660635 let parameters = (ins
661636 LLVM_DITagParameter:$tag,
662- "DIScopeAttr":$scope,
663637 "DINodeAttr":$entity,
664638 OptionalParameter<"DIFileAttr">:$file,
665639 OptionalParameter<"unsigned">:$line,
0 commit comments