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: e1e082e2ec2a
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: 3b529c6f9033
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Nov 26, 2015

  1. compiler.testbench: fix after e1cd2cc.

    whitequark committed Nov 26, 2015
    Copy the full SHA
    e2f7d10 View commit details
  2. compiler.types: implement map.

    whitequark committed Nov 26, 2015
    Copy the full SHA
    3b529c6 View commit details
2 changes: 1 addition & 1 deletion artiq/compiler/testbench/irgen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys, fileinput
from pythonparser import diagnostic
from .. import Module, Source
from ..module import Module, Source

def main():
def process_diagnostic(diag):
2 changes: 1 addition & 1 deletion artiq/compiler/testbench/jit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os, sys, fileinput, ctypes
from pythonparser import diagnostic
from llvmlite_artiq import binding as llvm
from .. import Module, Source
from ..module import Module, Source
from ..targets import NativeTarget

def main():
2 changes: 1 addition & 1 deletion artiq/compiler/testbench/llvmgen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys, fileinput
from pythonparser import diagnostic
from llvmlite_artiq import ir as ll
from .. import Module, Source
from ..module import Module, Source
from ..targets import NativeTarget

def main():
2 changes: 1 addition & 1 deletion artiq/compiler/testbench/perf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys, os
from pythonparser import diagnostic
from .. import Module, Source
from ..module import Module, Source
from ..targets import OR1KTarget
from . import benchmark

2 changes: 1 addition & 1 deletion artiq/compiler/testbench/perf_embedding.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
from pythonparser import diagnostic
from ...protocols.file_db import FlatFileDB
from ...master.worker_db import DeviceManager
from .. import Module
from ..module import Module
from ..embedding import Stitcher
from ..targets import OR1KTarget
from . import benchmark
2 changes: 1 addition & 1 deletion artiq/compiler/testbench/shlib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys, os
from pythonparser import diagnostic
from .. import Module, Source
from ..module import Module, Source
from ..targets import OR1KTarget

def main():
3 changes: 2 additions & 1 deletion artiq/compiler/testbench/signature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys, fileinput
from pythonparser import diagnostic
from .. import types, iodelay, Module, Source
from ..module import Module, Source
from .. import types, iodelay

def main():
if len(sys.argv) > 1 and sys.argv[1] == "+diag":
60 changes: 60 additions & 0 deletions artiq/compiler/types.py
Original file line number Diff line number Diff line change
@@ -78,6 +78,9 @@ def fold(self, accum, fn):
else:
return self.find().fold(accum, fn)

def map(self, fn):
return fn(self)

def __repr__(self):
if self.parent is self:
return "<artiq.compiler.types.TVar %d>" % id(self)
@@ -122,6 +125,21 @@ def fold(self, accum, fn):
accum = self.params[param].fold(accum, fn)
return fn(accum, self)

def map(self, fn):
params = OrderedDict()
for param in self.params:
params[param] = self.params[param].map(fn)

attributes = OrderedDict()
for attr in self.attributes:
attributes[attr] = self.attributes[attr].map(fn)

self_copy = self.__class__.__new__(self.__class__)
self_copy.name = self.name
self_copy.params = params
self_copy.attributes = attributes
return fn(self_copy)

def __repr__(self):
return "artiq.compiler.types.TMono(%s, %s)" % (repr(self.name), repr(self.params))

@@ -168,6 +186,9 @@ def fold(self, accum, fn):
accum = elt.fold(accum, fn)
return fn(accum, self)

def map(self, fn):
return fn(TTuple(list(map(lambda elt: elt.map(fn), self.elts))))

def __repr__(self):
return "artiq.compiler.types.TTuple(%s)" % repr(self.elts)

@@ -236,6 +257,23 @@ def fold(self, accum, fn):
accum = self.ret.fold(accum, fn)
return fn(accum, self)

def _map_args(self, fn):
args = OrderedDict()
for arg in self.args:
args[arg] = self.args[arg].map(fn)

optargs = OrderedDict()
for optarg in self.optargs:
optargs[optarg] = self.optargs[optarg].map(fn)

return args, optargs, self.ret.map(fn)

def map(self, fn):
args, optargs, ret = self._map_args(fn)
self_copy = TFunction(args, optargs, ret)
self_copy.delay = self.delay.map(fn)
return fn(self_copy)

def __repr__(self):
return "artiq.compiler.types.TFunction({}, {}, {})".format(
repr(self.args), repr(self.optargs), repr(self.ret))
@@ -274,6 +312,12 @@ def unify(self, other):
else:
raise UnificationError(self, other)

def map(self, fn):
args, optargs, ret = self._map_args(fn)
self_copy = TRPCFunction(args, optargs, ret, self.service)
self_copy.delay = self.delay.map(fn)
return fn(self_copy)

class TCFunction(TFunction):
"""
A function type of a runtime-provided C function.
@@ -297,6 +341,12 @@ def unify(self, other):
else:
raise UnificationError(self, other)

def map(self, fn):
args, _optargs, ret = self._map_args(fn)
self_copy = TCFunction(args, ret, self.name)
self_copy.delay = self.delay.map(fn)
return fn(self_copy)

class TBuiltin(Type):
"""
An instance of builtin type. Every instance of a builtin
@@ -318,6 +368,9 @@ def unify(self, other):
def fold(self, accum, fn):
return fn(accum, self)

def map(self, fn):
return fn(self)

def __repr__(self):
return "artiq.compiler.types.{}({})".format(type(self).__name__, repr(self.name))

@@ -409,6 +462,9 @@ def unify(self, other):
def fold(self, accum, fn):
return fn(accum, self)

def map(self, fn):
return fn(self)

def __repr__(self):
return "artiq.compiler.types.TValue(%s)" % repr(self.value)

@@ -456,6 +512,10 @@ def fold(self, accum, fn):
# delay types do not participate in folding
pass

def map(self, fn):
# or mapping
return self

def __eq__(self, other):
return isinstance(other, TDelay) and \
(self.duration == other.duration and \
3 changes: 2 additions & 1 deletion artiq/language/types.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
from artiq.compiler import types, builtins

__all__ = ["TNone", "TBool", "TInt32", "TInt64", "TFloat",
"TStr", "TList", "TRange32", "TRange64"]
"TStr", "TList", "TRange32", "TRange64", "TVar"]

TNone = builtins.TNone()
TBool = builtins.TBool()
@@ -17,3 +17,4 @@
TList = builtins.TList
TRange32 = builtins.TRange(builtins.TInt(types.TValue(32)))
TRange64 = builtins.TRange(builtins.TInt(types.TValue(64)))
TVar = types.TVar