Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
affine.h
Go to the documentation of this file.
1#pragma once
2
3#include "thorin/world.h"
4
6
7namespace thorin::affine {
8
9/// @name %%affine.For
10///@{
11/// Returns the affine_for axiom applied with \a params.
12/// See documentation for %affine.For axiom in @ref affine.
13inline const Def* fn_for(World& w, Defs params) {
14 return w.app(w.annex<affine::For>(),
15 {w.lit_nat(Idx::bitwidth2size(32)), w.lit_nat(params.size()), w.tuple(params)});
16}
17
18/// Returns a fully applied affine_for axiom.
19/// See documentation for %affine.For axiom in @ref affine.
20// clang-format off
21inline const Def* op_for(World& w,
22 Ref begin,
23 Ref end,
24 Ref step,
25 Defs inits,
26 Ref body,
27 Ref brk) {
28 DefArray types(inits.size(), [&](size_t i) { return inits[i]->type(); });
29 return w.app(fn_for(w, types), {begin, end, step, w.tuple(inits), body, brk});
30}
31// clang-format on
32///@}
33
34} // namespace thorin::affine
Base class for all Defs.
Definition: def.h:203
Helper class to retrieve Infer::arg if present.
Definition: def.h:76
A container-like wrapper for an array.
Definition: array.h:28
size_t size() const
Definition: array.h:82
The World represents the whole program and manages creation of Thorin nodes (Defs).
Definition: world.h:34
The affine Plugin
Definition: affine.h:7
const Def * fn_for(World &w, Defs params)
Definition: affine.h:13
const Def * op_for(World &w, Ref begin, Ref end, Ref step, Defs inits, Ref body, Ref brk)
Returns a fully applied affine_for axiom.
Definition: affine.h:21