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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 while (label->isLinked()) { | 49 while (label->isLinked()) { |
50 intptr_t position = label->getLinkPosition(); | 50 intptr_t position = label->getLinkPosition(); |
51 intptr_t next = Buffer.load<int32_t>(position); | 51 intptr_t next = Buffer.load<int32_t>(position); |
52 Buffer.store<int32_t>(position, bound - (position + 4)); | 52 Buffer.store<int32_t>(position, bound - (position + 4)); |
53 label->setPosition(next); | 53 label->setPosition(next); |
54 } | 54 } |
55 // TODO(kschimpf) Decide if we have near jumps. | 55 // TODO(kschimpf) Decide if we have near jumps. |
56 label->bindTo(bound); | 56 label->bindTo(bound); |
57 } | 57 } |
58 | 58 |
| 59 void ARM32::AssemblerARM32::emitType01(CondARM32::Cond Cond, uint32_t Type, |
| 60 uint32_t Opcode, bool SetCc, uint32_t Rn, |
| 61 uint32_t Rd, uint32_t Imm12) { |
| 62 assert(isGPRRegisterDefined(Rd)); |
| 63 assert(Cond != CondARM32::kNone); |
| 64 uint32_t Encoding = encodeCondition(Cond) << kConditionShift | |
| 65 (Type << kTypeShift) | (Opcode << kOpcodeShift) | |
| 66 (encodeBool(SetCc) << kSShift) | (Rn << kRnShift) | |
| 67 (Rd << kRdShift) | Imm12; |
| 68 emitInt32(Encoding); |
| 69 } |
| 70 |
59 void ARM32::AssemblerARM32::bkpt(uint16_t imm16) { | 71 void ARM32::AssemblerARM32::bkpt(uint16_t imm16) { |
60 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 72 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
61 emitInt32(BkptEncoding(imm16)); | 73 emitInt32(BkptEncoding(imm16)); |
62 } | 74 } |
63 | 75 |
64 void ARM32::AssemblerARM32::bx(RegARM32::GPRRegister rm, CondARM32::Cond cond) { | 76 void ARM32::AssemblerARM32::bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond) { |
65 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond. | 77 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond. |
66 assert(rm != RegARM32::Encoded_Not_GPR); | 78 // (ARM cection A8.8.27, encoding A1). |
67 assert(cond != CondARM32::kNone); | 79 assert(isGPRRegisterDefined(Rm)); |
| 80 assert(isConditionDefined(Cond)); |
68 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 81 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
69 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | B24 | | 82 uint32_t Encoding = (encodeCondition(Cond) << kConditionShift) | B24 | B21 | |
70 B21 | (0xfff << 8) | B4 | | 83 (0xfff << 8) | B4 | (encodeGPRRegister(Rm) << kRmShift); |
71 (static_cast<int32_t>(rm) << kRmShift); | 84 emitInt32(Encoding); |
72 emitInt32(encoding); | 85 } |
| 86 |
| 87 void ARM32::AssemblerARM32::mov(RegARM32::GPRRegister Rd, |
| 88 const OperandARM32FlexImm &FlexImm, |
| 89 CondARM32::Cond Cond) { |
| 90 // cccc0011101s0000ddddiiiiiiiiiiii (ARM section A8.8.102, encoding A1) |
| 91 assert(isConditionDefined(Cond)); |
| 92 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 93 bool SetCc = false; // Note: We don't use movs in this assembler. |
| 94 uint32_t Rn = 0; |
| 95 uint32_t Mov = B3 | B2 | B0; // 1101. |
| 96 emitType01(Cond, kInstTypeImmediate, Mov, SetCc, Rn, encodeGPRRegister(Rd), |
| 97 encodeImm12FromFlexImm(FlexImm)); |
73 } | 98 } |
74 | 99 |
75 } // end of namespace Ice | 100 } // end of namespace Ice |
OLD | NEW |