From 1c234f8fbffd624306709c0d110169a536afc429 Mon Sep 17 00:00:00 2001 From: xlauko Date: Fri, 30 Aug 2024 15:53:03 +0200 Subject: [PATCH] treewide: Move symbol interfaces to core dialect. --- include/vast/CodeGen/ScopeContext.hpp | 14 +++++----- include/vast/Dialect/ABI/ABI.td | 2 +- include/vast/Dialect/ABI/ABIOps.hpp | 3 +- include/vast/Dialect/Core/CMakeLists.txt | 2 ++ include/vast/Dialect/Core/Core.td | 2 +- include/vast/Dialect/Core/CoreAttributes.hpp | 4 +-- include/vast/Dialect/Core/CoreAttributes.td | 2 +- include/vast/Dialect/Core/CoreLazy.td | 2 +- include/vast/Dialect/Core/CoreOps.hpp | 4 +-- include/vast/Dialect/Core/CoreOps.td | 12 +++++--- include/vast/Dialect/Core/Func.td | 4 +-- .../Dialect/Core/Interfaces/CMakeLists.txt | 4 +++ .../vast/Dialect/Core/Interfaces/Common.td | 26 +++++++++++++++++ .../Core}/Interfaces/SymbolInterface.hpp | 2 +- .../Core}/Interfaces/SymbolInterface.td | 19 +++++++------ .../Core}/Interfaces/SymbolRefInterface.hpp | 2 +- .../Core}/Interfaces/SymbolRefInterface.td | 0 .../Core}/Interfaces/SymbolTableInterface.hpp | 4 +-- .../Core}/Interfaces/SymbolTableInterface.td | 2 +- include/vast/Dialect/Core/SymbolTable.hpp | 2 +- include/vast/Dialect/HighLevel/HighLevel.td | 2 +- include/vast/Dialect/HighLevel/HighLevelCF.td | 4 +-- .../vast/Dialect/HighLevel/HighLevelOps.hpp | 2 +- .../vast/Dialect/HighLevel/HighLevelOps.td | 28 +++++++++++-------- .../vast/Dialect/HighLevel/HighLevelOpsCxx.td | 2 +- .../vast/Dialect/HighLevel/HighLevelUtils.hpp | 5 ++-- .../vast/Dialect/HighLevel/HighLevelVar.td | 2 +- include/vast/Dialect/LowLevel/LowLevel.td | 2 +- include/vast/Dialect/LowLevel/LowLevelOps.hpp | 2 +- include/vast/Dialect/LowLevel/LowLevelOps.td | 4 +-- include/vast/Dialect/Meta/Meta.td | 3 +- .../vast/Dialect/Unsupported/Unsupported.td | 2 +- include/vast/Interfaces/AST/DeclInterface.td | 2 +- include/vast/Interfaces/CMakeLists.txt | 3 -- include/vast/Util/Symbols.hpp | 4 +-- lib/vast/Dialect/Core/SymbolTable.cpp | 4 +-- lib/vast/Interfaces/SymbolInterface.cpp | 4 +-- lib/vast/Interfaces/SymbolRefInterface.cpp | 4 +-- lib/vast/Interfaces/SymbolTableInterface.cpp | 4 +-- 39 files changed, 115 insertions(+), 80 deletions(-) create mode 100644 include/vast/Dialect/Core/Interfaces/CMakeLists.txt create mode 100644 include/vast/Dialect/Core/Interfaces/Common.td rename include/vast/{ => Dialect/Core}/Interfaces/SymbolInterface.hpp (94%) rename include/vast/{ => Dialect/Core}/Interfaces/SymbolInterface.td (66%) rename include/vast/{ => Dialect/Core}/Interfaces/SymbolRefInterface.hpp (84%) rename include/vast/{ => Dialect/Core}/Interfaces/SymbolRefInterface.td (100%) rename include/vast/{ => Dialect/Core}/Interfaces/SymbolTableInterface.hpp (79%) rename include/vast/{ => Dialect/Core}/Interfaces/SymbolTableInterface.td (98%) diff --git a/include/vast/CodeGen/ScopeContext.hpp b/include/vast/CodeGen/ScopeContext.hpp index 57e63c505c..cc48f7a69d 100644 --- a/include/vast/CodeGen/ScopeContext.hpp +++ b/include/vast/CodeGen/ScopeContext.hpp @@ -12,7 +12,7 @@ VAST_UNRELAX_WARNINGS #include "vast/Util/TypeList.hpp" #include "vast/Util/Symbols.hpp" -#include "vast/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" #include #include @@ -56,22 +56,22 @@ namespace vast::cg operation declare(operation op) { llvm::TypeSwitch< operation >(op) - .Case< VarSymbolOpInterface >([&] (auto &op) { + .Case< core::VarSymbolOpInterface >([&] (auto &op) { symbols.vars.insert(op.getSymbolName(), op->getResult(0)); }) - .Case< TypeSymbolOpInterface >([&] (auto &op) { + .Case< core::TypeSymbolOpInterface >([&] (auto &op) { symbols.types.insert(op.getSymbolName(), op); }) - .Case< FuncSymbolOpInterface >([&] (auto &op) { + .Case< core::FuncSymbolOpInterface >([&] (auto &op) { symbols.funs.insert(op.getSymbolName(), op); }) - .Case< MemberVarSymbolOpInterface >([&] (auto &op) { + .Case< core::MemberVarSymbolOpInterface >([&] (auto &op) { symbols.members.insert(op.getSymbolName(), op); }) - .Case< LabelSymbolOpInterface >([&] (auto &op) { + .Case< core::LabelSymbolOpInterface >([&] (auto &op) { symbols.labels.insert(op.getSymbolName(), op); }) - .Case< EnumConstantSymbolOpInterface >([&] (auto &op) { + .Case< core::EnumConstantSymbolOpInterface >([&] (auto &op) { symbols.enum_constants.insert(op.getSymbolName(), op); }) .Default([] (auto &op){ diff --git a/include/vast/Dialect/ABI/ABI.td b/include/vast/Dialect/ABI/ABI.td index 6e022d34eb..4358b19e97 100644 --- a/include/vast/Dialect/ABI/ABI.td +++ b/include/vast/Dialect/ABI/ABI.td @@ -10,7 +10,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/IR/RegionKindInterface.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" def ABI_Dialect : Dialect { let name = "abi"; diff --git a/include/vast/Dialect/ABI/ABIOps.hpp b/include/vast/Dialect/ABI/ABIOps.hpp index 403b2eee1a..a32efc735f 100644 --- a/include/vast/Dialect/ABI/ABIOps.hpp +++ b/include/vast/Dialect/ABI/ABIOps.hpp @@ -15,14 +15,13 @@ VAST_RELAX_WARNINGS #include VAST_RELAX_WARNINGS -#include "vast/Interfaces/SymbolInterface.hpp" #include "vast/Util/Common.hpp" #include "vast/Dialect/Core/CoreDialect.hpp" #include "vast/Dialect/Core/CoreTypes.hpp" #include "vast/Dialect/Core/CoreAttributes.hpp" #include "vast/Dialect/Core/Func.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" #define GET_OP_CLASSES #include "vast/Dialect/ABI/ABI.h.inc" - diff --git a/include/vast/Dialect/Core/CMakeLists.txt b/include/vast/Dialect/Core/CMakeLists.txt index 122c633af1..8247949785 100644 --- a/include/vast/Dialect/Core/CMakeLists.txt +++ b/include/vast/Dialect/Core/CMakeLists.txt @@ -1,3 +1,5 @@ # Copyright (c) 2022-present, Trail of Bits, Inc. add_vast_dialect_with_doc(Core core) + +add_subdirectory(Interfaces) \ No newline at end of file diff --git a/include/vast/Dialect/Core/Core.td b/include/vast/Dialect/Core/Core.td index 68383bbd6e..73e6da03da 100644 --- a/include/vast/Dialect/Core/Core.td +++ b/include/vast/Dialect/Core/Core.td @@ -3,7 +3,7 @@ #ifndef VAST_DIALECT_CORE #define VAST_DIALECT_CORE -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" include "vast/Dialect/Core/Utils.td" diff --git a/include/vast/Dialect/Core/CoreAttributes.hpp b/include/vast/Dialect/Core/CoreAttributes.hpp index 618d82bff7..ea9fd483bd 100644 --- a/include/vast/Dialect/Core/CoreAttributes.hpp +++ b/include/vast/Dialect/Core/CoreAttributes.hpp @@ -14,9 +14,9 @@ VAST_UNRELAX_WARNINGS #include "vast/Dialect/Core/CoreDialect.hpp" #include "vast/Dialect/Core/CoreTraits.hpp" -#include "vast/Interfaces/SymbolInterface.hpp" -#include "vast/Interfaces/SymbolRefInterface.hpp" #include "vast/Interfaces/TypeQualifiersInterfaces.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolRefInterface.hpp" #include "vast/Util/Common.hpp" #include "vast/Util/TypeList.hpp" diff --git a/include/vast/Dialect/Core/CoreAttributes.td b/include/vast/Dialect/Core/CoreAttributes.td index 723e227a76..0b264d6db4 100644 --- a/include/vast/Dialect/Core/CoreAttributes.td +++ b/include/vast/Dialect/Core/CoreAttributes.td @@ -5,7 +5,7 @@ include "mlir/IR/AttrTypeBase.td" include "mlir/IR/BuiltinAttributeInterfaces.td" -include "vast/Interfaces/SymbolRefInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolRefInterface.td" include "mlir/IR/EnumAttr.td" diff --git a/include/vast/Dialect/Core/CoreLazy.td b/include/vast/Dialect/Core/CoreLazy.td index fd70a11ce8..9a72fc783c 100644 --- a/include/vast/Dialect/Core/CoreLazy.td +++ b/include/vast/Dialect/Core/CoreLazy.td @@ -8,7 +8,7 @@ include "mlir/IR/OpBase.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/CastInterfaces.td" include "mlir/Interfaces/FunctionInterfaces.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" class Core_LazyEval< string mnemonic, list < Trait > traits = [] > : Core_Op< mnemonic, !listconcat(traits, []) >, Results<(outs AnyType:$result)> diff --git a/include/vast/Dialect/Core/CoreOps.hpp b/include/vast/Dialect/Core/CoreOps.hpp index 48c993b137..2033b5a399 100644 --- a/include/vast/Dialect/Core/CoreOps.hpp +++ b/include/vast/Dialect/Core/CoreOps.hpp @@ -5,8 +5,8 @@ #include "vast/Dialect/Core/CoreDialect.hpp" #include "vast/Dialect/Core/CoreTraits.hpp" #include "vast/Dialect/Core/SymbolTable.hpp" -#include "vast/Interfaces/SymbolInterface.hpp" -#include "vast/Interfaces/SymbolTableInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolTableInterface.hpp" #include "vast/Util/Common.hpp" #include "vast/Util/TypeList.hpp" diff --git a/include/vast/Dialect/Core/CoreOps.td b/include/vast/Dialect/Core/CoreOps.td index db3737a6d3..bb5afad8f3 100644 --- a/include/vast/Dialect/Core/CoreOps.td +++ b/include/vast/Dialect/Core/CoreOps.td @@ -10,14 +10,16 @@ include "mlir/Interfaces/DataLayoutInterfaces.td" include "mlir/IR/RegionKindInterface.td" include "vast/Dialect/Core/CoreTraits.td" -include "vast/Interfaces/SymbolTableInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolTableInterface.td" def Core_ModuleOp : Core_Op< "module", [ IsolatedFromAbove, DataLayoutOpInterface, HasDefaultDLTIDataLayout, - NoTerminator, NoRegionArguments, SingleBlock, VastSymbol, - ShadowingSymbolTable< [[FuncSymbol, VarSymbol, TypeSymbol], [ElaboratedTypeSymbol]] >, + NoTerminator, NoRegionArguments, SingleBlock, Core_Symbol, + ShadowingSymbolTable< [ + [Core_FuncSymbol, Core_VarSymbol, Core_TypeSymbol], [Core_ElaboratedTypeSymbol] + ] >, ] > { let summary = "VAST top level container operation"; let description = [{ @@ -73,7 +75,9 @@ def Core_ModuleOp : Core_Op< "module", [ def Core_ScopeOp : Core_Op< "scope", [ NoTerminator, - ShadowingSymbolTable< [[VarSymbol, TypeSymbol], [ElaboratedTypeSymbol]] >, + ShadowingSymbolTable< [ + [Core_VarSymbol, Core_TypeSymbol], [Core_ElaboratedTypeSymbol] + ] >, DeclareOpInterfaceMethods ] > { let summary = "VAST scope declaration"; diff --git a/include/vast/Dialect/Core/Func.td b/include/vast/Dialect/Core/Func.td index 5f1e0e3859..7ddf0526cb 100644 --- a/include/vast/Dialect/Core/Func.td +++ b/include/vast/Dialect/Core/Func.td @@ -8,7 +8,7 @@ include "mlir/IR/RegionKindInterface.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/FunctionInterfaces.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" include "vast/Dialect/Core/CoreTraits.td" @@ -37,7 +37,7 @@ class Core_FuncBaseOp< Dialect dialect, string mnemonic, list< Trait > traits = CallableOpInterface, FunctionOpInterface, IsolatedFromAbove, - FuncSymbol, + Core_FuncSymbol, NoTerminator, DeclareOpInterfaceMethods< RegionKindInterface > ]) diff --git a/include/vast/Dialect/Core/Interfaces/CMakeLists.txt b/include/vast/Dialect/Core/Interfaces/CMakeLists.txt new file mode 100644 index 0000000000..2cdfccdb65 --- /dev/null +++ b/include/vast/Dialect/Core/Interfaces/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_vast_op_interface(SymbolInterface) +add_vast_op_interface(SymbolTableInterface) +add_vast_attr_interface(SymbolRefInterface) \ No newline at end of file diff --git a/include/vast/Dialect/Core/Interfaces/Common.td b/include/vast/Dialect/Core/Interfaces/Common.td new file mode 100644 index 0000000000..10e1a4b6ec --- /dev/null +++ b/include/vast/Dialect/Core/Interfaces/Common.td @@ -0,0 +1,26 @@ +// Copyright (c) 2024, Trail of Bits, Inc. + +#ifndef VAST_DIALECT_CORE_INTERFACES_COMMON +#define VAST_DIALECT_CORE_INTERFACES_COMMON + +include "mlir/IR/OpBase.td" + +class Core_OpInterface baseInterfaces = []> + : OpInterface +{ + let cppNamespace = "::vast::core"; +} + +class Core_TypeInterface baseInterfaces = []> + : TypeInterface +{ + let cppNamespace = "::vast::core"; +} + +class Core_AttrInterface baseInterfaces = []> + : AttrInterface +{ + let cppNamespace = "::vast::core"; +} + +#endif // VAST_DIALECT_CORE_INTERFACES_COMMON diff --git a/include/vast/Interfaces/SymbolInterface.hpp b/include/vast/Dialect/Core/Interfaces/SymbolInterface.hpp similarity index 94% rename from include/vast/Interfaces/SymbolInterface.hpp rename to include/vast/Dialect/Core/Interfaces/SymbolInterface.hpp index bf37110311..ac2e1a789e 100644 --- a/include/vast/Interfaces/SymbolInterface.hpp +++ b/include/vast/Dialect/Core/Interfaces/SymbolInterface.hpp @@ -22,7 +22,7 @@ namespace vast::core { } // namespace vast::core /// Include the generated interface declarations. -#include "vast/Interfaces/SymbolInterface.h.inc" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.h.inc" namespace vast::core { diff --git a/include/vast/Interfaces/SymbolInterface.td b/include/vast/Dialect/Core/Interfaces/SymbolInterface.td similarity index 66% rename from include/vast/Interfaces/SymbolInterface.td rename to include/vast/Dialect/Core/Interfaces/SymbolInterface.td index 4209b48034..77774cf739 100644 --- a/include/vast/Interfaces/SymbolInterface.td +++ b/include/vast/Dialect/Core/Interfaces/SymbolInterface.td @@ -6,10 +6,11 @@ include "mlir/IR/OpBase.td" include "vast/Interfaces/Common.td" include "vast/Dialect/Core/CoreTraits.td" +include "vast/Dialect/Core/Interfaces/Common.td" -def VastSymbol : VastOpInterface< "VastSymbolOpInterface" > { +def Core_Symbol : Core_OpInterface< "VastSymbolOpInterface" > { let description = [{ - This interface describes an operation that may define a `VastSymbol`. + This interface describes an operation that may define a `Symbol`. }]; let methods = [ @@ -40,12 +41,12 @@ def VastSymbol : VastOpInterface< "VastSymbolOpInterface" > { ]; } -def VarSymbol : VastOpInterface< "VarSymbolOpInterface", [VastSymbol] >; -def MemberVarSymbol : VastOpInterface< "MemberVarSymbolOpInterface", [VastSymbol] >; -def FuncSymbol : VastOpInterface< "FuncSymbolOpInterface", [VastSymbol] >; -def TypeSymbol : VastOpInterface< "TypeSymbolOpInterface", [VastSymbol] >; -def ElaboratedTypeSymbol : VastOpInterface< "ElaboratedTypeSymbolOpInterface", [VastSymbol] >; -def LabelSymbol : VastOpInterface< "LabelSymbolOpInterface", [VastSymbol] >; -def EnumConstantSymbol : VastOpInterface< "EnumConstantSymbolOpInterface", [VastSymbol] >; +def Core_VarSymbol : Core_OpInterface< "VarSymbolOpInterface", [Core_Symbol] >; +def Core_MemberVarSymbol : Core_OpInterface< "MemberVarSymbolOpInterface", [Core_Symbol] >; +def Core_FuncSymbol : Core_OpInterface< "FuncSymbolOpInterface", [Core_Symbol] >; +def Core_TypeSymbol : Core_OpInterface< "TypeSymbolOpInterface", [Core_Symbol] >; +def Core_ElaboratedTypeSymbol : Core_OpInterface< "ElaboratedTypeSymbolOpInterface", [Core_Symbol] >; +def Core_LabelSymbol : Core_OpInterface< "LabelSymbolOpInterface", [Core_Symbol] >; +def Core_EnumConstantSymbol : Core_OpInterface< "EnumConstantSymbolOpInterface", [Core_Symbol] >; #endif // VAST_INTERFACES_SYMBOL_INTERFACE diff --git a/include/vast/Interfaces/SymbolRefInterface.hpp b/include/vast/Dialect/Core/Interfaces/SymbolRefInterface.hpp similarity index 84% rename from include/vast/Interfaces/SymbolRefInterface.hpp rename to include/vast/Dialect/Core/Interfaces/SymbolRefInterface.hpp index 7c3be20bc2..6c3e6b3ac0 100644 --- a/include/vast/Interfaces/SymbolRefInterface.hpp +++ b/include/vast/Dialect/Core/Interfaces/SymbolRefInterface.hpp @@ -13,4 +13,4 @@ VAST_RELAX_WARNINGS VAST_RELAX_WARNINGS /// Include the generated interface declarations. -#include "vast/Interfaces/SymbolRefInterface.h.inc" +#include "vast/Dialect/Core/Interfaces/SymbolRefInterface.h.inc" diff --git a/include/vast/Interfaces/SymbolRefInterface.td b/include/vast/Dialect/Core/Interfaces/SymbolRefInterface.td similarity index 100% rename from include/vast/Interfaces/SymbolRefInterface.td rename to include/vast/Dialect/Core/Interfaces/SymbolRefInterface.td diff --git a/include/vast/Interfaces/SymbolTableInterface.hpp b/include/vast/Dialect/Core/Interfaces/SymbolTableInterface.hpp similarity index 79% rename from include/vast/Interfaces/SymbolTableInterface.hpp rename to include/vast/Dialect/Core/Interfaces/SymbolTableInterface.hpp index 47da0516b4..db6d46d46d 100644 --- a/include/vast/Interfaces/SymbolTableInterface.hpp +++ b/include/vast/Dialect/Core/Interfaces/SymbolTableInterface.hpp @@ -2,7 +2,7 @@ #pragma once -#include "vast/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" #include "vast/Dialect/Core/CoreTraits.hpp" #include "vast/Dialect/Core/SymbolTable.hpp" @@ -15,7 +15,7 @@ namespace vast::core { } // namespace vast::core /// Include the generated interface declarations. -#include "vast/Interfaces/SymbolTableInterface.h.inc" +#include "vast/Dialect/Core/Interfaces/SymbolTableInterface.h.inc" namespace vast::core { diff --git a/include/vast/Interfaces/SymbolTableInterface.td b/include/vast/Dialect/Core/Interfaces/SymbolTableInterface.td similarity index 98% rename from include/vast/Interfaces/SymbolTableInterface.td rename to include/vast/Dialect/Core/Interfaces/SymbolTableInterface.td index a69b074f87..149b653c87 100644 --- a/include/vast/Interfaces/SymbolTableInterface.td +++ b/include/vast/Dialect/Core/Interfaces/SymbolTableInterface.td @@ -53,7 +53,7 @@ def SymbolTableOpInterface : VastOpInterface< "SymbolTableOpInterface" > { class GetCppTraitName< list interfaces > { - defvar cppInterfaceNames = !foreach(interface, interfaces, interface.cppInterfaceName); + defvar cppInterfaceNames = !foreach(interface, interfaces, interface.cppNamespace # "::" # interface.cppInterfaceName); string result = [{ util::type_list< }] # !interleave(cppInterfaceNames, ", ") # [{ > }]; } diff --git a/include/vast/Dialect/Core/SymbolTable.hpp b/include/vast/Dialect/Core/SymbolTable.hpp index 384cbdbc19..e4967ee3f3 100644 --- a/include/vast/Dialect/Core/SymbolTable.hpp +++ b/include/vast/Dialect/Core/SymbolTable.hpp @@ -14,7 +14,7 @@ VAST_UNRELAX_WARNINGS #include "vast/Util/Common.hpp" #include "vast/Util/TypeList.hpp" -#include "vast/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" #include #include diff --git a/include/vast/Dialect/HighLevel/HighLevel.td b/include/vast/Dialect/HighLevel/HighLevel.td index f8caa76dbf..49a9b822fe 100644 --- a/include/vast/Dialect/HighLevel/HighLevel.td +++ b/include/vast/Dialect/HighLevel/HighLevel.td @@ -11,7 +11,7 @@ include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/IR/RegionKindInterface.td" include "mlir/IR/BuiltinAttributeInterfaces.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" include "vast/Dialect/Core/Utils.td" diff --git a/include/vast/Dialect/HighLevel/HighLevelCF.td b/include/vast/Dialect/HighLevel/HighLevelCF.td index 63ff92f318..cc860caf2d 100644 --- a/include/vast/Dialect/HighLevel/HighLevelCF.td +++ b/include/vast/Dialect/HighLevel/HighLevelCF.td @@ -6,7 +6,7 @@ include "mlir/Interfaces/ControlFlowInterfaces.td" include "vast/Dialect/Core/CoreTraits.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" class HighLevel_ControlFlowOp< string mnemonic, list< Trait > traits = [] > : HighLevel_Op< mnemonic, !listconcat(traits, @@ -430,7 +430,7 @@ def HighLevel_DefaultOp } def HighLevel_LabelDeclOp - : HighLevel_Op< "label.decl", [LabelSymbol] > + : HighLevel_Op< "label.decl", [Core_LabelSymbol] > , Arguments<(ins StrAttr:$name)> , Results<(outs HighLevel_LabelType:$result)> { diff --git a/include/vast/Dialect/HighLevel/HighLevelOps.hpp b/include/vast/Dialect/HighLevel/HighLevelOps.hpp index cfc5abfbb6..f4e7d03b27 100644 --- a/include/vast/Dialect/HighLevel/HighLevelOps.hpp +++ b/include/vast/Dialect/HighLevel/HighLevelOps.hpp @@ -18,7 +18,7 @@ VAST_UNRELAX_WARNINGS #include "vast/Dialect/Core/SymbolTable.hpp" -#include "vast/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" #include "vast/Interfaces/AggregateTypeDefinitionInterface.hpp" #include "vast/Interfaces/AST/DeclInterface.hpp" diff --git a/include/vast/Dialect/HighLevel/HighLevelOps.td b/include/vast/Dialect/HighLevel/HighLevelOps.td index bbda1ed342..f1ec61df5e 100644 --- a/include/vast/Dialect/HighLevel/HighLevelOps.td +++ b/include/vast/Dialect/HighLevel/HighLevelOps.td @@ -9,8 +9,8 @@ include "mlir/IR/BuiltinAttributes.td" include "mlir/Interfaces/CastInterfaces.td" include "vast/Interfaces/AggregateTypeDefinitionInterface.td" -include "vast/Interfaces/SymbolInterface.td" -include "vast/Interfaces/SymbolTableInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolTableInterface.td" include "vast/Dialect/HighLevel/HighLevelCF.td" @@ -25,7 +25,9 @@ include "vast/Interfaces/AST/DeclInterface.td" def HighLevel_TranslationUnitOp : HighLevel_Op< "translation_unit", [ NoTerminator, - ShadowingSymbolTable< [[FuncSymbol, VarSymbol, TypeSymbol], [ElaboratedTypeSymbol]] >, + ShadowingSymbolTable< [ + [Core_FuncSymbol, Core_VarSymbol, Core_TypeSymbol], [Core_ElaboratedTypeSymbol] + ] >, IsolatedFromAbove ] > { @@ -46,8 +48,10 @@ def HighLevel_TranslationUnitOp def HighLevel_FuncOp : Core_FuncBaseOp< HighLevel_Dialect, "func", [ - FuncSymbol, - ShadowingSymbolTable< [[VarSymbol, TypeSymbol], [ElaboratedTypeSymbol]] >, + Core_FuncSymbol, + ShadowingSymbolTable< [ + [Core_VarSymbol, Core_TypeSymbol], [Core_ElaboratedTypeSymbol] + ] >, IsolatedFromAbove ] > { @@ -86,7 +90,7 @@ def HighLevel_FuncOp } def HighLevel_TypeDeclOp - : HighLevel_Op< "type", [TypeSymbol] > + : HighLevel_Op< "type", [Core_TypeSymbol] > , Arguments<(ins StrAttr:$name)> { let summary = "VAST type declaration"; @@ -100,7 +104,7 @@ def HighLevel_TypeDeclOp } def HighLevel_TypeDefOp - : HighLevel_Op< "typedef", [TypeSymbol] > + : HighLevel_Op< "typedef", [Core_TypeSymbol] > , Arguments<(ins SymbolNameAttr:$sym_name, TypeAttr:$type)> { let summary = "VAST typedef operation"; @@ -120,7 +124,7 @@ def HighLevel_TypeDefOp } def HighLevel_TypeAliasOp - : HighLevel_Op< "alias", [TypeSymbol] > + : HighLevel_Op< "alias", [Core_TypeSymbol] > , Arguments<(ins StrAttr:$name, TypeAttr:$type)> { let summary = "VAST type alias operation"; @@ -162,7 +166,7 @@ def HighLevel_TypeOfExprOp } def HighLevel_EnumConstantOp - : HighLevel_Op< "enum.const", [EnumConstantSymbol] > + : HighLevel_Op< "enum.const", [Core_EnumConstantSymbol] > , Arguments<(ins StrAttr:$name, TypedAttrInterface:$value)> { let summary = "VAST enum constant declaration"; @@ -208,7 +212,7 @@ def HighLevel_EnumConstantOp def HighLevel_EnumRegion : Region< Core_HasOneBlock, "enum constants region" >; def HighLevel_EnumDeclOp - : HighLevel_Op< "enum", [NoTerminator, TypeSymbol] > + : HighLevel_Op< "enum", [NoTerminator, Core_TypeSymbol] > , Arguments<(ins StrAttr:$name, OptionalAttr:$type)> { let summary = "VAST enum declaration"; @@ -248,7 +252,7 @@ def HighLevel_EnumDeclOp class HighLevel_RecordLikeDeclOp< string mnemonic, list< Trait > traits = [] > : HighLevel_Op< mnemonic, !listconcat(traits, [ - NoTerminator, TypeSymbol, + NoTerminator, Core_TypeSymbol, DeclareOpInterfaceMethods< AggregateTypeDefinition > ]) > @@ -315,7 +319,7 @@ def HighLevel_UnionDeclOp } def HighLevel_FieldDeclOp - : HighLevel_Op< "field", [MemberVarSymbol] > + : HighLevel_Op< "field", [Core_MemberVarSymbol] > , Arguments<(ins StrAttr:$name, TypeAttr:$type, OptionalAttr:$bits)> { let summary = "VAST record field declaration"; diff --git a/include/vast/Dialect/HighLevel/HighLevelOpsCxx.td b/include/vast/Dialect/HighLevel/HighLevelOpsCxx.td index c384799935..6d40198516 100644 --- a/include/vast/Dialect/HighLevel/HighLevelOpsCxx.td +++ b/include/vast/Dialect/HighLevel/HighLevelOpsCxx.td @@ -4,7 +4,7 @@ #define VAST_DIALECT_HIGHLEVEL_IR_HIGHLEVELOPS_CXX class HighLevel_CxxRecordLikeDeclOp< string mnemonic, list< Trait > traits = [] > - : HighLevel_Op< mnemonic, !listconcat(traits, [NoTerminator, TypeSymbol]) > + : HighLevel_Op< mnemonic, !listconcat(traits, [NoTerminator, Core_TypeSymbol]) > , Arguments<(ins StrAttr:$name)> { // TODO(hl:cxx): Add region constraints. diff --git a/include/vast/Dialect/HighLevel/HighLevelUtils.hpp b/include/vast/Dialect/HighLevel/HighLevelUtils.hpp index cab7bcb434..e7fd39d4a1 100644 --- a/include/vast/Dialect/HighLevel/HighLevelUtils.hpp +++ b/include/vast/Dialect/HighLevel/HighLevelUtils.hpp @@ -8,8 +8,7 @@ #include "vast/Dialect/HighLevel/HighLevelTypes.hpp" #include "vast/Dialect/Core/CoreOps.hpp" - -#include "vast/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" #include "vast/Util/Common.hpp" #include @@ -166,7 +165,7 @@ namespace vast::hl { }); } - walk_result users(FuncSymbolOpInterface fn, auto scope, auto &&yield) { + walk_result users(core::FuncSymbolOpInterface fn, auto scope, auto &&yield) { return scope.walk([&](operation op) { if (auto call = mlir::dyn_cast< hl::CallOp >(op)) { return call.getCallee() == fn.getSymbolName() ? yield(op) : walk_result::advance(); diff --git a/include/vast/Dialect/HighLevel/HighLevelVar.td b/include/vast/Dialect/HighLevel/HighLevelVar.td index 5326b607cb..3a30c42840 100644 --- a/include/vast/Dialect/HighLevel/HighLevelVar.td +++ b/include/vast/Dialect/HighLevel/HighLevelVar.td @@ -173,7 +173,7 @@ class HighLevel_StorageSpecifiers : } // Variable Operation -def HighLevel_VarDeclOp : HighLevel_Op< "var", [VarSymbol] > +def HighLevel_VarDeclOp : HighLevel_Op< "var", [Core_VarSymbol] > , HighLevel_StorageSpecifiers { let summary = "VAST variable declaration"; diff --git a/include/vast/Dialect/LowLevel/LowLevel.td b/include/vast/Dialect/LowLevel/LowLevel.td index f47358d10e..0d4f327405 100644 --- a/include/vast/Dialect/LowLevel/LowLevel.td +++ b/include/vast/Dialect/LowLevel/LowLevel.td @@ -10,7 +10,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/IR/RegionKindInterface.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" def LowLevel_Dialect : Dialect { let name = "ll"; diff --git a/include/vast/Dialect/LowLevel/LowLevelOps.hpp b/include/vast/Dialect/LowLevel/LowLevelOps.hpp index 102a59d6b5..d89d8e5f39 100644 --- a/include/vast/Dialect/LowLevel/LowLevelOps.hpp +++ b/include/vast/Dialect/LowLevel/LowLevelOps.hpp @@ -17,7 +17,7 @@ VAST_RELAX_WARNINGS #include VAST_RELAX_WARNINGS -#include "vast/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" #include "vast/Interfaces/ElementTypeInterface.hpp" #include "vast/Dialect/Core/CoreTypes.hpp" diff --git a/include/vast/Dialect/LowLevel/LowLevelOps.td b/include/vast/Dialect/LowLevel/LowLevelOps.td index 04aa05fca4..91059f14f6 100644 --- a/include/vast/Dialect/LowLevel/LowLevelOps.td +++ b/include/vast/Dialect/LowLevel/LowLevelOps.td @@ -8,7 +8,7 @@ include "mlir/IR/BuiltinAttributes.td" include "mlir/Interfaces/ControlFlowInterfaces.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" include "vast/Interfaces/ElementTypeInterface.td" include "vast/Dialect/Core/CoreTraits.td" @@ -94,7 +94,7 @@ def Store } def UninitializedVar - : LowLevel_Op< "uninitialized_var", [VarSymbol] > + : LowLevel_Op< "uninitialized_var", [Core_VarSymbol] > , Results<(outs AnyType:$result)> { let summary = "Declaration of variable that have not been initialized yet."; diff --git a/include/vast/Dialect/Meta/Meta.td b/include/vast/Dialect/Meta/Meta.td index 5887570263..7b85a959fb 100644 --- a/include/vast/Dialect/Meta/Meta.td +++ b/include/vast/Dialect/Meta/Meta.td @@ -10,7 +10,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/IR/RegionKindInterface.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" def Meta_Dialect : Dialect { let name = "meta"; @@ -34,4 +34,3 @@ def Meta_Dialect : Dialect { include "MetaAttributes.td" #endif // VAST_DIALECT_META - diff --git a/include/vast/Dialect/Unsupported/Unsupported.td b/include/vast/Dialect/Unsupported/Unsupported.td index 7c4857a91d..04b51399c9 100644 --- a/include/vast/Dialect/Unsupported/Unsupported.td +++ b/include/vast/Dialect/Unsupported/Unsupported.td @@ -11,7 +11,7 @@ include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/DataLayoutInterfaces.td" include "vast/Interfaces/DefaultDataLayoutTypeInterface.td" -include "vast/Interfaces/SymbolInterface.td" +include "vast/Dialect/Core/Interfaces/SymbolInterface.td" def Unsupported_Dialect : Dialect { let name = "unsup"; diff --git a/include/vast/Interfaces/AST/DeclInterface.td b/include/vast/Interfaces/AST/DeclInterface.td index a7b76f8276..4d9e83c692 100644 --- a/include/vast/Interfaces/AST/DeclInterface.td +++ b/include/vast/Interfaces/AST/DeclInterface.td @@ -56,7 +56,7 @@ def VAST_ValueDeclInterface : VAST_ASTOpInterface< "VAST_ValueDeclInterface", def VAST_DeclaratorDeclInterface : VAST_ASTOpInterface< "VAST_DeclaratorDeclInterface", [VAST_ValueDeclInterface] > { - + let description = [{ An interface to provide [`clang::DeclaratorDecl`] (https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html) functionality. diff --git a/include/vast/Interfaces/CMakeLists.txt b/include/vast/Interfaces/CMakeLists.txt index c55450c103..7bada3b4a4 100644 --- a/include/vast/Interfaces/CMakeLists.txt +++ b/include/vast/Interfaces/CMakeLists.txt @@ -1,8 +1,5 @@ -add_vast_op_interface(SymbolInterface) -add_vast_op_interface(SymbolTableInterface) add_vast_op_interface(AggregateTypeDefinitionInterface) add_vast_attr_interface(TypeQualifiersInterfaces) -add_vast_attr_interface(SymbolRefInterface) add_vast_type_interface(AliasTypeInterface) add_vast_type_interface(DefaultDataLayoutTypeInterface) add_vast_type_interface(ElementTypeInterface) diff --git a/include/vast/Util/Symbols.hpp b/include/vast/Util/Symbols.hpp index e235b12e2d..ddc4c236be 100644 --- a/include/vast/Util/Symbols.hpp +++ b/include/vast/Util/Symbols.hpp @@ -12,11 +12,11 @@ VAST_UNRELAX_WARNINGS #include "vast/Util/Common.hpp" #include "vast/Dialect/HighLevel/HighLevelOps.hpp" -#include "vast/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" namespace vast::util { - using vast_symbol_interface = vast::VastSymbolOpInterface; + using vast_symbol_interface = core::VastSymbolOpInterface; using mlir_symbol_interface = mlir::SymbolOpInterface; void symbols(mlir::Operation *op, auto &&yield) { diff --git a/lib/vast/Dialect/Core/SymbolTable.cpp b/lib/vast/Dialect/Core/SymbolTable.cpp index f051314e99..5c08734084 100644 --- a/lib/vast/Dialect/Core/SymbolTable.cpp +++ b/lib/vast/Dialect/Core/SymbolTable.cpp @@ -6,8 +6,8 @@ #include -#include "vast/Interfaces/SymbolInterface.hpp" -#include "vast/Interfaces/SymbolTableInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolTableInterface.hpp" namespace vast::core { diff --git a/lib/vast/Interfaces/SymbolInterface.cpp b/lib/vast/Interfaces/SymbolInterface.cpp index 829ca0200e..3f0acf97f2 100644 --- a/lib/vast/Interfaces/SymbolInterface.cpp +++ b/lib/vast/Interfaces/SymbolInterface.cpp @@ -1,10 +1,10 @@ // Copyright (c) 2022-present, Trail of Bits, Inc. -#include "vast/Interfaces/SymbolInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp" //===----------------------------------------------------------------------===// // Symbol Interfaces //===----------------------------------------------------------------------===// /// Include the generated symbol interfaces. -#include "vast/Interfaces/SymbolInterface.cpp.inc" \ No newline at end of file +#include "vast/Dialect/Core/Interfaces/SymbolInterface.cpp.inc" diff --git a/lib/vast/Interfaces/SymbolRefInterface.cpp b/lib/vast/Interfaces/SymbolRefInterface.cpp index a0f2f77562..d05f6f9925 100644 --- a/lib/vast/Interfaces/SymbolRefInterface.cpp +++ b/lib/vast/Interfaces/SymbolRefInterface.cpp @@ -1,10 +1,10 @@ // Copyright (c) 2024, Trail of Bits, Inc. -#include "vast/Interfaces/SymbolRefInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolRefInterface.hpp" //===----------------------------------------------------------------------===// // Symbol Ref Interfaces //===----------------------------------------------------------------------===// /// Include the generated symbol interfaces. -#include "vast/Interfaces/SymbolRefInterface.cpp.inc" \ No newline at end of file +#include "vast/Dialect/Core/Interfaces/SymbolRefInterface.cpp.inc" \ No newline at end of file diff --git a/lib/vast/Interfaces/SymbolTableInterface.cpp b/lib/vast/Interfaces/SymbolTableInterface.cpp index 92a6e26f85..abd82260d3 100644 --- a/lib/vast/Interfaces/SymbolTableInterface.cpp +++ b/lib/vast/Interfaces/SymbolTableInterface.cpp @@ -1,10 +1,10 @@ // Copyright (c) 2024, Trail of Bits, Inc. -#include "vast/Interfaces/SymbolTableInterface.hpp" +#include "vast/Dialect/Core/Interfaces/SymbolTableInterface.hpp" //===----------------------------------------------------------------------===// // Symbol Interfaces //===----------------------------------------------------------------------===// /// Include the generated symbol interfaces. -#include "vast/Interfaces/SymbolTableInterface.cpp.inc" \ No newline at end of file +#include "vast/Dialect/Core/Interfaces/SymbolTableInterface.cpp.inc" \ No newline at end of file