-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler: Emit all-kernel_invariant objects as LLVM constants
This enables constant propagation optimisations, as verified by the included test case. This is only a first stop-gap measure, though; we should support optimisation based on kernel invariants on a more fine-grained level.
1 parent
124b257
commit bfbdba9
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# RUN: env ARTIQ_DUMP_LLVM=%t %python -m artiq.compiler.testbench.embedding +compile %s | ||
# RUN: OutputCheck %s --file-to-check=%t.ll | ||
|
||
from artiq.language.core import * | ||
from artiq.language.types import * | ||
|
||
class Class: | ||
kernel_invariants = {"foo"} | ||
|
||
def __init__(self): | ||
self.foo = True | ||
|
||
@kernel | ||
def run(self): | ||
if self.foo: | ||
print("bar") | ||
else: | ||
# Make sure all the code for this branch will be completely elided: | ||
# CHECK-NOT: baz | ||
print("baz") | ||
|
||
obj = Class() | ||
|
||
@kernel | ||
def entrypoint(): | ||
obj.run() |