include "mlir/Interfaces/ControlFlowInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
+include "mlir/IR/OpAsmInterface.td"
def Shape_WitnessType : DialectType<ShapeDialect,
CPred<"$_self.isa<::mlir::shape::WitnessType>()">, "witness">,
let hasFolder = 1;
}
-def Shape_ConstSizeOp : Shape_Op<"const_size", [ConstantLike, NoSideEffect]> {
+def Shape_ConstSizeOp : Shape_Op<"const_size", [
+ ConstantLike,
+ NoSideEffect,
+ DeclareOpInterfaceMethods<OpAsmOpInterface>
+ ]> {
let summary = "Creates a constant of type `shape.size`";
let description = [{
Creates a `shape.size` type representing the constant size given by `value`.
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/StandardTypes.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
using namespace mlir;
OpFoldResult ConstSizeOp::fold(ArrayRef<Attribute>) { return valueAttr(); }
+void ConstSizeOp::getAsmResultNames(
+ llvm::function_ref<void(Value, StringRef)> setNameFn) {
+ SmallString<4> buffer;
+ llvm::raw_svector_ostream os(buffer);
+ os << "c" << value();
+ setNameFn(getResult(), os.str());
+}
+
//===----------------------------------------------------------------------===//
// ConstWitnessOp
//===----------------------------------------------------------------------===//
%product = shape.mul %lhs, %rhs
return %product: !shape.size
}
+
+func @const_size() {
+ // CHECK: %c1 = shape.const_size 1
+ // CHECK: %c2 = shape.const_size 2
+ // CHECK: %c2_0 = shape.const_size 2
+ %0 = shape.const_size 1
+ %1 = shape.const_size 2
+ %2 = shape.const_size 2
+ return
+}