MimIR
0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
matrix.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
mim/world.h
>
4
5
#include "
mim/plug/matrix/autogen.h
"
6
7
namespace
mim::plug::matrix
{
8
9
static
constexpr
auto
internal_prefix
=
"internal_mapRed_"
;
10
11
/// %mat.zero: [n: Nat, S: «n; Nat», m: Nat] -> %mat.Mat (n,S,(Idx m));
12
inline
const
Def
*
zero_int
(
World
& w,
const
Def
* n,
const
Def
* S,
const
Def
*
mem
,
nat_t
m) {
13
// TODO: use mim definition by name
14
return
w.app(w.annex<
matrix::constMat
>(), {n, S, w.type_idx(m), mem, w.lit_idx(m, 0)});
15
}
16
17
inline
const
Def
*
op_read
(
const
Def
*
mem
,
const
Def
*
matrix
,
const
Def
* idx) {
18
auto
& world =
matrix
->world();
19
auto
mat_ty =
Axm::isa<Mat>
(
matrix
->type());
20
if
(!mat_ty)
return
matrix
;
21
assert(mat_ty);
22
world.DLOG(
"matrix read: {}[{}]"
,
matrix
, idx);
23
world.DLOG(
" matrix type: {}"
,
matrix
->type());
24
auto
[n, S, T] = mat_ty->args<3>();
25
world.DLOG(
" (n,S,T): {}, {}, {}"
, n, S, T);
26
return
world.app(world.app(world.annex<
read
>(), {n, S, T}), {mem, matrix, idx});
27
}
28
29
}
// namespace mim::plug::matrix
mim::Axm::isa
static auto isa(const Def *def)
Definition
axm.h:107
mim::Def
Base class for all Defs.
Definition
def.h:251
mim::World
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition
world.h:36
autogen.h
mim::plug::matrix
The matrix Plugin
Definition
matrix.h:7
mim::plug::matrix::constMat
constMat
Definition
autogen.h:29
mim::plug::matrix::op_read
const Def * op_read(const Def *mem, const Def *matrix, const Def *idx)
Definition
matrix.h:17
mim::plug::matrix::zero_int
const Def * zero_int(World &w, const Def *n, const Def *S, const Def *mem, nat_t m)
mat.zero: [n: Nat, S: «n; Nat», m: Nat] -> mat.Mat (n,S,(Idx m));
Definition
matrix.h:12
mim::plug::matrix::internal_prefix
static constexpr auto internal_prefix
Definition
matrix.h:9
mim::plug::matrix::read
read
Definition
autogen.h:36
mim::plug::mem
The mem Plugin
Definition
mem.h:11
mim::nat_t
u64 nat_t
Definition
types.h:43
world.h
include
mim
plug
matrix
matrix.h
Generated by
1.13.2