-
Notifications
You must be signed in to change notification settings - Fork 139
/
Copy pathARMOps2.hpp
82 lines (61 loc) · 3.02 KB
/
ARMOps2.hpp
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
/*******************************************************************************
*
* (c) Copyright IBM Corp. 2000, 2016
*
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0 and
* Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* Contributors:
* Multiple authors (IBM Corp.) - initial implementation and documentation
*******************************************************************************/
#include <stdint.h>
#define ARMOpProp_HasRecordForm 0x00000001
#define ARMOpProp_SetsCarryFlag 0x00000002
#define ARMOpProp_SetsOverflowFlag 0x00000004
#define ARMOpProp_ReadsCarryFlag 0x00000008
#define ARMOpProp_BranchOp 0x00000040
#define ARMOpProp_VFP 0x00000080
#define ARMOpProp_DoubleFP 0x00000100
#define ARMOpProp_SingleFP 0x00000200
#define ARMOpProp_UpdateForm 0x00000400
#define ARMOpProp_Arch4 0x00000800
#define ARMOpProp_IsRecordForm 0x00001000
#define ARMOpProp_Label 0x00002000
#define ARMOpProp_Arch6 0x00004000
class TR_ARMOpCode
{
typedef uint32_t TR_OpCodeBinaryEntry;
TR_ARMOpCodes _opCode;
static const uint32_t properties[ARMNumOpCodes];
static const TR_OpCodeBinaryEntry binaryEncodings[ARMNumOpCodes];
public:
TR_ARMOpCode() : _opCode(ARMOp_bad) {}
TR_ARMOpCode(TR_ARMOpCodes op) : _opCode(op) {}
TR_ARMOpCodes getOpCodeValue() {return _opCode;}
TR_ARMOpCodes setOpCodeValue(TR_ARMOpCodes op) {return (_opCode = op);}
TR_ARMOpCodes getRecordFormOpCodeValue() {return (TR_ARMOpCodes)(_opCode+1);}
uint32_t isRecordForm() {return properties[_opCode] & ARMOpProp_IsRecordForm;}
uint32_t hasRecordForm() {return properties[_opCode] & ARMOpProp_HasRecordForm;}
uint32_t singleFPOp() {return properties[_opCode] & ARMOpProp_SingleFP;}
uint32_t doubleFPOp() {return properties[_opCode] & ARMOpProp_DoubleFP;}
uint32_t isVFPOp() {return properties[_opCode] & ARMOpProp_VFP;}
uint32_t gprOp() {return (properties[_opCode] & (ARMOpProp_DoubleFP | ARMOpProp_SingleFP)) == 0;}
uint32_t fprOp() {return (properties[_opCode] & (ARMOpProp_DoubleFP | ARMOpProp_SingleFP));}
uint32_t readsCarryFlag() {return properties[_opCode] & ARMOpProp_ReadsCarryFlag;}
uint32_t setsCarryFlag() {return properties[_opCode] & ARMOpProp_SetsCarryFlag;}
uint32_t setsOverflowFlag() {return properties[_opCode] & ARMOpProp_SetsOverflowFlag;}
uint32_t isBranchOp() {return properties[_opCode] & ARMOpProp_BranchOp;}
uint32_t isLabel() {return properties[_opCode] & ARMOpProp_Label;}
uint8_t *copyBinaryToBuffer(uint8_t *cursor)
{
*(uint32_t *)cursor = *(uint32_t *)&binaryEncodings[_opCode];
return cursor;
}
};