Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
qcor
Commits
610f8f6f
Unverified
Commit
610f8f6f
authored
Sep 20, 2021
by
Mccaskey, Alex
Committed by
GitHub
Sep 20, 2021
Browse files
Merge pull request #225 from moar55/master
Paramaterized gate definition segfault fixed
parents
2c1660f4
2b358b4b
Pipeline
#165067
passed with stage
in 65 minutes and 53 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
mlir/parsers/qasm3/tests/test_declaration.cpp
View file @
610f8f6f
...
...
@@ -70,6 +70,29 @@ for i in [0:22] {
EXPECT_TRUE
(
qcor
::
execute
(
src2
,
"test"
));
}
TEST
(
qasm3VisitorTester
,
checkGate
)
{
const
std
::
string
gate_def
=
R"#(OPENQASM 3;
gate cphase(x) a, b
{
U(0, 0, x / 2) a;
CX a, b;
U(0, 0, -x / 2) b;
CX a, b;
U(0, 0, x / 2) b;
}
)#"
;
auto
mlir
=
qcor
::
mlir_compile
(
gate_def
,
"gate_def"
,
qcor
::
OutputType
::
MLIR
,
false
);
std
::
cout
<<
"gate_def MLIR:
\n
"
<<
mlir
<<
"
\n
"
;
qcor
::
execute
(
gate_def
,
"gate_def"
);
std
::
cout
<<
"LLVM:
\n
"
<<
qcor
::
mlir_compile
(
gate_def
,
"gate_def"
,
qcor
::
OutputType
::
LLVMIR
,
false
)
<<
"
\n
"
;
}
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
mlir/parsers/qasm3/visitor_handlers/quantum_types_handler.cpp
View file @
610f8f6f
...
...
@@ -152,6 +152,12 @@ antlrcpp::Any qasm3_visitor::visitQuantumGateDefinition(
// from this custom gate definition
std
::
vector
<
mlir
::
Value
>
result_qubit_vals
;
for
(
auto
arg
:
entryBlock
.
getArguments
())
{
// check if argument is a gate param
if
(
arg
.
getType
().
isF64
())
{
result_qubit_vals
.
push_back
(
arg
);
// skip use chain traversal
continue
;
}
mlir
::
Value
last_user
=
arg
;
auto
users
=
last_user
.
getUsers
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment