bit_test.py revision 5305:8b379ad9406d
1# Copyright (c) 2007 The Hewlett-Packard Development Company 2# All rights reserved. 3# 4# Redistribution and use of this software in source and binary forms, 5# with or without modification, are permitted provided that the 6# following conditions are met: 7# 8# The software must be used only for Non-Commercial Use which means any 9# use which is NOT directed to receiving any direct monetary 10# compensation for, or commercial advantage from such use. Illustrative 11# examples of non-commercial use are academic research, personal study, 12# teaching, education and corporate research & development. 13# Illustrative examples of commercial use are distributing products for 14# commercial advantage and providing services using the software for 15# commercial advantage. 16# 17# If you wish to use this software or functionality therein that may be 18# covered by patents for commercial use, please contact: 19# Director of Intellectual Property Licensing 20# Office of Strategy and Technology 21# Hewlett-Packard Company 22# 1501 Page Mill Road 23# Palo Alto, California 94304 24# 25# Redistributions of source code must retain the above copyright notice, 26# this list of conditions and the following disclaimer. Redistributions 27# in binary form must reproduce the above copyright notice, this list of 28# conditions and the following disclaimer in the documentation and/or 29# other materials provided with the distribution. Neither the name of 30# the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 31# contributors may be used to endorse or promote products derived from 32# this software without specific prior written permission. No right of 33# sublicense is granted herewith. Derivatives of the software and 34# output created using the software may be prepared, but only for 35# Non-Commercial Uses. Derivatives of the software may be shared with 36# others provided: (i) the others agree to abide by the list of 37# conditions herein which includes the Non-Commercial Use restrictions; 38# and (ii) such Derivatives of the software include the above copyright 39# notice to acknowledge the contribution from this software where 40# applicable, this list of conditions and the disclaimer below. 41# 42# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 43# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 44# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 45# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 46# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 47# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 48# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 49# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 50# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53# 54# Authors: Gabe Black 55 56microcode = ''' 57def macroop BT_R_I { 58 sexti t0, reg, imm, flags=(CF,) 59}; 60 61def macroop BT_M_I { 62 limm t1, imm 63 # This fudges just a tiny bit, but it's reasonable to expect the 64 # microcode generation logic to have the log of the various sizes 65 # floating around as well. 66 srai t2, t1, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 67 add t2, t2, base 68 ld t1, seg, [scale, index, t2], disp 69 sexti t0, t1, imm, flags=(CF,) 70}; 71 72def macroop BT_P_I { 73 rdip t7 74 limm t1, imm 75 srai t2, t1, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 76 ld t1, seg, [1, t2, t7] 77 sexti t0, t1, imm, flags=(CF,) 78}; 79 80def macroop BT_R_R { 81 sext t0, reg, regm, flags=(CF,) 82}; 83 84def macroop BT_M_R { 85 srai t2, reg, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 86 add t2, t2, base 87 ld t1, seg, [scale, index, t2], disp 88 sext t0, t1, reg, flags=(CF,) 89}; 90 91def macroop BT_P_R { 92 rdip t7 93 srai t2, reg, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 94 ld t1, seg, [1, t2, t7] 95 sext t0, t1, reg, flags=(CF,) 96}; 97 98def macroop BTC_R_I { 99 sexti t0, reg, imm, flags=(CF,) 100 limm t1, 1 101 roli t1, t1, imm 102 xor reg, reg, t1 103}; 104 105def macroop BTC_M_I { 106 limm t1, imm 107 # This fudges just a tiny bit, but it's reasonable to expect the 108 # microcode generation logic to have the log of the various sizes 109 # floating around as well. 110 srai t2, t1, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 111 add t2, t2, base 112 limm t3, 1 113 roli t3, t3, imm 114 ldst t1, seg, [scale, index, t2], disp 115 sexti t0, t1, imm, flags=(CF,) 116 xor t1, t1, t3 117 st t1, seg, [scale, index, t2], disp 118}; 119 120def macroop BTC_P_I { 121 rdip t7 122 limm t1, imm 123 srai t2, t1, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 124 limm t3, 1 125 roli t3, t3, imm 126 ldst t1, seg, [1, t2, t7] 127 sexti t0, t1, imm, flags=(CF,) 128 xor t1, t1, t3 129 st t1, seg, [1, t2, t7], disp 130}; 131 132def macroop BTC_R_R { 133 sext t0, reg, regm, flags=(CF,) 134 limm t1, 1 135 rol t1, t1, regm 136 xor reg, reg, t1 137}; 138 139def macroop BTC_M_R { 140 srai t2, reg, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 141 add t2, t2, base 142 limm t3, 1 143 rol t3, t3, reg 144 ldst t1, seg, [scale, index, t2], disp 145 sext t0, t1, reg, flags=(CF,) 146 xor t1, t1, t3 147 st t1, seg, [scale, index, t2], disp 148}; 149 150def macroop BTC_P_R { 151 rdip t7 152 srai t2, reg, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 153 limm t3, 1 154 rol t3, t3, reg 155 ldst t1, seg, [1, t2, t7] 156 sext t0, t1, reg, flags=(CF,) 157 xor t1, t1, t3 158 st t1, seg, [1, t2, t7], disp 159}; 160 161def macroop BTR_R_I { 162 sexti t0, reg, imm, flags=(CF,) 163 limm t1, "(uint64_t(-(2ULL)))" 164 roli t1, t1, imm 165 and reg, reg, t1 166}; 167 168def macroop BTR_M_I { 169 limm t1, imm 170 # This fudges just a tiny bit, but it's reasonable to expect the 171 # microcode generation logic to have the log of the various sizes 172 # floating around as well. 173 srai t2, t1, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 174 add t2, t2, base 175 limm t3, "(uint64_t(-(2ULL)))" 176 roli t3, t3, imm 177 ldst t1, seg, [scale, index, t2], disp 178 sexti t0, t1, imm, flags=(CF,) 179 and t1, t1, t3 180 st t1, seg, [scale, index, t2], disp 181}; 182 183def macroop BTR_P_I { 184 rdip t7 185 limm t1, imm 186 srai t2, t1, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 187 limm t3, "(uint64_t(-(2ULL)))" 188 roli t3, t3, imm 189 ldst t1, seg, [1, t2, t7] 190 sexti t0, t1, imm, flags=(CF,) 191 and t1, t1, t3 192 st t1, seg, [1, t2, t7], disp 193}; 194 195def macroop BTR_R_R { 196 sext t0, reg, regm, flags=(CF,) 197 limm t1, "(uint64_t(-(2ULL)))" 198 rol t1, t1, regm 199 and reg, reg, t1 200}; 201 202def macroop BTR_M_R { 203 srai t2, reg, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 204 add t2, t2, base 205 limm t3, "(uint64_t(-(2ULL)))" 206 rol t3, t3, reg 207 ldst t1, seg, [scale, index, t2], disp 208 sext t0, t1, reg, flags=(CF,) 209 and t1, t1, t3 210 st t1, seg, [scale, index, t2], disp 211}; 212 213def macroop BTR_P_R { 214 rdip t7 215 srai t2, reg, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 216 limm t3, "(uint64_t(-(2ULL)))" 217 rol t3, t3, reg 218 ldst t1, seg, [1, t2, t7] 219 sext t0, t1, reg, flags=(CF,) 220 and t1, t1, t3 221 st t1, seg, [1, t2, t7], disp 222}; 223 224def macroop BTS_R_I { 225 sexti t0, reg, imm, flags=(CF,) 226 limm t1, 1 227 roli t1, t1, imm 228 or reg, reg, t1 229}; 230 231def macroop BTS_M_I { 232 limm t1, imm 233 # This fudges just a tiny bit, but it's reasonable to expect the 234 # microcode generation logic to have the log of the various sizes 235 # floating around as well. 236 srai t2, t1, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 237 add t2, t2, base 238 limm t3, 1 239 roli t3, t3, imm 240 ldst t1, seg, [scale, index, t2], disp 241 sexti t0, t1, imm, flags=(CF,) 242 or t1, t1, t3 243 st t1, seg, [scale, index, t2], disp 244}; 245 246def macroop BTS_P_I { 247 rdip t7 248 limm t1, imm 249 srai t2, t1, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 250 limm t3, 1 251 roli t3, t3, imm 252 ldst t1, seg, [1, t2, t7] 253 sexti t0, t1, imm, flags=(CF,) 254 or t1, t1, t3 255 st t1, seg, [1, t2, t7], disp 256}; 257 258def macroop BTS_R_R { 259 sext t0, reg, regm, flags=(CF,) 260 limm t1, 1 261 rol t1, t1, regm 262 or reg, reg, t1 263}; 264 265def macroop BTS_M_R { 266 srai t2, reg, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 267 add t2, t2, base 268 limm t3, 1 269 rol t3, t3, reg 270 ldst t1, seg, [scale, index, t2], disp 271 sext t0, t1, reg, flags=(CF,) 272 or t1, t1, t3 273 st t1, seg, [scale, index, t2], disp 274}; 275 276def macroop BTS_P_R { 277 rdip t7 278 srai t2, reg, "(env.dataSize == 8) ? 3 : ((env.dataSize == 4) ? 2 : 1)" 279 limm t3, 1 280 rol t3, t3, reg 281 ldst t1, seg, [1, t2, t7] 282 sext t0, t1, reg, flags=(CF,) 283 or t1, t1, t3 284 st t1, seg, [1, t2, t7], disp 285}; 286''' 287