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

Side by Side Diff: src/compiler/ppc/instruction-selector-ppc.cc

Issue 935383002: Contribution of PowerPC port (continuation of 422063005) - PPC dir update 2 - mark2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/compiler/ppc/code-generator-ppc.cc ('k') | src/disassembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/instruction-selector-impl.h" 5 #include "src/compiler/instruction-selector-impl.h"
6 #include "src/compiler/node-matchers.h" 6 #include "src/compiler/node-matchers.h"
7 #include "src/compiler/node-properties.h" 7 #include "src/compiler/node-properties.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 #endif 1228 #endif
1229 1229
1230 1230
1231 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, 1231 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
1232 BasicBlock* fbranch) { 1232 BasicBlock* fbranch) {
1233 FlagsContinuation cont(kNotEqual, tbranch, fbranch); 1233 FlagsContinuation cont(kNotEqual, tbranch, fbranch);
1234 VisitWord32CompareZero(this, branch, branch->InputAt(0), &cont); 1234 VisitWord32CompareZero(this, branch, branch->InputAt(0), &cont);
1235 } 1235 }
1236 1236
1237 1237
1238 void InstructionSelector::VisitSwitch(Node* node, BasicBlock* default_branch,
1239 BasicBlock** case_branches,
1240 int32_t* case_values, size_t case_count,
1241 int32_t min_value, int32_t max_value) {
1242 PPCOperandGenerator g(this);
1243 InstructionOperand value_operand = g.UseRegister(node->InputAt(0));
1244 InstructionOperand default_operand = g.Label(default_branch);
1245
1246 // Note that {value_range} can be 0 if {min_value} is -2^31 and {max_value}
1247 // is 2^31-1, so don't assume that it's non-zero below.
1248 size_t value_range =
1249 1u + bit_cast<uint32_t>(max_value) - bit_cast<uint32_t>(min_value);
1250
1251 // Determine whether to issue an ArchTableSwitch or an ArchLookupSwitch
1252 // instruction.
1253 size_t table_space_cost = 4 + value_range;
1254 size_t table_time_cost = 3;
1255 size_t lookup_space_cost = 3 + 2 * case_count;
1256 size_t lookup_time_cost = case_count;
1257 if (case_count > 0 &&
1258 table_space_cost + 3 * table_time_cost <=
1259 lookup_space_cost + 3 * lookup_time_cost &&
1260 min_value > std::numeric_limits<int32_t>::min()) {
1261 InstructionOperand index_operand = value_operand;
1262 if (min_value) {
1263 index_operand = g.TempRegister();
1264 Emit(kPPC_Sub32, index_operand, value_operand,
1265 g.TempImmediate(min_value));
1266 }
1267 size_t input_count = 2 + value_range;
1268 auto* inputs = zone()->NewArray<InstructionOperand>(input_count);
1269 inputs[0] = index_operand;
1270 std::fill(&inputs[1], &inputs[input_count], default_operand);
1271 for (size_t index = 0; index < case_count; ++index) {
1272 size_t value = case_values[index] - min_value;
1273 BasicBlock* branch = case_branches[index];
1274 DCHECK_LE(0u, value);
1275 DCHECK_LT(value + 2, input_count);
1276 inputs[value + 2] = g.Label(branch);
1277 }
1278 Emit(kArchTableSwitch, 0, nullptr, input_count, inputs, 0, nullptr)
1279 ->MarkAsControl();
1280 return;
1281 }
1282
1283 // Generate a sequence of conditional jumps.
1284 size_t input_count = 2 + case_count * 2;
1285 auto* inputs = zone()->NewArray<InstructionOperand>(input_count);
1286 inputs[0] = value_operand;
1287 inputs[1] = default_operand;
1288 for (size_t index = 0; index < case_count; ++index) {
1289 int32_t value = case_values[index];
1290 BasicBlock* branch = case_branches[index];
1291 inputs[index * 2 + 2 + 0] = g.TempImmediate(value);
1292 inputs[index * 2 + 2 + 1] = g.Label(branch);
1293 }
1294 Emit(kArchLookupSwitch, 0, nullptr, input_count, inputs, 0, nullptr)
1295 ->MarkAsControl();
1296 }
1297
1298
1238 void InstructionSelector::VisitWord32Equal(Node* const node) { 1299 void InstructionSelector::VisitWord32Equal(Node* const node) {
1239 FlagsContinuation cont(kEqual, node); 1300 FlagsContinuation cont(kEqual, node);
1240 Int32BinopMatcher m(node); 1301 Int32BinopMatcher m(node);
1241 if (m.right().Is(0)) { 1302 if (m.right().Is(0)) {
1242 return VisitWord32CompareZero(this, m.node(), m.left().node(), &cont); 1303 return VisitWord32CompareZero(this, m.node(), m.left().node(), &cont);
1243 } 1304 }
1244 VisitWord32Compare(this, node, &cont); 1305 VisitWord32Compare(this, node, &cont);
1245 } 1306 }
1246 1307
1247 1308
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 return MachineOperatorBuilder::kFloat64Floor | 1435 return MachineOperatorBuilder::kFloat64Floor |
1375 MachineOperatorBuilder::kFloat64Ceil | 1436 MachineOperatorBuilder::kFloat64Ceil |
1376 MachineOperatorBuilder::kFloat64RoundTruncate | 1437 MachineOperatorBuilder::kFloat64RoundTruncate |
1377 MachineOperatorBuilder::kFloat64RoundTiesAway; 1438 MachineOperatorBuilder::kFloat64RoundTiesAway;
1378 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. 1439 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f.
1379 } 1440 }
1380 1441
1381 } // namespace compiler 1442 } // namespace compiler
1382 } // namespace internal 1443 } // namespace internal
1383 } // namespace v8 1444 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ppc/code-generator-ppc.cc ('k') | src/disassembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698