]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: x86 emulator: simplify sib decoding
authorAvi Kivity <avi@qumranet.com>
Mon, 16 Jun 2008 04:23:17 +0000 (21:23 -0700)
committerAvi Kivity <avi@qumranet.com>
Sun, 20 Jul 2008 09:42:33 +0000 (12:42 +0300)
Instead of using sparse switches, use simpler if/else sequences.

Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/x86_emulate.c

index 3721cfddc9737df3bf68773220e298106fa1c9a0..ca7ab2469a4a155aa3155689705ccc09dadcd8d4 100644 (file)
@@ -748,24 +748,12 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
                        base_reg |= sib & 7;
                        scale = sib >> 6;
 
-                       switch (base_reg) {
-                       case 5:
-                       case 13:
-                               if (c->modrm_mod != 0)
-                                       c->modrm_ea += c->regs[base_reg];
-                               else
-                                       c->modrm_ea +=
-                                               insn_fetch(s32, 4, c->eip);
-                               break;
-                       default:
+                       if ((base_reg & 7) == 5 && c->modrm_mod == 0)
+                               c->modrm_ea += insn_fetch(s32, 4, c->eip);
+                       else
                                c->modrm_ea += c->regs[base_reg];
-                       }
-                       switch (index_reg) {
-                       case 4:
-                               break;
-                       default:
+                       if (index_reg != 4)
                                c->modrm_ea += c->regs[index_reg] << scale;
-                       }
                        break;
                case 5:
                case 13: