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