Skip to content

Commit

Permalink
cg: Generate FormatArgAttr.
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko authored and Jezurko committed Nov 4, 2024
1 parent 5e6b250 commit 955d6c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/vast/CodeGen/DefaultAttrVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace vast::cg {
mlir_attr VisitAliasAttr(const clang::AliasAttr *attr);
mlir_attr VisitErrorAttr(const clang::ErrorAttr *attr);
mlir_attr VisitFormatAttr(const clang::FormatAttr *attr);
mlir_attr VisitFormatArgAttr(const clang::FormatArgAttr *attr);
mlir_attr VisitAnnotateAttr(const clang::AnnotateAttr *attr);
mlir_attr VisitAlignedAttr(const clang::AlignedAttr *attr);
mlir_attr VisitAlwaysInlineAttr(const clang::AlwaysInlineAttr *attr);
Expand Down
5 changes: 5 additions & 0 deletions include/vast/Dialect/HighLevel/HighLevelAttributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class HighLevel_FlatSymbolReferringAttr<string name, string attr_mnemonic>

def HighLevel_AnnotationAttr : HighLevel_NameAttr< "Annotation", "annotation" >;
def HighLevel_FormatAttr : HighLevel_NameAttr< "Format", "format" >;
def HighLevel_FormatArgAttr : HighLevel_NameAttr< "FormatArg", "format_arg" >
{
let parameters = (ins "unsigned":$format_idx);
let assemblyFormat = "`<` $format_idx `>`";
}
def HighLevel_SectionAttr : HighLevel_NameAttr< "Section", "section" >;
def HighLevel_AliasAttr : HighLevel_NameAttr< "Alias", "alias" >;
def HighLevel_ErrorAttr : HighLevel_NameAttr< "Error", "error" >;
Expand Down
5 changes: 4 additions & 1 deletion lib/vast/CodeGen/DefaultAttrVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ namespace vast::cg
return make< hl::ErrorAttr >(attr->getUserDiagnostic());
}


mlir_attr default_attr_visitor::VisitFormatAttr(const clang::FormatAttr *attr) {
return make< hl::FormatAttr >(attr->getType()->getName());
}

mlir_attr default_attr_visitor::VisitFormatArgAttr(const clang::FormatArgAttr *attr) {
return make< hl::FormatArgAttr >(attr->getFormatIdx().serialize());
}

mlir_attr default_attr_visitor::VisitAnnotateAttr(const clang::AnnotateAttr *attr) {
return make< hl::AnnotationAttr >(attr->getAnnotation());
}
Expand Down

0 comments on commit 955d6c6

Please sign in to comment.