Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// | 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// |
| 2 // | 2 // |
| 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
| 5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
| 6 // | 6 // |
| 7 // Modified by the Subzero authors. | 7 // Modified by the Subzero authors. |
| 8 // | 8 // |
| 9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
| 10 // | 10 // |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 // Returns the GPR register at given Shift in Value. | 173 // Returns the GPR register at given Shift in Value. |
| 174 RegARM32::GPRRegister getGPRReg(IValueT Shift, IValueT Value) { | 174 RegARM32::GPRRegister getGPRReg(IValueT Shift, IValueT Value) { |
| 175 return decodeGPRRegister((Value >> Shift) & 0xF); | 175 return decodeGPRRegister((Value >> Shift) & 0xF); |
| 176 } | 176 } |
| 177 | 177 |
| 178 // Defines alternate layouts of instruction operands, should the (common) | 178 // Defines alternate layouts of instruction operands, should the (common) |
| 179 // default pattern not be used. | 179 // default pattern not be used. |
| 180 enum OpEncoding { | 180 enum OpEncoding { |
| 181 // No alternate layout specified. | 181 // No alternate layout specified. |
| 182 DefaultOpEncoding, | 182 DefaultOpEncoding, |
| 183 // Alternate encoding for ImmRegOffset, where the offset is divided by 4 | |
| 184 // before encoding. | |
| 185 ImmRegOffsetDiv4, | |
| 183 // Alternate encoding 3 for memory operands (like in strb, strh, ldrb, and | 186 // Alternate encoding 3 for memory operands (like in strb, strh, ldrb, and |
| 184 // ldrh. | 187 // ldrh. |
| 185 OpEncoding3, | 188 OpEncoding3, |
| 186 // Alternate encoding for memory operands for ldrex and strex, which only | 189 // Alternate encoding for memory operands for ldrex and strex, which only |
| 187 // actually expect a register. | 190 // actually expect a register. |
| 188 OpEncodingMemEx | 191 OpEncodingMemEx |
| 189 }; | 192 }; |
| 190 | 193 |
| 191 IValueT getEncodedGPRegNum(const Variable *Var) { | 194 IValueT getEncodedGPRegNum(const Variable *Var) { |
| 192 assert(Var->hasReg()); | 195 assert(Var->hasReg()); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 assert(Imm8 < (1 << 8)); | 377 assert(Imm8 < (1 << 8)); |
| 375 Value = Value | B22 | ((Imm8 & 0xf0) << 4) | (Imm8 & 0x0f); | 378 Value = Value | B22 | ((Imm8 & 0xf0) << 4) | (Imm8 & 0x0f); |
| 376 return Value; | 379 return Value; |
| 377 } | 380 } |
| 378 | 381 |
| 379 IValueT encodeImmRegOffset(OpEncoding AddressEncoding, IValueT Reg, | 382 IValueT encodeImmRegOffset(OpEncoding AddressEncoding, IValueT Reg, |
| 380 IOffsetT Offset, OperandARM32Mem::AddrMode Mode) { | 383 IOffsetT Offset, OperandARM32Mem::AddrMode Mode) { |
| 381 switch (AddressEncoding) { | 384 switch (AddressEncoding) { |
| 382 case DefaultOpEncoding: | 385 case DefaultOpEncoding: |
| 383 return encodeImmRegOffset(Reg, Offset, Mode); | 386 return encodeImmRegOffset(Reg, Offset, Mode); |
| 387 case ImmRegOffsetDiv4: | |
| 388 assert((Offset & 0x3) == 0); | |
| 389 return encodeImmRegOffset(Reg, Offset >> 2, Mode); | |
| 384 case OpEncoding3: | 390 case OpEncoding3: |
| 385 return encodeImmRegOffsetEnc3(Reg, Offset, Mode); | 391 return encodeImmRegOffsetEnc3(Reg, Offset, Mode); |
| 386 case OpEncodingMemEx: | 392 case OpEncodingMemEx: |
| 387 assert(Offset == 0); | 393 assert(Offset == 0); |
| 388 assert(Mode == OperandARM32Mem::Offset); | 394 assert(Mode == OperandARM32Mem::Offset); |
| 389 return Reg << kRnShift; | 395 return Reg << kRnShift; |
| 390 } | 396 } |
| 391 llvm_unreachable("(silence g++ warning)"); | 397 llvm_unreachable("(silence g++ warning)"); |
| 392 } | 398 } |
| 393 | 399 |
| (...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2207 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm); | 2213 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm); |
| 2208 emitInst(Encoding); | 2214 emitInst(Encoding); |
| 2209 } | 2215 } |
| 2210 | 2216 |
| 2211 void AssemblerARM32::vldrd(const Operand *OpDd, const Operand *OpAddress, | 2217 void AssemblerARM32::vldrd(const Operand *OpDd, const Operand *OpAddress, |
| 2212 CondARM32::Cond Cond, const TargetInfo &TInfo) { | 2218 CondARM32::Cond Cond, const TargetInfo &TInfo) { |
| 2213 // VLDR - ARM section A8.8.333, encoding A1. | 2219 // VLDR - ARM section A8.8.333, encoding A1. |
| 2214 // vldr<c> <Dd>, [<Rn>{, #+/-<imm>}] | 2220 // vldr<c> <Dd>, [<Rn>{, #+/-<imm>}] |
| 2215 // | 2221 // |
| 2216 // cccc1101UD01nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd, | 2222 // cccc1101UD01nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd, |
| 2217 // iiiiiiii=abs(Opcode), and U=1 if Opcode>=0, | 2223 // iiiiiiii=abs(Imm >> 2), and U=1 if Opcode>=0. |
| 2218 constexpr const char *Vldrd = "vldrd"; | 2224 constexpr const char *Vldrd = "vldrd"; |
| 2219 IValueT Dd = encodeDRegister(OpDd, "Dd", Vldrd); | 2225 IValueT Dd = encodeDRegister(OpDd, "Dd", Vldrd); |
| 2220 assert(CondARM32::isDefined(Cond)); | 2226 assert(CondARM32::isDefined(Cond)); |
| 2221 IValueT Address; | 2227 IValueT Address; |
| 2222 EncodedOperand AddressEncoding = encodeAddress(OpAddress, Address, TInfo); | 2228 EncodedOperand AddressEncoding = |
| 2229 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4); | |
| 2223 (void)AddressEncoding; | 2230 (void)AddressEncoding; |
|
Jim Stichnoth
2016/01/22 05:10:30
remove this
Karl
2016/01/22 16:24:29
Done.
| |
| 2224 assert(AddressEncoding == EncodedAsImmRegOffset); | 2231 if (AddressEncoding != EncodedAsImmRegOffset) |
| 2232 // TODO(kschimpf) Fix this. | |
| 2233 return setNeedsTextFixup(); | |
| 2225 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 2234 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 2226 IValueT Encoding = B27 | B26 | B24 | B20 | B11 | B9 | B8 | | 2235 IValueT Encoding = B27 | B26 | B24 | B20 | B11 | B9 | B8 | |
| 2227 (encodeCondition(Cond) << kConditionShift) | | 2236 (encodeCondition(Cond) << kConditionShift) | |
| 2228 (getYInRegYXXXX(Dd) << 22) | | 2237 (getYInRegYXXXX(Dd) << 22) | |
| 2229 (getXXXXInRegYXXXX(Dd) << 12) | Address; | 2238 (getXXXXInRegYXXXX(Dd) << 12) | Address; |
| 2230 emitInst(Encoding); | 2239 emitInst(Encoding); |
| 2231 } | 2240 } |
| 2232 | 2241 |
| 2233 void AssemblerARM32::vldrs(const Operand *OpSd, const Operand *OpAddress, | 2242 void AssemblerARM32::vldrs(const Operand *OpSd, const Operand *OpAddress, |
| 2234 CondARM32::Cond Cond, const TargetInfo &TInfo) { | 2243 CondARM32::Cond Cond, const TargetInfo &TInfo) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2278 IValueT Dd = encodeDRegister(OpDd, "Dd", Vmuld); | 2287 IValueT Dd = encodeDRegister(OpDd, "Dd", Vmuld); |
| 2279 IValueT Dn = encodeDRegister(OpDn, "Dn", Vmuld); | 2288 IValueT Dn = encodeDRegister(OpDn, "Dn", Vmuld); |
| 2280 IValueT Dm = encodeDRegister(OpDm, "Dm", Vmuld); | 2289 IValueT Dm = encodeDRegister(OpDm, "Dm", Vmuld); |
| 2281 constexpr IValueT VmuldOpcode = B21; | 2290 constexpr IValueT VmuldOpcode = B21; |
| 2282 emitVFPddd(Cond, VmuldOpcode, Dd, Dn, Dm); | 2291 emitVFPddd(Cond, VmuldOpcode, Dd, Dn, Dm); |
| 2283 } | 2292 } |
| 2284 | 2293 |
| 2285 void AssemblerARM32::vstrd(const Operand *OpDd, const Operand *OpAddress, | 2294 void AssemblerARM32::vstrd(const Operand *OpDd, const Operand *OpAddress, |
| 2286 CondARM32::Cond Cond, const TargetInfo &TInfo) { | 2295 CondARM32::Cond Cond, const TargetInfo &TInfo) { |
| 2287 // VSTR - ARM section A8.8.413, encoding A1: | 2296 // VSTR - ARM section A8.8.413, encoding A1: |
| 2288 // vstr<c> <Dd>, [<Rn>{, #+/-<imm>}] | 2297 // vstr<c> <Dd>, [<Rn>{, #+/-<Imm>}] |
| 2289 // | 2298 // |
| 2290 // cccc1101UD00nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd, | 2299 // cccc1101UD00nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd, |
| 2291 // iiiiiiii=abs(Opcode), and U=1 if Opcode>=0, | 2300 // iiiiiiii=abs(Imm >> 2), and U=1 if Imm>=0. |
| 2292 constexpr const char *Vstrd = "vstrd"; | 2301 constexpr const char *Vstrd = "vstrd"; |
| 2293 IValueT Dd = encodeDRegister(OpDd, "Dd", Vstrd); | 2302 IValueT Dd = encodeDRegister(OpDd, "Dd", Vstrd); |
| 2294 assert(CondARM32::isDefined(Cond)); | 2303 assert(CondARM32::isDefined(Cond)); |
| 2295 IValueT Address; | 2304 IValueT Address; |
| 2296 if (encodeAddress(OpAddress, Address, TInfo) != EncodedAsImmRegOffset) | 2305 IValueT AddressEncoding = |
| 2297 assert(false); | 2306 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4); |
| 2307 (void)AddressEncoding; | |
|
Jim Stichnoth
2016/01/22 05:10:30
remove this
Karl
2016/01/22 16:24:29
Done.
| |
| 2308 if (AddressEncoding != EncodedAsImmRegOffset) | |
| 2309 // TODO(kschimpf) Fix this. | |
| 2310 return setNeedsTextFixup(); | |
| 2298 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 2311 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 2299 IValueT Encoding = B27 | B26 | B24 | B11 | B9 | B8 | | 2312 IValueT Encoding = B27 | B26 | B24 | B11 | B9 | B8 | |
| 2300 (encodeCondition(Cond) << kConditionShift) | | 2313 (encodeCondition(Cond) << kConditionShift) | |
| 2301 (getYInRegYXXXX(Dd) << 22) | | 2314 (getYInRegYXXXX(Dd) << 22) | |
| 2302 (getXXXXInRegYXXXX(Dd) << 12) | Address; | 2315 (getXXXXInRegYXXXX(Dd) << 12) | Address; |
| 2303 emitInst(Encoding); | 2316 emitInst(Encoding); |
| 2304 } | 2317 } |
| 2305 | 2318 |
| 2306 void AssemblerARM32::vstrs(const Operand *OpSd, const Operand *OpAddress, | 2319 void AssemblerARM32::vstrs(const Operand *OpSd, const Operand *OpAddress, |
| 2307 CondARM32::Cond Cond, const TargetInfo &TInfo) { | 2320 CondARM32::Cond Cond, const TargetInfo &TInfo) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2395 // | 2408 // |
| 2396 // cccc11010D101101dddd1010iiiiiiii where cccc=Cond, ddddD=BaseReg, and | 2409 // cccc11010D101101dddd1010iiiiiiii where cccc=Cond, ddddD=BaseReg, and |
| 2397 // iiiiiiii=NumConsecRegs. | 2410 // iiiiiiii=NumConsecRegs. |
| 2398 constexpr IValueT VpushOpcode = | 2411 constexpr IValueT VpushOpcode = |
| 2399 B27 | B26 | B24 | B21 | B19 | B18 | B16 | B11 | B9; | 2412 B27 | B26 | B24 | B21 | B19 | B18 | B16 | B11 | B9; |
| 2400 emitVStackOp(Cond, VpushOpcode, OpBaseReg, NumConsecRegs); | 2413 emitVStackOp(Cond, VpushOpcode, OpBaseReg, NumConsecRegs); |
| 2401 } | 2414 } |
| 2402 | 2415 |
| 2403 } // end of namespace ARM32 | 2416 } // end of namespace ARM32 |
| 2404 } // end of namespace Ice | 2417 } // end of namespace Ice |
| OLD | NEW |