001/* 002 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.loop; 024 025import com.oracle.graal.compiler.common.type.*; 026import com.oracle.graal.nodes.*; 027import com.oracle.graal.nodes.calc.*; 028 029public class DerivedConvertedInductionVariable extends DerivedInductionVariable { 030 031 private final Stamp stamp; 032 private final ValueNode value; 033 034 public DerivedConvertedInductionVariable(LoopEx loop, InductionVariable base, Stamp stamp, ValueNode value) { 035 super(loop, base); 036 this.stamp = stamp; 037 this.value = value; 038 } 039 040 @Override 041 public ValueNode valueNode() { 042 return value; 043 } 044 045 @Override 046 public Direction direction() { 047 return base.direction(); 048 } 049 050 @Override 051 public ValueNode initNode() { 052 return IntegerConvertNode.convert(base.initNode(), stamp, graph()); 053 } 054 055 @Override 056 public ValueNode strideNode() { 057 return IntegerConvertNode.convert(base.strideNode(), stamp, graph()); 058 } 059 060 @Override 061 public boolean isConstantInit() { 062 return base.isConstantInit(); 063 } 064 065 @Override 066 public boolean isConstantStride() { 067 return base.isConstantStride(); 068 } 069 070 @Override 071 public long constantInit() { 072 return base.constantInit(); 073 } 074 075 @Override 076 public long constantStride() { 077 return base.constantStride(); 078 } 079 080 @Override 081 public ValueNode extremumNode(boolean assumePositiveTripCount, Stamp s) { 082 return base.extremumNode(assumePositiveTripCount, s); 083 } 084 085 @Override 086 public ValueNode exitValueNode() { 087 return IntegerConvertNode.convert(base.exitValueNode(), stamp, graph()); 088 } 089 090 @Override 091 public boolean isConstantExtremum() { 092 return base.isConstantExtremum(); 093 } 094 095 @Override 096 public long constantExtremum() { 097 return base.constantExtremum(); 098 } 099 100 @Override 101 public void deleteUnusedNodes() { 102 } 103 104 @Override 105 public String toString() { 106 return String.format("DerivedConvertedInductionVariable base (%s) %s %s", base, value.getNodeClass().shortName(), stamp); 107 } 108}