libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
armOperandProperties.cpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
9#include <triton/cpuSize.hpp>
10#include <triton/exceptions.hpp>
11
12
13
14namespace triton {
15 namespace arch {
16 namespace arm {
17
28
29
31 this->extendSize = other.extendSize;
32 this->extendType = other.extendType;
33 this->shiftType = other.shiftType;
36 this->subtracted = other.subtracted;
37 this->vasType = other.vasType;
38 this->vectorIndex = other.vectorIndex;
39 }
40
41
43 this->extendSize = other.extendSize;
44 this->extendType = other.extendType;
45 this->shiftType = other.shiftType;
48 this->subtracted = other.subtracted;
49 this->vasType = other.vasType;
50 this->vectorIndex = other.vectorIndex;
51 return *this;
52 }
53
54
58
59
63
64
68
69
73
74
78
79
83
84
85 std::string ArmOperandProperties::getVASName(void) const {
86 switch (this->vasType) {
87 case ID_VAS_16B: return "16B";
88 case ID_VAS_8B: return "8B";
89 case ID_VAS_4B: return "4B";
90 case ID_VAS_1B: return "1B";
91 case ID_VAS_8H: return "8H";
92 case ID_VAS_4H: return "4H";
93 case ID_VAS_2H: return "2H";
94 case ID_VAS_1H: return "1H";
95 case ID_VAS_4S: return "4S";
96 case ID_VAS_2S: return "2S";
97 case ID_VAS_1S: return "1S";
98 case ID_VAS_2D: return "2D";
99 case ID_VAS_1D: return "1D";
100 case ID_VAS_1Q: return "1Q";
101 default: return "invalid";
102 }
103 }
104
105
107 switch (this->vasType) {
108 case ID_VAS_16B: [[fallthrough]];
109 case ID_VAS_8H: [[fallthrough]];
110 case ID_VAS_4S: [[fallthrough]];
111 case ID_VAS_2D: return triton::size::dqword;
112 case ID_VAS_8B: [[fallthrough]];
113 case ID_VAS_4H: [[fallthrough]];
114 case ID_VAS_2S: [[fallthrough]];
115 case ID_VAS_1D: [[fallthrough]];
116 case ID_VAS_1Q: return triton::size::qword;
117 case ID_VAS_4B: [[fallthrough]];
118 case ID_VAS_1S: [[fallthrough]];
119 case ID_VAS_2H: return triton::size::dword;
120 case ID_VAS_1H: return triton::size::word;
121 case ID_VAS_1B: return triton::size::byte;
122
123 default: return 0;
124 }
125 }
126
127
129 return this->extendSize;
130 }
131
132
134 return this->subtracted;
135 }
136
137
141
142
146
147
150 throw triton::exceptions::ArmOperandProperties("ArmOperandProperties::setShiftType(): invalid type of shift.");
151 this->shiftType = type;
152 }
153
154
157 throw triton::exceptions::ArmOperandProperties("ArmOperandProperties::setExtendType(): invalid type of extend.");
158 this->extendType = type;
159 }
160
161
164 throw triton::exceptions::ArmOperandProperties("ArmOperandProperties::setVASType(): invalid type of VAS.");
165 this->vasType = type;
166 }
167
168
170 switch (this->extendType) {
173 this->extendSize = dstSize - 8;
174 break;
175
178 this->extendSize = dstSize - 16;
179 break;
180
183 this->extendSize = dstSize - 32;
184 break;
185
188 this->extendSize = dstSize - 64;
189 break;
190
191 default:
192 throw triton::exceptions::ArmOperandProperties("ArmOperandProperties::setExtendedSize(): invalid type of extend");
193 }
194
195 if (this->extendSize > 64)
196 throw triton::exceptions::ArmOperandProperties("ArmOperandProperties::setExtendedSize(): invalid size of extension (integer overflow).");
197
198 if (dstSize != 8 && dstSize != 16 && dstSize != 32 && dstSize != 64)
199 throw triton::exceptions::ArmOperandProperties("ArmOperandProperties::setExtendedSize(): size must be 8, 16, 32 or 64.");
200 }
201
202
204 this->subtracted = value;
205 }
206
207
211
212 }; /* arm namespace */
213 }; /* arch namespace */
214}; /* triton namespace */
This class is used to represent specific properties of an Arm operand.
triton::arch::register_e shiftValueRegister
The shift value register.
triton::arch::arm::shift_e shiftType
The shift type.
TRITON_EXPORT void setVectorIndex(triton::sint32 index)
Sets the vector index.
TRITON_EXPORT ArmOperandProperties & operator=(const ArmOperandProperties &other)
Copy an ArmOperandProperties.
TRITON_EXPORT triton::arch::arm::shift_e getShiftType(void) const
Returns the type of the shift.
TRITON_EXPORT triton::arch::register_e getShiftRegister(void) const
Returns the value of the shift register.
TRITON_EXPORT void setVASType(triton::arch::arm::vas_e type)
Sets the type of vector arrangement specifier.
triton::arch::arm::vas_e vasType
Vector arrangement specifier.
TRITON_EXPORT triton::arch::arm::extend_e getExtendType(void) const
Returns the type of the extend.
TRITON_EXPORT void setShiftType(triton::arch::arm::shift_e type)
Sets the type of the shift.
TRITON_EXPORT void setExtendedSize(triton::uint32 dstSize)
Sets the extended size (in bits) after extension.
TRITON_EXPORT std::string getVASName(void) const
Returns the vector arrangement specifier string name.
TRITON_EXPORT triton::uint32 getExtendSize(void) const
Returns the size (in bits) of the extend.
TRITON_EXPORT void setSubtracted(bool value)
Sets subtracted flag.
TRITON_EXPORT ArmOperandProperties()
Constructor.
TRITON_EXPORT void setExtendType(triton::arch::arm::extend_e type)
Sets the type of the extend.
bool subtracted
The subtracted flag. Used in memory access operands and determines whether this operand has to be add...
triton::uint32 shiftValueImmediate
The shift value immediate.
TRITON_EXPORT triton::sint32 getVectorIndex(void) const
Returns the vector index (-1 if irrelevant).
TRITON_EXPORT triton::uint32 getShiftImmediate(void) const
Returns the value of the shift immediate.
TRITON_EXPORT triton::arch::arm::vas_e getVASType(void) const
Returns the vector arrangement specifier.
TRITON_EXPORT bool isSubtracted(void) const
Returns true if the operand has to be subtracted when computing a memory access.
triton::uint32 extendSize
The extend size (in bits).
triton::sint32 vectorIndex
Vector index (-1 if irrelevant).
TRITON_EXPORT triton::uint32 getVASSize(void) const
Returns the vector arrangement specifier size (64 or 128 bits).
TRITON_EXPORT void setShiftValue(triton::uint32 imm)
Sets the value of the shift immediate.
triton::arch::arm::extend_e extendType
The extend type.
The exception class used by shift mode.
register_e
Types of register.
Definition archEnums.hpp:68
@ ID_REG_INVALID
invalid = 0
Definition archEnums.hpp:69
shift_e
Types of shift.
vas_e
Vector arrangement specifier.
extend_e
Types of extend.
@ ID_SHIFT_LAST_ITEM
Must be the last item.
@ ID_SHIFT_INVALID
invalid
@ ID_VAS_4S
4 lanes, each containing a 32-bit element.
@ ID_VAS_2D
2 lanes, each containing a 64-bit element.
@ ID_VAS_4B
4 lane, containing an 8-bit element.
@ ID_VAS_1D
1 lane containing a 64-bit element.
@ ID_VAS_16B
16 lanes, each containing an 8-bit element.
@ ID_VAS_8B
8 lanes, each containing an 8-bit element.
@ ID_VAS_1S
1 lane, containing an 32-bit element.
@ ID_VAS_1Q
1 lane containing a 128-bit element.
@ ID_VAS_INVALID
invalid
@ ID_VAS_1B
1 lane, containing an 8-bit element.
@ ID_VAS_8H
8 lanes, each containing a 16-bit element.
@ ID_VAS_1H
1 lane, containing an 16-bit element.
@ ID_VAS_4H
4 lanes, each containing a 16-bit element.
@ ID_VAS_LAST_ITEM
must be the last item.
@ ID_VAS_2H
2 lanes, each containing a 16-bit element.
@ ID_VAS_2S
2 lanes, each containing a 32-bit element.
@ ID_EXTEND_SXTW
Extracts a word (32-bit) value from a register and zero extends it to the size of the register.
@ ID_EXTEND_UXTX
Use the whole 64-bit register.
@ ID_EXTEND_SXTX
Use the whole 64-bit register.
@ ID_EXTEND_SXTH
Extracts a halfword (16-bit) value from a register and zero extends it to the size of the register.
@ ID_EXTEND_UXTB
Extracts a byte (8-bit) value from a register and zero extends it to the size of the register.
@ ID_EXTEND_INVALID
invalid
@ ID_EXTEND_UXTW
Extracts a word (32-bit) value from a register and zero extends it to the size of the register.
@ ID_EXTEND_SXTB
Extracts a byte (8-bit) value from a register and zero extends it to the size of the register.
@ ID_EXTEND_UXTH
Extracts a halfword (16-bit) value from a register and zero extends it to the size of the register.
@ ID_EXTEND_LAST_ITEM
Must be the last item.
constexpr triton::uint32 dword
dword size in byte
Definition cpuSize.hpp:34
constexpr triton::uint32 word
word size in byte
Definition cpuSize.hpp:32
constexpr triton::uint32 dqword
dqword size in byte
Definition cpuSize.hpp:40
constexpr triton::uint32 byte
byte size in byte
Definition cpuSize.hpp:30
constexpr triton::uint32 qword
qword size in byte
Definition cpuSize.hpp:36
std::int32_t sint32
signed 32-bits
std::uint32_t uint32
unisgned 32-bits
The Triton namespace.