-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OM] Extract interfaces for ClassLike ops and ClassFieldLike ops, NFC. (
#5595) This adds interfaces around the existing ClassOp and ClassFieldOp. The interfaces are just abstracting over generated methods for the ClassOp. For the ClassFieldOp, the interface just has one method to get a type, which comes from the field's value. By adding these interfaces and using them for parsing, printing, verifying, etc., it will be simple to add new kinds of ClassLike operations with fields, that can share functionality with the original ClassOp. One immediate use case is a class declaration with only types in its fields, suitable for use to declare external classes.
- Loading branch information
1 parent
cceb170
commit 54839d3
Showing
11 changed files
with
212 additions
and
71 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
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,20 @@ | ||
//===- OMOpInterfaces.h - Object Model operation interfaces ---------------===// | ||
// | ||
// 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 contains the Object Model operation declarations. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CIRCT_DIALECT_OM_OMOPINTERFACES_H | ||
#define CIRCT_DIALECT_OM_OMOPINTERFACES_H | ||
|
||
#include "mlir/IR/OpDefinition.h" | ||
|
||
#include "circt/Dialect/OM/OMOpInterfaces.h.inc" | ||
|
||
#endif // CIRCT_DIALECT_OM_OMOPINTERFACES_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,57 @@ | ||
//===- OMOpInterfaces.td - Object Model dialect op interfaces -------------===// | ||
// | ||
// 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 contains the Object Model dialect operation interfaces. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CIRCT_DIALECT_OM_OMOPINTERFACES_TD | ||
#define CIRCT_DIALECT_OM_OMOPINTERFACES_TD | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def ClassLike : OpInterface<"ClassLike"> { | ||
let cppNamespace = "circt::om"; | ||
|
||
let description = [{ | ||
Common functionality for class-like operations. | ||
}]; | ||
|
||
let methods = [ | ||
InterfaceMethod<"Get the class-like symbol name", | ||
"llvm::StringRef", "getSymName", (ins)>, | ||
InterfaceMethod<"Get the class-like symbol name attribute", | ||
"mlir::StringAttr", "getSymNameAttr", (ins)>, | ||
InterfaceMethod<"Get the class-like symbol name attribute name", | ||
"mlir::StringAttr", "getSymNameAttrName", (ins)>, | ||
InterfaceMethod<"Get the class-like formal parameter names attribute", | ||
"mlir::ArrayAttr", "getFormalParamNames", (ins)>, | ||
InterfaceMethod<"Get the class-like formal parameter names attribute name", | ||
"mlir::StringAttr", "getFormalParamNamesAttrName", (ins)>, | ||
InterfaceMethod<"Get the class-like body region", | ||
"mlir::Region &", "getBody", (ins)>, | ||
InterfaceMethod<"Get the class-like body block", | ||
"mlir::Block *", "getBodyBlock", (ins), | ||
/*methodBody=*/[{ return $_op.getBodyBlock(); }]> | ||
]; | ||
} | ||
|
||
def ClassFieldLike : OpInterface<"ClassFieldLike"> { | ||
let cppNamespace = "circt::om"; | ||
|
||
let description = [{ | ||
Common functionality for class-like field operations. | ||
}]; | ||
|
||
let methods = [ | ||
InterfaceMethod<"Get the class-like field's type", | ||
"mlir::Type", "getType", (ins)> | ||
]; | ||
} | ||
|
||
#endif // CIRCT_DIALECT_OM_OMOPINTERFACES_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
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,15 @@ | ||
//===- OMOpInterfacess.cpp - Object Model operation interface definitions -===// | ||
// | ||
// 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 contains the Object Model operation interface definitions. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "circt/Dialect/OM/OMOpInterfaces.h" | ||
|
||
#include "circt/Dialect/OM/OMOpInterfaces.cpp.inc" |
Oops, something went wrong.