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
9/// %mat.zero: [n: Nat, S: «n; Nat», m: Nat] -> %mat.Mat (n,S,(Idx m));
10inline const Def* zero_int(World& w, const Def* n, const Def* S, const Def* mem, nat_t m) {
11 // TODO: use mim definition by name
12 return w.app(w.annex<matrix::constMat>(), {n, S, w.type_idx(m), mem, w.lit_idx(m, 0)});
13}
14
15inline const Def* op_read(const Def* mem, const Def* matrix, const Def* idx) {
16 auto& world = matrix->world();
17 auto mat_ty = Axm::isa<Mat>(matrix->type());
18 if (!mat_ty) return matrix;
19 assert(mat_ty);
20 world.DLOG("matrix read: {}[{}]", matrix, idx);
21 world.DLOG(" matrix type: {}", matrix->type());
22 auto [n, S, T] = mat_ty->args<3>();
23 world.DLOG(" (n,S,T): {}, {}, {}", n, S, T);
24 return world.app(world.app(world.annex<read>(), {n, S, T}), {mem, matrix, idx});
25}
26
27} // namespace mim::plug::matrix
static auto isa(const Def *def)
Definition axm.h:107
Base class for all Defs.
Definition def.h:251
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:31
The matrix Plugin
Definition matrix.h:7
const Def * op_read(const Def *mem, const Def *matrix, const Def *idx)
Definition matrix.h:15
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:10
The mem Plugin
Definition mem.h:11
u64 nat_t
Definition types.h:44