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