-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][IRDL] Added IRDL to C++ Translation #133982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
96 commits
Select commit
Hold shift + click to select a range
74f7aa6
set up mlir-translate for IRDL translation
Moxinilian 9f37bb6
simplify translation registration
Moxinilian c1ca4bd
generate dialect declaration
Moxinilian 483d5a2
add constraints on dialect names
Moxinilian 71cc646
add dialect def
Moxinilian 4b6bd5d
first draft of op template
Moxinilian 39dda7d
added base type class
hhkit cb7337d
generate singleton types
hhkit 451c439
basic operation work + escaped braces in operationdecl
hhkit f25ce38
mlir explicit type id
hhkit 228729d
used namespace path for type reg
hhkit bf226ad
Merge branch 'main' of https://github.com/opencompl/llvm-project into…
8d4bad5
merged from upstream, added name to mvp
704f111
return operand names
hhkit d30c976
return operand names
hhkit aa82910
Merge branch 'hhkit/irdl-to-cpp' of https://github.com/opencompl/llvm…
hhkit 3411c33
revert bad edit
hhkit 731fd7c
typedef list + print/parse defs
hhkit 79d5acb
compile decls and defs for build
hhkit 02d396e
refactored name processing logic
hhkit 3ddd47b
define typeIDs
hhkit f6920fe
irdl-to-cpp toolchain (#16)
Moxinilian 69ee9b0
add cross-compile support (#17)
Moxinilian 0da3cb6
build driver
hhkit dfdb06a
first step towards IRDL to cpp test (#18)
Moxinilian 19ae518
header builds
hhkit 9160c95
fixed compile errors in define
hhkit 2c496ec
successful registration in mlir-opt
hhkit b3801fe
abort fix
hhkit 3b9a32d
removed custom print and parse
hhkit 35d9dba
simplified test case
hhkit 1cbb39d
[IRDL2CPP] Attempt at Templating (#19)
hhkit aac4b98
some changes
Moxinilian 5f77c3a
fixed errors
hhkit f00bf0d
getters for operands
hhkit 739e8b1
clang-format
hhkit 9736b13
removed unneeded functions
hhkit 7727f15
handle errors
hhkit bc41321
support negative
hhkit 24b9d78
check results type
hhkit cb754ee
mlir-opt verify test
hhkit c8e98d9
fixed the easy changes
hhkit 73e8ff9
PR changes pt ii
hhkit 98efc62
case conversion
hhkit 77aaaf2
removed oplist and typelist defs
hhkit bda0295
newline fix
hhkit 1995868
added test for conversion
hhkit 14b3fde
Merge branch 'main' of https://github.com/opencompl/llvm-project into…
hhkit 4a9735e
new lines, macro guard documentation
hhkit 447e474
Update mlir/lib/Target/IRDLToCpp/IRDLToCpp.cpp
hhkit c1feed3
Merge branch 'hhkit/irdl-to-cpp' of https://github.com/opencompl/llvm…
hhkit edc9fa2
simple PR changes
hhkit 21eada6
set up for multiple dialect conversions
hhkit d2ca62c
Merge branch 'main' of https://github.com/opencompl/llvm-project into…
hhkit 1c5c3c1
conversion test works again
hhkit 26f580e
getODSResults
hhkit 732e606
fixed header naming
hhkit 44976b6
symbol verification
hhkit 318f759
invalid names
hhkit 6d1beac
check every irdl op
hhkit 16b0414
unsupported irdl ops
hhkit 05fa3a8
base types
hhkit ef0d97e
simplified test
hhkit 91d6f80
split file works omg cleanup needed
hhkit 8f7e939
silence most failing tests
hhkit 764d638
allow types and attribs to be prefixed with ! and #
hhkit dfbb919
clean up mlir-irdl-to-cpp
hhkit 3638c9b
fixed PR changes
hhkit a1f308e
renamed name checker
hhkit db38f4e
invert verifysupport check
hhkit 1295496
attempt to clean up main.cpp
hhkit b35f796
removed name with underscore
hhkit 7c52b16
simple cleanup
hhkit 81a1530
remaining fixes
hhkit cf508a9
fix templates
Moxinilian da16951
add comments and fix bug
Moxinilian 784b04d
extracted getters and builders
hhkit d99bc6a
Merge branch 'main' into hhkit/irdl-to-cpp
hhkit e980d88
fixed comments
hhkit c26e36d
fixed multidialect bug
hhkit b9fb698
Merge branch 'main' into hhkit/irdl-to-cpp
hhkit bc37a24
Update mlir/lib/Target/IRDLToCpp/IRDLToCpp.cpp
hhkit e51ae35
Update mlir/lib/Target/IRDLToCpp/IRDLToCpp.cpp
hhkit ef16ac5
Update mlir/lib/Target/IRDLToCpp/IRDLToCpp.cpp
hhkit e21a21f
Update mlir/lib/Target/IRDLToCpp/IRDLToCpp.cpp
hhkit c79ddcd
PR suggestions
hhkit 5ef348a
more PR fixes
hhkit a30bb8d
moved invalid name test
hhkit b1ccf66
Update mlir/lib/Target/IRDLToCpp/Templates/PerOperationDecl.txt
hhkit aae9e19
added basic filecheck for irdl translation
hhkit 29581b7
comments, as requested by PR
hhkit 180f3a5
hopefully fix CMake problems
Moxinilian c6b1fcd
hopefully make CI happy about templates
Moxinilian fafc0ee
simplify processBuffer code to please MSVC
Moxinilian 2abd9dc
wrap at 80 cols
hhkit f04509d
Merge branch 'main' into hhkit/irdl-to-cpp
hhkit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
function(add_irdl_to_cpp_target target irdl_file) | ||
add_custom_command( | ||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${irdl_file}.cpp.inc | ||
COMMAND ${MLIR_IRDL_TO_CPP_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/${irdl_file} -o ${CMAKE_CURRENT_BINARY_DIR}/${irdl_file}.cpp.inc | ||
|
||
# The command output depends on the executable to ensure IRDL sources are properly rebuilt | ||
# if the tool changes. | ||
DEPENDS ${MLIR_IRDL_TO_CPP_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/${irdl_file} | ||
COMMENT "Building ${irdl_file}..." | ||
) | ||
add_custom_target(${target} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${irdl_file}.cpp.inc) | ||
endfunction() |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,38 @@ | ||
//===- IRDLToCpp.h - Register translation -----------------------*- 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file defines the registration function for the IRDL to C++ translation. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_TARGET_IRDLTOCPP_IRDLTOCPP_H | ||
#define MLIR_TARGET_IRDLTOCPP_IRDLTOCPP_H | ||
|
||
#include "mlir/Dialect/IRDL/IR/IRDL.h" | ||
|
||
namespace mlir { | ||
namespace irdl { | ||
|
||
/// Translates an IRDL dialect definition to a C++ definition that can be used | ||
/// with MLIR. | ||
/// | ||
/// The following preprocessor macros will generate the following code: | ||
/// | ||
/// // This define generates code for the dialect's class declarations | ||
/// #define GEN_DIALECT_DECL_HEADER | ||
/// | ||
/// // This define generates code for the dialect's class definitions | ||
/// #define GEN_DIALECT_DEF | ||
LogicalResult | ||
translateIRDLDialectToCpp(llvm::ArrayRef<irdl::DialectOp> dialects, | ||
raw_ostream &output); | ||
|
||
} // namespace irdl | ||
} // namespace mlir | ||
|
||
#endif // MLIR_TARGET_IRDLTOCPP_IRDLTOCPP_H |
22 changes: 22 additions & 0 deletions
22
mlir/include/mlir/Target/IRDLToCpp/TranslationRegistration.h
This file contains hidden or 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,22 @@ | ||
//===- TranslationRegistration.h - Register translation ---------*- 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file defines the registration function for the IRDL to C++ translation. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_TARGET_IRDLTOCPP_TRANSLATIONREGISTRATION_H | ||
#define MLIR_TARGET_IRDLTOCPP_TRANSLATIONREGISTRATION_H | ||
|
||
namespace mlir { | ||
|
||
void registerIRDLToCppTranslation(); | ||
|
||
} // namespace mlir | ||
|
||
#endif // MLIR_TARGET_IRDLTOCPP_TRANSLATIONREGISTRATION_H |
This file contains hidden or 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 hidden or 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 hidden or 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,18 @@ | ||
add_mlir_translation_library(MLIRTargetIRDLToCpp | ||
TranslationRegistration.cpp | ||
IRDLToCpp.cpp | ||
Templates/DialectDecl.txt | ||
Templates/DialectDef.txt | ||
Templates/Header.txt | ||
Templates/PerOperationDecl.txt | ||
Templates/PerOperationDef.txt | ||
Templates/TypeDecl.txt | ||
Templates/TypeDef.txt | ||
Templates/TypeHeaderDecl.txt | ||
Templates/TypeHeaderDef.txt | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRIR | ||
MLIRIRDL | ||
MLIRTranslateLib | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this change (and the other changes related to the names) in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Moxinilian 🥹
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll clean that up in a subsequent PR if you don't mind. This is a little bit of a workaround for the symbol limitations. I'd like to remove symbols entirely from IRDL once this is merged. If you prefer it to be done the other way around it's also possible, but it would add some delay on this PR so it's your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem for me, that's okay