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
6
8
10
11#define INTERNAL_PREFIX "internal_mapRed_"
12
13/// %mat.zero: [n: Nat, S: «n; Nat», m: Nat] -> %mat.Mat (n,S,(Idx m));
14inline 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
19inline 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
Base class for all Defs.
Definition def.h:223
World & world() const
Definition def.cpp:415
const Def * type() const
Definition def.h:248
Helper class to retrieve Infer::arg if present.
Definition def.h:86
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:33
The matrix Plugin
Definition matrix.h:9
const Def * op_read(Ref mem, Ref matrix, Ref idx)
Definition matrix.h:19
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
The mem Plugin
Definition mem.h:11
u64 nat_t
Definition types.h:43
auto match(Ref def)
Definition axiom.h:112