1/*
2 * Copyright (c) 2006, 2019, 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 */
24
25#ifndef CPU_X86_VMREG_X86_HPP
26#define CPU_X86_VMREG_X86_HPP
27
28
29
30inline bool is_Register() {
31 return (unsigned int) value() < (unsigned int) ConcreteRegisterImpl::max_gpr;
32}
33
34inline bool is_FloatRegister() {
35 return value() >= ConcreteRegisterImpl::max_gpr && value() < ConcreteRegisterImpl::max_fpr;
36}
37
38inline bool is_XMMRegister() {
39 int uarch_max_xmm = ConcreteRegisterImpl::max_xmm;
40
41#ifdef _LP64
42 if (UseAVX < 3) {
43 int half_xmm = (XMMRegisterImpl::max_slots_per_register * XMMRegisterImpl::number_of_registers) / 2;
44 uarch_max_xmm -= half_xmm;
45 }
46#endif
47
48 return (value() >= ConcreteRegisterImpl::max_fpr && value() < uarch_max_xmm);
49}
50
51inline bool is_KRegister() {
52 if (UseAVX > 2) {
53 return value() >= ConcreteRegisterImpl::max_xmm && value() < ConcreteRegisterImpl::max_kpr;
54 } else {
55 return false;
56 }
57}
58
59inline Register as_Register() {
60
61 assert( is_Register(), "must be");
62 // Yuk
63#ifdef AMD64
64 return ::as_Register(value() >> 1);
65#else
66 return ::as_Register(value());
67#endif // AMD64
68}
69
70inline FloatRegister as_FloatRegister() {
71 assert( is_FloatRegister() && is_even(value()), "must be" );
72 // Yuk
73 return ::as_FloatRegister((value() - ConcreteRegisterImpl::max_gpr) >> 1);
74}
75
76inline XMMRegister as_XMMRegister() {
77 assert( is_XMMRegister() && is_even(value()), "must be" );
78 // Yuk
79 return ::as_XMMRegister((value() - ConcreteRegisterImpl::max_fpr) >> 4);
80}
81
82inline KRegister as_KRegister() {
83 assert(is_KRegister(), "must be");
84 // Yuk
85 return ::as_KRegister((value() - ConcreteRegisterImpl::max_xmm));
86}
87
88inline bool is_concrete() {
89 assert(is_reg(), "must be");
90#ifndef AMD64
91 if (is_Register()) return true;
92#endif // AMD64
93 return is_even(value());
94}
95
96#endif // CPU_X86_VMREG_X86_HPP
97