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 #include "src/compiler/code-generator-impl.h" | 6 #include "src/compiler/code-generator-impl.h" |
7 #include "src/compiler/gap-resolver.h" | 7 #include "src/compiler/gap-resolver.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/mips/macro-assembler-mips.h" | 9 #include "src/mips/macro-assembler-mips.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 PrintF("UNIMPLEMENTED code_generator_mips: %s at line %d\n", __FUNCTION__, \ | 31 PrintF("UNIMPLEMENTED code_generator_mips: %s at line %d\n", __FUNCTION__, \ |
32 __LINE__) | 32 __LINE__) |
33 | 33 |
34 | 34 |
35 // Adds Mips-specific methods to convert InstructionOperands. | 35 // Adds Mips-specific methods to convert InstructionOperands. |
36 class MipsOperandConverter FINAL : public InstructionOperandConverter { | 36 class MipsOperandConverter FINAL : public InstructionOperandConverter { |
37 public: | 37 public: |
38 MipsOperandConverter(CodeGenerator* gen, Instruction* instr) | 38 MipsOperandConverter(CodeGenerator* gen, Instruction* instr) |
39 : InstructionOperandConverter(gen, instr) {} | 39 : InstructionOperandConverter(gen, instr) {} |
40 | 40 |
41 FloatRegister OutputSingleRegister(int index = 0) { | 41 FloatRegister OutputSingleRegister(size_t index = 0) { |
42 return ToSingleRegister(instr_->OutputAt(index)); | 42 return ToSingleRegister(instr_->OutputAt(index)); |
43 } | 43 } |
44 | 44 |
45 FloatRegister InputSingleRegister(int index) { | 45 FloatRegister InputSingleRegister(size_t index) { |
46 return ToSingleRegister(instr_->InputAt(index)); | 46 return ToSingleRegister(instr_->InputAt(index)); |
47 } | 47 } |
48 | 48 |
49 FloatRegister ToSingleRegister(InstructionOperand* op) { | 49 FloatRegister ToSingleRegister(InstructionOperand* op) { |
50 // Single (Float) and Double register namespace is same on MIPS, | 50 // Single (Float) and Double register namespace is same on MIPS, |
51 // both are typedefs of FPURegister. | 51 // both are typedefs of FPURegister. |
52 return ToDoubleRegister(op); | 52 return ToDoubleRegister(op); |
53 } | 53 } |
54 | 54 |
55 Operand InputImmediate(int index) { | 55 Operand InputImmediate(size_t index) { |
56 Constant constant = ToConstant(instr_->InputAt(index)); | 56 Constant constant = ToConstant(instr_->InputAt(index)); |
57 switch (constant.type()) { | 57 switch (constant.type()) { |
58 case Constant::kInt32: | 58 case Constant::kInt32: |
59 return Operand(constant.ToInt32()); | 59 return Operand(constant.ToInt32()); |
60 case Constant::kInt64: | 60 case Constant::kInt64: |
61 return Operand(constant.ToInt64()); | 61 return Operand(constant.ToInt64()); |
62 case Constant::kFloat32: | 62 case Constant::kFloat32: |
63 return Operand( | 63 return Operand( |
64 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED)); | 64 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED)); |
65 case Constant::kFloat64: | 65 case Constant::kFloat64: |
66 return Operand( | 66 return Operand( |
67 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED)); | 67 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED)); |
68 case Constant::kExternalReference: | 68 case Constant::kExternalReference: |
69 case Constant::kHeapObject: | 69 case Constant::kHeapObject: |
70 // TODO(plind): Maybe we should handle ExtRef & HeapObj here? | 70 // TODO(plind): Maybe we should handle ExtRef & HeapObj here? |
71 // maybe not done on arm due to const pool ?? | 71 // maybe not done on arm due to const pool ?? |
72 break; | 72 break; |
73 case Constant::kRpoNumber: | 73 case Constant::kRpoNumber: |
74 UNREACHABLE(); // TODO(titzer): RPO immediates on mips? | 74 UNREACHABLE(); // TODO(titzer): RPO immediates on mips? |
75 break; | 75 break; |
76 } | 76 } |
77 UNREACHABLE(); | 77 UNREACHABLE(); |
78 return Operand(zero_reg); | 78 return Operand(zero_reg); |
79 } | 79 } |
80 | 80 |
81 Operand InputOperand(int index) { | 81 Operand InputOperand(size_t index) { |
82 InstructionOperand* op = instr_->InputAt(index); | 82 InstructionOperand* op = instr_->InputAt(index); |
83 if (op->IsRegister()) { | 83 if (op->IsRegister()) { |
84 return Operand(ToRegister(op)); | 84 return Operand(ToRegister(op)); |
85 } | 85 } |
86 return InputImmediate(index); | 86 return InputImmediate(index); |
87 } | 87 } |
88 | 88 |
89 MemOperand MemoryOperand(int* first_index) { | 89 MemOperand MemoryOperand(size_t* first_index) { |
90 const int index = *first_index; | 90 const size_t index = *first_index; |
91 switch (AddressingModeField::decode(instr_->opcode())) { | 91 switch (AddressingModeField::decode(instr_->opcode())) { |
92 case kMode_None: | 92 case kMode_None: |
93 break; | 93 break; |
94 case kMode_MRI: | 94 case kMode_MRI: |
95 *first_index += 2; | 95 *first_index += 2; |
96 return MemOperand(InputRegister(index + 0), InputInt32(index + 1)); | 96 return MemOperand(InputRegister(index + 0), InputInt32(index + 1)); |
97 case kMode_MRR: | 97 case kMode_MRR: |
98 // TODO(plind): r6 address mode, to be implemented ... | 98 // TODO(plind): r6 address mode, to be implemented ... |
99 UNREACHABLE(); | 99 UNREACHABLE(); |
100 } | 100 } |
101 UNREACHABLE(); | 101 UNREACHABLE(); |
102 return MemOperand(no_reg); | 102 return MemOperand(no_reg); |
103 } | 103 } |
104 | 104 |
105 MemOperand MemoryOperand(int index = 0) { return MemoryOperand(&index); } | 105 MemOperand MemoryOperand(size_t index = 0) { return MemoryOperand(&index); } |
106 | 106 |
107 MemOperand ToMemOperand(InstructionOperand* op) const { | 107 MemOperand ToMemOperand(InstructionOperand* op) const { |
108 DCHECK(op != NULL); | 108 DCHECK(op != NULL); |
109 DCHECK(!op->IsRegister()); | 109 DCHECK(!op->IsRegister()); |
110 DCHECK(!op->IsDoubleRegister()); | 110 DCHECK(!op->IsDoubleRegister()); |
111 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 111 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
112 // The linkage computes where all spill slots are located. | 112 // The linkage computes where all spill slots are located. |
113 FrameOffset offset = linkage()->GetFrameOffset(op->index(), frame(), 0); | 113 FrameOffset offset = linkage()->GetFrameOffset(op->index(), frame(), 0); |
114 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); | 114 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); |
115 } | 115 } |
116 }; | 116 }; |
117 | 117 |
118 | 118 |
119 static inline bool HasRegisterInput(Instruction* instr, int index) { | 119 static inline bool HasRegisterInput(Instruction* instr, size_t index) { |
120 return instr->InputAt(index)->IsRegister(); | 120 return instr->InputAt(index)->IsRegister(); |
121 } | 121 } |
122 | 122 |
123 | 123 |
124 namespace { | 124 namespace { |
125 | 125 |
126 class OutOfLineLoadSingle FINAL : public OutOfLineCode { | 126 class OutOfLineLoadSingle FINAL : public OutOfLineCode { |
127 public: | 127 public: |
128 OutOfLineLoadSingle(CodeGenerator* gen, FloatRegister result) | 128 OutOfLineLoadSingle(CodeGenerator* gen, FloatRegister result) |
129 : OutOfLineCode(gen), result_(result) {} | 129 : OutOfLineCode(gen), result_(result) {} |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 __ sw(i.InputRegister(2), i.MemoryOperand()); | 709 __ sw(i.InputRegister(2), i.MemoryOperand()); |
710 break; | 710 break; |
711 case kMips64Sd: | 711 case kMips64Sd: |
712 __ sd(i.InputRegister(2), i.MemoryOperand()); | 712 __ sd(i.InputRegister(2), i.MemoryOperand()); |
713 break; | 713 break; |
714 case kMips64Lwc1: { | 714 case kMips64Lwc1: { |
715 __ lwc1(i.OutputSingleRegister(), i.MemoryOperand()); | 715 __ lwc1(i.OutputSingleRegister(), i.MemoryOperand()); |
716 break; | 716 break; |
717 } | 717 } |
718 case kMips64Swc1: { | 718 case kMips64Swc1: { |
719 int index = 0; | 719 size_t index = 0; |
720 MemOperand operand = i.MemoryOperand(&index); | 720 MemOperand operand = i.MemoryOperand(&index); |
721 __ swc1(i.InputSingleRegister(index), operand); | 721 __ swc1(i.InputSingleRegister(index), operand); |
722 break; | 722 break; |
723 } | 723 } |
724 case kMips64Ldc1: | 724 case kMips64Ldc1: |
725 __ ldc1(i.OutputDoubleRegister(), i.MemoryOperand()); | 725 __ ldc1(i.OutputDoubleRegister(), i.MemoryOperand()); |
726 break; | 726 break; |
727 case kMips64Sdc1: | 727 case kMips64Sdc1: |
728 __ sdc1(i.InputDoubleRegister(2), i.MemoryOperand()); | 728 __ sdc1(i.InputDoubleRegister(2), i.MemoryOperand()); |
729 break; | 729 break; |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 } | 1358 } |
1359 } | 1359 } |
1360 MarkLazyDeoptSite(); | 1360 MarkLazyDeoptSite(); |
1361 } | 1361 } |
1362 | 1362 |
1363 #undef __ | 1363 #undef __ |
1364 | 1364 |
1365 } // namespace compiler | 1365 } // namespace compiler |
1366 } // namespace internal | 1366 } // namespace internal |
1367 } // namespace v8 | 1367 } // namespace v8 |
OLD | NEW |