Mercurial > hg > truffle
annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/DefaultLIRKindTool.java @ 21543:93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 25 May 2015 23:30:34 +0200 |
parents | f91e40c4bb47 |
children | 48c1ebd24120 |
rev | line source |
---|---|
18358
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
1 /* |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
22 */ |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.lir.gen; |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
25 import com.oracle.graal.api.meta.*; |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
26 import com.oracle.graal.compiler.common.spi.*; |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18481
diff
changeset
|
27 import com.oracle.jvmci.common.*; |
18358
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
28 |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
29 /** |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
30 * Default implementation of {@link LIRKindTool}. Returns the normal Java kind for primitive types. |
18481
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
31 * Subclasses still have to implement {@link #getObjectKind}. |
18358
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
32 */ |
18481
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
33 public class DefaultLIRKindTool implements LIRKindTool { |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
34 |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
35 private final PlatformKind wordKind; |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
36 |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
37 public DefaultLIRKindTool(PlatformKind wordKind) { |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
38 this.wordKind = wordKind; |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
39 } |
18358
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
40 |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
41 public LIRKind getIntegerKind(int bits) { |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
42 if (bits <= 8) { |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 return LIRKind.value(Kind.Byte); |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 } else if (bits <= 16) { |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 return LIRKind.value(Kind.Short); |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
46 } else if (bits <= 32) { |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 return LIRKind.value(Kind.Int); |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 } else { |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 assert bits <= 64; |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
50 return LIRKind.value(Kind.Long); |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
51 } |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
52 } |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
53 |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
54 public LIRKind getFloatingKind(int bits) { |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
55 switch (bits) { |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
56 case 32: |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
57 return LIRKind.value(Kind.Float); |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
58 case 64: |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
59 return LIRKind.value(Kind.Double); |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
60 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18481
diff
changeset
|
61 throw JVMCIError.shouldNotReachHere(); |
18358
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 } |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 } |
18481
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
64 |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
65 public LIRKind getObjectKind() { |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
66 return LIRKind.reference(Kind.Object); |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
67 } |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
68 |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
69 public LIRKind getWordKind() { |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
70 return LIRKind.value(wordKind); |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
71 } |
18358
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
72 } |