OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_COMPILER_CODE_GENERATOR_IMPL_H_ | 5 #ifndef V8_COMPILER_CODE_GENERATOR_IMPL_H_ |
6 #define V8_COMPILER_CODE_GENERATOR_IMPL_H_ | 6 #define V8_COMPILER_CODE_GENERATOR_IMPL_H_ |
7 | 7 |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler/code-generator.h" | 9 #include "src/compiler/code-generator.h" |
10 #include "src/compiler/instruction.h" | 10 #include "src/compiler/instruction.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 InstructionOperandConverter(CodeGenerator* gen, Instruction* instr) | 25 InstructionOperandConverter(CodeGenerator* gen, Instruction* instr) |
26 : gen_(gen), instr_(instr) {} | 26 : gen_(gen), instr_(instr) {} |
27 | 27 |
28 // -- Instruction operand accesses with conversions -------------------------- | 28 // -- Instruction operand accesses with conversions -------------------------- |
29 | 29 |
30 Register InputRegister(size_t index) { | 30 Register InputRegister(size_t index) { |
31 return ToRegister(instr_->InputAt(index)); | 31 return ToRegister(instr_->InputAt(index)); |
32 } | 32 } |
33 | 33 |
| 34 FloatRegister InputFloatRegister(size_t index) { |
| 35 return ToFloatRegister(instr_->InputAt(index)); |
| 36 } |
| 37 |
34 DoubleRegister InputDoubleRegister(size_t index) { | 38 DoubleRegister InputDoubleRegister(size_t index) { |
35 return ToDoubleRegister(instr_->InputAt(index)); | 39 return ToDoubleRegister(instr_->InputAt(index)); |
36 } | 40 } |
37 | 41 |
38 double InputDouble(size_t index) { return ToDouble(instr_->InputAt(index)); } | 42 double InputDouble(size_t index) { return ToDouble(instr_->InputAt(index)); } |
39 | 43 |
40 float InputFloat32(size_t index) { return ToFloat32(instr_->InputAt(index)); } | 44 float InputFloat32(size_t index) { return ToFloat32(instr_->InputAt(index)); } |
41 | 45 |
42 int32_t InputInt32(size_t index) { | 46 int32_t InputInt32(size_t index) { |
43 return ToConstant(instr_->InputAt(index)).ToInt32(); | 47 return ToConstant(instr_->InputAt(index)).ToInt32(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 86 } |
83 | 87 |
84 Register OutputRegister(size_t index = 0) { | 88 Register OutputRegister(size_t index = 0) { |
85 return ToRegister(instr_->OutputAt(index)); | 89 return ToRegister(instr_->OutputAt(index)); |
86 } | 90 } |
87 | 91 |
88 Register TempRegister(size_t index) { | 92 Register TempRegister(size_t index) { |
89 return ToRegister(instr_->TempAt(index)); | 93 return ToRegister(instr_->TempAt(index)); |
90 } | 94 } |
91 | 95 |
| 96 FloatRegister OutputFloatRegister() { |
| 97 return ToFloatRegister(instr_->Output()); |
| 98 } |
| 99 |
92 DoubleRegister OutputDoubleRegister() { | 100 DoubleRegister OutputDoubleRegister() { |
93 return ToDoubleRegister(instr_->Output()); | 101 return ToDoubleRegister(instr_->Output()); |
94 } | 102 } |
95 | 103 |
96 // -- Conversions for operands ----------------------------------------------- | 104 // -- Conversions for operands ----------------------------------------------- |
97 | 105 |
98 Label* ToLabel(InstructionOperand* op) { | 106 Label* ToLabel(InstructionOperand* op) { |
99 return gen_->GetLabel(ToRpoNumber(op)); | 107 return gen_->GetLabel(ToRpoNumber(op)); |
100 } | 108 } |
101 | 109 |
102 RpoNumber ToRpoNumber(InstructionOperand* op) { | 110 RpoNumber ToRpoNumber(InstructionOperand* op) { |
103 return ToConstant(op).ToRpoNumber(); | 111 return ToConstant(op).ToRpoNumber(); |
104 } | 112 } |
105 | 113 |
106 Register ToRegister(InstructionOperand* op) { | 114 Register ToRegister(InstructionOperand* op) { |
107 return LocationOperand::cast(op)->GetRegister(); | 115 return LocationOperand::cast(op)->GetRegister(); |
108 } | 116 } |
109 | 117 |
110 DoubleRegister ToDoubleRegister(InstructionOperand* op) { | 118 DoubleRegister ToDoubleRegister(InstructionOperand* op) { |
111 return LocationOperand::cast(op)->GetDoubleRegister(); | 119 return LocationOperand::cast(op)->GetDoubleRegister(); |
112 } | 120 } |
113 | 121 |
| 122 FloatRegister ToFloatRegister(InstructionOperand* op) { |
| 123 return LocationOperand::cast(op)->GetFloatRegister(); |
| 124 } |
| 125 |
114 Constant ToConstant(InstructionOperand* op) { | 126 Constant ToConstant(InstructionOperand* op) { |
115 if (op->IsImmediate()) { | 127 if (op->IsImmediate()) { |
116 return gen_->code()->GetImmediate(ImmediateOperand::cast(op)); | 128 return gen_->code()->GetImmediate(ImmediateOperand::cast(op)); |
117 } | 129 } |
118 return gen_->code()->GetConstant( | 130 return gen_->code()->GetConstant( |
119 ConstantOperand::cast(op)->virtual_register()); | 131 ConstantOperand::cast(op)->virtual_register()); |
120 } | 132 } |
121 | 133 |
122 double ToDouble(InstructionOperand* op) { return ToConstant(op).ToFloat64(); } | 134 double ToDouble(InstructionOperand* op) { return ToConstant(op).ToFloat64(); } |
123 | 135 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 | 201 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 |
190 masm->ud2(); | 202 masm->ud2(); |
191 #endif | 203 #endif |
192 } | 204 } |
193 | 205 |
194 } // namespace compiler | 206 } // namespace compiler |
195 } // namespace internal | 207 } // namespace internal |
196 } // namespace v8 | 208 } // namespace v8 |
197 | 209 |
198 #endif // V8_COMPILER_CODE_GENERATOR_IMPL_H | 210 #endif // V8_COMPILER_CODE_GENERATOR_IMPL_H |
OLD | NEW |