@@ -4,11 +4,11 @@ xctrl_locations(ex) = Expr(:call, :($YaoLocations.CtrlLocations), ex)
4
4
"""
5
5
@gate <locs> => <gate>
6
6
7
- Syntax sugar for `apply(gate, locs)`, must be used inside `@operation `.
8
- See also [`@operation `](@ref).
7
+ Syntax sugar for `apply(gate, locs)`, must be used inside `@device `.
8
+ See also [`@device `](@ref).
9
9
10
10
!!! tips
11
- You don't have to write `@gate` in most cases inside `@operation `.
11
+ You don't have to write `@gate` in most cases inside `@device `.
12
12
But in case there is ambuigity, you can annotate the expression
13
13
with `@gate` explicitly.
14
14
"""
22
22
"""
23
23
@ctrl <ctrl_locs> <locs> => <gate>
24
24
25
- Syntax sugar for `apply(gate, locs, ctrl_locs)`, must be used inside `@operation `.
26
- See also [`@operation `](@ref).
25
+ Syntax sugar for `apply(gate, locs, ctrl_locs)`, must be used inside `@device `.
26
+ See also [`@device `](@ref).
27
27
"""
28
28
macro ctrl (ctrl_locs, ex:: Expr )
29
29
@match ex begin
@@ -53,12 +53,12 @@ macro barrier(locs)
53
53
end
54
54
55
55
"""
56
- @operation <function def>
56
+ @device <function def>
57
57
58
- Annotate a Julia function as YaoLang operation kernel.
58
+ Annotate a Julia function as YaoLang device kernel.
59
59
"""
60
- macro operation (ex)
61
- esc (operation_m (__module__, ex))
60
+ macro device (ex)
61
+ esc (device_m (__module__, ex))
62
62
end
63
63
64
64
"""
@@ -71,7 +71,7 @@ on them directly.
71
71
"""
72
72
function routine_stub end
73
73
74
- function operation_m (mod:: Module , ex)
74
+ function device_m (mod:: Module , ex)
75
75
is_function (ex) || error (" expect a function definition" )
76
76
jlfn = JLFunction (ex)
77
77
isnothing (jlfn. kwargs) || error (" kwargs is not supported" )
@@ -86,7 +86,7 @@ function codegen_routine(jlfn::JLFunction)
86
86
87
87
return quote
88
88
$ (codegen_routine_type (jlfn, typename))
89
- $ (codegen_operation (jlfn, typename))
89
+ $ (codegen_device (jlfn, typename))
90
90
$ (codegen_inference_limit_heuristics (jlfn, typename))
91
91
$ (codegen_routine_stub (jlfn, typename))
92
92
$ (codegen_binding (jlfn, typename))
@@ -112,7 +112,7 @@ function codegen_binding(def::JLFunction, typename)
112
112
end
113
113
end
114
114
115
- function codegen_operation (def:: JLFunction , typename)
115
+ function codegen_device (def:: JLFunction , typename)
116
116
self = gensym (:self )
117
117
args = name_only .(def. args)
118
118
@@ -207,17 +207,17 @@ function transpile_gate_syntax(ex)
207
207
:($ locs => $ gate) => xcall (GlobalRef (Intrinsics, :apply ), gate, xlocations (locs))
208
208
# this will appear in anonymous function definition
209
209
# TODO : disambuigity this and function contains only single line
210
- # @operation function circuit(theta, phi)
210
+ # @device function circuit(theta, phi)
211
211
# 1 => X
212
212
# end
213
213
# Expr(:block, stmt1, line::LineNumberNode, stmt2) => ex
214
- Expr (:macrocall , Symbol (" @operation " ), _... ) => error (" syntax: cannot have nested @operation " )
214
+ Expr (:macrocall , Symbol (" @device " ), _... ) => error (" syntax: cannot have nested @device " )
215
215
Expr (:macrocall , name, args... ) => begin
216
216
if is_syntax_macro (name)
217
217
return ex
218
218
else
219
219
# we force top scope locs=>gate to be treated as gate stmt inside
220
- # all @operation region including non-YaoCompiler macros to make things
220
+ # all @device region including non-YaoCompiler macros to make things
221
221
# like @inbounds etc. work
222
222
return Expr (:macrocall , name, map (transpile_gate_syntax, args)... )
223
223
end
239
239
ci, nargs = obtain_codeinfo (op)
240
240
new = NewCodeInfo (ci)
241
241
register = insert! (new. slots, 2 , Symbol (" #register#" ))
242
- operation = insert! (new. slots, 3 , Symbol (" #op#" ))
243
- unpack_operation ! (new, operation , nargs)
242
+ device = insert! (new. slots, 3 , Symbol (" #op#" ))
243
+ unpack_device ! (new, device , nargs)
244
244
for (v, stmt) in new
245
245
@switch stmt begin
246
246
@case Expr (:call , GlobalRef (& Intrinsics, name), args... )
278
278
ci, nargs = obtain_codeinfo (op)
279
279
new = NewCodeInfo (ci)
280
280
register = insert! (new. slots, 2 , Symbol (" #register#" ))
281
- operation = insert! (new. slots, 3 , Symbol (" #op#" ))
281
+ device = insert! (new. slots, 3 , Symbol (" #op#" ))
282
282
glob_locs = insert! (new. slots, 4 , Symbol (" #locs#" ))
283
- unpack_operation ! (new, operation , nargs)
283
+ unpack_device ! (new, device , nargs)
284
284
285
285
for (v, stmt) in new
286
286
_update_slot_stmt (new, v, stmt) do stmt
@@ -327,10 +327,10 @@ end
327
327
ci, nargs = obtain_codeinfo (op)
328
328
new = NewCodeInfo (ci)
329
329
register = insert! (new. slots, 2 , Symbol (" #register#" ))
330
- operation = insert! (new. slots, 3 , Symbol (" #op#" ))
330
+ device = insert! (new. slots, 3 , Symbol (" #op#" ))
331
331
glob_locs = insert! (new. slots, 4 , Symbol (" #locs#" ))
332
332
glob_ctrl = insert! (new. slots, 5 , Symbol (" #ctrl#" ))
333
- unpack_operation ! (new, operation , nargs)
333
+ unpack_device ! (new, device , nargs)
334
334
335
335
for (v, stmt) in new
336
336
_update_slot_stmt (new, v, stmt) do stmt
@@ -398,7 +398,7 @@ function obtain_codeinfo(::Type{Operation{P,Args}}) where {P,Args}
398
398
return ci, nargs
399
399
end
400
400
401
- function unpack_operation ! (new:: NewCodeInfo , op:: NewSlotNumber , nargs:: Int )
401
+ function unpack_device ! (new:: NewCodeInfo , op:: NewSlotNumber , nargs:: Int )
402
402
# %parent = op.parent
403
403
parent = push! (new, Expr (:call , GlobalRef (Base, :getfield ), op, QuoteNode (:parent )))
404
404
0 commit comments