Skip to content

Commit

Permalink
[Sim][NFC] Include InferTypeOpInterface in SimOps.td (#7693)
Browse files Browse the repository at this point in the history
Include the `InferTypeOpInterface.td` file in `SimOps.td`, which causes
TableGen to automatically generate builders without result type for
operations where the result type is either fixed or derived from the
operands. This makes one of the builders obsolete.
  • Loading branch information
fabianschuiki authored Oct 11, 2024
1 parent c315ed5 commit 71b8665
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
8 changes: 4 additions & 4 deletions include/circt/Dialect/Sim/SimOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
#ifndef CIRCT_DIALECT_SIM_SIMOPS_H
#define CIRCT_DIALECT_SIM_SIMOPS_H

#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/SymbolTable.h"

#include "circt/Dialect/HW/HWOpInterfaces.h"
#include "circt/Dialect/Seq/SeqDialect.h"
#include "circt/Dialect/Seq/SeqTypes.h"
#include "circt/Dialect/Sim/SimDialect.h"
#include "circt/Dialect/Sim/SimTypes.h"
#include "circt/Support/BuilderUtils.h"
#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Interfaces/InferTypeOpInterface.h"

#define GET_OP_CLASSES
#include "circt/Dialect/Sim/Sim.h.inc"
Expand Down
19 changes: 6 additions & 13 deletions include/circt/Dialect/Sim/SimOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
#ifndef CIRCT_DIALECT_SIM_SIMOPS_TD
#define CIRCT_DIALECT_SIM_SIMOPS_TD

include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/FunctionInterfaces.td"
include "circt/Dialect/Sim/SimDialect.td"
include "circt/Dialect/Sim/SimTypes.td"
include "circt/Dialect/Seq/SeqTypes.td"
include "circt/Dialect/HW/HWOpInterfaces.td"
include "circt/Dialect/HW/HWTypes.td"
include "circt/Dialect/Seq/SeqTypes.td"
include "circt/Dialect/Sim/SimDialect.td"
include "circt/Dialect/Sim/SimTypes.td"
include "mlir/Interfaces/FunctionInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"

class SimOp<string mnemonic, list<Trait> traits = []> :
Op<SimDialect, mnemonic, traits>;
Expand Down Expand Up @@ -278,7 +279,6 @@ def FormatCharOp : SimOp<"fmt.char", [Pure]> {

def FormatStringConcatOp : SimOp<"fmt.concat", [Pure]> {
let summary = "Concatenate format strings";

let description = [{
Concatenates an arbitrary number of format strings from
left to right. If the argument list is empty, the empty string
Expand All @@ -288,7 +288,6 @@ def FormatStringConcatOp : SimOp<"fmt.concat", [Pure]> {
not contain itself directly or indirectly.
}];


let arguments = (ins Variadic<FormatStringType>:$inputs);
let results = (outs FormatStringType:$result);

Expand Down Expand Up @@ -319,12 +318,6 @@ def FormatStringConcatOp : SimOp<"fmt.concat", [Pure]> {
/// and flattening continues without recursing into the cycle.
LogicalResult getFlattenedInputs(llvm::SmallVectorImpl<Value> &flatOperands);
}];

let builders = [
OpBuilder<(ins "mlir::ValueRange":$inputs), [{
return build($_builder, $_state, circt::sim::FormatStringType::get($_builder.getContext()), inputs);
}]>
];
}

def PrintFormattedOp : SimOp<"print"> {
Expand Down
6 changes: 2 additions & 4 deletions lib/Dialect/Sim/Transforms/ProceduralizeSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
#include "circt/Dialect/Sim/SimOps.h"
#include "circt/Dialect/Sim/SimTypes.h"
#include "circt/Support/Debug.h"

#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/IndexedMap.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/Debug.h"

#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Pass/Pass.h"

#define DEBUG_TYPE "proceduralize-sim"

namespace circt {
Expand Down

0 comments on commit 71b8665

Please sign in to comment.