fp.isa revision 6724:70129fdded75
15222Sksewell@umich.edu// -*- mode:c++ -*- 25254Sksewell@umich.edu 35254Sksewell@umich.edu// Copyright (c) 2007-2008 The Florida State University 45222Sksewell@umich.edu// All rights reserved. 55254Sksewell@umich.edu// 65254Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without 75254Sksewell@umich.edu// modification, are permitted provided that the following conditions are 85254Sksewell@umich.edu// met: redistributions of source code must retain the above copyright 95254Sksewell@umich.edu// notice, this list of conditions and the following disclaimer; 105254Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright 115254Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the 125254Sksewell@umich.edu// documentation and/or other materials provided with the distribution; 135254Sksewell@umich.edu// neither the name of the copyright holders nor the names of its 145254Sksewell@umich.edu// contributors may be used to endorse or promote products derived from 155222Sksewell@umich.edu// this software without specific prior written permission. 165254Sksewell@umich.edu// 175254Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185254Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195254Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205254Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215254Sksewell@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225254Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235254Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245254Sksewell@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255254Sksewell@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265254Sksewell@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275222Sksewell@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285254Sksewell@umich.edu// 295222Sksewell@umich.edu// Authors: Stephen Hines 305222Sksewell@umich.edu 315222Sksewell@umich.edu//////////////////////////////////////////////////////////////////// 325222Sksewell@umich.edu// 335222Sksewell@umich.edu// Floating Point operate instructions 345222Sksewell@umich.edu// 355222Sksewell@umich.edu 365222Sksewell@umich.edudef template FPAExecute {{ 375222Sksewell@umich.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 385222Sksewell@umich.edu { 395222Sksewell@umich.edu Fault fault = NoFault; 405222Sksewell@umich.edu 415222Sksewell@umich.edu %(fp_enable_check)s; 425222Sksewell@umich.edu 435222Sksewell@umich.edu %(op_decl)s; 445222Sksewell@umich.edu %(op_rd)s; 455222Sksewell@umich.edu 465222Sksewell@umich.edu if (%(predicate_test)s) { 475222Sksewell@umich.edu %(code)s; 485222Sksewell@umich.edu if (fault == NoFault) { 495222Sksewell@umich.edu %(op_wb)s; 505222Sksewell@umich.edu } 515222Sksewell@umich.edu } 525222Sksewell@umich.edu 535222Sksewell@umich.edu return fault; 545222Sksewell@umich.edu } 555222Sksewell@umich.edu}}; 565222Sksewell@umich.edu 575222Sksewell@umich.edudef template FloatDoubleDecode {{ 585222Sksewell@umich.edu { 595222Sksewell@umich.edu ArmStaticInst *i = NULL; 605222Sksewell@umich.edu switch (OPCODE_19 << 1 | OPCODE_7) 615222Sksewell@umich.edu { 625222Sksewell@umich.edu case 0: 635222Sksewell@umich.edu i = (ArmStaticInst *)new %(class_name)sS(machInst); 645222Sksewell@umich.edu break; 655222Sksewell@umich.edu case 1: 665222Sksewell@umich.edu i = (ArmStaticInst *)new %(class_name)sD(machInst); 675222Sksewell@umich.edu break; 685222Sksewell@umich.edu case 2: 695222Sksewell@umich.edu case 3: 705222Sksewell@umich.edu default: 715222Sksewell@umich.edu panic("Cannot decode float/double nature of the instruction"); 725222Sksewell@umich.edu } 735222Sksewell@umich.edu return i; 745222Sksewell@umich.edu } 755222Sksewell@umich.edu}}; 765222Sksewell@umich.edu 775222Sksewell@umich.edu// Primary format for float point operate instructions: 785222Sksewell@umich.edudef format FloatOp(code, *flags) {{ 795222Sksewell@umich.edu orig_code = code 805222Sksewell@umich.edu 815222Sksewell@umich.edu cblk = code 825222Sksewell@umich.edu iop = InstObjParams(name, Name, 'PredOp', 835222Sksewell@umich.edu {"code": cblk, 845222Sksewell@umich.edu "predicate_test": predicateTest}, 855222Sksewell@umich.edu flags) 865222Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 875222Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 885222Sksewell@umich.edu exec_output = FPAExecute.subst(iop) 895222Sksewell@umich.edu 905222Sksewell@umich.edu sng_cblk = code 915222Sksewell@umich.edu sng_iop = InstObjParams(name, Name+'S', 'PredOp', 925222Sksewell@umich.edu {"code": sng_cblk, 935222Sksewell@umich.edu "predicate_test": predicateTest}, 945222Sksewell@umich.edu flags) 955222Sksewell@umich.edu header_output += BasicDeclare.subst(sng_iop) 965222Sksewell@umich.edu decoder_output += BasicConstructor.subst(sng_iop) 975222Sksewell@umich.edu exec_output += FPAExecute.subst(sng_iop) 985222Sksewell@umich.edu 995222Sksewell@umich.edu dbl_code = re.sub(r'\.sf', '.df', orig_code) 1005222Sksewell@umich.edu 1015222Sksewell@umich.edu dbl_cblk = dbl_code 1025222Sksewell@umich.edu dbl_iop = InstObjParams(name, Name+'D', 'PredOp', 1035222Sksewell@umich.edu {"code": dbl_cblk, 1045222Sksewell@umich.edu "predicate_test": predicateTest}, 1055222Sksewell@umich.edu flags) 1065222Sksewell@umich.edu header_output += BasicDeclare.subst(dbl_iop) 1075222Sksewell@umich.edu decoder_output += BasicConstructor.subst(dbl_iop) 1085222Sksewell@umich.edu exec_output += FPAExecute.subst(dbl_iop) 1095222Sksewell@umich.edu 1105222Sksewell@umich.edu decode_block = FloatDoubleDecode.subst(iop) 1115222Sksewell@umich.edu}}; 1125222Sksewell@umich.edu 1135222Sksewell@umich.edulet {{ 1145222Sksewell@umich.edu calcFPCcCode = ''' 1155222Sksewell@umich.edu uint16_t _in, _iz, _ic, _iv; 1165222Sksewell@umich.edu 1175222Sksewell@umich.edu _in = %(fReg1)s < %(fReg2)s; 1185222Sksewell@umich.edu _iz = %(fReg1)s == %(fReg2)s; 1195222Sksewell@umich.edu _ic = %(fReg1)s >= %(fReg2)s; 1205222Sksewell@umich.edu _iv = (isnan(%(fReg1)s) || isnan(%(fReg2)s)) & 1; 1215222Sksewell@umich.edu 1225222Sksewell@umich.edu CondCodes = _in << 31 | _iz << 30 | _ic << 29 | _iv << 28 | 1235222Sksewell@umich.edu (CondCodes & 0x0FFFFFFF); 1245222Sksewell@umich.edu ''' 1255222Sksewell@umich.edu}}; 1265222Sksewell@umich.edu 1275222Sksewell@umich.edudef format FloatCmp(fReg1, fReg2, *flags) {{ 1285222Sksewell@umich.edu code = calcFPCcCode % vars() 1295222Sksewell@umich.edu iop = InstObjParams(name, Name, 'PredOp', 1305222Sksewell@umich.edu {"code": code, 1315222Sksewell@umich.edu "predicate_test": predicateTest}, 1325222Sksewell@umich.edu flags) 1335222Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 1345222Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 1355222Sksewell@umich.edu decode_block = BasicDecode.subst(iop) 1365222Sksewell@umich.edu exec_output = FPAExecute.subst(iop) 1375222Sksewell@umich.edu}}; 1385222Sksewell@umich.edu 1395222Sksewell@umich.edu 1405222Sksewell@umich.edu