summaryrefslogtreecommitdiff
path: root/volk/gen
diff options
context:
space:
mode:
authorJosh Blum2012-04-15 17:32:38 -0700
committerJosh Blum2012-04-19 18:12:55 -0700
commit95e91b44d2ef3535129c0a402c51bc56cfd74d06 (patch)
treebfd183e0494cb1ea7b5cf87c9319dd7a5c061aaf /volk/gen
parenteccc86fbb8aa0392307bfdf1bd802e4394868334 (diff)
downloadgnuradio-95e91b44d2ef3535129c0a402c51bc56cfd74d06.tar.gz
gnuradio-95e91b44d2ef3535129c0a402c51bc56cfd74d06.tar.bz2
gnuradio-95e91b44d2ef3535129c0a402c51bc56cfd74d06.zip
volk: created other templates for runtime + machines
Diffstat (limited to 'volk/gen')
-rw-r--r--volk/gen/volk_arch_defs.py5
-rw-r--r--volk/gen/volk_kernel_defs.py10
-rw-r--r--volk/gen/volk_machine_defs.py3
-rw-r--r--volk/gen/volk_tmpl_utils.py10
4 files changed, 22 insertions, 6 deletions
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 6869ef7a9..c6115d64e 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -18,6 +18,9 @@
archs = list()
arch_dict = dict()
+#TODO enable this when we are ready
+create_unaligned_archs = False
+
class arch_class:
def __init__(self, **kwargs):
for key, cast, failval in (
@@ -44,7 +47,7 @@ def register_arch(**kwargs):
arch = arch_class(**kwargs)
archs.append(arch)
arch_dict[arch.name] = arch
- if arch.alignment > 1:
+ if arch.alignment > 1 and create_unaligned_archs:
kwargs['name'] += '_u'
kwargs['alignment'] = 1
register_arch(**kwargs)
diff --git a/volk/gen/volk_kernel_defs.py b/volk/gen/volk_kernel_defs.py
index f598ed3c0..a5c7cb710 100644
--- a/volk/gen/volk_kernel_defs.py
+++ b/volk/gen/volk_kernel_defs.py
@@ -154,8 +154,7 @@ for func in functions:
ret = replace.sub("", ret);
replace = re.compile("inline ");
ret = replace.sub("", ret);
- replace = re.compile("\)");
- arched_args = replace.sub(", const char* arch) {", args);
+ arched_args = args[args.find('(')+1:args.find(')')]
remove = re.compile('\)|\(|{');
rargs = remove.sub("", args);
@@ -198,8 +197,13 @@ for func in functions:
class kernel_class:
def __init__(self, index):
self.name = functions[index]
+ self.pname = self.name.replace('volk_', 'p_')
self.rettype = retlist[index]
- self.arglist = my_argtypelist[index]
+ self.arglist_defs = my_argtypelist[index]
+ self.arglist_namedefs = arched_arglist[index]
+ self.arglist_names = my_arglist[index]
+ self.tagdeps = fcountlist[index]
+ self.taglist = taglist[index]
def __repr__(self):
return self.name
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index 1c879cd50..82734679c 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -32,6 +32,7 @@ class machine_class:
if arch.alignment > 1 and arch_dict.has_key(arch_name):
arch = arch_dict[arch_name]
self.archs.append(arch)
+ self.alignment = max(map(lambda a: a.alignment, self.archs))
def __repr__(self): return self.name
@@ -39,7 +40,7 @@ def register_machine(name, archs):
for i, arch_name in enumerate(archs):
if '|' in arch_name: #handle special arch names with the '|'
for arch_sub in arch_name.split('|'):
- register_machine(name, archs[:i] + [arch_sub] + archs[i+1:])
+ register_machine(name+'_'+arch_sub, archs[:i] + [arch_sub] + archs[i+1:])
return
machine = machine_class(name=name, archs=archs)
machines.append(machine)
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py
index 804cc2f28..92b7fb1a4 100644
--- a/volk/gen/volk_tmpl_utils.py
+++ b/volk/gen/volk_tmpl_utils.py
@@ -37,6 +37,7 @@ def __escape_pre_processor(code):
conly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif')
both = fcn in ('if', 'else')
istmpl = '$' in stuff
+ if 'defined' in stuff: istmpl = False
if conly or (both and not istmpl):
line = '%s\\#%s%s%s'%(p0, p1, fcn, stuff)
out.append(line)
@@ -45,7 +46,9 @@ def __escape_pre_processor(code):
def __parse_tmpl(_tmpl, **kwargs):
defs = {
'archs': volk_arch_defs.archs,
+ 'arch_dict': volk_arch_defs.arch_dict,
'machines': volk_machine_defs.machines,
+ 'machine_dict': volk_machine_defs.machine_dict,
'kernels': volk_kernel_defs.kernels,
}
defs.update(kwargs)
@@ -58,4 +61,9 @@ def __parse_tmpl(_tmpl, **kwargs):
return str(Template.Template(_tmpl, defs))
if __name__ == '__main__':
- print __parse_tmpl(open(sys.argv[1]).read())
+ input_file = sys.argv[1]
+ output_file = sys.argv[2]
+ which = sys.argv[3]
+ output = __parse_tmpl(open(input_file).read(), which=which)
+ if output_file: open(output_file, 'w').write(output)
+ else: print output