blob: 6453a3c1a4bea9a1e75df0fe676d67700a655313 [file] [log] [blame]
Johnny Chen8584c922011-01-26 01:18:52 +00001//===-- lldb_ARMDefines.h ---------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef lldb_ARMDefines_h_
11#define lldb_ARMDefines_h_
12
13#include "InstructionUtils.h"
14
15// Common defintions for the ARM/Thumb Instruction Set Architecture.
16
17namespace lldb_private {
18
Johnny Chen4302f852011-02-04 21:27:54 +000019// ARM conditions // Meaning (integer) Meaning (floating-point) Condition flags
20#define COND_EQ 0x0 // Equal Equal Z == 1
21#define COND_NE 0x1 // Not equal Not equal, or unordered Z == 0
22#define COND_CS 0x2 // Carry set >, ==, or unordered C == 1
Johnny Chen8584c922011-01-26 01:18:52 +000023#define COND_HS 0x2
Johnny Chen4302f852011-02-04 21:27:54 +000024#define COND_CC 0x3 // Carry clear Less than C == 0
Johnny Chen8584c922011-01-26 01:18:52 +000025#define COND_LO 0x3
Johnny Chen4302f852011-02-04 21:27:54 +000026#define COND_MI 0x4 // Minus, negative Less than N == 1
27#define COND_PL 0x5 // Plus, positive or zero >, ==, or unordered N == 0
28#define COND_VS 0x6 // Overflow Unordered V == 1
29#define COND_VC 0x7 // No overflow Not unordered V == 0
30#define COND_HI 0x8 // Unsigned higher Greater than, or unordered C == 1 and Z == 0
31#define COND_LS 0x9 // Unsigned lower or same Less than or equal C == 0 or Z == 1
32#define COND_GE 0xA // Greater than or equal Greater than or equal N == V
33#define COND_LT 0xB // Less than Less than, or unordered N != V
34#define COND_GT 0xC // Greater than Greater than Z == 0 and N == V
35#define COND_LE 0xD // Less than or equal <, ==, or unordered Z == 1 or N != V
36#define COND_AL 0xE // Always (unconditional) Always (unconditional) Any
Johnny Chen8584c922011-01-26 01:18:52 +000037#define COND_UNCOND 0xF
38
Johnny Chen4302f852011-02-04 21:27:54 +000039static inline const char *ARMCondCodeToString(uint32_t CC)
40{
41 switch (CC) {
42 default: assert(0 && "Unknown condition code");
43 case COND_EQ: return "eq";
44 case COND_NE: return "ne";
45 case COND_HS: return "hs";
46 case COND_LO: return "lo";
47 case COND_MI: return "mi";
48 case COND_PL: return "pl";
49 case COND_VS: return "vs";
50 case COND_VC: return "vc";
51 case COND_HI: return "hi";
52 case COND_LS: return "ls";
53 case COND_GE: return "ge";
54 case COND_LT: return "lt";
55 case COND_GT: return "gt";
56 case COND_LE: return "le";
57 case COND_AL: return "al";
58 }
59}
60
Johnny Chen338bf542011-02-10 19:29:03 +000061// Bit positions for CPSR
62#define CPSR_T 5
63#define CPSR_F 6
64#define CPSR_I 7
65#define CPSR_A 8
66#define CPSR_E 9
67#define CPSR_J 24
68#define CPSR_Q 27
69#define CPSR_V 28
70#define CPSR_C 29
71#define CPSR_Z 30
72#define CPSR_N 31
73
Johnny Chen8584c922011-01-26 01:18:52 +000074// Masks for CPSR
75#define MASK_CPSR_MODE_MASK (0x0000001fu)
Johnny Chen338bf542011-02-10 19:29:03 +000076#define MASK_CPSR_T (1u << CPSR_T)
77#define MASK_CPSR_F (1u << CPSR_F)
78#define MASK_CPSR_I (1u << CPSR_I)
79#define MASK_CPSR_A (1u << CPSR_A)
80#define MASK_CPSR_E (1u << CPSR_E)
Johnny Chen8584c922011-01-26 01:18:52 +000081#define MASK_CPSR_GE_MASK (0x000f0000u)
Johnny Chen338bf542011-02-10 19:29:03 +000082#define MASK_CPSR_J (1u << CPSR_J)
83#define MASK_CPSR_Q (1u << CPSR_Q)
84#define MASK_CPSR_V (1u << CPSR_V)
85#define MASK_CPSR_C (1u << CPSR_C)
86#define MASK_CPSR_Z (1u << CPSR_Z)
87#define MASK_CPSR_N (1u << CPSR_N)
Johnny Chen8584c922011-01-26 01:18:52 +000088
89} // namespace lldb_private
90
91#endif // lldb_ARMDefines_h_