Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0755aa38ffe2
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e9afe5a93bd3
Choose a head ref
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Dec 18, 2015

  1. transforms.inferencer: fix unsupported decorator diagnostic when embe…

    …dding.
    
    decorator.loc points to the quoted object with a synthesized location,
    and it's not really worth refactoring when we can just point at the @.
    whitequark committed Dec 18, 2015
    Copy the full SHA
    7b3ace2 View commit details
  2. compiler.prelude: add @portable as an alias for @kernel.

    whitequark committed Dec 18, 2015
    Copy the full SHA
    baa986a View commit details
  3. Copy the full SHA
    0395efd View commit details
  4. runtime: include __powidf2.

    whitequark committed Dec 18, 2015
    Copy the full SHA
    e9afe5a View commit details
5 changes: 4 additions & 1 deletion artiq/compiler/ir.py
Original file line number Diff line number Diff line change
@@ -500,7 +500,10 @@ def __str__(self):
# Python-specific SSA IR classes

class TEnvironment(types.TMono):
def __init__(self, vars, outer=None):
def __init__(self, name, vars, outer=None):
assert isinstance(name, str)
self.env_name = name # for readable type names in LLVM IR

if outer is not None:
assert isinstance(outer, TEnvironment)
env = OrderedDict({"$outer": outer})
1 change: 1 addition & 0 deletions artiq/compiler/prelude.py
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ def globals():

# ARTIQ decorators
"kernel": builtins.fn_kernel(),
"portable": builtins.fn_kernel(),

# ARTIQ context managers
"parallel": builtins.obj_parallel(),
19 changes: 12 additions & 7 deletions artiq/compiler/transforms/artiq_ir_generator.py
Original file line number Diff line number Diff line change
@@ -181,11 +181,12 @@ def visit_ModuleT(self, node):
entry = self.add_block("entry")
old_block, self.current_block = self.current_block, entry

env = self.append(ir.Alloc([], ir.TEnvironment(node.typing_env), name="env"))
env_type = ir.TEnvironment(name=func.name, vars=node.typing_env)
env = self.append(ir.Alloc([], env_type, name="env"))
old_env, self.current_env = self.current_env, env

priv_env = self.append(ir.Alloc([], ir.TEnvironment({ "$return": typ.ret }),
name="privenv"))
priv_env_type = ir.TEnvironment(name=func.name + ".priv", vars={ "$return": typ.ret })
priv_env = self.append(ir.Alloc([], priv_env_type, name="privenv"))
old_priv_env, self.current_private_env = self.current_private_env, priv_env

self.generic_visit(node)
@@ -264,13 +265,15 @@ def visit_function(self, node, is_lambda, is_internal):
{var: node.typing_env[var]
for var in node.typing_env
if var not in node.globals_in_scope}
env_type = ir.TEnvironment(env_without_globals, self.current_env.type)
env_type = ir.TEnvironment(name=func.name,
vars=env_without_globals, outer=self.current_env.type)
env = self.append(ir.Alloc([], env_type, name="env"))
old_env, self.current_env = self.current_env, env

if not is_lambda:
priv_env = self.append(ir.Alloc([], ir.TEnvironment({ "$return": typ.ret }),
name="privenv"))
priv_env_type = ir.TEnvironment(name=func.name + ".priv",
vars={ "$return": typ.ret })
priv_env = self.append(ir.Alloc([], priv_env_type, name="privenv"))
old_priv_env, self.current_private_env = self.current_private_env, priv_env

self.append(ir.SetLocal(env, "$outer", env_arg))
@@ -1092,7 +1095,9 @@ def visit_ListCompT(self, node):
result = self.append(ir.Alloc([length], node.type))

try:
env_type = ir.TEnvironment(node.typing_env, self.current_env.type)
gen_suffix = ".gen.{}.{}".format(node.loc.line(), node.loc.column())
env_type = ir.TEnvironment(name=self.current_function.name + gen_suffix,
vars=node.typing_env, outer=self.current_env.type)
env = self.append(ir.Alloc([], env_type, name="env.gen"))
old_env, self.current_env = self.current_env, env

2 changes: 1 addition & 1 deletion artiq/compiler/transforms/inferencer.py
Original file line number Diff line number Diff line change
@@ -1017,7 +1017,7 @@ def visit_FunctionDefT(self, node):

diag = diagnostic.Diagnostic("error",
"decorators are not supported", {},
node.at_locs[index], [decorator.loc])
node.at_locs[index], [])
self.engine.process(diag)

try:
6 changes: 4 additions & 2 deletions artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
@@ -256,8 +256,10 @@ def llty_of_type(self, typ, bare=False, for_return=False):
elif ir.is_option(typ):
return ll.LiteralStructType([lli1, self.llty_of_type(typ.params["inner"])])
elif ir.is_environment(typ):
llty = ll.LiteralStructType([self.llty_of_type(typ.params[name])
for name in typ.params])
llty = self.llcontext.get_identified_type("env.{}".format(typ.env_name))
if llty.elements is None:
llty.elements = [self.llty_of_type(typ.params[name]) for name in typ.params]

if bare:
return llty
else:
3 changes: 2 additions & 1 deletion artiq/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ extern void __divsi3, __modsi3, __ledf2, __gedf2, __unorddf2, __eqdf2, __ltdf2,
__udivmoddi4, __floatsisf, __floatunsisf, __fixsfsi, __fixunssfsi,
__adddf3, __subdf3, __muldf3, __divdf3, __floatsidf, __floatunsidf,
__floatdidf, __fixdfsi, __fixdfdi, __fixunsdfsi, __clzsi2, __ctzsi2,
__udivdi3, __umoddi3, __moddi3;
__udivdi3, __umoddi3, __moddi3, __powidf2;

/* artiq_personality symbols */
extern void __artiq_personality;
@@ -80,6 +80,7 @@ static const struct symbol runtime_exports[] = {
{"__udivdi3", &__udivdi3},
{"__umoddi3", &__umoddi3},
{"__moddi3", &__moddi3},
{"__powidf2", &__powidf2},

/* exceptions */
{"_Unwind_Resume", &_Unwind_Resume},