AArch64LIRKindTool.java revision 12657:6ef01bd40ce2
1292934Sdim/*
2292934Sdim * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3353358Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4353358Sdim *
5353358Sdim * This code is free software; you can redistribute it and/or modify it
6292934Sdim * under the terms of the GNU General Public License version 2 only, as
7292934Sdim * published by the Free Software Foundation.
8292934Sdim *
9292934Sdim * This code is distributed in the hope that it will be useful, but WITHOUT
10292934Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11292934Sdim * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12292934Sdim * version 2 for more details (a copy is included in the LICENSE file that
13321369Sdim * accompanied this code).
14314564Sdim *
15292934Sdim * You should have received a copy of the GNU General Public License version
16292934Sdim * 2 along with this work; if not, write to the Free Software Foundation,
17292934Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18292934Sdim *
19292934Sdim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20292934Sdim * or visit www.oracle.com if you need additional information or have any
21292934Sdim * questions.
22292934Sdim */
23292934Sdimpackage org.graalvm.compiler.core.aarch64;
24292934Sdim
25292934Sdimimport org.graalvm.compiler.core.common.LIRKind;
26292934Sdimimport org.graalvm.compiler.core.common.spi.LIRKindTool;
27314564Sdimimport org.graalvm.compiler.debug.GraalError;
28292934Sdim
29314564Sdimimport jdk.vm.ci.aarch64.AArch64Kind;
30353358Sdim
31314564Sdimpublic class AArch64LIRKindTool implements LIRKindTool {
32360784Sdim
33314564Sdim    @Override
34327952Sdim    public LIRKind getIntegerKind(int bits) {
35292934Sdim        if (bits <= 8) {
36292934Sdim            return LIRKind.value(AArch64Kind.BYTE);
37292934Sdim        } else if (bits <= 16) {
38292934Sdim            return LIRKind.value(AArch64Kind.WORD);
39292934Sdim        } else if (bits <= 32) {
40292934Sdim            return LIRKind.value(AArch64Kind.DWORD);
41292934Sdim        } else {
42292934Sdim            assert bits <= 64;
43292934Sdim            return LIRKind.value(AArch64Kind.QWORD);
44292934Sdim        }
45314564Sdim    }
46314564Sdim
47314564Sdim    @Override
48292934Sdim    public LIRKind getFloatingKind(int bits) {
49292934Sdim        switch (bits) {
50353358Sdim            case 32:
51292934Sdim                return LIRKind.value(AArch64Kind.SINGLE);
52360784Sdim            case 64:
53360784Sdim                return LIRKind.value(AArch64Kind.DOUBLE);
54360784Sdim            default:
55314564Sdim                throw GraalError.shouldNotReachHere();
56314564Sdim        }
57360784Sdim    }
58360784Sdim
59292934Sdim    @Override
60344779Sdim    public LIRKind getObjectKind() {
61353358Sdim        return LIRKind.reference(AArch64Kind.QWORD);
62344779Sdim    }
63292934Sdim
64292934Sdim    @Override
65292934Sdim    public LIRKind getWordKind() {
66292934Sdim        return LIRKind.value(AArch64Kind.QWORD);
67353358Sdim    }
68353358Sdim
69292934Sdim}
70292934Sdim