Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flatten and target attribute support #744

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/vast/CodeGen/DefaultAttrVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ namespace vast::cg {

mlir_attr VisitConstAttr(const clang::ConstAttr *attr);
mlir_attr VisitSectionAttr(const clang::SectionAttr *attr);
mlir_attr VisitTargetAttr(const clang::TargetAttr *attr);
mlir_attr VisitAliasAttr(const clang::AliasAttr *attr);
mlir_attr VisitErrorAttr(const clang::ErrorAttr *attr);
mlir_attr VisitFlattenAttr(const clang::FlattenAttr *attr);
mlir_attr VisitFormatAttr(const clang::FormatAttr *attr);
mlir_attr VisitFormatArgAttr(const clang::FormatArgAttr *attr);
mlir_attr VisitAnnotateAttr(const clang::AnnotateAttr *attr);
Expand Down
18 changes: 18 additions & 0 deletions include/vast/Dialect/HighLevel/HighLevelAttributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,31 @@ class HighLevel_FlatSymbolReferringAttr<string name, string attr_mnemonic>
}

def HighLevel_AnnotationAttr : HighLevel_NameAttr< "Annotation", "annotation" >;
def HighLevel_FlattentAttr : HighLevel_Attr< "Flatten", "flatten" >;
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_TargetAttr : HighLevel_Attr< "Target", "target" >
{
let parameters = (ins "mlir::StringAttr":$features);

let builders = [
AttrBuilderWithInferredContext<(ins "::mlir::StringAttr":$features), [{
return get(features.getContext(), features);
}]>,
AttrBuilder<(ins "::mlir::StringRef":$features), [{
return get(mlir::StringAttr::get($_ctxt, features));
}]>,
];

let assemblyFormat = "`<` $features `>`";
}

def HighLevel_AliasAttr : HighLevel_NameAttr< "Alias", "alias" >;
def HighLevel_ErrorAttr : HighLevel_NameAttr< "Error", "error" >;
def HighLevel_CountedByAttr : HighLevel_Attr< "CountedBy", "counted_by" >;
Expand Down
8 changes: 8 additions & 0 deletions lib/vast/CodeGen/DefaultAttrVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ namespace vast::cg
return make< hl::SectionAttr >(attr->getName());
}

mlir_attr default_attr_visitor::VisitTargetAttr(const clang::TargetAttr *attr) {
return make< hl::TargetAttr >(attr->getFeaturesStr());
}

mlir_attr default_attr_visitor::VisitAliasAttr(const clang::AliasAttr *attr) {
return make< hl::AliasAttr >(attr->getAliasee());
}
Expand All @@ -22,6 +26,10 @@ namespace vast::cg
return make< hl::ErrorAttr >(attr->getUserDiagnostic());
}

mlir_attr default_attr_visitor::VisitFlattenAttr(const clang::FlattenAttr *attr) {
return make< hl::FlattenAttr >();
}

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