CIRCT  20.0.0git
LTLOps.cpp
Go to the documentation of this file.
1 //===- LTLOps.cpp ==-------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
11 #include "mlir/IR/Builders.h"
12 #include "mlir/IR/OpImplementation.h"
13 #include "mlir/IR/PatternMatch.h"
14 #include "mlir/IR/SymbolTable.h"
15 #include "mlir/Interfaces/FunctionImplementation.h"
16 #include "mlir/Interfaces/SideEffectInterfaces.h"
17 
18 using namespace circt;
19 using namespace ltl;
20 using namespace mlir;
21 
22 #define GET_OP_CLASSES
23 #include "circt/Dialect/LTL/LTL.cpp.inc"
24 
25 //===----------------------------------------------------------------------===//
26 // AndOp / OrOp
27 //===----------------------------------------------------------------------===//
28 
29 static LogicalResult inferAndLikeReturnTypes(MLIRContext *context,
30  ValueRange operands,
31  SmallVectorImpl<Type> &results) {
32  if (llvm::any_of(operands, [](auto operand) {
33  return isa<PropertyType>(operand.getType());
34  })) {
35  results.push_back(PropertyType::get(context));
36  } else if (llvm::any_of(operands, [](auto operand) {
37  return isa<SequenceType>(operand.getType());
38  })) {
39  results.push_back(SequenceType::get(context));
40  } else {
41  results.push_back(IntegerType::get(context, 1));
42  }
43  return success();
44 }
45 
46 LogicalResult
47 AndOp::inferReturnTypes(MLIRContext *context, std::optional<Location> loc,
48  ValueRange operands, DictionaryAttr attributes,
49  OpaqueProperties properties, RegionRange regions,
50  SmallVectorImpl<Type> &inferredReturnTypes) {
51  return inferAndLikeReturnTypes(context, operands, inferredReturnTypes);
52 }
53 
54 LogicalResult
55 OrOp::inferReturnTypes(MLIRContext *context, std::optional<Location> loc,
56  ValueRange operands, DictionaryAttr attributes,
57  OpaqueProperties properties, RegionRange regions,
58  SmallVectorImpl<Type> &inferredReturnTypes) {
59  return inferAndLikeReturnTypes(context, operands, inferredReturnTypes);
60 }
61 
62 LogicalResult
63 IntersectOp::inferReturnTypes(MLIRContext *context, std::optional<Location> loc,
64  ValueRange operands, DictionaryAttr attributes,
65  OpaqueProperties properties, RegionRange regions,
66  SmallVectorImpl<Type> &inferredReturnTypes) {
67  return inferAndLikeReturnTypes(context, operands, inferredReturnTypes);
68 }
69 
70 //===----------------------------------------------------------------------===//
71 // ClockOp
72 //===----------------------------------------------------------------------===//
73 
74 LogicalResult
75 ClockOp::inferReturnTypes(MLIRContext *context, std::optional<Location> loc,
76  ValueRange operands, DictionaryAttr attributes,
77  OpaqueProperties properties, RegionRange regions,
78  SmallVectorImpl<Type> &inferredReturnTypes) {
79  if (isa<PropertyType>(operands[0].getType())) {
80  inferredReturnTypes.push_back(PropertyType::get(context));
81  } else {
82  inferredReturnTypes.push_back(SequenceType::get(context));
83  }
84  return success();
85 }
static LogicalResult inferAndLikeReturnTypes(MLIRContext *context, ValueRange operands, SmallVectorImpl< Type > &results)
Definition: LTLOps.cpp:29
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
Definition: CalyxOps.cpp:55
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: ltl.py:1