Merge tag 'wberr-v4.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton...
[sfrench/cifs-2.6.git] / tools / perf / arch / x86 / annotate / instructions.c
index c1625f256df362ab06ab21cc35972bdcca227381..d84b72063a30e33847e28891c16b9158bb0b8406 100644 (file)
@@ -76,3 +76,49 @@ static struct ins x86__instructions[] = {
        { .name = "xbeginq",    .ops = &jump_ops, },
        { .name = "retq",       .ops = &ret_ops,  },
 };
+
+static bool x86__ins_is_fused(struct arch *arch, const char *ins1,
+                             const char *ins2)
+{
+       if (arch->family != 6 || arch->model < 0x1e || strstr(ins2, "jmp"))
+               return false;
+
+       if (arch->model == 0x1e) {
+               /* Nehalem */
+               if ((strstr(ins1, "cmp") && !strstr(ins1, "xchg")) ||
+                    strstr(ins1, "test")) {
+                       return true;
+               }
+       } else {
+               /* Newer platform */
+               if ((strstr(ins1, "cmp") && !strstr(ins1, "xchg")) ||
+                    strstr(ins1, "test") ||
+                    strstr(ins1, "add") ||
+                    strstr(ins1, "sub") ||
+                    strstr(ins1, "and") ||
+                    strstr(ins1, "inc") ||
+                    strstr(ins1, "dec")) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+static int x86__cpuid_parse(struct arch *arch, char *cpuid)
+{
+       unsigned int family, model, stepping;
+       int ret;
+
+       /*
+        * cpuid = "GenuineIntel,family,model,stepping"
+        */
+       ret = sscanf(cpuid, "%*[^,],%u,%u,%u", &family, &model, &stepping);
+       if (ret == 3) {
+               arch->family = family;
+               arch->model = model;
+               return 0;
+       }
+
+       return -1;
+}