install in /usr/local by default
[qbe.git] / ops.h
blob285bc5c5e1a95b691fff5929bc54073fbd45e2c9
1 #ifndef X /* amd64 */
2 #define X(NMemArgs, SetsZeroFlag, LeavesFlags)
3 #endif
5 #ifndef V /* riscv64 */
6 #define V(Imm)
7 #endif
10 #define T(a,b,c,d,e,f,g,h) { \
11 {[Kw]=K##a, [Kl]=K##b, [Ks]=K##c, [Kd]=K##d}, \
12 {[Kw]=K##e, [Kl]=K##f, [Ks]=K##g, [Kd]=K##h} \
16 /*********************/
17 /* PUBLIC OPERATIONS */
18 /*********************/
20 /* Arithmetic and Bits */
21 O(add, T(w,l,s,d, w,l,s,d), 1) X(2, 1, 0) V(1)
22 O(sub, T(w,l,s,d, w,l,s,d), 1) X(2, 1, 0) V(0)
23 O(neg, T(w,l,s,d, x,x,x,x), 1) X(1, 1, 0) V(0)
24 O(div, T(w,l,s,d, w,l,s,d), 1) X(0, 0, 0) V(0)
25 O(rem, T(w,l,e,e, w,l,e,e), 1) X(0, 0, 0) V(0)
26 O(udiv, T(w,l,e,e, w,l,e,e), 1) X(0, 0, 0) V(0)
27 O(urem, T(w,l,e,e, w,l,e,e), 1) X(0, 0, 0) V(0)
28 O(mul, T(w,l,s,d, w,l,s,d), 1) X(2, 0, 0) V(0)
29 O(and, T(w,l,e,e, w,l,e,e), 1) X(2, 1, 0) V(1)
30 O(or, T(w,l,e,e, w,l,e,e), 1) X(2, 1, 0) V(1)
31 O(xor, T(w,l,e,e, w,l,e,e), 1) X(2, 1, 0) V(1)
32 O(sar, T(w,l,e,e, w,w,e,e), 1) X(1, 1, 0) V(1)
33 O(shr, T(w,l,e,e, w,w,e,e), 1) X(1, 1, 0) V(1)
34 O(shl, T(w,l,e,e, w,w,e,e), 1) X(1, 1, 0) V(1)
36 /* Comparisons */
37 O(ceqw, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(0)
38 O(cnew, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(0)
39 O(csgew, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(0)
40 O(csgtw, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(0)
41 O(cslew, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(0)
42 O(csltw, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(1)
43 O(cugew, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(0)
44 O(cugtw, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(0)
45 O(culew, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(0)
46 O(cultw, T(w,w,e,e, w,w,e,e), 1) X(0, 1, 0) V(1)
48 O(ceql, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(0)
49 O(cnel, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(0)
50 O(csgel, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(0)
51 O(csgtl, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(0)
52 O(cslel, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(0)
53 O(csltl, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(1)
54 O(cugel, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(0)
55 O(cugtl, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(0)
56 O(culel, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(0)
57 O(cultl, T(l,l,e,e, l,l,e,e), 1) X(0, 1, 0) V(1)
59 O(ceqs, T(s,s,e,e, s,s,e,e), 1) X(0, 1, 0) V(0)
60 O(cges, T(s,s,e,e, s,s,e,e), 1) X(0, 1, 0) V(0)
61 O(cgts, T(s,s,e,e, s,s,e,e), 1) X(0, 1, 0) V(0)
62 O(cles, T(s,s,e,e, s,s,e,e), 1) X(0, 1, 0) V(0)
63 O(clts, T(s,s,e,e, s,s,e,e), 1) X(0, 1, 0) V(0)
64 O(cnes, T(s,s,e,e, s,s,e,e), 1) X(0, 1, 0) V(0)
65 O(cos, T(s,s,e,e, s,s,e,e), 1) X(0, 1, 0) V(0)
66 O(cuos, T(s,s,e,e, s,s,e,e), 1) X(0, 1, 0) V(0)
68 O(ceqd, T(d,d,e,e, d,d,e,e), 1) X(0, 1, 0) V(0)
69 O(cged, T(d,d,e,e, d,d,e,e), 1) X(0, 1, 0) V(0)
70 O(cgtd, T(d,d,e,e, d,d,e,e), 1) X(0, 1, 0) V(0)
71 O(cled, T(d,d,e,e, d,d,e,e), 1) X(0, 1, 0) V(0)
72 O(cltd, T(d,d,e,e, d,d,e,e), 1) X(0, 1, 0) V(0)
73 O(cned, T(d,d,e,e, d,d,e,e), 1) X(0, 1, 0) V(0)
74 O(cod, T(d,d,e,e, d,d,e,e), 1) X(0, 1, 0) V(0)
75 O(cuod, T(d,d,e,e, d,d,e,e), 1) X(0, 1, 0) V(0)
77 /* Memory */
78 O(storeb, T(w,e,e,e, m,e,e,e), 0) X(0, 0, 1) V(0)
79 O(storeh, T(w,e,e,e, m,e,e,e), 0) X(0, 0, 1) V(0)
80 O(storew, T(w,e,e,e, m,e,e,e), 0) X(0, 0, 1) V(0)
81 O(storel, T(l,e,e,e, m,e,e,e), 0) X(0, 0, 1) V(0)
82 O(stores, T(s,e,e,e, m,e,e,e), 0) X(0, 0, 1) V(0)
83 O(stored, T(d,e,e,e, m,e,e,e), 0) X(0, 0, 1) V(0)
85 O(loadsb, T(m,m,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
86 O(loadub, T(m,m,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
87 O(loadsh, T(m,m,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
88 O(loaduh, T(m,m,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
89 O(loadsw, T(m,m,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
90 O(loaduw, T(m,m,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
91 O(load, T(m,m,m,m, x,x,x,x), 0) X(0, 0, 1) V(0)
93 /* Extensions and Truncations */
94 O(extsb, T(w,w,e,e, x,x,e,e), 1) X(0, 0, 1) V(0)
95 O(extub, T(w,w,e,e, x,x,e,e), 1) X(0, 0, 1) V(0)
96 O(extsh, T(w,w,e,e, x,x,e,e), 1) X(0, 0, 1) V(0)
97 O(extuh, T(w,w,e,e, x,x,e,e), 1) X(0, 0, 1) V(0)
98 O(extsw, T(e,w,e,e, e,x,e,e), 1) X(0, 0, 1) V(0)
99 O(extuw, T(e,w,e,e, e,x,e,e), 1) X(0, 0, 1) V(0)
101 O(exts, T(e,e,e,s, e,e,e,x), 1) X(0, 0, 1) V(0)
102 O(truncd, T(e,e,d,e, e,e,x,e), 1) X(0, 0, 1) V(0)
103 O(stosi, T(s,s,e,e, x,x,e,e), 1) X(0, 0, 1) V(0)
104 O(stoui, T(s,s,e,e, x,x,e,e), 1) X(0, 0, 1) V(0)
105 O(dtosi, T(d,d,e,e, x,x,e,e), 1) X(0, 0, 1) V(0)
106 O(dtoui, T(d,d,e,e, x,x,e,e), 1) X(0, 0, 1) V(0)
107 O(swtof, T(e,e,w,w, e,e,x,x), 1) X(0, 0, 1) V(0)
108 O(uwtof, T(e,e,w,w, e,e,x,x), 1) X(0, 0, 1) V(0)
109 O(sltof, T(e,e,l,l, e,e,x,x), 1) X(0, 0, 1) V(0)
110 O(ultof, T(e,e,l,l, e,e,x,x), 1) X(0, 0, 1) V(0)
111 O(cast, T(s,d,w,l, x,x,x,x), 1) X(0, 0, 1) V(0)
113 /* Stack Allocation */
114 O(alloc4, T(e,l,e,e, e,x,e,e), 0) X(0, 0, 0) V(0)
115 O(alloc8, T(e,l,e,e, e,x,e,e), 0) X(0, 0, 0) V(0)
116 O(alloc16, T(e,l,e,e, e,x,e,e), 0) X(0, 0, 0) V(0)
118 /* Variadic Function Helpers */
119 O(vaarg, T(m,m,m,m, x,x,x,x), 0) X(0, 0, 0) V(0)
120 O(vastart, T(m,e,e,e, x,e,e,e), 0) X(0, 0, 0) V(0)
122 O(copy, T(w,l,s,d, x,x,x,x), 0) X(0, 0, 1) V(0)
125 /****************************************/
126 /* INTERNAL OPERATIONS (keep nop first) */
127 /****************************************/
129 /* Miscellaneous and Architecture-Specific Operations */
130 O(nop, T(x,x,x,x, x,x,x,x), 0) X(0, 0, 1) V(0)
131 O(addr, T(m,m,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
132 O(swap, T(w,l,s,d, w,l,s,d), 0) X(1, 0, 0) V(0)
133 O(sign, T(w,l,e,e, x,x,e,e), 0) X(0, 0, 0) V(0)
134 O(salloc, T(e,l,e,e, e,x,e,e), 0) X(0, 0, 0) V(0)
135 O(xidiv, T(w,l,e,e, x,x,e,e), 0) X(1, 0, 0) V(0)
136 O(xdiv, T(w,l,e,e, x,x,e,e), 0) X(1, 0, 0) V(0)
137 O(xcmp, T(w,l,s,d, w,l,s,d), 0) X(1, 1, 0) V(0)
138 O(xtest, T(w,l,e,e, w,l,e,e), 0) X(1, 1, 0) V(0)
139 O(acmp, T(w,l,e,e, w,l,e,e), 0) X(0, 0, 0) V(0)
140 O(acmn, T(w,l,e,e, w,l,e,e), 0) X(0, 0, 0) V(0)
141 O(afcmp, T(e,e,s,d, e,e,s,d), 0) X(0, 0, 0) V(0)
142 O(reqz, T(w,l,e,e, x,x,e,e), 0) X(0, 0, 0) V(0)
143 O(rnez, T(w,l,e,e, x,x,e,e), 0) X(0, 0, 0) V(0)
145 /* Arguments, Parameters, and Calls */
146 O(par, T(x,x,x,x, x,x,x,x), 0) X(0, 0, 0) V(0)
147 O(parc, T(e,x,e,e, e,x,e,e), 0) X(0, 0, 0) V(0)
148 O(pare, T(e,x,e,e, e,x,e,e), 0) X(0, 0, 0) V(0)
149 O(arg, T(w,l,s,d, x,x,x,x), 0) X(0, 0, 0) V(0)
150 O(argc, T(e,x,e,e, e,l,e,e), 0) X(0, 0, 0) V(0)
151 O(arge, T(e,l,e,e, e,x,e,e), 0) X(0, 0, 0) V(0)
152 O(argv, T(x,x,x,x, x,x,x,x), 0) X(0, 0, 0) V(0)
153 O(call, T(m,m,m,m, x,x,x,x), 0) X(0, 0, 0) V(0)
155 /* Flags Setting */
156 O(flagieq, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
157 O(flagine, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
158 O(flagisge, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
159 O(flagisgt, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
160 O(flagisle, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
161 O(flagislt, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
162 O(flagiuge, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
163 O(flagiugt, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
164 O(flagiule, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
165 O(flagiult, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
166 O(flagfeq, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
167 O(flagfge, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
168 O(flagfgt, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
169 O(flagfle, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
170 O(flagflt, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
171 O(flagfne, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
172 O(flagfo, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
173 O(flagfuo, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1) V(0)
176 #undef T
177 #undef X
178 #undef V
179 #undef O
182 | column -t -o ' '