@@ -5,21 +5,21 @@ extension ArmInstruction: OperandContainer {
5
5
let operands : [ cs_arm_op ] = readDetailsArray ( array: detail? . arm. operands, size: detail? . arm. op_count)
6
6
return operands. map ( { Operand ( op: $0) } )
7
7
}
8
-
8
+
9
9
/// User-mode registers to be loaded (for LDM/STM instructions).
10
10
/// nil when detail mode is off
11
11
public var usermode : Bool ! { detail? . arm. usermode }
12
-
12
+
13
13
/// Scalar size for vector instructions
14
14
/// nil when detail mode is off
15
15
public var vectorSize : Int ! { optionalNumericCast ( detail? . arm. vector_size) }
16
-
16
+
17
17
/// Data type for elements of vector instructions
18
18
/// nil when detail mode is off, or wrong instruction
19
19
public var vectorDataType : ArmVectordata ! {
20
20
optionalEnumCast ( detail? . arm. vector_data, ignoring: ARM_VECTORDATA_INVALID)
21
21
}
22
-
22
+
23
23
/// CPS mode for CPS instruction
24
24
/// nil when detail mode is off, or wrong instruction
25
25
public var cpsMode : ( mode: ArmCpsmode , flag: ArmCpsflag ) ! {
@@ -29,86 +29,86 @@ extension ArmInstruction: OperandContainer {
29
29
}
30
30
return ( mode, flag)
31
31
}
32
-
32
+
33
33
/// Condition code
34
34
/// nil when detail mode is off, or instruction has no condition code
35
35
public var conditionCode : ArmCc ! {
36
36
optionalEnumCast ( detail? . arm. cc, ignoring: ARM_CC_INVALID)
37
37
}
38
-
38
+
39
39
/// Does this instruction update flags?
40
40
/// nil when detail mode is off
41
41
public var updatesFlags : Bool ! { detail? . arm. update_flags }
42
-
42
+
43
43
/// Does this instruction write-back?
44
44
/// nil when detail mode is off
45
45
public var writeBack : Bool ! { detail? . arm. writeback }
46
-
46
+
47
47
/// Option for some memory barrier instructions
48
48
/// nil when detail mode is off, or wrong instruction
49
49
public var memoryBarrier : ArmMb ! {
50
50
optionalEnumCast ( detail? . arm. mem_barrier, ignoring: ARM_MB_INVALID)
51
51
}
52
-
52
+
53
53
public struct Operand : InstructionOperand , CustomStringConvertible {
54
54
internal var op : cs_arm_op
55
-
55
+
56
56
public var type : ArmOp { enumCast ( op. type) }
57
-
57
+
58
58
/// Operand access mode
59
59
public var access : Access { enumCast ( op. access) }
60
-
60
+
61
61
/// Vector Index for some vector operands
62
62
public var vectorIndex : Int ! {
63
63
guard op. vector_index != - 1 else {
64
64
return nil
65
65
}
66
66
return numericCast ( op. vector_index)
67
67
}
68
-
68
+
69
69
/// Operand shift
70
70
public var shift : Shift ? {
71
71
guard op. shift. type != ARM_SFT_INVALID else {
72
72
return nil
73
73
}
74
74
return Shift ( op. shift)
75
75
}
76
-
76
+
77
77
/// In some instructions, an operand can be subtracted or added to the base register
78
78
public var subtracted : Bool { op. subtracted }
79
-
79
+
80
80
/// Neon lane index for NEON instructions
81
81
public var neonLane : Int ! {
82
82
guard op. neon_lane != - 1 else {
83
83
return nil
84
84
}
85
85
return numericCast ( op. neon_lane)
86
86
}
87
-
87
+
88
88
/// Register value for register operand
89
89
public var register : ArmReg ! {
90
90
guard type == . reg else { return nil }
91
91
return enumCast ( op. reg)
92
92
}
93
-
93
+
94
94
/// Register value for system register operand
95
95
public var systemRegister : ArmSysreg ! {
96
96
guard type == . sysreg else { return nil }
97
97
return enumCast ( op. reg)
98
98
}
99
-
99
+
100
100
/// Immediate value for C-IMM, P-IMM or IMM operand
101
101
public var immediateValue : Int32 ! {
102
102
guard type. immediate else { return nil }
103
103
return op. imm
104
104
}
105
-
105
+
106
106
/// Floating point value for FP operand
107
107
public var doubleValue : Double ! {
108
108
guard type == . fp else { return nil }
109
109
return op. fp
110
110
}
111
-
111
+
112
112
/// Base/index/scale/disp value for memory operand
113
113
public var memory : Memory ! {
114
114
guard type == . mem else { return nil }
@@ -120,13 +120,13 @@ extension ArmInstruction: OperandContainer {
120
120
leftShift: op. mem. lshift == 0 ? nil : numericCast ( op. mem. lshift)
121
121
)
122
122
}
123
-
123
+
124
124
/// Operand type for SETEND instruction
125
125
public var setend : ArmSetend ! {
126
126
guard type == . setend else { return nil }
127
127
return enumCast ( op. setend)
128
128
}
129
-
129
+
130
130
/// Operand value
131
131
public var value : ArmOperandValue {
132
132
switch type {
@@ -147,11 +147,11 @@ extension ArmInstruction: OperandContainer {
147
147
return 0
148
148
}
149
149
}
150
-
150
+
151
151
public var description : String {
152
152
" \( type) < \( value) > "
153
153
}
154
-
154
+
155
155
/// Instruction operand shift
156
156
public enum Shift {
157
157
public enum Direction : UInt8 {
@@ -166,10 +166,10 @@ extension ArmInstruction: OperandContainer {
166
166
/// Rotate Right with eXtend
167
167
case rrx = 5
168
168
}
169
-
169
+
170
170
case immediate( direction: Direction , value: UInt )
171
171
case register( direction: Direction , register: ArmReg )
172
-
172
+
173
173
init ( _ shift: cs_arm_op . __Unnamed_struct_shift ) {
174
174
switch shift. type. rawValue {
175
175
case ARM_SFT_LSL . rawValue... ARM_SFT_RRX . rawValue:
@@ -181,7 +181,7 @@ extension ArmInstruction: OperandContainer {
181
181
}
182
182
}
183
183
}
184
-
184
+
185
185
/// Instruction's operand referring to memory
186
186
public struct Memory {
187
187
/// Base register
0 commit comments