# HG changeset patch # User Tom Rodriguez # Date 1423525937 28800 # Node ID 18c2fd3d7fc7e346b406d842aeebc520f616f518 # Parent 7ebed83df427fc7dab02fb878de41c3c930fa6e4 Cleanup InductionVariable declarations a bit diff -r 7ebed83df427 -r 18c2fd3d7fc7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java Mon Feb 09 17:06:21 2015 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java Mon Feb 09 15:52:17 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,10 +29,10 @@ public class BasicInductionVariable extends InductionVariable { - private ValuePhiNode phi; - private ValueNode init; - private ValueNode rawStride; - private BinaryArithmeticNode op; + private final ValuePhiNode phi; + private final ValueNode init; + private final ValueNode rawStride; + private final BinaryArithmeticNode op; public BasicInductionVariable(LoopEx loop, ValuePhiNode phi, ValueNode init, ValueNode rawStride, BinaryArithmeticNode op) { super(loop); diff -r 7ebed83df427 -r 18c2fd3d7fc7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedInductionVariable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedInductionVariable.java Mon Feb 09 15:52:17 2015 -0800 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.loop; + +import com.oracle.graal.nodes.*; + +/** + * Base class of the derived induction variables. + */ +public abstract class DerivedInductionVariable extends InductionVariable { + + protected final InductionVariable base; + + public DerivedInductionVariable(LoopEx loop, InductionVariable base) { + super(loop); + this.base = base; + } + + @Override + public StructuredGraph graph() { + return base.graph(); + } + + public InductionVariable getBase() { + return base; + } +} diff -r 7ebed83df427 -r 18c2fd3d7fc7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java Mon Feb 09 17:06:21 2015 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java Mon Feb 09 15:52:17 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,33 +27,22 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; -public class DerivedOffsetInductionVariable extends InductionVariable { +public class DerivedOffsetInductionVariable extends DerivedInductionVariable { - private InductionVariable base; - private ValueNode offset; - private BinaryArithmeticNode value; + private final ValueNode offset; + private final BinaryArithmeticNode value; public DerivedOffsetInductionVariable(LoopEx loop, InductionVariable base, ValueNode offset, BinaryArithmeticNode value) { - super(loop); - this.base = base; + super(loop, base); this.offset = offset; this.value = value; } - public InductionVariable getBase() { - return base; - } - public ValueNode getOffset() { return offset; } @Override - public StructuredGraph graph() { - return base.graph(); - } - - @Override public Direction direction() { return base.direction(); } diff -r 7ebed83df427 -r 18c2fd3d7fc7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java Mon Feb 09 17:06:21 2015 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java Mon Feb 09 15:52:17 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,29 +27,30 @@ import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.util.*; -public class DerivedScaledInductionVariable extends InductionVariable { +public class DerivedScaledInductionVariable extends DerivedInductionVariable { - private InductionVariable base; - private ValueNode scale; - private ValueNode value; + private final ValueNode scale; + private final ValueNode value; public DerivedScaledInductionVariable(LoopEx loop, InductionVariable base, ValueNode scale, ValueNode value) { - super(loop); - this.base = base; + super(loop, base); this.scale = scale; this.value = value; } public DerivedScaledInductionVariable(LoopEx loop, InductionVariable base, NegateNode value) { - super(loop); - this.base = base; + super(loop, base); this.scale = ConstantNode.forInt(-1, value.graph()); this.value = value; } + public ValueNode getScale() { + return scale; + } + @Override - public StructuredGraph graph() { - return base.graph(); + public ValueNode valueNode() { + return value; } @Override @@ -67,11 +68,6 @@ } @Override - public ValueNode valueNode() { - return value; - } - - @Override public ValueNode initNode() { return BinaryArithmeticNode.mul(graph(), base.initNode(), scale); } diff -r 7ebed83df427 -r 18c2fd3d7fc7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java Mon Feb 09 17:06:21 2015 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java Mon Feb 09 15:52:17 2015 -0800 @@ -87,7 +87,9 @@ /** * Returns the extremum value of the induction variable. The extremum value is the value of the - * induction variable in the loop body of the last iteration. + * induction variable in the loop body of the last iteration, only taking into account the main + * loop limit test. It's possible for the loop to exit before this value if + * {@link CountedLoopInfo#isExactTripCount()} returns false for the containing loop. */ public ValueNode extremumNode() { return extremumNode(false, valueNode().stamp());