1 /*
2 * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
349 LabelOp label = (LabelOp) gen.getResult().getLIR().getLIRforBlock(block).get(0);
350 label.setPhiValues(createPhiIn(merge));
351 if (Options.PrintIRWithLIR.getValue(options) && !TTY.isSuppressed()) {
352 TTY.println("Created PhiIn: " + label);
353
354 }
355 }
356 }
357 doBlockPrologue(block, options);
358
359 List<Node> nodes = blockMap.get(block);
360
361 // Allow NodeLIRBuilder subclass to specialize code generation of any interesting groups
362 // of instructions
363 matchComplexExpressions(nodes);
364
365 boolean trace = traceLIRGeneratorLevel >= 3;
366 for (int i = 0; i < nodes.size(); i++) {
367 Node node = nodes.get(i);
368 if (node instanceof ValueNode) {
369 DebugContext debug = node.getDebug();
370 ValueNode valueNode = (ValueNode) node;
371 if (trace) {
372 TTY.println("LIRGen for " + valueNode);
373 }
374 Value operand = getOperand(valueNode);
375 if (operand == null) {
376 if (!peephole(valueNode)) {
377 try {
378 doRoot(valueNode);
379 } catch (GraalError e) {
380 throw GraalGraphError.transformAndAddContext(e, valueNode);
381 } catch (Throwable e) {
382 throw new GraalGraphError(e).addContext(valueNode);
383 }
384 }
385 } else if (ComplexMatchValue.INTERIOR_MATCH.equals(operand)) {
386 // Doesn't need to be evaluated
387 debug.log("interior match for %s", valueNode);
388 } else if (operand instanceof ComplexMatchValue) {
451 }
452 }
453
454 protected abstract boolean peephole(ValueNode valueNode);
455
456 private void doRoot(ValueNode instr) {
457 if (traceLIRGeneratorLevel >= 2) {
458 TTY.println("Emitting LIR for instruction " + instr);
459 }
460 currentInstruction = instr;
461 DebugContext debug = instr.getDebug();
462 debug.log("Visiting %s", instr);
463 emitNode(instr);
464 debug.log("Operand for %s = %s", instr, getOperand(instr));
465 }
466
467 protected void emitNode(ValueNode node) {
468 if (node.getDebug().isLogEnabled() && node.stamp(NodeView.DEFAULT).isEmpty()) {
469 node.getDebug().log("This node has an empty stamp, we are emitting dead code(?): %s", node);
470 }
471 setSourcePosition(node.getNodeSourcePosition());
472 if (node instanceof LIRLowerable) {
473 ((LIRLowerable) node).generate(this);
474 } else {
475 throw GraalError.shouldNotReachHere("node is not LIRLowerable: " + node);
476 }
477 }
478
479 protected void emitPrologue(StructuredGraph graph) {
480 CallingConvention incomingArguments = gen.getResult().getCallingConvention();
481
482 Value[] params = new Value[incomingArguments.getArgumentCount()];
483 for (int i = 0; i < params.length; i++) {
484 params[i] = incomingArguments.getArgument(i);
485 if (ValueUtil.isStackSlot(params[i])) {
486 StackSlot slot = ValueUtil.asStackSlot(params[i]);
487 if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) {
488 gen.getResult().getLIR().setHasArgInCallerFrame();
489 }
490 }
491 }
|
1 /*
2 * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
349 LabelOp label = (LabelOp) gen.getResult().getLIR().getLIRforBlock(block).get(0);
350 label.setPhiValues(createPhiIn(merge));
351 if (Options.PrintIRWithLIR.getValue(options) && !TTY.isSuppressed()) {
352 TTY.println("Created PhiIn: " + label);
353
354 }
355 }
356 }
357 doBlockPrologue(block, options);
358
359 List<Node> nodes = blockMap.get(block);
360
361 // Allow NodeLIRBuilder subclass to specialize code generation of any interesting groups
362 // of instructions
363 matchComplexExpressions(nodes);
364
365 boolean trace = traceLIRGeneratorLevel >= 3;
366 for (int i = 0; i < nodes.size(); i++) {
367 Node node = nodes.get(i);
368 if (node instanceof ValueNode) {
369 setSourcePosition(node.getNodeSourcePosition());
370 DebugContext debug = node.getDebug();
371 ValueNode valueNode = (ValueNode) node;
372 if (trace) {
373 TTY.println("LIRGen for " + valueNode);
374 }
375 Value operand = getOperand(valueNode);
376 if (operand == null) {
377 if (!peephole(valueNode)) {
378 try {
379 doRoot(valueNode);
380 } catch (GraalError e) {
381 throw GraalGraphError.transformAndAddContext(e, valueNode);
382 } catch (Throwable e) {
383 throw new GraalGraphError(e).addContext(valueNode);
384 }
385 }
386 } else if (ComplexMatchValue.INTERIOR_MATCH.equals(operand)) {
387 // Doesn't need to be evaluated
388 debug.log("interior match for %s", valueNode);
389 } else if (operand instanceof ComplexMatchValue) {
452 }
453 }
454
455 protected abstract boolean peephole(ValueNode valueNode);
456
457 private void doRoot(ValueNode instr) {
458 if (traceLIRGeneratorLevel >= 2) {
459 TTY.println("Emitting LIR for instruction " + instr);
460 }
461 currentInstruction = instr;
462 DebugContext debug = instr.getDebug();
463 debug.log("Visiting %s", instr);
464 emitNode(instr);
465 debug.log("Operand for %s = %s", instr, getOperand(instr));
466 }
467
468 protected void emitNode(ValueNode node) {
469 if (node.getDebug().isLogEnabled() && node.stamp(NodeView.DEFAULT).isEmpty()) {
470 node.getDebug().log("This node has an empty stamp, we are emitting dead code(?): %s", node);
471 }
472 if (node instanceof LIRLowerable) {
473 ((LIRLowerable) node).generate(this);
474 } else {
475 throw GraalError.shouldNotReachHere("node is not LIRLowerable: " + node);
476 }
477 }
478
479 protected void emitPrologue(StructuredGraph graph) {
480 CallingConvention incomingArguments = gen.getResult().getCallingConvention();
481
482 Value[] params = new Value[incomingArguments.getArgumentCount()];
483 for (int i = 0; i < params.length; i++) {
484 params[i] = incomingArguments.getArgument(i);
485 if (ValueUtil.isStackSlot(params[i])) {
486 StackSlot slot = ValueUtil.asStackSlot(params[i]);
487 if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) {
488 gen.getResult().getLIR().setHasArgInCallerFrame();
489 }
490 }
491 }
|