brintos

brintos / llvm-project-archived public Read only

0
0
Text · 800 B · f3596f2 Raw
24 lines · cpp
1#include <stdint.h>2#include <stdio.h>3#include <string.h>4alignas(16) uint8_t buf[32];5// This uses inline assembly to generate an instruction that writes to a large6// block of memory. If it fails on your compiler/architecture, please add7// appropriate code to generate a large write to "buf". If you cannot write at8// least 2*sizeof(void*) bytes with a single instruction, you will have to skip9// this test.10 11int main() {12  memset(buf, UINT32_MAX, 8);13#if defined(__i386__) || defined(__x86_64__)14  asm volatile ("movdqa %%xmm0, %0" : : "m"(buf));15#elif defined(__arm__)16  asm volatile ("stm %0, { r0, r1, r2, r3 }" : : "r"(buf));17#elif defined(__aarch64__)18  asm volatile ("stp x0, x1, %0" : : "m"(buf));19#elif defined(__mips__)20  asm volatile ("lw $2, %0" : : "m"(buf));21#endif22  return 0;23}24