comparison jvmci/jdk.vm.ci.amd64/src/jdk/vm/ci/amd64/AMD64Kind.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.amd64/src/jdk/internal/jvmci/amd64/AMD64Kind.java@3abba3d4aef1
children 4b58c92e939b
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.amd64;
24
25 import jdk.vm.ci.meta.PlatformKind;
26
27 public enum AMD64Kind implements PlatformKind {
28
29 // scalar
30 BYTE(1),
31 WORD(2),
32 DWORD(4),
33 QWORD(8),
34 SINGLE(4),
35 DOUBLE(8),
36
37 // SSE2
38 V32_BYTE(4, BYTE),
39 V32_WORD(4, WORD),
40 V64_BYTE(8, BYTE),
41 V64_WORD(8, WORD),
42 V64_DWORD(8, DWORD),
43 V128_BYTE(16, BYTE),
44 V128_WORD(16, WORD),
45 V128_DWORD(16, DWORD),
46 V128_QWORD(16, QWORD),
47 V128_SINGLE(16, SINGLE),
48 V128_DOUBLE(16, DOUBLE),
49
50 // AVX
51 V256_BYTE(32, BYTE),
52 V256_WORD(32, WORD),
53 V256_DWORD(32, DWORD),
54 V256_QWORD(32, QWORD),
55 V256_SINGLE(32, SINGLE),
56 V256_DOUBLE(32, DOUBLE),
57
58 // AVX512
59 V512_BYTE(64, BYTE),
60 V512_WORD(64, WORD),
61 V512_DWORD(64, DWORD),
62 V512_QWORD(64, QWORD),
63 V512_SINGLE(64, SINGLE),
64 V512_DOUBLE(64, DOUBLE),
65
66 MASK8(1),
67 MASK16(2),
68 MASK32(4),
69 MASK64(8);
70
71 private final int size;
72 private final int vectorLength;
73
74 private final AMD64Kind scalar;
75 private final EnumKey<AMD64Kind> key = new EnumKey<>(this);
76
77 private AMD64Kind(int size) {
78 this.size = size;
79 this.scalar = this;
80 this.vectorLength = 1;
81 }
82
83 private AMD64Kind(int size, AMD64Kind scalar) {
84 this.size = size;
85 this.scalar = scalar;
86
87 assert size % scalar.size == 0;
88 this.vectorLength = size / scalar.size;
89 }
90
91 public AMD64Kind getScalar() {
92 return scalar;
93 }
94
95 public int getSizeInBytes() {
96 return size;
97 }
98
99 public int getVectorLength() {
100 return vectorLength;
101 }
102
103 public Key getKey() {
104 return key;
105 }
106
107 public boolean isInteger() {
108 switch (this) {
109 case BYTE:
110 case WORD:
111 case DWORD:
112 case QWORD:
113 return true;
114 default:
115 return false;
116 }
117 }
118
119 public boolean isXMM() {
120 switch (this) {
121 case SINGLE:
122 case DOUBLE:
123 case V32_BYTE:
124 case V32_WORD:
125 case V64_BYTE:
126 case V64_WORD:
127 case V64_DWORD:
128 case V128_BYTE:
129 case V128_WORD:
130 case V128_DWORD:
131 case V128_QWORD:
132 case V128_SINGLE:
133 case V128_DOUBLE:
134 case V256_BYTE:
135 case V256_WORD:
136 case V256_DWORD:
137 case V256_QWORD:
138 case V256_SINGLE:
139 case V256_DOUBLE:
140 case V512_BYTE:
141 case V512_WORD:
142 case V512_DWORD:
143 case V512_QWORD:
144 case V512_SINGLE:
145 case V512_DOUBLE:
146 return true;
147 default:
148 return false;
149 }
150 }
151
152 public boolean isMask() {
153 switch (this) {
154 case MASK8:
155 case MASK16:
156 case MASK32:
157 case MASK64:
158 return true;
159 default:
160 return false;
161 }
162 }
163
164 public char getTypeChar() {
165 switch (this) {
166 case BYTE:
167 return 'b';
168 case WORD:
169 return 'w';
170 case DWORD:
171 return 'd';
172 case QWORD:
173 return 'q';
174 case SINGLE:
175 return 'S';
176 case DOUBLE:
177 return 'D';
178 case V32_BYTE:
179 case V32_WORD:
180 case V64_BYTE:
181 case V64_WORD:
182 case V64_DWORD:
183 return 'v';
184 case V128_BYTE:
185 case V128_WORD:
186 case V128_DWORD:
187 case V128_QWORD:
188 case V128_SINGLE:
189 case V128_DOUBLE:
190 return 'x';
191 case V256_BYTE:
192 case V256_WORD:
193 case V256_DWORD:
194 case V256_QWORD:
195 case V256_SINGLE:
196 case V256_DOUBLE:
197 return 'y';
198 case V512_BYTE:
199 case V512_WORD:
200 case V512_DWORD:
201 case V512_QWORD:
202 case V512_SINGLE:
203 case V512_DOUBLE:
204 return 'z';
205 case MASK8:
206 case MASK16:
207 case MASK32:
208 case MASK64:
209 return 'k';
210 default:
211 return '-';
212 }
213 }
214 }