types.cc revision 7624
1/* 2 * Copyright (c) 2010 Gabe Black 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Gabe Black 29 */ 30 31#include "arch/x86/types.hh" 32#include "sim/serialize.hh" 33 34using namespace X86ISA; 35using namespace std; 36 37template <> 38void 39paramOut(ostream &os, const string &name, ExtMachInst const &machInst) 40{ 41 // Prefixes 42 paramOut(os, name + ".legacy", (uint8_t)machInst.legacy); 43 paramOut(os, name + ".rex", (uint8_t)machInst.rex); 44 45 // Opcode 46 paramOut(os, name + ".opcode.num", machInst.opcode.num); 47 paramOut(os, name + ".opcode.prefixA", machInst.opcode.prefixA); 48 paramOut(os, name + ".opcode.prefixB", machInst.opcode.prefixB); 49 paramOut(os, name + ".opcode.op", (uint8_t)machInst.opcode.op); 50 51 // Modifier bytes 52 paramOut(os, name + ".modRM", (uint8_t)machInst.modRM); 53 paramOut(os, name + ".sib", (uint8_t)machInst.sib); 54 55 // Immediate fields 56 paramOut(os, name + ".immediate", machInst.immediate); 57 paramOut(os, name + ".displacement", machInst.displacement); 58 59 // Sizes 60 paramOut(os, name + ".opSize", machInst.opSize); 61 paramOut(os, name + ".addrSize", machInst.addrSize); 62 paramOut(os, name + ".stackSize", machInst.stackSize); 63 paramOut(os, name + ".dispSize", machInst.dispSize); 64 65 // Mode 66 paramOut(os, name + ".mode", (uint8_t)machInst.mode); 67} 68 69template <> 70void 71paramIn(Checkpoint *cp, const string §ion, 72 const string &name, ExtMachInst &machInst) 73{ 74 uint8_t temp8; 75 // Prefixes 76 paramIn(cp, section, name + ".legacy", temp8); 77 machInst.legacy = temp8; 78 paramIn(cp, section, name + ".rex", temp8); 79 machInst.rex = temp8; 80 81 // Opcode 82 paramIn(cp, section, name + ".opcode.num", machInst.opcode.num); 83 paramIn(cp, section, name + ".opcode.prefixA", machInst.opcode.prefixA); 84 paramIn(cp, section, name + ".opcode.prefixB", machInst.opcode.prefixB); 85 paramIn(cp, section, name + ".opcode.op", temp8); 86 machInst.opcode.op = temp8; 87 88 // Modifier bytes 89 paramIn(cp, section, name + ".modRM", temp8); 90 machInst.modRM = temp8; 91 paramIn(cp, section, name + ".sib", temp8); 92 machInst.sib = temp8;; 93 94 // Immediate fields 95 paramIn(cp, section, name + ".immediate", machInst.immediate); 96 paramIn(cp, section, name + ".displacement", machInst.displacement); 97 98 // Sizes 99 paramIn(cp, section, name + ".opSize", machInst.opSize); 100 paramIn(cp, section, name + ".addrSize", machInst.addrSize); 101 paramIn(cp, section, name + ".stackSize", machInst.stackSize); 102 paramIn(cp, section, name + ".dispSize", machInst.dispSize); 103 104 // Mode 105 paramIn(cp, section, name + ".mode", temp8); 106 machInst.mode = temp8; 107} 108