vfp.isa revision 8303:5a95f1d2494e
1848SN/A// -*- mode:c++ -*-
29956SN/A
39956SN/A// Copyright (c) 2010 ARM Limited
49956SN/A// All rights reserved
59956SN/A//
69956SN/A// The license below extends only to copyright in the software and shall
79956SN/A// not be construed as granting a license to any other intellectual
89956SN/A// property including but not limited to intellectual property relating
99956SN/A// to a hardware implementation of the functionality of the software
109956SN/A// licensed hereunder.  You may use the software subject to the license
119956SN/A// terms below provided that you ensure that this notice is replicated
129956SN/A// unmodified and in its entirety in all distributions of the software,
139956SN/A// modified or unmodified, in source code or in binary form.
141762SN/A//
15848SN/A// Redistribution and use in source and binary forms, with or without
16848SN/A// modification, are permitted provided that the following conditions are
17848SN/A// met: redistributions of source code must retain the above copyright
18848SN/A// notice, this list of conditions and the following disclaimer;
19848SN/A// redistributions in binary form must reproduce the above copyright
20848SN/A// notice, this list of conditions and the following disclaimer in the
21848SN/A// documentation and/or other materials provided with the distribution;
22848SN/A// neither the name of the copyright holders nor the names of its
23848SN/A// contributors may be used to endorse or promote products derived from
24848SN/A// this software without specific prior written permission.
25848SN/A//
26848SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27848SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28848SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29848SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30848SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31848SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32848SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33848SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34848SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35848SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36848SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37848SN/A//
38848SN/A// Authors: Gabe Black
392665SN/A
402665SN/Alet {{
412665SN/A    vfpEnabledCheckCode = '''
422665SN/A        if (!vfpEnabled(Cpacr, Cpsr, Fpexc))
43848SN/A            return disabledFault();
44848SN/A    '''
4511264Sandreas.sandberg@arm.com
4611264Sandreas.sandberg@arm.com    vmsrEnabledCheckCode = '''
47848SN/A        if (!vfpEnabled(Cpacr, Cpsr))
48848SN/A            if (dest != (int)MISCREG_FPEXC && dest != (int)MISCREG_FPSID)
49848SN/A                return disabledFault();
508232SN/A        if (!inPrivilegedMode(Cpsr))
5111264Sandreas.sandberg@arm.com            if (dest != (int)MISCREG_FPSCR)
522565SN/A                return disabledFault();
533348SN/A
544762SN/A    '''
552565SN/A
56848SN/A    vmrsEnabledCheckCode = '''
578737SN/A        if (!vfpEnabled(Cpacr, Cpsr))
588737SN/A            if (op1 != (int)MISCREG_FPEXC && op1 != (int)MISCREG_FPSID &&
598737SN/A                op1 != (int)MISCREG_MVFR0 && op1 != (int)MISCREG_MVFR1)
60848SN/A                return disabledFault();
615772SN/A        if (!inPrivilegedMode(Cpsr))
625772SN/A            if (op1 != (int)MISCREG_FPSCR)
635772SN/A                return disabledFault();
645772SN/A    '''
655772SN/A    vmrsApsrEnabledCheckCode = '''
665772SN/A        if (!vfpEnabled(Cpacr, Cpsr))
675772SN/A                return disabledFault();
685772SN/A    '''
695772SN/A}};
705772SN/A
715772SN/Adef template FpRegRegOpDeclare {{
725772SN/Aclass %(class_name)s : public %(base_class)s
735772SN/A{
745772SN/A  public:
755772SN/A    // Constructor
765772SN/A    %(class_name)s(ExtMachInst machInst,
775772SN/A                   IntRegIndex _dest, IntRegIndex _op1,
785772SN/A                   VfpMicroMode mode = VfpNotAMicroop);
795772SN/A    %(BasicExecDeclare)s
805772SN/A};
815772SN/A}};
825772SN/A
835772SN/Adef template FpRegRegOpConstructor {{
845772SN/A    inline %(class_name)s::%(class_name)s(ExtMachInst machInst,
855772SN/A                                          IntRegIndex _dest, IntRegIndex _op1,
8612895Sjason@lowepower.com                                          VfpMicroMode mode)
875772SN/A        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
885772SN/A                _dest, _op1, mode)
895772SN/A    {
905772SN/A        %(constructor)s;
915772SN/A        if (!(condCode == COND_AL || condCode == COND_UC)) {
925772SN/A            for (int x = 0; x < _numDestRegs; x++) {
935772SN/A                _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
94848SN/A            }
951149SN/A        }
969807SN/A    }
975772SN/A}};
985772SN/A
995772SN/Adef template FpRegImmOpDeclare {{
1005772SN/Aclass %(class_name)s : public %(base_class)s
1015772SN/A{
1027750SN/A  public:
1037750SN/A    // Constructor
104848SN/A    %(class_name)s(ExtMachInst machInst, IntRegIndex _dest,
105848SN/A            uint64_t _imm, VfpMicroMode mode = VfpNotAMicroop);
1065772SN/A    %(BasicExecDeclare)s
1071149SN/A};
10812201Sgabeblack@google.com}};
10912201Sgabeblack@google.com
11012201Sgabeblack@google.comdef template FpRegImmOpConstructor {{
11112201Sgabeblack@google.com    inline %(class_name)s::%(class_name)s(ExtMachInst machInst,
11212201Sgabeblack@google.com            IntRegIndex _dest, uint64_t _imm, VfpMicroMode mode)
11312201Sgabeblack@google.com        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
11412201Sgabeblack@google.com                _dest, _imm, mode)
11512201Sgabeblack@google.com    {
11612201Sgabeblack@google.com        %(constructor)s;
11712201Sgabeblack@google.com        if (!(condCode == COND_AL || condCode == COND_UC)) {
11812201Sgabeblack@google.com            for (int x = 0; x < _numDestRegs; x++) {
11912201Sgabeblack@google.com                _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
12012201Sgabeblack@google.com            }
12112201Sgabeblack@google.com        }
12212201Sgabeblack@google.com    }
12312201Sgabeblack@google.com}};
12412201Sgabeblack@google.com
12512201Sgabeblack@google.comdef template FpRegRegImmOpDeclare {{
12612201Sgabeblack@google.comclass %(class_name)s : public %(base_class)s
1275772SN/A{
128848SN/A  public:
12912201Sgabeblack@google.com    // Constructor
1305772SN/A    %(class_name)s(ExtMachInst machInst,
1315772SN/A                   IntRegIndex _dest, IntRegIndex _op1,
1326431SN/A                   uint64_t _imm, VfpMicroMode mode = VfpNotAMicroop);
1338198SN/A    %(BasicExecDeclare)s
1347750SN/A};
1359956SN/A}};
1367750SN/A
1378198SN/Adef template FpRegRegImmOpConstructor {{
1387750SN/A    inline %(class_name)s::%(class_name)s(ExtMachInst machInst,
1399956SN/A                                          IntRegIndex _dest,
1407750SN/A                                          IntRegIndex _op1,
1417750SN/A                                          uint64_t _imm,
1426431SN/A                                          VfpMicroMode mode)
1436431SN/A        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
144864SN/A                         _dest, _op1, _imm, mode)
145864SN/A    {
146929SN/A        %(constructor)s;
147929SN/A        if (!(condCode == COND_AL || condCode == COND_UC)) {
148929SN/A            for (int x = 0; x < _numDestRegs; x++) {
1495772SN/A                _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
150929SN/A            }
151929SN/A        }
1525772SN/A    }
1535772SN/A}};
1545772SN/A
1555772SN/Adef template FpRegRegRegOpDeclare {{
1569807SN/Aclass %(class_name)s : public %(base_class)s
1575772SN/A{
158849SN/A  public:
159849SN/A    // Constructor
160849SN/A    %(class_name)s(ExtMachInst machInst,
161849SN/A                   IntRegIndex _dest, IntRegIndex _op1, IntRegIndex _op2,
1625772SN/A                   VfpMicroMode mode = VfpNotAMicroop);
1635772SN/A    %(BasicExecDeclare)s
1645772SN/A};
1655772SN/A}};
1665772SN/A
1675772SN/Adef template FpRegRegRegOpConstructor {{
1685772SN/A    inline %(class_name)s::%(class_name)s(ExtMachInst machInst,
1695772SN/A                                          IntRegIndex _dest,
170849SN/A                                          IntRegIndex _op1,
1715772SN/A                                          IntRegIndex _op2,
1725772SN/A                                          VfpMicroMode mode)
1735772SN/A        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
174849SN/A                         _dest, _op1, _op2, mode)
175849SN/A    {
1762846SN/A        %(constructor)s;
1773349SN/A        if (!(condCode == COND_AL || condCode == COND_UC)) {
178848SN/A            for (int x = 0; x < _numDestRegs; x++) {
1792846SN/A                _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
1804875SN/A            }
1819807SN/A        }
1824875SN/A    }
1834875SN/A}};
1842846SN/A