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
9static constexpr auto internal_prefix = "internal_mapRed_";
10
11/// %mat.zero: [n: Nat, S: «n; Nat», m: Nat] -> %mat.Mat (n,S,(Idx m));
12inline 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
17inline 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
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:36
The matrix Plugin
Definition matrix.h:7
const Def * op_read(const Def *mem, const Def *matrix, const Def *idx)
Definition matrix.h:17
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
static constexpr auto internal_prefix
Definition matrix.h:9
The mem Plugin
Definition mem.h:11
u64 nat_t
Definition types.h:43