From 269298689f8065af278fbe67acb8b129d3b001c0 Mon Sep 17 00:00:00 2001 From: xlauko Date: Fri, 10 Jan 2025 14:43:16 +0100 Subject: [PATCH] core: Add symbol reference attr contraints. --- .../Dialect/Core/CommonAttrConstraints.td | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/include/vast/Dialect/Core/CommonAttrConstraints.td b/include/vast/Dialect/Core/CommonAttrConstraints.td index 7a3e8e466c..524ab7d5ef 100644 --- a/include/vast/Dialect/Core/CommonAttrConstraints.td +++ b/include/vast/Dialect/Core/CommonAttrConstraints.td @@ -21,4 +21,75 @@ def Core_VarSymbolRefAttr : Attr< let convertFromStorage = "$_self.getValue()"; } +def Core_TypeSymbolRefAttr : Attr< + CPred< "::llvm::isa< ::vast::core::TypeSymbolRefAttr >($_self)" >, + "type symbol reference attribute" +> { + let storageType = [{ ::vast::core::TypeSymbolRefAttr }]; + let returnType = [{ ::llvm::StringRef }]; + let valueType = NoneType; + let constBuilderCall = + "::mlir::SymbolRefAttr::get($_builder.getContext(), $0)"; + let convertFromStorage = "$_self.getValue()"; +} + +def Core_FuncSymbolRefAttr : Attr< + CPred< "::llvm::isa< ::vast::core::FuncSymbolRefAttr >($_self)" >, + "function symbol reference attribute" +> { + let storageType = [{ ::vast::core::FuncSymbolRefAttr }]; + let returnType = [{ ::llvm::StringRef }]; + let valueType = NoneType; + let constBuilderCall = + "::mlir::SymbolRefAttr::get($_builder.getContext(), $0)"; + let convertFromStorage = "$_self.getValue()"; +} + +def Core_LabelSymbolRefAttr : Attr< + CPred< "::llvm::isa< ::vast::core::LabelSymbolRefAttr >($_self)" >, + "label symbol reference attribute" +> { + let storageType = [{ ::vast::core::LabelSymbolRefAttr }]; + let returnType = [{ ::llvm::StringRef }]; + let valueType = NoneType; + let constBuilderCall = + "::mlir::SymbolRefAttr::get($_builder.getContext(), $0)"; + let convertFromStorage = "$_self.getValue()"; +} + +def Core_EnumConstantSymbolRefAttr : Attr< + CPred< "::llvm::isa< ::vast::core::EnumConstantSymbolRefAttr >($_self)" >, + "enum constant symbol reference attribute" +> { + let storageType = [{ ::vast::core::EnumConstantSymbolRefAttr }]; + let returnType = [{ ::llvm::StringRef }]; + let valueType = NoneType; + let constBuilderCall = + "::mlir::SymbolRefAttr::get($_builder.getContext(), $0)"; + let convertFromStorage = "$_self.getValue()"; +} + +def Core_MemberVarSymbolRefAttr : Attr< + CPred< "::llvm::isa< ::vast::core::MemberVarSymbolRefAttr >($_self)" >, + "member variable symbol reference attribute" +> { + let storageType = [{ ::vast::core::MemberVarSymbolRefAttr }]; + let returnType = [{ ::llvm::StringRef }]; + let valueType = NoneType; + let constBuilderCall = + "::mlir::SymbolRefAttr::get($_builder.getContext(), $0)"; + let convertFromStorage = "$_self.getValue()"; +} + +def Core_ElaboratedTypeSymbolRefAttr : Attr< + CPred< "::llvm::isa< ::vast::core::ElaboratedTypeSymbolRefAttr >($_self)" >, + "elaborated type symbol reference attribute" +> { + let storageType = [{ ::vast::core::ElaboratedTypeSymbolRefAttr }]; + let returnType = [{ ::llvm::StringRef }]; + let valueType = NoneType; + let constBuilderCall = + "::mlir::SymbolRefAttr::get($_builder.getContext(), $0)"; + let convertFromStorage = "$_self.getValue()"; +} #endif // VAST_DIALECT_CORE_COMMON_ATTR_CONSTRAINTS_TD