1//===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===//
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//
9// This file declares a simple interface to perform IR generation targeting MLIR
10// from a Module AST for the Toy language.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef TOY_MLIRGEN_H
15#define TOY_MLIRGEN_H
16
17#include <memory>
18
19namespace mlir {
20class MLIRContext;
21template <typename OpTy>
22class OwningOpRef;
23class ModuleOp;
24} // namespace mlir
25
26namespace toy {
27class ModuleAST;
28
29/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
30/// or nullptr on failure.
31mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
32 ModuleAST &moduleAST);
33} // namespace toy
34
35#endif // TOY_MLIRGEN_H
36

source code of mlir/examples/toy/Ch4/include/toy/MLIRGen.h