@@ -4,11 +4,11 @@ xctrl_locations(ex) = Expr(:call, :($YaoLocations.CtrlLocations), ex)
44"""
55 @gate <locs> => <gate>
66
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).
99
1010!!! 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 `.
1212 But in case there is ambuigity, you can annotate the expression
1313 with `@gate` explicitly.
1414"""
2222"""
2323 @ctrl <ctrl_locs> <locs> => <gate>
2424
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).
2727"""
2828macro ctrl (ctrl_locs, ex:: Expr )
2929 @match ex begin
@@ -53,12 +53,12 @@ macro barrier(locs)
5353end
5454
5555"""
56- @operation <function def>
56+ @device <function def>
5757
58- Annotate a Julia function as YaoLang operation kernel.
58+ Annotate a Julia function as YaoLang device kernel.
5959"""
60- macro operation (ex)
61- esc (operation_m (__module__, ex))
60+ macro device (ex)
61+ esc (device_m (__module__, ex))
6262end
6363
6464"""
@@ -71,7 +71,7 @@ on them directly.
7171"""
7272function routine_stub end
7373
74- function operation_m (mod:: Module , ex)
74+ function device_m (mod:: Module , ex)
7575 is_function (ex) || error (" expect a function definition" )
7676 jlfn = JLFunction (ex)
7777 isnothing (jlfn. kwargs) || error (" kwargs is not supported" )
@@ -86,7 +86,7 @@ function codegen_routine(jlfn::JLFunction)
8686
8787 return quote
8888 $ (codegen_routine_type (jlfn, typename))
89- $ (codegen_operation (jlfn, typename))
89+ $ (codegen_device (jlfn, typename))
9090 $ (codegen_inference_limit_heuristics (jlfn, typename))
9191 $ (codegen_routine_stub (jlfn, typename))
9292 $ (codegen_binding (jlfn, typename))
@@ -112,7 +112,7 @@ function codegen_binding(def::JLFunction, typename)
112112 end
113113end
114114
115- function codegen_operation (def:: JLFunction , typename)
115+ function codegen_device (def:: JLFunction , typename)
116116 self = gensym (:self )
117117 args = name_only .(def. args)
118118
@@ -207,17 +207,17 @@ function transpile_gate_syntax(ex)
207207 :($ locs => $ gate) => xcall (GlobalRef (Intrinsics, :apply ), gate, xlocations (locs))
208208 # this will appear in anonymous function definition
209209 # TODO : disambuigity this and function contains only single line
210- # @operation function circuit(theta, phi)
210+ # @device function circuit(theta, phi)
211211 # 1 => X
212212 # end
213213 # 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 " )
215215 Expr (:macrocall , name, args... ) => begin
216216 if is_syntax_macro (name)
217217 return ex
218218 else
219219 # 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
221221 # like @inbounds etc. work
222222 return Expr (:macrocall , name, map (transpile_gate_syntax, args)... )
223223 end
239239 ci, nargs = obtain_codeinfo (op)
240240 new = NewCodeInfo (ci)
241241 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)
244244 for (v, stmt) in new
245245 @switch stmt begin
246246 @case Expr (:call , GlobalRef (& Intrinsics, name), args... )
278278 ci, nargs = obtain_codeinfo (op)
279279 new = NewCodeInfo (ci)
280280 register = insert! (new. slots, 2 , Symbol (" #register#" ))
281- operation = insert! (new. slots, 3 , Symbol (" #op#" ))
281+ device = insert! (new. slots, 3 , Symbol (" #op#" ))
282282 glob_locs = insert! (new. slots, 4 , Symbol (" #locs#" ))
283- unpack_operation ! (new, operation , nargs)
283+ unpack_device ! (new, device , nargs)
284284
285285 for (v, stmt) in new
286286 _update_slot_stmt (new, v, stmt) do stmt
@@ -327,10 +327,10 @@ end
327327 ci, nargs = obtain_codeinfo (op)
328328 new = NewCodeInfo (ci)
329329 register = insert! (new. slots, 2 , Symbol (" #register#" ))
330- operation = insert! (new. slots, 3 , Symbol (" #op#" ))
330+ device = insert! (new. slots, 3 , Symbol (" #op#" ))
331331 glob_locs = insert! (new. slots, 4 , Symbol (" #locs#" ))
332332 glob_ctrl = insert! (new. slots, 5 , Symbol (" #ctrl#" ))
333- unpack_operation ! (new, operation , nargs)
333+ unpack_device ! (new, device , nargs)
334334
335335 for (v, stmt) in new
336336 _update_slot_stmt (new, v, stmt) do stmt
@@ -398,7 +398,7 @@ function obtain_codeinfo(::Type{Operation{P,Args}}) where {P,Args}
398398 return ci, nargs
399399end
400400
401- function unpack_operation ! (new:: NewCodeInfo , op:: NewSlotNumber , nargs:: Int )
401+ function unpack_device ! (new:: NewCodeInfo , op:: NewSlotNumber , nargs:: Int )
402402 # %parent = op.parent
403403 parent = push! (new, Expr (:call , GlobalRef (Base, :getfield ), op, QuoteNode (:parent )))
404404
0 commit comments