-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td #86080
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
lanza
merged 18 commits into
main
from
users/lanza/sprcirnfc-add-scaffolding-for-the-cir-dialect-and-ciropstd
Apr 25, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ff8be69
[𝘀𝗽𝗿] initial version
lanza 2499cc1
[𝘀𝗽𝗿] changes to main this commit is based on
lanza 4358695
fix MLIRCIROpsIncGen
lanza fe44284
add some guts to CIRDialect.cpp and MLIRCIR lib
lanza 53655ac
[𝘀𝗽𝗿] changes introduced through rebase
lanza 2a0015f
rebase
lanza 14bf496
[𝘀𝗽𝗿] changes introduced through rebase
lanza a558a18
rebase
lanza 550ca52
[𝘀𝗽𝗿] changes introduced through rebase
lanza 95995e0
rebase
lanza 6c946b1
[𝘀𝗽𝗿] changes introduced through rebase
marbre 2daf8b7
address comments
lanza 9b1f2da
[𝘀𝗽𝗿] changes introduced through rebase
kazutakahirata b7b5374
rebase
lanza 0e19554
include dialect and add include guards
lanza 5e28699
dont support standalone
lanza 5effbee
[𝘀𝗽𝗿] changes introduced through rebase
mtrofin ac4aab9
rebase
lanza 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir | ||
set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) | ||
include_directories(${MLIR_INCLUDE_DIR}) | ||
include_directories(${MLIR_TABLEGEN_OUTPUT_DIR}) | ||
|
||
add_subdirectory(Dialect) |
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 @@ | ||
add_subdirectory(IR) |
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,16 @@ | ||
//===- CIRDialect.h - CIR dialect -------------------------------*- 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 declares the CIR dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT_H | ||
#define LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT_H | ||
|
||
#endif // LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT_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,44 @@ | ||
//===- CIRDialect.td - CIR dialect -------------------------*- tablegen -*-===// | ||
// | ||
// 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 declares the CIR dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT | ||
#define LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def CIR_Dialect : Dialect { | ||
let name = "cir"; | ||
|
||
// A short one-line summary of our dialect. | ||
let summary = "A high-level dialect for analyzing and optimizing Clang " | ||
"supported languages"; | ||
|
||
let cppNamespace = "::mlir::cir"; | ||
|
||
let useDefaultAttributePrinterParser = 0; | ||
let useDefaultTypePrinterParser = 0; | ||
lanza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
let extraClassDeclaration = [{ | ||
void registerAttributes(); | ||
void registerTypes(); | ||
|
||
Type parseType(DialectAsmParser &parser) const override; | ||
lanza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
void printType(Type type, DialectAsmPrinter &printer) const override; | ||
|
||
Attribute parseAttribute(DialectAsmParser &parser, | ||
Type type) const override; | ||
|
||
void printAttribute(Attribute attr, DialectAsmPrinter &os) const override; | ||
}]; | ||
} | ||
|
||
#endif // LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT |
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,19 @@ | ||
//===-- CIROps.td - CIR dialect definition -----------------*- tablegen -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// \file | ||
/// Definition of the CIR dialect | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIROPS | ||
#define LLVM_CLANG_CIR_DIALECT_IR_CIROPS | ||
|
||
include "clang/CIR/Dialect/IR/CIRDialect.td" | ||
|
||
#endif // LLVM_CLANG_CIR_DIALECT_IR_CIROPS |
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,16 @@ | ||
# This replicates part of the add_mlir_dialect cmake function from MLIR that | ||
# cannot be used here. This happens because it expects to be run inside MLIR | ||
# directory which is not the case for CIR (and also FIR, both have similar | ||
# workarounds). | ||
|
||
# Equivalent to add_mlir_dialect(CIROps cir) | ||
set(LLVM_TARGET_DEFINITIONS CIROps.td) | ||
mlir_tablegen(CIROps.h.inc -gen-op-decls) | ||
mlir_tablegen(CIROps.cpp.inc -gen-op-defs) | ||
mlir_tablegen(CIROpsTypes.h.inc -gen-typedef-decls) | ||
mlir_tablegen(CIROpsTypes.cpp.inc -gen-typedef-defs) | ||
mlir_tablegen(CIROpsDialect.h.inc -gen-dialect-decls) | ||
mlir_tablegen(CIROpsDialect.cpp.inc -gen-dialect-defs) | ||
add_public_tablegen_target(MLIRCIROpsIncGen) | ||
add_dependencies(mlir-headers MLIRCIROpsIncGen) | ||
lanza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
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,4 @@ | ||
include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include) | ||
include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include) | ||
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think something like |
||
|
||
add_subdirectory(Dialect) |
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 @@ | ||
add_subdirectory(IR) |
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,13 @@ | ||
//===- CIRDialect.cpp - MLIR CIR ops implementation -----------------------===// | ||
// | ||
// 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 implements the CIR dialect and its operations. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
lanza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#include <clang/CIR/Dialect/IR/CIRDialect.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,3 @@ | ||
add_clang_library(MLIRCIR | ||
CIRDialect.cpp | ||
) |
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.
Uh oh!
There was an error while loading. Please reload this page.