Skip to content

Broadcasting and slicing updates #2326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c190235
broadcasting
orpuente-MS Apr 21, 2025
12f8fae
fix parsing and lowering of indexed idents
orpuente-MS Apr 22, 2025
8a04ec0
update indexed_ident tests
orpuente-MS Apr 22, 2025
14293f5
broadcasting edge case
orpuente-MS Apr 22, 2025
a80a5a6
update unit tests
orpuente-MS Apr 22, 2025
4a8f3ff
remove empty lines
orpuente-MS Apr 22, 2025
c2596b4
unignore slicing tests
orpuente-MS Apr 22, 2025
d3ca004
box IdentOrIndexedIdent
orpuente-MS Apr 22, 2025
f549de4
allow broadcast with mixed registers and qubits
orpuente-MS Apr 22, 2025
4c46ea9
array indexing (work in progress)
orpuente-MS Apr 24, 2025
5c8fa54
zero range step error
orpuente-MS Apr 24, 2025
32ba718
Merge branch 'main' into oscarpuente/qasm-follow-up
orpuente-MS Apr 24, 2025
5f92556
arrays support
orpuente-MS Apr 30, 2025
464b977
Merge branch 'main' into oscarpuente/qasm-follow-up
orpuente-MS Apr 30, 2025
f6b7a77
update unit tests after merge
orpuente-MS Apr 30, 2025
267acbd
add indexed assign tests
orpuente-MS Apr 30, 2025
2395efd
multidimensional indexed assign
orpuente-MS Apr 30, 2025
81f8cbd
use `w/=` for first index of multidimensional assignment
orpuente-MS Apr 30, 2025
a86da20
add array const evaluation tests
orpuente-MS Apr 30, 2025
5a1dd55
add bit array support
orpuente-MS Apr 30, 2025
5f12767
fix bug with array of size 1
orpuente-MS Apr 30, 2025
2373969
disallow const arrays
orpuente-MS May 1, 2025
0055ef4
unignore some tests
orpuente-MS May 1, 2025
5b1eb27
array type checking
orpuente-MS May 1, 2025
5434bab
clean up indexed_type tests
orpuente-MS May 1, 2025
5993ac9
remove const field from array types
orpuente-MS May 1, 2025
f19b00e
unignore index_set_in_non_alias_stmt_fails
orpuente-MS May 2, 2025
ac966f1
remove old comment
orpuente-MS May 2, 2025
c611c1e
disallow zero size array access
orpuente-MS May 2, 2025
e546a2d
disallow array decls in non-global scopes
orpuente-MS May 2, 2025
91a5c9e
address PR feedback in `semantic/types.rs`
orpuente-MS May 2, 2025
583cb47
remove comented out code
orpuente-MS May 2, 2025
b447d38
add zero size array and subarrays tests
orpuente-MS May 2, 2025
8ae812f
lift 3-dimensions array restriction in crate::types.rs
orpuente-MS May 2, 2025
07d8f40
fix typo
orpuente-MS May 2, 2025
93b660e
improve array unit tests
orpuente-MS May 2, 2025
f3f9f63
add test case for broadcast of double controlled gate
orpuente-MS May 5, 2025
2cada40
rename `check_lit_array_type` to `check_lit_array_size`
orpuente-MS May 6, 2025
856c460
Update compiler/qsc_qasm/src/semantic/lowerer.rs
orpuente-MS May 6, 2025
ce63b72
Update compiler/qsc_qasm/src/semantic/types.rs
orpuente-MS May 6, 2025
88f4905
cargo fmt types.rs
orpuente-MS May 6, 2025
17ff72f
cleanup index_into_qubit_register impl
orpuente-MS May 6, 2025
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
42 changes: 42 additions & 0 deletions compiler/qsc_qasm/src/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,28 @@ pub(crate) fn build_indexed_assignment_statement<S: AsRef<str>>(
}
}

pub(crate) fn build_ternary_update_expr(
lhs: ast::Expr,
index: ast::Expr,
rhs: ast::Expr,
) -> ast::Expr {
let span = Span {
lo: lhs.span.lo,
hi: rhs.span.hi,
};

ast::Expr {
id: Default::default(),
span,
kind: Box::new(ast::ExprKind::TernOp(
ast::TernOp::Update,
Box::new(lhs),
Box::new(index),
Box::new(rhs),
)),
}
}

pub(crate) fn build_assignment_statement<S: AsRef<str>>(
name_span: Span,
name: S,
Expand Down Expand Up @@ -1328,6 +1350,14 @@ pub(crate) fn map_qsharp_type_to_ast_ty(output_ty: &crate::types::Type) -> Ty {
crate::types::Type::IntArray(dims, _) => build_array_type_name("Int", dims),
crate::types::Type::DoubleArray(dims) => build_array_type_name("Double", dims),
crate::types::Type::BoolArray(dims, _) => build_array_type_name("Bool", dims),
crate::types::Type::ComplexArray(dims, _) => {
let ty = build_complex_ty_ident();
wrap_array_ty_by_dims(dims, ty)
}
crate::types::Type::AngleArray(dims, _) => {
let ty = build_angle_ty_ident();
wrap_array_ty_by_dims(dims, ty)
}
crate::types::Type::Callable(_, _, _) => todo!(),
crate::types::Type::Range => build_path_ident_ty("Range"),
crate::types::Type::Tuple(tys) => {
Expand Down Expand Up @@ -1360,6 +1390,18 @@ fn wrap_array_ty_by_dims(dims: &ArrayDimensions, ty: Ty) -> Ty {
ArrayDimensions::One(..) => wrap_ty_in_array(ty),
ArrayDimensions::Two(..) => wrap_ty_in_array(wrap_ty_in_array(ty)),
ArrayDimensions::Three(..) => wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(ty))),
ArrayDimensions::Four(..) => {
wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(ty))))
}
ArrayDimensions::Five(..) => wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(
wrap_ty_in_array(wrap_ty_in_array(ty)),
))),
ArrayDimensions::Six(..) => wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(
wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(ty))),
))),
ArrayDimensions::Seven(..) => wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(
wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(wrap_ty_in_array(ty)))),
))),
}
}

Expand Down
Loading