Skip to content

Commit

Permalink
Entry point name in simple module matches repo convention (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
idavis authored May 20, 2024
1 parent f220cf9 commit 9ec966f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyqir/pyqir/_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
num_qubits: int,
num_results: int,
context: Optional[Context] = None,
entrypoint_name: str = "main",
entry_point_name: str = "main",
) -> None:
"""
Initializes a simple module.
Expand All @@ -41,7 +41,7 @@ def __init__(
:param str num_qubits: The number of statically allocated qubits.
:param int num_results: The number of statically allocated results.
:param Optional[Context] context: The LLVM context.
:param str entrypoint_name: The name of the entry point function.
:param str entry_point_name: The name of the entry point function.
"""

if context is None:
Expand All @@ -60,7 +60,7 @@ def __init__(
self._num_results = num_results

entry_point = pyqir.entry_point(
self._module, entrypoint_name, num_qubits, num_results
self._module, entry_point_name, num_qubits, num_results
)
self._builder.insert_at_end(BasicBlock(context, "entry", entry_point))

Expand Down
8 changes: 8 additions & 0 deletions pyqir/tests/test_simplemodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ def test_default_attributes_are_set() -> None:

assert mod.get_flag("dynamic_result_management") is not None
assert str(mod.get_flag("dynamic_result_management")) == "i1 false"


def test_entry_point_override_is_applied() -> None:
simple = pyqir.SimpleModule("test", 2, 5, entry_point_name="new_entry")
mod = pyqir.Module.from_bitcode(pyqir.Context(), simple.bitcode())

entry = next(filter(is_entry_point, mod.functions))
assert entry.name == "new_entry"

0 comments on commit 9ec966f

Please sign in to comment.