summaryrefslogtreecommitdiff
path: root/volk/gen/make_registry.py
blob: de1f46aa6493230e251e798179f82b2136c4d310 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from xml.dom import minidom
from emit_omnilog import *
from volk_regexp import *
import string

def make_registry(dom, funclist, fcountlist, taglist) :
    tempstring = "";
    tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n";
    tempstring = tempstring +'\n#ifndef INCLUDED_VOLK_REGISTRY_H';
    tempstring = tempstring +'\n#define INCLUDED_VOLK_REGISTRY_H\n\n';
    tempstring = tempstring +'#include<volk/volk_config_fixed.h>\n';
    tempstring = tempstring + emit_prolog();
    tempstring = tempstring + '\n'

    

    
    for domarch in dom:
        arch = str(domarch.attributes["name"].value);
        tempstring = tempstring +"#ifdef LV_HAVE_" + arch.swapcase() + "\n";
        tempstring = tempstring +"#define LV_" + arch.swapcase() + "_CNT 1\n";
        tempstring = tempstring +"#else\n";
        tempstring = tempstring +"#define LV_" + arch.swapcase() + "_CNT 0\n";
        tempstring = tempstring +"#endif /*LV_HAVE_" + arch.swapcase() + "*/\n\n";

    counter = 0;
    
    for i in range(len(funclist)):
        tempstring = tempstring + "static const char* " + funclist[i] + "_indices[] = {\n";
        
        tags_counter = 0;    
        for arch_list in fcountlist[i]:
            tempstring = tempstring + "#if defined(LV_HAVE_"
            for ind in range(len(arch_list)):
                
                tempstring = tempstring + arch_list[ind] + ")";
                if ind < len(arch_list) - 1:
                    tempstring = tempstring + " && defined(LV_HAVE_";
                
            tempstring = tempstring + "\n \"" + str(taglist[i][tags_counter]) + "\",\n#endif\n";
            tags_counter = tags_counter + 1;
                
        tempstring = strip_trailing(tempstring, ",")
        tempstring = tempstring + "};\n\n";

    
    for fcount in fcountlist:
        tempstring = tempstring + "static const int " + funclist[counter] + "_arch_defs[] = {\n";
        counter += 1;
        for arch_list in fcount:
            tempstring = tempstring + "#if defined(LV_HAVE_"
            for ind in range(len(arch_list)): 
                tempstring = tempstring + arch_list[ind] + ")";
                if ind < len(arch_list) - 1:
                    tempstring = tempstring + " && defined(LV_HAVE_";
            tempstring = tempstring + "\n"
            tempstring = tempstring + " (1 << LV_"
            for ind in range(len(arch_list)):
                tempstring = tempstring + arch_list[ind];
                if ind < len(arch_list) - 1:
                    tempstring = tempstring + ") + (1 << LV_"
            tempstring = tempstring + "),\n#endif\n"
        tempstring = strip_trailing(tempstring, ",")
        tempstring = tempstring + "};\n\n"
        
    counter = 0;
    for fcount in fcountlist:
        tempstring += "static const int " + funclist[counter] + "_n_archs = "
        counter += 1;
        for arch_list in fcount:
            tempstring = tempstring + " (LV_"
            for ind in range(len(arch_list)): 
                tempstring = tempstring + arch_list[ind] + "_CNT";
                if ind < len(arch_list) - 1:
                    tempstring = tempstring + " * LV_";
            tempstring = tempstring + ") + ";
        tempstring = strip_trailing(tempstring, " + ");
        tempstring = tempstring + ";\n"

    
    tempstring = tempstring + emit_epilog();
    tempstring = tempstring +"#endif /*INCLUDED_VOLK_REGISTRY_H*/\n";

    return tempstring;