Tatiana Shpeisman | 1bcfe98 | 2018-07-13 13:03:13 -0700 | [diff] [blame] | 1 | //===- MLFunction.h - MLIR MLFunction Class ---------------------*- C++ -*-===// |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 2 | // |
| 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 Shpeisman | 1bcfe98 | 2018-07-13 13:03:13 -0700 | [diff] [blame] | 26 | #include "mlir/IR/StmtBlock.h" |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 27 | |
| 28 | namespace mlir { |
| 29 | |
| 30 | // MLFunction is defined as a sequence of statements that may |
Tatiana Shpeisman | 1bcfe98 | 2018-07-13 13:03:13 -0700 | [diff] [blame] | 31 | // include nested affine for loops, conditionals and operations. |
| 32 | class MLFunction : public Function, public StmtBlock { |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 33 | public: |
| 34 | MLFunction(StringRef name, FunctionType *type); |
| 35 | |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 36 | // TODO: add function arguments and return values once |
| 37 | // SSA values are implemented |
| 38 | |
Tatiana Shpeisman | c2d88e9 | 2018-07-14 16:44:22 -0700 | [diff] [blame^] | 39 | /// Methods for support type inquiry through isa, cast, and dyn_cast. |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 40 | static bool classof(const Function *func) { |
Tatiana Shpeisman | c2d88e9 | 2018-07-14 16:44:22 -0700 | [diff] [blame^] | 41 | return func->getKind() == Function::Kind::MLFunc; |
| 42 | } |
| 43 | |
| 44 | static bool classof(const StmtBlock *block) { |
| 45 | return block->getStmtBlockKind() == StmtBlockKind::MLFunc; |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void print(raw_ostream &os) const; |
| 49 | }; |
| 50 | |
| 51 | } // end namespace mlir |
| 52 | |
| 53 | #endif // MLIR_IR_MLFUNCTION_H_ |