Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: src/compiler/code-generator-impl.h

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_CODE_GENERATOR_IMPL_H_
6 #define V8_COMPILER_CODE_GENERATOR_IMPL_H_
7
8 #include "src/compiler/code-generator.h"
9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/generic-graph.h"
11 #include "src/compiler/instruction.h"
12 #include "src/compiler/linkage.h"
13 #include "src/compiler/machine-operator.h"
14 #include "src/compiler/node.h"
15 #include "src/compiler/opcodes.h"
16 #include "src/compiler/operator.h"
17
18 namespace v8 {
19 namespace internal {
20 namespace compiler {
21
22 // Converts InstructionOperands from a given instruction to
23 // architecture-specific
24 // registers and operands after they have been assigned by the register
25 // allocator.
26 class InstructionOperandConverter {
27 public:
28 InstructionOperandConverter(CodeGenerator* gen, Instruction* instr)
29 : gen_(gen), instr_(instr) {}
30
31 Register InputRegister(int index) {
32 return ToRegister(instr_->InputAt(index));
33 }
34
35 DoubleRegister InputDoubleRegister(int index) {
36 return ToDoubleRegister(instr_->InputAt(index));
37 }
38
39 double InputDouble(int index) {
40 return ToDouble(instr_->InputAt(index));
41 }
42
43 int32_t InputInt32(int index) {
44 return ToConstant(instr_->InputAt(index)).ToInt32();
45 }
46
47 int8_t InputInt8(int index) {
48 return static_cast<int8_t>(InputInt32(index));
49 }
50
51 int16_t InputInt16(int index) {
52 return static_cast<int16_t>(InputInt32(index));
53 }
54
55 uint8_t InputInt5(int index) {
56 return static_cast<uint8_t>(InputInt32(index) & 0x1F);
57 }
58
59 uint8_t InputInt6(int index) {
60 return static_cast<uint8_t>(InputInt32(index) & 0x3F);
61 }
62
63 Handle<HeapObject> InputHeapObject(int index) {
64 return ToHeapObject(instr_->InputAt(index));
65 }
66
67 Label* InputLabel(int index) {
68 return gen_->code()->GetLabel(InputBlock(index));
69 }
70
71 BasicBlock* InputBlock(int index) {
72 NodeId block_id = static_cast<NodeId>(instr_->InputAt(index)->index());
73 // operand should be a block id.
74 ASSERT(block_id >= 0);
75 ASSERT(block_id < gen_->schedule()->BasicBlockCount());
76 return gen_->schedule()->GetBlockById(block_id);
77 }
78
79 Register OutputRegister() {
80 return ToRegister(instr_->Output());
81 }
82
83 DoubleRegister OutputDoubleRegister() {
84 return ToDoubleRegister(instr_->Output());
85 }
86
87 Register TempRegister(int index) {
88 return ToRegister(instr_->TempAt(index));
89 }
90
91 Register ToRegister(InstructionOperand* op) {
92 ASSERT(op->IsRegister());
93 return Register::FromAllocationIndex(op->index());
94 }
95
96 DoubleRegister ToDoubleRegister(InstructionOperand* op) {
97 ASSERT(op->IsDoubleRegister());
98 return DoubleRegister::FromAllocationIndex(op->index());
99 }
100
101 Constant ToConstant(InstructionOperand* operand) {
102 if (operand->IsImmediate()) {
103 return gen_->code()->GetImmediate(operand->index());
104 }
105 return gen_->code()->GetConstant(operand->index());
106 }
107
108 double ToDouble(InstructionOperand* operand) {
109 return ToConstant(operand).ToFloat64();
110 }
111
112 Handle<HeapObject> ToHeapObject(InstructionOperand* operand) {
113 return ToConstant(operand).ToHeapObject();
114 }
115
116 Frame* frame() const { return gen_->frame(); }
117 Isolate* isolate() const { return gen_->isolate(); }
118 Linkage* linkage() const { return gen_->linkage(); }
119
120 protected:
121 CodeGenerator* gen_;
122 Instruction* instr_;
123 };
124
125
126 // TODO(dcarney): generify this on bleeding_edge and replace this call
127 // when merged.
128 static inline void FinishCode(MacroAssembler* masm) {
129 #if V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_ARM
130 masm->CheckConstPool(true, false);
131 #endif
132 }
133
134 } // namespace compiler
135 } // namespace internal
136 } // namespace v8
137
138 #endif // V8_COMPILER_CODE_GENERATOR_IMPL_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698