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/pass/pipelinebuilder.h
>
6
7
#include "
mim/plug/matrix/autogen.h
"
8
9
namespace
mim::plug::matrix
{
10
11
#define INTERNAL_PREFIX "internal_mapRed_"
12
13
/// %mat.zero: [n: Nat, S: «n; Nat», m: Nat] -> %mat.Mat (n,S,(Idx m));
14
inline
const
Def
*
zero_int
(
World
& w,
Ref
n,
Ref
S,
Ref
mem
,
nat_t
m) {
15
// TODO: use mim definition by name
16
return
w.app(w.annex<
matrix::constMat
>(), {n, S, w.type_idx(m), mem, w.lit_idx(m, 0)});
17
}
18
19
inline
const
Def
*
op_read
(
Ref
mem
,
Ref
matrix,
Ref
idx) {
20
auto
& world = matrix->
world
();
21
auto
mat_ty =
match<Mat>
(matrix->
type
());
22
if
(!mat_ty)
return
matrix;
23
assert(mat_ty);
24
world.DLOG(
"matrix read: {}[{}]"
, matrix, idx);
25
world.DLOG(
" matrix type: {}"
, matrix->
type
());
26
auto
[n, S, T] = mat_ty->args<3>();
27
world.DLOG(
" (n,S,T): {}, {}, {}"
, n, S, T);
28
return
world.app(world.app(world.annex<
read
>(), {n, S, T}), {mem, matrix, idx});
29
}
30
31
}
// namespace mim::plug::matrix
mim::Def
Base class for all Defs.
Definition
def.h:223
mim::Def::world
World & world() const
Definition
def.cpp:415
mim::Def::type
const Def * type() const
Definition
def.h:248
mim::Ref
Helper class to retrieve Infer::arg if present.
Definition
def.h:86
mim::World
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition
world.h:33
autogen.h
mim::plug::matrix
The matrix Plugin
Definition
matrix.h:9
mim::plug::matrix::constMat
constMat
Definition
autogen.h:29
mim::plug::matrix::op_read
const Def * op_read(Ref mem, Ref matrix, Ref idx)
Definition
matrix.h:19
mim::plug::matrix::zero_int
const Def * zero_int(World &w, Ref n, Ref S, Ref mem, nat_t m)
mat.zero: [n: Nat, S: «n; Nat», m: Nat] -> mat.Mat (n,S,(Idx m));
Definition
matrix.h:14
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
mim::match
auto match(Ref def)
Definition
axiom.h:112
pipelinebuilder.h
world.h
include
mim
plug
matrix
matrix.h
Generated by
1.12.0