1 //===-- RegisterNumber.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_TARGET_REGISTERNUMBER_H
11 #define LLDB_TARGET_REGISTERNUMBER_H
12 
13 #include "lldb/lldb-private.h"
14 #include <map>
15 
16 //--------------------------------------------------------------------
17 /// A class to represent register numbers, and able to convert between
18 /// different register numbering schemes that may be used in a single
19 /// debug session.
20 //--------------------------------------------------------------------
21 
22 class RegisterNumber {
23 public:
24   RegisterNumber(lldb_private::Thread &thread, lldb::RegisterKind kind,
25                  uint32_t num);
26 
27   // This constructor plus the init() method below allow for the placeholder
28   // creation of an invalid object initially, possibly to be filled in.  It
29   // would be more consistent to have three Set* methods to set the three data
30   // that the object needs.
31   RegisterNumber();
32 
33   void init(lldb_private::Thread &thread, lldb::RegisterKind kind,
34             uint32_t num);
35 
36   const RegisterNumber &operator=(const RegisterNumber &rhs);
37 
38   bool operator==(RegisterNumber &rhs);
39 
40   bool operator!=(RegisterNumber &rhs);
41 
42   bool IsValid() const;
43 
44   uint32_t GetAsKind(lldb::RegisterKind kind);
45 
46   uint32_t GetRegisterNumber() const;
47 
48   lldb::RegisterKind GetRegisterKind() const;
49 
50   const char *GetName();
51 
52 private:
53   typedef std::map<lldb::RegisterKind, uint32_t> Collection;
54 
55   lldb::RegisterContextSP m_reg_ctx_sp;
56   uint32_t m_regnum;
57   lldb::RegisterKind m_kind;
58   Collection m_kind_regnum_map;
59   const char *m_name;
60 };
61 
62 #endif // liblldb_RegisterNumber_h
63