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" |
11 #include "src/compiler/linkage.h" | 11 #include "src/compiler/linkage.h" |
12 #include "src/compiler/opcodes.h" | 12 #include "src/compiler/opcodes.h" |
13 #include "src/macro-assembler.h" | 13 #include "src/macro-assembler.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 namespace compiler { | 17 namespace compiler { |
18 | 18 |
19 // Converts InstructionOperands from a given instruction to | 19 // Converts InstructionOperands from a given instruction to |
20 // architecture-specific | 20 // architecture-specific |
21 // registers and operands after they have been assigned by the register | 21 // registers and operands after they have been assigned by the register |
22 // allocator. | 22 // allocator. |
23 class InstructionOperandConverter { | 23 class InstructionOperandConverter { |
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(int index) { | 30 Register InputRegister(size_t index) { |
31 return ToRegister(instr_->InputAt(index)); | 31 return ToRegister(instr_->InputAt(index)); |
32 } | 32 } |
33 | 33 |
34 DoubleRegister InputDoubleRegister(int index) { | 34 DoubleRegister InputDoubleRegister(size_t index) { |
35 return ToDoubleRegister(instr_->InputAt(index)); | 35 return ToDoubleRegister(instr_->InputAt(index)); |
36 } | 36 } |
37 | 37 |
38 double InputDouble(int index) { return ToDouble(instr_->InputAt(index)); } | 38 double InputDouble(size_t index) { return ToDouble(instr_->InputAt(index)); } |
39 | 39 |
40 int32_t InputInt32(int index) { | 40 int32_t InputInt32(size_t index) { |
41 return ToConstant(instr_->InputAt(index)).ToInt32(); | 41 return ToConstant(instr_->InputAt(index)).ToInt32(); |
42 } | 42 } |
43 | 43 |
44 int8_t InputInt8(int index) { return static_cast<int8_t>(InputInt32(index)); } | 44 int8_t InputInt8(size_t index) { |
| 45 return static_cast<int8_t>(InputInt32(index)); |
| 46 } |
45 | 47 |
46 int16_t InputInt16(int index) { | 48 int16_t InputInt16(size_t index) { |
47 return static_cast<int16_t>(InputInt32(index)); | 49 return static_cast<int16_t>(InputInt32(index)); |
48 } | 50 } |
49 | 51 |
50 uint8_t InputInt5(int index) { | 52 uint8_t InputInt5(size_t index) { |
51 return static_cast<uint8_t>(InputInt32(index) & 0x1F); | 53 return static_cast<uint8_t>(InputInt32(index) & 0x1F); |
52 } | 54 } |
53 | 55 |
54 uint8_t InputInt6(int index) { | 56 uint8_t InputInt6(size_t index) { |
55 return static_cast<uint8_t>(InputInt32(index) & 0x3F); | 57 return static_cast<uint8_t>(InputInt32(index) & 0x3F); |
56 } | 58 } |
57 | 59 |
58 Handle<HeapObject> InputHeapObject(int index) { | 60 Handle<HeapObject> InputHeapObject(size_t index) { |
59 return ToHeapObject(instr_->InputAt(index)); | 61 return ToHeapObject(instr_->InputAt(index)); |
60 } | 62 } |
61 | 63 |
62 Label* InputLabel(int index) { return ToLabel(instr_->InputAt(index)); } | 64 Label* InputLabel(size_t index) { return ToLabel(instr_->InputAt(index)); } |
63 | 65 |
64 BasicBlock::RpoNumber InputRpo(int index) { | 66 BasicBlock::RpoNumber InputRpo(size_t index) { |
65 return ToRpoNumber(instr_->InputAt(index)); | 67 return ToRpoNumber(instr_->InputAt(index)); |
66 } | 68 } |
67 | 69 |
68 Register OutputRegister(int index = 0) { | 70 Register OutputRegister(size_t index = 0) { |
69 return ToRegister(instr_->OutputAt(index)); | 71 return ToRegister(instr_->OutputAt(index)); |
70 } | 72 } |
71 | 73 |
72 Register TempRegister(int index) { return ToRegister(instr_->TempAt(index)); } | 74 Register TempRegister(size_t index) { |
| 75 return ToRegister(instr_->TempAt(index)); |
| 76 } |
73 | 77 |
74 DoubleRegister OutputDoubleRegister() { | 78 DoubleRegister OutputDoubleRegister() { |
75 return ToDoubleRegister(instr_->Output()); | 79 return ToDoubleRegister(instr_->Output()); |
76 } | 80 } |
77 | 81 |
78 // -- Conversions for operands ----------------------------------------------- | 82 // -- Conversions for operands ----------------------------------------------- |
79 | 83 |
80 Label* ToLabel(InstructionOperand* op) { | 84 Label* ToLabel(InstructionOperand* op) { |
81 return gen_->GetLabel(ToRpoNumber(op)); | 85 return gen_->GetLabel(ToRpoNumber(op)); |
82 } | 86 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 | 151 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 |
148 masm->ud2(); | 152 masm->ud2(); |
149 #endif | 153 #endif |
150 } | 154 } |
151 | 155 |
152 } // namespace compiler | 156 } // namespace compiler |
153 } // namespace internal | 157 } // namespace internal |
154 } // namespace v8 | 158 } // namespace v8 |
155 | 159 |
156 #endif // V8_COMPILER_CODE_GENERATOR_IMPL_H | 160 #endif // V8_COMPILER_CODE_GENERATOR_IMPL_H |
OLD | NEW |