Functions are always callable operations and thus every operation implementing the `FunctionOpInterface` also implements the `CallableOpInterface`. The only exception was the FuncOp in the toy example. To make implementation of the `FunctionOpInterface` easier, this commit lets `FunctionOpInterface` inherit from `CallableOpInterface` and merges some of their methods. More precisely, the `CallableOpInterface` has methods to get the argument and result attributes and a method to get the result types of the callable region. These methods are always implemented the same way as their analogues in `FunctionOpInterface` and thus this commit moves all the argument and result attribute handling methods to the callable interface as well as the methods to get the argument and result types. The `FuntionOpInterface` then does not have to declare them as well, but just inherits them from the `CallableOpInterface`. Adding the inheritance relation also required to move the `FunctionOpInterface` from the IR directory to the Interfaces directory since IR should not depend on Interfaces. Reviewed By: jpienaar, springerm Differential Revision: https://reviews.llvm.org/D157988
37 lines
1.3 KiB
C
37 lines
1.3 KiB
C
//===- Dialect.h - Dialect definition for the Toy IR ----------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the IR Dialect for the Toy language.
|
|
// See docs/Tutorials/Toy/Ch-2.md for more information.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef MLIR_TUTORIAL_TOY_DIALECT_H_
|
|
#define MLIR_TUTORIAL_TOY_DIALECT_H_
|
|
|
|
#include "mlir/Bytecode/BytecodeOpInterface.h"
|
|
#include "mlir/IR/BuiltinTypes.h"
|
|
#include "mlir/IR/Dialect.h"
|
|
#include "mlir/IR/SymbolTable.h"
|
|
#include "mlir/Interfaces/CallInterfaces.h"
|
|
#include "mlir/Interfaces/CastInterfaces.h"
|
|
#include "mlir/Interfaces/FunctionInterfaces.h"
|
|
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
|
#include "toy/ShapeInferenceInterface.h"
|
|
|
|
/// Include the auto-generated header file containing the declaration of the toy
|
|
/// dialect.
|
|
#include "toy/Dialect.h.inc"
|
|
|
|
/// Include the auto-generated header file containing the declarations of the
|
|
/// toy operations.
|
|
#define GET_OP_CLASSES
|
|
#include "toy/Ops.h.inc"
|
|
|
|
#endif // MLIR_TUTORIAL_TOY_DIALECT_H_
|