MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
buffer.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/world.h>
4
6
8
9/// The buffer type `%buffer.Buf (r, s, T)`.
10inline const Def* type_buf(const Def* r, const Def* s, const Def* T) {
11 auto& w = r->world();
12 return w.app(w.annex<Buf>(), {r, s, T});
13}
14
15/// `%buffer.alloc (r, s, T) mem` ↦ `[%mem.M 0, %buffer.Buf (r, s, T)]`.
16inline const Def* op_alloc(const Def* r, const Def* s, const Def* T, const Def* mem) {
17 auto& w = mem->world();
18 return w.app(w.app(w.annex<alloc>(), {r, s, T}), mem);
19}
20
21/// `%buffer.read (r, s, T) (mem, buf, idx)` ↦ `[%mem.M 0, T]`.
22inline const Def* op_read(const Def* r, const Def* s, const Def* T, const Def* mem, const Def* buf, const Def* idx) {
23 auto& w = mem->world();
24 return w.app(w.app(w.annex<read>(), {r, s, T}), {mem, buf, idx});
25}
26
27/// `%buffer.write (r, s, T) (mem, buf, idx, val)` ↦ `[%mem.M 0, %buffer.Buf (r, s, T)]`.
28inline const Def*
29op_write(const Def* r, const Def* s, const Def* T, const Def* mem, const Def* buf, const Def* idx, const Def* val) {
30 auto& w = mem->world();
31 return w.app(w.app(w.annex<write>(), {r, s, T}), {mem, buf, idx, val});
32}
33
34/// `%buffer.copy (r, s, T) (mem, dst, src)` ↦ `%mem.M 0` (copies the whole buffer `src` into `dst`).
35inline const Def* op_copy(const Def* r, const Def* s, const Def* T, const Def* mem, const Def* dst, const Def* src) {
36 auto& w = mem->world();
37 return w.app(w.app(w.annex<copy>(), {r, s, T}), {mem, dst, src});
38}
39
40/// `%buffer.init (r, s, T) (mem, val)` ↦ `[%mem.M 0, %buffer.Buf (r, s, T)]` (initialised with the array value `val`).
41inline const Def* op_init(const Def* r, const Def* s, const Def* T, const Def* mem, const Def* val) {
42 auto& w = mem->world();
43 return w.app(w.app(w.annex<init>(), {r, s, T}), {mem, val});
44}
45
46/// `%buffer.constant (r, s, T) (mem, val)` ↦ `[%mem.M 0, %buffer.Buf (r, s, T)]` (every element initialised to `val`).
47inline const Def* op_constant(const Def* r, const Def* s, const Def* T, const Def* mem, const Def* val) {
48 auto& w = mem->world();
49 return w.app(w.app(w.annex<constant>(), {r, s, T}), {mem, val});
50}
51
52} // namespace mim::plug::buffer
Base class for all Defs.
Definition def.h:261
The buffer Plugin
Definition buffer.h:7
const Def * type_buf(const Def *r, const Def *s, const Def *T)
The buffer type buffer.Buf (r, s, T).
Definition buffer.h:10
const Def * op_write(const Def *r, const Def *s, const Def *T, const Def *mem, const Def *buf, const Def *idx, const Def *val)
buffer.write (r, s, T) (mem, buf, idx, val) ↦ [mem.M 0, buffer.Buf (r, s, T)].
Definition buffer.h:29
const Def * op_constant(const Def *r, const Def *s, const Def *T, const Def *mem, const Def *val)
buffer.constant (r, s, T) (mem, val) ↦ [mem.M 0, buffer.Buf (r, s, T)] (every element initialised to ...
Definition buffer.h:47
const Def * op_read(const Def *r, const Def *s, const Def *T, const Def *mem, const Def *buf, const Def *idx)
buffer.read (r, s, T) (mem, buf, idx) ↦ [mem.M 0, T].
Definition buffer.h:22
const Def * op_init(const Def *r, const Def *s, const Def *T, const Def *mem, const Def *val)
buffer.init (r, s, T) (mem, val) ↦ [mem.M 0, buffer.Buf (r, s, T)] (initialised with the array value ...
Definition buffer.h:41
const Def * op_alloc(const Def *r, const Def *s, const Def *T, const Def *mem)
buffer.alloc (r, s, T) mem ↦ [mem.M 0, buffer.Buf (r, s, T)].
Definition buffer.h:16
const Def * op_copy(const Def *r, const Def *s, const Def *T, const Def *mem, const Def *dst, const Def *src)
buffer.copy (r, s, T) (mem, dst, src) ↦ mem.M 0 (copies the whole buffer src into dst).
Definition buffer.h:35
The mem Plugin
Definition mem.h:11