-
Notifications
You must be signed in to change notification settings - Fork 16
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
v3 MVP #165
Conversation
…fetched via conan. This is needed for libraries using libqasm.
All these changes to V1 cannot finally go into develop. Otherwise we would be breaking the V1 parsing.
All these changes to V1 cannot finally go into develop. Otherwise we would be breaking the V1 parsing. test/v1x/parsing.cpp: - Changed vector of API levels used in semantic checks to use only '3.0'. - Changed the names of the registered instructions 'x90' and 'cnot' to 'X90' and 'CNOT', so that they are resolved correctly.
Updated v3 lexer and parser grammar files. Updated BuildTreeGenAstVisitor files so that the library compiles, although the new methods are yet unimplemented.
- changed 'analyze' function's ''file_parser' parameter name to 'parser', because the parser can actually invoke the file or the string parser. - minor fixes suggested by Clang-tidy.
At the moment, I'm just copy-pasting from the v1 code, and simplifying the contents by removing everything I think I won't need.
…s}.tree. At the moment, I'm just copy-pasting from the v1 code, and simplifying the contents by removing everything I think I won't need.
This reverts commit 96a9042.
- Use of nested namespaces. - Change some comments so that they have meaningful phrases per line.
- We have something that compiles. - After having added all the (I think needed) .tree and .hpp files. - I have tried not to reuse anything from v1x. For example, v3x/cqasm-values.tree defines cqasm::v3x::values/const_int, which is already defined in cqasm::v1x::values, with exactly the same logic. - My main concern is with the 'array' type in v3x/cqasm-types.tree. I don't think tree-gen allows to define something like a templated class, this is, an 'array<T>'. We would need this in order to consider 'array' as a type, so that we could have, for example, arrays of arrays of int (array<array<int>>). So, with tree-gen, if I'm not mistaken, we will be forced to define a specific type for every array type. E.g. qubit_array. Matrices should be a different type as well, as in v1x.
For the MVP, the only allowed types are qubit, bit, qubit_array, and bit_array.
- Moved read_file and write_file functions to utils.{hpp,cpp}. - Moved register_tests function to test-register.hpp. - Added cqasm::test namespace. - test/v1x/parsing.cpp: fixed ParsingTest::TestBody method. It was using 'api_version' 3.0 instead of 1.0, 1.1, and 1.2. It was using 'X90' and 'CNOT' instead of 'x90' and 'cnot'.
…_SOURCES instead of CQASM_V1X_SOURCES.
Reorganized test folder to accommodate future v3x tests. - Moved read_file and write_file functions to utils.{hpp,cpp}. - Moved register_tests function to test-register.hpp. - Added cqasm::test namespace. - test/v1x/parsing.cpp: fixed ParsingTest::TestBody method. It was using 'api_version' 3.0 instead of 1.0, 1.1, and 1.2. It was using 'X90' and 'CNOT' instead of 'x90' and 'cnot'.
- Use of nested namespaces. - Change some comments so that they have meaningful phrases per line.
- Changed v3 grammar: qubit and bit array sizes can only be of type integer at the moment. - Changed tree-gen classes: - A variable has optionally a size (when it is of array type). - A measurement_instruction is not a subtype of an instruction (gate). - All v3 code refers now to v3 files and classes. - Added cqasm-analyzer, although the analysis is unimplemented. - All tests are passing
…ree. Changes to the grammar: - Changed measure_instruction into measure_statement. - A version number doesn't need now a minor number. Added src/v3x/cqasm-types.cpp and src/v3x/cqasm-values.cpp. Added test/v3x/parsing.cpp and registered v3x tests.
…n't use multiple declarations per line.
…t array, or index reference to one or many qubits), and one output operand (bit, bit array, or index reference to one or many bits).
… remain case-sensitive. The code calling them (v1x or v3x) can be case-insensitive by converting to lowercase before adding and resolving an overload. Fixed some object slicing issues pointed out by clang-tidy (mainly assignments from One<T> to Maybe<T>). Renamed utils::{lowercase,case_insensitive_equals} to utils::{to_lowercase,equal_case_insensitive}.
Hi @jvansomeren, Thanks for the comment! The implementation of v3 in Of course, I don't pretend either to break OpenQL support for v1.2. This PR has changed some v1 files, but the changes are minor: comments, clang-tidy suggestions, use of nested namespaces... The only "important" change is to have moded the Best regards, |
- we have removed the first_output_operand_index from an ast::Instruction, and - we have changed the error message for when the number of input indices and the number of output indices differ.
…ruction. This flag is false by default, and set to true for a measure instruction. Reimplemented check_input_indices_equals_output_indices as check_same_size_input_output_indices, without using std::span. Removed first_output_operand_index from a semantic AST instruction.
It seems a header in a Python library is defining things like STRING, and this macro expansion is hitting some enums in a different header in the ANTLR runtime library. Weird. This fix avoids v10 code to include v3x/cqasm.hpp.
Missing 'conan profile detect'.
- We have removed output_operands from an instruction.
Implemented operator== and operator<=> for Version. Changed equal, less_than, more_than, less_than_or_equal, and more_than_or_equal to ==, <, >, <=, and >=. Renamed Overload.{tag_,param_types_} to tag and param_types.
Made Analyzer::api_version public and removed accessor function.
looks good to me, please ping me know when/if I need to approve :) |
…it_indices_have_same_size. Used 'i' (for 'indices') instead of 'f' (for 'force' -to be equal, an old name for this flag-) when serializing request_qubit_and_bit_indices_have_same_size.
python/CMakeLists.txt: - Changed CMake minimum required version to 3.12. - Changed C++ standard to C++20 (like for libqasm). - Removed code that checked if CMake version was smaller than 3.12. - Deleted python/compat folder, which was only used when CMake version was smaller than 3.12. - Added v3x Python generated files to installation. Moved include/cqasm-py.hpp to include/v1x. Moved src/cqasm-py.cpp to src/v1x, and refactored code. Added include/v3x/cqasm-py.hpp. Added src/v3x/cqasm-py.cpp.
Let's merge this and finalize in another PR (it's already too large haha) |
Oh, no, I'm still fighting with that, I have just started:
|
And then the toy v1 parser became a v3 MVP.
Implemented the
libqasm
side of the v3 MVP.Most of the code has been reused from the v1 parser: tree files, include files, and source files.
Main differences lie on:
Analyzer::analyze
performs the analysis through anAnalyzeTreeGenAstVisitor::visitProgram
call.q
andb
registers anymore, and neither hasQubitRefs
andBitRefs
.Instead, we have
Qubit
,QubitArray
,Bit
, andBitArray
types, andIndexRefs
, which will point to a variable of one of the mentioned types.The mapping of these qubit/bit variables to a physical qubit/bit register, and the semantic checks related to that mapping are not implemented at the
libqasm
level, at least not yet.measure
instruction, with the syntax<bit references> = measure <qubit references>
is implemented.Changes to v1x files
fmt
formatters for types and values classes, and reimplementedoperator<<
usingfmt::format
.noexcept
,[[nodiscard]]
to method signatures.auto
toconst auto &
for many loop constructs.cqasm-analyzer
to have only one constructor, which receives aVersion
.semantic.1.x.golden.txt
files becauseapi_version
is now dumped at the top of theProgram
members, right beforeversion
.less_than
,more_than
...).api_version
to the beginning of theprogram
structure incqasm-semantic.tree
.res/v1x/parsing
folders by changing dashes to underscores, becausegtest
doesn't like test names with dashes.cqasm::v1x::analyzer
).Changes to v3x files
res/v3x/parsing
test files. Many of these files were moved fromres/v1x/toy-v1x-parsing
.test/parsing.cpp
.Changes to common v1x/v3x files
equal
,less_than
,more_than
,less_than_or_equal
, andmore_than_or_equal
toVersion
.test/cqasm-utils.cpp
to testto_lowercase
andequal_case_insensitive
functions.Overload
templates frominclude/v1x/cqasm-resolver
toinclude/cqasm-overload
.read_file
andwrite_file
functions totest/utils.cpp
.register_tests
code, used both bytest/v1x/parsing.cpp
andtest/v3x/parsing.cpp
totest/test-register.hpp
.Changes to the build system
range-v3
dependencies.src/CMakeLists.txt
to fetch contentfmt
andrange-v3
in case the packages were not found.src/CMakeLists.txt
to generate tree-gen classes for v3 (AST, types, values, and semantic AST).