bit_test.py revision 5326:7e4cef0e528b
12SN/A# Copyright (c) 2008 The Regents of The University of Michigan 21762SN/A# All rights reserved. 32SN/A# 42SN/A# Redistribution and use in source and binary forms, with or without 52SN/A# modification, are permitted provided that the following conditions are 62SN/A# met: redistributions of source code must retain the above copyright 72SN/A# notice, this list of conditions and the following disclaimer; 82SN/A# redistributions in binary form must reproduce the above copyright 92SN/A# notice, this list of conditions and the following disclaimer in the 102SN/A# documentation and/or other materials provided with the distribution; 112SN/A# neither the name of the copyright holders nor the names of its 122SN/A# contributors may be used to endorse or promote products derived from 132SN/A# this software without specific prior written permission. 142SN/A# 152SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262SN/A# 272665Ssaidi@eecs.umich.edu# Authors: Gabe Black 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.edu# Copyright (c) 2007-2008 The Hewlett-Packard Development Company 302665Ssaidi@eecs.umich.edu# All rights reserved. 312SN/A# 322SN/A# Redistribution and use of this software in source and binary forms, 332SN/A# with or without modification, are permitted provided that the 342SN/A# following conditions are met: 352SN/A# 362SN/A# The software must be used only for Non-Commercial Use which means any 3775SN/A# use which is NOT directed to receiving any direct monetary 382SN/A# compensation for, or commercial advantage from such use. Illustrative 392439SN/A# examples of non-commercial use are academic research, personal study, 402439SN/A# teaching, education and corporate research & development. 41603SN/A# Illustrative examples of commercial use are distributing products for 422986Sgblack@eecs.umich.edu# commercial advantage and providing services using the software for 43603SN/A# commercial advantage. 444762Snate@binkert.org# 452520SN/A# If you wish to use this software or functionality therein that may be 464762Snate@binkert.org# covered by patents for commercial use, please contact: 472378SN/A# Director of Intellectual Property Licensing 482378SN/A# Office of Strategy and Technology 49722SN/A# Hewlett-Packard Company 502521SN/A# 1501 Page Mill Road 512378SN/A# Palo Alto, California 94304 52312SN/A# 531634SN/A# Redistributions of source code must retain the above copyright notice, 542680Sktlim@umich.edu# this list of conditions and the following disclaimer. Redistributions 551634SN/A# in binary form must reproduce the above copyright notice, this list of 562521SN/A# conditions and the following disclaimer in the documentation and/or 572378SN/A# other materials provided with the distribution. Neither the name of 582378SN/A# the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 59803SN/A# contributors may be used to endorse or promote products derived from 603960Sgblack@eecs.umich.edu# this software without specific prior written permission. No right of 612378SN/A# sublicense is granted herewith. Derivatives of the software and 623536Sgblack@eecs.umich.edu# output created using the software may be prepared, but only for 633536Sgblack@eecs.umich.edu# Non-Commercial Uses. Derivatives of the software may be shared with 643536Sgblack@eecs.umich.edu# others provided: (i) the others agree to abide by the list of 653536Sgblack@eecs.umich.edu# conditions herein which includes the Non-Commercial Use restrictions; 662SN/A# and (ii) such Derivatives of the software include the above copyright 672SN/A# notice to acknowledge the contribution from this software where 682SN/A# applicable, this list of conditions and the disclaimer below. 69603SN/A# 702901Ssaidi@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 712902Ssaidi@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 722902Ssaidi@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 734762Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 744762Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 754762Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 764762Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 774762Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 784762Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 792901Ssaidi@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 802901Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 812901Ssaidi@eecs.umich.edu# 822901Ssaidi@eecs.umich.edu# Authors: Gabe Black 832901Ssaidi@eecs.umich.edu 844762Snate@binkert.orgmicrocode = ''' 852901Ssaidi@eecs.umich.edudef macroop BT_R_I { 862521SN/A sexti t0, reg, imm, flags=(CF,) 872SN/A}; 882SN/A 892680Sktlim@umich.edudef macroop BT_M_I { 905714Shsul@eecs.umich.edu limm t1, imm, dataSize=asz 911806SN/A # This fudges just a tiny bit, but it's reasonable to expect the 925713Shsul@eecs.umich.edu # microcode generation logic to have the log of the various sizes 935713Shsul@eecs.umich.edu # floating around as well. 945713Shsul@eecs.umich.edu ld t1, seg, sib, disp 955713Shsul@eecs.umich.edu sexti t0, t1, imm, flags=(CF,) 965713Shsul@eecs.umich.edu}; 975714Shsul@eecs.umich.edu 981806SN/Adef macroop BT_P_I { 995714Shsul@eecs.umich.edu rdip t7 1001806SN/A limm t1, imm, dataSize=asz 1011806SN/A ld t1, seg, riprel, disp, dataSize=asz 1025714Shsul@eecs.umich.edu sexti t0, t1, imm, flags=(CF,) 1031806SN/A}; 104180SN/A 1052378SN/Adef macroop BT_R_R { 1062378SN/A sext t0, reg, regm, flags=(CF,) 1072378SN/A}; 1082378SN/A 1092520SN/Adef macroop BT_M_R { 1102520SN/A srai t2, reg, 3, dataSize=asz 1112520SN/A srai t3, t2, ldsz, dataSize=asz 1122521SN/A lea t3, flatseg, [dsz, t3, base], dataSize=asz 1132520SN/A ld t1, seg, [scale, index, t3], disp 1141885SN/A sext t0, t1, reg, flags=(CF,) 1151070SN/A}; 116954SN/A 1171070SN/Adef macroop BT_P_R { 1181070SN/A rdip t7 1191070SN/A srai t2, reg, 3, dataSize=asz 1201070SN/A srai t3, t2, ldsz, dataSize=asz 1211070SN/A lea t3, flatseg, [ldsz, t3, base], dataSize=asz 1221070SN/A ld t1, seg, [1, t3, t7], disp 1231070SN/A sext t0, t1, reg, flags=(CF,) 1241070SN/A}; 1251070SN/A 1261070SN/Adef macroop BTC_R_I { 1271070SN/A sexti t0, reg, imm, flags=(CF,) 1281070SN/A limm t1, 1 1292378SN/A roli t1, t1, imm 1302378SN/A xor reg, reg, t1 1312378SN/A}; 1322378SN/A 1334997Sgblack@eecs.umich.edudef macroop BTC_M_I { 1344997Sgblack@eecs.umich.edu limm t1, imm, dataSize=asz 1354997Sgblack@eecs.umich.edu # This fudges just a tiny bit, but it's reasonable to expect the 1364997Sgblack@eecs.umich.edu # microcode generation logic to have the log of the various sizes 1374997Sgblack@eecs.umich.edu # floating around as well. 1384997Sgblack@eecs.umich.edu limm t4, 1 1394997Sgblack@eecs.umich.edu roli t4, t4, imm 1404997Sgblack@eecs.umich.edu ldst t1, seg, sib, disp 1414997Sgblack@eecs.umich.edu sexti t0, t1, imm, flags=(CF,) 1422378SN/A xor t1, t1, t4 1432378SN/A st t1, seg, sib, disp 1442378SN/A}; 1451885SN/A 1464762Snate@binkert.orgdef macroop BTC_P_I { 1472901Ssaidi@eecs.umich.edu rdip t7, dataSize=asz 1482424SN/A limm t1, imm, dataSize=asz 1491885SN/A limm t4, 1 1501885SN/A roli t4, t4, imm 1511885SN/A ldst t1, seg, riprel, disp 1521885SN/A sexti t0, t1, imm, flags=(CF,) 1531885SN/A xor t1, t1, t4 1542158SN/A st t1, seg, riprel, disp 1551885SN/A}; 1561885SN/A 1571885SN/Adef macroop BTC_R_R { 1581885SN/A sext t0, reg, regm, flags=(CF,) 1591885SN/A limm t1, 1 1601885SN/A rol t1, t1, regm 1612989Ssaidi@eecs.umich.edu xor reg, reg, t1 1621885SN/A}; 1631913SN/A 1641885SN/Adef macroop BTC_M_R { 1651885SN/A srai t2, reg, 3, dataSize=asz 1661885SN/A srai t3, t2, ldsz, dataSize=asz 1671885SN/A lea t3, flatseg, [dsz, t3, base], dataSize=asz 1681885SN/A limm t4, 1 1691885SN/A rol t4, t4, reg 1701885SN/A ldst t1, seg, [scale, index, t3], disp 1711885SN/A sext t0, t1, reg, flags=(CF,) 1721885SN/A xor t1, t1, t4 1731885SN/A st t1, seg, [scale, index, t3], disp 1741885SN/A}; 1752989Ssaidi@eecs.umich.edu 1761885SN/Adef macroop BTC_P_R { 1771885SN/A rdip t7, dataSize=asz 1781885SN/A srai t2, reg, 3, dataSize=asz 1791885SN/A srai t3, t2, ldsz, dataSize=asz 1802378SN/A lea t3, flatseg, [dsz, t3, base], dataSize=asz 18177SN/A limm t4, 1 1823536Sgblack@eecs.umich.edu rol t4, t4, reg 1831070SN/A ldst t1, seg, [1, t2, t7], disp 1843960Sgblack@eecs.umich.edu sext t0, t1, reg, flags=(CF,) 1851070SN/A xor t1, t1, t4 1861070SN/A st t1, seg, [1, t2, t7], disp 1874762Snate@binkert.org}; 1881070SN/A 1892158SN/Adef macroop BTR_R_I { 1902158SN/A sexti t0, reg, imm, flags=(CF,) 1911070SN/A limm t1, "(uint64_t(-(2ULL)))" 1922158SN/A roli t1, t1, imm 1931070SN/A and reg, reg, t1 1942SN/A}; 1952SN/A 1961129SN/Adef macroop BTR_M_I { 1971129SN/A limm t1, imm, dataSize=asz 1982158SN/A limm t4, "(uint64_t(-(2ULL)))" 1992158SN/A roli t4, t4, imm 2001070SN/A ldst t1, seg, sib, disp 2012378SN/A sexti t0, t1, imm, flags=(CF,) 2022378SN/A and t1, t1, t4 2031070SN/A st t1, seg, sib, disp 2041070SN/A}; 2051070SN/A 2061070SN/Adef macroop BTR_P_I { 2071070SN/A rdip t7, dataSize=asz 2081070SN/A limm t1, imm, dataSize=asz 2091070SN/A limm t4, "(uint64_t(-(2ULL)))" 2101070SN/A roli t4, t4, imm 2111070SN/A ldst t1, seg, riprel, disp 2121070SN/A sexti t0, t1, imm, flags=(CF,) 2131070SN/A and t1, t1, t4 2141070SN/A st t1, seg, riprel, disp 2151070SN/A}; 2161070SN/A 2171070SN/Adef macroop BTR_R_R { 2181070SN/A sext t0, reg, regm, flags=(CF,) 2191070SN/A limm t1, "(uint64_t(-(2ULL)))" 2201070SN/A rol t1, t1, regm 2212378SN/A and reg, reg, t1 2222378SN/A}; 2232378SN/A 2242378SN/Adef macroop BTR_M_R { 2252378SN/A srai t2, reg, 3, dataSize=asz 2262378SN/A srai t3, t2, ldsz, dataSize=asz 2275712Shsul@eecs.umich.edu lea t3, flatseg, [dsz, t3, base], dataSize=asz 2285713Shsul@eecs.umich.edu limm t4, "(uint64_t(-(2ULL)))" 2291070SN/A rol t4, t4, reg 2301070SN/A ldst t1, seg, [scale, index, t3], disp 2311070SN/A sext t0, t1, reg, flags=(CF,) 2322SN/A and t1, t1, t4 23377SN/A st t1, seg, [scale, index, t3], disp 2342SN/A}; 2352SN/A 2362SN/Adef macroop BTR_P_R { 2372SN/A rdip t7, dataSize=asz 2382SN/A srai t2, reg, 3, dataSize=asz 2392SN/A srai t3, t2, ldsz, dataSize=asz 2402SN/A lea t3, flatseg, [dsz, t3, base], dataSize=asz 2412SN/A limm t4, "(uint64_t(-(2ULL)))" 2422SN/A rol t4, t4, reg 2432SN/A ldst t1, seg, [1, t3, t7], disp 2442158SN/A sext t0, t1, reg, flags=(CF,) 2452158SN/A and t1, t1, t4 2462SN/A st t1, seg, [1, t3, t7], disp 2472SN/A}; 2482SN/A 249def macroop BTS_R_I { 250 sexti t0, reg, imm, flags=(CF,) 251 limm t1, 1 252 roli t1, t1, imm 253 or reg, reg, t1 254}; 255 256def macroop BTS_M_I { 257 limm t1, imm, dataSize=asz 258 limm t4, 1 259 roli t4, t4, imm 260 ldst t1, seg, sib, disp 261 sexti t0, t1, imm, flags=(CF,) 262 or t1, t1, t4 263 st t1, seg, sib, disp 264}; 265 266def macroop BTS_P_I { 267 rdip t7, dataSize=asz 268 limm t1, imm, dataSize=asz 269 limm t4, 1 270 roli t4, t4, imm 271 ldst t1, seg, riprel, disp 272 sexti t0, t1, imm, flags=(CF,) 273 or t1, t1, t4 274 st t1, seg, riprel, disp 275}; 276 277def macroop BTS_R_R { 278 sext t0, reg, regm, flags=(CF,) 279 limm t1, 1 280 rol t1, t1, regm 281 or reg, reg, t1 282}; 283 284def macroop BTS_M_R { 285 srai t2, reg, 3, dataSize=asz 286 srai t3, t2, ldsz, dataSize=asz 287 lea t3, flatseg, [dsz, t3, base], dataSize=asz 288 limm t4, 1 289 rol t4, t4, reg 290 ldst t1, seg, [scale, index, t3], disp 291 sext t0, t1, reg, flags=(CF,) 292 or t1, t1, t4 293 st t1, seg, [scale, index, t3], disp 294}; 295 296def macroop BTS_P_R { 297 rdip t7, dataSize=asz 298 srai t2, reg, 3, dataSize=asz 299 srai t3, t2, ldsz, dataSize=asz 300 lea t3, flatseg, [dsz, t3, base], dataSize=asz 301 limm t4, 1 302 rol t4, t4, reg 303 ldst t1, seg, [1, t3, t7], disp 304 sext t0, t1, reg, flags=(CF,) 305 or t1, t1, t4 306 st t1, seg, [1, t3, t7], disp 307}; 308''' 309