-
Notifications
You must be signed in to change notification settings - Fork 302
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
[RTGTest] Add RTGTest dialect #7841
Merged
Merged
Changes from all commits
Commits
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 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 @@ | ||
add_subdirectory(IR) |
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,6 @@ | ||
add_circt_dialect(RTGTest rtgtest) | ||
|
||
set(LLVM_TARGET_DEFINITIONS RTGTest.td) | ||
|
||
add_circt_dialect_doc(RTGTest rtgtest) | ||
|
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,26 @@ | ||
//===- RTGTest.td - RTGTest top-level 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This is the top level file for the RTGTest dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CIRCT_DIALECT_RTGTEST_IR_RTGTEST_TD | ||
#define CIRCT_DIALECT_RTGTEST_IR_RTGTEST_TD | ||
|
||
include "mlir/IR/OpBase.td" | ||
include "mlir/Interfaces/SideEffectInterfaces.td" | ||
include "mlir/IR/OpAsmInterface.td" | ||
|
||
include "circt/Dialect/RTG/IR/RTGInterfaces.td" | ||
|
||
include "circt/Dialect/RTGTest/IR/RTGTestDialect.td" | ||
include "circt/Dialect/RTGTest/IR/RTGTestTypes.td" | ||
include "circt/Dialect/RTGTest/IR/RTGTestOps.td" | ||
|
||
#endif // CIRCT_DIALECT_RTGTEST_IR_RTGTEST_TD |
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,24 @@ | ||
//===- RTGTestDialect.h - RTG Test dialect declaration ----------*- 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 RTGTest MLIR dialect. This dialect defines a minimal | ||
// set of operations to use for testing the RTG dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CIRCT_DIALECT_RTGTEST_IR_RTGTESTDIALECT_H | ||
#define CIRCT_DIALECT_RTGTEST_IR_RTGTESTDIALECT_H | ||
|
||
#include "circt/Support/LLVM.h" | ||
#include "mlir/IR/BuiltinAttributes.h" | ||
#include "mlir/IR/Dialect.h" | ||
|
||
// Pull in the Dialect definition. | ||
#include "circt/Dialect/RTGTest/IR/RTGTestDialect.h.inc" | ||
|
||
#endif // CIRCT_DIALECT_RTGTEST_IR_RTGTESTDIALECT_H |
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,36 @@ | ||
//===- RTGTestDialect.td - RTG Test 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file defines the RTG Test dialect. This dialect provides a minimal | ||
// set of operations to test the RTG dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CIRCT_DIALECT_RTGTEST_IR_RTGTESTDIALECT_TD | ||
#define CIRCT_DIALECT_RTGTEST_IR_RTGTESTDIALECT_TD | ||
|
||
include "mlir/IR/DialectBase.td" | ||
|
||
def RTGTestDialect : Dialect { | ||
let name = "rtgtest"; | ||
|
||
let summary = "types and operations for random test generation testing"; | ||
let description = [{ | ||
This dialect defines the `rtgtest` dialect, which provides a set of | ||
operation definitions to test the RTG dialect. | ||
}]; | ||
|
||
let useDefaultTypePrinterParser = 1; | ||
let cppNamespace = "::circt::rtgtest"; | ||
|
||
let extraClassDeclaration = [{ | ||
void registerTypes(); | ||
}]; | ||
} | ||
|
||
#endif // CIRCT_DIALECT_RTGTEST_IR_RTGTESTDIALECT_TD |
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,30 @@ | ||
//===- RTGTestOps.h - Declare RTGTest dialect operations --------*- 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 operation classes for the RTGTest dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CIRCT_DIALECT_RTGTEST_IR_RTGTESTOPS_H | ||
#define CIRCT_DIALECT_RTGTEST_IR_RTGTESTOPS_H | ||
|
||
#include "circt/Dialect/RTG/IR/RTGOpInterfaces.h" | ||
#include "circt/Dialect/RTG/IR/RTGOps.h" | ||
#include "circt/Dialect/RTGTest/IR/RTGTestDialect.h" | ||
#include "circt/Dialect/RTGTest/IR/RTGTestTypes.h" | ||
#include "circt/Support/LLVM.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// TableGen generated logic. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#define GET_OP_CLASSES | ||
#include "circt/Dialect/RTGTest/IR/RTGTest.h.inc" | ||
|
||
#endif // CIRCT_DIALECT_RTGTEST_IR_RTGTESTOPS_H |
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,36 @@ | ||
//===- RTGTestOps.td - RTGTest operations ------------------*- 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 describes the RTGTest MLIR operations. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
include "mlir/IR/CommonAttrConstraints.td" | ||
include "circt/Dialect/RTG/IR/RTGInterfaces.td" | ||
|
||
// Base class for the operation in this dialect. | ||
class RTGTestOp<string mnemonic, list<Trait> traits = []> : | ||
Op<RTGTestDialect, mnemonic, traits>; | ||
|
||
|
||
def CPUDeclOp : RTGTestOp<"cpu_decl", [ | ||
Pure, | ||
ConstantLike, | ||
DeclareOpInterfaceMethods<ContextResourceOpInterface>, | ||
]> { | ||
let summary = "declare a CPU"; | ||
let description = [{ | ||
This operation is used to test the `ContextResourceOpInterface` and passes | ||
taking advantage of it. | ||
}]; | ||
|
||
let arguments = (ins IndexAttr:$id); | ||
let results = (outs CPUType:$cpu); | ||
|
||
let assemblyFormat = "$id attr-dict"; | ||
} |
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,21 @@ | ||
//===- RTGTestTypes.h - RTG Test dialect types ------------------*- 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 CIRCT_DIALECT_RTGTEST_IR_RTGTESTTYPES_H | ||
#define CIRCT_DIALECT_RTGTEST_IR_RTGTESTTYPES_H | ||
|
||
#include "mlir/IR/BuiltinAttributes.h" | ||
#include "mlir/IR/BuiltinTypes.h" | ||
#include "mlir/IR/Types.h" | ||
|
||
#include "circt/Dialect/RTG/IR/RTGTypeInterfaces.h" | ||
|
||
#define GET_TYPEDEF_CLASSES | ||
#include "circt/Dialect/RTGTest/IR/RTGTestTypes.h.inc" | ||
|
||
#endif // CIRCT_DIALECT_RTGTEST_IR_RTGTESTTYPES_H |
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,35 @@ | ||
//===- RTGTestTypes.td - RTGTest types ---------------------*- 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 describes the RTGTest types. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CIRCT_DIALECT_RTGTEST_IR_RTGTESTTYPES_TD | ||
#define CIRCT_DIALECT_RTGTEST_IR_RTGTESTTYPES_TD | ||
|
||
include "circt/Dialect/RTGTest/IR/RTGTestDialect.td" | ||
include "circt/Dialect/RTG/IR/RTGInterfaces.td" | ||
include "mlir/IR/AttrTypeBase.td" | ||
|
||
class RTGTestTypeDef<string name, list<Trait> traits = []> | ||
: TypeDef<RTGTestDialect, name, traits>; | ||
|
||
def CPUType : RTGTestTypeDef<"cpu", [ContextResourceTypeInterface]> { | ||
let summary = "handle to a specific CPU"; | ||
let description = [{ | ||
This type implements a specific context resource to test RTG operations | ||
taking context resources as operands (such as `on_context`) and other things | ||
requiring a concrete instance of a `ContextResourceTypeInterface`. | ||
}]; | ||
|
||
let mnemonic = "cpu"; | ||
let assemblyFormat = ""; | ||
} | ||
|
||
#endif // CIRCT_DIALECT_RTGTEST_IR_RTGTESTTYPES_TD |
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 @@ | ||
add_subdirectory(IR) |
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,15 @@ | ||
add_circt_dialect_library(CIRCTRTGTestDialect | ||
RTGTestDialect.cpp | ||
RTGTestOps.cpp | ||
RTGTestTypes.cpp | ||
|
||
ADDITIONAL_HEADER_DIRS | ||
${CIRCT_MAIN_INCLUDE_DIR}/circt/Dialect/RTGTest/IR | ||
|
||
DEPENDS | ||
MLIRRTGTestIncGen | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRIR | ||
CIRCTRTGDialect | ||
) |
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,36 @@ | ||
//===- RTGTestDialect.cpp - Implement the RTGTest dialect -----------------===// | ||
// | ||
// 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 RTGTest dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "circt/Dialect/RTGTest/IR/RTGTestDialect.h" | ||
#include "circt/Dialect/RTGTest/IR/RTGTestOps.h" | ||
#include "circt/Dialect/RTGTest/IR/RTGTestTypes.h" | ||
#include "mlir/IR/Builders.h" | ||
#include "mlir/IR/BuiltinTypes.h" | ||
#include "mlir/IR/DialectImplementation.h" | ||
|
||
using namespace circt; | ||
using namespace rtgtest; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Dialect specification. | ||
//===----------------------------------------------------------------------===// | ||
|
||
void RTGTestDialect::initialize() { | ||
registerTypes(); | ||
// Register operations. | ||
addOperations< | ||
#define GET_OP_LIST | ||
#include "circt/Dialect/RTGTest/IR/RTGTest.cpp.inc" | ||
>(); | ||
} | ||
|
||
#include "circt/Dialect/RTGTest/IR/RTGTestDialect.cpp.inc" |
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,32 @@ | ||
//===- RTGTestOps.cpp - Implement the RTG operations ----------------------===// | ||
// | ||
// 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 RTGTest ops. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "circt/Dialect/RTGTest/IR/RTGTestOps.h" | ||
#include "mlir/IR/Builders.h" | ||
#include "llvm/ADT/APInt.h" | ||
|
||
using namespace circt; | ||
using namespace rtgtest; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// CPUDeclOp | ||
//===----------------------------------------------------------------------===// | ||
|
||
size_t CPUDeclOp::getIdentifier(size_t idx) { return getId().getZExtValue(); } | ||
|
||
//===----------------------------------------------------------------------===// | ||
// TableGen generated logic. | ||
//===----------------------------------------------------------------------===// | ||
|
||
// Provide the autogenerated implementation guts for the Op classes. | ||
#define GET_OP_CLASSES | ||
#include "circt/Dialect/RTGTest/IR/RTGTest.cpp.inc" |
Oops, something went wrong.
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.
This is very neat 👍