|
From: Florian K. <br...@ac...> - 2013-01-31 02:19:54
|
We should change the definition of HReg to make mixups of integers
(typically register number) and HReg less likely. Like so:
Index: VEX/priv/host_generic_regs.h
===================================================================
--- VEX/priv/host_generic_regs.h (revision 2671)
+++ VEX/priv/host_generic_regs.h (working copy)
@@ -116,22 +116,22 @@
occupy 24 bits. */
if (r24 != regno)
vpanic("mkHReg: regno exceeds 2^24");
- return regno | (((UInt)rc) << 28) | (virtual ? (1<<24) : 0);
+ return (regno << 5) | (((UInt)rc) << 1) | (virtual ? 1 : 0);
}
static inline HRegClass hregClass ( HReg r ) {
UInt rc = r;
- rc = (rc >> 28) & 0x0F;
+ rc = (rc >> 1) & 0x0F;
vassert(rc >= HRcInt32 && rc <= HRcVec128);
return (HRegClass)rc;
}
static inline UInt hregNumber ( HReg r ) {
- return ((UInt)r) & 0x00FFFFFF;
+ return ((UInt)r) >> 5;
}
static inline Bool hregIsVirtual ( HReg r ) {
- return toBool(((UInt)r) & (1<<24));
+ return toBool(((UInt)r) & 1);
}
While it would be preferred to find such mixups so at compile time, I
cannot think of a non-intrusive way to do it. So.. the above patch is
most likely to find those mixups at runtime as assigning a HReg to an
integer will no longer give the register number in the low order bits.
Florian
|