instruction_ref.hpp 1.12 KB
Newer Older
Paul's avatar
Paul committed
1
2
#ifndef MIGRAPHX_GUARD_INSTRUCTION_REF_HPP
#define MIGRAPHX_GUARD_INSTRUCTION_REF_HPP
Paul's avatar
Paul committed
3
4

#include <list>
5
#include <functional>
Paul's avatar
Paul committed
6
#include <migraphx/config.hpp>
Paul's avatar
Paul committed
7

Paul's avatar
Paul committed
8
namespace migraphx {
Paul's avatar
Paul committed
9
inline namespace MIGRAPHX_INLINE_NS {
Paul's avatar
Paul committed
10
11
12
13

struct instruction;
using instruction_ref = std::list<instruction>::iterator;

14
15
migraphx::instruction* as_address(const instruction_ref& ins) noexcept;

Paul's avatar
Paul committed
16
} // namespace MIGRAPHX_INLINE_NS
Paul's avatar
Paul committed
17
} // namespace migraphx
Paul's avatar
Paul committed
18

19
20
21
22
23
namespace std {
template <>
struct hash<migraphx::instruction_ref>
{
    using argument_type = migraphx::instruction_ref;
Shucai Xiao's avatar
Shucai Xiao committed
24
    using result_type   = int;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    result_type operator()(const migraphx::instruction_ref& x) const noexcept
    {
        return std::hash<migraphx::instruction*>{}(migraphx::as_address(x));
    }
};

template <>
struct equal_to<migraphx::instruction_ref>
{
    using argument_type = migraphx::instruction_ref;
    using result_type   = bool;
    result_type operator()(const migraphx::instruction_ref& x,
                           const migraphx::instruction_ref& y) const noexcept
    {
        return migraphx::as_address(x) == migraphx::as_address(y);
    }
};

} // namespace std

Paul's avatar
Paul committed
45
#endif