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 SPARCKind(int size) { 51 this.size = size; 52 this.scalar = this; 53 this.vectorLength = 1; 54 } 55 56 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 @Override 69 public int getSizeInBytes() { 70 return size; 71 } 72 73 public int getSizeInBits() { 74 return getSizeInBytes() * 8; 75 } 76 77 @Override 78 public int getVectorLength() { 79 return vectorLength; 80 } 81 82 @Override 83 public Key getKey() { 84 return key; 85 } 86 87 public boolean isInteger() { 88 switch (this) { 89 case BYTE: 90 case HWORD: 91 case WORD: 92 case XWORD: 93 return true; 94 default: 95 return false; 96 } 97 } 98 99 public boolean isFloat() { 100 return !isInteger(); 101 } 102 103 @Override 104 public char getTypeChar() { 105 switch (this) { 106 case BYTE: 107 return 'b'; 108 case HWORD: 109 return 'h'; 110 case WORD: 111 return 'w'; 112 case XWORD: 113 return 'd'; 114 case SINGLE: 115 return 'S'; 116 case DOUBLE: 117 case V64_BYTE: 118 case V64_HWORD: 119 case V64_WORD: 120 return 'D'; 121 default: 122 return '-'; 123 } 124 } 125 }