fp.isa revision 6724
11689SN/A// -*- mode:c++ -*- 29444SAndreas.Sandberg@ARM.com 39444SAndreas.Sandberg@ARM.com// Copyright (c) 2007-2008 The Florida State University 49444SAndreas.Sandberg@ARM.com// All rights reserved. 59444SAndreas.Sandberg@ARM.com// 69444SAndreas.Sandberg@ARM.com// Redistribution and use in source and binary forms, with or without 79444SAndreas.Sandberg@ARM.com// modification, are permitted provided that the following conditions are 89444SAndreas.Sandberg@ARM.com// met: redistributions of source code must retain the above copyright 99444SAndreas.Sandberg@ARM.com// notice, this list of conditions and the following disclaimer; 109444SAndreas.Sandberg@ARM.com// redistributions in binary form must reproduce the above copyright 119444SAndreas.Sandberg@ARM.com// notice, this list of conditions and the following disclaimer in the 129444SAndreas.Sandberg@ARM.com// documentation and/or other materials provided with the distribution; 139444SAndreas.Sandberg@ARM.com// neither the name of the copyright holders nor the names of its 142329SN/A// contributors may be used to endorse or promote products derived from 151689SN/A// this software without specific prior written permission. 161689SN/A// 171689SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 181689SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 191689SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 201689SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 211689SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 221689SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 231689SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 241689SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 251689SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 261689SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 271689SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 281689SN/A// 291689SN/A// Authors: Stephen Hines 301689SN/A 311689SN/A//////////////////////////////////////////////////////////////////// 321689SN/A// 331689SN/A// Floating Point operate instructions 341689SN/A// 351689SN/A 361689SN/Adef template FPAExecute {{ 371689SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 381689SN/A { 392665Ssaidi@eecs.umich.edu Fault fault = NoFault; 402665Ssaidi@eecs.umich.edu 412831Sksewell@umich.edu %(fp_enable_check)s; 421689SN/A 431689SN/A %(op_decl)s; 446221Snate@binkert.org %(op_rd)s; 456221Snate@binkert.org 461717SN/A if (%(predicate_test)s) { 478232Snate@binkert.org %(code)s; 488232Snate@binkert.org if (fault == NoFault) { 491060SN/A %(op_wb)s; 506221Snate@binkert.org } 512292SN/A } 521061SN/A 534329Sktlim@umich.edu return fault; 542980Sgblack@eecs.umich.edu } 556221Snate@binkert.org}}; 564329Sktlim@umich.edu 574329Sktlim@umich.edudef template FloatDoubleDecode {{ 581060SN/A { 591060SN/A ArmStaticInst *i = NULL; 602292SN/A switch (OPCODE_19 << 1 | OPCODE_7) 611060SN/A { 622980Sgblack@eecs.umich.edu case 0: 632292SN/A i = (ArmStaticInst *)new %(class_name)sS(machInst); 642292SN/A break; 652292SN/A case 1: 662292SN/A i = (ArmStaticInst *)new %(class_name)sD(machInst); 672292SN/A break; 682292SN/A case 2: 692292SN/A case 3: 702292SN/A default: 712292SN/A panic("Cannot decode float/double nature of the instruction"); 722292SN/A } 736221Snate@binkert.org return i; 746221Snate@binkert.org } 752292SN/A}}; 762292SN/A 772292SN/A// Primary format for float point operate instructions: 782292SN/Adef format FloatOp(code, *flags) {{ 794329Sktlim@umich.edu orig_code = code 802292SN/A 812292SN/A cblk = code 822292SN/A iop = InstObjParams(name, Name, 'PredOp', 832292SN/A {"code": cblk, 842292SN/A "predicate_test": predicateTest}, 856221Snate@binkert.org flags) 866221Snate@binkert.org header_output = BasicDeclare.subst(iop) 872292SN/A decoder_output = BasicConstructor.subst(iop) 882292SN/A exec_output = FPAExecute.subst(iop) 892292SN/A 902292SN/A sng_cblk = code 914329Sktlim@umich.edu sng_iop = InstObjParams(name, Name+'S', 'PredOp', 922292SN/A {"code": sng_cblk, 932292SN/A "predicate_test": predicateTest}, 942292SN/A flags) 952292SN/A header_output += BasicDeclare.subst(sng_iop) 966221Snate@binkert.org decoder_output += BasicConstructor.subst(sng_iop) 976221Snate@binkert.org exec_output += FPAExecute.subst(sng_iop) 982292SN/A 992292SN/A dbl_code = re.sub(r'\.sf', '.df', orig_code) 1002292SN/A 1012292SN/A dbl_cblk = dbl_code 1022292SN/A dbl_iop = InstObjParams(name, Name+'D', 'PredOp', 1031060SN/A {"code": dbl_cblk, 1049444SAndreas.Sandberg@ARM.com "predicate_test": predicateTest}, 1059444SAndreas.Sandberg@ARM.com flags) 1069444SAndreas.Sandberg@ARM.com header_output += BasicDeclare.subst(dbl_iop) 1079444SAndreas.Sandberg@ARM.com decoder_output += BasicConstructor.subst(dbl_iop) 1089444SAndreas.Sandberg@ARM.com exec_output += FPAExecute.subst(dbl_iop) 1099444SAndreas.Sandberg@ARM.com 1109444SAndreas.Sandberg@ARM.com decode_block = FloatDoubleDecode.subst(iop) 1119444SAndreas.Sandberg@ARM.com}}; 1129444SAndreas.Sandberg@ARM.com 1139444SAndreas.Sandberg@ARM.comlet {{ 1146221Snate@binkert.org calcFPCcCode = ''' 1159444SAndreas.Sandberg@ARM.com uint16_t _in, _iz, _ic, _iv; 1162292SN/A 1179444SAndreas.Sandberg@ARM.com _in = %(fReg1)s < %(fReg2)s; 1181060SN/A _iz = %(fReg1)s == %(fReg2)s; 1192292SN/A _ic = %(fReg1)s >= %(fReg2)s; 1202292SN/A _iv = (isnan(%(fReg1)s) || isnan(%(fReg2)s)) & 1; 1212292SN/A 1222292SN/A CondCodes = _in << 31 | _iz << 30 | _ic << 29 | _iv << 28 | 1232292SN/A (CondCodes & 0x0FFFFFFF); 1242292SN/A ''' 1252292SN/A}}; 1264329Sktlim@umich.edu 1274329Sktlim@umich.edudef format FloatCmp(fReg1, fReg2, *flags) {{ 1284329Sktlim@umich.edu code = calcFPCcCode % vars() 1294329Sktlim@umich.edu iop = InstObjParams(name, Name, 'PredOp', 1304329Sktlim@umich.edu {"code": code, 1314329Sktlim@umich.edu "predicate_test": predicateTest}, 1324329Sktlim@umich.edu flags) 1332292SN/A header_output = BasicDeclare.subst(iop) 1346221Snate@binkert.org decoder_output = BasicConstructor.subst(iop) 1352292SN/A decode_block = BasicDecode.subst(iop) 1362292SN/A exec_output = FPAExecute.subst(iop) 1372292SN/A}}; 1382292SN/A 1392292SN/A 1402307SN/A