-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathsimulate_fusion_at_array.cpp
More file actions
440 lines (374 loc) · 18.7 KB
/
Copy pathsimulate_fusion_at_array.cpp
File metadata and controls
440 lines (374 loc) · 18.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#include "daScript/misc/platform.h"
#ifdef _MSC_VER
#pragma warning(disable:4505)
#endif
#include "daScript/simulate/simulate_fusion.h"
#if DAS_FUSION
#include "daScript/simulate/runtime_array.h"
#include "daScript/simulate/sim_policy.h"
#include "daScript/ast/ast.h"
#include "daScript/simulate/simulate_visit_op.h"
namespace das {
struct SimNode_Op2ArrayAt : SimNode_Op2Fusion {
virtual SimNode * visit(SimVisitor & vis) override {
V_BEGIN();
string name = op;
name += getSimSourceName(l.type);
name += getSimSourceName(r.type);
if (baseType != Type::none) {
vis.op(name.c_str(), getTypeBaseSize(baseType), das_to_string(baseType));
} else {
vis.op(name.c_str());
}
l.visit(vis);
r.visit(vis);
V_ARG(stride);
V_ARG(offset);
V_END();
}
uint32_t stride, offset;
};
// the 32-bit array bounds check, toggled per node family: checked op-name (ArrayAt/ArrayAtR2V)
// instantiates with it ON, the unchecked op-name (ArrayAtU/ArrayAtR2VU, emitted only where the
// index is proven in range) with it OFF - both families share one node-body macro.
#define DAS_ARRAYAT_CHECK_ON(rr) if ( rr<0 || uint64_t(rr) >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %d of %llu", rr, (unsigned long long)pl->size)
#define DAS_ARRAYAT_CHECK_OFF(rr)
// int64-indexed parallel base for fused arr[i64] access
struct SimNode_Op2ArrayAt_I64 : SimNode_Op2ArrayAt {};
// uint64-indexed parallel base for fused arr[u64] access
struct SimNode_Op2ArrayAt_U64 : SimNode_Op2ArrayAt {};
/* ArrayAtR2V SCALAR */
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int32_t rr = r.subexpr->evalInt(context); \
DAS_ARRAYAT_CHECK(rr); \
return *((CTYPE *)(pl->data + uint64_t(rr)*uint64_t(stride) + offset)); \
} \
DAS_NODE(TYPE,CTYPE); \
};
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int32_t rr = *((int32_t *)r.compute##COMPUTER(context)); \
DAS_ARRAYAT_CHECK(rr); \
return *((CTYPE *)(pl->data + uint64_t(rr)*uint64_t(stride) + offset)); \
} \
DAS_NODE(TYPE,CTYPE); \
};
#define IMPLEMENT_OP2_SET_SETUP_NODE(result,node) \
auto rn = (SimNode_Op2ArrayAt *)result; \
auto sn = (SimNode_ArrayAt *)node; \
rn->stride = sn->stride; \
rn->offset = sn->offset;
#define FUSION_OP2_SUBEXPR_LEFT(CTYPE,node) ((static_cast<SimNode_ArrayAt *>(node))->l)
#define FUSION_OP2_SUBEXPR_RIGHT(CTYPE,node) ((static_cast<SimNode_ArrayAt *>(node))->r)
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
#define DAS_ARRAYAT_CHECK DAS_ARRAYAT_CHECK_ON
IMPLEMENT_SETOP_SCALAR(ArrayAtR2V);
#undef DAS_ARRAYAT_CHECK
#define DAS_ARRAYAT_CHECK DAS_ARRAYAT_CHECK_OFF
IMPLEMENT_SETOP_SCALAR(ArrayAtR2VU);
#undef DAS_ARRAYAT_CHECK
/* ArrayAtR2V VECTOR */
#undef IMPLEMENT_OP2_SET_NODE_ANY
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt { \
DAS_EVAL_ABI virtual vec4f eval ( Context & context ) override { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int32_t rr = r.subexpr->evalInt(context); \
DAS_ARRAYAT_CHECK(rr); \
vec4f __r; \
DAS_LDU_WORKHORSE(__r, pl->data + uint64_t(rr)*uint64_t(stride) + offset, CTYPE); \
return __r; \
} \
};
#undef IMPLEMENT_OP2_SET_NODE
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt { \
DAS_EVAL_ABI virtual vec4f eval ( Context & context ) override { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int32_t rr = *((int32_t *)r.compute##COMPUTER(context)); \
DAS_ARRAYAT_CHECK(rr); \
vec4f __r; \
DAS_LDU_WORKHORSE(__r, pl->data + uint64_t(rr)*uint64_t(stride) + offset, CTYPE); \
return __r; \
} \
};
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
#define DAS_ARRAYAT_CHECK DAS_ARRAYAT_CHECK_ON
IMPLEMENT_SETOP_NUMERIC_VEC(ArrayAtR2V);
#undef DAS_ARRAYAT_CHECK
#define DAS_ARRAYAT_CHECK DAS_ARRAYAT_CHECK_OFF
IMPLEMENT_SETOP_NUMERIC_VEC(ArrayAtR2VU);
#undef DAS_ARRAYAT_CHECK
/* ArrayAt */
#undef IMPLEMENT_OP2_SET_NODE_ANY
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int32_t rr = r.subexpr->evalInt(context); \
DAS_ARRAYAT_CHECK(rr); \
return pl->data + uint64_t(rr)*uint64_t(stride) + offset; \
} \
DAS_PTR_NODE; \
};
#undef IMPLEMENT_OP2_SET_NODE
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int32_t rr = *((int32_t *)r.compute##COMPUTER(context)); \
DAS_ARRAYAT_CHECK(rr); \
return pl->data + uint64_t(rr)*uint64_t(stride) + offset; \
} \
DAS_PTR_NODE; \
};
#undef IMPLEMENT_OP2_SET_SETUP_NODE
#define IMPLEMENT_OP2_SET_SETUP_NODE(result,node) \
auto rn = (SimNode_Op2ArrayAt *)result; \
auto sn = (SimNode_ArrayAt *)node; \
rn->stride = sn->stride; \
rn->offset = sn->offset; \
rn->baseType = Type::none;
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
#define DAS_ARRAYAT_CHECK DAS_ARRAYAT_CHECK_ON
IMPLEMENT_ANY_SETOP(__forceinline, ArrayAt, Ptr, StringPtr, StringPtr);
#undef DAS_ARRAYAT_CHECK
#define DAS_ARRAYAT_CHECK DAS_ARRAYAT_CHECK_OFF
IMPLEMENT_ANY_SETOP(__forceinline, ArrayAtU, Ptr, StringPtr, StringPtr);
#undef DAS_ARRAYAT_CHECK
/* ArrayAtR2V_I64 SCALAR */
#undef IMPLEMENT_OP2_SET_NODE_ANY
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt_I64 { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int64_t rr = r.subexpr->evalInt64(context); \
if ( rr<0 || uint64_t(rr) >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %lld of %llu", (long long)rr, (unsigned long long)pl->size); \
return *((CTYPE *)(pl->data + uint64_t(rr)*uint64_t(stride) + offset)); \
} \
DAS_NODE(TYPE,CTYPE); \
};
#undef IMPLEMENT_OP2_SET_NODE
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt_I64 { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int64_t rr = *((int64_t *)r.compute##COMPUTER(context)); \
if ( rr<0 || uint64_t(rr) >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %lld of %llu", (long long)rr, (unsigned long long)pl->size); \
return *((CTYPE *)(pl->data + uint64_t(rr)*uint64_t(stride) + offset)); \
} \
DAS_NODE(TYPE,CTYPE); \
};
#undef IMPLEMENT_OP2_SET_SETUP_NODE
#define IMPLEMENT_OP2_SET_SETUP_NODE(result,node) \
auto rn = (SimNode_Op2ArrayAt_I64 *)result; \
auto sn = (SimNode_ArrayAt_I64 *)node; \
rn->stride = sn->stride; \
rn->offset = sn->offset;
#undef FUSION_OP2_SUBEXPR_LEFT
#undef FUSION_OP2_SUBEXPR_RIGHT
#define FUSION_OP2_SUBEXPR_LEFT(CTYPE,node) ((static_cast<SimNode_ArrayAt_I64 *>(node))->l)
#define FUSION_OP2_SUBEXPR_RIGHT(CTYPE,node) ((static_cast<SimNode_ArrayAt_I64 *>(node))->r)
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
IMPLEMENT_SETOP_SCALAR(ArrayAtR2V_I64);
/* ArrayAtR2V_I64 VECTOR */
#undef IMPLEMENT_OP2_SET_NODE_ANY
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt_I64 { \
DAS_EVAL_ABI virtual vec4f eval ( Context & context ) override { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int64_t rr = r.subexpr->evalInt64(context); \
if ( rr<0 || uint64_t(rr) >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %lld of %llu", (long long)rr, (unsigned long long)pl->size); \
vec4f __r; \
DAS_LDU_WORKHORSE(__r, pl->data + uint64_t(rr)*uint64_t(stride) + offset, CTYPE); \
return __r; \
} \
};
#undef IMPLEMENT_OP2_SET_NODE
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt_I64 { \
DAS_EVAL_ABI virtual vec4f eval ( Context & context ) override { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int64_t rr = *((int64_t *)r.compute##COMPUTER(context)); \
if ( rr<0 || uint64_t(rr) >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %lld of %llu", (long long)rr, (unsigned long long)pl->size); \
vec4f __r; \
DAS_LDU_WORKHORSE(__r, pl->data + uint64_t(rr)*uint64_t(stride) + offset, CTYPE); \
return __r; \
} \
};
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
IMPLEMENT_SETOP_NUMERIC_VEC(ArrayAtR2V_I64);
/* ArrayAt_I64 */
#undef IMPLEMENT_OP2_SET_NODE_ANY
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt_I64 { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int64_t rr = r.subexpr->evalInt64(context); \
if ( rr<0 || uint64_t(rr) >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %lld of %llu", (long long)rr, (unsigned long long)pl->size); \
return pl->data + uint64_t(rr)*uint64_t(stride) + offset; \
} \
DAS_PTR_NODE; \
};
#undef IMPLEMENT_OP2_SET_NODE
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt_I64 { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
int64_t rr = *((int64_t *)r.compute##COMPUTER(context)); \
if ( rr<0 || uint64_t(rr) >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %lld of %llu", (long long)rr, (unsigned long long)pl->size); \
return pl->data + uint64_t(rr)*uint64_t(stride) + offset; \
} \
DAS_PTR_NODE; \
};
#undef IMPLEMENT_OP2_SET_SETUP_NODE
#define IMPLEMENT_OP2_SET_SETUP_NODE(result,node) \
auto rn = (SimNode_Op2ArrayAt_I64 *)result; \
auto sn = (SimNode_ArrayAt_I64 *)node; \
rn->stride = sn->stride; \
rn->offset = sn->offset; \
rn->baseType = Type::none;
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
IMPLEMENT_ANY_SETOP(__forceinline, ArrayAt_I64, Ptr, StringPtr, StringPtr);
/* ArrayAtR2V_U64 SCALAR */
#undef IMPLEMENT_OP2_SET_NODE_ANY
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt_U64 { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
uint64_t rr = r.subexpr->evalUInt64(context); \
if ( rr >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %llu of %llu", (unsigned long long)rr, (unsigned long long)pl->size); \
return *((CTYPE *)(pl->data + rr*uint64_t(stride) + offset)); \
} \
DAS_NODE(TYPE,CTYPE); \
};
#undef IMPLEMENT_OP2_SET_NODE
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt_U64 { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
uint64_t rr = *((uint64_t *)r.compute##COMPUTER(context)); \
if ( rr >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %llu of %llu", (unsigned long long)rr, (unsigned long long)pl->size); \
return *((CTYPE *)(pl->data + rr*uint64_t(stride) + offset)); \
} \
DAS_NODE(TYPE,CTYPE); \
};
#undef IMPLEMENT_OP2_SET_SETUP_NODE
#define IMPLEMENT_OP2_SET_SETUP_NODE(result,node) \
auto rn = (SimNode_Op2ArrayAt_U64 *)result; \
auto sn = (SimNode_ArrayAt_U64 *)node; \
rn->stride = sn->stride; \
rn->offset = sn->offset;
#undef FUSION_OP2_SUBEXPR_LEFT
#undef FUSION_OP2_SUBEXPR_RIGHT
#define FUSION_OP2_SUBEXPR_LEFT(CTYPE,node) ((static_cast<SimNode_ArrayAt_U64 *>(node))->l)
#define FUSION_OP2_SUBEXPR_RIGHT(CTYPE,node) ((static_cast<SimNode_ArrayAt_U64 *>(node))->r)
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
IMPLEMENT_SETOP_SCALAR(ArrayAtR2V_U64);
/* ArrayAtR2V_U64 VECTOR */
#undef IMPLEMENT_OP2_SET_NODE_ANY
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt_U64 { \
DAS_EVAL_ABI virtual vec4f eval ( Context & context ) override { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
uint64_t rr = r.subexpr->evalUInt64(context); \
if ( rr >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %llu of %llu", (unsigned long long)rr, (unsigned long long)pl->size); \
vec4f __r; \
DAS_LDU_WORKHORSE(__r, pl->data + rr*uint64_t(stride) + offset, CTYPE); \
return __r; \
} \
};
#undef IMPLEMENT_OP2_SET_NODE
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt_U64 { \
DAS_EVAL_ABI virtual vec4f eval ( Context & context ) override { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
uint64_t rr = *((uint64_t *)r.compute##COMPUTER(context)); \
if ( rr >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %llu of %llu", (unsigned long long)rr, (unsigned long long)pl->size); \
vec4f __r; \
DAS_LDU_WORKHORSE(__r, pl->data + rr*uint64_t(stride) + offset, CTYPE); \
return __r; \
} \
};
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
IMPLEMENT_SETOP_NUMERIC_VEC(ArrayAtR2V_U64);
/* ArrayAt_U64 */
#undef IMPLEMENT_OP2_SET_NODE_ANY
#define IMPLEMENT_OP2_SET_NODE_ANY(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL) \
struct SimNode_##OPNAME##_##COMPUTEL##_Any : SimNode_Op2ArrayAt_U64 { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
uint64_t rr = r.subexpr->evalUInt64(context); \
if ( rr >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %llu of %llu", (unsigned long long)rr, (unsigned long long)pl->size); \
return pl->data + rr*uint64_t(stride) + offset; \
} \
DAS_PTR_NODE; \
};
#undef IMPLEMENT_OP2_SET_NODE
#define IMPLEMENT_OP2_SET_NODE(INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER) \
struct SimNode_##OPNAME##_##COMPUTEL##_##COMPUTER : SimNode_Op2ArrayAt_U64 { \
INLINE auto compute ( Context & context ) { \
DAS_PROFILE_NODE \
auto pl = (Array *) l.compute##COMPUTEL(context); \
uint64_t rr = *((uint64_t *)r.compute##COMPUTER(context)); \
if ( rr >= pl->size ) context.throw_error_at(debugInfo,"array index out of range, %llu of %llu", (unsigned long long)rr, (unsigned long long)pl->size); \
return pl->data + rr*uint64_t(stride) + offset; \
} \
DAS_PTR_NODE; \
};
#undef IMPLEMENT_OP2_SET_SETUP_NODE
#define IMPLEMENT_OP2_SET_SETUP_NODE(result,node) \
auto rn = (SimNode_Op2ArrayAt_U64 *)result; \
auto sn = (SimNode_ArrayAt_U64 *)node; \
rn->stride = sn->stride; \
rn->offset = sn->offset; \
rn->baseType = Type::none;
#include "daScript/simulate/simulate_fusion_op2_set_impl.h"
#include "daScript/simulate/simulate_fusion_op2_set_perm.h"
IMPLEMENT_ANY_SETOP(__forceinline, ArrayAt_U64, Ptr, StringPtr, StringPtr);
void createFusionEngine_at_array() {
REGISTER_SETOP_SCALAR(ArrayAtR2V);
REGISTER_SETOP_NUMERIC_VEC(ArrayAtR2V);
(*getFusionEngine())["ArrayAt"].emplace_back(new FusionPoint_Set_ArrayAt_StringPtr());
REGISTER_SETOP_SCALAR(ArrayAtR2VU);
REGISTER_SETOP_NUMERIC_VEC(ArrayAtR2VU);
(*getFusionEngine())["ArrayAtU"].emplace_back(new FusionPoint_Set_ArrayAtU_StringPtr());
REGISTER_SETOP_SCALAR(ArrayAtR2V_I64);
REGISTER_SETOP_NUMERIC_VEC(ArrayAtR2V_I64);
(*getFusionEngine())["ArrayAt_I64"].emplace_back(new FusionPoint_Set_ArrayAt_I64_StringPtr());
REGISTER_SETOP_SCALAR(ArrayAtR2V_U64);
REGISTER_SETOP_NUMERIC_VEC(ArrayAtR2V_U64);
(*getFusionEngine())["ArrayAt_U64"].emplace_back(new FusionPoint_Set_ArrayAt_U64_StringPtr());
}
}
#endif