1 /* 2 * Copyright (c) 2015, 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 package jdk.vm.ci.sparc; 24 25 import jdk.vm.ci.meta.PlatformKind; 26 27 public enum SPARCKind implements PlatformKind { 28 BYTE(1), 29 HWORD(2), 30 WORD(4), 31 XWORD(8), 32 SINGLE(4), 33 DOUBLE(8), 34 QUAD(16), 35 36 V32_BYTE(4, BYTE), 37 V32_HWORD(4, HWORD), 38 39 V64_BYTE(8, BYTE), 40 V64_HWORD(8, HWORD), 41 V64_WORD(8, WORD), 42 V64_SINGLE(8, SINGLE); 43 44 private final int size; 45 private final int vectorLength; 46 47 private final SPARCKind scalar; 48 private final EnumKey<SPARCKind> key = new EnumKey<>(this); 49 50 private SPARCKind(int size) { 51 this.size = size; 52 this.scalar = this; 53 this.vectorLength = 1; 54 } 55 56 private SPARCKind(int size, SPARCKind scalar) { 57 this.size = size; 58 this.scalar = scalar; 59 60 assert size % scalar.size == 0; 61 this.vectorLength = size / scalar.size; 62 } 63 64 public SPARCKind getScalar() { 65 return scalar; 66 } 67 68 public int getSizeInBytes() { 69 return size; 70 } 71 72 public int getSizeInBits() { 73 return getSizeInBytes() * 8; 74 } 75 76 public int getVectorLength() { 77 return vectorLength; 78 } 79 80 public Key getKey() { 81 return key; 82 } 83 84 public boolean isInteger() { 85 switch (this) { 86 case BYTE: 87 case HWORD: 88 case WORD: 89 case XWORD: 90 return true; 91 default: 92 return false; 93 } 94 } 95 96 public boolean isFloat() { 97 return !isInteger(); 98 } 99 100 public char getTypeChar() { 101 switch (this) { 102 case BYTE: 103 return 'b'; 104 case HWORD: 105 return 'h'; 106 case WORD: 107 return 'w'; 108 case XWORD: 109 return 'd'; 110 case SINGLE: 111 return 'S'; 112 case DOUBLE: 113 case V64_BYTE: 114 case V64_HWORD: 115 case V64_WORD: 116 return 'D'; 117 default: 118 return '-'; 119 } 120 } 121 }