Ghidra Decompiler Analysis Engine
opbehavior.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
18 #ifndef __CPUI_OPBEHAVIOR__
19 #define __CPUI_OPBEHAVIOR__
20 
21 #include "error.hh"
22 #include "opcodes.hh"
23 
24 class Translate; // Forward declaration
25 
28 struct EvaluationError : public LowlevelError {
29  EvaluationError(const string &s) : LowlevelError(s) {}
30 };
31 
42 class OpBehavior {
43  OpCode opcode;
44  bool isunary;
45  bool isspecial;
46 public:
47  OpBehavior(OpCode opc,bool isun);
48 
49  OpBehavior(OpCode opc,bool isun,bool isspec);
50 
51  virtual ~OpBehavior(void) {}
52 
54  OpCode getOpcode(void) const;
55 
57  bool isSpecial(void) const;
58 
60  bool isUnary(void) const;
61 
63  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
64 
66  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
67 
69  virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
70 
72  virtual uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein) const;
73 
74  static void registerInstructions(vector<OpBehavior *> &inst,const Translate *trans);
75 };
76 
80 inline OpBehavior::OpBehavior(OpCode opc,bool isun)
81 
82 {
83  opcode = opc;
84  isunary = isun;
85  isspecial = false;
86 }
87 
92 inline OpBehavior::OpBehavior(OpCode opc,bool isun,bool isspec)
93 
94 {
95  opcode = opc;
96  isunary = isun;
97  isspecial = isspec;
98 }
99 
103 inline OpCode OpBehavior::getOpcode(void) const {
104  return opcode;
105 }
106 
110 inline bool OpBehavior::isSpecial(void) const {
111  return isspecial;
112 }
113 
116 inline bool OpBehavior::isUnary(void) const {
117  return isunary;
118 }
119 
120 // A class for each opcode
121 
123 class OpBehaviorCopy : public OpBehavior {
124 public:
125  OpBehaviorCopy(void) : OpBehavior(CPUI_COPY,true) {}
126  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
127  virtual uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein) const;
128 };
129 
131 class OpBehaviorEqual : public OpBehavior {
132 public:
133  OpBehaviorEqual(void) : OpBehavior(CPUI_INT_EQUAL,false) {}
134  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
135 };
136 
139 public:
141  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
142 };
143 
146 public:
147  OpBehaviorIntSless(void) : OpBehavior(CPUI_INT_SLESS,false) {}
148  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
149 };
150 
153 public:
155  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
156 };
157 
160 public:
161  OpBehaviorIntLess(void) : OpBehavior(CPUI_INT_LESS,false) {}
162  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
163 };
164 
167 public:
169  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
170 };
171 
174 public:
176  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
177  virtual uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein) const;
178 };
179 
182 public:
184  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
185  virtual uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein) const;
186 };
187 
189 class OpBehaviorIntAdd : public OpBehavior {
190 public:
191  OpBehaviorIntAdd(void): OpBehavior(CPUI_INT_ADD,false) {}
192  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
193  virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
194 };
195 
197 class OpBehaviorIntSub : public OpBehavior {
198 public:
199  OpBehaviorIntSub(void): OpBehavior(CPUI_INT_SUB,false) {}
200  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
201  virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
202 };
203 
206 public:
208  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
209 };
210 
213 public:
215  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
216 };
217 
220 public:
222  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
223 };
224 
227 public:
229  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
230 };
231 
234 public:
236  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
237 };
238 
240 class OpBehaviorIntXor : public OpBehavior {
241 public:
242  OpBehaviorIntXor(void): OpBehavior(CPUI_INT_XOR,false) {}
243  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
244 };
245 
247 class OpBehaviorIntAnd : public OpBehavior {
248 public:
249  OpBehaviorIntAnd(void): OpBehavior(CPUI_INT_AND,false) {}
250  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
251 };
252 
254 class OpBehaviorIntOr : public OpBehavior {
255 public:
256  OpBehaviorIntOr(void): OpBehavior(CPUI_INT_OR,false) {}
257  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
258 };
259 
262 public:
263  OpBehaviorIntLeft(void): OpBehavior(CPUI_INT_LEFT,false) {}
264  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
265  virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
266 };
267 
270 public:
272  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
273  virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
274 };
275 
278 public:
280  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
281  virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
282 };
283 
286 public:
287  OpBehaviorIntMult(void): OpBehavior(CPUI_INT_MULT,false) {}
288  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
289 };
290 
292 class OpBehaviorIntDiv : public OpBehavior {
293 public:
294  OpBehaviorIntDiv(void): OpBehavior(CPUI_INT_DIV,false) {}
295  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
296 };
297 
300 public:
301  OpBehaviorIntSdiv(void): OpBehavior(CPUI_INT_SDIV,false) {}
302  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
303 };
304 
306 class OpBehaviorIntRem : public OpBehavior {
307 public:
308  OpBehaviorIntRem(void): OpBehavior(CPUI_INT_REM,false) {}
309  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
310 };
311 
314 public:
315  OpBehaviorIntSrem(void): OpBehavior(CPUI_INT_SREM,false) {}
316  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
317 };
318 
321 public:
323  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
324 };
325 
328 public:
329  OpBehaviorBoolXor(void): OpBehavior(CPUI_BOOL_XOR,false) {}
330  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
331 };
332 
335 public:
336  OpBehaviorBoolAnd(void): OpBehavior(CPUI_BOOL_AND,false) {}
337  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
338 };
339 
341 class OpBehaviorBoolOr : public OpBehavior {
342 public:
343  OpBehaviorBoolOr(void): OpBehavior(CPUI_BOOL_OR,false) {}
344  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
345 };
346 
349  const Translate *translate;
350 public:
351  OpBehaviorFloatEqual(const Translate *trans): OpBehavior(CPUI_FLOAT_EQUAL,false) { translate = trans; }
352  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
353 };
354 
357  const Translate *translate;
358 public:
359  OpBehaviorFloatNotEqual(const Translate *trans): OpBehavior(CPUI_FLOAT_NOTEQUAL,false) { translate = trans; }
360  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
361 };
362 
365  const Translate *translate;
366 public:
367  OpBehaviorFloatLess(const Translate *trans) : OpBehavior(CPUI_FLOAT_LESS,false) { translate = trans; }
368  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
369 };
370 
373  const Translate *translate;
374 public:
375  OpBehaviorFloatLessEqual(const Translate *trans) : OpBehavior(CPUI_FLOAT_LESSEQUAL,false) { translate = trans; }
376  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
377 };
378 
381  const Translate *translate;
382 public:
383  OpBehaviorFloatNan(const Translate *trans) : OpBehavior(CPUI_FLOAT_NAN,true) { translate = trans; }
384  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
385 };
386 
389  const Translate *translate;
390 public:
391  OpBehaviorFloatAdd(const Translate *trans) : OpBehavior(CPUI_FLOAT_ADD,false) { translate = trans; }
392  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
393 };
394 
397  const Translate *translate;
398 public:
399  OpBehaviorFloatDiv(const Translate *trans) : OpBehavior(CPUI_FLOAT_DIV,false) { translate = trans; }
400  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
401 };
402 
405  const Translate *translate;
406 public:
407  OpBehaviorFloatMult(const Translate *trans) : OpBehavior(CPUI_FLOAT_MULT,false) { translate = trans; }
408  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
409 };
410 
413  const Translate *translate;
414 public:
415  OpBehaviorFloatSub(const Translate *trans) : OpBehavior(CPUI_FLOAT_SUB,false) { translate = trans; }
416  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
417 };
418 
421  const Translate *translate;
422 public:
423  OpBehaviorFloatNeg(const Translate *trans) : OpBehavior(CPUI_FLOAT_NEG,true) { translate = trans; }
424  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
425 };
426 
429  const Translate *translate;
430 public:
431  OpBehaviorFloatAbs(const Translate *trans) : OpBehavior(CPUI_FLOAT_ABS,true) { translate = trans; }
432  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
433 };
434 
437  const Translate *translate;
438 public:
439  OpBehaviorFloatSqrt(const Translate *trans) : OpBehavior(CPUI_FLOAT_SQRT,true) { translate = trans; }
440  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
441 };
442 
445  const Translate *translate;
446 public:
447  OpBehaviorFloatInt2Float(const Translate *trans) : OpBehavior(CPUI_FLOAT_INT2FLOAT,true) { translate = trans; }
448  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
449 };
450 
453  const Translate *translate;
454 public:
455  OpBehaviorFloatFloat2Float(const Translate *trans) : OpBehavior(CPUI_FLOAT_FLOAT2FLOAT,true) { translate = trans; }
456  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
457 };
458 
461  const Translate *translate;
462 public:
463  OpBehaviorFloatTrunc(const Translate *trans) : OpBehavior(CPUI_FLOAT_TRUNC,true) { translate = trans; }
464  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
465 };
466 
469  const Translate *translate;
470 public:
471  OpBehaviorFloatCeil(const Translate *trans) : OpBehavior(CPUI_FLOAT_CEIL,true) { translate = trans; }
472  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
473 };
474 
477  const Translate *translate;
478 public:
479  OpBehaviorFloatFloor(const Translate *trans) : OpBehavior(CPUI_FLOAT_FLOOR,true) { translate = trans; }
480  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
481 };
482 
485  const Translate *translate;
486 public:
487  OpBehaviorFloatRound(const Translate *trans) : OpBehavior(CPUI_FLOAT_ROUND,true) { translate = trans; }
488  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
489 };
490 
492 class OpBehaviorPiece : public OpBehavior {
493 public:
494  OpBehaviorPiece(void) : OpBehavior(CPUI_PIECE,false) {}
495  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
496 };
497 
500 public:
501  OpBehaviorSubpiece(void) : OpBehavior(CPUI_SUBPIECE,false) {}
502  virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
503 };
504 
507 public:
509  virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
510 };
511 
512 #endif
OpBehaviorFloatNotEqual
CPUI_FLOAT_NOTEQUAL behavior.
Definition: opbehavior.hh:356
OpBehaviorIntRight
CPUI_INT_RIGHT behavior.
Definition: opbehavior.hh:269
OpBehaviorIntZext
CPUI_INT_ZEXT behavior.
Definition: opbehavior.hh:173
CPUI_FLOAT_ROUND
@ CPUI_FLOAT_ROUND
Round towards nearest.
Definition: opcodes.hh:106
OpBehaviorFloatSqrt
CPUI_FLOAT_SQRT behavior.
Definition: opbehavior.hh:436
OpBehaviorIntRight::recoverInputBinary
virtual uintb recoverInputBinary(int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const
Reverse the binary op-code operation, recovering an input value.
Definition: opbehavior.cc:412
OpBehaviorIntSdiv
CPUI_INT_SDIV behavior.
Definition: opbehavior.hh:299
OpBehaviorIntSrem
CPUI_INT_SREM behavior.
Definition: opbehavior.hh:313
CPUI_FLOAT_NAN
@ CPUI_FLOAT_NAN
Not-a-number test (NaN)
Definition: opcodes.hh:91
CPUI_PIECE
@ CPUI_PIECE
Concatenate.
Definition: opcodes.hh:114
OpBehaviorFloatInt2Float::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:663
OpBehaviorFloatAdd::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:593
OpBehaviorInt2Comp
CPUI_INT_2COMP behavior.
Definition: opbehavior.hh:226
OpBehaviorIntSext::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:250
OpBehavior::registerInstructions
static void registerInstructions(vector< OpBehavior * > &inst, const Translate *trans)
Build all pcode behaviors.
Definition: opbehavior.cc:22
CPUI_INT_NEGATE
@ CPUI_INT_NEGATE
Logical/bitwise negation (~)
Definition: opcodes.hh:66
OpBehaviorNotEqual::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:174
LowlevelError
The lowest level error generated by the decompiler.
Definition: error.hh:44
CPUI_FLOAT_LESS
@ CPUI_FLOAT_LESS
Floating-point comparison, less-than (<)
Definition: opcodes.hh:88
CPUI_FLOAT_LESSEQUAL
@ CPUI_FLOAT_LESSEQUAL
Floating-point comparison, less-than-or-equal (<=)
Definition: opcodes.hh:89
CPUI_INT_DIV
@ CPUI_INT_DIV
Integer division, unsigned (/)
Definition: opcodes.hh:74
CPUI_FLOAT_NEG
@ CPUI_FLOAT_NEG
Floating-point negation (-)
Definition: opcodes.hh:97
OpBehaviorBoolOr
CPUI_BOOL_OR behavior.
Definition: opbehavior.hh:341
OpBehaviorIntZext::recoverInputUnary
virtual uintb recoverInputUnary(int4 sizeout, uintb out, int4 sizein) const
Reverse the unary op-code operation, recovering the input value.
Definition: opbehavior.cc:241
OpBehaviorFloatLess
CPUI_FLOAT_LESS behavior.
Definition: opbehavior.hh:364
OpBehaviorIntAdd::recoverInputBinary
virtual uintb recoverInputBinary(int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const
Reverse the binary op-code operation, recovering an input value.
Definition: opbehavior.cc:281
OpBehaviorIntSub::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:288
CPUI_INT_ADD
@ CPUI_INT_ADD
Addition, signed or unsigned (+)
Definition: opcodes.hh:60
error.hh
Base class for error handling facilities.
OpBehaviorFloatAbs
CPUI_FLOAT_ABS behavior.
Definition: opbehavior.hh:428
CPUI_INT_SDIV
@ CPUI_INT_SDIV
Integer division, signed (/)
Definition: opcodes.hh:75
CPUI_INT_SUB
@ CPUI_INT_SUB
Subtraction, signed or unsigned (-)
Definition: opcodes.hh:61
OpBehaviorFloatTrunc::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:686
OpBehaviorIntScarry::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:314
OpBehaviorPiece::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:726
CPUI_INT_EQUAL
@ CPUI_INT_EQUAL
Integer comparison, equality (==)
Definition: opcodes.hh:51
OpBehaviorFloatInt2Float
CPUI_FLOAT_INT2FLOAT behavior.
Definition: opbehavior.hh:444
OpBehaviorFloatSub::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:623
CPUI_FLOAT_SUB
@ CPUI_FLOAT_SUB
Floating-point subtraction (-)
Definition: opcodes.hh:96
OpBehaviorIntXor
CPUI_INT_XOR behavior.
Definition: opbehavior.hh:240
CPUI_SUBPIECE
@ CPUI_SUBPIECE
Truncate.
Definition: opcodes.hh:115
CPUI_INT_LESSEQUAL
@ CPUI_INT_LESSEQUAL
Integer comparison, unsigned less-than-or-equal (<=)
Definition: opcodes.hh:57
OpBehaviorFloatNeg::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:633
OpBehaviorIntXor::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:360
OpBehaviorFloatNan::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:583
OpBehaviorFloatFloat2Float::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:673
CPUI_INT_2COMP
@ CPUI_INT_2COMP
Twos complement.
Definition: opcodes.hh:65
CPUI_FLOAT_ADD
@ CPUI_FLOAT_ADD
Floating-point addition (+)
Definition: opcodes.hh:93
OpBehaviorIntSext
CPUI_INT_SEXT behavior.
Definition: opbehavior.hh:181
OpBehaviorFloatMult::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:613
OpBehaviorFloatLess::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:563
OpBehavior::isSpecial
bool isSpecial(void) const
Check if this is a special operator.
Definition: opbehavior.hh:110
CPUI_INT_OR
@ CPUI_INT_OR
Logical/bitwise or (|)
Definition: opcodes.hh:69
OpBehaviorIntLess::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:221
CPUI_INT_NOTEQUAL
@ CPUI_INT_NOTEQUAL
Integer comparison, in-equality (!=)
Definition: opcodes.hh:52
CPUI_FLOAT_DIV
@ CPUI_FLOAT_DIV
Floating-point division (/)
Definition: opcodes.hh:94
OpBehaviorCopy::recoverInputUnary
virtual uintb recoverInputUnary(int4 sizeout, uintb out, int4 sizein) const
Reverse the unary op-code operation, recovering the input value.
Definition: opbehavior.cc:161
CPUI_INT_LEFT
@ CPUI_INT_LEFT
Left shift (<<)
Definition: opcodes.hh:70
OpBehaviorFloatRound::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:716
OpBehaviorFloatRound
CPUI_FLOAT_ROUND behavior.
Definition: opbehavior.hh:484
CPUI_BOOL_OR
@ CPUI_BOOL_OR
Boolean or (||)
Definition: opcodes.hh:82
OpBehaviorBoolAnd
CPUI_BOOL_AND behavior.
Definition: opbehavior.hh:334
CPUI_INT_SRIGHT
@ CPUI_INT_SRIGHT
Right shift, arithmetic (>>)
Definition: opcodes.hh:72
OpBehaviorIntRem::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:491
OpBehavior
Class encapsulating the action/behavior of specific pcode opcodes.
Definition: opbehavior.hh:42
OpBehaviorBoolNegate
CPUI_BOOL_NEGATE behavior.
Definition: opbehavior.hh:320
OpBehavior::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:123
OpBehaviorIntCarry::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:307
CPUI_FLOAT_EQUAL
@ CPUI_FLOAT_EQUAL
Floating-point comparison, equality (==)
Definition: opcodes.hh:86
OpBehaviorIntMult::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:462
OpBehaviorIntAnd::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:367
OpBehaviorBoolXor::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:522
CPUI_FLOAT_SQRT
@ CPUI_FLOAT_SQRT
Floating-point square root (sqrt)
Definition: opcodes.hh:99
OpBehaviorIntCarry
CPUI_INT_CARRY behavior.
Definition: opbehavior.hh:205
CPUI_BOOL_NEGATE
@ CPUI_BOOL_NEGATE
Boolean negate (!)
Definition: opcodes.hh:79
OpBehaviorEqual
CPUI_INT_EQUAL behavior.
Definition: opbehavior.hh:131
OpBehaviorBoolNegate::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:515
CPUI_INT_ZEXT
@ CPUI_INT_ZEXT
Zero extension.
Definition: opcodes.hh:58
CPUI_INT_RIGHT
@ CPUI_INT_RIGHT
Right shift, logical (>>)
Definition: opcodes.hh:71
CPUI_BOOL_AND
@ CPUI_BOOL_AND
Boolean and (&&)
Definition: opcodes.hh:81
OpBehaviorIntNegate::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:353
OpBehaviorFloatNeg
CPUI_FLOAT_NEG behavior.
Definition: opbehavior.hh:420
OpBehaviorFloatLessEqual
CPUI_FLOAT_LESSEQUAL behavior.
Definition: opbehavior.hh:372
CPUI_FLOAT_FLOOR
@ CPUI_FLOAT_FLOOR
Round towards -infinity.
Definition: opcodes.hh:105
CPUI_INT_SREM
@ CPUI_INT_SREM
Remainder/modulo, signed (%)
Definition: opcodes.hh:77
OpBehaviorIntDiv::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:469
OpBehaviorFloatNan
CPUI_FLOAT_NAN behavior.
Definition: opbehavior.hh:380
OpBehavior::OpBehavior
OpBehavior(OpCode opc, bool isun)
A behavior constructor.
Definition: opbehavior.hh:80
OpBehaviorFloatFloor
CPUI_FLOAT_FLOOR behavior.
Definition: opbehavior.hh:476
OpBehaviorIntSlessEqual::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:201
OpBehaviorFloatSub
CPUI_FLOAT_SUB behavior.
Definition: opbehavior.hh:412
OpBehaviorBoolAnd::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:529
OpBehaviorIntLessEqual::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:228
OpBehaviorIntSless
CPUI_INT_SLESS behavior.
Definition: opbehavior.hh:145
CPUI_FLOAT_CEIL
@ CPUI_FLOAT_CEIL
Round towards +infinity.
Definition: opcodes.hh:104
OpBehaviorFloatDiv::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:603
CPUI_POPCOUNT
@ CPUI_POPCOUNT
Count the 1-bits.
Definition: opcodes.hh:125
OpBehaviorIntMult
CPUI_INT_MULT behavior.
Definition: opbehavior.hh:285
OpBehaviorIntSub
CPUI_INT_SUB behavior.
Definition: opbehavior.hh:197
OpBehaviorBoolOr::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:536
CPUI_INT_SEXT
@ CPUI_INT_SEXT
Sign extension.
Definition: opcodes.hh:59
opcodes.hh
All the individual p-code operations.
OpBehaviorIntLeft
CPUI_INT_LEFT behavior.
Definition: opbehavior.hh:261
OpBehaviorSubpiece
CPUI_SUBPIECE behavior.
Definition: opbehavior.hh:499
CPUI_INT_LESS
@ CPUI_INT_LESS
Integer comparison, unsigned less-than (<)
Definition: opcodes.hh:55
OpBehaviorFloatFloat2Float
CPUI_FLOAT_FLOAT2FLOAT behavior.
Definition: opbehavior.hh:452
OpBehaviorIntZext::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:235
OpBehaviorFloatCeil
CPUI_FLOAT_CEIL behavior.
Definition: opbehavior.hh:468
CPUI_FLOAT_NOTEQUAL
@ CPUI_FLOAT_NOTEQUAL
Floating-point comparison, in-equality (!=)
Definition: opcodes.hh:87
OpBehaviorIntSub::recoverInputBinary
virtual uintb recoverInputBinary(int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const
Reverse the binary op-code operation, recovering an input value.
Definition: opbehavior.cc:295
OpBehaviorIntLess
CPUI_INT_LESS behavior.
Definition: opbehavior.hh:159
EvaluationError
Definition: opbehavior.hh:28
OpBehaviorSubpiece::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:733
OpBehaviorFloatFloor::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:706
OpBehaviorIntSrem::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:501
LowlevelError::LowlevelError
LowlevelError(const string &s)
Initialize the error with an explanatory string.
Definition: error.hh:47
OpBehaviorFloatTrunc
CPUI_FLOAT_TRUNC behavior.
Definition: opbehavior.hh:460
CPUI_BOOL_XOR
@ CPUI_BOOL_XOR
Boolean exclusive-or (^^)
Definition: opcodes.hh:80
OpBehaviorEqual::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:167
OpBehaviorFloatLessEqual::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:573
OpBehaviorNotEqual
CPUI_INT_NOTEQUAL behavior.
Definition: opbehavior.hh:138
CPUI_INT_XOR
@ CPUI_INT_XOR
Logical/bitwise exclusive-or (^)
Definition: opcodes.hh:67
OpBehaviorIntSright
CPUI_INT_SRIGHT behavior.
Definition: opbehavior.hh:277
Translate
The interface to a translation engine for a processor.
Definition: translate.hh:294
OpBehaviorIntLeft::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:381
OpBehavior::getOpcode
OpCode getOpcode(void) const
Get the opcode for this pcode operation.
Definition: opbehavior.hh:103
OpBehaviorFloatMult
CPUI_FLOAT_MULT behavior.
Definition: opbehavior.hh:404
OpBehaviorIntSless::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:181
OpBehaviorPopcount::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:740
OpBehaviorIntSright::recoverInputBinary
virtual uintb recoverInputBinary(int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const
Reverse the binary op-code operation, recovering an input value.
Definition: opbehavior.cc:444
CPUI_INT_CARRY
@ CPUI_INT_CARRY
Test for unsigned carry.
Definition: opcodes.hh:62
OpBehaviorFloatCeil::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:696
CPUI_INT_SCARRY
@ CPUI_INT_SCARRY
Test for signed carry.
Definition: opcodes.hh:63
OpBehaviorIntDiv
CPUI_INT_DIV behavior.
Definition: opbehavior.hh:292
OpCode
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
OpBehaviorIntSdiv::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:477
OpBehaviorIntSborrow
CPUI_INT_SBORROW behavior.
Definition: opbehavior.hh:219
CPUI_FLOAT_ABS
@ CPUI_FLOAT_ABS
Floating-point absolute value (abs)
Definition: opcodes.hh:98
OpBehaviorFloatSqrt::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:653
OpBehaviorFloatEqual
CPUI_FLOAT_EQUAL behavior.
Definition: opbehavior.hh:348
OpBehaviorIntRight::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:402
OpBehavior::isUnary
bool isUnary(void) const
Check if operator is unary.
Definition: opbehavior.hh:116
CPUI_INT_AND
@ CPUI_INT_AND
Logical/bitwise and (&)
Definition: opcodes.hh:68
OpBehaviorIntLeft::recoverInputBinary
virtual uintb recoverInputBinary(int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const
Reverse the binary op-code operation, recovering an input value.
Definition: opbehavior.cc:391
OpBehaviorIntOr::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:374
OpBehavior::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:111
CPUI_INT_REM
@ CPUI_INT_REM
Remainder/modulo, unsigned (%)
Definition: opcodes.hh:76
OpBehaviorIntSborrow::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:330
CPUI_FLOAT_FLOAT2FLOAT
@ CPUI_FLOAT_FLOAT2FLOAT
Convert between different floating-point sizes.
Definition: opcodes.hh:102
OpBehaviorPiece
CPUI_PIECE behavior.
Definition: opbehavior.hh:492
CPUI_INT_SLESSEQUAL
@ CPUI_INT_SLESSEQUAL
Integer comparison, signed less-than-or-equal (<=)
Definition: opcodes.hh:54
CPUI_INT_SBORROW
@ CPUI_INT_SBORROW
Test for signed borrow.
Definition: opcodes.hh:64
OpBehaviorInt2Comp::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:346
CPUI_COPY
@ CPUI_COPY
Copy one operand to another.
Definition: opcodes.hh:36
OpBehaviorIntAdd
CPUI_INT_ADD behavior.
Definition: opbehavior.hh:189
OpBehaviorCopy::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:155
OpBehaviorCopy
CPUI_COPY behavior.
Definition: opbehavior.hh:123
OpBehaviorFloatNotEqual::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:553
OpBehavior::recoverInputBinary
virtual uintb recoverInputBinary(int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const
Reverse the binary op-code operation, recovering an input value.
Definition: opbehavior.cc:149
OpBehaviorFloatDiv
CPUI_FLOAT_DIV behavior.
Definition: opbehavior.hh:396
OpBehaviorIntLessEqual
CPUI_INT_LESSEQUAL behavior.
Definition: opbehavior.hh:166
OpBehaviorIntSlessEqual
CPUI_INT_SLESSEQUAL behavior.
Definition: opbehavior.hh:152
OpBehaviorIntScarry
CPUI_INT_SCARRY behavior.
Definition: opbehavior.hh:212
OpBehaviorIntAdd::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:274
OpBehaviorIntAnd
CPUI_INT_AND behavior.
Definition: opbehavior.hh:247
OpBehaviorIntSright::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:424
CPUI_FLOAT_MULT
@ CPUI_FLOAT_MULT
Floating-point multiplication (*)
Definition: opcodes.hh:95
OpBehaviorBoolXor
CPUI_BOOL_XOR behavior.
Definition: opbehavior.hh:327
OpBehaviorIntNegate
CPUI_INT_NEGATE behavior.
Definition: opbehavior.hh:233
CPUI_FLOAT_TRUNC
@ CPUI_FLOAT_TRUNC
Round towards zero.
Definition: opcodes.hh:103
CPUI_FLOAT_INT2FLOAT
@ CPUI_FLOAT_INT2FLOAT
Convert an integer to a floating-point.
Definition: opcodes.hh:101
OpBehavior::recoverInputUnary
virtual uintb recoverInputUnary(int4 sizeout, uintb out, int4 sizein) const
Reverse the unary op-code operation, recovering the input value.
Definition: opbehavior.cc:135
OpBehaviorPopcount
CPUI_POPCOUNT behavior.
Definition: opbehavior.hh:506
OpBehaviorFloatAbs::evaluateUnary
virtual uintb evaluateUnary(int4 sizeout, int4 sizein, uintb in1) const
Emulate the unary op-code on an input value.
Definition: opbehavior.cc:643
CPUI_INT_MULT
@ CPUI_INT_MULT
Integer multiplication, signed and unsigned (*)
Definition: opcodes.hh:73
CPUI_INT_SLESS
@ CPUI_INT_SLESS
Integer comparison, signed less-than (<)
Definition: opcodes.hh:53
OpBehaviorIntSext::recoverInputUnary
virtual uintb recoverInputUnary(int4 sizeout, uintb out, int4 sizein) const
Reverse the unary op-code operation, recovering the input value.
Definition: opbehavior.cc:257
OpBehaviorIntOr
CPUI_INT_OR behavior.
Definition: opbehavior.hh:254
OpBehaviorFloatEqual::evaluateBinary
virtual uintb evaluateBinary(int4 sizeout, int4 sizein, uintb in1, uintb in2) const
Emulate the binary op-code on input values.
Definition: opbehavior.cc:543
OpBehaviorFloatAdd
CPUI_FLOAT_ADD behavior.
Definition: opbehavior.hh:388
OpBehaviorIntRem
CPUI_INT_REM behavior.
Definition: opbehavior.hh:306