Skip to contentSkip to conversation

Use bitfields in MIPS tlb_t

PATCH New Thiemo Seufer 1 participant 1 message Feb 16, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use bitfields in MIPS tlb_t

Hello All,

this patch switches the MIPS tlb_t to a more compact bitfield representation and gets rid of explicit masking of the various TLB flags.

Thiemo

Index: target-mips/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-mips/cpu.h,v
retrieving revision 1.4

cpu.h +8 -5
diff -u -p -r1.4 cpu.h
@@ -22,11 +22,14 @@ struct tlb_t {
     target_ulong VPN;
     target_ulong end;
     target_ulong end2;
-    uint8_t ASID;
-    uint8_t G;
-    uint8_t C[2];
-    uint8_t V[2];
-    uint8_t D[2];
+    uint_fast8_t ASID;
+    uint_fast16_t G:1;
+    uint_fast16_t C0:3;
+    uint_fast16_t C1:3;
+    uint_fast16_t V0:1;
+    uint_fast16_t V1:1;
+    uint_fast16_t D0:1;
+    uint_fast16_t D1:1;
     target_ulong PFN[2];
 };
 #endif

Index: target-mips/helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-mips/helper.c,v retrieving revision 1.8

helper.c +5 -6
diff -u -p -r1.8 helper.c
@@ -50,17 +50,16 @@ static int map_address (CPUState *env, t
             /* TLB match */
             n = (address >> 12) & 1;
             /* Check access rights */
-            if ((tlb->V[n] & 2) && (rw == 0 || (tlb->D[n] & 4))) {
+	    if (!(n ? tlb->V1 : tlb->V0))
+                return -3;
+	    if (rw == 0 || (n ? tlb->D1 : tlb->D0)) {
                 *physical = tlb->PFN[n] | (address & 0xFFF);
                 *prot = PAGE_READ;
-                if (tlb->D[n])
+                if (n ? tlb->D1 : tlb->D0)
                     *prot |= PAGE_WRITE;
                 return 0;
-            } else if (!(tlb->V[n] & 2)) {
-                return -3;
-            } else {
-                return -4;
             }
+            return -4;
         }
     }
 

Index: target-mips/op_helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-mips/op_helper.c,v retrieving revision 1.8

op_helper.c +22 -30

104 lines not on this page · raw message