decoder.hh (10593:a39de7b8d2c9) decoder.hh (10924:d02e9c239892)
1/*
2 * Copyright (c) 2012 Google
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;

--- 50 unchanged lines hidden (view full) ---

59 static ByteTable UsesModRMTwoByte;
60 static ByteTable UsesModRMThreeByte0F38;
61 static ByteTable UsesModRMThreeByte0F3A;
62
63 static ByteTable ImmediateTypeOneByte;
64 static ByteTable ImmediateTypeTwoByte;
65 static ByteTable ImmediateTypeThreeByte0F38;
66 static ByteTable ImmediateTypeThreeByte0F3A;
1/*
2 * Copyright (c) 2012 Google
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;

--- 50 unchanged lines hidden (view full) ---

59 static ByteTable UsesModRMTwoByte;
60 static ByteTable UsesModRMThreeByte0F38;
61 static ByteTable UsesModRMThreeByte0F3A;
62
63 static ByteTable ImmediateTypeOneByte;
64 static ByteTable ImmediateTypeTwoByte;
65 static ByteTable ImmediateTypeThreeByte0F38;
66 static ByteTable ImmediateTypeThreeByte0F3A;
67 static ByteTable ImmediateTypeVex[10];
67
68 protected:
69 struct InstBytes
70 {
71 StaticInstPtr si;
72 std::vector<MachInst> chunks;
73 std::vector<MachInst> masks;
74 int lastOffset;

--- 95 unchanged lines hidden (view full) ---

170 //This is how much of any immediate value we've gotten. This is used
171 //for both the actual immediate and the displacement.
172 int immediateCollected;
173
174 enum State {
175 ResetState,
176 FromCacheState,
177 PrefixState,
68
69 protected:
70 struct InstBytes
71 {
72 StaticInstPtr si;
73 std::vector<MachInst> chunks;
74 std::vector<MachInst> masks;
75 int lastOffset;

--- 95 unchanged lines hidden (view full) ---

171 //This is how much of any immediate value we've gotten. This is used
172 //for both the actual immediate and the displacement.
173 int immediateCollected;
174
175 enum State {
176 ResetState,
177 FromCacheState,
178 PrefixState,
179 TwoByteVexState,
180 ThreeByteVexFirstState,
181 ThreeByteVexSecondState,
178 OneByteOpcodeState,
179 TwoByteOpcodeState,
180 ThreeByte0F38OpcodeState,
181 ThreeByte0F3AOpcodeState,
182 ModRMState,
183 SIBState,
184 DisplacementState,
185 ImmediateState,
186 //We should never get to this state. Getting here is an error.
187 ErrorState
188 };
189
190 State state;
191
192 //Functions to handle each of the states
193 State doResetState();
194 State doFromCacheState();
195 State doPrefixState(uint8_t);
182 OneByteOpcodeState,
183 TwoByteOpcodeState,
184 ThreeByte0F38OpcodeState,
185 ThreeByte0F3AOpcodeState,
186 ModRMState,
187 SIBState,
188 DisplacementState,
189 ImmediateState,
190 //We should never get to this state. Getting here is an error.
191 ErrorState
192 };
193
194 State state;
195
196 //Functions to handle each of the states
197 State doResetState();
198 State doFromCacheState();
199 State doPrefixState(uint8_t);
200 State doTwoByteVexState(uint8_t);
201 State doThreeByteVexFirstState(uint8_t);
202 State doThreeByteVexSecondState(uint8_t);
196 State doOneByteOpcodeState(uint8_t);
197 State doTwoByteOpcodeState(uint8_t);
198 State doThreeByte0F38OpcodeState(uint8_t);
199 State doThreeByte0F3AOpcodeState(uint8_t);
200 State doModRMState(uint8_t);
201 State doSIBState(uint8_t);
202 State doDisplacementState();
203 State doImmediateState();
204
205 //Process the actual opcode found earlier, using the supplied tables.
206 State processOpcode(ByteTable &immTable, ByteTable &modrmTable,
207 bool addrSizedImm = false);
203 State doOneByteOpcodeState(uint8_t);
204 State doTwoByteOpcodeState(uint8_t);
205 State doThreeByte0F38OpcodeState(uint8_t);
206 State doThreeByte0F3AOpcodeState(uint8_t);
207 State doModRMState(uint8_t);
208 State doSIBState(uint8_t);
209 State doDisplacementState();
210 State doImmediateState();
211
212 //Process the actual opcode found earlier, using the supplied tables.
213 State processOpcode(ByteTable &immTable, ByteTable &modrmTable,
214 bool addrSizedImm = false);
215 // Process the opcode found with VEX / XOP prefix.
216 State processExtendedOpcode(ByteTable &immTable);
208
209 protected:
210 /// Caching for decoded instruction objects.
211
212 typedef MiscReg CacheKey;
213
214 typedef DecodeCache::AddrMap<Decoder::InstBytes> DecodePages;
215 DecodePages *decodePages;

--- 125 unchanged lines hidden ---
217
218 protected:
219 /// Caching for decoded instruction objects.
220
221 typedef MiscReg CacheKey;
222
223 typedef DecodeCache::AddrMap<Decoder::InstBytes> DecodePages;
224 DecodePages *decodePages;

--- 125 unchanged lines hidden ---