Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
matrix.h
Go to the documentation of this file.
1#pragma once
2
3#include <thorin/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 thorin 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 thorin::plug::matrix
Base class for all Defs.
Definition def.h:222
const Def * type() const
Yields the raw type of this Def, i.e. maybe nullptr.
Definition def.h:248
World & world() const
Definition def.cpp:421
Helper class to retrieve Infer::arg if present.
Definition def.h:87
The World represents the whole program and manages creation of Thorin nodes (Defs).
Definition world.h:35
The matrix Plugin
Definition matrix.h:9
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
const Def * op_read(Ref mem, Ref matrix, Ref idx)
Definition matrix.h:19
The mem Plugin
Definition mem.h:11
u64 nat_t
Definition types.h:44