[Mlir-commits] [mlir] [mlir][emitc] Add op modelling C expressions (PR #71631)

Simon Camphausen llvmlistbot at llvm.org
Wed Nov 8 06:49:48 PST 2023


================
@@ -0,0 +1,117 @@
+//===- Transforms.cpp - Patterns and transforms for the EmitC 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/EmitC/Transforms/Transforms.h"
+#include "mlir/Dialect/EmitC/IR/EmitC.h"
+#include "mlir/IR/IRMapping.h"
+#include "mlir/IR/PatternMatch.h"
+#include "llvm/Support/Debug.h"
+
+namespace mlir {
+namespace emitc {
+
+ExpressionOp createExpression(Operation *op, OpBuilder &builder) {
+  assert(ExpressionOp::isCExpression(*op) && "Expected a C expression");
+
+  // Create an expression yielding the value returned by op.
+  assert(op->getNumResults() == 1 && "Expected exactly one result");
+  Value result = op->getResults()[0];
----------------
simon-camp wrote:

```suggestion
  Value result = op->getResult(0);
```

https://github.com/llvm/llvm-project/pull/71631


More information about the Mlir-commits mailing list