OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // This is forked from Dart revision df52deea9f25690eb8b66c5995da92b70f7ac1fe | 5 // This is forked from Dart revision df52deea9f25690eb8b66c5995da92b70f7ac1fe |
6 // Please update the (git) revision if we merge changes from Dart. | 6 // Please update the (git) revision if we merge changes from Dart. |
7 // https://code.google.com/p/dart/wiki/GettingTheSource | 7 // https://code.google.com/p/dart/wiki/GettingTheSource |
8 | 8 |
9 #include "vm/globals.h" // NOLINT | 9 #include "vm/globals.h" // NOLINT |
10 #if defined(TARGET_ARCH_ARM) | 10 #if defined(TARGET_ARCH_ARM) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 void Assembler::Emit(int32_t value) { | 69 void Assembler::Emit(int32_t value) { |
70 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 70 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
71 buffer_.Emit<int32_t>(value); | 71 buffer_.Emit<int32_t>(value); |
72 } | 72 } |
73 | 73 |
74 #if 0 | 74 #if 0 |
75 // Moved to class AssemblerARM32. | 75 // Moved to ARM32::AssemblerARM32::emitType01() |
76 void Assembler::EmitType01(Condition cond, | 76 void Assembler::EmitType01(Condition cond, |
77 int type, | 77 int type, |
78 Opcode opcode, | 78 Opcode opcode, |
79 int set_cc, | 79 int set_cc, |
80 Register rn, | 80 Register rn, |
81 Register rd, | 81 Register rd, |
82 Operand o) { | 82 Operand o) { |
83 ASSERT(rd != kNoRegister); | 83 ASSERT(rd != kNoRegister); |
84 ASSERT(cond != kNoCondition); | 84 ASSERT(cond != kNoCondition); |
85 int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | | 85 int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | |
86 type << kTypeShift | | 86 type << kTypeShift | |
87 static_cast<int32_t>(opcode) << kOpcodeShift | | 87 static_cast<int32_t>(opcode) << kOpcodeShift | |
88 set_cc << kSShift | | 88 set_cc << kSShift | |
89 static_cast<int32_t>(rn) << kRnShift | | 89 static_cast<int32_t>(rn) << kRnShift | |
90 static_cast<int32_t>(rd) << kRdShift | | 90 static_cast<int32_t>(rd) << kRdShift | |
91 o.encoding(); | 91 o.encoding(); |
92 Emit(encoding); | 92 Emit(encoding); |
93 } | 93 } |
94 #endif | 94 #endif |
95 | 95 |
96 void Assembler::EmitType5(Condition cond, int32_t offset, bool link) { | 96 void Assembler::EmitType5(Condition cond, int32_t offset, bool link) { |
97 ASSERT(cond != kNoCondition); | 97 ASSERT(cond != kNoCondition); |
98 int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | | 98 int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | |
99 5 << kTypeShift | | 99 5 << kTypeShift | |
100 (link ? 1 : 0) << kLinkShift; | 100 (link ? 1 : 0) << kLinkShift; |
101 Emit(Assembler::EncodeBranchOffset(offset, encoding)); | 101 Emit(Assembler::EncodeBranchOffset(offset, encoding)); |
102 } | 102 } |
103 | 103 |
104 | 104 |
105 #if 0 | |
106 // Moved to ARM32::AssemblerARM32::emitMemOp() | |
105 void Assembler::EmitMemOp(Condition cond, | 107 void Assembler::EmitMemOp(Condition cond, |
106 bool load, | 108 bool load, |
107 bool byte, | 109 bool byte, |
108 Register rd, | 110 Register rd, |
109 Address ad) { | 111 Address ad) { |
110 ASSERT(rd != kNoRegister); | 112 ASSERT(rd != kNoRegister); |
111 ASSERT(cond != kNoCondition); | 113 ASSERT(cond != kNoCondition); |
112 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | | 114 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
113 B26 | (ad.kind() == Address::Immediate ? 0 : B25) | | 115 B26 | (ad.kind() == Address::Immediate ? 0 : B25) | |
114 (load ? L : 0) | | 116 (load ? L : 0) | |
115 (byte ? B : 0) | | 117 (byte ? B : 0) | |
116 (static_cast<int32_t>(rd) << kRdShift) | | 118 (static_cast<int32_t>(rd) << kRdShift) | |
117 ad.encoding(); | 119 ad.encoding(); |
118 Emit(encoding); | 120 Emit(encoding); |
119 } | 121 } |
120 | 122 #endif |
121 | 123 |
122 void Assembler::EmitMemOpAddressMode3(Condition cond, | 124 void Assembler::EmitMemOpAddressMode3(Condition cond, |
123 int32_t mode, | 125 int32_t mode, |
124 Register rd, | 126 Register rd, |
125 Address ad) { | 127 Address ad) { |
126 ASSERT(rd != kNoRegister); | 128 ASSERT(rd != kNoRegister); |
127 ASSERT(cond != kNoCondition); | 129 ASSERT(cond != kNoCondition); |
128 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | | 130 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
129 mode | | 131 mode | |
130 (static_cast<int32_t>(rd) << kRdShift) | | 132 (static_cast<int32_t>(rd) << kRdShift) | |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 | 189 |
188 void Assembler::and_(Register rd, Register rn, Operand o, Condition cond) { | 190 void Assembler::and_(Register rd, Register rn, Operand o, Condition cond) { |
189 EmitType01(cond, o.type(), AND, 0, rn, rd, o); | 191 EmitType01(cond, o.type(), AND, 0, rn, rd, o); |
190 } | 192 } |
191 | 193 |
192 | 194 |
193 void Assembler::eor(Register rd, Register rn, Operand o, Condition cond) { | 195 void Assembler::eor(Register rd, Register rn, Operand o, Condition cond) { |
194 EmitType01(cond, o.type(), EOR, 0, rn, rd, o); | 196 EmitType01(cond, o.type(), EOR, 0, rn, rd, o); |
195 } | 197 } |
196 | 198 |
197 | 199 #if 0 |
200 // Moved to ARM32::AssemberARM32::sub() | |
198 void Assembler::sub(Register rd, Register rn, Operand o, Condition cond) { | 201 void Assembler::sub(Register rd, Register rn, Operand o, Condition cond) { |
199 EmitType01(cond, o.type(), SUB, 0, rn, rd, o); | 202 EmitType01(cond, o.type(), SUB, 0, rn, rd, o); |
200 } | 203 } |
204 #endif | |
201 | 205 |
202 void Assembler::rsb(Register rd, Register rn, Operand o, Condition cond) { | 206 void Assembler::rsb(Register rd, Register rn, Operand o, Condition cond) { |
203 EmitType01(cond, o.type(), RSB, 0, rn, rd, o); | 207 EmitType01(cond, o.type(), RSB, 0, rn, rd, o); |
204 } | 208 } |
205 | 209 |
206 void Assembler::rsbs(Register rd, Register rn, Operand o, Condition cond) { | 210 void Assembler::rsbs(Register rd, Register rn, Operand o, Condition cond) { |
207 EmitType01(cond, o.type(), RSB, 1, rn, rd, o); | 211 EmitType01(cond, o.type(), RSB, 1, rn, rd, o); |
208 } | 212 } |
209 | 213 |
210 | 214 |
211 #if 0 | 215 #if 0 |
212 // Moved to IceAssemberARM32::add. | 216 // Moved to ARM32::AssemberARM32::add() |
213 void Assembler::add(Register rd, Register rn, Operand o, Condition cond) { | 217 void Assembler::add(Register rd, Register rn, Operand o, Condition cond) { |
214 EmitType01(cond, o.type(), ADD, 0, rn, rd, o); | 218 EmitType01(cond, o.type(), ADD, 0, rn, rd, o); |
215 } | 219 } |
216 | 220 |
217 | 221 // Moved to ARM32::AssemberARM32::add() |
218 void Assembler::adds(Register rd, Register rn, Operand o, Condition cond) { | 222 void Assembler::adds(Register rd, Register rn, Operand o, Condition cond) { |
219 EmitType01(cond, o.type(), ADD, 1, rn, rd, o); | 223 EmitType01(cond, o.type(), ADD, 1, rn, rd, o); |
220 } | 224 } |
221 #endif | 225 #if 0 |
Jim Stichnoth
2015/10/15 20:41:29
#endif ?
Karl
2015/10/15 22:03:33
Done.
| |
222 | 226 |
223 | 227 #if 0 |
228 // Moved to ARM32::AssemberARM32::sub() | |
224 void Assembler::subs(Register rd, Register rn, Operand o, Condition cond) { | 229 void Assembler::subs(Register rd, Register rn, Operand o, Condition cond) { |
225 EmitType01(cond, o.type(), SUB, 1, rn, rd, o); | 230 EmitType01(cond, o.type(), SUB, 1, rn, rd, o); |
226 } | 231 } |
227 | 232 #endif |
228 | 233 |
229 void Assembler::adc(Register rd, Register rn, Operand o, Condition cond) { | 234 void Assembler::adc(Register rd, Register rn, Operand o, Condition cond) { |
230 EmitType01(cond, o.type(), ADC, 0, rn, rd, o); | 235 EmitType01(cond, o.type(), ADC, 0, rn, rd, o); |
231 } | 236 } |
232 | 237 |
233 | 238 |
234 void Assembler::adcs(Register rd, Register rn, Operand o, Condition cond) { | 239 void Assembler::adcs(Register rd, Register rn, Operand o, Condition cond) { |
235 EmitType01(cond, o.type(), ADC, 1, rn, rd, o); | 240 EmitType01(cond, o.type(), ADC, 1, rn, rd, o); |
236 } | 241 } |
237 | 242 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 void Assembler::sdiv(Register rd, Register rn, Register rm, Condition cond) { | 462 void Assembler::sdiv(Register rd, Register rn, Register rm, Condition cond) { |
458 EmitDivOp(cond, 0, rd, rn, rm); | 463 EmitDivOp(cond, 0, rd, rn, rm); |
459 } | 464 } |
460 | 465 |
461 | 466 |
462 void Assembler::udiv(Register rd, Register rn, Register rm, Condition cond) { | 467 void Assembler::udiv(Register rd, Register rn, Register rm, Condition cond) { |
463 EmitDivOp(cond, B21 , rd, rn, rm); | 468 EmitDivOp(cond, B21 , rd, rn, rm); |
464 } | 469 } |
465 | 470 |
466 | 471 |
472 #if 0 | |
473 // Moved to ARM32::AssemblerARM32::ldr() | |
467 void Assembler::ldr(Register rd, Address ad, Condition cond) { | 474 void Assembler::ldr(Register rd, Address ad, Condition cond) { |
468 EmitMemOp(cond, true, false, rd, ad); | 475 EmitMemOp(cond, true, false, rd, ad); |
469 } | 476 } |
470 | 477 |
471 | 478 // Moved to ARM32::AssemblerARM32::str() |
472 void Assembler::str(Register rd, Address ad, Condition cond) { | 479 void Assembler::str(Register rd, Address ad, Condition cond) { |
473 EmitMemOp(cond, false, false, rd, ad); | 480 EmitMemOp(cond, false, false, rd, ad); |
474 } | 481 } |
475 | 482 |
476 | 483 // Moved to ARM32::AssemblerARM32::ldr() |
477 void Assembler::ldrb(Register rd, Address ad, Condition cond) { | 484 void Assembler::ldrb(Register rd, Address ad, Condition cond) { |
478 EmitMemOp(cond, true, true, rd, ad); | 485 EmitMemOp(cond, true, true, rd, ad); |
479 } | 486 } |
480 | 487 |
481 | 488 // Moved to ARM32::AssemblerARM32::str() |
482 void Assembler::strb(Register rd, Address ad, Condition cond) { | 489 void Assembler::strb(Register rd, Address ad, Condition cond) { |
483 EmitMemOp(cond, false, true, rd, ad); | 490 EmitMemOp(cond, false, true, rd, ad); |
484 } | 491 } |
485 | 492 #endif |
486 | 493 |
487 void Assembler::ldrh(Register rd, Address ad, Condition cond) { | 494 void Assembler::ldrh(Register rd, Address ad, Condition cond) { |
488 EmitMemOpAddressMode3(cond, L | B7 | H | B4, rd, ad); | 495 EmitMemOpAddressMode3(cond, L | B7 | H | B4, rd, ad); |
489 } | 496 } |
490 | 497 |
491 | 498 |
492 void Assembler::strh(Register rd, Address ad, Condition cond) { | 499 void Assembler::strh(Register rd, Address ad, Condition cond) { |
493 EmitMemOpAddressMode3(cond, B7 | H | B4, rd, ad); | 500 EmitMemOpAddressMode3(cond, B7 | H | B4, rd, ad); |
494 } | 501 } |
495 | 502 |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1434 EmitSIMDqqq(B24 | B9 | B8, sz, qd, qn, qm); | 1441 EmitSIMDqqq(B24 | B9 | B8, sz, qd, qn, qm); |
1435 } | 1442 } |
1436 | 1443 |
1437 | 1444 |
1438 void Assembler::vcgtqs(QRegister qd, QRegister qn, QRegister qm) { | 1445 void Assembler::vcgtqs(QRegister qd, QRegister qn, QRegister qm) { |
1439 EmitSIMDqqq(B24 | B21 | B11 | B10 | B9, kSWord, qd, qn, qm); | 1446 EmitSIMDqqq(B24 | B21 | B11 | B10 | B9, kSWord, qd, qn, qm); |
1440 } | 1447 } |
1441 | 1448 |
1442 | 1449 |
1443 #if 0 | 1450 #if 0 |
1444 // Moved to: ARM32::AssemblerARM32. | 1451 // Moved to: ARM32::AssemblerARM32::bkpt() |
1445 void Assembler::bkpt(uint16_t imm16) { | 1452 void Assembler::bkpt(uint16_t imm16) { |
1446 Emit(BkptEncoding(imm16)); | 1453 Emit(BkptEncoding(imm16)); |
1447 } | 1454 } |
1448 #endif | 1455 #endif |
1449 | 1456 |
1450 | 1457 |
1451 void Assembler::b(Label* label, Condition cond) { | 1458 void Assembler::b(Label* label, Condition cond) { |
1452 EmitBranch(cond, label, false); | 1459 EmitBranch(cond, label, false); |
1453 } | 1460 } |
1454 | 1461 |
1455 | 1462 |
1456 void Assembler::bl(Label* label, Condition cond) { | 1463 void Assembler::bl(Label* label, Condition cond) { |
1457 EmitBranch(cond, label, true); | 1464 EmitBranch(cond, label, true); |
1458 } | 1465 } |
1459 | 1466 |
1460 #if 0 | 1467 #if 0 |
1461 // Moved to: ARM32::AssemblerARM32. | 1468 // Moved to: ARM32::AssemblerARM32::bx() |
1462 void Assembler::bx(Register rm, Condition cond) { | 1469 void Assembler::bx(Register rm, Condition cond) { |
1463 ASSERT(rm != kNoRegister); | 1470 ASSERT(rm != kNoRegister); |
1464 ASSERT(cond != kNoCondition); | 1471 ASSERT(cond != kNoCondition); |
1465 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | | 1472 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
1466 B24 | B21 | (0xfff << 8) | B4 | | 1473 B24 | B21 | (0xfff << 8) | B4 | |
1467 (static_cast<int32_t>(rm) << kRmShift); | 1474 (static_cast<int32_t>(rm) << kRmShift); |
1468 Emit(encoding); | 1475 Emit(encoding); |
1469 } | 1476 } |
1470 #endif | 1477 #endif |
1471 | 1478 |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2320 int32_t next = buffer_.Load<int32_t>(position); | 2327 int32_t next = buffer_.Load<int32_t>(position); |
2321 int32_t encoded = Assembler::EncodeBranchOffset(dest, next); | 2328 int32_t encoded = Assembler::EncodeBranchOffset(dest, next); |
2322 buffer_.Store<int32_t>(position, encoded); | 2329 buffer_.Store<int32_t>(position, encoded); |
2323 label->position_ = Assembler::DecodeBranchOffset(next); | 2330 label->position_ = Assembler::DecodeBranchOffset(next); |
2324 } | 2331 } |
2325 } | 2332 } |
2326 label->BindTo(bound_pc); | 2333 label->BindTo(bound_pc); |
2327 } | 2334 } |
2328 | 2335 |
2329 #if 0 | 2336 #if 0 |
2330 // Moved to: ARM32::AssemblerARM32 as method bind(Label* Label) | 2337 // Moved to: ARM32::AssemblerARM32::bind(Label* Label) |
2331 // Note: Most of this code isn't needed because instruction selection has | 2338 // Note: Most of this code isn't needed because instruction selection has |
2332 // already been handler | 2339 // already been handler |
2333 void Assembler::BindARMv7(Label* label) { | 2340 void Assembler::BindARMv7(Label* label) { |
2334 ASSERT(!label->IsBound()); | 2341 ASSERT(!label->IsBound()); |
2335 intptr_t bound_pc = buffer_.Size(); | 2342 intptr_t bound_pc = buffer_.Size(); |
2336 while (label->IsLinked()) { | 2343 while (label->IsLinked()) { |
2337 const int32_t position = label->Position(); | 2344 const int32_t position = label->Position(); |
2338 int32_t dest = bound_pc - position; | 2345 int32_t dest = bound_pc - position; |
2339 if (use_far_branches() && !CanEncodeBranchOffset(dest)) { | 2346 if (use_far_branches() && !CanEncodeBranchOffset(dest)) { |
2340 // Far branches are enabled and we can't encode the branch offset. | 2347 // Far branches are enabled and we can't encode the branch offset. |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3660 | 3667 |
3661 | 3668 |
3662 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3669 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3663 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); | 3670 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); |
3664 return fpu_reg_names[reg]; | 3671 return fpu_reg_names[reg]; |
3665 } | 3672 } |
3666 | 3673 |
3667 } // namespace dart | 3674 } // namespace dart |
3668 | 3675 |
3669 #endif // defined TARGET_ARCH_ARM | 3676 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |