Skip to content

Commit

Permalink
Merge branch 'main' into bd-terminate-on-synchronize
Browse files Browse the repository at this point in the history
  • Loading branch information
bcdonovan committed Mar 27, 2024
2 parents cddda9c + d09f48c commit 5396bc7
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion conan/qasm/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sources:
hash: "d59248cbb4cf8840c9720462f2569907b9506323"
hash: "a9cf9fa3599b2045941d154dc91aba5a45beabb7"
requirements:
- "gmp/6.2.1"
- "mpfr/4.1.0"
Expand Down
2 changes: 1 addition & 1 deletion conan/qasm/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class QasmConan(ConanFile):
name = "qasm"
version = "0.3.0"
version = "0.3.1"
url = "https://github.com/openqasm/qe-qasm.git"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "examples": [True, False]}
Expand Down
2 changes: 1 addition & 1 deletion conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ requirements:
- pybind11/2.11.1
- clang-tools-extra/17.0.5-0@
- llvm/17.0.5-0@
- qasm/0.3.0@qss/stable
- qasm/0.3.1@qss/stable
5 changes: 2 additions & 3 deletions include/Dialect/Pulse/Utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ Waveform_CreateOp getWaveformOp(PlayOp pulsePlayOp,

Waveform_CreateOp getWaveformOp(PlayOp pulsePlayOp,
CallSequenceStack_t &callSequenceOpStack);

double getPhaseValue(ShiftPhaseOp shiftPhaseOp,
CallSequenceStack_t &callSequenceOpStack);
mlir::Value getPhaseValue(ShiftPhaseOp shiftPhaseOp,
CallSequenceStack_t &callSequenceOpStack);

/// this function goes over all the blocks of the input pulse sequence, and for
/// each block, it sorts the pulse ops within the block according to their
Expand Down
17 changes: 6 additions & 11 deletions lib/Dialect/Pulse/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,20 @@ Waveform_CreateOp getWaveformOp(PlayOp pulsePlayOp,
return waveformOp;
}

double getPhaseValue(ShiftPhaseOp shiftPhaseOp,
CallSequenceStack_t &callSequenceOpStack) {
mlir::Value getPhaseValue(ShiftPhaseOp shiftPhaseOp,
CallSequenceStack_t &callSequenceOpStack) {
auto phaseOffsetIndex = 0;
mlir::Value phaseOffset = shiftPhaseOp.getPhaseOffset();

for (auto it = callSequenceOpStack.rbegin(); it != callSequenceOpStack.rend();
++it) {
if (phaseOffset.isa<BlockArgument>()) {
phaseOffsetIndex = phaseOffset.dyn_cast<BlockArgument>().getArgNumber();
phaseOffset = it->getOperand(phaseOffsetIndex);
} else
if (auto blockArg = dyn_cast<BlockArgument>(phaseOffset))
phaseOffset = it->getOperand(blockArg.getArgNumber());
else
break;
}

auto phaseOffsetOp =
dyn_cast<mlir::arith::ConstantFloatOp>(phaseOffset.getDefiningOp());
if (!phaseOffsetOp)
phaseOffsetOp->emitError() << "Phase offset is not a ConstantFloatOp.";
return phaseOffsetOp.value().convertToDouble();
return phaseOffset;
}

void sortOpsByTimepoint(SequenceOp &sequenceOp) {
Expand Down
1 change: 1 addition & 0 deletions lib/Frontend/OpenQASM3/QUIRGenQASM3Visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,7 @@ ExpressionValueType QUIRGenQASM3Visitor::visit_(const ASTUnaryOpNode *node) {
}

switch (node->GetOpType()) {
case ASTOpTypeBitNot:
case ASTOpTypeLogicalNot: {
const auto boolType = builder.getI1Type();

Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/add-bitnot-support-7ad288e5a87b7302.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fixes failure to parse expressions with bitnot operation. Refer to
`#278 <https://github.com/openqasm/qe-compiler/issues/278>` for more
details.
8 changes: 8 additions & 0 deletions test/Frontend/OpenQASM3/bitops.qasm
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,11 @@ f = e | d;
// MLIR: [[NOT_CBIT:%.*]] = "oq3.cast"([[NOT]]) : (i1) -> !quir.cbit<1>
// MLIR: oq3.variable_assign @f : !quir.cbit<1> = [[NOT_CBIT]]
f = !f;

// MLIR: [[F:%.*]] = oq3.variable_load @f : !quir.cbit<1>
// MLIR: [[BOOL_F:%.*]] = "oq3.cast"([[F]]) : (!quir.cbit<1>) -> i1
// MLIR: [[TRUE:%.*]] = arith.constant true
// MLIR: [[NOT:%.*]] = arith.cmpi ne, [[BOOL_F]], [[TRUE]] : i1
// MLIR: [[NOT_CBIT:%.*]] = "oq3.cast"([[NOT]]) : (i1) -> !quir.cbit<1>
// MLIR: oq3.variable_assign @f : !quir.cbit<1> = [[NOT_CBIT]]
f = ~f;

0 comments on commit 5396bc7

Please sign in to comment.