ae2f_docs
Loading...
Searching...
No Matches
asm.h
Go to the documentation of this file.
1/** @file asm.h @brief finalise the emission */
2
3#include <spirv/unified1/spirv.h>
4#include <aclspv.h>
5
6#include <util/iddef.h>
7#include <util/wrdemit.h>
8
9ae2f_inline static ae2f_noexcept e_aclspv_compile_t impl_asm(
10 const h_util_ctx_t h_ctx
11 )
12{
13 h_ctx->m_num_ret
14 = h_ctx->m_count.m_capability
15 + h_ctx->m_count.m_ext
16 + h_ctx->m_count.m_memmodel
17 + h_ctx->m_count.m_entp
18 + h_ctx->m_count.m_execmode
19 + h_ctx->m_count.m_name
20 + h_ctx->m_count.m_decorate
21 + h_ctx->m_count.m_types
22 + h_ctx->m_count.m_vars
23 + h_ctx->m_count.m_fndef
24 + 5;
25
26 _aclspv_grow_vec(malloc, _free, h_ctx->m_ret
27 , (size_t)count_to_sz(h_ctx->m_num_ret)
28 );
29
30 unless(h_ctx->m_ret.m_p) return ACLSPV_COMPILE_ALLOC_FAILED;
31
32 get_wrd_of_vec(&h_ctx->m_ret)[0] = SpvMagicNumber;
33 get_wrd_of_vec(&h_ctx->m_ret)[1] = SpvVersion & 0x10000;
34 get_wrd_of_vec(&h_ctx->m_ret)[2] = 0;
35 get_wrd_of_vec(&h_ctx->m_ret)[3] = h_ctx->m_num_ret;
36 get_wrd_of_vec(&h_ctx->m_ret)[4] = 0;
37
38#define retbuf ((aclspv_wrd_t* ae2f_restrict)(h_ctx->m_ret.m_p))
39
40#define cpypad retbuf + 5
41#define cpysz count_to_sz(h_ctx->m_count.m_capability)
42
43 if((cpysz) != 0) memcpy(cpypad, h_ctx->m_section.m_capability.m_p, (size_t)cpysz);
44
45#undef cpypad
46#undef cpysz
47#define cpypad retbuf + 5
48 + (h_ctx->m_count.m_capability)
49#define cpysz count_to_sz(h_ctx->m_count.m_ext)
50 if((cpysz) != 0) memcpy(cpypad, h_ctx->m_section.m_ext.m_p, (size_t)cpysz);
51
52#undef cpypad
53#undef cpysz
54#define cpypad retbuf + 5
55 + (h_ctx->m_count.m_capability)
56 + (h_ctx->m_count.m_ext)
57#define cpysz count_to_sz(h_ctx->m_count.m_memmodel)
58 if((cpysz) != 0) memcpy(cpypad, h_ctx->m_section.m_memmodel.m_p, (size_t)cpysz);
59
60
61#undef cpypad
62#undef cpysz
63#define cpypad retbuf + 5
64 + (h_ctx->m_count.m_capability)
65 + (h_ctx->m_count.m_ext)
66 + (h_ctx->m_count.m_memmodel)
67#define cpysz count_to_sz(h_ctx->m_count.m_entp)
68 if((cpysz) != 0) memcpy(cpypad, h_ctx->m_section.m_entp.m_p, (size_t)cpysz);
69
70#undef cpypad
71#undef cpysz
72#define cpypad retbuf + 5
73 + (h_ctx->m_count.m_capability)
74 + (h_ctx->m_count.m_ext)
75 + (h_ctx->m_count.m_memmodel)
76 + (h_ctx->m_count.m_entp)
77#define cpysz count_to_sz(h_ctx->m_count.m_execmode)
78 if((cpysz) != 0) memcpy(cpypad, (h_ctx)->m_section.m_execmode.m_p, (size_t)cpysz);
79
80#undef cpypad
81#undef cpysz
82#define cpypad retbuf + 5
83 + (h_ctx->m_count.m_capability)
84 + (h_ctx->m_count.m_ext)
85 + (h_ctx->m_count.m_memmodel)
86 + (h_ctx->m_count.m_entp)
87 + (h_ctx->m_count.m_execmode)
88#define cpysz count_to_sz(h_ctx->m_count.m_name)
89 if((cpysz) != 0) memcpy(cpypad, (h_ctx)->m_section.m_name.m_p, (size_t)cpysz);
90
91
92#undef cpypad
93#undef cpysz
94#define cpypad retbuf + 5
95 + (h_ctx->m_count.m_capability)
96 + (h_ctx->m_count.m_ext)
97 + (h_ctx->m_count.m_memmodel)
98 + (h_ctx->m_count.m_entp)
99 + (h_ctx->m_count.m_execmode)
100 + (h_ctx->m_count.m_name)
101#define cpysz count_to_sz(h_ctx->m_count.m_decorate)
102 if((cpysz) != 0) memcpy(cpypad, (h_ctx)->m_section.m_decorate.m_p, (size_t)cpysz);
103
104#undef cpypad
105#undef cpysz
106#define cpypad retbuf + 5
107 + (h_ctx->m_count.m_capability)
108 + (h_ctx->m_count.m_ext)
109 + (h_ctx->m_count.m_memmodel)
110 + (h_ctx->m_count.m_entp)
111 + (h_ctx->m_count.m_execmode)
112 + (h_ctx->m_count.m_name)
113 + (h_ctx->m_count.m_decorate)
114#define cpysz count_to_sz(h_ctx->m_count.m_types)
115 if((cpysz) != 0) memcpy(cpypad, (h_ctx)->m_section.m_types.m_p, (size_t)cpysz);
116
117
118
119#undef cpypad
120#undef cpysz
121#define cpypad retbuf + 5
122 + (h_ctx->m_count.m_capability)
123 + (h_ctx->m_count.m_ext)
124 + (h_ctx->m_count.m_memmodel)
125 + (h_ctx->m_count.m_entp)
126 + (h_ctx->m_count.m_execmode)
127 + (h_ctx->m_count.m_name)
128 + (h_ctx->m_count.m_decorate)
129 + (h_ctx->m_count.m_types)
130#define cpysz count_to_sz(h_ctx->m_count.m_vars)
131 if((cpysz) != 0) memcpy(cpypad, (h_ctx)->m_section.m_vars.m_p, (size_t)cpysz);
132
133#undef cpypad
134#undef cpysz
135#define cpypad retbuf + 5
136 + (h_ctx->m_count.m_capability)
137 + (h_ctx->m_count.m_ext)
138 + (h_ctx->m_count.m_memmodel)
139 + (h_ctx->m_count.m_entp)
140 + (h_ctx->m_count.m_execmode)
141 + (h_ctx->m_count.m_name)
142 + (h_ctx->m_count.m_decorate)
143 + (h_ctx->m_count.m_types)
144 + (h_ctx->m_count.m_vars)
145#define cpysz count_to_sz(h_ctx->m_count.m_fndef)
146 if((cpysz) != 0) memcpy(cpypad, (h_ctx)->m_section.m_fndef.m_p, (size_t)cpysz);
147
148#undef retbuf
149
150 assert(h_ctx->m_ret.m_p);
151
152 return ACLSPV_COMPILE_OK;
153}
#define ae2f_IS_SHARED
Definition Call.auto.h:12
#define ae2f_OFF
Definition Call.auto.h:3
#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_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 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
aclspv_id_t m_id
id
Definition ctx.h:50
aclspv_wrdcount_t m_num_cursor
number of m_cursors. for its use see util/cursor.h
Definition ctx.h:41
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
#define count_to_sz(c_count)
word count to byte size
Definition wrdemit.h:32