js/src/jit/shared/LIR-x86-shared.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef jit_shared_LIR_x86_shared_h
michael@0 8 #define jit_shared_LIR_x86_shared_h
michael@0 9
michael@0 10 namespace js {
michael@0 11 namespace jit {
michael@0 12
michael@0 13 class LDivI : public LBinaryMath<1>
michael@0 14 {
michael@0 15 public:
michael@0 16 LIR_HEADER(DivI)
michael@0 17
michael@0 18 LDivI(const LAllocation &lhs, const LAllocation &rhs, const LDefinition &temp) {
michael@0 19 setOperand(0, lhs);
michael@0 20 setOperand(1, rhs);
michael@0 21 setTemp(0, temp);
michael@0 22 }
michael@0 23
michael@0 24 const char *extraName() const {
michael@0 25 if (mir()->isTruncated()) {
michael@0 26 if (mir()->canBeNegativeZero()) {
michael@0 27 return mir()->canBeNegativeOverflow()
michael@0 28 ? "Truncate_NegativeZero_NegativeOverflow"
michael@0 29 : "Truncate_NegativeZero";
michael@0 30 }
michael@0 31 return mir()->canBeNegativeOverflow() ? "Truncate_NegativeOverflow" : "Truncate";
michael@0 32 }
michael@0 33 if (mir()->canBeNegativeZero())
michael@0 34 return mir()->canBeNegativeOverflow() ? "NegativeZero_NegativeOverflow" : "NegativeZero";
michael@0 35 return mir()->canBeNegativeOverflow() ? "NegativeOverflow" : nullptr;
michael@0 36 }
michael@0 37
michael@0 38 const LDefinition *remainder() {
michael@0 39 return getTemp(0);
michael@0 40 }
michael@0 41 MDiv *mir() const {
michael@0 42 return mir_->toDiv();
michael@0 43 }
michael@0 44 };
michael@0 45
michael@0 46 // Signed division by a power-of-two constant.
michael@0 47 class LDivPowTwoI : public LBinaryMath<0>
michael@0 48 {
michael@0 49 const int32_t shift_;
michael@0 50 const bool negativeDivisor_;
michael@0 51
michael@0 52 public:
michael@0 53 LIR_HEADER(DivPowTwoI)
michael@0 54
michael@0 55 LDivPowTwoI(const LAllocation &lhs, const LAllocation &lhsCopy, int32_t shift, bool negativeDivisor)
michael@0 56 : shift_(shift), negativeDivisor_(negativeDivisor)
michael@0 57 {
michael@0 58 setOperand(0, lhs);
michael@0 59 setOperand(1, lhsCopy);
michael@0 60 }
michael@0 61
michael@0 62 const LAllocation *numerator() {
michael@0 63 return getOperand(0);
michael@0 64 }
michael@0 65 const LAllocation *numeratorCopy() {
michael@0 66 return getOperand(1);
michael@0 67 }
michael@0 68 int32_t shift() const {
michael@0 69 return shift_;
michael@0 70 }
michael@0 71 bool negativeDivisor() const {
michael@0 72 return negativeDivisor_;
michael@0 73 }
michael@0 74 MDiv *mir() const {
michael@0 75 return mir_->toDiv();
michael@0 76 }
michael@0 77 };
michael@0 78
michael@0 79 class LDivOrModConstantI : public LInstructionHelper<1, 1, 1>
michael@0 80 {
michael@0 81 const int32_t denominator_;
michael@0 82
michael@0 83 public:
michael@0 84 LIR_HEADER(DivOrModConstantI)
michael@0 85
michael@0 86 LDivOrModConstantI(const LAllocation &lhs, int32_t denominator, const LDefinition& temp)
michael@0 87 : denominator_(denominator)
michael@0 88 {
michael@0 89 setOperand(0, lhs);
michael@0 90 setTemp(0, temp);
michael@0 91 }
michael@0 92
michael@0 93 const LAllocation *numerator() {
michael@0 94 return getOperand(0);
michael@0 95 }
michael@0 96 int32_t denominator() const {
michael@0 97 return denominator_;
michael@0 98 }
michael@0 99 MBinaryArithInstruction *mir() const {
michael@0 100 JS_ASSERT(mir_->isDiv() || mir_->isMod());
michael@0 101 return static_cast<MBinaryArithInstruction *>(mir_);
michael@0 102 }
michael@0 103 bool canBeNegativeDividend() const {
michael@0 104 if (mir_->isMod())
michael@0 105 return mir_->toMod()->canBeNegativeDividend();
michael@0 106 return mir_->toDiv()->canBeNegativeDividend();
michael@0 107 }
michael@0 108 };
michael@0 109
michael@0 110 class LModI : public LBinaryMath<1>
michael@0 111 {
michael@0 112 public:
michael@0 113 LIR_HEADER(ModI)
michael@0 114
michael@0 115 LModI(const LAllocation &lhs, const LAllocation &rhs, const LDefinition &temp) {
michael@0 116 setOperand(0, lhs);
michael@0 117 setOperand(1, rhs);
michael@0 118 setTemp(0, temp);
michael@0 119 }
michael@0 120
michael@0 121 const char *extraName() const {
michael@0 122 return mir()->isTruncated() ? "Truncated" : nullptr;
michael@0 123 }
michael@0 124
michael@0 125 const LDefinition *remainder() {
michael@0 126 return getDef(0);
michael@0 127 }
michael@0 128 MMod *mir() const {
michael@0 129 return mir_->toMod();
michael@0 130 }
michael@0 131 };
michael@0 132
michael@0 133 // This class performs a simple x86 'div', yielding either a quotient or remainder depending on
michael@0 134 // whether this instruction is defined to output eax (quotient) or edx (remainder).
michael@0 135 class LUDivOrMod : public LBinaryMath<1>
michael@0 136 {
michael@0 137 public:
michael@0 138 LIR_HEADER(UDivOrMod);
michael@0 139
michael@0 140 LUDivOrMod(const LAllocation &lhs, const LAllocation &rhs, const LDefinition &temp) {
michael@0 141 setOperand(0, lhs);
michael@0 142 setOperand(1, rhs);
michael@0 143 setTemp(0, temp);
michael@0 144 }
michael@0 145
michael@0 146 const LDefinition *remainder() {
michael@0 147 return getTemp(0);
michael@0 148 }
michael@0 149
michael@0 150 const char *extraName() const {
michael@0 151 return mir()->isTruncated() ? "Truncated" : nullptr;
michael@0 152 }
michael@0 153
michael@0 154 MBinaryArithInstruction *mir() const {
michael@0 155 JS_ASSERT(mir_->isDiv() || mir_->isMod());
michael@0 156 return static_cast<MBinaryArithInstruction *>(mir_);
michael@0 157 }
michael@0 158
michael@0 159 bool canBeDivideByZero() const {
michael@0 160 if (mir_->isMod())
michael@0 161 return mir_->toMod()->canBeDivideByZero();
michael@0 162 return mir_->toDiv()->canBeDivideByZero();
michael@0 163 }
michael@0 164 };
michael@0 165
michael@0 166 class LModPowTwoI : public LInstructionHelper<1,1,0>
michael@0 167 {
michael@0 168 const int32_t shift_;
michael@0 169
michael@0 170 public:
michael@0 171 LIR_HEADER(ModPowTwoI)
michael@0 172
michael@0 173 LModPowTwoI(const LAllocation &lhs, int32_t shift)
michael@0 174 : shift_(shift)
michael@0 175 {
michael@0 176 setOperand(0, lhs);
michael@0 177 }
michael@0 178
michael@0 179 int32_t shift() const {
michael@0 180 return shift_;
michael@0 181 }
michael@0 182 const LDefinition *remainder() {
michael@0 183 return getDef(0);
michael@0 184 }
michael@0 185 MMod *mir() const {
michael@0 186 return mir_->toMod();
michael@0 187 }
michael@0 188 };
michael@0 189
michael@0 190 // Double raised to a half power.
michael@0 191 class LPowHalfD : public LInstructionHelper<1, 1, 0>
michael@0 192 {
michael@0 193 public:
michael@0 194 LIR_HEADER(PowHalfD)
michael@0 195 LPowHalfD(const LAllocation &input) {
michael@0 196 setOperand(0, input);
michael@0 197 }
michael@0 198
michael@0 199 const LAllocation *input() {
michael@0 200 return getOperand(0);
michael@0 201 }
michael@0 202 const LDefinition *output() {
michael@0 203 return getDef(0);
michael@0 204 }
michael@0 205 MPowHalf *mir() const {
michael@0 206 return mir_->toPowHalf();
michael@0 207 }
michael@0 208 };
michael@0 209
michael@0 210 // Takes a tableswitch with an integer to decide
michael@0 211 class LTableSwitch : public LInstructionHelper<0, 1, 2>
michael@0 212 {
michael@0 213 public:
michael@0 214 LIR_HEADER(TableSwitch)
michael@0 215
michael@0 216 LTableSwitch(const LAllocation &in, const LDefinition &inputCopy,
michael@0 217 const LDefinition &jumpTablePointer, MTableSwitch *ins)
michael@0 218 {
michael@0 219 setOperand(0, in);
michael@0 220 setTemp(0, inputCopy);
michael@0 221 setTemp(1, jumpTablePointer);
michael@0 222 setMir(ins);
michael@0 223 }
michael@0 224
michael@0 225 MTableSwitch *mir() const {
michael@0 226 return mir_->toTableSwitch();
michael@0 227 }
michael@0 228
michael@0 229 const LAllocation *index() {
michael@0 230 return getOperand(0);
michael@0 231 }
michael@0 232 const LDefinition *tempInt() {
michael@0 233 return getTemp(0);
michael@0 234 }
michael@0 235 const LDefinition *tempPointer() {
michael@0 236 return getTemp(1);
michael@0 237 }
michael@0 238 };
michael@0 239
michael@0 240 // Takes a tableswitch with a value to decide
michael@0 241 class LTableSwitchV : public LInstructionHelper<0, BOX_PIECES, 3>
michael@0 242 {
michael@0 243 public:
michael@0 244 LIR_HEADER(TableSwitchV)
michael@0 245
michael@0 246 LTableSwitchV(const LDefinition &inputCopy, const LDefinition &floatCopy,
michael@0 247 const LDefinition &jumpTablePointer, MTableSwitch *ins)
michael@0 248 {
michael@0 249 setTemp(0, inputCopy);
michael@0 250 setTemp(1, floatCopy);
michael@0 251 setTemp(2, jumpTablePointer);
michael@0 252 setMir(ins);
michael@0 253 }
michael@0 254
michael@0 255 MTableSwitch *mir() const {
michael@0 256 return mir_->toTableSwitch();
michael@0 257 }
michael@0 258
michael@0 259 static const size_t InputValue = 0;
michael@0 260
michael@0 261 const LDefinition *tempInt() {
michael@0 262 return getTemp(0);
michael@0 263 }
michael@0 264 const LDefinition *tempFloat() {
michael@0 265 return getTemp(1);
michael@0 266 }
michael@0 267 const LDefinition *tempPointer() {
michael@0 268 return getTemp(2);
michael@0 269 }
michael@0 270 };
michael@0 271
michael@0 272 class LGuardShape : public LInstructionHelper<0, 1, 0>
michael@0 273 {
michael@0 274 public:
michael@0 275 LIR_HEADER(GuardShape)
michael@0 276
michael@0 277 LGuardShape(const LAllocation &in) {
michael@0 278 setOperand(0, in);
michael@0 279 }
michael@0 280 const MGuardShape *mir() const {
michael@0 281 return mir_->toGuardShape();
michael@0 282 }
michael@0 283 };
michael@0 284
michael@0 285 class LGuardObjectType : public LInstructionHelper<0, 1, 0>
michael@0 286 {
michael@0 287 public:
michael@0 288 LIR_HEADER(GuardObjectType)
michael@0 289
michael@0 290 LGuardObjectType(const LAllocation &in) {
michael@0 291 setOperand(0, in);
michael@0 292 }
michael@0 293 const MGuardObjectType *mir() const {
michael@0 294 return mir_->toGuardObjectType();
michael@0 295 }
michael@0 296 };
michael@0 297
michael@0 298 class LInterruptCheck : public LInstructionHelper<0, 0, 0>
michael@0 299 {
michael@0 300 public:
michael@0 301 LIR_HEADER(InterruptCheck)
michael@0 302 };
michael@0 303
michael@0 304 class LMulI : public LBinaryMath<0, 1>
michael@0 305 {
michael@0 306 public:
michael@0 307 LIR_HEADER(MulI)
michael@0 308
michael@0 309 LMulI(const LAllocation &lhs, const LAllocation &rhs, const LAllocation &lhsCopy) {
michael@0 310 setOperand(0, lhs);
michael@0 311 setOperand(1, rhs);
michael@0 312 setOperand(2, lhsCopy);
michael@0 313 }
michael@0 314
michael@0 315 const char *extraName() const {
michael@0 316 return (mir()->mode() == MMul::Integer)
michael@0 317 ? "Integer"
michael@0 318 : (mir()->canBeNegativeZero() ? "CanBeNegativeZero" : nullptr);
michael@0 319 }
michael@0 320
michael@0 321 MMul *mir() const {
michael@0 322 return mir_->toMul();
michael@0 323 }
michael@0 324 const LAllocation *lhsCopy() {
michael@0 325 return this->getOperand(2);
michael@0 326 }
michael@0 327 };
michael@0 328
michael@0 329 } // namespace jit
michael@0 330 } // namespace js
michael@0 331
michael@0 332 #endif /* jit_shared_LIR_x86_shared_h */

mercurial