qir-alliance / qcor

C++ compiler for heterogeneous quantum-classical computing built on Clang and XACC
http://docs.aide-qc.org
MIT License
97 stars 39 forks source link

Indexing with classical register #251

Closed vmartinv closed 2 years ago

vmartinv commented 2 years ago

I'm trying to write code in QASM 3 and this is the only compiler I found. I'm having problems indexing an array of classical bits using a variable as shown below:

OPENQASM 3;

int[32] pos=2;
bit c[8]="01010101";
print(c[pos]);

gives me:

bash-5.1$ qcor -qpu aer -shots 1  test.qasm -o test

[qcor-mlir] Reported Error: see current operation: %2 = "std.index_cast"(%0) : (memref<i32>) -> index
error: 'std.index_cast' op requires the same shape for all operands and results
[qcor-mlir-tool] MLIR-to-LLVM_MLIR lowering failed.
[qcor-exec] fatal error.

Do I need to do some extra casting to do this?