pass.hpp 999 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
#ifndef MIGRAPHX_GUARD_PASS_HPP
#define MIGRAPHX_GUARD_PASS_HPP
Paul's avatar
Paul committed
3

Paul's avatar
Paul committed
4
#include <cassert>
Paul's avatar
Paul committed
5
6
7
8
#include <string>
#include <memory>
#include <type_traits>
#include <utility>
9
#include <migraphx/functional.hpp>
Paul's avatar
Paul committed
10
#include <migraphx/config.hpp>
Paul's avatar
Paul committed
11

Paul's avatar
Paul committed
12
namespace migraphx {
Paul's avatar
Paul committed
13
inline namespace MIGRAPHX_INLINE_NS {
Paul's avatar
Paul committed
14
15

struct program;
Shucai Xiao's avatar
Shucai Xiao committed
16
struct module;
Paul's avatar
Paul committed
17

Paul's avatar
Paul committed
18
19
#ifdef DOXYGEN

Paul's avatar
Paul committed
20
21
/// An interface for applying a transformation to the instructions in a
/// `program`
Paul's avatar
Paul committed
22
23
24
25
struct pass
{
    /// A unique name used to identify the pass
    std::string name() const;
26
27
    /// Run the pass on the module
    void apply(module& m) const;
Paul's avatar
Paul committed
28
    /// Run the pass on the program
29
    void apply(program& p) const;
Paul's avatar
Paul committed
30
31
32
33
};

#else

Paul's avatar
Paul committed
34
35
36
<%
interface('pass',
    virtual('name', returns='std::string', const=True),
37
38
    virtual('apply', returns='void', m='module &', const=True, default='migraphx::nop'),
    virtual('apply', returns='void', p='program &', const=True, default='migraphx::nop')
Paul's avatar
Paul committed
39
40
41
)
%>

Paul's avatar
Paul committed
42
43
#endif

Paul's avatar
Paul committed
44
} // namespace MIGRAPHX_INLINE_NS
Paul's avatar
Paul committed
45
} // namespace migraphx
Paul's avatar
Paul committed
46
47

#endif