FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
daScript/src/simulate/simulate_fusion_call2.cpp at master · nolankramer/daScript · GitHub
nolankramer
/
daScript
Public
forked from
GaijinEntertainment/daScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
daScript
/
src
/
simulate
/
simulate_fusion_call2.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
270 lines (235 loc) · 9.93 KB
Breadcrumbs
daScript
/
src
/
simulate
/
simulate_fusion_call2.cpp
Copy path
File metadata and controls
270 lines (235 loc) · 9.93 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
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/sim_policy.h
"
#
include
"
daScript/ast/ast.h
"
#
include
"
daScript/simulate/simulate_visit_op.h
"
namespace
das
{
struct
SimNode_Op2Call2
: SimNode_Op2Fusion {
virtual
SimNode *
visit
(SimVisitor & vis)
override
{
V_BEGIN
();
string name = op;
name +=
"
2
"
;
name +=
getSimSourceName
(l.
type
);
name +=
getSimSourceName
(r.
type
);
vis.
op
(name.
c_str
());
if
( fnPtr ) {
vis.
arg
(fnPtr->
name
,
"
fnPtr
"
);
vis.
arg
(
Func
(), fnPtr->
mangledName
,
"
fnIndex
"
);
}
if
( cmresEval ) {
V_SUB
(cmresEval);
}
l.
visit
(vis);
r.
visit
(vis);
V_END
();
}
virtual
SimNode *
copyNode
( Context & context, NodeAllocator * code )
override
{
SimNode_Op2Call2 * that = (SimNode_Op2Call2 *)
SimNode_Op2Fusion::copyNode
(context, code);
if
( fnPtr ) {
that->
fnPtr
= context.
fnByMangledName
(fnPtr->
mangledNameHash
);
//
printf("OP2 %p to %p\n", fnPtr, that->fnPtr );
}
return
that;
}
SimFunction * fnPtr =
nullptr
;
SimNode * cmresEval =
nullptr
;
};
/*
Call
*/
#
define
EVAL_NODE
(
TYPE,CTYPE
)\
virtual
CTYPE
eval##
TYPE
( Context & context )
override
{ \
return
cast<
CTYPE
>::
to
(
compute
(context)); \
}
#
define
DAS_EVAL_NODE
\
EVAL_NODE
(Ptr,
char
*); \
EVAL_NODE
(Int,
int32_t
); \
EVAL_NODE
(UInt,
uint32_t
); \
EVAL_NODE
(Int64,
int64_t
); \
EVAL_NODE
(UInt64,
uint64_t
); \
EVAL_NODE
(Float,
float
); \
EVAL_NODE
(Double,
double
); \
EVAL_NODE
(Bool,
bool
);
//
OP(COMPUTEL,*)
#
undef
IMPLEMENT_OP2_NODE_ANYR
#
define
IMPLEMENT_OP2_NODE_ANYR
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTEL
) \
struct
SimNode_
##
OPNAME
##_Any_##
COMPUTEL
: SimNode_Op2Call2 { \
INLINE
vec4f
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
vec4f argValues[
2
]; \
argValues[
0
] = l.
subexpr
->
eval
(context); \
argValues[
1
] =
v_ldu
((
const
float
*)r.
compute
##
COMPUTEL
(context)); \
return
context.
call
(fnPtr, argValues, &debugInfo); \
} \
DAS_EVAL_ABI
virtual
vec4f
eval
( Context & context )
override
{ \
return
compute
(context); \
} \
DAS_EVAL_NODE
\
};
//
OP(*,COMPUTER)
#
undef
IMPLEMENT_OP2_NODE_ANYL
#
define
IMPLEMENT_OP2_NODE_ANYL
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTER
) \
struct
SimNode_
##
OPNAME
##_##
COMPUTER
##_Any : SimNode_Op2Call2 { \
INLINE
auto
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
vec4f argValues[
2
]; \
argValues[
0
] =
v_ldu
((
const
float
*)l.
compute
##
COMPUTER
(context)); \
argValues[
1
] = r.
subexpr
->
eval
(context); \
return
context.
call
(fnPtr, argValues, &debugInfo); \
} \
DAS_EVAL_ABI
virtual
vec4f
eval
( Context & context )
override
{ \
return
compute
(context); \
} \
DAS_EVAL_NODE
\
};
//
OP(COMPUTEL,COMPUTER)
#
undef
IMPLEMENT_OP2_NODE
#
define
IMPLEMENT_OP2_NODE
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER
) \
struct
SimNode_
##
OPNAME
##_##
COMPUTEL
##_##
COMPUTER
: SimNode_Op2Call2 { \
INLINE
auto
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
vec4f argValues[
2
]; \
argValues[
0
] =
v_ldu
((
const
float
*)l.
compute
##
COMPUTEL
(context)); \
argValues[
1
] =
v_ldu
((
const
float
*)r.
compute
##
COMPUTER
(context)); \
return
context.
call
(fnPtr, argValues, &debugInfo); \
} \
DAS_EVAL_ABI
virtual
vec4f
eval
( Context & context )
override
{ \
return
compute
(context); \
} \
DAS_EVAL_NODE
\
};
#
undef
IMPLEMENT_OP2_SETUP_NODE
#
define
IMPLEMENT_OP2_SETUP_NODE
(
result,node
) \
auto
rn = (SimNode_Op2Call2 *)result; \
auto
sn = (SimNode_CallBase *)node; \
rn->fnPtr = sn->fnPtr; \
rn->cmresEval = sn->cmresEval; \
rn->baseType = Type::none;
__forceinline SimNode *
safeArg2
( SimNode * node,
int
index ) {
auto
cb =
static_cast
<SimNode_CallBase *>(node);
return
(cb->
nArguments
==
2
) ? cb->
arguments
[index] :
nullptr
;
}
#
define
FUSION_OP2_SUBEXPR_LEFT
(
CTYPE,node
) (safeArg2(node,
0
))
#
define
FUSION_OP2_SUBEXPR_RIGHT
(
CTYPE,node
) (safeArg2(node,
1
))
#
include
"
daScript/simulate/simulate_fusion_op2_impl.h
"
IMPLEMENT_ANY_OP2
(__forceinline, Call, Ptr, StringPtr)
/*
CallWithCopyOnReturn
*/
//
OP(COMPUTEL,*)
#
undef
IMPLEMENT_OP2_NODE_ANYR
#
define
IMPLEMENT_OP2_NODE_ANYR
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTEL
) \
struct
SimNode_
##
OPNAME
##_Any_##
COMPUTEL
: SimNode_Op2Call2 { \
__forceinline
char
*
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
auto
cmres = cmresEval->
evalPtr
(context); \
vec4f argValues[
2
]; \
argValues[
0
] = l.
subexpr
->
eval
(context); \
argValues[
1
] =
v_ldu
((
const
float
*)r.
compute
##
COMPUTEL
(context)); \
return
cast<
char
*>::
to
(context.
callWithCopyOnReturn
(fnPtr, argValues, cmres, &debugInfo)); \
} \
DAS_PTR_NODE
; \
};
//
OP(*,COMPUTER)
#
undef
IMPLEMENT_OP2_NODE_ANYL
#
define
IMPLEMENT_OP2_NODE_ANYL
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTER
) \
struct
SimNode_
##
OPNAME
##_##
COMPUTER
##_Any : SimNode_Op2Call2 { \
__forceinline
char
*
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
auto
cmres = cmresEval->
evalPtr
(context); \
vec4f argValues[
2
]; \
argValues[
0
] =
v_ldu
((
const
float
*)l.
compute
##
COMPUTER
(context)); \
argValues[
1
] = r.
subexpr
->
eval
(context); \
return
cast<
char
*>::
to
(context.
callWithCopyOnReturn
(fnPtr, argValues, cmres, &debugInfo)); \
} \
DAS_PTR_NODE
; \
};
//
OP(COMPUTEL,COMPUTER)
#
undef
IMPLEMENT_OP2_NODE
#
define
IMPLEMENT_OP2_NODE
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER
) \
struct
SimNode_
##
OPNAME
##_##
COMPUTEL
##_##
COMPUTER
: SimNode_Op2Call2 { \
__forceinline
char
*
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
auto
cmres = cmresEval->
evalPtr
(context); \
vec4f argValues[
2
]; \
argValues[
0
] =
v_ldu
((
const
float
*)l.
compute
##
COMPUTEL
(context)); \
argValues[
1
] =
v_ldu
((
const
float
*)r.
compute
##
COMPUTER
(context)); \
return
cast<
char
*>::
to
(context.
callWithCopyOnReturn
(fnPtr, argValues, cmres, &debugInfo)); \
} \
DAS_PTR_NODE
; \
};
#
include
"
daScript/simulate/simulate_fusion_op2_impl.h
"
IMPLEMENT_ANY_OP2
(__forceinline, CallAndCopyOrMove, Ptr, StringPtr)
/*
FastCall
*/
//
OP(COMPUTEL,*)
#
undef
IMPLEMENT_OP2_NODE_ANYR
#
define
IMPLEMENT_OP2_NODE_ANYR
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTEL
) \
struct
SimNode_
##
OPNAME
##_Any_##
COMPUTEL
: SimNode_Op2Call2 { \
INLINE
auto
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
vec4f argValues[
2
]; \
argValues[
0
] = l.
subexpr
->
eval
(context); \
argValues[
1
] =
v_ldu
((
const
float
*)r.
compute
##
COMPUTEL
(context)); \
auto
aa = context.
abiArg
; \
context.
abiArg
= argValues; \
auto
res = fnPtr->
code
->
eval
(context); \
context.
stopFlags
&= ~(EvalFlags::stopForReturn | EvalFlags::stopForBreak | EvalFlags::stopForContinue); \
context.
abiArg
= aa; \
return
res; \
} \
DAS_EVAL_ABI
virtual
vec4f
eval
( Context & context )
override
{ \
return
compute
(context); \
} \
DAS_EVAL_NODE
\
};
//
OP(*,COMPUTER)
#
undef
IMPLEMENT_OP2_NODE_ANYL
#
define
IMPLEMENT_OP2_NODE_ANYL
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTER
) \
struct
SimNode_
##
OPNAME
##_##
COMPUTER
##_Any : SimNode_Op2Call2 { \
INLINE
auto
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
vec4f argValues[
2
]; \
argValues[
0
] =
v_ldu
((
const
float
*)l.
compute
##
COMPUTER
(context)); \
argValues[
1
] = r.
subexpr
->
eval
(context); \
auto
aa = context.
abiArg
; \
context.
abiArg
= argValues; \
auto
res = fnPtr->
code
->
eval
(context); \
context.
stopFlags
&= ~(EvalFlags::stopForReturn | EvalFlags::stopForBreak | EvalFlags::stopForContinue); \
context.
abiArg
= aa; \
return
res; \
} \
DAS_EVAL_ABI
virtual
vec4f
eval
( Context & context )
override
{ \
return
compute
(context); \
} \
DAS_EVAL_NODE
\
};
//
OP(COMPUTEL,COMPUTER)
#
undef
IMPLEMENT_OP2_NODE
#
define
IMPLEMENT_OP2_NODE
(
INLINE,OPNAME,TYPE,CTYPE,COMPUTEL,COMPUTER
) \
struct
SimNode_
##
OPNAME
##_##
COMPUTEL
##_##
COMPUTER
: SimNode_Op2Call2 { \
INLINE
auto
compute
( Context & context ) { \
DAS_PROFILE_NODE
\
vec4f argValues[
2
]; \
argValues[
0
] =
v_ldu
((
const
float
*)l.
compute
##
COMPUTEL
(context)); \
argValues[
1
] =
v_ldu
((
const
float
*)r.
compute
##
COMPUTER
(context)); \
auto
aa = context.
abiArg
; \
context.
abiArg
= argValues; \
auto
res = fnPtr->
code
->
eval
(context); \
context.
stopFlags
&= ~(EvalFlags::stopForReturn | EvalFlags::stopForBreak | EvalFlags::stopForContinue); \
context.
abiArg
= aa; \
return
res; \
} \
DAS_EVAL_ABI
virtual
vec4f
eval
( Context & context )
override
{ \
return
compute
(context); \
} \
DAS_EVAL_NODE
\
};
#
include
"
daScript/simulate/simulate_fusion_op2_impl.h
"
IMPLEMENT_ANY_OP2
(__forceinline, FastCall, Ptr, StringPtr)
void
createFusionEngine_call2
() {
(*
getFusionEngine
())[
"
Call
"
].
emplace_back
(
new
FusionPoint_Call_StringPtr
());
(*
getFusionEngine
())[
"
CallAndCopyOrMove
"
].
emplace_back
(
new
FusionPoint_CallAndCopyOrMove_StringPtr
());
(*
getFusionEngine
())[
"
FastCall
"
].
emplace_back
(
new
FusionPoint_FastCall_StringPtr
());
}
}
#
endif
Back
|
FazBrowse Home
|
New Git URL