comparison jvmci/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARCKind.java @ 22672:1bbd4a7c274b

Rename jdk.internal.jvmci to jdk.vm.ci
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 08 Oct 2015 17:28:41 -0700
parents jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARCKind.java@111882d99400
children 5ba5ff0fda9e
comparison
equal deleted inserted replaced
22671:97f30e4d0e95 22672:1bbd4a7c274b
1 /*
2 * Copyright (c) 2015, 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 DWORD(8),
32 SINGLE(4),
33 DOUBLE(8),
34
35 V32_BYTE(4, BYTE),
36 V32_HWORD(4, HWORD),
37
38 V64_BYTE(8, BYTE),
39 V64_HWORD(8, HWORD),
40 V64_WORD(8, WORD),
41 V64_SINGLE(8, SINGLE);
42
43 private final int size;
44 private final int vectorLength;
45
46 private final SPARCKind scalar;
47 private final EnumKey<SPARCKind> key = new EnumKey<>(this);
48
49 private SPARCKind(int size) {
50 this.size = size;
51 this.scalar = this;
52 this.vectorLength = 1;
53 }
54
55 private SPARCKind(int size, SPARCKind scalar) {
56 this.size = size;
57 this.scalar = scalar;
58
59 assert size % scalar.size == 0;
60 this.vectorLength = size / scalar.size;
61 }
62
63 public SPARCKind getScalar() {
64 return scalar;
65 }
66
67 public int getSizeInBytes() {
68 return size;
69 }
70
71 public int getSizeInBits() {
72 return getSizeInBytes() * 8;
73 }
74
75 public int getVectorLength() {
76 return vectorLength;
77 }
78
79 public Key getKey() {
80 return key;
81 }
82
83 public boolean isInteger() {
84 switch (this) {
85 case BYTE:
86 case HWORD:
87 case WORD:
88 case DWORD:
89 return true;
90 default:
91 return false;
92 }
93 }
94
95 public boolean isFloat() {
96 return !isInteger();
97 }
98
99 public char getTypeChar() {
100 switch (this) {
101 case BYTE:
102 return 'b';
103 case HWORD:
104 return 'h';
105 case WORD:
106 return 'w';
107 case DWORD:
108 return 'd';
109 case SINGLE:
110 return 'S';
111 case DOUBLE:
112 case V64_BYTE:
113 case V64_HWORD:
114 case V64_WORD:
115 return 'D';
116 default:
117 return '-';
118 }
119 }
120 }