Skip to content

Still got an error in @code_qasm #2

Description

@ChenZhao44

I supposed that the CNOT gate should be available without including qelib1.inc. But I still got an error when using @code_qasm, even if I include qelib1.inc.

julia> using YaoCompiler

julia> qasm"""
       OPENQASM 2.0;
       include "test/compiler/qelib1.inc";
       """
cu3 (generic routine with 1 methods)

julia> @device function adder3()
           @ctrl 1 4=>X
           @ctrl 2 4=>X
           @ctrl 3 4=>X
       end
adder3 (generic routine with 1 methods)

julia> @code_qasm adder3()
ERROR: invalid control statement for QASM backend, got: YaoCompiler.Semantic.ctrl(Main.X, %3, %4)
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] codegen_ctrl(#unused#::YaoCompiler.TargetQASMTopLevel, ci::Core.CodeInfo, st::YaoCompiler.QASMCodeGenState)
   @ YaoCompiler ~/.julia/dev/YaoCompiler/src/compiler/codegen/qasm.jl:533
 [3] codegen_stmt(target::YaoCompiler.TargetQASMTopLevel, ci::Core.CodeInfo, st::YaoCompiler.QASMCodeGenState)
   @ YaoCompiler ~/.julia/dev/YaoCompiler/src/compiler/codegen/qasm.jl:333
 [4] codegen(target::YaoCompiler.TargetQASMTopLevel, ci::Core.CodeInfo)
   @ YaoCompiler ~/.julia/dev/YaoCompiler/src/compiler/codegen/qasm.jl:237
 [5] code_qasm(spec::RoutineSpec{GenericRoutine{:adder3}, Tuple{}}; optimize::Bool, gate::Bool, passes::Vector{Symbol})
   @ YaoCompiler ~/.julia/dev/YaoCompiler/src/compiler/reflection.jl:6
 [6] code_qasm(spec::RoutineSpec{GenericRoutine{:adder3}, Tuple{}})
   @ YaoCompiler ~/.julia/dev/YaoCompiler/src/compiler/reflection.jl:4
 [7] top-level scope
   @ ~/.julia/dev/YaoCompiler/src/compiler/reflection.jl:26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions