1
//! \file
2
/*
3
**  Copyright (C) - Triton
4
**
5
**  This program is under the terms of the Apache License 2.0.
6
*/
7

8
#ifndef TRITON_REGISTEROPERAND_HPP
9
#define TRITON_REGISTEROPERAND_HPP
10

11
#include <string>
12
#include <ostream>
13

14
#include <triton/archEnums.hpp>
15
#include <triton/armOperandProperties.hpp>
16
#include <triton/bitsVector.hpp>
17
#include <triton/cpuSize.hpp>
18
#include <triton/dllexport.hpp>
19
#include <triton/tritonTypes.hpp>
20

21

22

23
//! The Triton namespace
24
namespace triton {
25
/*!
26
 *  \addtogroup triton
27
 *  @{
28
 */
29

30
  //! The Triton namespace
31
  namespace arch {
32
  /*!
33
   *  \ingroup triton
34
   *  \addtogroup arch
35
   *  @{
36
   */
37

38
    //! Used for a Register constructor.
39
    class CpuInterface;
40

41
    /*! \class Register
42
     *  \brief This class is used when an instruction has a register operand.
43
     */
44 1
    class Register : public BitsVector, public arm::ArmOperandProperties {
45
      protected:
46
        //! The name of the register.
47
        std::string name;
48

49
        //! The id of the register.
50
        triton::arch::register_e id;
51

52
        //! The parent id of the register.
53
        triton::arch::register_e parent;
54

55
        //! True if the register is mutable. For example XZR in AArch64 is immutable.
56
        bool vmutable;
57

58
      private:
59
        //! Copy a Register.
60
        void copy(const Register& other);
61

62
      public:
63
        //! Constructor.
64
        TRITON_EXPORT Register();
65

66
        //! Constructor.
67
        TRITON_EXPORT Register(triton::arch::register_e regId, std::string name, triton::arch::register_e parent, triton::uint32 high, triton::uint32 low, bool vmutable);
68

69
        //! Constructor.
70
        TRITON_EXPORT Register(const triton::arch::CpuInterface&, triton::arch::register_e regId);
71

72
        //! Constructor.
73
        TRITON_EXPORT Register(const Register& other);
74

75
        //! Returns the parent id of the register.
76
        TRITON_EXPORT triton::arch::register_e getParent(void) const;
77

78
        //! Returns true if `other` and `self` overlap.
79
        TRITON_EXPORT bool isOverlapWith(const Register& other) const;
80

81
        //! Returns true if this register is mutable. Mainly used in AArch64 to define that some registers like XZR are immutable.
82
        TRITON_EXPORT bool isMutable(void) const;
83

84
        //! Returns the name of the register.
85
        TRITON_EXPORT std::string getName(void) const;
86

87
        //! Returns the id of the register.
88
        TRITON_EXPORT triton::arch::register_e getId(void) const;
89

90
        //! Returns the size (in bits) of the register.
91
        TRITON_EXPORT triton::uint32 getBitSize(void) const;
92

93
        //! Returns the size (in bytes) of the register.
94
        TRITON_EXPORT triton::uint32 getSize(void) const;
95

96
        //! Returns the type of the operand (triton::arch::OPERAND_REGISTER).
97
        TRITON_EXPORT triton::arch::operand_e getType(void) const;
98

99
        //! Compare two registers specifications
100
        TRITON_EXPORT bool operator==(const Register& other) const;
101

102
        //! Compare two registers specifications
103
        TRITON_EXPORT bool operator!=(const Register& other) const;
104

105
        //! Copies a Register.
106
        TRITON_EXPORT Register& operator=(const Register& other);
107
    };
108

109
    //! Displays a Register.
110
    TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, const Register& reg);
111

112
    //! Displays a Register.
113
    TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, const Register* reg);
114

115
    //! Compares two Register
116
    TRITON_EXPORT bool operator<(const Register& reg1, const Register& reg2);
117

118
  /*! @} End of arch namespace */
119
  };
120
/*! @} End of triton namespace */
121
};
122

123
#endif /* TRITON_REGISTEROPERAND_HPP */

Read our documentation on viewing source code .

Loading