1/* 2 * Copyright (c) 2007 The Hewlett-Packard Development Company 3 * Copyright (c) 2011 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 254 unchanged lines hidden (view full) --- 263 tc->setIntReg(X86ISA::INTREG_PSEUDO(3), 0); 264 tc->setIntReg(X86ISA::INTREG_PSEUDO(4), 0); 265 266 // Update the RFLAGS misc reg with whatever didn't go into the 267 // magic registers. 268 tc->setMiscReg(MISCREG_RFLAGS, val & ~(ccFlagMask | cfofMask | DFBit)); 269} 270 |
271uint8_t 272convX87TagsToXTags(uint16_t ftw) 273{ 274 uint8_t ftwx(0); 275 for (int i = 0; i < 8; ++i) { 276 // Extract the tag for the current element on the FP stack 277 const unsigned tag((ftw >> (2 * i)) & 0x3); 278 279 /* 280 * Check the type of the current FP element. Valid values are: 281 * 0 == Valid 282 * 1 == Zero 283 * 2 == Special (Nan, unsupported, infinity, denormal) 284 * 3 == Empty 285 */ 286 // The xsave version of the tag word only keeps track of 287 // whether the element is empty or not. Set the corresponding 288 // bit in the ftwx if it's not empty, 289 if (tag != 0x3) 290 ftwx |= 1 << i; 291 } 292 293 return ftwx; 294} 295 |
296uint16_t |
297convX87XTagsToTags(uint8_t ftwx) 298{ 299 uint16_t ftw(0); 300 for (int i = 0; i < 8; ++i) { 301 const unsigned xtag(((ftwx >> i) & 0x1)); 302 303 // The xtag for an x87 stack position is 0 for empty stack positions. 304 if (!xtag) { 305 // Set the tag word to 3 (empty) for the current element. 306 ftw |= 0x3 << (2 * i); 307 } else { 308 // TODO: We currently assume that non-empty elements are 309 // valid (0x0), but we should ideally reconstruct the full 310 // state (valid/zero/special). 311 } 312 } 313 314 return ftw; 315} 316 317uint16_t |
318genX87Tags(uint16_t ftw, uint8_t top, int8_t spm) 319{ 320 const uint8_t new_top((top + spm + 8) % 8); 321 322 if (spm > 0) { 323 // Removing elements from the stack. Flag the elements as empty. 324 for (int i = top; i != new_top; i = (i + 1 + 8) % 8) 325 ftw |= 0x3 << (2 * i); --- 12 unchanged lines hidden --- |