1#include <cinttypes>
2#include <cstdint>
3#include <cstdio>
4
5union alignas(16) xmm_t {
6 uint64_t as_uint64[2];
7 uint8_t as_uint8[16];
8};
9
10int main() {
11 constexpr xmm_t xmm_fill = {
12 .as_uint64 = { 0, 0 }
13 };
14
15 uint64_t mm[8];
16 xmm_t xmm[8];
17
18 asm volatile(
19 "movq %2, %%mm0\n\t"
20 "movq %2, %%mm1\n\t"
21 "movq %2, %%mm2\n\t"
22 "movq %2, %%mm3\n\t"
23 "movq %2, %%mm4\n\t"
24 "movq %2, %%mm5\n\t"
25 "movq %2, %%mm6\n\t"
26 "movq %2, %%mm7\n\t"
27 "\n\t"
28 "movaps %2, %%xmm0\n\t"
29 "movaps %2, %%xmm1\n\t"
30 "movaps %2, %%xmm2\n\t"
31 "movaps %2, %%xmm3\n\t"
32 "movaps %2, %%xmm4\n\t"
33 "movaps %2, %%xmm5\n\t"
34 "movaps %2, %%xmm6\n\t"
35 "movaps %2, %%xmm7\n\t"
36 "\n\t"
37 "int3\n\t"
38 "\n\t"
39 "movq %%mm0, 0x00(%0)\n\t"
40 "movq %%mm1, 0x08(%0)\n\t"
41 "movq %%mm2, 0x10(%0)\n\t"
42 "movq %%mm3, 0x18(%0)\n\t"
43 "movq %%mm4, 0x20(%0)\n\t"
44 "movq %%mm5, 0x28(%0)\n\t"
45 "movq %%mm6, 0x30(%0)\n\t"
46 "movq %%mm7, 0x38(%0)\n\t"
47 "\n\t"
48 "movaps %%xmm0, 0x00(%1)\n\t"
49 "movaps %%xmm1, 0x10(%1)\n\t"
50 "movaps %%xmm2, 0x20(%1)\n\t"
51 "movaps %%xmm3, 0x30(%1)\n\t"
52 "movaps %%xmm4, 0x40(%1)\n\t"
53 "movaps %%xmm5, 0x50(%1)\n\t"
54 "movaps %%xmm6, 0x60(%1)\n\t"
55 "movaps %%xmm7, 0x70(%1)\n\t"
56 :
57 : "a"(mm), "b"(xmm), "m"(xmm_fill)
58 : "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7", "%xmm0",
59 "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7"
60 );
61
62 for (int i = 0; i < 8; ++i)
63 printf(format: "mm%d = 0x%016" PRIx64 "\n", i, mm[i]);
64 for (int i = 0; i < 8; ++i) {
65 printf(format: "xmm%d = { ", i);
66 for (int j = 0; j < sizeof(xmm->as_uint8); ++j)
67 printf(format: "0x%02x ", xmm[i].as_uint8[j]);
68 printf(format: "}\n");
69 }
70
71 return 0;
72}
73

source code of lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp