Skip to content

Commit

Permalink
hl: Add asm label attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko committed Nov 1, 2023
1 parent f859614 commit f93e272
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/vast/CodeGen/CodeGenAttrVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ namespace vast::cg {
return make< hl::BuiltinAttr >(attr->getID());
}

mlir_attr VisitAsmLabelAttr(const clang::AsmLabelAttr *attr) {
return make< hl::AsmLabelAttr >(attr->getLabel(), attr->getIsLiteralLabel());
}

mlir_attr VisitAllocAlignAttr(const clang::AllocAlignAttr *attr) {
return make< hl::AllocAlignAttr >(attr->getParamIndex().getSourceIndex());
}
Expand Down
14 changes: 14 additions & 0 deletions include/vast/Dialect/HighLevel/HighLevelAttributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ def RestrictAttr : HighLevel_Attr< "Restrict", "restrict" >;
def NoThrowAttr : HighLevel_Attr< "NoThrow", "nothrow" >;
def NonNullAttr : HighLevel_Attr< "NonNull", "nonnull" >;

def AsmLabelAttr : HighLevel_Attr< "AsmLabel", "asm" > {
let parameters = (ins "::mlir::StringAttr":$label, "bool":$isLiteral);
let builders = [
AttrBuilderWithInferredContext<(ins "::mlir::StringAttr":$label, "bool":$literal), [{
return get(label.getContext(), label, literal);
}]>,
AttrBuilder<(ins "::mlir::StringRef":$label, "bool":$literal), [{
return get(mlir::StringAttr::get($_ctxt, label), literal);
}]>,
];

let assemblyFormat = "`<` $label `,` $isLiteral `>`";
}

def ModeAttr : HighLevel_Attr< "Mode", "mode" > {
let parameters = (ins "::mlir::StringAttr":$mode);
let builders = [
Expand Down

0 comments on commit f93e272

Please sign in to comment.