| 28 | return True |
| 29 | |
| 30 | class Features: |
| 31 | def __init__(self, arch, cc): |
| 32 | self.copt = FakeCCompilerOpt(arch, cc, cpu_baseline="max") |
| 33 | |
| 34 | def names(self): |
| 35 | return self.copt.cpu_baseline_names() |
| 36 | |
| 37 | def serialize(self, features_names): |
| 38 | result = [] |
| 39 | for f in self.copt.feature_sorted(features_names): |
| 40 | gather = self.copt.feature_supported.get(f, {}).get("group", []) |
| 41 | implies = self.copt.feature_sorted(self.copt.feature_implies(f)) |
| 42 | result.append((f, implies, gather)) |
| 43 | return result |
| 44 | |
| 45 | def table(self, **kwargs): |
| 46 | return self.gen_table(self.serialize(self.names()), **kwargs) |
| 47 | |
| 48 | def table_diff(self, vs, **kwargs): |
| 49 | fnames = set(self.names()) |
| 50 | fnames_vs = set(vs.names()) |
| 51 | common = fnames.intersection(fnames_vs) |
| 52 | extra = fnames.difference(fnames_vs) |
| 53 | notavl = fnames_vs.difference(fnames) |
| 54 | iextra = {} |
| 55 | inotavl = {} |
| 56 | idiff = set() |
| 57 | for f in common: |
| 58 | implies = self.copt.feature_implies(f) |
| 59 | implies_vs = vs.copt.feature_implies(f) |
| 60 | e = implies.difference(implies_vs) |
| 61 | i = implies_vs.difference(implies) |
| 62 | if not i and not e: |
| 63 | continue |
| 64 | if e: |
| 65 | iextra[f] = e |
| 66 | if i: |
| 67 | inotavl[f] = e |
| 68 | idiff.add(f) |
| 69 | |
| 70 | def fbold(f): |
| 71 | if f in extra: |
| 72 | return f':enabled:`{f}`' |
| 73 | if f in notavl: |
| 74 | return f':disabled:`{f}`' |
| 75 | return f |
| 76 | |
| 77 | def fbold_implies(f, i): |
| 78 | if i in iextra.get(f, {}): |
| 79 | return f':enabled:`{i}`' |
| 80 | if f in notavl or i in inotavl.get(f, {}): |
| 81 | return f':disabled:`{i}`' |
| 82 | return i |
| 83 | |
| 84 | diff_all = self.serialize(idiff.union(extra)) |
| 85 | diff_all += vs.serialize(notavl) |
| 86 | content = self.gen_table( |
| 87 | diff_all, fstyle=fbold, fstyle_implies=fbold_implies, **kwargs |