From: Gabe Black Date: Tue, 6 Sep 2011 01:36:26 +0000 (-0700) Subject: X86: Make sure instruction flags are set properly even on 32 bit machines. X-Git-Tag: stable_2012_02_02~99 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=87d687e242e3437e7e3a83e04bf9a403d95b3e9e;p=gem5.git X86: Make sure instruction flags are set properly even on 32 bit machines. The way flag bits were being set for microops in x86 ended up implicitly calling the bitset constructor which was truncating flags beyond the width of an unsigned long. This change sets the bits in chunks which are always small enough to avoid being truncated. On 64 bit machines this should reduce to be the same as before, and on 32 bit machines it should work properly and not be unreasonably inefficient. --- diff --git a/src/arch/x86/insts/microop.hh b/src/arch/x86/insts/microop.hh index 6fc215452..e5248c9ce 100644 --- a/src/arch/x86/insts/microop.hh +++ b/src/arch/x86/insts/microop.hh @@ -100,7 +100,15 @@ namespace X86ISA X86ISA::X86StaticInst(mnem, _machInst, __opClass), instMnem(_instMnem) { - flags |= setFlags; + const int ChunkSize = sizeof(unsigned long); + const int Chunks = sizeof(setFlags) / ChunkSize; + + // Since the bitset constructor can only handle unsigned long + // sized chunks, feed it those one at a time while oring them in. + for (int i = 0; i < Chunks; i++) { + unsigned shift = i * ChunkSize * 8; + flags |= (std::bitset(setFlags >> shift) << shift); + } } std::string generateDisassembly(Addr pc,