Loading [MathJax]/extensions/tex2jax.js
libTriton version 1.0 build 1599
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
52 // ShortcutRegister set for RV32 is the same,
53 #define REG_SPEC(_0, _1, LOWER_NAME, _2, _3, _4, _5) \
54 triton::arch::Register riscv_##LOWER_NAME;
55 #define REG_SPEC_NO_CAPSTONE REG_SPEC
56 #include "triton/riscv64.spec"
57
60
62 void clear(void) {
63 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5, _6, _7, _8) \
64 this->x86_##LOWER_NAME = triton::arch::Register();
65 #define REG_SPEC_NO_CAPSTONE REG_SPEC
66 #include "triton/x86.spec"
67
68 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5) \
69 this->aarch64_##LOWER_NAME = triton::arch::Register();
70 #define REG_SPEC_NO_CAPSTONE REG_SPEC
71 #define SYS_REG_SPEC REG_SPEC
72 #include "triton/aarch64.spec"
73
74 #define REG_SPEC(_0, LOWER_NAME, _2, _3, _4, _5) \
75 this->arm32_##LOWER_NAME = triton::arch::Register();
76 #define REG_SPEC_NO_CAPSTONE REG_SPEC
77 #include "triton/arm32.spec"
78
79 // ShortcutRegister set for RV32 is the same,
80 #define REG_SPEC(_0, _1, LOWER_NAME, _2, _3, _4, _5) \
81 this->riscv_##LOWER_NAME = triton::arch::Register();
82 #define REG_SPEC_NO_CAPSTONE REG_SPEC
83 #include "triton/riscv64.spec"
84 };
85
88 this->clear();
89
90 switch (arch) {
92 #define REG_SPEC(UPPER_NAME, LOWER_NAME, AARCH64_UPPER, AARCH64_LOWER, AARCH64_PARENT, MUTABLE) \
93 this->aarch64_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_AARCH64_##UPPER_NAME, \
94 #LOWER_NAME, \
95 triton::arch::ID_REG_AARCH64_##AARCH64_PARENT, \
96 AARCH64_UPPER, \
97 AARCH64_LOWER, \
98 MUTABLE);
99 #define REG_SPEC_NO_CAPSTONE REG_SPEC
100 #define SYS_REG_SPEC REG_SPEC
101 #include "triton/aarch64.spec"
102 }
103 break;
104
106 #define REG_SPEC(UPPER_NAME, LOWER_NAME, ARM32_UPPER, ARM32_LOWER, ARM32_PARENT, MUTABLE) \
107 this->arm32_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_ARM32_##UPPER_NAME, \
108 #LOWER_NAME, \
109 triton::arch::ID_REG_ARM32_##ARM32_PARENT, \
110 ARM32_UPPER, \
111 ARM32_LOWER, \
112 MUTABLE);
113 #define REG_SPEC_NO_CAPSTONE REG_SPEC
114 #include "triton/arm32.spec"
115 }
116 break;
117
119 #define REG_SPEC(UPPER_NAME, LOWER_NAME, _1, _2, _3, X86_UPPER, X86_LOWER, X86_PARENT, X86_AVAIL) \
120 if (X86_AVAIL) \
121 this->x86_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_X86_##UPPER_NAME, \
122 #LOWER_NAME, \
123 triton::arch::ID_REG_X86_##X86_PARENT, \
124 X86_UPPER, \
125 X86_LOWER, \
126 true);
127 #define REG_SPEC_NO_CAPSTONE REG_SPEC
128 #include "triton/x86.spec"
129 }
130 break;
131
133 #define REG_SPEC(UPPER_NAME, LOWER_NAME, X86_64_UPPER, X86_64_LOWER, X86_64_PARENT, X86_UPPER, X86_LOWER, X86_PARENT, X86_AVAIL) \
134 this->x86_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_X86_##UPPER_NAME, \
135 #LOWER_NAME, \
136 triton::arch::ID_REG_X86_##X86_64_PARENT, \
137 X86_64_UPPER, \
138 X86_64_LOWER, \
139 true);
140 #define REG_SPEC_NO_CAPSTONE REG_SPEC
141 #include "triton/x86.spec"
142 }
143 break;
144
146 #define REG_SPEC(CS_UPPER_NAME, UPPER_NAME, LOWER_NAME, ABI_NAME, RISCV_UPPER, RISCV_LOWER, MUTABLE) \
147 this->riscv_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_RV64_##UPPER_NAME, \
148 #LOWER_NAME, \
149 triton::arch::ID_REG_RV64_##UPPER_NAME, \
150 RISCV_UPPER, \
151 RISCV_LOWER, \
152 MUTABLE);
153 #define REG_SPEC_NO_CAPSTONE REG_SPEC
154 #include "triton/riscv64.spec"
155 }
156 break;
157
159 #define REG_SPEC(CS_UPPER_NAME, UPPER_NAME, LOWER_NAME, ABI_NAME, RISCV_UPPER, RISCV_LOWER, MUTABLE) \
160 this->riscv_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_RV32_##UPPER_NAME, \
161 #LOWER_NAME, \
162 triton::arch::ID_REG_RV32_##UPPER_NAME, \
163 RISCV_UPPER, \
164 RISCV_LOWER, \
165 MUTABLE);
166 #define REG_SPEC_NO_CAPSTONE REG_SPEC
167 #include "triton/riscv32.spec"
168 }
169 break;
170
171 default:
172 throw triton::exceptions::Architecture("ShortcutRegister::init(): Invalid architecture.");
173 }
174 };
175 };
176
178 };
180};
181
182#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.