libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
shortcutRegister.hpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
8#ifndef TRITON_SHORTCUTREGISTER_HPP
9#define TRITON_SHORTCUTREGISTER_HPP
10
11#include <triton/archEnums.hpp>
12#include <triton/exceptions.hpp>
13#include <triton/register.hpp>
14
15
16
18namespace triton {
25 namespace arch {
35 public:
36 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5, _6, _7, _8) \
37 triton::arch::Register x86_##LOWER_NAME;
38 #define REG_SPEC_NO_CAPSTONE REG_SPEC
39 #include "triton/x86.spec"
40
41 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5) \
42 triton::arch::Register aarch64_##LOWER_NAME;
43 #define REG_SPEC_NO_CAPSTONE REG_SPEC
44 #define SYS_REG_SPEC REG_SPEC
45 #include "triton/aarch64.spec"
46
47 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5) \
48 triton::arch::Register arm32_##LOWER_NAME;
49 #define REG_SPEC_NO_CAPSTONE REG_SPEC
50 #include "triton/arm32.spec"
51
54
56 void clear(void) {
57 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5, _6, _7, _8) \
58 this->x86_##LOWER_NAME = triton::arch::Register();
59 #define REG_SPEC_NO_CAPSTONE REG_SPEC
60 #include "triton/x86.spec"
61
62 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5) \
63 this->aarch64_##LOWER_NAME = triton::arch::Register();
64 #define REG_SPEC_NO_CAPSTONE REG_SPEC
65 #define SYS_REG_SPEC REG_SPEC
66 #include "triton/aarch64.spec"
67
68 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5) \
69 this->arm32_##LOWER_NAME = triton::arch::Register();
70 #define REG_SPEC_NO_CAPSTONE REG_SPEC
71 #include "triton/arm32.spec"
72 };
73
76 this->clear();
77
78 switch (arch) {
80 #define REG_SPEC(UPPER_NAME, LOWER_NAME, AARCH64_UPPER, AARCH64_LOWER, AARCH64_PARENT, MUTABLE) \
81 this->aarch64_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_AARCH64_##UPPER_NAME, \
82 #LOWER_NAME, \
83 triton::arch::ID_REG_AARCH64_##AARCH64_PARENT, \
84 AARCH64_UPPER, \
85 AARCH64_LOWER, \
86 MUTABLE);
87 #define REG_SPEC_NO_CAPSTONE REG_SPEC
88 #define SYS_REG_SPEC REG_SPEC
89 #include "triton/aarch64.spec"
90 }
91 break;
92
94 #define REG_SPEC(UPPER_NAME, LOWER_NAME, ARM32_UPPER, ARM32_LOWER, ARM32_PARENT, MUTABLE) \
95 this->arm32_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_ARM32_##UPPER_NAME, \
96 #LOWER_NAME, \
97 triton::arch::ID_REG_ARM32_##ARM32_PARENT, \
98 ARM32_UPPER, \
99 ARM32_LOWER, \
100 MUTABLE);
101 #define REG_SPEC_NO_CAPSTONE REG_SPEC
102 #include "triton/arm32.spec"
103 }
104 break;
105
107 #define REG_SPEC(UPPER_NAME, LOWER_NAME, _1, _2, _3, X86_UPPER, X86_LOWER, X86_PARENT, X86_AVAIL) \
108 if (X86_AVAIL) \
109 this->x86_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_X86_##UPPER_NAME, \
110 #LOWER_NAME, \
111 triton::arch::ID_REG_X86_##X86_PARENT, \
112 X86_UPPER, \
113 X86_LOWER, \
114 true);
115 #define REG_SPEC_NO_CAPSTONE REG_SPEC
116 #include "triton/x86.spec"
117 }
118 break;
119
121 #define REG_SPEC(UPPER_NAME, LOWER_NAME, X86_64_UPPER, X86_64_LOWER, X86_64_PARENT, X86_UPPER, X86_LOWER, X86_PARENT, X86_AVAIL) \
122 this->x86_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_X86_##UPPER_NAME, \
123 #LOWER_NAME, \
124 triton::arch::ID_REG_X86_##X86_64_PARENT, \
125 X86_64_UPPER, \
126 X86_64_LOWER, \
127 true);
128 #define REG_SPEC_NO_CAPSTONE REG_SPEC
129 #include "triton/x86.spec"
130 }
131 break;
132
133 default:
134 throw triton::exceptions::Architecture("ShortcutRegister::init(): Invalid architecture.");
135 }
136 };
137 };
138
140 };
142};
143
144#endif /* TRITON_SHORTCUTREGISTER_HPP */
This is used as a shortcut to access to registers.
void init(triton::arch::architecture_e arch)
The exception class used by architectures.
The Triton namespace.