blob: bd985673a4c92a9820da9dc761bd4f64abe17f3c [file] [log] [blame]
Gabe Blacke1e76052007-09-04 23:21:41 -07001/*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
3 * All rights reserved.
4 *
Nathan Binkert13d64902010-05-23 22:44:15 -07005 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
Gabe Blacke1e76052007-09-04 23:21:41 -070013 *
Nathan Binkert13d64902010-05-23 22:44:15 -070014 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
Gabe Blacke1e76052007-09-04 23:21:41 -070022 * contributors may be used to endorse or promote products derived from
Nathan Binkert13d64902010-05-23 22:44:15 -070023 * this software without specific prior written permission.
Gabe Blacke1e76052007-09-04 23:21:41 -070024 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Gabe Blacke1e76052007-09-04 23:21:41 -070036 */
37
38#ifndef __ARCH_X86_FLOATREGS_HH__
39#define __ARCH_X86_FLOATREGS_HH__
40
41#include "arch/x86/x86_traits.hh"
42#include "base/bitunion.hh"
43
Daniel R. Carvalho974a47d2021-05-09 12:32:07 -030044namespace gem5
45{
46
Gabe Blacke1e76052007-09-04 23:21:41 -070047namespace X86ISA
48{
49 enum FloatRegIndex
50 {
51 // MMX/X87 registers
52 FLOATREG_MMX_BASE,
53 FLOATREG_FPR_BASE = FLOATREG_MMX_BASE,
54 FLOATREG_MMX0 = FLOATREG_MMX_BASE,
55 FLOATREG_MMX1,
56 FLOATREG_MMX2,
57 FLOATREG_MMX3,
58 FLOATREG_MMX4,
59 FLOATREG_MMX5,
60 FLOATREG_MMX6,
61 FLOATREG_MMX7,
62
63 FLOATREG_FPR0 = FLOATREG_FPR_BASE,
64 FLOATREG_FPR1,
65 FLOATREG_FPR2,
66 FLOATREG_FPR3,
67 FLOATREG_FPR4,
68 FLOATREG_FPR5,
69 FLOATREG_FPR6,
70 FLOATREG_FPR7,
71
72 FLOATREG_XMM_BASE = FLOATREG_MMX_BASE + NumMMXRegs,
73 FLOATREG_XMM0_LOW = FLOATREG_XMM_BASE,
74 FLOATREG_XMM0_HIGH,
75 FLOATREG_XMM1_LOW,
76 FLOATREG_XMM1_HIGH,
77 FLOATREG_XMM2_LOW,
78 FLOATREG_XMM2_HIGH,
79 FLOATREG_XMM3_LOW,
80 FLOATREG_XMM3_HIGH,
81 FLOATREG_XMM4_LOW,
82 FLOATREG_XMM4_HIGH,
83 FLOATREG_XMM5_LOW,
84 FLOATREG_XMM5_HIGH,
85 FLOATREG_XMM6_LOW,
86 FLOATREG_XMM6_HIGH,
87 FLOATREG_XMM7_LOW,
88 FLOATREG_XMM7_HIGH,
89 FLOATREG_XMM8_LOW,
90 FLOATREG_XMM8_HIGH,
91 FLOATREG_XMM9_LOW,
92 FLOATREG_XMM9_HIGH,
93 FLOATREG_XMM10_LOW,
94 FLOATREG_XMM10_HIGH,
95 FLOATREG_XMM11_LOW,
96 FLOATREG_XMM11_HIGH,
97 FLOATREG_XMM12_LOW,
98 FLOATREG_XMM12_HIGH,
99 FLOATREG_XMM13_LOW,
100 FLOATREG_XMM13_HIGH,
101 FLOATREG_XMM14_LOW,
102 FLOATREG_XMM14_HIGH,
103 FLOATREG_XMM15_LOW,
104 FLOATREG_XMM15_HIGH,
105
Gabe Blackaf4c04c2007-09-04 23:31:40 -0700106 FLOATREG_MICROFP_BASE = FLOATREG_XMM_BASE + 2 * NumXMMRegs,
107 FLOATREG_MICROFP0 = FLOATREG_MICROFP_BASE,
108 FLOATREG_MICROFP1,
109 FLOATREG_MICROFP2,
110 FLOATREG_MICROFP3,
111 FLOATREG_MICROFP4,
112 FLOATREG_MICROFP5,
113 FLOATREG_MICROFP6,
114 FLOATREG_MICROFP7,
115
116 NUM_FLOATREGS = FLOATREG_MICROFP_BASE + NumMicroFpRegs
Gabe Blacke1e76052007-09-04 23:21:41 -0700117 };
118
119 static inline FloatRegIndex
120 FLOATREG_MMX(int index)
121 {
122 return (FloatRegIndex)(FLOATREG_MMX_BASE + index);
123 }
124
125 static inline FloatRegIndex
126 FLOATREG_FPR(int index)
127 {
128 return (FloatRegIndex)(FLOATREG_FPR_BASE + index);
129 }
130
131 static inline FloatRegIndex
132 FLOATREG_XMM_LOW(int index)
133 {
134 return (FloatRegIndex)(FLOATREG_XMM_BASE + 2 * index);
135 }
136
137 static inline FloatRegIndex
138 FLOATREG_XMM_HIGH(int index)
139 {
140 return (FloatRegIndex)(FLOATREG_XMM_BASE + 2 * index + 1);
141 }
Gabe Blackaf4c04c2007-09-04 23:31:40 -0700142
143 static inline FloatRegIndex
144 FLOATREG_MICROFP(int index)
145 {
146 return (FloatRegIndex)(FLOATREG_MICROFP_BASE + index);
147 }
Gabe Blackf3f37472007-09-19 18:26:42 -0700148
149 static inline FloatRegIndex
150 FLOATREG_STACK(int index, int top)
151 {
Gabe Black3f9b0cc2009-07-16 09:26:38 -0700152 return FLOATREG_FPR((top + index + 8) % 8);
Gabe Blackf3f37472007-09-19 18:26:42 -0700153 }
Gabe Black124f82c2021-02-22 03:20:18 -0800154
155 // Each 128 bit xmm register is broken into two effective 64 bit registers.
156 // Add 8 for the indices that are mapped over the fp stack
157 const int NumFloatRegs =
158 NumMMXRegs + 2 * NumXMMRegs + NumMicroFpRegs + 8;
Daniel R. Carvalho974a47d2021-05-09 12:32:07 -0300159
160} // namespace X86ISA
161} // namespace gem5
Gabe Blacke1e76052007-09-04 23:21:41 -0700162
163#endif // __ARCH_X86_FLOATREGS_HH__