Add a sample test that exercises short circuit control flow.

pull/1/head
Stella Laurenzo 2020-06-19 17:25:18 -07:00
parent b811db4b76
commit b3ecd57b29
2 changed files with 16 additions and 2 deletions

View File

@ -27,3 +27,11 @@ def int_add(a: int, b: int):
result = int_add(5, 6)
assert result == 11
@compile_function
def simple_control_flow(a: int, b: int):
return (a * b) and (a - b)
assert simple_control_flow(5, 6) == -1
assert simple_control_flow(-1, 0) == 0

View File

@ -10,6 +10,13 @@ __all__ = [
"CompilerBackend",
]
FRONTEND_PASSES = (
"basicpy-type-inference",
"convert-basicpy-to-std",
"canonicalize",
"convert-scf-to-std",
)
_ireec = None
_ireert = None
_cached_config = None
@ -111,8 +118,7 @@ class CompilerBackend:
backend compilation. They are separated to aid debugging.
"""
# TOOD: Have an API for this
pm.addPassPipelines("basicpy-type-inference", "convert-basicpy-to-std",
"canonicalize")
pm.addPassPipelines(*FRONTEND_PASSES)
def add_backend_passes(self, pm: mlir.passes.PassManager):
"""Adds passes for full backend compilation.