ae2f_docs
Loading...
Searching...
No Matches
emitx.h
Go to the documentation of this file.
1/** @file emitx.h @brief advanced emission */
2
3#ifndef lib_util_emitx
4#define lib_util_emitx
5
6#include "./wrdemit.h"
7#include <spirv/unified1/spirv.h>
8
9ae2f_inline static spvsz_t util_emitx_2(
10 x_aclspv_vec* ae2f_restrict const h_wrds,
11 const spvsz_t c_wrdcount,
12 const aclspv_wrd_t c_opcode,
13 const aclspv_wrd_t c_oprand
14 )
15{
16 ae2f_expected_but_else(util_emit_wrd(h_wrds, c_wrdcount + 1, c_oprand))
17 return 0;
18
19 get_wrd_of_vec(h_wrds)[c_wrdcount] = opcode_to_wrd(c_opcode, 1);
20
21 return c_wrdcount + 2;
22}
23
24ae2f_inline static spvsz_t util_emitx_3(
25 x_aclspv_vec* ae2f_restrict const h_wrds,
26 const spvsz_t c_wrdcount,
27 const aclspv_wrd_t c_opcode,
28 const aclspv_wrd_t c_opr_0,
29 const aclspv_wrd_t c_opr_1
30 )
31{
32 ae2f_expected_but_else(util_emit_wrd(h_wrds, c_wrdcount + 2, c_opr_1))
33 return 0;
34
35 get_wrd_of_vec(h_wrds)[c_wrdcount + 1] = c_opr_0;
36 get_wrd_of_vec(h_wrds)[c_wrdcount] = opcode_to_wrd(c_opcode, 2);
37
38 return c_wrdcount + 3;
39}
40
41ae2f_inline static spvsz_t util_emitx_4(
42 x_aclspv_vec* ae2f_restrict const h_wrds,
43 const spvsz_t c_wrdcount,
44 const aclspv_wrd_t c_opcode,
45 const aclspv_wrd_t c_opr_0,
46 const aclspv_wrd_t c_opr_1,
47 const aclspv_wrd_t c_opr_2
48 )
49{
50 ae2f_expected_but_else(util_emit_wrd(h_wrds, c_wrdcount + 3, c_opr_2))
51 return 0;
52
53 get_wrd_of_vec(h_wrds)[c_wrdcount + 2] = c_opr_1;
54 get_wrd_of_vec(h_wrds)[c_wrdcount + 1] = c_opr_0;
55 get_wrd_of_vec(h_wrds)[c_wrdcount] = opcode_to_wrd(c_opcode, 3);
56
57 return c_wrdcount + 4;
58}
59
60ae2f_inline static spvsz_t util_emitx_5(
61 x_aclspv_vec* ae2f_restrict const h_wrds,
62 const spvsz_t c_wrdcount,
63 const aclspv_wrd_t c_opcode,
64 const aclspv_wrd_t c_opr_0,
65 const aclspv_wrd_t c_opr_1,
66 const aclspv_wrd_t c_opr_2,
67 const aclspv_wrd_t c_opr_3
68 )
69{
70 ae2f_expected_but_else(util_emit_wrd(h_wrds, c_wrdcount + 4, c_opr_3))
71 return 0;
72
73 get_wrd_of_vec(h_wrds)[c_wrdcount + 3] = c_opr_2;
74 get_wrd_of_vec(h_wrds)[c_wrdcount + 2] = c_opr_1;
75 get_wrd_of_vec(h_wrds)[c_wrdcount + 1] = c_opr_0;
76 get_wrd_of_vec(h_wrds)[c_wrdcount] = opcode_to_wrd(c_opcode, 4);
77
78 return c_wrdcount + 5;
79}
80
81ae2f_inline static spvsz_t util_emitx_6(
82 x_aclspv_vec* ae2f_restrict const h_wrds,
83 const spvsz_t c_wrdcount,
84 const aclspv_wrd_t c_opcode,
85 const aclspv_wrd_t c_opr_0,
86 const aclspv_wrd_t c_opr_1,
87 const aclspv_wrd_t c_opr_2,
88 const aclspv_wrd_t c_opr_3,
89 const aclspv_wrd_t c_opr_4
90 )
91{
92 ae2f_expected_but_else(util_emit_wrd(h_wrds, c_wrdcount + 5, c_opr_4))
93 return 0;
94
95 get_wrd_of_vec(h_wrds)[c_wrdcount + 4] = c_opr_3;
96 get_wrd_of_vec(h_wrds)[c_wrdcount + 3] = c_opr_2;
97 get_wrd_of_vec(h_wrds)[c_wrdcount + 2] = c_opr_1;
98 get_wrd_of_vec(h_wrds)[c_wrdcount + 1] = c_opr_0;
99 get_wrd_of_vec(h_wrds)[c_wrdcount] = opcode_to_wrd(c_opcode, 5);
100
101 return c_wrdcount + 6;
102}
103
104ae2f_inline static spvsz_t util_emitx_8(
105 x_aclspv_vec* ae2f_restrict const h_wrds,
106 const spvsz_t c_wrdcount,
107 const aclspv_wrd_t c_opcode,
108 const aclspv_wrd_t c_opr_0,
109 const aclspv_wrd_t c_opr_1,
110 const aclspv_wrd_t c_opr_2,
111 const aclspv_wrd_t c_opr_3,
112 const aclspv_wrd_t c_opr_4,
113 const aclspv_wrd_t c_opr_5,
114 const aclspv_wrd_t c_opr_6
115 )
116{
117 ae2f_expected_but_else(util_emit_wrd(h_wrds, c_wrdcount + 7, c_opr_6))
118 return 0;
119
120 get_wrd_of_vec(h_wrds)[c_wrdcount + 6] = c_opr_5;
121 get_wrd_of_vec(h_wrds)[c_wrdcount + 5] = c_opr_4;
122 get_wrd_of_vec(h_wrds)[c_wrdcount + 4] = c_opr_3;
123 get_wrd_of_vec(h_wrds)[c_wrdcount + 3] = c_opr_2;
124 get_wrd_of_vec(h_wrds)[c_wrdcount + 2] = c_opr_1;
125 get_wrd_of_vec(h_wrds)[c_wrdcount + 1] = c_opr_0;
126 get_wrd_of_vec(h_wrds)[c_wrdcount] = opcode_to_wrd(c_opcode, 7);
127
128 return c_wrdcount + 8;
129}
130
131#define util_emitx_variable(h_wrds, c_wrdcount, c_type, c_retid, c_storage_class)
132 util_emitx_4(h_wrds, c_wrdcount, SpvOpVariable, c_type, c_retid, c_storage_class)
133
134#define util_emitx_type_pointer(h_wrds, c_wrdcount, c_retid, c_storage_class, c_elm_type_id)
135 util_emitx_4(h_wrds, c_wrdcount, SpvOpTypePointer, c_retid, c_storage_class, c_elm_type_id)
136
137#define util_emitx_type_array(h_wrds, c_wrdcount, c_retid, c_elm_type_id, c_arrcount_id)
138 util_emitx_4(h_wrds, c_wrdcount, SpvOpTypeArray, c_retid, c_elm_type_id, c_arrcount_id)
139
140#define util_emitx_spec_constant(h_wrds, c_wrdcount, c_ty, c_retid, c_val)
141 util_emitx_4(h_wrds, c_wrdcount, SpvOpSpecConstant, c_ty, c_retid, c_val)
142
143#define util_emitx_spec_constant_op(h_wrds, c_wrdcount, c_ty, c_retid, c_operator, c_operand)
144 util_emitx_5(h_wrds, c_wrdcount, SpvOpSpecConstantOp, c_ty, c_retid, c_operator, c_operand)
145
146#define util_emitx_spec_constant_op2(h_wrds, c_wrdcount, c_retid, c_ty, c_operator, c_opr_0, c_opr_1)
147 util_emitx_6(h_wrds, c_wrdcount, SpvOpSpecConstantOp, c_retid, c_ty, c_operator, c_opr_0, c_opr_1)
148
149#endif
#define ae2f_IS_SHARED
Definition Call.auto.h:12
#define ae2f_OFF
Definition Call.auto.h:3
#define ae2f_WhenCXX(a)
Appears when the current language is C.
Definition Cxx.h:44
#define ae2f_WhenC(a)
Appears when the current language is C++.
Definition Cxx.h:38
#define unless(a)
Invokes when condition is false.
Definition Keys.h:34
#define ae2f_extern
Suggests the existence of external variable or function, in naming of C. [non-mangling].
Definition Keys.h:25
#define ae2f_NIL
Definition Nil.h:13
#define ACLSPV_ABI_DECL
Declaration as ABI.
Definition abi.h:23
#define STATE_VAL
#define FNINFO
#define cpysz
#define cpypad
#define ae2f_assume(a)
tells the compiler that value if a is false, below this keyword is not expected to be reached.
Definition cc.h:228
#define ae2f_unexpected_but_if(a)
Definition cc.h:192
#define ae2f_expected_but_else(a)
Definition cc.h:201
#define ae2f_ccconst
Keyword as [[const]] on C23..
Definition cc.h:66
#define ae2f_noexcept
marker that this function does not throw something.
Definition cc.h:133
#define ae2f_restrict
Keyword as restrict on C99.
Definition cc.h:81
#define ae2f_expected_not(a)
expectes a as false.
Definition cc.h:185
#define ae2f_unreachable()
tells the compiler that below this keyword is not expected to be reached.
Definition cc.h:213
#define ae2f_inline
inline
Definition cc.h:149
#define ae2f_expected(a)
expectes a as true.
Definition cc.h:184
#define CTX
#define EMIT_POS
#define util_emitx_type_pointer(h_wrds, c_wrdcount, c_retid, c_storage_class, c_elm_type_id)
Definition emitx.h:134
#define ret_count
#define get_buf_from_scale(h_alloc, c_scale)
Definition scale.h:34
#define aclspv_opcode_t
integer as operation code
Definition spvty.h:27
aclspv_wrd_t aclspv_wrdcount_t
the integer type represents the number of word.
Definition spvty.h:61
#define aclspv_wrd_t
integer as word
Definition spvty.h:16
x_aclspv_vec m_scale_vars
Definition ctx.h:62
aclspv_wrdcount_t m_num_type_uniques
Definition ctx.h:44
x_aclspv_vec m_cursors
cache for cursors for parsing one function for its use see util/cursor.h
Definition ctx.h:77
x_aclspv_vec m_constant_cache
Definition ctx.h:65
aclspv_id_t m_id
id
Definition ctx.h:50
x_aclspv_vec m_ret
word count for m_ret
Definition ctx.h:56
aclspv_wrd_t m_is_logical
when on, ignores m_is_buffer_64.
Definition ctx.h:23
aclspv_wrdcount_t m_num_cursor
number of m_cursors. for its use see util/cursor.h
Definition ctx.h:41
x_aclspv_vec m_type_uniques
cache for complex types which needs to be stored somewhere for its use see util/type_unique....
Definition ctx.h:86
util_bind_unified m_unified
Definition bind.h:20
#define emit_opcode(h_wrds, c_wrdcount, c_opcode, c_num_opprm_opt)
try emit opcode with num_opprm
Definition wrdemit.h:75
#define get_wrd_of_vec(vec)
get word buffer from vector
Definition wrdemit.h:38
aclspv_wrdcount_t spvsz_t
Definition wrdemit.h:18
#define count_to_sz(c_count)
word count to byte size
Definition wrdemit.h:32
#define set_oprnd_count_for_opcode(cr_wrd, c_num_opprm)
Definition wrdemit.h:78
#define opcode_to_wrd(c_opcode, c_num_opprm)
Definition wrdemit.h:69