-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasm_demo.cpp
31 lines (28 loc) · 1017 Bytes
/
easm_demo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cstdint>
#include <cassert>
#include "asmfmt_fwd.hpp"
using namespace std;
int main(int argc, char**argv){
uint64_t u;
// nc++ easm_demo.cpp && ./a.out
// clang++ -std=gnu++14 -target linux-ve -O3 -mllvm -show-spill-message-vec -fno-vectorize -fno-unroll-loops -fno-slp-vectorize -fno-crash-diagnostics easm_demo.cpp -O0 -Wall && ./a.out
asm( "xor %0,%0,%0\n\t"
"addu.l %0,1,%0\n\t"
:"=r"(u) : : );
assert(u==1);
uint64_t v=77U;
asm( "addu.l %0,%1,%1\n\t"
:"=r"(v) : "0r"(u): );
assert(v==2);
asm( "addu.l %0,%0,%0\n\t"
:"+r"(v) :"r"(v) : );
assert(v==4);
asm( "or %0,%1,%2\n\t"
"vxor %%v0,%%v0,%%v0\n\t"
:"+r"(u) :"%r"(0x5500), "r"(v) : );
assert(u==0x5504);
// vector registers do not seems to be supported.
cout<<"\nGoodbye"<<endl;
}
// vim: ts=4 sw=4 et cindent cino=^=l0,\:.5s,=-.5s,N-s,g.5s,b1 cinkeys=0{,0},0),\:,0#,!^F,o,O,e,0=break