Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion grammars/Quil.g4
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ offsetDescriptor : OFFSET INT IDENTIFIER ;

classicalUnary : ( NEG | NOT | TRUE | FALSE ) addr ;
classicalBinary : logicalBinaryOp | arithmeticBinaryOp | move | exchange | convert ;
logicalBinaryOp : ( AND | OR | IOR | XOR ) addr ( addr | INT ) ;
logicalBinaryOp : ( AND | OR | IOR | XOR | SHL | SHR | ASHR ) addr ( addr | INT ) ;
arithmeticBinaryOp : ( ADD | SUB | MUL | DIV ) addr ( addr | number ) ;
move : MOVE addr ( addr | number );
exchange : EXCHANGE addr addr ;
Expand Down Expand Up @@ -184,6 +184,9 @@ FALSE : 'FALSE' ; // Deprecated
AND : 'AND' ;
IOR : 'IOR' ;
XOR : 'XOR' ;
SHL : 'SHL' ;
SHR : 'SHR' ;
ASHR : 'ASHR' ;
OR : 'OR' ; // Deprecated

ADD : 'ADD' ;
Expand Down
25 changes: 25 additions & 0 deletions specgen/spec/sec-mem.s
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ the same syntax.}
@syntax[:name "Classical Binary"]{
MOVE @alt EXCHANGE @alt CONVERT
@alt AND @alt IOR @alt XOR
@alt SHL @alt SHR @alt ASHR
@alt ADD @alt SUB @alt MUL @alt DIV
}

Expand Down Expand Up @@ -582,6 +583,30 @@ XOR a b # a := a ^ b
<bit> <bit>
<bit> <!int>

# Bitshifts
#
# - Shifting by a negative number of bits is forbidden.
#
# - Shifting by as many or more bits than are present in a word fills
# the entire word with the bit being shifted in.
#
# - SHL and SHR are "logical shifts", and fill in the shifted-out bits
# with zeros.
#
# - ASHR is an "arithmetic shift", and is the same as n := n * 2⁻ᵏ
# (rounding towards -∞); in a 2's-complement representation, this is
# the same as shifting right and filling in the shifted-out bits
# with the original value of the high bit.
SHL n b # n := n << b; shift left (logical)
SHR n b # n := n >> b; shift right (logical)
ASHR n b # n := n * 2⁻ᵏ, or n := n >>> b; arithmetic shift right
<oct> <oct>
<oct> <int>
<oct> <!int>
<int> <oct>
<int> <int>
<int> <!int>

# Arithmetic Operations
NEG a # a := -a
<int>
Expand Down
12 changes: 5 additions & 7 deletions specgen/spec/sec-structure.s
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@ i pi

@p{The following identifiers are reserved (as Quil keywords):

@clist{
ADD AND AS CONTROLLED CONVERT DAGGER DECLARE DEFCIRCUIT DEFGATE DIV EQ
EXCHANGE FORKED GE GT HALT INCLUDE IOR JUMP JUMP-UNLESS JUMP-WHEN
LABEL LE LOAD LT MATRIX MEASURE MOVE MUL NEG NOP NOT OFFSET PAULI-SUM
PERMUTATION PRAGMA RESET SHARING STORE SUB WAIT XOR EXTERN CALL
}
}
@clist{ ADD AND ASHR AS CONTROLLED CONVERT DAGGER DECLARE DEFCIRCUIT
DEFGATE DIV EQ EXCHANGE FORKED GE GT HALT INCLUDE IOR JUMP JUMP-UNLESS
JUMP-WHEN LABEL LE LOAD LT MATRIX MEASURE MOVE MUL NEG NOP NOT OFFSET
PAULI-SUM PERMUTATION PRAGMA RESET SHARING SHL SHR STORE SUB WAIT XOR
EXTERN CALL } }

@p{The following identifiers are also reserved (for standard gate
definitions):
Expand Down