Mercurial > hg > graal-jvmci-8
comparison jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ValueKind.java @ 23396:9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Fri, 13 May 2016 14:33:19 +0200 |
parents | |
children | a7b12c1ab514 |
comparison
equal
deleted
inserted
replaced
23395:19432ed40848 | 23396:9ed5b586018b |
---|---|
1 /* | |
2 * Copyright (c) 2016, 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.meta; | |
24 | |
25 /** | |
26 * Represents the type of {@link Value values}. This class can be extended by compilers to track | |
27 * additional information about values. | |
28 */ | |
29 public abstract class ValueKind<K extends ValueKind<K>> { | |
30 | |
31 private enum IllegalKind implements PlatformKind { | |
32 ILLEGAL; | |
33 | |
34 private final EnumKey<IllegalKind> key = new EnumKey<>(this); | |
35 | |
36 public Key getKey() { | |
37 return key; | |
38 } | |
39 | |
40 public int getSizeInBytes() { | |
41 return 0; | |
42 } | |
43 | |
44 public int getVectorLength() { | |
45 return 0; | |
46 } | |
47 | |
48 public char getTypeChar() { | |
49 return '-'; | |
50 } | |
51 } | |
52 | |
53 private static class IllegalValueKind extends ValueKind<IllegalValueKind> { | |
54 | |
55 IllegalValueKind() { | |
56 super(IllegalKind.ILLEGAL); | |
57 } | |
58 | |
59 @Override | |
60 public IllegalValueKind changeType(PlatformKind newPlatformKind) { | |
61 return this; | |
62 } | |
63 } | |
64 | |
65 /** | |
66 * The non-type. | |
67 */ | |
68 public static final ValueKind<?> Illegal = new IllegalValueKind(); | |
69 | |
70 private final PlatformKind platformKind; | |
71 | |
72 public ValueKind(PlatformKind platformKind) { | |
73 this.platformKind = platformKind; | |
74 } | |
75 | |
76 public final PlatformKind getPlatformKind() { | |
77 return platformKind; | |
78 } | |
79 | |
80 /** | |
81 * Create a new {@link ValueKind} with a different {@link PlatformKind}. Subclasses should | |
82 * override this to preserve the additional information added by the compiler. | |
83 */ | |
84 public abstract K changeType(PlatformKind newPlatformKind); | |
85 } |