summaryrefslogtreecommitdiff
path: root/volk/gen
diff options
context:
space:
mode:
authorJohnathan Corgan2012-04-16 08:39:32 -0700
committerJohnathan Corgan2012-04-16 08:39:32 -0700
commit847be64ac11f767a9ef631154ef88030e9d4d8ba (patch)
tree400268c513bfeb7f9d8c4bc29af4c99a2f32cf90 /volk/gen
parentec7faa9b80dff18ef170d85efdd498bea3af4940 (diff)
parent92db96430685e843443a00936328b3539354c83e (diff)
downloadgnuradio-847be64ac11f767a9ef631154ef88030e9d4d8ba.tar.gz
gnuradio-847be64ac11f767a9ef631154ef88030e9d4d8ba.tar.bz2
gnuradio-847be64ac11f767a9ef631154ef88030e9d4d8ba.zip
Merge branch 'maint'
Conflicts: volk/gen/make_cpuid_c.py
Diffstat (limited to 'volk/gen')
-rw-r--r--volk/gen/archs.xml2
-rw-r--r--volk/gen/make_cpuid_c.py45
2 files changed, 36 insertions, 11 deletions
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index ca2118475..59cc81cc5 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -148,6 +148,8 @@
<reg>c</reg>
<shift>28</shift>
<flag>mavx</flag>
+ <check>xgetbv</check>
+ <checkval>7</checkval>
<alignment>32</alignment>
</arch>
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index e30d643cb..a8939fb90 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -73,6 +73,13 @@ static inline unsigned int cpuid_edx(unsigned int op) {
cpuid_x86 (op, regs);
return regs[3];
}
+
+static inline unsigned int xgetbv(void) {
+ //check to make sure that xgetbv is enabled in OS
+ int xgetbv_enabled = cpuid_ecx(1) >> 27 & 0x01;
+ if(xgetbv_enabled == 0) return 0;
+ return __xgetbv();
+}
#endif
"""
@@ -90,19 +97,25 @@ def make_cpuid_c(dom) :
no_test = False;
else:
no_test = False;
- arch = str(domarch.attributes["name"].value);
- op = domarch.getElementsByTagName("op");
+ arch = str(domarch.attributes["name"].value)
+ op = domarch.getElementsByTagName("op")
if op:
- op = str(op[0].firstChild.data);
- reg = domarch.getElementsByTagName("reg");
+ op = str(op[0].firstChild.data)
+ reg = domarch.getElementsByTagName("reg")
if reg:
- reg = str(reg[0].firstChild.data);
- shift = domarch.getElementsByTagName("shift");
+ reg = str(reg[0].firstChild.data)
+ shift = domarch.getElementsByTagName("shift")
if shift:
- shift = str(shift[0].firstChild.data);
- val = domarch.getElementsByTagName("val");
+ shift = str(shift[0].firstChild.data)
+ val = domarch.getElementsByTagName("val")
if val:
- val = str(val[0].firstChild.data);
+ val = str(val[0].firstChild.data)
+ check = domarch.getElementsByTagName("check")
+ if check:
+ check = str(check[0].firstChild.data)
+ checkval = domarch.getElementsByTagName("checkval")
+ if checkval:
+ checkval = str(checkval[0].firstChild.data)
if no_test:
tempstring = tempstring + """\
@@ -121,13 +134,23 @@ int i_can_has_%s () {
int i_can_has_%s () {
#if defined(VOLK_CPU_x86)
unsigned int e%sx = cpuid_e%sx (%s);
- return ((e%sx >> %s) & 1) == %s;
+ int hwcap = (((e%sx >> %s) & 1) == %s);
+""" % (arch, reg, reg, op, reg, shift, val)
+
+ if check and checkval:
+ tempstring += """\
+ if (hwcap == 0) return 0;
+ hwcap &= (%s() == %s);
+""" % (check, checkval)
+
+ tempstring += """\
+ return hwcap;
#else
return 0;
#endif
}
-""" % (arch, reg, reg, op, reg, shift, val)
+"""
elif op == "0x80000001":
tempstring = tempstring + """\