OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm64/macro-assembler-arm64.h" | 7 #include "src/arm64/macro-assembler-arm64.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 #define ASSEMBLE_SHIFT(asm_instr, width) \ | 164 #define ASSEMBLE_SHIFT(asm_instr, width) \ |
165 do { \ | 165 do { \ |
166 if (instr->InputAt(1)->IsRegister()) { \ | 166 if (instr->InputAt(1)->IsRegister()) { \ |
167 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), \ | 167 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), \ |
168 i.InputRegister##width(1)); \ | 168 i.InputRegister##width(1)); \ |
169 } else { \ | 169 } else { \ |
170 int64_t imm = i.InputOperand##width(1).immediate().value(); \ | 170 int64_t imm = i.InputOperand##width(1).immediate().value(); \ |
171 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), imm); \ | 171 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), imm); \ |
172 } \ | 172 } \ |
173 } while (0); | 173 } while (0) |
| 174 |
| 175 |
| 176 #define ASSEMBLE_TEST_AND_BRANCH(asm_instr, width) \ |
| 177 do { \ |
| 178 bool fallthrough = IsNextInAssemblyOrder(i.InputRpo(3)); \ |
| 179 __ asm_instr(i.InputRegister##width(0), i.InputInt6(1), \ |
| 180 code_->GetLabel(i.InputRpo(2))); \ |
| 181 if (!fallthrough) __ B(code_->GetLabel(i.InputRpo(3))); \ |
| 182 } while (0) |
174 | 183 |
175 | 184 |
176 // Assembles an instruction after register allocation, producing machine code. | 185 // Assembles an instruction after register allocation, producing machine code. |
177 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 186 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
178 Arm64OperandConverter i(this, instr); | 187 Arm64OperandConverter i(this, instr); |
179 InstructionCode opcode = instr->opcode(); | 188 InstructionCode opcode = instr->opcode(); |
180 switch (ArchOpcodeField::decode(opcode)) { | 189 switch (ArchOpcodeField::decode(opcode)) { |
181 case kArchCallCodeObject: { | 190 case kArchCallCodeObject: { |
182 EnsureSpaceForLazyDeopt(); | 191 EnsureSpaceForLazyDeopt(); |
183 if (instr->InputAt(0)->IsImmediate()) { | 192 if (instr->InputAt(0)->IsImmediate()) { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 __ Sxtw(i.OutputRegister(), i.InputRegister32(0)); | 420 __ Sxtw(i.OutputRegister(), i.InputRegister32(0)); |
412 break; | 421 break; |
413 case kArm64Ubfx: | 422 case kArm64Ubfx: |
414 __ Ubfx(i.OutputRegister(), i.InputRegister(0), i.InputInt8(1), | 423 __ Ubfx(i.OutputRegister(), i.InputRegister(0), i.InputInt8(1), |
415 i.InputInt8(2)); | 424 i.InputInt8(2)); |
416 break; | 425 break; |
417 case kArm64Ubfx32: | 426 case kArm64Ubfx32: |
418 __ Ubfx(i.OutputRegister32(), i.InputRegister32(0), i.InputInt8(1), | 427 __ Ubfx(i.OutputRegister32(), i.InputRegister32(0), i.InputInt8(1), |
419 i.InputInt8(2)); | 428 i.InputInt8(2)); |
420 break; | 429 break; |
| 430 case kArm64Tbz: |
| 431 ASSEMBLE_TEST_AND_BRANCH(Tbz, 64); |
| 432 break; |
| 433 case kArm64Tbz32: |
| 434 ASSEMBLE_TEST_AND_BRANCH(Tbz, 32); |
| 435 break; |
| 436 case kArm64Tbnz: |
| 437 ASSEMBLE_TEST_AND_BRANCH(Tbnz, 64); |
| 438 break; |
| 439 case kArm64Tbnz32: |
| 440 ASSEMBLE_TEST_AND_BRANCH(Tbnz, 32); |
| 441 break; |
421 case kArm64Claim: { | 442 case kArm64Claim: { |
422 int words = MiscField::decode(instr->opcode()); | 443 int words = MiscField::decode(instr->opcode()); |
423 __ Claim(words); | 444 __ Claim(words); |
424 break; | 445 break; |
425 } | 446 } |
426 case kArm64Poke: { | 447 case kArm64Poke: { |
427 int slot = MiscField::decode(instr->opcode()); | 448 int slot = MiscField::decode(instr->opcode()); |
428 Operand operand(slot * kPointerSize); | 449 Operand operand(slot * kPointerSize); |
429 __ Poke(i.InputRegister(0), operand); | 450 __ Poke(i.InputRegister(0), operand); |
430 break; | 451 break; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 } | 1018 } |
998 } | 1019 } |
999 MarkLazyDeoptSite(); | 1020 MarkLazyDeoptSite(); |
1000 } | 1021 } |
1001 | 1022 |
1002 #undef __ | 1023 #undef __ |
1003 | 1024 |
1004 } // namespace compiler | 1025 } // namespace compiler |
1005 } // namespace internal | 1026 } // namespace internal |
1006 } // namespace v8 | 1027 } // namespace v8 |
OLD | NEW |