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 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 138 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
139 | 139 |
140 result.type = kOperand; | 140 result.type = kOperand; |
141 // The linkage computes where all spill slots are located. | 141 // The linkage computes where all spill slots are located. |
142 FrameOffset offset = linkage()->GetFrameOffset(op->index(), frame(), extra); | 142 FrameOffset offset = linkage()->GetFrameOffset(op->index(), frame(), extra); |
143 result.operand = | 143 result.operand = |
144 Operand(offset.from_stack_pointer() ? rsp : rbp, offset.offset()); | 144 Operand(offset.from_stack_pointer() ? rsp : rbp, offset.offset()); |
145 return result; | 145 return result; |
146 } | 146 } |
147 | 147 |
148 Operand MemoryOperand(int* first_input) { | 148 static int NextOffset(int* offset) { |
149 const int offset = *first_input; | 149 int i = *offset; |
150 switch (AddressingModeField::decode(instr_->opcode())) { | 150 (*offset)++; |
151 case kMode_MR1I: { | 151 return i; |
152 *first_input += 2; | 152 } |
153 Register index = InputRegister(offset + 1); | 153 |
154 return Operand(InputRegister(offset + 0), index, times_1, | 154 static ScaleFactor ScaleFor(AddressingMode one, AddressingMode mode) { |
155 0); // TODO(dcarney): K != 0 | 155 STATIC_ASSERT(0 == static_cast<int>(times_1)); |
| 156 STATIC_ASSERT(1 == static_cast<int>(times_2)); |
| 157 STATIC_ASSERT(2 == static_cast<int>(times_4)); |
| 158 STATIC_ASSERT(3 == static_cast<int>(times_8)); |
| 159 int scale = static_cast<int>(mode - one); |
| 160 DCHECK(scale >= 0 && scale < 4); |
| 161 return static_cast<ScaleFactor>(scale); |
| 162 } |
| 163 |
| 164 Operand MemoryOperand(int* offset) { |
| 165 AddressingMode mode = AddressingModeField::decode(instr_->opcode()); |
| 166 switch (mode) { |
| 167 case kMode_MR: { |
| 168 Register base = InputRegister(NextOffset(offset)); |
| 169 int32_t disp = 0; |
| 170 return Operand(base, disp); |
156 } | 171 } |
157 case kMode_MRI: | 172 case kMode_MRI: { |
158 *first_input += 2; | 173 Register base = InputRegister(NextOffset(offset)); |
159 return Operand(InputRegister(offset + 0), InputInt32(offset + 1)); | 174 int32_t disp = InputInt32(NextOffset(offset)); |
160 default: | 175 return Operand(base, disp); |
| 176 } |
| 177 case kMode_MR1: |
| 178 case kMode_MR2: |
| 179 case kMode_MR4: |
| 180 case kMode_MR8: { |
| 181 Register base = InputRegister(NextOffset(offset)); |
| 182 Register index = InputRegister(NextOffset(offset)); |
| 183 ScaleFactor scale = ScaleFor(kMode_MR1, mode); |
| 184 int32_t disp = 0; |
| 185 return Operand(base, index, scale, disp); |
| 186 } |
| 187 case kMode_MR1I: |
| 188 case kMode_MR2I: |
| 189 case kMode_MR4I: |
| 190 case kMode_MR8I: { |
| 191 Register base = InputRegister(NextOffset(offset)); |
| 192 Register index = InputRegister(NextOffset(offset)); |
| 193 ScaleFactor scale = ScaleFor(kMode_MR1I, mode); |
| 194 int32_t disp = InputInt32(NextOffset(offset)); |
| 195 return Operand(base, index, scale, disp); |
| 196 } |
| 197 case kMode_M1: |
| 198 case kMode_M2: |
| 199 case kMode_M4: |
| 200 case kMode_M8: { |
| 201 Register index = InputRegister(NextOffset(offset)); |
| 202 ScaleFactor scale = ScaleFor(kMode_M1, mode); |
| 203 int32_t disp = 0; |
| 204 return Operand(index, scale, disp); |
| 205 } |
| 206 case kMode_M1I: |
| 207 case kMode_M2I: |
| 208 case kMode_M4I: |
| 209 case kMode_M8I: { |
| 210 Register index = InputRegister(NextOffset(offset)); |
| 211 ScaleFactor scale = ScaleFor(kMode_M1I, mode); |
| 212 int32_t disp = InputInt32(NextOffset(offset)); |
| 213 return Operand(index, scale, disp); |
| 214 } |
| 215 case kMode_None: |
161 UNREACHABLE(); | 216 UNREACHABLE(); |
162 return Operand(no_reg, 0); | 217 return Operand(no_reg, 0); |
163 } | 218 } |
| 219 UNREACHABLE(); |
| 220 return Operand(no_reg, 0); |
164 } | 221 } |
165 | 222 |
166 Operand MemoryOperand() { | 223 Operand MemoryOperand() { |
167 int first_input = 0; | 224 int first_input = 0; |
168 return MemoryOperand(&first_input); | 225 return MemoryOperand(&first_input); |
169 } | 226 } |
170 }; | 227 }; |
171 | 228 |
172 | 229 |
173 static bool HasImmediateInput(Instruction* instr, int index) { | 230 static bool HasImmediateInput(Instruction* instr, int index) { |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 } | 1092 } |
1036 } | 1093 } |
1037 MarkLazyDeoptSite(); | 1094 MarkLazyDeoptSite(); |
1038 } | 1095 } |
1039 | 1096 |
1040 #undef __ | 1097 #undef __ |
1041 | 1098 |
1042 } // namespace internal | 1099 } // namespace internal |
1043 } // namespace compiler | 1100 } // namespace compiler |
1044 } // namespace v8 | 1101 } // namespace v8 |
OLD | NEW |