blob: 731a1916420d3a1155520af110d4046e8e7c069f [file] [log] [blame]
Tatiana Shpeisman1bcfe982018-07-13 13:03:13 -07001//===- MLFunction.h - MLIR MLFunction Class ---------------------*- C++ -*-===//
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -07002//
3// Copyright 2019 The MLIR Authors.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16// =============================================================================
17//
18// This file defines MLFunction class
19//
20//===----------------------------------------------------------------------===//
21
22#ifndef MLIR_IR_MLFUNCTION_H_
23#define MLIR_IR_MLFUNCTION_H_
24
25#include "mlir/IR/Function.h"
Tatiana Shpeisman1bcfe982018-07-13 13:03:13 -070026#include "mlir/IR/StmtBlock.h"
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070027
28namespace mlir {
29
30// MLFunction is defined as a sequence of statements that may
Tatiana Shpeisman1bcfe982018-07-13 13:03:13 -070031// include nested affine for loops, conditionals and operations.
32class MLFunction : public Function, public StmtBlock {
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070033public:
34 MLFunction(StringRef name, FunctionType *type);
35
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070036 // TODO: add function arguments and return values once
37 // SSA values are implemented
38
Tatiana Shpeismanc2d88e92018-07-14 16:44:22 -070039 /// Methods for support type inquiry through isa, cast, and dyn_cast.
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070040 static bool classof(const Function *func) {
Tatiana Shpeismanc2d88e92018-07-14 16:44:22 -070041 return func->getKind() == Function::Kind::MLFunc;
42 }
43
44 static bool classof(const StmtBlock *block) {
45 return block->getStmtBlockKind() == StmtBlockKind::MLFunc;
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070046 }
47
48 void print(raw_ostream &os) const;
49};
50
51} // end namespace mlir
52
53#endif // MLIR_IR_MLFUNCTION_H_