15041SN/A/*
25041SN/A * Copyright (c) 2007 The Hewlett-Packard Development Company
35041SN/A * All rights reserved.
45041SN/A *
57087SN/A * The license below extends only to copyright in the software and shall
67087SN/A * not be construed as granting a license to any other intellectual
77087SN/A * property including but not limited to intellectual property relating
87087SN/A * to a hardware implementation of the functionality of the software
97087SN/A * licensed hereunder.  You may use the software subject to the license
107087SN/A * terms below provided that you ensure that this notice is replicated
117087SN/A * unmodified and in its entirety in all distributions of the software,
127087SN/A * modified or unmodified, in source code or in binary form.
135041SN/A *
147087SN/A * Redistribution and use in source and binary forms, with or without
157087SN/A * modification, are permitted provided that the following conditions are
167087SN/A * met: redistributions of source code must retain the above copyright
177087SN/A * notice, this list of conditions and the following disclaimer;
187087SN/A * redistributions in binary form must reproduce the above copyright
197087SN/A * notice, this list of conditions and the following disclaimer in the
207087SN/A * documentation and/or other materials provided with the distribution;
217087SN/A * neither the name of the copyright holders nor the names of its
225041SN/A * contributors may be used to endorse or promote products derived from
237087SN/A * this software without specific prior written permission.
245041SN/A *
255041SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
265041SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
275041SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
285041SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
295041SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
305041SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
315041SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
325041SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
335041SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
345041SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
355041SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
365041SN/A *
375041SN/A * Authors: Gabe Black
385041SN/A */
395041SN/A
405041SN/A#ifndef __ARCH_X86_FLOATREGS_HH__
415041SN/A#define __ARCH_X86_FLOATREGS_HH__
425041SN/A
435041SN/A#include "arch/x86/x86_traits.hh"
445041SN/A#include "base/bitunion.hh"
455041SN/A
465041SN/Anamespace X86ISA
475041SN/A{
485041SN/A    enum FloatRegIndex
495041SN/A    {
505041SN/A        // MMX/X87 registers
515041SN/A        FLOATREG_MMX_BASE,
525041SN/A        FLOATREG_FPR_BASE = FLOATREG_MMX_BASE,
535041SN/A        FLOATREG_MMX0 = FLOATREG_MMX_BASE,
545041SN/A        FLOATREG_MMX1,
555041SN/A        FLOATREG_MMX2,
565041SN/A        FLOATREG_MMX3,
575041SN/A        FLOATREG_MMX4,
585041SN/A        FLOATREG_MMX5,
595041SN/A        FLOATREG_MMX6,
605041SN/A        FLOATREG_MMX7,
615041SN/A
625041SN/A        FLOATREG_FPR0 = FLOATREG_FPR_BASE,
635041SN/A        FLOATREG_FPR1,
645041SN/A        FLOATREG_FPR2,
655041SN/A        FLOATREG_FPR3,
665041SN/A        FLOATREG_FPR4,
675041SN/A        FLOATREG_FPR5,
685041SN/A        FLOATREG_FPR6,
695041SN/A        FLOATREG_FPR7,
705041SN/A
715041SN/A        FLOATREG_XMM_BASE = FLOATREG_MMX_BASE + NumMMXRegs,
725041SN/A        FLOATREG_XMM0_LOW = FLOATREG_XMM_BASE,
735041SN/A        FLOATREG_XMM0_HIGH,
745041SN/A        FLOATREG_XMM1_LOW,
755041SN/A        FLOATREG_XMM1_HIGH,
765041SN/A        FLOATREG_XMM2_LOW,
775041SN/A        FLOATREG_XMM2_HIGH,
785041SN/A        FLOATREG_XMM3_LOW,
795041SN/A        FLOATREG_XMM3_HIGH,
805041SN/A        FLOATREG_XMM4_LOW,
815041SN/A        FLOATREG_XMM4_HIGH,
825041SN/A        FLOATREG_XMM5_LOW,
835041SN/A        FLOATREG_XMM5_HIGH,
845041SN/A        FLOATREG_XMM6_LOW,
855041SN/A        FLOATREG_XMM6_HIGH,
865041SN/A        FLOATREG_XMM7_LOW,
875041SN/A        FLOATREG_XMM7_HIGH,
885041SN/A        FLOATREG_XMM8_LOW,
895041SN/A        FLOATREG_XMM8_HIGH,
905041SN/A        FLOATREG_XMM9_LOW,
915041SN/A        FLOATREG_XMM9_HIGH,
925041SN/A        FLOATREG_XMM10_LOW,
935041SN/A        FLOATREG_XMM10_HIGH,
945041SN/A        FLOATREG_XMM11_LOW,
955041SN/A        FLOATREG_XMM11_HIGH,
965041SN/A        FLOATREG_XMM12_LOW,
975041SN/A        FLOATREG_XMM12_HIGH,
985041SN/A        FLOATREG_XMM13_LOW,
995041SN/A        FLOATREG_XMM13_HIGH,
1005041SN/A        FLOATREG_XMM14_LOW,
1015041SN/A        FLOATREG_XMM14_HIGH,
1025041SN/A        FLOATREG_XMM15_LOW,
1035041SN/A        FLOATREG_XMM15_HIGH,
1045041SN/A
1055045SN/A        FLOATREG_MICROFP_BASE = FLOATREG_XMM_BASE + 2 * NumXMMRegs,
1065045SN/A        FLOATREG_MICROFP0 = FLOATREG_MICROFP_BASE,
1075045SN/A        FLOATREG_MICROFP1,
1085045SN/A        FLOATREG_MICROFP2,
1095045SN/A        FLOATREG_MICROFP3,
1105045SN/A        FLOATREG_MICROFP4,
1115045SN/A        FLOATREG_MICROFP5,
1125045SN/A        FLOATREG_MICROFP6,
1135045SN/A        FLOATREG_MICROFP7,
1145045SN/A
1155045SN/A        NUM_FLOATREGS = FLOATREG_MICROFP_BASE + NumMicroFpRegs
1165041SN/A    };
1175041SN/A
1185041SN/A    static inline FloatRegIndex
1195041SN/A    FLOATREG_MMX(int index)
1205041SN/A    {
1215041SN/A        return (FloatRegIndex)(FLOATREG_MMX_BASE + index);
1225041SN/A    }
1235041SN/A
1245041SN/A    static inline FloatRegIndex
1255041SN/A    FLOATREG_FPR(int index)
1265041SN/A    {
1275041SN/A        return (FloatRegIndex)(FLOATREG_FPR_BASE + index);
1285041SN/A    }
1295041SN/A
1305041SN/A    static inline FloatRegIndex
1315041SN/A    FLOATREG_XMM_LOW(int index)
1325041SN/A    {
1335041SN/A        return (FloatRegIndex)(FLOATREG_XMM_BASE + 2 * index);
1345041SN/A    }
1355041SN/A
1365041SN/A    static inline FloatRegIndex
1375041SN/A    FLOATREG_XMM_HIGH(int index)
1385041SN/A    {
1395041SN/A        return (FloatRegIndex)(FLOATREG_XMM_BASE + 2 * index + 1);
1405041SN/A    }
1415045SN/A
1425045SN/A    static inline FloatRegIndex
1435045SN/A    FLOATREG_MICROFP(int index)
1445045SN/A    {
1455045SN/A        return (FloatRegIndex)(FLOATREG_MICROFP_BASE + index);
1465045SN/A    }
1475082SN/A
1485082SN/A    static inline FloatRegIndex
1495082SN/A    FLOATREG_STACK(int index, int top)
1505082SN/A    {
1516343SN/A        return FLOATREG_FPR((top + index + 8) % 8);
1525082SN/A    }
1538902Sandreas.hansson@arm.com}
1545041SN/A
1555041SN/A#endif // __ARCH_X86_FLOATREGS_HH__
156