forked from llvm/clangir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR] Make AST attributes accessible via interfaces. (llvm#250)
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang AST nodes, but allows to plugin custom attribute, making `CIR` dialect AST independent. - Extends hierarchy of `DeclAttr`s to model `Decl` attributes more faithfully. - Notably all `CIRASTAttr`s are now created uniformly using `makeAstDeclAttr` which builds corresponding Attribute based on `clang::Decl`.
- Loading branch information
Showing
41 changed files
with
508 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root | ||
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir | ||
set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) | ||
include_directories(SYSTEM ${MLIR_INCLUDE_DIR}) | ||
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR}) | ||
|
||
add_subdirectory(Dialect) | ||
add_subdirectory(Interfaces) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//===- ASTAttrInterfaces.h - CIR AST Interfaces -----------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_INTERFACES_CIR_AST_ATTR_INTERFACES_H_ | ||
#define MLIR_INTERFACES_CIR_AST_ATTR_INTERFACES_H_ | ||
|
||
#include "mlir/IR/Attributes.h" | ||
|
||
#include "clang/AST/Attr.h" | ||
#include "clang/AST/DeclTemplate.h" | ||
#include "clang/AST/Mangle.h" | ||
|
||
namespace mlir { | ||
namespace cir { | ||
|
||
mlir::Attribute makeFuncDeclAttr(const clang::Decl *decl, | ||
mlir::MLIRContext *ctx); | ||
|
||
} // namespace cir | ||
} // namespace mlir | ||
|
||
/// Include the generated interface declarations. | ||
#include "clang/CIR/Interfaces/ASTAttrInterfaces.h.inc" | ||
|
||
namespace mlir { | ||
namespace cir { | ||
|
||
template <typename T> bool hasAttr(ASTDeclInterface decl) { | ||
if constexpr (std::is_same_v<T, clang::OwnerAttr>) | ||
return decl.hasOwnerAttr(); | ||
if constexpr (std::is_same_v<T, clang::PointerAttr>) | ||
return decl.hasPointerAttr(); | ||
if constexpr (std::is_same_v<T, clang::InitPriorityAttr>) | ||
return decl.hasInitPriorityAttr(); | ||
} | ||
|
||
} // namespace cir | ||
} // namespace mlir | ||
|
||
#endif // MLIR_INTERFACES_CIR_AST_ATAR_INTERFACES_H_ |
Oops, something went wrong.