bit_test.py (6096:72f1239a1583) bit_test.py (7087:fb8d5786ff30)
1# Copyright (c) 2007-2008 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license
9# terms below provided that you ensure that this notice is replicated
10# unmodified and in its entirety in all distributions of the software,
11# modified or unmodified, in source code or in binary form.
12#
1# Copyright (c) 2008 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Gabe Black
28
13# Copyright (c) 2008 The Regents of The University of Michigan
14# All rights reserved.
15#
16# Redistribution and use in source and binary forms, with or without
17# modification, are permitted provided that the following conditions are
18# met: redistributions of source code must retain the above copyright
19# notice, this list of conditions and the following disclaimer;
20# redistributions in binary form must reproduce the above copyright
21# notice, this list of conditions and the following disclaimer in the
22# documentation and/or other materials provided with the distribution;
23# neither the name of the copyright holders nor the names of its
24# contributors may be used to endorse or promote products derived from
25# this software without specific prior written permission.
26#
27# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38#
39# Authors: Gabe Black
40
29# Copyright (c) 2007-2008 The Hewlett-Packard Development Company
30# All rights reserved.
31#
32# Redistribution and use of this software in source and binary forms,
33# with or without modification, are permitted provided that the
34# following conditions are met:
35#
36# The software must be used only for Non-Commercial Use which means any
37# use which is NOT directed to receiving any direct monetary
38# compensation for, or commercial advantage from such use. Illustrative
39# examples of non-commercial use are academic research, personal study,
40# teaching, education and corporate research & development.
41# Illustrative examples of commercial use are distributing products for
42# commercial advantage and providing services using the software for
43# commercial advantage.
44#
45# If you wish to use this software or functionality therein that may be
46# covered by patents for commercial use, please contact:
47# Director of Intellectual Property Licensing
48# Office of Strategy and Technology
49# Hewlett-Packard Company
50# 1501 Page Mill Road
51# Palo Alto, California 94304
52#
53# Redistributions of source code must retain the above copyright notice,
54# this list of conditions and the following disclaimer. Redistributions
55# in binary form must reproduce the above copyright notice, this list of
56# conditions and the following disclaimer in the documentation and/or
57# other materials provided with the distribution. Neither the name of
58# the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
59# contributors may be used to endorse or promote products derived from
60# this software without specific prior written permission. No right of
61# sublicense is granted herewith. Derivatives of the software and
62# output created using the software may be prepared, but only for
63# Non-Commercial Uses. Derivatives of the software may be shared with
64# others provided: (i) the others agree to abide by the list of
65# conditions herein which includes the Non-Commercial Use restrictions;
66# and (ii) such Derivatives of the software include the above copyright
67# notice to acknowledge the contribution from this software where
68# applicable, this list of conditions and the disclaimer below.
69#
70# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
71# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
72# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
73# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
74# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
75# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
77# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
78# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81#
82# Authors: Gabe Black
83
84microcode = '''
85def macroop BT_R_I {
86 sexti t0, reg, imm, flags=(CF,)
87};
88
89def macroop BT_M_I {
90 limm t1, imm, dataSize=asz
91 # This fudges just a tiny bit, but it's reasonable to expect the
92 # microcode generation logic to have the log of the various sizes
93 # floating around as well.
94 ld t1, seg, sib, disp
95 sexti t0, t1, imm, flags=(CF,)
96};
97
98def macroop BT_P_I {
99 rdip t7
100 limm t1, imm, dataSize=asz
101 ld t1, seg, riprel, disp, dataSize=asz
102 sexti t0, t1, imm, flags=(CF,)
103};
104
105def macroop BT_R_R {
106 sext t0, reg, regm, flags=(CF,)
107};
108
109def macroop BT_M_R {
110 srai t2, reg, 3, dataSize=asz
111 srai t3, t2, ldsz, dataSize=asz
112 lea t3, flatseg, [dsz, t3, base], dataSize=asz
113 ld t1, seg, [scale, index, t3], disp
114 sext t0, t1, reg, flags=(CF,)
115};
116
117def macroop BT_P_R {
118 rdip t7
119 srai t2, reg, 3, dataSize=asz
120 srai t3, t2, ldsz, dataSize=asz
121 lea t3, flatseg, [ldsz, t3, base], dataSize=asz
122 ld t1, seg, [1, t3, t7], disp
123 sext t0, t1, reg, flags=(CF,)
124};
125
126def macroop BTC_R_I {
127 sexti t0, reg, imm, flags=(CF,)
128 limm t1, 1
129 roli t1, t1, imm
130 xor reg, reg, t1
131};
132
133def macroop BTC_M_I {
134 limm t1, imm, dataSize=asz
135 # This fudges just a tiny bit, but it's reasonable to expect the
136 # microcode generation logic to have the log of the various sizes
137 # floating around as well.
138 limm t4, 1
139 roli t4, t4, imm
140 ldst t1, seg, sib, disp
141 sexti t0, t1, imm, flags=(CF,)
142 xor t1, t1, t4
143 st t1, seg, sib, disp
144};
145
146def macroop BTC_P_I {
147 rdip t7, dataSize=asz
148 limm t1, imm, dataSize=asz
149 limm t4, 1
150 roli t4, t4, imm
151 ldst t1, seg, riprel, disp
152 sexti t0, t1, imm, flags=(CF,)
153 xor t1, t1, t4
154 st t1, seg, riprel, disp
155};
156
157def macroop BTC_LOCKED_M_I {
158 limm t1, imm, dataSize=asz
159 limm t4, 1
160 roli t4, t4, imm
161 ldstl t1, seg, sib, disp
162 sexti t0, t1, imm, flags=(CF,)
163 xor t1, t1, t4
164 stul t1, seg, sib, disp
165};
166
167def macroop BTC_LOCKED_P_I {
168 rdip t7, dataSize=asz
169 limm t1, imm, dataSize=asz
170 limm t4, 1
171 roli t4, t4, imm
172 ldstl t1, seg, riprel, disp
173 sexti t0, t1, imm, flags=(CF,)
174 xor t1, t1, t4
175 stul t1, seg, riprel, disp
176};
177
178def macroop BTC_R_R {
179 sext t0, reg, regm, flags=(CF,)
180 limm t1, 1
181 rol t1, t1, regm
182 xor reg, reg, t1
183};
184
185def macroop BTC_M_R {
186 srai t2, reg, 3, dataSize=asz
187 srai t3, t2, ldsz, dataSize=asz
188 lea t3, flatseg, [dsz, t3, base], dataSize=asz
189 limm t4, 1
190 rol t4, t4, reg
191 ldst t1, seg, [scale, index, t3], disp
192 sext t0, t1, reg, flags=(CF,)
193 xor t1, t1, t4
194 st t1, seg, [scale, index, t3], disp
195};
196
197def macroop BTC_P_R {
198 rdip t7, dataSize=asz
199 srai t2, reg, 3, dataSize=asz
200 srai t3, t2, ldsz, dataSize=asz
201 lea t3, flatseg, [dsz, t3, base], dataSize=asz
202 limm t4, 1
203 rol t4, t4, reg
204 ldst t1, seg, [1, t2, t7], disp
205 sext t0, t1, reg, flags=(CF,)
206 xor t1, t1, t4
207 st t1, seg, [1, t2, t7], disp
208};
209
210def macroop BTC_LOCKED_M_R {
211 srai t2, reg, 3, dataSize=asz
212 srai t3, t2, ldsz, dataSize=asz
213 lea t3, flatseg, [dsz, t3, base], dataSize=asz
214 limm t4, 1
215 rol t4, t4, reg
216 ldstl t1, seg, [scale, index, t3], disp
217 sext t0, t1, reg, flags=(CF,)
218 xor t1, t1, t4
219 stul t1, seg, [scale, index, t3], disp
220};
221
222def macroop BTC_LOCKED_P_R {
223 rdip t7, dataSize=asz
224 srai t2, reg, 3, dataSize=asz
225 srai t3, t2, ldsz, dataSize=asz
226 lea t3, flatseg, [dsz, t3, base], dataSize=asz
227 limm t4, 1
228 rol t4, t4, reg
229 ldstl t1, seg, [1, t2, t7], disp
230 sext t0, t1, reg, flags=(CF,)
231 xor t1, t1, t4
232 stul t1, seg, [1, t2, t7], disp
233};
234
235def macroop BTR_R_I {
236 sexti t0, reg, imm, flags=(CF,)
237 limm t1, "(uint64_t(-(2ULL)))"
238 roli t1, t1, imm
239 and reg, reg, t1
240};
241
242def macroop BTR_M_I {
243 limm t1, imm, dataSize=asz
244 limm t4, "(uint64_t(-(2ULL)))"
245 roli t4, t4, imm
246 ldst t1, seg, sib, disp
247 sexti t0, t1, imm, flags=(CF,)
248 and t1, t1, t4
249 st t1, seg, sib, disp
250};
251
252def macroop BTR_P_I {
253 rdip t7, dataSize=asz
254 limm t1, imm, dataSize=asz
255 limm t4, "(uint64_t(-(2ULL)))"
256 roli t4, t4, imm
257 ldst t1, seg, riprel, disp
258 sexti t0, t1, imm, flags=(CF,)
259 and t1, t1, t4
260 st t1, seg, riprel, disp
261};
262
263def macroop BTR_LOCKED_M_I {
264 limm t1, imm, dataSize=asz
265 limm t4, "(uint64_t(-(2ULL)))"
266 roli t4, t4, imm
267 ldstl t1, seg, sib, disp
268 sexti t0, t1, imm, flags=(CF,)
269 and t1, t1, t4
270 stul t1, seg, sib, disp
271};
272
273def macroop BTR_LOCKED_P_I {
274 rdip t7, dataSize=asz
275 limm t1, imm, dataSize=asz
276 limm t4, "(uint64_t(-(2ULL)))"
277 roli t4, t4, imm
278 ldstl t1, seg, riprel, disp
279 sexti t0, t1, imm, flags=(CF,)
280 and t1, t1, t4
281 stul t1, seg, riprel, disp
282};
283
284def macroop BTR_R_R {
285 sext t0, reg, regm, flags=(CF,)
286 limm t1, "(uint64_t(-(2ULL)))"
287 rol t1, t1, regm
288 and reg, reg, t1
289};
290
291def macroop BTR_M_R {
292 srai t2, reg, 3, dataSize=asz
293 srai t3, t2, ldsz, dataSize=asz
294 lea t3, flatseg, [dsz, t3, base], dataSize=asz
295 limm t4, "(uint64_t(-(2ULL)))"
296 rol t4, t4, reg
297 ldst t1, seg, [scale, index, t3], disp
298 sext t0, t1, reg, flags=(CF,)
299 and t1, t1, t4
300 st t1, seg, [scale, index, t3], disp
301};
302
303def macroop BTR_P_R {
304 rdip t7, dataSize=asz
305 srai t2, reg, 3, dataSize=asz
306 srai t3, t2, ldsz, dataSize=asz
307 lea t3, flatseg, [dsz, t3, base], dataSize=asz
308 limm t4, "(uint64_t(-(2ULL)))"
309 rol t4, t4, reg
310 ldst t1, seg, [1, t3, t7], disp
311 sext t0, t1, reg, flags=(CF,)
312 and t1, t1, t4
313 st t1, seg, [1, t3, t7], disp
314};
315
316def macroop BTR_LOCKED_M_R {
317 srai t2, reg, 3, dataSize=asz
318 srai t3, t2, ldsz, dataSize=asz
319 lea t3, flatseg, [dsz, t3, base], dataSize=asz
320 limm t4, "(uint64_t(-(2ULL)))"
321 rol t4, t4, reg
322 ldstl t1, seg, [scale, index, t3], disp
323 sext t0, t1, reg, flags=(CF,)
324 and t1, t1, t4
325 stul t1, seg, [scale, index, t3], disp
326};
327
328def macroop BTR_LOCKED_P_R {
329 rdip t7, dataSize=asz
330 srai t2, reg, 3, dataSize=asz
331 srai t3, t2, ldsz, dataSize=asz
332 lea t3, flatseg, [dsz, t3, base], dataSize=asz
333 limm t4, "(uint64_t(-(2ULL)))"
334 rol t4, t4, reg
335 ldstl t1, seg, [1, t3, t7], disp
336 sext t0, t1, reg, flags=(CF,)
337 and t1, t1, t4
338 stul t1, seg, [1, t3, t7], disp
339};
340
341def macroop BTS_R_I {
342 sexti t0, reg, imm, flags=(CF,)
343 limm t1, 1
344 roli t1, t1, imm
345 or reg, reg, t1
346};
347
348def macroop BTS_M_I {
349 limm t1, imm, dataSize=asz
350 limm t4, 1
351 roli t4, t4, imm
352 ldst t1, seg, sib, disp
353 sexti t0, t1, imm, flags=(CF,)
354 or t1, t1, t4
355 st t1, seg, sib, disp
356};
357
358def macroop BTS_P_I {
359 rdip t7, dataSize=asz
360 limm t1, imm, dataSize=asz
361 limm t4, 1
362 roli t4, t4, imm
363 ldst t1, seg, riprel, disp
364 sexti t0, t1, imm, flags=(CF,)
365 or t1, t1, t4
366 st t1, seg, riprel, disp
367};
368
369def macroop BTS_LOCKED_M_I {
370 limm t1, imm, dataSize=asz
371 limm t4, 1
372 roli t4, t4, imm
373 ldstl t1, seg, sib, disp
374 sexti t0, t1, imm, flags=(CF,)
375 or t1, t1, t4
376 stul t1, seg, sib, disp
377};
378
379def macroop BTS_LOCKED_P_I {
380 rdip t7, dataSize=asz
381 limm t1, imm, dataSize=asz
382 limm t4, 1
383 roli t4, t4, imm
384 ldstl t1, seg, riprel, disp
385 sexti t0, t1, imm, flags=(CF,)
386 or t1, t1, t4
387 stul t1, seg, riprel, disp
388};
389
390def macroop BTS_R_R {
391 sext t0, reg, regm, flags=(CF,)
392 limm t1, 1
393 rol t1, t1, regm
394 or reg, reg, t1
395};
396
397def macroop BTS_M_R {
398 srai t2, reg, 3, dataSize=asz
399 srai t3, t2, ldsz, dataSize=asz
400 lea t3, flatseg, [dsz, t3, base], dataSize=asz
401 limm t4, 1
402 rol t4, t4, reg
403 ldst t1, seg, [scale, index, t3], disp
404 sext t0, t1, reg, flags=(CF,)
405 or t1, t1, t4
406 st t1, seg, [scale, index, t3], disp
407};
408
409def macroop BTS_P_R {
410 rdip t7, dataSize=asz
411 srai t2, reg, 3, dataSize=asz
412 srai t3, t2, ldsz, dataSize=asz
413 lea t3, flatseg, [dsz, t3, base], dataSize=asz
414 limm t4, 1
415 rol t4, t4, reg
416 ldst t1, seg, [1, t3, t7], disp
417 sext t0, t1, reg, flags=(CF,)
418 or t1, t1, t4
419 st t1, seg, [1, t3, t7], disp
420};
421
422def macroop BTS_LOCKED_M_R {
423 srai t2, reg, 3, dataSize=asz
424 srai t3, t2, ldsz, dataSize=asz
425 lea t3, flatseg, [dsz, t3, base], dataSize=asz
426 limm t4, 1
427 rol t4, t4, reg
428 ldstl t1, seg, [scale, index, t3], disp
429 sext t0, t1, reg, flags=(CF,)
430 or t1, t1, t4
431 stul t1, seg, [scale, index, t3], disp
432};
433
434def macroop BTS_LOCKED_P_R {
435 rdip t7, dataSize=asz
436 srai t2, reg, 3, dataSize=asz
437 srai t3, t2, ldsz, dataSize=asz
438 lea t3, flatseg, [dsz, t3, base], dataSize=asz
439 limm t4, 1
440 rol t4, t4, reg
441 ldstl t1, seg, [1, t3, t7], disp
442 sext t0, t1, reg, flags=(CF,)
443 or t1, t1, t4
444 stul t1, seg, [1, t3, t7], disp
445};
446'''
41microcode = '''
42def macroop BT_R_I {
43 sexti t0, reg, imm, flags=(CF,)
44};
45
46def macroop BT_M_I {
47 limm t1, imm, dataSize=asz
48 # This fudges just a tiny bit, but it's reasonable to expect the
49 # microcode generation logic to have the log of the various sizes
50 # floating around as well.
51 ld t1, seg, sib, disp
52 sexti t0, t1, imm, flags=(CF,)
53};
54
55def macroop BT_P_I {
56 rdip t7
57 limm t1, imm, dataSize=asz
58 ld t1, seg, riprel, disp, dataSize=asz
59 sexti t0, t1, imm, flags=(CF,)
60};
61
62def macroop BT_R_R {
63 sext t0, reg, regm, flags=(CF,)
64};
65
66def macroop BT_M_R {
67 srai t2, reg, 3, dataSize=asz
68 srai t3, t2, ldsz, dataSize=asz
69 lea t3, flatseg, [dsz, t3, base], dataSize=asz
70 ld t1, seg, [scale, index, t3], disp
71 sext t0, t1, reg, flags=(CF,)
72};
73
74def macroop BT_P_R {
75 rdip t7
76 srai t2, reg, 3, dataSize=asz
77 srai t3, t2, ldsz, dataSize=asz
78 lea t3, flatseg, [ldsz, t3, base], dataSize=asz
79 ld t1, seg, [1, t3, t7], disp
80 sext t0, t1, reg, flags=(CF,)
81};
82
83def macroop BTC_R_I {
84 sexti t0, reg, imm, flags=(CF,)
85 limm t1, 1
86 roli t1, t1, imm
87 xor reg, reg, t1
88};
89
90def macroop BTC_M_I {
91 limm t1, imm, dataSize=asz
92 # This fudges just a tiny bit, but it's reasonable to expect the
93 # microcode generation logic to have the log of the various sizes
94 # floating around as well.
95 limm t4, 1
96 roli t4, t4, imm
97 ldst t1, seg, sib, disp
98 sexti t0, t1, imm, flags=(CF,)
99 xor t1, t1, t4
100 st t1, seg, sib, disp
101};
102
103def macroop BTC_P_I {
104 rdip t7, dataSize=asz
105 limm t1, imm, dataSize=asz
106 limm t4, 1
107 roli t4, t4, imm
108 ldst t1, seg, riprel, disp
109 sexti t0, t1, imm, flags=(CF,)
110 xor t1, t1, t4
111 st t1, seg, riprel, disp
112};
113
114def macroop BTC_LOCKED_M_I {
115 limm t1, imm, dataSize=asz
116 limm t4, 1
117 roli t4, t4, imm
118 ldstl t1, seg, sib, disp
119 sexti t0, t1, imm, flags=(CF,)
120 xor t1, t1, t4
121 stul t1, seg, sib, disp
122};
123
124def macroop BTC_LOCKED_P_I {
125 rdip t7, dataSize=asz
126 limm t1, imm, dataSize=asz
127 limm t4, 1
128 roli t4, t4, imm
129 ldstl t1, seg, riprel, disp
130 sexti t0, t1, imm, flags=(CF,)
131 xor t1, t1, t4
132 stul t1, seg, riprel, disp
133};
134
135def macroop BTC_R_R {
136 sext t0, reg, regm, flags=(CF,)
137 limm t1, 1
138 rol t1, t1, regm
139 xor reg, reg, t1
140};
141
142def macroop BTC_M_R {
143 srai t2, reg, 3, dataSize=asz
144 srai t3, t2, ldsz, dataSize=asz
145 lea t3, flatseg, [dsz, t3, base], dataSize=asz
146 limm t4, 1
147 rol t4, t4, reg
148 ldst t1, seg, [scale, index, t3], disp
149 sext t0, t1, reg, flags=(CF,)
150 xor t1, t1, t4
151 st t1, seg, [scale, index, t3], disp
152};
153
154def macroop BTC_P_R {
155 rdip t7, dataSize=asz
156 srai t2, reg, 3, dataSize=asz
157 srai t3, t2, ldsz, dataSize=asz
158 lea t3, flatseg, [dsz, t3, base], dataSize=asz
159 limm t4, 1
160 rol t4, t4, reg
161 ldst t1, seg, [1, t2, t7], disp
162 sext t0, t1, reg, flags=(CF,)
163 xor t1, t1, t4
164 st t1, seg, [1, t2, t7], disp
165};
166
167def macroop BTC_LOCKED_M_R {
168 srai t2, reg, 3, dataSize=asz
169 srai t3, t2, ldsz, dataSize=asz
170 lea t3, flatseg, [dsz, t3, base], dataSize=asz
171 limm t4, 1
172 rol t4, t4, reg
173 ldstl t1, seg, [scale, index, t3], disp
174 sext t0, t1, reg, flags=(CF,)
175 xor t1, t1, t4
176 stul t1, seg, [scale, index, t3], disp
177};
178
179def macroop BTC_LOCKED_P_R {
180 rdip t7, dataSize=asz
181 srai t2, reg, 3, dataSize=asz
182 srai t3, t2, ldsz, dataSize=asz
183 lea t3, flatseg, [dsz, t3, base], dataSize=asz
184 limm t4, 1
185 rol t4, t4, reg
186 ldstl t1, seg, [1, t2, t7], disp
187 sext t0, t1, reg, flags=(CF,)
188 xor t1, t1, t4
189 stul t1, seg, [1, t2, t7], disp
190};
191
192def macroop BTR_R_I {
193 sexti t0, reg, imm, flags=(CF,)
194 limm t1, "(uint64_t(-(2ULL)))"
195 roli t1, t1, imm
196 and reg, reg, t1
197};
198
199def macroop BTR_M_I {
200 limm t1, imm, dataSize=asz
201 limm t4, "(uint64_t(-(2ULL)))"
202 roli t4, t4, imm
203 ldst t1, seg, sib, disp
204 sexti t0, t1, imm, flags=(CF,)
205 and t1, t1, t4
206 st t1, seg, sib, disp
207};
208
209def macroop BTR_P_I {
210 rdip t7, dataSize=asz
211 limm t1, imm, dataSize=asz
212 limm t4, "(uint64_t(-(2ULL)))"
213 roli t4, t4, imm
214 ldst t1, seg, riprel, disp
215 sexti t0, t1, imm, flags=(CF,)
216 and t1, t1, t4
217 st t1, seg, riprel, disp
218};
219
220def macroop BTR_LOCKED_M_I {
221 limm t1, imm, dataSize=asz
222 limm t4, "(uint64_t(-(2ULL)))"
223 roli t4, t4, imm
224 ldstl t1, seg, sib, disp
225 sexti t0, t1, imm, flags=(CF,)
226 and t1, t1, t4
227 stul t1, seg, sib, disp
228};
229
230def macroop BTR_LOCKED_P_I {
231 rdip t7, dataSize=asz
232 limm t1, imm, dataSize=asz
233 limm t4, "(uint64_t(-(2ULL)))"
234 roli t4, t4, imm
235 ldstl t1, seg, riprel, disp
236 sexti t0, t1, imm, flags=(CF,)
237 and t1, t1, t4
238 stul t1, seg, riprel, disp
239};
240
241def macroop BTR_R_R {
242 sext t0, reg, regm, flags=(CF,)
243 limm t1, "(uint64_t(-(2ULL)))"
244 rol t1, t1, regm
245 and reg, reg, t1
246};
247
248def macroop BTR_M_R {
249 srai t2, reg, 3, dataSize=asz
250 srai t3, t2, ldsz, dataSize=asz
251 lea t3, flatseg, [dsz, t3, base], dataSize=asz
252 limm t4, "(uint64_t(-(2ULL)))"
253 rol t4, t4, reg
254 ldst t1, seg, [scale, index, t3], disp
255 sext t0, t1, reg, flags=(CF,)
256 and t1, t1, t4
257 st t1, seg, [scale, index, t3], disp
258};
259
260def macroop BTR_P_R {
261 rdip t7, dataSize=asz
262 srai t2, reg, 3, dataSize=asz
263 srai t3, t2, ldsz, dataSize=asz
264 lea t3, flatseg, [dsz, t3, base], dataSize=asz
265 limm t4, "(uint64_t(-(2ULL)))"
266 rol t4, t4, reg
267 ldst t1, seg, [1, t3, t7], disp
268 sext t0, t1, reg, flags=(CF,)
269 and t1, t1, t4
270 st t1, seg, [1, t3, t7], disp
271};
272
273def macroop BTR_LOCKED_M_R {
274 srai t2, reg, 3, dataSize=asz
275 srai t3, t2, ldsz, dataSize=asz
276 lea t3, flatseg, [dsz, t3, base], dataSize=asz
277 limm t4, "(uint64_t(-(2ULL)))"
278 rol t4, t4, reg
279 ldstl t1, seg, [scale, index, t3], disp
280 sext t0, t1, reg, flags=(CF,)
281 and t1, t1, t4
282 stul t1, seg, [scale, index, t3], disp
283};
284
285def macroop BTR_LOCKED_P_R {
286 rdip t7, dataSize=asz
287 srai t2, reg, 3, dataSize=asz
288 srai t3, t2, ldsz, dataSize=asz
289 lea t3, flatseg, [dsz, t3, base], dataSize=asz
290 limm t4, "(uint64_t(-(2ULL)))"
291 rol t4, t4, reg
292 ldstl t1, seg, [1, t3, t7], disp
293 sext t0, t1, reg, flags=(CF,)
294 and t1, t1, t4
295 stul t1, seg, [1, t3, t7], disp
296};
297
298def macroop BTS_R_I {
299 sexti t0, reg, imm, flags=(CF,)
300 limm t1, 1
301 roli t1, t1, imm
302 or reg, reg, t1
303};
304
305def macroop BTS_M_I {
306 limm t1, imm, dataSize=asz
307 limm t4, 1
308 roli t4, t4, imm
309 ldst t1, seg, sib, disp
310 sexti t0, t1, imm, flags=(CF,)
311 or t1, t1, t4
312 st t1, seg, sib, disp
313};
314
315def macroop BTS_P_I {
316 rdip t7, dataSize=asz
317 limm t1, imm, dataSize=asz
318 limm t4, 1
319 roli t4, t4, imm
320 ldst t1, seg, riprel, disp
321 sexti t0, t1, imm, flags=(CF,)
322 or t1, t1, t4
323 st t1, seg, riprel, disp
324};
325
326def macroop BTS_LOCKED_M_I {
327 limm t1, imm, dataSize=asz
328 limm t4, 1
329 roli t4, t4, imm
330 ldstl t1, seg, sib, disp
331 sexti t0, t1, imm, flags=(CF,)
332 or t1, t1, t4
333 stul t1, seg, sib, disp
334};
335
336def macroop BTS_LOCKED_P_I {
337 rdip t7, dataSize=asz
338 limm t1, imm, dataSize=asz
339 limm t4, 1
340 roli t4, t4, imm
341 ldstl t1, seg, riprel, disp
342 sexti t0, t1, imm, flags=(CF,)
343 or t1, t1, t4
344 stul t1, seg, riprel, disp
345};
346
347def macroop BTS_R_R {
348 sext t0, reg, regm, flags=(CF,)
349 limm t1, 1
350 rol t1, t1, regm
351 or reg, reg, t1
352};
353
354def macroop BTS_M_R {
355 srai t2, reg, 3, dataSize=asz
356 srai t3, t2, ldsz, dataSize=asz
357 lea t3, flatseg, [dsz, t3, base], dataSize=asz
358 limm t4, 1
359 rol t4, t4, reg
360 ldst t1, seg, [scale, index, t3], disp
361 sext t0, t1, reg, flags=(CF,)
362 or t1, t1, t4
363 st t1, seg, [scale, index, t3], disp
364};
365
366def macroop BTS_P_R {
367 rdip t7, dataSize=asz
368 srai t2, reg, 3, dataSize=asz
369 srai t3, t2, ldsz, dataSize=asz
370 lea t3, flatseg, [dsz, t3, base], dataSize=asz
371 limm t4, 1
372 rol t4, t4, reg
373 ldst t1, seg, [1, t3, t7], disp
374 sext t0, t1, reg, flags=(CF,)
375 or t1, t1, t4
376 st t1, seg, [1, t3, t7], disp
377};
378
379def macroop BTS_LOCKED_M_R {
380 srai t2, reg, 3, dataSize=asz
381 srai t3, t2, ldsz, dataSize=asz
382 lea t3, flatseg, [dsz, t3, base], dataSize=asz
383 limm t4, 1
384 rol t4, t4, reg
385 ldstl t1, seg, [scale, index, t3], disp
386 sext t0, t1, reg, flags=(CF,)
387 or t1, t1, t4
388 stul t1, seg, [scale, index, t3], disp
389};
390
391def macroop BTS_LOCKED_P_R {
392 rdip t7, dataSize=asz
393 srai t2, reg, 3, dataSize=asz
394 srai t3, t2, ldsz, dataSize=asz
395 lea t3, flatseg, [dsz, t3, base], dataSize=asz
396 limm t4, 1
397 rol t4, t4, reg
398 ldstl t1, seg, [1, t3, t7], disp
399 sext t0, t1, reg, flags=(CF,)
400 or t1, t1, t4
401 stul t1, seg, [1, t3, t7], disp
402};
403'''