< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/calc/FloatConvert.java

Print this page




   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  */
  23 package org.graalvm.compiler.core.common.calc;
  24 
  25 import org.graalvm.compiler.debug.GraalError;
  26 
  27 public enum FloatConvert {
  28     F2I(FloatConvertCategory.FloatingPointToInteger),
  29     D2I(FloatConvertCategory.FloatingPointToInteger),
  30     F2L(FloatConvertCategory.FloatingPointToInteger),
  31     D2L(FloatConvertCategory.FloatingPointToInteger),
  32     I2F(FloatConvertCategory.IntegerToFloatingPoint),
  33     L2F(FloatConvertCategory.IntegerToFloatingPoint),
  34     D2F(FloatConvertCategory.FloatingPointToFloatingPoint),
  35     I2D(FloatConvertCategory.IntegerToFloatingPoint),
  36     L2D(FloatConvertCategory.IntegerToFloatingPoint),
  37     F2D(FloatConvertCategory.FloatingPointToFloatingPoint);
  38 
  39     private FloatConvertCategory category;

  40 
  41     FloatConvert(FloatConvertCategory category) {
  42         this.category = category;

  43     }
  44 
  45     public FloatConvertCategory getCategory() {
  46         return category;
  47     }
  48 
  49     public FloatConvert reverse() {
  50         switch (this) {
  51             case D2F:
  52                 return F2D;
  53             case D2I:
  54                 return I2D;
  55             case D2L:
  56                 return L2D;
  57             case F2D:
  58                 return D2F;
  59             case F2I:
  60                 return I2F;
  61             case F2L:
  62                 return L2F;
  63             case I2D:
  64                 return D2I;
  65             case I2F:
  66                 return F2I;
  67             case L2D:
  68                 return D2L;
  69             case L2F:
  70                 return F2L;
  71             default:
  72                 throw GraalError.shouldNotReachHere();
  73         }




  74     }
  75 }


   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  */
  23 package org.graalvm.compiler.core.common.calc;
  24 
  25 import org.graalvm.compiler.debug.GraalError;
  26 
  27 public enum FloatConvert {
  28     F2I(FloatConvertCategory.FloatingPointToInteger, 32),
  29     D2I(FloatConvertCategory.FloatingPointToInteger, 64),
  30     F2L(FloatConvertCategory.FloatingPointToInteger, 32),
  31     D2L(FloatConvertCategory.FloatingPointToInteger, 64),
  32     I2F(FloatConvertCategory.IntegerToFloatingPoint, 32),
  33     L2F(FloatConvertCategory.IntegerToFloatingPoint, 64),
  34     D2F(FloatConvertCategory.FloatingPointToFloatingPoint, 64),
  35     I2D(FloatConvertCategory.IntegerToFloatingPoint, 32),
  36     L2D(FloatConvertCategory.IntegerToFloatingPoint, 64),
  37     F2D(FloatConvertCategory.FloatingPointToFloatingPoint, 32);
  38 
  39     private final FloatConvertCategory category;
  40     private final int inputBits;
  41 
  42     FloatConvert(FloatConvertCategory category, int inputBits) {
  43         this.category = category;
  44         this.inputBits = inputBits;
  45     }
  46 
  47     public FloatConvertCategory getCategory() {
  48         return category;
  49     }
  50 
  51     public FloatConvert reverse() {
  52         switch (this) {
  53             case D2F:
  54                 return F2D;
  55             case D2I:
  56                 return I2D;
  57             case D2L:
  58                 return L2D;
  59             case F2D:
  60                 return D2F;
  61             case F2I:
  62                 return I2F;
  63             case F2L:
  64                 return L2F;
  65             case I2D:
  66                 return D2I;
  67             case I2F:
  68                 return F2I;
  69             case L2D:
  70                 return D2L;
  71             case L2F:
  72                 return F2L;
  73             default:
  74                 throw GraalError.shouldNotReachHere();
  75         }
  76     }
  77 
  78     public int getInputBits() {
  79         return inputBits;
  80     }
  81 }
< prev index next >