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# 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 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 ld t1, seg, [dsz, t3, t7], disp 79 sext t0, t1, reg, flags=(CF,) 80}; 81 82def macroop BTC_R_I { 83 sexti t0, reg, imm, flags=(CF,) 84 limm t1, 1 85 roli t1, t1, imm 86 xor reg, reg, t1 87}; 88 89def macroop BTC_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 limm t4, 1 95 roli t4, t4, imm 96 ldst t1, seg, sib, disp 97 sexti t0, t1, imm, flags=(CF,) 98 xor t1, t1, t4 99 st t1, seg, sib, disp 100}; 101 102def macroop BTC_P_I { 103 rdip t7, dataSize=asz 104 limm t1, imm, dataSize=asz 105 limm t4, 1 106 roli t4, t4, imm 107 ldst t1, seg, riprel, disp 108 sexti t0, t1, imm, flags=(CF,) 109 xor t1, t1, t4 110 st t1, seg, riprel, disp 111}; 112 113def macroop BTC_LOCKED_M_I { 114 limm t1, imm, dataSize=asz 115 limm t4, 1 116 roli t4, t4, imm
|
117 mfence |
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 mfence |
123}; 124 125def macroop BTC_LOCKED_P_I { 126 rdip t7, dataSize=asz 127 limm t1, imm, dataSize=asz 128 limm t4, 1 129 roli t4, t4, imm
|
130 mfence |
131 ldstl t1, seg, riprel, disp 132 sexti t0, t1, imm, flags=(CF,) 133 xor t1, t1, t4 134 stul t1, seg, riprel, disp
|
135 mfence |
136}; 137 138def macroop BTC_R_R { 139 sext t0, reg, regm, flags=(CF,) 140 limm t1, 1 141 rol t1, t1, regm 142 xor reg, reg, t1 143}; 144 145def macroop BTC_M_R { 146 srai t2, reg, 3, dataSize=asz 147 srai t3, t2, ldsz, dataSize=asz 148 lea t3, flatseg, [dsz, t3, base], dataSize=asz 149 limm t4, 1 150 rol t4, t4, reg 151 ldst t1, seg, [scale, index, t3], disp 152 sext t0, t1, reg, flags=(CF,) 153 xor t1, t1, t4 154 st t1, seg, [scale, index, t3], disp 155}; 156 157def macroop BTC_P_R { 158 rdip t7, dataSize=asz 159 srai t2, reg, 3, dataSize=asz 160 srai t3, t2, ldsz, dataSize=asz 161 limm t4, 1 162 rol t4, t4, reg 163 ldst t1, seg, [dsz, t3, t7], disp 164 sext t0, t1, reg, flags=(CF,) 165 xor t1, t1, t4 166 st t1, seg, [dsz, t3, t7], disp 167}; 168 169def macroop BTC_LOCKED_M_R { 170 srai t2, reg, 3, dataSize=asz 171 srai t3, t2, ldsz, dataSize=asz 172 lea t3, flatseg, [dsz, t3, base], dataSize=asz 173 limm t4, 1 174 rol t4, t4, reg
|
175 mfence |
176 ldstl t1, seg, [scale, index, t3], disp 177 sext t0, t1, reg, flags=(CF,) 178 xor t1, t1, t4 179 stul t1, seg, [scale, index, t3], disp
|
180 mfence |
181}; 182 183def macroop BTC_LOCKED_P_R { 184 rdip t7, dataSize=asz 185 srai t2, reg, 3, dataSize=asz 186 srai t3, t2, ldsz, dataSize=asz 187 limm t4, 1 188 rol t4, t4, reg
|
189 mfence |
190 ldstl t1, seg, [dsz, t3, t7], disp 191 sext t0, t1, reg, flags=(CF,) 192 xor t1, t1, t4 193 stul t1, seg, [dsz, t3, t7], disp
|
194 mfence |
195}; 196 197def macroop BTR_R_I { 198 sexti t0, reg, imm, flags=(CF,) 199 limm t1, "(uint64_t(-(2ULL)))" 200 roli t1, t1, imm 201 and reg, reg, t1 202}; 203 204def macroop BTR_M_I { 205 limm t1, imm, dataSize=asz 206 limm t4, "(uint64_t(-(2ULL)))" 207 roli t4, t4, imm 208 ldst t1, seg, sib, disp 209 sexti t0, t1, imm, flags=(CF,) 210 and t1, t1, t4 211 st t1, seg, sib, disp 212}; 213 214def macroop BTR_P_I { 215 rdip t7, dataSize=asz 216 limm t1, imm, dataSize=asz 217 limm t4, "(uint64_t(-(2ULL)))" 218 roli t4, t4, imm 219 ldst t1, seg, riprel, disp 220 sexti t0, t1, imm, flags=(CF,) 221 and t1, t1, t4 222 st t1, seg, riprel, disp 223}; 224 225def macroop BTR_LOCKED_M_I { 226 limm t1, imm, dataSize=asz 227 limm t4, "(uint64_t(-(2ULL)))" 228 roli t4, t4, imm
|
229 mfence |
230 ldstl t1, seg, sib, disp 231 sexti t0, t1, imm, flags=(CF,) 232 and t1, t1, t4 233 stul t1, seg, sib, disp
|
234 mfence |
235}; 236 237def macroop BTR_LOCKED_P_I { 238 rdip t7, dataSize=asz 239 limm t1, imm, dataSize=asz 240 limm t4, "(uint64_t(-(2ULL)))" 241 roli t4, t4, imm
|
242 mfence |
243 ldstl t1, seg, riprel, disp 244 sexti t0, t1, imm, flags=(CF,) 245 and t1, t1, t4 246 stul t1, seg, riprel, disp
|
247 mfence |
248}; 249 250def macroop BTR_R_R { 251 sext t0, reg, regm, flags=(CF,) 252 limm t1, "(uint64_t(-(2ULL)))" 253 rol t1, t1, regm 254 and reg, reg, t1 255}; 256 257def macroop BTR_M_R { 258 srai t2, reg, 3, dataSize=asz 259 srai t3, t2, ldsz, dataSize=asz 260 lea t3, flatseg, [dsz, t3, base], dataSize=asz 261 limm t4, "(uint64_t(-(2ULL)))" 262 rol t4, t4, reg 263 ldst t1, seg, [scale, index, t3], disp 264 sext t0, t1, reg, flags=(CF,) 265 and t1, t1, t4 266 st t1, seg, [scale, index, t3], disp 267}; 268 269def macroop BTR_P_R { 270 rdip t7, dataSize=asz 271 srai t2, reg, 3, dataSize=asz 272 srai t3, t2, ldsz, dataSize=asz 273 limm t4, "(uint64_t(-(2ULL)))" 274 rol t4, t4, reg 275 ldst t1, seg, [dsz, t3, t7], disp 276 sext t0, t1, reg, flags=(CF,) 277 and t1, t1, t4 278 st t1, seg, [dsz, t3, t7], disp 279}; 280 281def macroop BTR_LOCKED_M_R { 282 srai t2, reg, 3, dataSize=asz 283 srai t3, t2, ldsz, dataSize=asz 284 lea t3, flatseg, [dsz, t3, base], dataSize=asz 285 limm t4, "(uint64_t(-(2ULL)))" 286 rol t4, t4, reg
|
287 mfence |
288 ldstl t1, seg, [scale, index, t3], disp 289 sext t0, t1, reg, flags=(CF,) 290 and t1, t1, t4 291 stul t1, seg, [scale, index, t3], disp
|
292 mfence |
293}; 294 295def macroop BTR_LOCKED_P_R { 296 rdip t7, dataSize=asz 297 srai t2, reg, 3, dataSize=asz 298 srai t3, t2, ldsz, dataSize=asz 299 limm t4, "(uint64_t(-(2ULL)))" 300 rol t4, t4, reg
|
301 mfence |
302 ldstl t1, seg, [dsz, t3, t7], disp 303 sext t0, t1, reg, flags=(CF,) 304 and t1, t1, t4 305 stul t1, seg, [dsz, t3, t7], disp
|
306 mfence |
307}; 308 309def macroop BTS_R_I { 310 sexti t0, reg, imm, flags=(CF,) 311 limm t1, 1 312 roli t1, t1, imm 313 or reg, reg, t1 314}; 315 316def macroop BTS_M_I { 317 limm t1, imm, dataSize=asz 318 limm t4, 1 319 roli t4, t4, imm 320 ldst t1, seg, sib, disp 321 sexti t0, t1, imm, flags=(CF,) 322 or t1, t1, t4 323 st t1, seg, sib, disp 324}; 325 326def macroop BTS_P_I { 327 rdip t7, dataSize=asz 328 limm t1, imm, dataSize=asz 329 limm t4, 1 330 roli t4, t4, imm 331 ldst t1, seg, riprel, disp 332 sexti t0, t1, imm, flags=(CF,) 333 or t1, t1, t4 334 st t1, seg, riprel, disp 335}; 336 337def macroop BTS_LOCKED_M_I { 338 limm t1, imm, dataSize=asz 339 limm t4, 1 340 roli t4, t4, imm
|
341 mfence |
342 ldstl t1, seg, sib, disp 343 sexti t0, t1, imm, flags=(CF,) 344 or t1, t1, t4 345 stul t1, seg, sib, disp
|
346 mfence |
347}; 348 349def macroop BTS_LOCKED_P_I { 350 rdip t7, dataSize=asz 351 limm t1, imm, dataSize=asz 352 limm t4, 1 353 roli t4, t4, imm
|
354 mfence |
355 ldstl t1, seg, riprel, disp 356 sexti t0, t1, imm, flags=(CF,) 357 or t1, t1, t4 358 stul t1, seg, riprel, disp
|
359 mfence |
360}; 361 362def macroop BTS_R_R { 363 sext t0, reg, regm, flags=(CF,) 364 limm t1, 1 365 rol t1, t1, regm 366 or reg, reg, t1 367}; 368 369def macroop BTS_M_R { 370 srai t2, reg, 3, dataSize=asz 371 srai t3, t2, ldsz, dataSize=asz 372 lea t3, flatseg, [dsz, t3, base], dataSize=asz 373 limm t4, 1 374 rol t4, t4, reg 375 ldst t1, seg, [scale, index, t3], disp 376 sext t0, t1, reg, flags=(CF,) 377 or t1, t1, t4 378 st t1, seg, [scale, index, t3], disp 379}; 380 381def macroop BTS_P_R { 382 rdip t7, dataSize=asz 383 srai t2, reg, 3, dataSize=asz 384 srai t3, t2, ldsz, dataSize=asz 385 lea t3, flatseg, [dsz, t3, base], dataSize=asz 386 limm t4, 1 387 rol t4, t4, reg 388 ldst t1, seg, [1, t3, t7], disp 389 sext t0, t1, reg, flags=(CF,) 390 or t1, t1, t4 391 st t1, seg, [1, t3, t7], disp 392}; 393 394def macroop BTS_LOCKED_M_R { 395 srai t2, reg, 3, dataSize=asz 396 srai t3, t2, ldsz, dataSize=asz 397 lea t3, flatseg, [dsz, t3, base], dataSize=asz 398 limm t4, 1 399 rol t4, t4, reg
|
400 mfence |
401 ldstl t1, seg, [scale, index, t3], disp 402 sext t0, t1, reg, flags=(CF,) 403 or t1, t1, t4 404 stul t1, seg, [scale, index, t3], disp
|
405 mfence |
406}; 407 408def macroop BTS_LOCKED_P_R { 409 rdip t7, dataSize=asz 410 srai t2, reg, 3, dataSize=asz 411 srai t3, t2, ldsz, dataSize=asz 412 lea t3, flatseg, [dsz, t3, base], dataSize=asz 413 limm t4, 1 414 rol t4, t4, reg
|
415 mfence |
416 ldstl t1, seg, [1, t3, t7], disp 417 sext t0, t1, reg, flags=(CF,) 418 or t1, t1, t4 419 stul t1, seg, [1, t3, t7], disp
|
420 mfence |
421}; 422'''
|