forked from cseagle/blc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opbehavior.hh
512 lines (437 loc) · 20 KB
/
opbehavior.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// \file opbehavior.hh
/// \brief Classes for describing the behavior of individual p-code operations
#ifndef __CPUI_OPBEHAVIOR__
#define __CPUI_OPBEHAVIOR__
#include "error.hh"
#include "opcodes.hh"
class Translate; // Forward declaration
/// This exception is thrown when emulation evaluation of an operator fails for some reason.
/// This can be thrown for either forward or reverse emulation
struct EvaluationError : public LowlevelError {
EvaluationError(const string &s) : LowlevelError(s) {} ///< Initialize the error with an explanatory string
};
/// \brief Class encapsulating the action/behavior of specific pcode opcodes
///
/// At the lowest level, a pcode op is one of a small set of opcodes that
/// operate on varnodes (address space, offset, size). Classes derived from
/// this base class encapsulate this basic behavior for each possible opcode.
/// These classes describe the most basic behaviors and include:
/// * uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb int2)
/// * uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1)
/// * uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in)
/// * uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein)
class OpBehavior {
OpCode opcode; ///< the internal enumeration for pcode types
bool isunary; ///< true= use unary interfaces, false = use binary
bool isspecial; ///< Is op not a normal unary or binary op
public:
OpBehavior(OpCode opc,bool isun); ///< A behavior constructor
OpBehavior(OpCode opc,bool isun,bool isspec); ///< A special behavior constructor
virtual ~OpBehavior(void) {}
/// \brief Get the opcode for this pcode operation
OpCode getOpcode(void) const;
/// \brief Check if this is a special operator
bool isSpecial(void) const;
/// \brief Check if operator is unary
bool isUnary(void) const;
/// \brief Emulate the unary op-code on an input value
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
/// \brief Emulate the binary op-code on input values
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
/// \brief Reverse the binary op-code operation, recovering an input value
virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
/// \brief Reverse the unary op-code operation, recovering the input value
virtual uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein) const;
static void registerInstructions(vector<OpBehavior *> &inst,const Translate *trans); ///< Build all pcode behaviors
};
/// This kind of OpBehavior is associated with a particular opcode and is either unary or binary
/// \param opc is the opcode of the behavior
/// \param isun is \b true if the behavior is unary, \b false if binary
inline OpBehavior::OpBehavior(OpCode opc,bool isun)
{
opcode = opc;
isunary = isun;
isspecial = false;
}
/// This kind of OpBehavior can be set to \b special, if it neither unary or binary.
/// \param opc is the opcode of the behavior
/// \param isun is \b true if the behavior is unary
/// \param isspec is \b true if the behavior is neither unary or binary
inline OpBehavior::OpBehavior(OpCode opc,bool isun,bool isspec)
{
opcode = opc;
isunary = isun;
isspecial = isspec;
}
/// There is an internal enumeration value for each type of pcode operation.
/// This routine returns that value.
/// \return the opcode value
inline OpCode OpBehavior::getOpcode(void) const {
return opcode;
}
/// If this function returns false, the operation is a normal unary or binary operation
/// which can be evaluated calling evaluateBinary() or evaluateUnary().
/// Otherwise, the operation requires special handling to emulate properly
inline bool OpBehavior::isSpecial(void) const {
return isspecial;
}
/// The operated can either be evaluated as unary or binary
/// \return \b true if the operator is unary
inline bool OpBehavior::isUnary(void) const {
return isunary;
}
// A class for each opcode
/// CPUI_COPY behavior
class OpBehaviorCopy : public OpBehavior {
public:
OpBehaviorCopy(void) : OpBehavior(CPUI_COPY,true) {} ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
virtual uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein) const;
};
/// CPUI_INT_EQUAL behavior
class OpBehaviorEqual : public OpBehavior {
public:
OpBehaviorEqual(void) : OpBehavior(CPUI_INT_EQUAL,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_NOTEQUAL behavior
class OpBehaviorNotEqual : public OpBehavior {
public:
OpBehaviorNotEqual(void) : OpBehavior(CPUI_INT_NOTEQUAL,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_SLESS behavior
class OpBehaviorIntSless : public OpBehavior {
public:
OpBehaviorIntSless(void) : OpBehavior(CPUI_INT_SLESS,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_SLESSEQUAL behavior
class OpBehaviorIntSlessEqual : public OpBehavior {
public:
OpBehaviorIntSlessEqual(void) : OpBehavior(CPUI_INT_SLESSEQUAL,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_LESS behavior
class OpBehaviorIntLess : public OpBehavior {
public:
OpBehaviorIntLess(void) : OpBehavior(CPUI_INT_LESS,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_LESSEQUAL behavior
class OpBehaviorIntLessEqual : public OpBehavior {
public:
OpBehaviorIntLessEqual(void): OpBehavior(CPUI_INT_LESSEQUAL,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_ZEXT behavior
class OpBehaviorIntZext : public OpBehavior {
public:
OpBehaviorIntZext(void): OpBehavior(CPUI_INT_ZEXT,true) {} ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
virtual uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein) const;
};
/// CPUI_INT_SEXT behavior
class OpBehaviorIntSext : public OpBehavior {
public:
OpBehaviorIntSext(void): OpBehavior(CPUI_INT_SEXT,true) {} ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
virtual uintb recoverInputUnary(int4 sizeout,uintb out,int4 sizein) const;
};
/// CPUI_INT_ADD behavior
class OpBehaviorIntAdd : public OpBehavior {
public:
OpBehaviorIntAdd(void): OpBehavior(CPUI_INT_ADD,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
};
/// CPUI_INT_SUB behavior
class OpBehaviorIntSub : public OpBehavior {
public:
OpBehaviorIntSub(void): OpBehavior(CPUI_INT_SUB,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
};
/// CPUI_INT_CARRY behavior
class OpBehaviorIntCarry : public OpBehavior {
public:
OpBehaviorIntCarry(void): OpBehavior(CPUI_INT_CARRY,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_SCARRY behavior
class OpBehaviorIntScarry : public OpBehavior {
public:
OpBehaviorIntScarry(void): OpBehavior(CPUI_INT_SCARRY,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_SBORROW behavior
class OpBehaviorIntSborrow : public OpBehavior {
public:
OpBehaviorIntSborrow(void): OpBehavior(CPUI_INT_SBORROW,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_2COMP behavior
class OpBehaviorInt2Comp : public OpBehavior {
public:
OpBehaviorInt2Comp(void): OpBehavior(CPUI_INT_2COMP,true) {} ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_INT_NEGATE behavior
class OpBehaviorIntNegate : public OpBehavior {
public:
OpBehaviorIntNegate(void): OpBehavior(CPUI_INT_NEGATE,true) {} ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_INT_XOR behavior
class OpBehaviorIntXor : public OpBehavior {
public:
OpBehaviorIntXor(void): OpBehavior(CPUI_INT_XOR,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_AND behavior
class OpBehaviorIntAnd : public OpBehavior {
public:
OpBehaviorIntAnd(void): OpBehavior(CPUI_INT_AND,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_OR behavior
class OpBehaviorIntOr : public OpBehavior {
public:
OpBehaviorIntOr(void): OpBehavior(CPUI_INT_OR,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_LEFT behavior
class OpBehaviorIntLeft : public OpBehavior {
public:
OpBehaviorIntLeft(void): OpBehavior(CPUI_INT_LEFT,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
};
/// CPUI_INT_RIGHT behavior
class OpBehaviorIntRight : public OpBehavior {
public:
OpBehaviorIntRight(void): OpBehavior(CPUI_INT_RIGHT,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
};
/// CPUI_INT_SRIGHT behavior
class OpBehaviorIntSright : public OpBehavior {
public:
OpBehaviorIntSright(void): OpBehavior(CPUI_INT_SRIGHT,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
virtual uintb recoverInputBinary(int4 slot,int4 sizeout,uintb out,int4 sizein,uintb in) const;
};
/// CPUI_INT_MULT behavior
class OpBehaviorIntMult : public OpBehavior {
public:
OpBehaviorIntMult(void): OpBehavior(CPUI_INT_MULT,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_DIV behavior
class OpBehaviorIntDiv : public OpBehavior {
public:
OpBehaviorIntDiv(void): OpBehavior(CPUI_INT_DIV,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_SDIV behavior
class OpBehaviorIntSdiv : public OpBehavior {
public:
OpBehaviorIntSdiv(void): OpBehavior(CPUI_INT_SDIV,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_REM behavior
class OpBehaviorIntRem : public OpBehavior {
public:
OpBehaviorIntRem(void): OpBehavior(CPUI_INT_REM,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_INT_SREM behavior
class OpBehaviorIntSrem : public OpBehavior {
public:
OpBehaviorIntSrem(void): OpBehavior(CPUI_INT_SREM,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_BOOL_NEGATE behavior
class OpBehaviorBoolNegate : public OpBehavior {
public:
OpBehaviorBoolNegate(void): OpBehavior(CPUI_BOOL_NEGATE,true) {} ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_BOOL_XOR behavior
class OpBehaviorBoolXor : public OpBehavior {
public:
OpBehaviorBoolXor(void): OpBehavior(CPUI_BOOL_XOR,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_BOOL_AND behavior
class OpBehaviorBoolAnd : public OpBehavior {
public:
OpBehaviorBoolAnd(void): OpBehavior(CPUI_BOOL_AND,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_BOOL_OR behavior
class OpBehaviorBoolOr : public OpBehavior {
public:
OpBehaviorBoolOr(void): OpBehavior(CPUI_BOOL_OR,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_EQUAL behavior
class OpBehaviorFloatEqual : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatEqual(const Translate *trans): OpBehavior(CPUI_FLOAT_EQUAL,false) { translate = trans; } ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_NOTEQUAL behavior
class OpBehaviorFloatNotEqual : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatNotEqual(const Translate *trans): OpBehavior(CPUI_FLOAT_NOTEQUAL,false) { translate = trans; } ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_LESS behavior
class OpBehaviorFloatLess : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatLess(const Translate *trans) : OpBehavior(CPUI_FLOAT_LESS,false) { translate = trans; } ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_LESSEQUAL behavior
class OpBehaviorFloatLessEqual : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatLessEqual(const Translate *trans) : OpBehavior(CPUI_FLOAT_LESSEQUAL,false) { translate = trans; } ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_NAN behavior
class OpBehaviorFloatNan : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatNan(const Translate *trans) : OpBehavior(CPUI_FLOAT_NAN,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_ADD behavior
class OpBehaviorFloatAdd : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatAdd(const Translate *trans) : OpBehavior(CPUI_FLOAT_ADD,false) { translate = trans; } ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_DIV behavior
class OpBehaviorFloatDiv : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatDiv(const Translate *trans) : OpBehavior(CPUI_FLOAT_DIV,false) { translate = trans; } ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_MULT behavior
class OpBehaviorFloatMult : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatMult(const Translate *trans) : OpBehavior(CPUI_FLOAT_MULT,false) { translate = trans; } ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_SUB behavior
class OpBehaviorFloatSub : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatSub(const Translate *trans) : OpBehavior(CPUI_FLOAT_SUB,false) { translate = trans; } ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_FLOAT_NEG behavior
class OpBehaviorFloatNeg : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatNeg(const Translate *trans) : OpBehavior(CPUI_FLOAT_NEG,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_ABS behavior
class OpBehaviorFloatAbs : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatAbs(const Translate *trans) : OpBehavior(CPUI_FLOAT_ABS,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_SQRT behavior
class OpBehaviorFloatSqrt : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatSqrt(const Translate *trans) : OpBehavior(CPUI_FLOAT_SQRT,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_INT2FLOAT behavior
class OpBehaviorFloatInt2Float : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatInt2Float(const Translate *trans) : OpBehavior(CPUI_FLOAT_INT2FLOAT,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_FLOAT2FLOAT behavior
class OpBehaviorFloatFloat2Float : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatFloat2Float(const Translate *trans) : OpBehavior(CPUI_FLOAT_FLOAT2FLOAT,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_TRUNC behavior
class OpBehaviorFloatTrunc : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatTrunc(const Translate *trans) : OpBehavior(CPUI_FLOAT_TRUNC,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_CEIL behavior
class OpBehaviorFloatCeil : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatCeil(const Translate *trans) : OpBehavior(CPUI_FLOAT_CEIL,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_FLOOR behavior
class OpBehaviorFloatFloor : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatFloor(const Translate *trans) : OpBehavior(CPUI_FLOAT_FLOOR,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_FLOAT_ROUND behavior
class OpBehaviorFloatRound : public OpBehavior {
const Translate *translate; ///< Translate object for recovering float format
public:
OpBehaviorFloatRound(const Translate *trans) : OpBehavior(CPUI_FLOAT_ROUND,true) { translate = trans; } ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
/// CPUI_PIECE behavior
class OpBehaviorPiece : public OpBehavior {
public:
OpBehaviorPiece(void) : OpBehavior(CPUI_PIECE,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_SUBPIECE behavior
class OpBehaviorSubpiece : public OpBehavior {
public:
OpBehaviorSubpiece(void) : OpBehavior(CPUI_SUBPIECE,false) {} ///< Constructor
virtual uintb evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const;
};
/// CPUI_POPCOUNT behavior
class OpBehaviorPopcount : public OpBehavior {
public:
OpBehaviorPopcount(void) : OpBehavior(CPUI_POPCOUNT,true) {} ///< Constructor
virtual uintb evaluateUnary(int4 sizeout,int4 sizein,uintb in1) const;
};
#endif