Commit 613b5c0a authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Conform the ResultOne and ResultZero to the QIR spec



The spec requires these two are external constants of **pointer** type.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 767ed87b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -111,6 +111,6 @@ Result *__quantum__qis__mz(Qubit *q) {
  if (mode == QRT_MODE::FTQC)
    if (verbose)
      printf("[qir-qrt] Result was %d.\n", bit);
  return bit ? &ResultOne : &ResultZero;
  return bit ? ResultOne : ResultZero;
}
}
 No newline at end of file
+5 −3
Original line number Diff line number Diff line
@@ -10,9 +10,11 @@
#include "xacc_config.hpp"
#include "xacc_internal_compiler.hpp"
#include "xacc_service.hpp"

Result ResultZero = false;
Result ResultOne = true;
static const Result ResultZeroVal = false;
static const Result ResultOneVal = true;
// Define these global pointer constants
Result *ResultZero = const_cast<Result *>(&ResultZeroVal);
Result *ResultOne = const_cast<Result *>(&ResultOneVal);
// Track allocated qubits
unsigned long allocated_qbits = 0;
std::shared_ptr<xacc::AcceleratorBuffer> global_qreg;
+9 −2
Original line number Diff line number Diff line
@@ -11,8 +11,11 @@ namespace xacc {

extern "C" {
using qreg = xacc::internal_compiler::qreg;
extern Result ResultZero;
extern Result ResultOne;

// Note: The QIR spec requires ResultZero and ResultOne
// as External Global constants of *pointer* type.
extern Result *ResultZero;
extern Result *ResultOne;
extern unsigned long allocated_qbits;
extern bool initialized;
extern bool verbose;
@@ -47,6 +50,7 @@ void __quantum__qis__u3(double theta, double phi, double lambda, Qubit* q);
Result* __quantum__qis__mz(Qubit* q);
// Compare results.
bool __quantum__rt__result_equal(Result *res, Result *comp);
void __quantum__rt__result_update_reference_count(Result *, int64_t count);

// Qubit Alloc/Dealloc API
Array* __quantum__rt__qubit_allocate_array(uint64_t idx);
@@ -80,4 +84,7 @@ int8_t *__quantum__rt__array_get_element_ptr_nonvariadic(Array *array,
                                                         va_list args);
int8_t *__quantum__rt__array_get_element_ptr(Array *array, ...);
Array *__quantum__rt__array_project(Array *array, int dim, int64_t index);

// String-related API
void __quantum__rt__string_update_reference_count(void *str, int64_t count);
}
 No newline at end of file