vfp.isa revision 10474:799c8ee4ecba
112855Sgabeblack@google.com// -*- mode:c++ -*- 212855Sgabeblack@google.com 312855Sgabeblack@google.com// Copyright (c) 2010-2013 ARM Limited 412855Sgabeblack@google.com// All rights reserved 512855Sgabeblack@google.com// 612855Sgabeblack@google.com// The license below extends only to copyright in the software and shall 712855Sgabeblack@google.com// not be construed as granting a license to any other intellectual 812855Sgabeblack@google.com// property including but not limited to intellectual property relating 912855Sgabeblack@google.com// to a hardware implementation of the functionality of the software 1012855Sgabeblack@google.com// licensed hereunder. You may use the software subject to the license 1112855Sgabeblack@google.com// terms below provided that you ensure that this notice is replicated 1212855Sgabeblack@google.com// unmodified and in its entirety in all distributions of the software, 1312855Sgabeblack@google.com// modified or unmodified, in source code or in binary form. 1412855Sgabeblack@google.com// 1512855Sgabeblack@google.com// Redistribution and use in source and binary forms, with or without 1612855Sgabeblack@google.com// modification, are permitted provided that the following conditions are 1712855Sgabeblack@google.com// met: redistributions of source code must retain the above copyright 1812855Sgabeblack@google.com// notice, this list of conditions and the following disclaimer; 1912855Sgabeblack@google.com// redistributions in binary form must reproduce the above copyright 2012855Sgabeblack@google.com// notice, this list of conditions and the following disclaimer in the 2112855Sgabeblack@google.com// documentation and/or other materials provided with the distribution; 2212855Sgabeblack@google.com// neither the name of the copyright holders nor the names of its 2312855Sgabeblack@google.com// contributors may be used to endorse or promote products derived from 2412855Sgabeblack@google.com// this software without specific prior written permission. 2512855Sgabeblack@google.com// 2612855Sgabeblack@google.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2712855Sgabeblack@google.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2812855Sgabeblack@google.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2912855Sgabeblack@google.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3012855Sgabeblack@google.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3112855Sgabeblack@google.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3212855Sgabeblack@google.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3312855Sgabeblack@google.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3412855Sgabeblack@google.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3512855Sgabeblack@google.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3612855Sgabeblack@google.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3712855Sgabeblack@google.com// 3812855Sgabeblack@google.com// Authors: Gabe Black 3912855Sgabeblack@google.com 4012855Sgabeblack@google.comlet {{ 4112855Sgabeblack@google.com vfpEnabledCheckCode = ''' 4212855Sgabeblack@google.com uint32_t issEnCheck; 4312855Sgabeblack@google.com bool trapEnCheck; 4412855Sgabeblack@google.com uint32_t seq; 4512855Sgabeblack@google.com if (!vfpNeonEnabled(seq,Hcptr, Nsacr, Cpacr, Cpsr, issEnCheck, 4612855Sgabeblack@google.com trapEnCheck, xc->tcBase(), Fpexc)) 4712855Sgabeblack@google.com {return disabledFault();} 4812855Sgabeblack@google.com if (trapEnCheck) { 4912855Sgabeblack@google.com CPSR cpsrEnCheck = Cpsr; 5012855Sgabeblack@google.com if (cpsrEnCheck.mode == MODE_HYP) { 5112855Sgabeblack@google.com return std::make_shared<UndefinedInstruction>( 5212855Sgabeblack@google.com machInst, issEnCheck, 5312855Sgabeblack@google.com EC_TRAPPED_HCPTR, mnemonic); 5412855Sgabeblack@google.com } else { 5512855Sgabeblack@google.com if (!inSecureState(Scr, Cpsr)) { 5612855Sgabeblack@google.com return std::make_shared<HypervisorTrap>( 5712855Sgabeblack@google.com machInst, issEnCheck, 5812855Sgabeblack@google.com EC_TRAPPED_HCPTR); 5912855Sgabeblack@google.com } 6012855Sgabeblack@google.com } 6112855Sgabeblack@google.com } 6212855Sgabeblack@google.com ''' 6312855Sgabeblack@google.com 6412855Sgabeblack@google.com vfp64EnabledCheckCode = ''' 6512855Sgabeblack@google.com CPSR cpsrEnCheck = Cpsr; 6612855Sgabeblack@google.com ExceptionLevel el = (ExceptionLevel) (uint8_t) cpsrEnCheck.el; 6712855Sgabeblack@google.com if (!vfpNeon64Enabled(Cpacr64, el)) 6812855Sgabeblack@google.com return std::make_shared<SupervisorTrap>(machInst, 0x1E00000, 6912855Sgabeblack@google.com EC_TRAPPED_SIMD_FP); 7012855Sgabeblack@google.com 7112855Sgabeblack@google.com if (ArmSystem::haveVirtualization(xc->tcBase()) && el <= EL2) { 7212855Sgabeblack@google.com HCPTR cptrEnCheck = xc->tcBase()->readMiscReg(MISCREG_CPTR_EL2); 7312855Sgabeblack@google.com if (cptrEnCheck.tfp) 7412855Sgabeblack@google.com return std::make_shared<HypervisorTrap>(machInst, 0x1E00000, 7512855Sgabeblack@google.com EC_TRAPPED_SIMD_FP); 7612855Sgabeblack@google.com } 7712855Sgabeblack@google.com 7812855Sgabeblack@google.com if (ArmSystem::haveSecurity(xc->tcBase())) { 7912855Sgabeblack@google.com HCPTR cptrEnCheck = xc->tcBase()->readMiscReg(MISCREG_CPTR_EL3); 8012855Sgabeblack@google.com if (cptrEnCheck.tfp) 8112855Sgabeblack@google.com return std::make_shared<SecureMonitorTrap>(machInst, 0x1E00000, 8212855Sgabeblack@google.com EC_TRAPPED_SIMD_FP); 8312855Sgabeblack@google.com } 8412855Sgabeblack@google.com ''' 8512855Sgabeblack@google.com 8612855Sgabeblack@google.com vmsrEnabledCheckCode = ''' 8712855Sgabeblack@google.com uint32_t issEnCheck; 8812855Sgabeblack@google.com bool trapEnCheck; 8912855Sgabeblack@google.com uint32_t seq; 9012855Sgabeblack@google.com if (!vfpNeonEnabled(seq,Hcptr, Nsacr, Cpacr, Cpsr, issEnCheck, 9112855Sgabeblack@google.com trapEnCheck, xc->tcBase())) 9212855Sgabeblack@google.com if (dest != (int)MISCREG_FPEXC && dest != (int)MISCREG_FPSID) 9312855Sgabeblack@google.com {return disabledFault();} 9412855Sgabeblack@google.com if (!inPrivilegedMode(Cpsr)) 9512855Sgabeblack@google.com if (dest != (int)MISCREG_FPSCR) 9612855Sgabeblack@google.com return disabledFault(); 9712855Sgabeblack@google.com if (trapEnCheck) { 9812855Sgabeblack@google.com CPSR cpsrEnCheck = Cpsr; 9912855Sgabeblack@google.com if (cpsrEnCheck.mode == MODE_HYP) { 10012855Sgabeblack@google.com return std::make_shared<UndefinedInstruction>( 10112855Sgabeblack@google.com machInst, issEnCheck, 10212855Sgabeblack@google.com EC_TRAPPED_HCPTR, mnemonic); 10312855Sgabeblack@google.com } else { 10412855Sgabeblack@google.com if (!inSecureState(Scr, Cpsr)) { 10512855Sgabeblack@google.com return std::make_shared<HypervisorTrap>( 10612855Sgabeblack@google.com machInst, issEnCheck, 10712855Sgabeblack@google.com EC_TRAPPED_HCPTR); 10812855Sgabeblack@google.com } 10912855Sgabeblack@google.com } 11012855Sgabeblack@google.com } 11112855Sgabeblack@google.com ''' 11212855Sgabeblack@google.com 11312855Sgabeblack@google.com vmrsEnabledCheckCode = ''' 11412855Sgabeblack@google.com uint32_t issEnCheck; 11512855Sgabeblack@google.com bool trapEnCheck; 11612855Sgabeblack@google.com uint32_t seq; 11712855Sgabeblack@google.com if (!vfpNeonEnabled(seq,Hcptr, Nsacr, Cpacr, Cpsr, issEnCheck, 11812855Sgabeblack@google.com trapEnCheck, xc->tcBase())) 11912855Sgabeblack@google.com if (op1 != (int)MISCREG_FPEXC && op1 != (int)MISCREG_FPSID && 120 op1 != (int)MISCREG_MVFR0 && op1 != (int)MISCREG_MVFR1) 121 {return disabledFault();} 122 if (!inPrivilegedMode(Cpsr)) 123 if (op1 != (int)MISCREG_FPSCR) 124 return disabledFault(); 125 if (trapEnCheck) { 126 CPSR cpsrEnCheck = Cpsr; 127 if (cpsrEnCheck.mode == MODE_HYP) { 128 return std::make_shared<UndefinedInstruction>( 129 machInst, issEnCheck, 130 EC_TRAPPED_HCPTR, mnemonic); 131 } else { 132 if (!inSecureState(Scr, Cpsr)) { 133 return std::make_shared<HypervisorTrap>( 134 machInst, issEnCheck, 135 EC_TRAPPED_HCPTR); 136 } 137 } 138 } 139 ''' 140 vmrsApsrEnabledCheckCode = ''' 141 uint32_t issEnCheck; 142 bool trapEnCheck; 143 uint32_t seq; 144 if (!vfpNeonEnabled(seq,Hcptr, Nsacr, Cpacr, Cpsr, issEnCheck, 145 trapEnCheck, xc->tcBase())) 146 {return disabledFault();} 147 if (trapEnCheck) { 148 CPSR cpsrEnCheck = Cpsr; 149 if (cpsrEnCheck.mode == MODE_HYP) { 150 return std::make_shared<UndefinedInstruction>( 151 machInst, issEnCheck, 152 EC_TRAPPED_HCPTR, mnemonic); 153 } else { 154 if (!inSecureState(Scr, Cpsr)) { 155 return std::make_shared<HypervisorTrap>( 156 machInst, issEnCheck, 157 EC_TRAPPED_HCPTR); 158 } 159 } 160 } 161 ''' 162}}; 163 164def template FpRegRegOpDeclare {{ 165class %(class_name)s : public %(base_class)s 166{ 167 public: 168 // Constructor 169 %(class_name)s(ExtMachInst machInst, 170 IntRegIndex _dest, IntRegIndex _op1, 171 VfpMicroMode mode = VfpNotAMicroop); 172 %(BasicExecDeclare)s 173}; 174}}; 175 176def template FpRegRegOpConstructor {{ 177 %(class_name)s::%(class_name)s(ExtMachInst machInst, 178 IntRegIndex _dest, IntRegIndex _op1, 179 VfpMicroMode mode) 180 : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 181 _dest, _op1, mode) 182 { 183 %(constructor)s; 184 if (!(condCode == COND_AL || condCode == COND_UC)) { 185 for (int x = 0; x < _numDestRegs; x++) { 186 _srcRegIdx[_numSrcRegs++] = _destRegIdx[x]; 187 } 188 } 189 } 190}}; 191 192def template FpRegImmOpDeclare {{ 193class %(class_name)s : public %(base_class)s 194{ 195 public: 196 // Constructor 197 %(class_name)s(ExtMachInst machInst, IntRegIndex _dest, 198 uint64_t _imm, VfpMicroMode mode = VfpNotAMicroop); 199 %(BasicExecDeclare)s 200}; 201}}; 202 203def template FpRegImmOpConstructor {{ 204 %(class_name)s::%(class_name)s(ExtMachInst machInst, 205 IntRegIndex _dest, uint64_t _imm, VfpMicroMode mode) 206 : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 207 _dest, _imm, mode) 208 { 209 %(constructor)s; 210 if (!(condCode == COND_AL || condCode == COND_UC)) { 211 for (int x = 0; x < _numDestRegs; x++) { 212 _srcRegIdx[_numSrcRegs++] = _destRegIdx[x]; 213 } 214 } 215 } 216}}; 217 218def template FpRegRegImmOpDeclare {{ 219class %(class_name)s : public %(base_class)s 220{ 221 public: 222 // Constructor 223 %(class_name)s(ExtMachInst machInst, 224 IntRegIndex _dest, IntRegIndex _op1, 225 uint64_t _imm, VfpMicroMode mode = VfpNotAMicroop); 226 %(BasicExecDeclare)s 227}; 228}}; 229 230def template FpRegRegImmOpConstructor {{ 231 %(class_name)s::%(class_name)s(ExtMachInst machInst, 232 IntRegIndex _dest, 233 IntRegIndex _op1, 234 uint64_t _imm, 235 VfpMicroMode mode) 236 : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 237 _dest, _op1, _imm, mode) 238 { 239 %(constructor)s; 240 if (!(condCode == COND_AL || condCode == COND_UC)) { 241 for (int x = 0; x < _numDestRegs; x++) { 242 _srcRegIdx[_numSrcRegs++] = _destRegIdx[x]; 243 } 244 } 245 } 246}}; 247 248def template FpRegRegRegOpDeclare {{ 249class %(class_name)s : public %(base_class)s 250{ 251 public: 252 // Constructor 253 %(class_name)s(ExtMachInst machInst, 254 IntRegIndex _dest, IntRegIndex _op1, IntRegIndex _op2, 255 VfpMicroMode mode = VfpNotAMicroop); 256 %(BasicExecDeclare)s 257}; 258}}; 259 260def template FpRegRegRegOpConstructor {{ 261 %(class_name)s::%(class_name)s(ExtMachInst machInst, 262 IntRegIndex _dest, 263 IntRegIndex _op1, 264 IntRegIndex _op2, 265 VfpMicroMode mode) 266 : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 267 _dest, _op1, _op2, mode) 268 { 269 %(constructor)s; 270 if (!(condCode == COND_AL || condCode == COND_UC)) { 271 for (int x = 0; x < _numDestRegs; x++) { 272 _srcRegIdx[_numSrcRegs++] = _destRegIdx[x]; 273 } 274 } 275 } 276}}; 277