1 //===-- ARMDefines.h --------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMDEFINES_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMDEFINES_H
12 #include "llvm/Support/ErrorHandling.h"
17 // Common definitions for the ARM/Thumb Instruction Set Architecture.
19 namespace lldb_private
{
22 enum ARM_ShifterType
{
31 // ARM conditions // Meaning (integer) Meaning (floating-point)
34 0x0 // Equal Equal Z == 1
36 0x1 // Not equal Not equal, or unordered Z == 0
38 0x2 // Carry set >, ==, or unordered C == 1
41 0x3 // Carry clear Less than C == 0
44 0x4 // Minus, negative Less than N == 1
46 0x5 // Plus, positive or zero >, ==, or unordered N == 0
48 0x6 // Overflow Unordered V == 1
50 0x7 // No overflow Not unordered V == 0
52 0x8 // Unsigned higher Greater than, or unordered C == 1 and Z ==
55 0x9 // Unsigned lower or same Less than or equal C == 0 or Z ==
58 0xA // Greater than or equal Greater than or equal N == V
60 0xB // Less than Less than, or unordered N != V
62 0xC // Greater than Greater than Z == 0 and N ==
65 0xD // Less than or equal <, ==, or unordered Z == 1 or N !=
68 0xE // Always (unconditional) Always (unconditional) Any
69 #define COND_UNCOND 0xF
71 static inline const char *ARMCondCodeToString(uint32_t CC
) {
104 llvm_unreachable("Unknown condition code");
107 static inline bool ARMConditionPassed(const uint32_t condition
,
108 const uint32_t cpsr
) {
109 const uint32_t cpsr_n
= (cpsr
>> 31) & 1u; // Negative condition code flag
110 const uint32_t cpsr_z
= (cpsr
>> 30) & 1u; // Zero condition code flag
111 const uint32_t cpsr_c
= (cpsr
>> 29) & 1u; // Carry condition code flag
112 const uint32_t cpsr_v
= (cpsr
>> 28) & 1u; // Overflow condition code flag
116 return (cpsr_z
== 1);
118 return (cpsr_z
== 0);
120 return (cpsr_c
== 1);
122 return (cpsr_c
== 0);
124 return (cpsr_n
== 1);
126 return (cpsr_n
== 0);
128 return (cpsr_v
== 1);
130 return (cpsr_v
== 0);
132 return ((cpsr_c
== 1) && (cpsr_z
== 0));
134 return ((cpsr_c
== 0) || (cpsr_z
== 1));
136 return (cpsr_n
== cpsr_v
);
138 return (cpsr_n
!= cpsr_v
);
140 return ((cpsr_z
== 0) && (cpsr_n
== cpsr_v
));
142 return ((cpsr_z
== 1) || (cpsr_n
!= cpsr_v
));
151 // Bit positions for CPSR
157 #define CPSR_J_POS 24
158 #define CPSR_Q_POS 27
159 #define CPSR_V_POS 28
160 #define CPSR_C_POS 29
161 #define CPSR_Z_POS 30
162 #define CPSR_N_POS 31
164 // CPSR mode definitions
165 #define CPSR_MODE_USR 0x10u
166 #define CPSR_MODE_FIQ 0x11u
167 #define CPSR_MODE_IRQ 0x12u
168 #define CPSR_MODE_SVC 0x13u
169 #define CPSR_MODE_ABT 0x17u
170 #define CPSR_MODE_UND 0x1bu
171 #define CPSR_MODE_SYS 0x1fu
174 #define MASK_CPSR_MODE_MASK (0x0000001fu)
175 #define MASK_CPSR_IT_MASK (0x0600fc00u)
176 #define MASK_CPSR_T (1u << CPSR_T_POS)
177 #define MASK_CPSR_F (1u << CPSR_F_POS)
178 #define MASK_CPSR_I (1u << CPSR_I_POS)
179 #define MASK_CPSR_A (1u << CPSR_A_POS)
180 #define MASK_CPSR_E (1u << CPSR_E_POS)
181 #define MASK_CPSR_GE_MASK (0x000f0000u)
182 #define MASK_CPSR_J (1u << CPSR_J_POS)
183 #define MASK_CPSR_Q (1u << CPSR_Q_POS)
184 #define MASK_CPSR_V (1u << CPSR_V_POS)
185 #define MASK_CPSR_C (1u << CPSR_C_POS)
186 #define MASK_CPSR_Z (1u << CPSR_Z_POS)
187 #define MASK_CPSR_N (1u << CPSR_N_POS)
189 } // namespace lldb_private
191 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMDEFINES_H