34 #ifndef MC2LIB_CODEGEN_OPS_X86_64_HPP_ 35 #define MC2LIB_CODEGEN_OPS_X86_64_HPP_ 47 std::size_t
Return(
void *code, std::size_t len)
const override;
49 std::size_t
Delay(std::size_t length,
void *code,
50 std::size_t len)
const override;
67 std::size_t len)
const override;
73 *
static_cast<char *
>(code) = 0xc3;
78 std::size_t len)
const {
79 char *cnext =
static_cast<char *
>(code);
81 assert(len >= length);
82 for (std::size_t i = 0; i < length; ++i) {
87 assert((cnext - static_cast<char *>(code)) ==
88 static_cast<std::ptrdiff_t>(length));
93 void *code, std::size_t len,
95 char *cnext =
static_cast<char *
>(code);
96 std::size_t expected_len = 0;
98 if (addr <= static_cast<types::Addr>(0xffffffff)) {
103 assert(len >= expected_len);
111 *
reinterpret_cast<std::uint32_t *
>(cnext) =
112 static_cast<std::uint32_t>(addr);
113 cnext +=
sizeof(std::uint32_t);
117 throw std::logic_error(
"Not supported");
124 assert(len >= expected_len);
134 assert(len >= expected_len);
143 throw std::logic_error(
"Not supported");
146 *
reinterpret_cast<std::uint64_t *
>(cnext) =
147 static_cast<std::uint64_t>(addr);
148 cnext +=
sizeof(std::uint64_t);
151 assert((cnext - static_cast<char *>(code)) ==
152 static_cast<std::ptrdiff_t>(expected_len));
160 char *cnext =
static_cast<char *
>(code);
161 std::size_t expected_len = 0;
165 assert(len >= expected_len);
172 if (addr <= static_cast<types::Addr>(0xffffffff)) {
177 assert(len >= expected_len);
184 *
reinterpret_cast<std::uint32_t *
>(cnext) =
185 static_cast<std::uint32_t>(addr);
186 cnext +=
sizeof(std::uint32_t);
190 throw std::logic_error(
"Not supported");
196 assert(len >= expected_len);
202 *
reinterpret_cast<std::uint64_t *
>(cnext) =
203 static_cast<std::uint64_t>(addr);
204 cnext +=
sizeof(std::uint64_t);
229 throw std::logic_error(
"Not supported");
233 assert((cnext - static_cast<char *>(code)) ==
234 static_cast<std::ptrdiff_t>(expected_len));
243 char *cnext =
static_cast<char *
>(code);
244 std::size_t expected_len = 0;
246 assert(write_id != 0);
248 if (addr <= static_cast<types::Addr>(0xffffffff)) {
253 assert(len >= expected_len);
261 *
reinterpret_cast<std::uint32_t *
>(cnext) =
262 static_cast<std::uint32_t>(addr);
263 cnext +=
sizeof(std::uint32_t);
270 throw std::logic_error(
"Not supported");
278 assert(len >= expected_len);
284 *
reinterpret_cast<std::uint64_t *
>(cnext) =
285 static_cast<std::uint64_t>(addr);
286 cnext +=
sizeof(std::uint64_t);
300 assert(len >= expected_len);
306 *
reinterpret_cast<std::uint64_t *
>(cnext) =
307 static_cast<std::uint64_t>(addr);
308 cnext +=
sizeof(std::uint64_t);
312 *
reinterpret_cast<std::uint32_t *
>(cnext) = write_id;
313 cnext +=
sizeof(std::uint32_t);
322 throw std::logic_error(
"Not supported");
326 assert((cnext - static_cast<char *>(code)) ==
327 static_cast<std::ptrdiff_t>(expected_len));
334 void *code, std::size_t len,
336 char *cnext =
static_cast<char *
>(code);
337 std::size_t expected_len = 0;
339 assert(write_id != 0);
345 assert(len >= expected_len);
356 assert(len >= expected_len);
360 *
reinterpret_cast<std::uint32_t *
>(cnext) = write_id;
361 cnext +=
sizeof(std::uint32_t);
365 throw std::logic_error(
"Not supported");
368 if (addr <= static_cast<types::Addr>(0xffffffff)) {
374 assert(len >= expected_len);
379 *
reinterpret_cast<std::uint32_t *
>(cnext) =
380 static_cast<std::uint32_t>(addr);
381 cnext +=
sizeof(std::uint32_t);
390 throw std::logic_error(
"Not supported");
398 assert(len >= expected_len);
404 *
reinterpret_cast<std::uint64_t *
>(cnext) =
405 static_cast<std::uint64_t>(addr);
406 cnext +=
sizeof(std::uint64_t);
418 assert(len >= expected_len);
424 *
reinterpret_cast<std::uint64_t *
>(cnext) =
425 static_cast<std::uint64_t>(addr);
426 cnext +=
sizeof(std::uint64_t);
436 throw std::logic_error(
"Not supported");
440 assert((cnext - static_cast<char *>(code)) ==
441 static_cast<std::ptrdiff_t>(expected_len));
446 std::size_t len)
const {
447 char *cnext =
static_cast<char *
>(code);
448 std::size_t expected_len = 0;
450 if (addr <= static_cast<types::Addr>(0xffffffff)) {
453 assert(len >= expected_len);
460 *
reinterpret_cast<std::uint32_t *
>(cnext) =
461 static_cast<std::uint32_t>(addr);
462 cnext +=
sizeof(std::uint32_t);
467 assert(len >= expected_len);
472 *
reinterpret_cast<std::uint64_t *
>(cnext) =
473 static_cast<std::uint64_t>(addr);
474 cnext +=
sizeof(std::uint64_t);
482 assert((cnext - static_cast<char *>(code)) ==
483 static_cast<std::ptrdiff_t>(expected_len));
std::size_t CacheFlush(types::Addr addr, void *code, std::size_t len) const override
Definition: x86_64.hpp:445
Types< true >::InstPtr InstPtr
Instruction pointer type.
Definition: types.hpp:81
Definition: x86_64.hpp:46
Definition: strong.hpp:54
std::size_t Delay(std::size_t length, void *code, std::size_t len) const override
Definition: x86_64.hpp:77
std::size_t Write(types::Addr addr, types::WriteID write_id, types::InstPtr start, void *code, std::size_t len, types::InstPtr *at) const override
Definition: x86_64.hpp:238
Types< true >::WriteID WriteID
Write ID type.
Definition: types.hpp:86
std::size_t ReadModifyWrite(types::Addr addr, types::WriteID write_id, types::InstPtr start, void *code, std::size_t len, types::InstPtr *at) const override
Definition: x86_64.hpp:331
Types< true >::Addr Addr
Address type.
Definition: types.hpp:66
std::size_t Read(types::Addr addr, types::InstPtr start, void *code, std::size_t len, types::InstPtr *at) const override
Definition: x86_64.hpp:92
std::size_t ReadAddrDp(types::Addr addr, types::InstPtr start, void *code, std::size_t len, types::InstPtr *at) const override
Definition: x86_64.hpp:156
std::size_t Return(void *code, std::size_t len) const override
Definition: x86_64.hpp:70