vfp.isa revision 8303
17375Sgblack@eecs.umich.edu// -*- mode:c++ -*-
27375Sgblack@eecs.umich.edu
37375Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited
47375Sgblack@eecs.umich.edu// All rights reserved
57375Sgblack@eecs.umich.edu//
67375Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall
77375Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual
87375Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating
97375Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software
107375Sgblack@eecs.umich.edu// licensed hereunder.  You may use the software subject to the license
117375Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated
127375Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software,
137375Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form.
147375Sgblack@eecs.umich.edu//
157375Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
167375Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
177375Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright
187375Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
197375Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
207375Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
217375Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution;
227375Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its
237375Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
247375Sgblack@eecs.umich.edu// this software without specific prior written permission.
257375Sgblack@eecs.umich.edu//
267375Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
277375Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
287375Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
297375Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
307375Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
317375Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
327375Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
337375Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
347375Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
357375Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
367375Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
377375Sgblack@eecs.umich.edu//
387375Sgblack@eecs.umich.edu// Authors: Gabe Black
397375Sgblack@eecs.umich.edu
407640Sgblack@eecs.umich.edulet {{
417640Sgblack@eecs.umich.edu    vfpEnabledCheckCode = '''
427640Sgblack@eecs.umich.edu        if (!vfpEnabled(Cpacr, Cpsr, Fpexc))
437640Sgblack@eecs.umich.edu            return disabledFault();
447640Sgblack@eecs.umich.edu    '''
457640Sgblack@eecs.umich.edu
467644Sali.saidi@arm.com    vmsrEnabledCheckCode = '''
477640Sgblack@eecs.umich.edu        if (!vfpEnabled(Cpacr, Cpsr))
487644Sali.saidi@arm.com            if (dest != (int)MISCREG_FPEXC && dest != (int)MISCREG_FPSID)
497644Sali.saidi@arm.com                return disabledFault();
507644Sali.saidi@arm.com        if (!inPrivilegedMode(Cpsr))
517644Sali.saidi@arm.com            if (dest != (int)MISCREG_FPSCR)
527644Sali.saidi@arm.com                return disabledFault();
537644Sali.saidi@arm.com
547644Sali.saidi@arm.com    '''
557644Sali.saidi@arm.com
567644Sali.saidi@arm.com    vmrsEnabledCheckCode = '''
577644Sali.saidi@arm.com        if (!vfpEnabled(Cpacr, Cpsr))
587644Sali.saidi@arm.com            if (op1 != (int)MISCREG_FPEXC && op1 != (int)MISCREG_FPSID &&
597644Sali.saidi@arm.com                op1 != (int)MISCREG_MVFR0 && op1 != (int)MISCREG_MVFR1)
607644Sali.saidi@arm.com                return disabledFault();
617644Sali.saidi@arm.com        if (!inPrivilegedMode(Cpsr))
627644Sali.saidi@arm.com            if (op1 != (int)MISCREG_FPSCR)
637644Sali.saidi@arm.com                return disabledFault();
647640Sgblack@eecs.umich.edu    '''
658303SAli.Saidi@ARM.com    vmrsApsrEnabledCheckCode = '''
668303SAli.Saidi@ARM.com        if (!vfpEnabled(Cpacr, Cpsr))
678303SAli.Saidi@ARM.com                return disabledFault();
688303SAli.Saidi@ARM.com    '''
697640Sgblack@eecs.umich.edu}};
707640Sgblack@eecs.umich.edu
717396Sgblack@eecs.umich.edudef template FpRegRegOpDeclare {{
727375Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
737375Sgblack@eecs.umich.edu{
747396Sgblack@eecs.umich.edu  public:
757396Sgblack@eecs.umich.edu    // Constructor
767396Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst,
777396Sgblack@eecs.umich.edu                   IntRegIndex _dest, IntRegIndex _op1,
787396Sgblack@eecs.umich.edu                   VfpMicroMode mode = VfpNotAMicroop);
797396Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
807375Sgblack@eecs.umich.edu};
817375Sgblack@eecs.umich.edu}};
827375Sgblack@eecs.umich.edu
837396Sgblack@eecs.umich.edudef template FpRegRegOpConstructor {{
847375Sgblack@eecs.umich.edu    inline %(class_name)s::%(class_name)s(ExtMachInst machInst,
857375Sgblack@eecs.umich.edu                                          IntRegIndex _dest, IntRegIndex _op1,
867375Sgblack@eecs.umich.edu                                          VfpMicroMode mode)
877375Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
887375Sgblack@eecs.umich.edu                _dest, _op1, mode)
897375Sgblack@eecs.umich.edu    {
907375Sgblack@eecs.umich.edu        %(constructor)s;
917848SAli.Saidi@ARM.com        if (!(condCode == COND_AL || condCode == COND_UC)) {
927848SAli.Saidi@ARM.com            for (int x = 0; x < _numDestRegs; x++) {
937848SAli.Saidi@ARM.com                _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
947848SAli.Saidi@ARM.com            }
957848SAli.Saidi@ARM.com        }
967375Sgblack@eecs.umich.edu    }
977375Sgblack@eecs.umich.edu}};
987375Sgblack@eecs.umich.edu
997396Sgblack@eecs.umich.edudef template FpRegImmOpDeclare {{
1007375Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
1017375Sgblack@eecs.umich.edu{
1027396Sgblack@eecs.umich.edu  public:
1037396Sgblack@eecs.umich.edu    // Constructor
1047396Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst, IntRegIndex _dest,
1057396Sgblack@eecs.umich.edu            uint64_t _imm, VfpMicroMode mode = VfpNotAMicroop);
1067396Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
1077375Sgblack@eecs.umich.edu};
1087375Sgblack@eecs.umich.edu}};
1097375Sgblack@eecs.umich.edu
1107396Sgblack@eecs.umich.edudef template FpRegImmOpConstructor {{
1117375Sgblack@eecs.umich.edu    inline %(class_name)s::%(class_name)s(ExtMachInst machInst,
1127375Sgblack@eecs.umich.edu            IntRegIndex _dest, uint64_t _imm, VfpMicroMode mode)
1137375Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
1147375Sgblack@eecs.umich.edu                _dest, _imm, mode)
1157375Sgblack@eecs.umich.edu    {
1167375Sgblack@eecs.umich.edu        %(constructor)s;
1177848SAli.Saidi@ARM.com        if (!(condCode == COND_AL || condCode == COND_UC)) {
1187848SAli.Saidi@ARM.com            for (int x = 0; x < _numDestRegs; x++) {
1197848SAli.Saidi@ARM.com                _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
1207848SAli.Saidi@ARM.com            }
1217848SAli.Saidi@ARM.com        }
1227375Sgblack@eecs.umich.edu    }
1237375Sgblack@eecs.umich.edu}};
1247375Sgblack@eecs.umich.edu
1257396Sgblack@eecs.umich.edudef template FpRegRegImmOpDeclare {{
1267375Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
1277375Sgblack@eecs.umich.edu{
1287396Sgblack@eecs.umich.edu  public:
1297396Sgblack@eecs.umich.edu    // Constructor
1307396Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst,
1317396Sgblack@eecs.umich.edu                   IntRegIndex _dest, IntRegIndex _op1,
1327396Sgblack@eecs.umich.edu                   uint64_t _imm, VfpMicroMode mode = VfpNotAMicroop);
1337396Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
1347375Sgblack@eecs.umich.edu};
1357375Sgblack@eecs.umich.edu}};
1367375Sgblack@eecs.umich.edu
1377396Sgblack@eecs.umich.edudef template FpRegRegImmOpConstructor {{
1387375Sgblack@eecs.umich.edu    inline %(class_name)s::%(class_name)s(ExtMachInst machInst,
1397375Sgblack@eecs.umich.edu                                          IntRegIndex _dest,
1407375Sgblack@eecs.umich.edu                                          IntRegIndex _op1,
1417375Sgblack@eecs.umich.edu                                          uint64_t _imm,
1427375Sgblack@eecs.umich.edu                                          VfpMicroMode mode)
1437375Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
1447375Sgblack@eecs.umich.edu                         _dest, _op1, _imm, mode)
1457375Sgblack@eecs.umich.edu    {
1467375Sgblack@eecs.umich.edu        %(constructor)s;
1477848SAli.Saidi@ARM.com        if (!(condCode == COND_AL || condCode == COND_UC)) {
1487848SAli.Saidi@ARM.com            for (int x = 0; x < _numDestRegs; x++) {
1497848SAli.Saidi@ARM.com                _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
1507848SAli.Saidi@ARM.com            }
1517848SAli.Saidi@ARM.com        }
1527375Sgblack@eecs.umich.edu    }
1537375Sgblack@eecs.umich.edu}};
1547375Sgblack@eecs.umich.edu
1557396Sgblack@eecs.umich.edudef template FpRegRegRegOpDeclare {{
1567375Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
1577375Sgblack@eecs.umich.edu{
1587396Sgblack@eecs.umich.edu  public:
1597396Sgblack@eecs.umich.edu    // Constructor
1607396Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst,
1617396Sgblack@eecs.umich.edu                   IntRegIndex _dest, IntRegIndex _op1, IntRegIndex _op2,
1627396Sgblack@eecs.umich.edu                   VfpMicroMode mode = VfpNotAMicroop);
1637396Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
1647375Sgblack@eecs.umich.edu};
1657375Sgblack@eecs.umich.edu}};
1667375Sgblack@eecs.umich.edu
1677396Sgblack@eecs.umich.edudef template FpRegRegRegOpConstructor {{
1687375Sgblack@eecs.umich.edu    inline %(class_name)s::%(class_name)s(ExtMachInst machInst,
1697375Sgblack@eecs.umich.edu                                          IntRegIndex _dest,
1707375Sgblack@eecs.umich.edu                                          IntRegIndex _op1,
1717375Sgblack@eecs.umich.edu                                          IntRegIndex _op2,
1727375Sgblack@eecs.umich.edu                                          VfpMicroMode mode)
1737375Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
1747375Sgblack@eecs.umich.edu                         _dest, _op1, _op2, mode)
1757375Sgblack@eecs.umich.edu    {
1767375Sgblack@eecs.umich.edu        %(constructor)s;
1777848SAli.Saidi@ARM.com        if (!(condCode == COND_AL || condCode == COND_UC)) {
1787848SAli.Saidi@ARM.com            for (int x = 0; x < _numDestRegs; x++) {
1797848SAli.Saidi@ARM.com                _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
1807848SAli.Saidi@ARM.com            }
1817848SAli.Saidi@ARM.com        }
1827375Sgblack@eecs.umich.edu    }
1837375Sgblack@eecs.umich.edu}};
184