From f93e27201bcf8d7c31aa18c0d9b5c6bdd3e16ffa Mon Sep 17 00:00:00 2001 From: Henrich Lauko Date: Wed, 1 Nov 2023 11:46:23 +0100 Subject: [PATCH] hl: Add asm label attribute. --- include/vast/CodeGen/CodeGenAttrVisitor.hpp | 4 ++++ .../vast/Dialect/HighLevel/HighLevelAttributes.td | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/vast/CodeGen/CodeGenAttrVisitor.hpp b/include/vast/CodeGen/CodeGenAttrVisitor.hpp index 0bb5a91b1b..52f739fa5c 100644 --- a/include/vast/CodeGen/CodeGenAttrVisitor.hpp +++ b/include/vast/CodeGen/CodeGenAttrVisitor.hpp @@ -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()); } diff --git a/include/vast/Dialect/HighLevel/HighLevelAttributes.td b/include/vast/Dialect/HighLevel/HighLevelAttributes.td index 0fb5afbd90..3c0d350845 100644 --- a/include/vast/Dialect/HighLevel/HighLevelAttributes.td +++ b/include/vast/Dialect/HighLevel/HighLevelAttributes.td @@ -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 = [