barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1 | /* |
oliver@apple.com | c3a5b8c | 2013-07-25 04:01:38 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2013 Apple Inc. |
eric@webkit.org | 6a210e7 | 2010-04-22 13:24:56 +0000 | [diff] [blame] | 3 | * Copyright (C) 2009, 2010 University of Szeged |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 | * 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 | |
| 28 | #ifndef MacroAssemblerARM_h |
| 29 | #define MacroAssemblerARM_h |
| 30 | |
mjs@apple.com | cc66821 | 2010-01-04 11:38:56 +0000 | [diff] [blame] | 31 | #if ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 32 | |
| 33 | #include "ARMAssembler.h" |
| 34 | #include "AbstractMacroAssembler.h" |
| 35 | |
| 36 | namespace JSC { |
| 37 | |
| 38 | class MacroAssemblerARM : public AbstractMacroAssembler<ARMAssembler> { |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 39 | static const int DoubleConditionMask = 0x0f; |
| 40 | static const int DoubleConditionBitSpecial = 0x10; |
| 41 | COMPILE_ASSERT(!(DoubleConditionBitSpecial & DoubleConditionMask), DoubleConditionBitSpecial_should_not_interfere_with_ARMAssembler_Condition_codes); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 42 | public: |
barraclough@apple.com | cdab360 | 2010-07-01 22:56:58 +0000 | [diff] [blame] | 43 | typedef ARMRegisters::FPRegisterID FPRegisterID; |
| 44 | |
commit-queue@webkit.org | 9407369 | 2013-10-22 11:57:32 +0000 | [diff] [blame] | 45 | static RegisterID firstRegister() { return ARMRegisters::r0; } |
| 46 | static RegisterID lastRegister() { return ARMRegisters::r15; } |
| 47 | |
| 48 | static FPRegisterID firstFPRegister() { return ARMRegisters::d0; } |
| 49 | static FPRegisterID lastFPRegister() { return ARMRegisters::d31; } |
| 50 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 51 | enum RelationalCondition { |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 52 | Equal = ARMAssembler::EQ, |
| 53 | NotEqual = ARMAssembler::NE, |
| 54 | Above = ARMAssembler::HI, |
| 55 | AboveOrEqual = ARMAssembler::CS, |
| 56 | Below = ARMAssembler::CC, |
| 57 | BelowOrEqual = ARMAssembler::LS, |
| 58 | GreaterThan = ARMAssembler::GT, |
| 59 | GreaterThanOrEqual = ARMAssembler::GE, |
| 60 | LessThan = ARMAssembler::LT, |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 61 | LessThanOrEqual = ARMAssembler::LE |
| 62 | }; |
| 63 | |
| 64 | enum ResultCondition { |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 65 | Overflow = ARMAssembler::VS, |
| 66 | Signed = ARMAssembler::MI, |
mark.lam@apple.com | a61ec35 | 2013-04-22 17:37:29 +0000 | [diff] [blame] | 67 | PositiveOrZero = ARMAssembler::PL, |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 68 | Zero = ARMAssembler::EQ, |
| 69 | NonZero = ARMAssembler::NE |
| 70 | }; |
| 71 | |
| 72 | enum DoubleCondition { |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 73 | // These conditions will only evaluate to true if the comparison is ordered - i.e. neither operand is NaN. |
| 74 | DoubleEqual = ARMAssembler::EQ, |
| 75 | DoubleNotEqual = ARMAssembler::NE | DoubleConditionBitSpecial, |
barraclough@apple.com | 9ef61d5 | 2009-08-06 05:33:27 +0000 | [diff] [blame] | 76 | DoubleGreaterThan = ARMAssembler::GT, |
| 77 | DoubleGreaterThanOrEqual = ARMAssembler::GE, |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 78 | DoubleLessThan = ARMAssembler::CC, |
| 79 | DoubleLessThanOrEqual = ARMAssembler::LS, |
| 80 | // If either operand is NaN, these conditions always evaluate to true. |
| 81 | DoubleEqualOrUnordered = ARMAssembler::EQ | DoubleConditionBitSpecial, |
| 82 | DoubleNotEqualOrUnordered = ARMAssembler::NE, |
| 83 | DoubleGreaterThanOrUnordered = ARMAssembler::HI, |
| 84 | DoubleGreaterThanOrEqualOrUnordered = ARMAssembler::CS, |
barraclough@apple.com | 2ffca6f | 2009-11-04 23:59:14 +0000 | [diff] [blame] | 85 | DoubleLessThanOrUnordered = ARMAssembler::LT, |
| 86 | DoubleLessThanOrEqualOrUnordered = ARMAssembler::LE, |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 89 | static const RegisterID stackPointerRegister = ARMRegisters::sp; |
commit-queue@webkit.org | 9407369 | 2013-10-22 11:57:32 +0000 | [diff] [blame] | 90 | static const RegisterID framePointerRegister = ARMRegisters::fp; |
eric@webkit.org | 6fe95ae | 2009-10-26 22:49:23 +0000 | [diff] [blame] | 91 | static const RegisterID linkRegister = ARMRegisters::lr; |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 92 | |
| 93 | static const Scale ScalePtr = TimesFour; |
| 94 | |
| 95 | void add32(RegisterID src, RegisterID dest) |
| 96 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 97 | m_assembler.adds(dest, dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 98 | } |
| 99 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 100 | void add32(RegisterID op1, RegisterID op2, RegisterID dest) |
| 101 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 102 | m_assembler.adds(dest, op1, op2); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 103 | } |
| 104 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 105 | void add32(TrustedImm32 imm, Address address) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 106 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 107 | load32(address, ARMRegisters::S1); |
| 108 | add32(imm, ARMRegisters::S1); |
| 109 | store32(ARMRegisters::S1, address); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 110 | } |
| 111 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 112 | void add32(TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 113 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 114 | m_assembler.adds(dest, dest, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 115 | } |
| 116 | |
rgabor@webkit.org | 58c69f8 | 2012-07-16 15:05:57 +0000 | [diff] [blame] | 117 | void add32(AbsoluteAddress src, RegisterID dest) |
| 118 | { |
rgabor@webkit.org | 43ad3e5 | 2012-07-16 16:16:03 +0000 | [diff] [blame] | 119 | move(TrustedImmPtr(src.m_ptr), ARMRegisters::S1); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 120 | m_assembler.dtrUp(ARMAssembler::LoadUint32, ARMRegisters::S1, ARMRegisters::S1, 0); |
rgabor@webkit.org | 58c69f8 | 2012-07-16 15:05:57 +0000 | [diff] [blame] | 121 | add32(ARMRegisters::S1, dest); |
| 122 | } |
| 123 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 124 | void add32(Address src, RegisterID dest) |
| 125 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 126 | load32(src, ARMRegisters::S1); |
| 127 | add32(ARMRegisters::S1, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 128 | } |
| 129 | |
hausmann@webkit.org | 552d5cd | 2012-03-07 11:30:29 +0000 | [diff] [blame] | 130 | void add32(RegisterID src, TrustedImm32 imm, RegisterID dest) |
| 131 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 132 | m_assembler.adds(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
hausmann@webkit.org | 552d5cd | 2012-03-07 11:30:29 +0000 | [diff] [blame] | 133 | } |
| 134 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 135 | void and32(RegisterID src, RegisterID dest) |
| 136 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 137 | m_assembler.bitAnds(dest, dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 138 | } |
| 139 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 140 | void and32(RegisterID op1, RegisterID op2, RegisterID dest) |
| 141 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 142 | m_assembler.bitAnds(dest, op1, op2); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 143 | } |
| 144 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 145 | void and32(TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 146 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 147 | ARMWord w = m_assembler.getImm(imm.m_value, ARMRegisters::S0, true); |
commit-queue@webkit.org | 3dfe8ce | 2012-08-07 22:55:04 +0000 | [diff] [blame] | 148 | if (w & ARMAssembler::Op2InvertedImmediate) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 149 | m_assembler.bics(dest, dest, w & ~ARMAssembler::Op2InvertedImmediate); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 150 | else |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 151 | m_assembler.bitAnds(dest, dest, w); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 152 | } |
| 153 | |
ossy@webkit.org | dac63a0 | 2012-03-06 09:36:30 +0000 | [diff] [blame] | 154 | void and32(TrustedImm32 imm, RegisterID src, RegisterID dest) |
| 155 | { |
| 156 | ARMWord w = m_assembler.getImm(imm.m_value, ARMRegisters::S0, true); |
commit-queue@webkit.org | 3dfe8ce | 2012-08-07 22:55:04 +0000 | [diff] [blame] | 157 | if (w & ARMAssembler::Op2InvertedImmediate) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 158 | m_assembler.bics(dest, src, w & ~ARMAssembler::Op2InvertedImmediate); |
ossy@webkit.org | dac63a0 | 2012-03-06 09:36:30 +0000 | [diff] [blame] | 159 | else |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 160 | m_assembler.bitAnds(dest, src, w); |
ossy@webkit.org | dac63a0 | 2012-03-06 09:36:30 +0000 | [diff] [blame] | 161 | } |
| 162 | |
rgabor@webkit.org | d37989e | 2013-03-19 09:32:54 +0000 | [diff] [blame] | 163 | void and32(Address src, RegisterID dest) |
| 164 | { |
| 165 | load32(src, ARMRegisters::S1); |
| 166 | and32(ARMRegisters::S1, dest); |
| 167 | } |
| 168 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 169 | void lshift32(RegisterID shiftAmount, RegisterID dest) |
barraclough@apple.com | c4a3fa8 | 2009-11-06 09:35:03 +0000 | [diff] [blame] | 170 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 171 | lshift32(dest, shiftAmount, dest); |
| 172 | } |
barraclough@apple.com | c4a3fa8 | 2009-11-06 09:35:03 +0000 | [diff] [blame] | 173 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 174 | void lshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest) |
| 175 | { |
| 176 | ARMWord w = ARMAssembler::getOp2Byte(0x1f); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 177 | m_assembler.bitAnd(ARMRegisters::S0, shiftAmount, w); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 178 | |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 179 | m_assembler.movs(dest, m_assembler.lslRegister(src, ARMRegisters::S0)); |
barraclough@apple.com | c4a3fa8 | 2009-11-06 09:35:03 +0000 | [diff] [blame] | 180 | } |
| 181 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 182 | void lshift32(TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 183 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 184 | m_assembler.movs(dest, m_assembler.lsl(dest, imm.m_value & 0x1f)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 185 | } |
| 186 | |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 187 | void lshift32(RegisterID src, TrustedImm32 imm, RegisterID dest) |
| 188 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 189 | m_assembler.movs(dest, m_assembler.lsl(src, imm.m_value & 0x1f)); |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 190 | } |
| 191 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 192 | void mul32(RegisterID op1, RegisterID op2, RegisterID dest) |
| 193 | { |
| 194 | if (op2 == dest) { |
| 195 | if (op1 == dest) { |
| 196 | move(op2, ARMRegisters::S0); |
| 197 | op2 = ARMRegisters::S0; |
| 198 | } else { |
| 199 | // Swap the operands. |
| 200 | RegisterID tmp = op1; |
| 201 | op1 = op2; |
| 202 | op2 = tmp; |
| 203 | } |
| 204 | } |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 205 | m_assembler.muls(dest, op1, op2); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 206 | } |
| 207 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 208 | void mul32(RegisterID src, RegisterID dest) |
| 209 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 210 | mul32(src, dest, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 211 | } |
| 212 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 213 | void mul32(TrustedImm32 imm, RegisterID src, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 214 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 215 | move(imm, ARMRegisters::S0); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 216 | m_assembler.muls(dest, src, ARMRegisters::S0); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 217 | } |
| 218 | |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 219 | void neg32(RegisterID srcDest) |
| 220 | { |
commit-queue@webkit.org | b6cc185 | 2012-08-15 21:09:00 +0000 | [diff] [blame] | 221 | m_assembler.rsbs(srcDest, srcDest, ARMAssembler::getOp2Byte(0)); |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 222 | } |
| 223 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 224 | void or32(RegisterID src, RegisterID dest) |
| 225 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 226 | m_assembler.orrs(dest, dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 227 | } |
| 228 | |
kadam@inf.u-szeged.hu | 3af1cf1 | 2012-09-18 09:11:05 +0000 | [diff] [blame] | 229 | void or32(RegisterID src, AbsoluteAddress dest) |
| 230 | { |
| 231 | move(TrustedImmPtr(dest.m_ptr), ARMRegisters::S0); |
| 232 | load32(Address(ARMRegisters::S0), ARMRegisters::S1); |
| 233 | or32(src, ARMRegisters::S1); |
| 234 | store32(ARMRegisters::S1, ARMRegisters::S0); |
| 235 | } |
| 236 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 237 | void or32(TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 238 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 239 | m_assembler.orrs(dest, dest, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 240 | } |
| 241 | |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 242 | void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) |
| 243 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 244 | m_assembler.orrs(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 245 | } |
| 246 | |
barraclough@apple.com | 8328f63 | 2011-09-21 18:33:43 +0000 | [diff] [blame] | 247 | void or32(RegisterID op1, RegisterID op2, RegisterID dest) |
| 248 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 249 | m_assembler.orrs(dest, op1, op2); |
barraclough@apple.com | 8328f63 | 2011-09-21 18:33:43 +0000 | [diff] [blame] | 250 | } |
| 251 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 252 | void rshift32(RegisterID shiftAmount, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 253 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 254 | rshift32(dest, shiftAmount, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 255 | } |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 256 | |
| 257 | void rshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest) |
| 258 | { |
| 259 | ARMWord w = ARMAssembler::getOp2Byte(0x1f); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 260 | m_assembler.bitAnd(ARMRegisters::S0, shiftAmount, w); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 261 | |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 262 | m_assembler.movs(dest, m_assembler.asrRegister(src, ARMRegisters::S0)); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 263 | } |
| 264 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 265 | void rshift32(TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 266 | { |
oliver@apple.com | 5b6a0d3 | 2011-07-01 16:33:46 +0000 | [diff] [blame] | 267 | rshift32(dest, imm, dest); |
| 268 | } |
| 269 | |
| 270 | void rshift32(RegisterID src, TrustedImm32 imm, RegisterID dest) |
| 271 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 272 | m_assembler.movs(dest, m_assembler.asr(src, imm.m_value & 0x1f)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 273 | } |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 274 | |
| 275 | void urshift32(RegisterID shiftAmount, RegisterID dest) |
oliver@apple.com | 429ede0 | 2010-04-30 07:56:38 +0000 | [diff] [blame] | 276 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 277 | urshift32(dest, shiftAmount, dest); |
oliver@apple.com | 429ede0 | 2010-04-30 07:56:38 +0000 | [diff] [blame] | 278 | } |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 279 | |
| 280 | void urshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest) |
| 281 | { |
| 282 | ARMWord w = ARMAssembler::getOp2Byte(0x1f); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 283 | m_assembler.bitAnd(ARMRegisters::S0, shiftAmount, w); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 284 | |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 285 | m_assembler.movs(dest, m_assembler.lsrRegister(src, ARMRegisters::S0)); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 286 | } |
| 287 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 288 | void urshift32(TrustedImm32 imm, RegisterID dest) |
oliver@apple.com | 429ede0 | 2010-04-30 07:56:38 +0000 | [diff] [blame] | 289 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 290 | m_assembler.movs(dest, m_assembler.lsr(dest, imm.m_value & 0x1f)); |
oliver@apple.com | 429ede0 | 2010-04-30 07:56:38 +0000 | [diff] [blame] | 291 | } |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 292 | |
| 293 | void urshift32(RegisterID src, TrustedImm32 imm, RegisterID dest) |
| 294 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 295 | m_assembler.movs(dest, m_assembler.lsr(src, imm.m_value & 0x1f)); |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 296 | } |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 297 | |
| 298 | void sub32(RegisterID src, RegisterID dest) |
| 299 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 300 | m_assembler.subs(dest, dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 301 | } |
| 302 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 303 | void sub32(TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 304 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 305 | m_assembler.subs(dest, dest, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 306 | } |
| 307 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 308 | void sub32(TrustedImm32 imm, Address address) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 309 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 310 | load32(address, ARMRegisters::S1); |
| 311 | sub32(imm, ARMRegisters::S1); |
| 312 | store32(ARMRegisters::S1, address); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | void sub32(Address src, RegisterID dest) |
| 316 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 317 | load32(src, ARMRegisters::S1); |
| 318 | sub32(ARMRegisters::S1, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 319 | } |
| 320 | |
hausmann@webkit.org | 552d5cd | 2012-03-07 11:30:29 +0000 | [diff] [blame] | 321 | void sub32(RegisterID src, TrustedImm32 imm, RegisterID dest) |
| 322 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 323 | m_assembler.subs(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
hausmann@webkit.org | 552d5cd | 2012-03-07 11:30:29 +0000 | [diff] [blame] | 324 | } |
| 325 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 326 | void xor32(RegisterID src, RegisterID dest) |
| 327 | { |
commit-queue@webkit.org | b6cc185 | 2012-08-15 21:09:00 +0000 | [diff] [blame] | 328 | m_assembler.eors(dest, dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 329 | } |
| 330 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 331 | void xor32(RegisterID op1, RegisterID op2, RegisterID dest) |
| 332 | { |
commit-queue@webkit.org | b6cc185 | 2012-08-15 21:09:00 +0000 | [diff] [blame] | 333 | m_assembler.eors(dest, op1, op2); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 334 | } |
| 335 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 336 | void xor32(TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 337 | { |
barraclough@apple.com | a6bdfc8 | 2012-02-27 18:26:23 +0000 | [diff] [blame] | 338 | if (imm.m_value == -1) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 339 | m_assembler.mvns(dest, dest); |
barraclough@apple.com | a6bdfc8 | 2012-02-27 18:26:23 +0000 | [diff] [blame] | 340 | else |
commit-queue@webkit.org | b6cc185 | 2012-08-15 21:09:00 +0000 | [diff] [blame] | 341 | m_assembler.eors(dest, dest, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 342 | } |
| 343 | |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 344 | void xor32(TrustedImm32 imm, RegisterID src, RegisterID dest) |
| 345 | { |
| 346 | if (imm.m_value == -1) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 347 | m_assembler.mvns(dest, src); |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 348 | else |
commit-queue@webkit.org | b6cc185 | 2012-08-15 21:09:00 +0000 | [diff] [blame] | 349 | m_assembler.eors(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 350 | } |
| 351 | |
loki@webkit.org | 0f28f9b | 2010-11-20 22:02:36 +0000 | [diff] [blame] | 352 | void countLeadingZeros32(RegisterID src, RegisterID dest) |
| 353 | { |
| 354 | #if WTF_ARM_ARCH_AT_LEAST(5) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 355 | m_assembler.clz(dest, src); |
loki@webkit.org | 0f28f9b | 2010-11-20 22:02:36 +0000 | [diff] [blame] | 356 | #else |
| 357 | UNUSED_PARAM(src); |
| 358 | UNUSED_PARAM(dest); |
oliver@apple.com | 5598c18 | 2013-01-23 22:25:07 +0000 | [diff] [blame] | 359 | RELEASE_ASSERT_NOT_REACHED(); |
loki@webkit.org | 0f28f9b | 2010-11-20 22:02:36 +0000 | [diff] [blame] | 360 | #endif |
| 361 | } |
| 362 | |
loki@webkit.org | 2acccd0 | 2010-03-09 09:36:06 +0000 | [diff] [blame] | 363 | void load8(ImplicitAddress address, RegisterID dest) |
| 364 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 365 | m_assembler.dataTransfer32(ARMAssembler::LoadUint8, dest, address.base, address.offset); |
loki@webkit.org | 2acccd0 | 2010-03-09 09:36:06 +0000 | [diff] [blame] | 366 | } |
| 367 | |
msaboff@apple.com | 2cc4150 | 2011-09-12 22:17:53 +0000 | [diff] [blame] | 368 | void load8(BaseIndex address, RegisterID dest) |
| 369 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 370 | m_assembler.baseIndexTransfer32(ARMAssembler::LoadUint8, dest, address.base, address.index, static_cast<int>(address.scale), address.offset); |
| 371 | } |
| 372 | |
| 373 | void load8Signed(BaseIndex address, RegisterID dest) |
| 374 | { |
| 375 | m_assembler.baseIndexTransfer16(ARMAssembler::LoadInt8, dest, address.base, address.index, static_cast<int>(address.scale), address.offset); |
| 376 | } |
| 377 | |
| 378 | void load16(ImplicitAddress address, RegisterID dest) |
| 379 | { |
| 380 | m_assembler.dataTransfer16(ARMAssembler::LoadUint16, dest, address.base, address.offset); |
| 381 | } |
| 382 | |
| 383 | void load16(BaseIndex address, RegisterID dest) |
| 384 | { |
| 385 | m_assembler.baseIndexTransfer16(ARMAssembler::LoadUint16, dest, address.base, address.index, static_cast<int>(address.scale), address.offset); |
| 386 | } |
| 387 | |
| 388 | void load16Signed(BaseIndex address, RegisterID dest) |
| 389 | { |
| 390 | m_assembler.baseIndexTransfer16(ARMAssembler::LoadInt16, dest, address.base, address.index, static_cast<int>(address.scale), address.offset); |
msaboff@apple.com | 2cc4150 | 2011-09-12 22:17:53 +0000 | [diff] [blame] | 391 | } |
| 392 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 393 | void load32(ImplicitAddress address, RegisterID dest) |
| 394 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 395 | m_assembler.dataTransfer32(ARMAssembler::LoadUint32, dest, address.base, address.offset); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | void load32(BaseIndex address, RegisterID dest) |
| 399 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 400 | m_assembler.baseIndexTransfer32(ARMAssembler::LoadUint32, dest, address.base, address.index, static_cast<int>(address.scale), address.offset); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 401 | } |
| 402 | |
mjs@apple.com | cc66821 | 2010-01-04 11:38:56 +0000 | [diff] [blame] | 403 | #if CPU(ARMV5_OR_LOWER) |
eric@webkit.org | 16d65d1 | 2009-09-26 02:27:02 +0000 | [diff] [blame] | 404 | void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest); |
| 405 | #else |
| 406 | void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest) |
| 407 | { |
| 408 | load32(address, dest); |
| 409 | } |
| 410 | #endif |
| 411 | |
commit-queue@webkit.org | a7d13c8 | 2011-12-08 23:16:54 +0000 | [diff] [blame] | 412 | void load16Unaligned(BaseIndex address, RegisterID dest) |
| 413 | { |
| 414 | load16(address, dest); |
| 415 | } |
| 416 | |
zherczeg@webkit.org | adfdb1f | 2012-07-08 10:00:04 +0000 | [diff] [blame] | 417 | ConvertibleLoadLabel convertibleLoadPtr(Address address, RegisterID dest) |
| 418 | { |
| 419 | ConvertibleLoadLabel result(this); |
| 420 | ASSERT(address.offset >= 0 && address.offset <= 255); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 421 | m_assembler.dtrUp(ARMAssembler::LoadUint32, dest, address.base, address.offset); |
zherczeg@webkit.org | adfdb1f | 2012-07-08 10:00:04 +0000 | [diff] [blame] | 422 | return result; |
| 423 | } |
| 424 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 425 | DataLabel32 load32WithAddressOffsetPatch(Address address, RegisterID dest) |
| 426 | { |
| 427 | DataLabel32 dataLabel(this); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 428 | m_assembler.ldrUniqueImmediate(ARMRegisters::S0, 0); |
| 429 | m_assembler.dtrUpRegister(ARMAssembler::LoadUint32, dest, address.base, ARMRegisters::S0); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 430 | return dataLabel; |
| 431 | } |
zherczeg@webkit.org | 4a63758 | 2012-07-26 12:29:10 +0000 | [diff] [blame] | 432 | |
| 433 | static bool isCompactPtrAlignedAddressOffset(ptrdiff_t value) |
| 434 | { |
| 435 | return value >= -4095 && value <= 4095; |
| 436 | } |
| 437 | |
oliver@apple.com | 2c012fa | 2011-05-17 20:02:41 +0000 | [diff] [blame] | 438 | DataLabelCompact load32WithCompactAddressOffsetPatch(Address address, RegisterID dest) |
| 439 | { |
| 440 | DataLabelCompact dataLabel(this); |
zherczeg@webkit.org | 4a63758 | 2012-07-26 12:29:10 +0000 | [diff] [blame] | 441 | ASSERT(isCompactPtrAlignedAddressOffset(address.offset)); |
| 442 | if (address.offset >= 0) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 443 | m_assembler.dtrUp(ARMAssembler::LoadUint32, dest, address.base, address.offset); |
zherczeg@webkit.org | 4a63758 | 2012-07-26 12:29:10 +0000 | [diff] [blame] | 444 | else |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 445 | m_assembler.dtrDown(ARMAssembler::LoadUint32, dest, address.base, address.offset); |
oliver@apple.com | 2c012fa | 2011-05-17 20:02:41 +0000 | [diff] [blame] | 446 | return dataLabel; |
| 447 | } |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 448 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 449 | DataLabel32 store32WithAddressOffsetPatch(RegisterID src, Address address) |
| 450 | { |
| 451 | DataLabel32 dataLabel(this); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 452 | m_assembler.ldrUniqueImmediate(ARMRegisters::S0, 0); |
| 453 | m_assembler.dtrUpRegister(ARMAssembler::StoreUint32, src, address.base, ARMRegisters::S0); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 454 | return dataLabel; |
| 455 | } |
| 456 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 457 | void store8(RegisterID src, BaseIndex address) |
| 458 | { |
| 459 | m_assembler.baseIndexTransfer32(ARMAssembler::StoreUint8, src, address.base, address.index, static_cast<int>(address.scale), address.offset); |
| 460 | } |
| 461 | |
paroga@webkit.org | 34f68fd | 2013-04-10 20:30:19 +0000 | [diff] [blame] | 462 | void store8(TrustedImm32 imm, const void* address) |
rgabor@webkit.org | 5e7efa3 | 2012-09-20 13:25:12 +0000 | [diff] [blame] | 463 | { |
| 464 | move(TrustedImm32(reinterpret_cast<ARMWord>(address)), ARMRegisters::S0); |
paroga@webkit.org | 34f68fd | 2013-04-10 20:30:19 +0000 | [diff] [blame] | 465 | move(imm, ARMRegisters::S1); |
rgabor@webkit.org | 5e7efa3 | 2012-09-20 13:25:12 +0000 | [diff] [blame] | 466 | m_assembler.dtrUp(ARMAssembler::StoreUint8, ARMRegisters::S1, ARMRegisters::S0, 0); |
| 467 | } |
| 468 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 469 | void store16(RegisterID src, BaseIndex address) |
| 470 | { |
| 471 | m_assembler.baseIndexTransfer16(ARMAssembler::StoreUint16, src, address.base, address.index, static_cast<int>(address.scale), address.offset); |
| 472 | } |
| 473 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 474 | void store32(RegisterID src, ImplicitAddress address) |
| 475 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 476 | m_assembler.dataTransfer32(ARMAssembler::StoreUint32, src, address.base, address.offset); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | void store32(RegisterID src, BaseIndex address) |
| 480 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 481 | m_assembler.baseIndexTransfer32(ARMAssembler::StoreUint32, src, address.base, address.index, static_cast<int>(address.scale), address.offset); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 482 | } |
| 483 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 484 | void store32(TrustedImm32 imm, ImplicitAddress address) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 485 | { |
barraclough@apple.com | aa82d50 | 2012-05-06 05:27:29 +0000 | [diff] [blame] | 486 | move(imm, ARMRegisters::S1); |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 487 | store32(ARMRegisters::S1, address); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 488 | } |
| 489 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 490 | void store32(TrustedImm32 imm, BaseIndex address) |
| 491 | { |
| 492 | move(imm, ARMRegisters::S1); |
| 493 | m_assembler.baseIndexTransfer32(ARMAssembler::StoreUint32, ARMRegisters::S1, address.base, address.index, static_cast<int>(address.scale), address.offset); |
| 494 | } |
| 495 | |
paroga@webkit.org | 34f68fd | 2013-04-10 20:30:19 +0000 | [diff] [blame] | 496 | void store32(RegisterID src, const void* address) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 497 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 498 | m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast<ARMWord>(address)); |
| 499 | m_assembler.dtrUp(ARMAssembler::StoreUint32, src, ARMRegisters::S0, 0); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 500 | } |
| 501 | |
paroga@webkit.org | 34f68fd | 2013-04-10 20:30:19 +0000 | [diff] [blame] | 502 | void store32(TrustedImm32 imm, const void* address) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 503 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 504 | m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast<ARMWord>(address)); |
barraclough@apple.com | aa82d50 | 2012-05-06 05:27:29 +0000 | [diff] [blame] | 505 | m_assembler.moveImm(imm.m_value, ARMRegisters::S1); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 506 | m_assembler.dtrUp(ARMAssembler::StoreUint32, ARMRegisters::S1, ARMRegisters::S0, 0); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | void pop(RegisterID dest) |
| 510 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 511 | m_assembler.pop(dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | void push(RegisterID src) |
| 515 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 516 | m_assembler.push(src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | void push(Address address) |
| 520 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 521 | load32(address, ARMRegisters::S1); |
| 522 | push(ARMRegisters::S1); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 523 | } |
| 524 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 525 | void push(TrustedImm32 imm) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 526 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 527 | move(imm, ARMRegisters::S0); |
| 528 | push(ARMRegisters::S0); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 529 | } |
| 530 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 531 | void move(TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 532 | { |
barraclough@apple.com | aa82d50 | 2012-05-06 05:27:29 +0000 | [diff] [blame] | 533 | m_assembler.moveImm(imm.m_value, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | void move(RegisterID src, RegisterID dest) |
| 537 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 538 | if (src != dest) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 539 | m_assembler.mov(dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 540 | } |
| 541 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 542 | void move(TrustedImmPtr imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 543 | { |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 544 | move(TrustedImm32(imm), dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | void swap(RegisterID reg1, RegisterID reg2) |
| 548 | { |
rgabor@webkit.org | 61e0f58 | 2013-05-27 12:23:13 +0000 | [diff] [blame] | 549 | xor32(reg1, reg2); |
| 550 | xor32(reg2, reg1); |
| 551 | xor32(reg1, reg2); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | void signExtend32ToPtr(RegisterID src, RegisterID dest) |
| 555 | { |
| 556 | if (src != dest) |
| 557 | move(src, dest); |
| 558 | } |
| 559 | |
| 560 | void zeroExtend32ToPtr(RegisterID src, RegisterID dest) |
| 561 | { |
| 562 | if (src != dest) |
| 563 | move(src, dest); |
| 564 | } |
| 565 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 566 | Jump branch8(RelationalCondition cond, Address left, TrustedImm32 right) |
loki@webkit.org | 2acccd0 | 2010-03-09 09:36:06 +0000 | [diff] [blame] | 567 | { |
| 568 | load8(left, ARMRegisters::S1); |
| 569 | return branch32(cond, ARMRegisters::S1, right); |
| 570 | } |
| 571 | |
msaboff@apple.com | 2cc4150 | 2011-09-12 22:17:53 +0000 | [diff] [blame] | 572 | Jump branch8(RelationalCondition cond, BaseIndex left, TrustedImm32 right) |
| 573 | { |
| 574 | ASSERT(!(right.m_value & 0xFFFFFF00)); |
| 575 | load8(left, ARMRegisters::S1); |
| 576 | return branch32(cond, ARMRegisters::S1, right); |
| 577 | } |
| 578 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 579 | Jump branch32(RelationalCondition cond, RegisterID left, RegisterID right, int useConstantPool = 0) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 580 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 581 | m_assembler.cmp(left, right); |
barraclough@apple.com | 970af2c | 2009-08-13 05:58:36 +0000 | [diff] [blame] | 582 | return Jump(m_assembler.jmp(ARMCondition(cond), useConstantPool)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 583 | } |
| 584 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 585 | Jump branch32(RelationalCondition cond, RegisterID left, TrustedImm32 right, int useConstantPool = 0) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 586 | { |
ossy@webkit.org | a32a527 | 2012-11-26 14:47:40 +0000 | [diff] [blame] | 587 | internalCompare32(left, right); |
barraclough@apple.com | 970af2c | 2009-08-13 05:58:36 +0000 | [diff] [blame] | 588 | return Jump(m_assembler.jmp(ARMCondition(cond), useConstantPool)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 589 | } |
| 590 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 591 | Jump branch32(RelationalCondition cond, RegisterID left, Address right) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 592 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 593 | load32(right, ARMRegisters::S1); |
| 594 | return branch32(cond, left, ARMRegisters::S1); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 595 | } |
| 596 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 597 | Jump branch32(RelationalCondition cond, Address left, RegisterID right) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 598 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 599 | load32(left, ARMRegisters::S1); |
| 600 | return branch32(cond, ARMRegisters::S1, right); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 601 | } |
| 602 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 603 | Jump branch32(RelationalCondition cond, Address left, TrustedImm32 right) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 604 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 605 | load32(left, ARMRegisters::S1); |
| 606 | return branch32(cond, ARMRegisters::S1, right); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 607 | } |
| 608 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 609 | Jump branch32(RelationalCondition cond, BaseIndex left, TrustedImm32 right) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 610 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 611 | load32(left, ARMRegisters::S1); |
| 612 | return branch32(cond, ARMRegisters::S1, right); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 613 | } |
| 614 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 615 | Jump branch32WithUnalignedHalfWords(RelationalCondition cond, BaseIndex left, TrustedImm32 right) |
eric@webkit.org | 16d65d1 | 2009-09-26 02:27:02 +0000 | [diff] [blame] | 616 | { |
| 617 | load32WithUnalignedHalfWords(left, ARMRegisters::S1); |
| 618 | return branch32(cond, ARMRegisters::S1, right); |
| 619 | } |
| 620 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 621 | Jump branchTest8(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1)) |
loki@webkit.org | 2acccd0 | 2010-03-09 09:36:06 +0000 | [diff] [blame] | 622 | { |
| 623 | load8(address, ARMRegisters::S1); |
| 624 | return branchTest32(cond, ARMRegisters::S1, mask); |
| 625 | } |
| 626 | |
fpizlo@apple.com | b75911b | 2012-06-13 20:53:52 +0000 | [diff] [blame] | 627 | Jump branchTest8(ResultCondition cond, AbsoluteAddress address, TrustedImm32 mask = TrustedImm32(-1)) |
| 628 | { |
| 629 | move(TrustedImmPtr(address.m_ptr), ARMRegisters::S1); |
| 630 | load8(Address(ARMRegisters::S1), ARMRegisters::S1); |
| 631 | return branchTest32(cond, ARMRegisters::S1, mask); |
| 632 | } |
| 633 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 634 | Jump branchTest32(ResultCondition cond, RegisterID reg, RegisterID mask) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 635 | { |
| 636 | ASSERT((cond == Zero) || (cond == NonZero)); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 637 | m_assembler.tst(reg, mask); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 638 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 639 | } |
| 640 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 641 | Jump branchTest32(ResultCondition cond, RegisterID reg, TrustedImm32 mask = TrustedImm32(-1)) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 642 | { |
| 643 | ASSERT((cond == Zero) || (cond == NonZero)); |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 644 | ARMWord w = m_assembler.getImm(mask.m_value, ARMRegisters::S0, true); |
commit-queue@webkit.org | 3dfe8ce | 2012-08-07 22:55:04 +0000 | [diff] [blame] | 645 | if (w & ARMAssembler::Op2InvertedImmediate) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 646 | m_assembler.bics(ARMRegisters::S0, reg, w & ~ARMAssembler::Op2InvertedImmediate); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 647 | else |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 648 | m_assembler.tst(reg, w); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 649 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 650 | } |
| 651 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 652 | Jump branchTest32(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1)) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 653 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 654 | load32(address, ARMRegisters::S1); |
| 655 | return branchTest32(cond, ARMRegisters::S1, mask); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 656 | } |
| 657 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 658 | Jump branchTest32(ResultCondition cond, BaseIndex address, TrustedImm32 mask = TrustedImm32(-1)) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 659 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 660 | load32(address, ARMRegisters::S1); |
| 661 | return branchTest32(cond, ARMRegisters::S1, mask); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | Jump jump() |
| 665 | { |
| 666 | return Jump(m_assembler.jmp()); |
| 667 | } |
| 668 | |
| 669 | void jump(RegisterID target) |
| 670 | { |
eric@webkit.org | 6a210e7 | 2010-04-22 13:24:56 +0000 | [diff] [blame] | 671 | m_assembler.bx(target); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | void jump(Address address) |
| 675 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 676 | load32(address, ARMRegisters::pc); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 677 | } |
| 678 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 679 | void jump(AbsoluteAddress address) |
| 680 | { |
| 681 | move(TrustedImmPtr(address.m_ptr), ARMRegisters::S0); |
| 682 | load32(Address(ARMRegisters::S0, 0), ARMRegisters::pc); |
| 683 | } |
| 684 | |
commit-queue@webkit.org | 7fb1511 | 2012-10-10 08:31:40 +0000 | [diff] [blame] | 685 | void moveDoubleToInts(FPRegisterID src, RegisterID dest1, RegisterID dest2) |
| 686 | { |
| 687 | m_assembler.vmov(dest1, dest2, src); |
| 688 | } |
| 689 | |
ossy@webkit.org | 0d44f41 | 2013-03-06 17:39:37 +0000 | [diff] [blame] | 690 | void moveIntsToDouble(RegisterID src1, RegisterID src2, FPRegisterID dest, FPRegisterID) |
commit-queue@webkit.org | 7fb1511 | 2012-10-10 08:31:40 +0000 | [diff] [blame] | 691 | { |
commit-queue@webkit.org | 7fb1511 | 2012-10-10 08:31:40 +0000 | [diff] [blame] | 692 | m_assembler.vmov(dest, src1, src2); |
| 693 | } |
| 694 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 695 | Jump branchAdd32(ResultCondition cond, RegisterID src, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 696 | { |
mark.lam@apple.com | 3089c6b | 2013-05-21 16:44:01 +0000 | [diff] [blame] | 697 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) |
| 698 | || (cond == NonZero) || (cond == PositiveOrZero)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 699 | add32(src, dest); |
| 700 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 701 | } |
| 702 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 703 | Jump branchAdd32(ResultCondition cond, RegisterID op1, RegisterID op2, RegisterID dest) |
| 704 | { |
mark.lam@apple.com | 3089c6b | 2013-05-21 16:44:01 +0000 | [diff] [blame] | 705 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) |
| 706 | || (cond == NonZero) || (cond == PositiveOrZero)); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 707 | add32(op1, op2, dest); |
| 708 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 709 | } |
| 710 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 711 | Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 712 | { |
mark.lam@apple.com | 3089c6b | 2013-05-21 16:44:01 +0000 | [diff] [blame] | 713 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) |
| 714 | || (cond == NonZero) || (cond == PositiveOrZero)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 715 | add32(imm, dest); |
| 716 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 717 | } |
| 718 | |
hausmann@webkit.org | 552d5cd | 2012-03-07 11:30:29 +0000 | [diff] [blame] | 719 | Jump branchAdd32(ResultCondition cond, RegisterID src, TrustedImm32 imm, RegisterID dest) |
| 720 | { |
mark.lam@apple.com | 3089c6b | 2013-05-21 16:44:01 +0000 | [diff] [blame] | 721 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) |
| 722 | || (cond == NonZero) || (cond == PositiveOrZero)); |
hausmann@webkit.org | 552d5cd | 2012-03-07 11:30:29 +0000 | [diff] [blame] | 723 | add32(src, imm, dest); |
| 724 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 725 | } |
| 726 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 727 | Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, AbsoluteAddress dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 728 | { |
mark.lam@apple.com | 3089c6b | 2013-05-21 16:44:01 +0000 | [diff] [blame] | 729 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) |
| 730 | || (cond == NonZero) || (cond == PositiveOrZero)); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 731 | add32(imm, dest); |
| 732 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 733 | } |
| 734 | |
| 735 | void mull32(RegisterID op1, RegisterID op2, RegisterID dest) |
| 736 | { |
| 737 | if (op2 == dest) { |
| 738 | if (op1 == dest) { |
| 739 | move(op2, ARMRegisters::S0); |
| 740 | op2 = ARMRegisters::S0; |
| 741 | } else { |
| 742 | // Swap the operands. |
| 743 | RegisterID tmp = op1; |
| 744 | op1 = op2; |
| 745 | op2 = tmp; |
| 746 | } |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 747 | } |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 748 | m_assembler.mull(ARMRegisters::S1, dest, op1, op2); |
| 749 | m_assembler.cmp(ARMRegisters::S1, m_assembler.asr(dest, 31)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 750 | } |
| 751 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 752 | Jump branchMul32(ResultCondition cond, RegisterID src1, RegisterID src2, RegisterID dest) |
| 753 | { |
| 754 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); |
| 755 | if (cond == Overflow) { |
| 756 | mull32(src1, src2, dest); |
| 757 | cond = NonZero; |
| 758 | } |
| 759 | else |
| 760 | mul32(src1, src2, dest); |
| 761 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 762 | } |
| 763 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 764 | Jump branchMul32(ResultCondition cond, RegisterID src, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 765 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 766 | return branchMul32(cond, src, dest, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 767 | } |
| 768 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 769 | Jump branchMul32(ResultCondition cond, TrustedImm32 imm, RegisterID src, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 770 | { |
| 771 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); |
| 772 | if (cond == Overflow) { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 773 | move(imm, ARMRegisters::S0); |
| 774 | mull32(ARMRegisters::S0, src, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 775 | cond = NonZero; |
| 776 | } |
| 777 | else |
| 778 | mul32(imm, src, dest); |
| 779 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 780 | } |
| 781 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 782 | Jump branchSub32(ResultCondition cond, RegisterID src, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 783 | { |
| 784 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); |
| 785 | sub32(src, dest); |
| 786 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 787 | } |
| 788 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 789 | Jump branchSub32(ResultCondition cond, TrustedImm32 imm, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 790 | { |
| 791 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); |
| 792 | sub32(imm, dest); |
| 793 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 794 | } |
| 795 | |
hausmann@webkit.org | 552d5cd | 2012-03-07 11:30:29 +0000 | [diff] [blame] | 796 | Jump branchSub32(ResultCondition cond, RegisterID src, TrustedImm32 imm, RegisterID dest) |
| 797 | { |
| 798 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); |
| 799 | sub32(src, imm, dest); |
| 800 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 801 | } |
| 802 | |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 803 | Jump branchSub32(ResultCondition cond, RegisterID op1, RegisterID op2, RegisterID dest) |
| 804 | { |
| 805 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 806 | m_assembler.subs(dest, op1, op2); |
commit-queue@webkit.org | 1e0469c | 2012-05-03 02:15:49 +0000 | [diff] [blame] | 807 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 808 | } |
| 809 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 810 | Jump branchNeg32(ResultCondition cond, RegisterID srcDest) |
ggaren@apple.com | 5a0ed29 | 2010-03-22 18:33:23 +0000 | [diff] [blame] | 811 | { |
| 812 | ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); |
| 813 | neg32(srcDest); |
| 814 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 815 | } |
| 816 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 817 | Jump branchOr32(ResultCondition cond, RegisterID src, RegisterID dest) |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 818 | { |
| 819 | ASSERT((cond == Signed) || (cond == Zero) || (cond == NonZero)); |
| 820 | or32(src, dest); |
| 821 | return Jump(m_assembler.jmp(ARMCondition(cond))); |
| 822 | } |
| 823 | |
ossy@webkit.org | a32a527 | 2012-11-26 14:47:40 +0000 | [diff] [blame] | 824 | PatchableJump patchableBranch32(RelationalCondition cond, RegisterID reg, TrustedImm32 imm) |
| 825 | { |
| 826 | internalCompare32(reg, imm); |
| 827 | Jump jump(m_assembler.loadBranchTarget(ARMRegisters::S1, ARMCondition(cond), true)); |
| 828 | m_assembler.bx(ARMRegisters::S1, ARMCondition(cond)); |
| 829 | return PatchableJump(jump); |
| 830 | } |
| 831 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 832 | void breakpoint() |
| 833 | { |
| 834 | m_assembler.bkpt(0); |
| 835 | } |
| 836 | |
| 837 | Call nearCall() |
| 838 | { |
eric@webkit.org | 6a210e7 | 2010-04-22 13:24:56 +0000 | [diff] [blame] | 839 | m_assembler.loadBranchTarget(ARMRegisters::S1, ARMAssembler::AL, true); |
| 840 | return Call(m_assembler.blx(ARMRegisters::S1), Call::LinkableNear); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | Call call(RegisterID target) |
| 844 | { |
loki@webkit.org | ea6cf18 | 2010-11-24 13:04:35 +0000 | [diff] [blame] | 845 | return Call(m_assembler.blx(target), Call::None); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | void call(Address address) |
| 849 | { |
| 850 | call32(address.base, address.offset); |
| 851 | } |
| 852 | |
| 853 | void ret() |
| 854 | { |
eric@webkit.org | 6a210e7 | 2010-04-22 13:24:56 +0000 | [diff] [blame] | 855 | m_assembler.bx(linkRegister); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 856 | } |
| 857 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 858 | void compare32(RelationalCondition cond, RegisterID left, RegisterID right, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 859 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 860 | m_assembler.cmp(left, right); |
| 861 | m_assembler.mov(dest, ARMAssembler::getOp2Byte(0)); |
| 862 | m_assembler.mov(dest, ARMAssembler::getOp2Byte(1), ARMCondition(cond)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 863 | } |
| 864 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 865 | void compare32(RelationalCondition cond, RegisterID left, TrustedImm32 right, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 866 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 867 | m_assembler.cmp(left, m_assembler.getImm(right.m_value, ARMRegisters::S0)); |
| 868 | m_assembler.mov(dest, ARMAssembler::getOp2Byte(0)); |
| 869 | m_assembler.mov(dest, ARMAssembler::getOp2Byte(1), ARMCondition(cond)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 870 | } |
| 871 | |
ossy@webkit.org | d2b2b7f | 2012-04-12 09:51:00 +0000 | [diff] [blame] | 872 | void compare8(RelationalCondition cond, Address left, TrustedImm32 right, RegisterID dest) |
fpizlo@apple.com | 9c149ea | 2012-04-12 01:13:07 +0000 | [diff] [blame] | 873 | { |
ossy@webkit.org | d2b2b7f | 2012-04-12 09:51:00 +0000 | [diff] [blame] | 874 | load8(left, ARMRegisters::S1); |
fpizlo@apple.com | 9c149ea | 2012-04-12 01:13:07 +0000 | [diff] [blame] | 875 | compare32(cond, ARMRegisters::S1, right, dest); |
| 876 | } |
| 877 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 878 | void test32(ResultCondition cond, RegisterID reg, TrustedImm32 mask, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 879 | { |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 880 | if (mask.m_value == -1) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 881 | m_assembler.cmp(0, reg); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 882 | else |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 883 | m_assembler.tst(reg, m_assembler.getImm(mask.m_value, ARMRegisters::S0)); |
| 884 | m_assembler.mov(dest, ARMAssembler::getOp2Byte(0)); |
| 885 | m_assembler.mov(dest, ARMAssembler::getOp2Byte(1), ARMCondition(cond)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 886 | } |
| 887 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 888 | void test32(ResultCondition cond, Address address, TrustedImm32 mask, RegisterID dest) |
commit-queue@webkit.org | 4fa9acd | 2011-02-01 14:40:03 +0000 | [diff] [blame] | 889 | { |
| 890 | load32(address, ARMRegisters::S1); |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 891 | test32(cond, ARMRegisters::S1, mask, dest); |
commit-queue@webkit.org | 4fa9acd | 2011-02-01 14:40:03 +0000 | [diff] [blame] | 892 | } |
| 893 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 894 | void test8(ResultCondition cond, Address address, TrustedImm32 mask, RegisterID dest) |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 895 | { |
commit-queue@webkit.org | 4fa9acd | 2011-02-01 14:40:03 +0000 | [diff] [blame] | 896 | load8(address, ARMRegisters::S1); |
barraclough@apple.com | cc5c351 | 2011-04-20 19:02:01 +0000 | [diff] [blame] | 897 | test32(cond, ARMRegisters::S1, mask, dest); |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 898 | } |
| 899 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 900 | void add32(TrustedImm32 imm, RegisterID src, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 901 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 902 | m_assembler.add(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 903 | } |
| 904 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 905 | void add32(TrustedImm32 imm, AbsoluteAddress address) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 906 | { |
paroga@webkit.org | 34f68fd | 2013-04-10 20:30:19 +0000 | [diff] [blame] | 907 | load32(address.m_ptr, ARMRegisters::S1); |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 908 | add32(imm, ARMRegisters::S1); |
paroga@webkit.org | 34f68fd | 2013-04-10 20:30:19 +0000 | [diff] [blame] | 909 | store32(ARMRegisters::S1, address.m_ptr); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 910 | } |
| 911 | |
commit-queue@webkit.org | df4b927 | 2012-12-12 08:00:33 +0000 | [diff] [blame] | 912 | void add64(TrustedImm32 imm, AbsoluteAddress address) |
| 913 | { |
| 914 | ARMWord tmp; |
| 915 | |
| 916 | move(TrustedImmPtr(address.m_ptr), ARMRegisters::S1); |
| 917 | m_assembler.dtrUp(ARMAssembler::LoadUint32, ARMRegisters::S0, ARMRegisters::S1, 0); |
| 918 | |
| 919 | if ((tmp = ARMAssembler::getOp2(imm.m_value)) != ARMAssembler::InvalidImmediate) |
| 920 | m_assembler.adds(ARMRegisters::S0, ARMRegisters::S0, tmp); |
| 921 | else if ((tmp = ARMAssembler::getOp2(-imm.m_value)) != ARMAssembler::InvalidImmediate) |
| 922 | m_assembler.subs(ARMRegisters::S0, ARMRegisters::S0, tmp); |
| 923 | else { |
| 924 | m_assembler.adds(ARMRegisters::S0, ARMRegisters::S0, m_assembler.getImm(imm.m_value, ARMRegisters::S1)); |
| 925 | move(TrustedImmPtr(address.m_ptr), ARMRegisters::S1); |
| 926 | } |
| 927 | m_assembler.dtrUp(ARMAssembler::StoreUint32, ARMRegisters::S0, ARMRegisters::S1, 0); |
| 928 | |
| 929 | m_assembler.dtrUp(ARMAssembler::LoadUint32, ARMRegisters::S0, ARMRegisters::S1, sizeof(ARMWord)); |
| 930 | if (imm.m_value >= 0) |
| 931 | m_assembler.adc(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(0)); |
| 932 | else |
| 933 | m_assembler.sbc(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(0)); |
| 934 | m_assembler.dtrUp(ARMAssembler::StoreUint32, ARMRegisters::S0, ARMRegisters::S1, sizeof(ARMWord)); |
| 935 | } |
| 936 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 937 | void sub32(TrustedImm32 imm, AbsoluteAddress address) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 938 | { |
paroga@webkit.org | 34f68fd | 2013-04-10 20:30:19 +0000 | [diff] [blame] | 939 | load32(address.m_ptr, ARMRegisters::S1); |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 940 | sub32(imm, ARMRegisters::S1); |
paroga@webkit.org | 34f68fd | 2013-04-10 20:30:19 +0000 | [diff] [blame] | 941 | store32(ARMRegisters::S1, address.m_ptr); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 942 | } |
| 943 | |
barraclough@apple.com | 94e12c1 | 2011-03-13 21:26:16 +0000 | [diff] [blame] | 944 | void load32(const void* address, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 945 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 946 | m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast<ARMWord>(address)); |
| 947 | m_assembler.dtrUp(ARMAssembler::LoadUint32, dest, ARMRegisters::S0, 0); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 948 | } |
| 949 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 950 | Jump branch32(RelationalCondition cond, AbsoluteAddress left, RegisterID right) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 951 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 952 | load32(left.m_ptr, ARMRegisters::S1); |
| 953 | return branch32(cond, ARMRegisters::S1, right); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 954 | } |
ossy@webkit.org | d2b2b7f | 2012-04-12 09:51:00 +0000 | [diff] [blame] | 955 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 956 | Jump branch32(RelationalCondition cond, AbsoluteAddress left, TrustedImm32 right) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 957 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 958 | load32(left.m_ptr, ARMRegisters::S1); |
| 959 | return branch32(cond, ARMRegisters::S1, right); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 960 | } |
| 961 | |
loki@webkit.org | 0f28f9b | 2010-11-20 22:02:36 +0000 | [diff] [blame] | 962 | void relativeTableJump(RegisterID index, int scale) |
| 963 | { |
| 964 | ASSERT(scale >= 0 && scale <= 31); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 965 | m_assembler.add(ARMRegisters::pc, ARMRegisters::pc, m_assembler.lsl(index, scale)); |
loki@webkit.org | 0f28f9b | 2010-11-20 22:02:36 +0000 | [diff] [blame] | 966 | |
| 967 | // NOP the default prefetching |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 968 | m_assembler.mov(ARMRegisters::r0, ARMRegisters::r0); |
loki@webkit.org | 0f28f9b | 2010-11-20 22:02:36 +0000 | [diff] [blame] | 969 | } |
| 970 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 971 | Call call() |
| 972 | { |
eric@webkit.org | 6a210e7 | 2010-04-22 13:24:56 +0000 | [diff] [blame] | 973 | ensureSpace(2 * sizeof(ARMWord), sizeof(ARMWord)); |
| 974 | m_assembler.loadBranchTarget(ARMRegisters::S1, ARMAssembler::AL, true); |
| 975 | return Call(m_assembler.blx(ARMRegisters::S1), Call::Linkable); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | Call tailRecursiveCall() |
| 979 | { |
| 980 | return Call::fromTailJump(jump()); |
| 981 | } |
| 982 | |
| 983 | Call makeTailRecursiveCall(Jump oldJump) |
| 984 | { |
| 985 | return Call::fromTailJump(oldJump); |
| 986 | } |
| 987 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 988 | DataLabelPtr moveWithPatch(TrustedImmPtr initialValue, RegisterID dest) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 989 | { |
| 990 | DataLabelPtr dataLabel(this); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 991 | m_assembler.ldrUniqueImmediate(dest, reinterpret_cast<ARMWord>(initialValue.m_value)); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 992 | return dataLabel; |
| 993 | } |
| 994 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 995 | Jump branchPtrWithPatch(RelationalCondition cond, RegisterID left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0)) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 996 | { |
zherczeg@webkit.org | 5b49d58 | 2013-02-19 17:12:41 +0000 | [diff] [blame] | 997 | ensureSpace(3 * sizeof(ARMWord), 2 * sizeof(ARMWord)); |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 998 | dataLabel = moveWithPatch(initialRightValue, ARMRegisters::S1); |
| 999 | Jump jump = branch32(cond, left, ARMRegisters::S1, true); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1000 | return jump; |
| 1001 | } |
| 1002 | |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 1003 | Jump branchPtrWithPatch(RelationalCondition cond, Address left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0)) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1004 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 1005 | load32(left, ARMRegisters::S1); |
zherczeg@webkit.org | 5b49d58 | 2013-02-19 17:12:41 +0000 | [diff] [blame] | 1006 | ensureSpace(3 * sizeof(ARMWord), 2 * sizeof(ARMWord)); |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 1007 | dataLabel = moveWithPatch(initialRightValue, ARMRegisters::S0); |
| 1008 | Jump jump = branch32(cond, ARMRegisters::S0, ARMRegisters::S1, true); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1009 | return jump; |
| 1010 | } |
| 1011 | |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 1012 | DataLabelPtr storePtrWithPatch(TrustedImmPtr initialValue, ImplicitAddress address) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1013 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 1014 | DataLabelPtr dataLabel = moveWithPatch(initialValue, ARMRegisters::S1); |
| 1015 | store32(ARMRegisters::S1, address); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1016 | return dataLabel; |
| 1017 | } |
| 1018 | |
| 1019 | DataLabelPtr storePtrWithPatch(ImplicitAddress address) |
| 1020 | { |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 1021 | return storePtrWithPatch(TrustedImmPtr(0), address); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | // Floating point operators |
barraclough@apple.com | 2326f42 | 2011-11-09 20:01:24 +0000 | [diff] [blame] | 1025 | static bool supportsFloatingPoint() |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1026 | { |
zoltan@webkit.org | 212e83e | 2009-09-15 11:29:33 +0000 | [diff] [blame] | 1027 | return s_isVFPPresent; |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
barraclough@apple.com | 2326f42 | 2011-11-09 20:01:24 +0000 | [diff] [blame] | 1030 | static bool supportsFloatingPointTruncate() |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1031 | { |
commit-queue@webkit.org | 4f9cceb | 2011-09-07 02:00:16 +0000 | [diff] [blame] | 1032 | return false; |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1033 | } |
| 1034 | |
barraclough@apple.com | 2326f42 | 2011-11-09 20:01:24 +0000 | [diff] [blame] | 1035 | static bool supportsFloatingPointSqrt() |
oliver@apple.com | 2bd947e | 2010-04-29 03:57:16 +0000 | [diff] [blame] | 1036 | { |
zherczeg@webkit.org | fa3e921 | 2010-04-29 14:08:44 +0000 | [diff] [blame] | 1037 | return s_isVFPPresent; |
oliver@apple.com | 2bd947e | 2010-04-29 03:57:16 +0000 | [diff] [blame] | 1038 | } |
barraclough@apple.com | 2326f42 | 2011-11-09 20:01:24 +0000 | [diff] [blame] | 1039 | static bool supportsFloatingPointAbs() { return false; } |
oliver@apple.com | 2bd947e | 2010-04-29 03:57:16 +0000 | [diff] [blame] | 1040 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1041 | void loadFloat(BaseIndex address, FPRegisterID dest) |
| 1042 | { |
| 1043 | m_assembler.baseIndexTransferFloat(ARMAssembler::LoadFloat, dest, address.base, address.index, static_cast<int>(address.scale), address.offset); |
| 1044 | } |
| 1045 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1046 | void loadDouble(ImplicitAddress address, FPRegisterID dest) |
| 1047 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1048 | m_assembler.dataTransferFloat(ARMAssembler::LoadDouble, dest, address.base, address.offset); |
| 1049 | } |
| 1050 | |
| 1051 | void loadDouble(BaseIndex address, FPRegisterID dest) |
| 1052 | { |
| 1053 | m_assembler.baseIndexTransferFloat(ARMAssembler::LoadDouble, dest, address.base, address.index, static_cast<int>(address.scale), address.offset); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1054 | } |
| 1055 | |
oliver@apple.com | 2bd947e | 2010-04-29 03:57:16 +0000 | [diff] [blame] | 1056 | void loadDouble(const void* address, FPRegisterID dest) |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1057 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1058 | move(TrustedImm32(reinterpret_cast<ARMWord>(address)), ARMRegisters::S0); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1059 | m_assembler.doubleDtrUp(ARMAssembler::LoadDouble, dest, ARMRegisters::S0, 0); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | void storeFloat(FPRegisterID src, BaseIndex address) |
| 1063 | { |
| 1064 | m_assembler.baseIndexTransferFloat(ARMAssembler::StoreFloat, src, address.base, address.index, static_cast<int>(address.scale), address.offset); |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1065 | } |
| 1066 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1067 | void storeDouble(FPRegisterID src, ImplicitAddress address) |
| 1068 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1069 | m_assembler.dataTransferFloat(ARMAssembler::StoreDouble, src, address.base, address.offset); |
| 1070 | } |
| 1071 | |
| 1072 | void storeDouble(FPRegisterID src, BaseIndex address) |
| 1073 | { |
| 1074 | m_assembler.baseIndexTransferFloat(ARMAssembler::StoreDouble, src, address.base, address.index, static_cast<int>(address.scale), address.offset); |
| 1075 | } |
| 1076 | |
| 1077 | void storeDouble(FPRegisterID src, const void* address) |
| 1078 | { |
| 1079 | move(TrustedImm32(reinterpret_cast<ARMWord>(address)), ARMRegisters::S0); |
| 1080 | m_assembler.dataTransferFloat(ARMAssembler::StoreDouble, src, ARMRegisters::S0, 0); |
| 1081 | } |
| 1082 | |
| 1083 | void moveDouble(FPRegisterID src, FPRegisterID dest) |
| 1084 | { |
| 1085 | if (src != dest) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1086 | m_assembler.vmov_f64(dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | void addDouble(FPRegisterID src, FPRegisterID dest) |
| 1090 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1091 | m_assembler.vadd_f64(dest, dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1092 | } |
| 1093 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1094 | void addDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest) |
| 1095 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1096 | m_assembler.vadd_f64(dest, op1, op2); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1097 | } |
| 1098 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1099 | void addDouble(Address src, FPRegisterID dest) |
| 1100 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 1101 | loadDouble(src, ARMRegisters::SD0); |
| 1102 | addDouble(ARMRegisters::SD0, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1103 | } |
| 1104 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1105 | void addDouble(AbsoluteAddress address, FPRegisterID dest) |
| 1106 | { |
| 1107 | loadDouble(address.m_ptr, ARMRegisters::SD0); |
| 1108 | addDouble(ARMRegisters::SD0, dest); |
| 1109 | } |
| 1110 | |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1111 | void divDouble(FPRegisterID src, FPRegisterID dest) |
| 1112 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1113 | m_assembler.vdiv_f64(dest, dest, src); |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1116 | void divDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest) |
| 1117 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1118 | m_assembler.vdiv_f64(dest, op1, op2); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1121 | void divDouble(Address src, FPRegisterID dest) |
| 1122 | { |
oliver@apple.com | 5598c18 | 2013-01-23 22:25:07 +0000 | [diff] [blame] | 1123 | RELEASE_ASSERT_NOT_REACHED(); // Untested |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1124 | loadDouble(src, ARMRegisters::SD0); |
| 1125 | divDouble(ARMRegisters::SD0, dest); |
| 1126 | } |
| 1127 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1128 | void subDouble(FPRegisterID src, FPRegisterID dest) |
| 1129 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1130 | m_assembler.vsub_f64(dest, dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1133 | void subDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest) |
| 1134 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1135 | m_assembler.vsub_f64(dest, op1, op2); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1136 | } |
| 1137 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1138 | void subDouble(Address src, FPRegisterID dest) |
| 1139 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 1140 | loadDouble(src, ARMRegisters::SD0); |
| 1141 | subDouble(ARMRegisters::SD0, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | void mulDouble(FPRegisterID src, FPRegisterID dest) |
| 1145 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1146 | m_assembler.vmul_f64(dest, dest, src); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | void mulDouble(Address src, FPRegisterID dest) |
| 1150 | { |
eric@webkit.org | 734dd06 | 2009-08-20 00:02:24 +0000 | [diff] [blame] | 1151 | loadDouble(src, ARMRegisters::SD0); |
| 1152 | mulDouble(ARMRegisters::SD0, dest); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1153 | } |
| 1154 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1155 | void mulDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest) |
| 1156 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1157 | m_assembler.vmul_f64(dest, op1, op2); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1158 | } |
| 1159 | |
zherczeg@webkit.org | fa3e921 | 2010-04-29 14:08:44 +0000 | [diff] [blame] | 1160 | void sqrtDouble(FPRegisterID src, FPRegisterID dest) |
oliver@apple.com | 2bd947e | 2010-04-29 03:57:16 +0000 | [diff] [blame] | 1161 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1162 | m_assembler.vsqrt_f64(dest, src); |
oliver@apple.com | 2bd947e | 2010-04-29 03:57:16 +0000 | [diff] [blame] | 1163 | } |
oliver@apple.com | 5b6a0d3 | 2011-07-01 16:33:46 +0000 | [diff] [blame] | 1164 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1165 | void absDouble(FPRegisterID src, FPRegisterID dest) |
oliver@apple.com | 5b6a0d3 | 2011-07-01 16:33:46 +0000 | [diff] [blame] | 1166 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1167 | m_assembler.vabs_f64(dest, src); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
| 1170 | void negateDouble(FPRegisterID src, FPRegisterID dest) |
| 1171 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1172 | m_assembler.vneg_f64(dest, src); |
oliver@apple.com | 5b6a0d3 | 2011-07-01 16:33:46 +0000 | [diff] [blame] | 1173 | } |
oliver@apple.com | 2bd947e | 2010-04-29 03:57:16 +0000 | [diff] [blame] | 1174 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1175 | void convertInt32ToDouble(RegisterID src, FPRegisterID dest) |
| 1176 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1177 | m_assembler.vmov_vfp32(dest << 1, src); |
| 1178 | m_assembler.vcvt_f64_s32(dest, dest << 1); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1181 | void convertInt32ToDouble(Address src, FPRegisterID dest) |
| 1182 | { |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1183 | load32(src, ARMRegisters::S1); |
| 1184 | convertInt32ToDouble(ARMRegisters::S1, dest); |
| 1185 | } |
| 1186 | |
| 1187 | void convertInt32ToDouble(AbsoluteAddress src, FPRegisterID dest) |
| 1188 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1189 | move(TrustedImmPtr(src.m_ptr), ARMRegisters::S1); |
| 1190 | load32(Address(ARMRegisters::S1), ARMRegisters::S1); |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1191 | convertInt32ToDouble(ARMRegisters::S1, dest); |
| 1192 | } |
| 1193 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1194 | void convertFloatToDouble(FPRegisterID src, FPRegisterID dst) |
| 1195 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1196 | m_assembler.vcvt_f64_f32(dst, src); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | void convertDoubleToFloat(FPRegisterID src, FPRegisterID dst) |
| 1200 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1201 | m_assembler.vcvt_f32_f64(dst, src); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1204 | Jump branchDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right) |
| 1205 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1206 | m_assembler.vcmp_f64(left, right); |
zherczeg@webkit.org | b699414 | 2010-08-13 06:49:16 +0000 | [diff] [blame] | 1207 | m_assembler.vmrs_apsr(); |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 1208 | if (cond & DoubleConditionBitSpecial) |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1209 | m_assembler.cmp(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::VS); |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 1210 | return Jump(m_assembler.jmp(static_cast<ARMAssembler::Condition>(cond & ~DoubleConditionMask))); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1211 | } |
| 1212 | |
| 1213 | // Truncates 'src' to an integer, and places the resulting 'dest'. |
| 1214 | // If the result is not representable as a 32 bit value, branch. |
| 1215 | // May also branch for some values that are representable in 32 bits |
commit-queue@webkit.org | 4f9cceb | 2011-09-07 02:00:16 +0000 | [diff] [blame] | 1216 | // (specifically, in this case, INT_MIN). |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1217 | enum BranchTruncateType { BranchIfTruncateFailed, BranchIfTruncateSuccessful }; |
| 1218 | Jump branchTruncateDoubleToInt32(FPRegisterID src, RegisterID dest, BranchTruncateType branchType = BranchIfTruncateFailed) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1219 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1220 | truncateDoubleToInt32(src, dest); |
| 1221 | |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1222 | m_assembler.add(ARMRegisters::S0, dest, ARMAssembler::getOp2Byte(1)); |
| 1223 | m_assembler.bic(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(1)); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1224 | |
| 1225 | ARMWord w = ARMAssembler::getOp2(0x80000000); |
commit-queue@webkit.org | 3dfe8ce | 2012-08-07 22:55:04 +0000 | [diff] [blame] | 1226 | ASSERT(w != ARMAssembler::InvalidImmediate); |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1227 | m_assembler.cmp(ARMRegisters::S0, w); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1228 | return Jump(m_assembler.jmp(branchType == BranchIfTruncateFailed ? ARMAssembler::EQ : ARMAssembler::NE)); |
| 1229 | } |
| 1230 | |
| 1231 | Jump branchTruncateDoubleToUint32(FPRegisterID src, RegisterID dest, BranchTruncateType branchType = BranchIfTruncateFailed) |
| 1232 | { |
| 1233 | truncateDoubleToUint32(src, dest); |
| 1234 | |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1235 | m_assembler.add(ARMRegisters::S0, dest, ARMAssembler::getOp2Byte(1)); |
| 1236 | m_assembler.bic(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(1)); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1237 | |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1238 | m_assembler.cmp(ARMRegisters::S0, ARMAssembler::getOp2Byte(0)); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1239 | return Jump(m_assembler.jmp(branchType == BranchIfTruncateFailed ? ARMAssembler::EQ : ARMAssembler::NE)); |
| 1240 | } |
| 1241 | |
| 1242 | // Result is undefined if the value is outside of the integer range. |
| 1243 | void truncateDoubleToInt32(FPRegisterID src, RegisterID dest) |
| 1244 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1245 | m_assembler.vcvt_s32_f64(ARMRegisters::SD0 << 1, src); |
| 1246 | m_assembler.vmov_arm32(dest, ARMRegisters::SD0 << 1); |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1247 | } |
| 1248 | |
| 1249 | void truncateDoubleToUint32(FPRegisterID src, RegisterID dest) |
| 1250 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1251 | m_assembler.vcvt_u32_f64(ARMRegisters::SD0 << 1, src); |
| 1252 | m_assembler.vmov_arm32(dest, ARMRegisters::SD0 << 1); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 1255 | // Convert 'src' to an integer, and places the resulting 'dest'. |
| 1256 | // If the result is not representable as a 32 bit value, branch. |
| 1257 | // May also branch for some values that are representable in 32 bits |
| 1258 | // (specifically, in this case, 0). |
commit-queue@webkit.org | 9f56bcd | 2013-04-25 22:52:34 +0000 | [diff] [blame] | 1259 | void branchConvertDoubleToInt32(FPRegisterID src, RegisterID dest, JumpList& failureCases, FPRegisterID, bool negZeroCheck = true) |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 1260 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1261 | m_assembler.vcvt_s32_f64(ARMRegisters::SD0 << 1, src); |
| 1262 | m_assembler.vmov_arm32(dest, ARMRegisters::SD0 << 1); |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 1263 | |
| 1264 | // Convert the integer result back to float & compare to the original value - if not equal or unordered (NaN) then jump. |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1265 | m_assembler.vcvt_f64_s32(ARMRegisters::SD0, ARMRegisters::SD0 << 1); |
zoltan@webkit.org | 086fa8f | 2009-11-17 07:16:22 +0000 | [diff] [blame] | 1266 | failureCases.append(branchDouble(DoubleNotEqualOrUnordered, src, ARMRegisters::SD0)); |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 1267 | |
| 1268 | // If the result is zero, it might have been -0.0, and 0.0 equals to -0.0 |
commit-queue@webkit.org | 9f56bcd | 2013-04-25 22:52:34 +0000 | [diff] [blame] | 1269 | if (negZeroCheck) |
| 1270 | failureCases.append(branchTest32(Zero, dest)); |
ossy@webkit.org | cb98130 | 2009-11-06 07:28:56 +0000 | [diff] [blame] | 1271 | } |
| 1272 | |
barraclough@apple.com | 07d783c | 2011-01-07 00:38:37 +0000 | [diff] [blame] | 1273 | Jump branchDoubleNonZero(FPRegisterID reg, FPRegisterID scratch) |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1274 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1275 | m_assembler.mov(ARMRegisters::S0, ARMAssembler::getOp2Byte(0)); |
barraclough@apple.com | 07d783c | 2011-01-07 00:38:37 +0000 | [diff] [blame] | 1276 | convertInt32ToDouble(ARMRegisters::S0, scratch); |
| 1277 | return branchDouble(DoubleNotEqual, reg, scratch); |
| 1278 | } |
| 1279 | |
| 1280 | Jump branchDoubleZeroOrNaN(FPRegisterID reg, FPRegisterID scratch) |
| 1281 | { |
commit-queue@webkit.org | b140963 | 2012-08-14 11:28:25 +0000 | [diff] [blame] | 1282 | m_assembler.mov(ARMRegisters::S0, ARMAssembler::getOp2Byte(0)); |
barraclough@apple.com | 07d783c | 2011-01-07 00:38:37 +0000 | [diff] [blame] | 1283 | convertInt32ToDouble(ARMRegisters::S0, scratch); |
| 1284 | return branchDouble(DoubleEqualOrUnordered, reg, scratch); |
zoltan@webkit.org | 1916f84 | 2009-11-14 00:44:42 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1287 | // Invert a relational condition, e.g. == becomes !=, < becomes >=, etc. |
| 1288 | static RelationalCondition invert(RelationalCondition cond) |
| 1289 | { |
| 1290 | ASSERT((static_cast<uint32_t>(cond & 0x0fffffff)) == 0 && static_cast<uint32_t>(cond) < static_cast<uint32_t>(ARMAssembler::AL)); |
| 1291 | return static_cast<RelationalCondition>(cond ^ 0x10000000); |
| 1292 | } |
| 1293 | |
oliver@apple.com | 31df1c8 | 2011-05-20 01:33:46 +0000 | [diff] [blame] | 1294 | void nop() |
| 1295 | { |
| 1296 | m_assembler.nop(); |
| 1297 | } |
| 1298 | |
ossy@webkit.org | 699a877 | 2011-11-30 11:06:29 +0000 | [diff] [blame] | 1299 | static FunctionPtr readCallTarget(CodeLocationCall call) |
| 1300 | { |
| 1301 | return FunctionPtr(reinterpret_cast<void(*)()>(ARMAssembler::readCallTarget(call.dataLocation()))); |
| 1302 | } |
| 1303 | |
fpizlo@apple.com | b75911b | 2012-06-13 20:53:52 +0000 | [diff] [blame] | 1304 | static void replaceWithJump(CodeLocationLabel instructionStart, CodeLocationLabel destination) |
| 1305 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1306 | ARMAssembler::replaceWithJump(instructionStart.dataLocation(), destination.dataLocation()); |
fpizlo@apple.com | b75911b | 2012-06-13 20:53:52 +0000 | [diff] [blame] | 1307 | } |
| 1308 | |
| 1309 | static ptrdiff_t maxJumpReplacementSize() |
| 1310 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1311 | ARMAssembler::maxJumpReplacementSize(); |
fpizlo@apple.com | b75911b | 2012-06-13 20:53:52 +0000 | [diff] [blame] | 1312 | return 0; |
| 1313 | } |
| 1314 | |
ossy@webkit.org | 180434a | 2012-11-13 08:53:09 +0000 | [diff] [blame] | 1315 | static bool canJumpReplacePatchableBranchPtrWithPatch() { return false; } |
| 1316 | |
ossy@webkit.org | 55698851 | 2012-11-23 15:32:46 +0000 | [diff] [blame] | 1317 | static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr) |
ossy@webkit.org | 180434a | 2012-11-13 08:53:09 +0000 | [diff] [blame] | 1318 | { |
| 1319 | UNREACHABLE_FOR_PLATFORM(); |
ossy@webkit.org | ce46704 | 2012-11-14 14:51:59 +0000 | [diff] [blame] | 1320 | return CodeLocationLabel(); |
ossy@webkit.org | 180434a | 2012-11-13 08:53:09 +0000 | [diff] [blame] | 1321 | } |
| 1322 | |
ossy@webkit.org | 55698851 | 2012-11-23 15:32:46 +0000 | [diff] [blame] | 1323 | static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label) |
| 1324 | { |
| 1325 | return label.labelAtOffset(0); |
| 1326 | } |
| 1327 | |
| 1328 | static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID reg, void* initialValue) |
| 1329 | { |
zherczeg@webkit.org | 5b49d58 | 2013-02-19 17:12:41 +0000 | [diff] [blame] | 1330 | ARMAssembler::revertBranchPtrWithPatch(instructionStart.dataLocation(), reg, reinterpret_cast<uintptr_t>(initialValue) & 0xffff); |
ossy@webkit.org | 55698851 | 2012-11-23 15:32:46 +0000 | [diff] [blame] | 1331 | } |
| 1332 | |
ossy@webkit.org | 0d44f41 | 2013-03-06 17:39:37 +0000 | [diff] [blame] | 1333 | static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel, Address, void*) |
ossy@webkit.org | 180434a | 2012-11-13 08:53:09 +0000 | [diff] [blame] | 1334 | { |
| 1335 | UNREACHABLE_FOR_PLATFORM(); |
| 1336 | } |
| 1337 | |
oliver@apple.com | c3a5b8c | 2013-07-25 04:01:38 +0000 | [diff] [blame] | 1338 | #if USE(MASM_PROBE) |
| 1339 | struct CPUState { |
| 1340 | #define DECLARE_REGISTER(_type, _regName) \ |
| 1341 | _type _regName; |
| 1342 | FOR_EACH_CPU_REGISTER(DECLARE_REGISTER) |
| 1343 | #undef DECLARE_REGISTER |
| 1344 | }; |
| 1345 | |
| 1346 | struct ProbeContext; |
| 1347 | typedef void (*ProbeFunction)(struct ProbeContext*); |
| 1348 | |
| 1349 | struct ProbeContext { |
| 1350 | ProbeFunction probeFunction; |
| 1351 | void* arg1; |
| 1352 | void* arg2; |
oliver@apple.com | c3a5b8c | 2013-07-25 04:01:38 +0000 | [diff] [blame] | 1353 | CPUState cpu; |
| 1354 | |
| 1355 | void dump(const char* indentation = 0); |
| 1356 | private: |
| 1357 | void dumpCPURegisters(const char* indentation); |
| 1358 | }; |
| 1359 | |
| 1360 | // For details about probe(), see comment in MacroAssemblerX86_64.h. |
| 1361 | void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0); |
| 1362 | #endif // USE(MASM_PROBE) |
| 1363 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1364 | protected: |
barraclough@apple.com | 03cd248 | 2011-04-20 18:44:35 +0000 | [diff] [blame] | 1365 | ARMAssembler::Condition ARMCondition(RelationalCondition cond) |
| 1366 | { |
| 1367 | return static_cast<ARMAssembler::Condition>(cond); |
| 1368 | } |
| 1369 | |
| 1370 | ARMAssembler::Condition ARMCondition(ResultCondition cond) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1371 | { |
| 1372 | return static_cast<ARMAssembler::Condition>(cond); |
| 1373 | } |
| 1374 | |
barraclough@apple.com | 970af2c | 2009-08-13 05:58:36 +0000 | [diff] [blame] | 1375 | void ensureSpace(int insnSpace, int constSpace) |
| 1376 | { |
| 1377 | m_assembler.ensureSpace(insnSpace, constSpace); |
| 1378 | } |
| 1379 | |
| 1380 | int sizeOfConstantPool() |
| 1381 | { |
| 1382 | return m_assembler.sizeOfConstantPool(); |
| 1383 | } |
| 1384 | |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1385 | void call32(RegisterID base, int32_t offset) |
| 1386 | { |
zherczeg@webkit.org | d6e661f | 2012-07-05 07:04:16 +0000 | [diff] [blame] | 1387 | load32(Address(base, offset), ARMRegisters::S1); |
| 1388 | m_assembler.blx(ARMRegisters::S1); |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1389 | } |
| 1390 | |
barraclough@apple.com | 96e7343 | 2009-07-22 03:24:34 +0000 | [diff] [blame] | 1391 | private: |
| 1392 | friend class LinkBuffer; |
| 1393 | friend class RepatchBuffer; |
| 1394 | |
ossy@webkit.org | a32a527 | 2012-11-26 14:47:40 +0000 | [diff] [blame] | 1395 | void internalCompare32(RegisterID left, TrustedImm32 right) |
| 1396 | { |
| 1397 | ARMWord tmp = (static_cast<unsigned>(right.m_value) == 0x80000000) ? ARMAssembler::InvalidImmediate : m_assembler.getOp2(-right.m_value); |
| 1398 | if (tmp != ARMAssembler::InvalidImmediate) |
| 1399 | m_assembler.cmn(left, tmp); |
| 1400 | else |
| 1401 | m_assembler.cmp(left, m_assembler.getImm(right.m_value, ARMRegisters::S0)); |
| 1402 | } |
| 1403 | |
barraclough@apple.com | 96e7343 | 2009-07-22 03:24:34 +0000 | [diff] [blame] | 1404 | static void linkCall(void* code, Call call, FunctionPtr function) |
| 1405 | { |
barraclough@apple.com | 0d15b9e | 2011-05-26 04:12:41 +0000 | [diff] [blame] | 1406 | ARMAssembler::linkCall(code, call.m_label, function.value()); |
barraclough@apple.com | 96e7343 | 2009-07-22 03:24:34 +0000 | [diff] [blame] | 1407 | } |
| 1408 | |
| 1409 | static void repatchCall(CodeLocationCall call, CodeLocationLabel destination) |
| 1410 | { |
| 1411 | ARMAssembler::relinkCall(call.dataLocation(), destination.executableAddress()); |
| 1412 | } |
| 1413 | |
| 1414 | static void repatchCall(CodeLocationCall call, FunctionPtr destination) |
| 1415 | { |
| 1416 | ARMAssembler::relinkCall(call.dataLocation(), destination.executableAddress()); |
| 1417 | } |
| 1418 | |
oliver@apple.com | c3a5b8c | 2013-07-25 04:01:38 +0000 | [diff] [blame] | 1419 | #if USE(MASM_PROBE) |
| 1420 | inline TrustedImm32 trustedImm32FromPtr(void* ptr) |
| 1421 | { |
| 1422 | return TrustedImm32(TrustedImmPtr(ptr)); |
| 1423 | } |
| 1424 | |
| 1425 | inline TrustedImm32 trustedImm32FromPtr(ProbeFunction function) |
| 1426 | { |
| 1427 | return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function))); |
| 1428 | } |
| 1429 | |
| 1430 | inline TrustedImm32 trustedImm32FromPtr(void (*function)()) |
| 1431 | { |
| 1432 | return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function))); |
| 1433 | } |
| 1434 | #endif |
| 1435 | |
zoltan@webkit.org | 212e83e | 2009-09-15 11:29:33 +0000 | [diff] [blame] | 1436 | static const bool s_isVFPPresent; |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1437 | }; |
| 1438 | |
| 1439 | } |
| 1440 | |
mjs@apple.com | cc66821 | 2010-01-04 11:38:56 +0000 | [diff] [blame] | 1441 | #endif // ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL) |
barraclough@apple.com | 5ea6895 | 2009-07-17 21:56:28 +0000 | [diff] [blame] | 1442 | |
| 1443 | #endif // MacroAssemblerARM_h |