18342Sksewell@umich.edu// -*- mode:c++ -*- 28342Sksewell@umich.edu 34040Ssaidi@eecs.umich.edu// Copyright (c) 2006-2007 The Regents of The University of Michigan 43388Sgblack@eecs.umich.edu// All rights reserved. 53388Sgblack@eecs.umich.edu// 63388Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without 73388Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are 83388Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright 93388Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer; 103388Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright 113388Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the 123388Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution; 133388Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its 143388Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 153388Sgblack@eecs.umich.edu// this software without specific prior written permission. 163388Sgblack@eecs.umich.edu// 173388Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 183388Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 193388Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 203388Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 213388Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 223388Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 233388Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 243388Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 253388Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 263388Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 273388Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 283388Sgblack@eecs.umich.edu// 293388Sgblack@eecs.umich.edu// Authors: Ali Saidi 303388Sgblack@eecs.umich.edu// Gabe Black 313388Sgblack@eecs.umich.edu 322022SN/A//////////////////////////////////////////////////////////////////// 332022SN/A// 342022SN/A// Mem instructions 352022SN/A// 362022SN/A 373385SN/Adef template MemDeclare {{ 383385SN/A /** 393385SN/A * Static instruction class for "%(mnemonic)s". 403385SN/A */ 413385SN/A class %(class_name)s : public %(base_class)s 423385SN/A { 433385SN/A public: 443385SN/A 453385SN/A /// Constructor. 463385SN/A %(class_name)s(ExtMachInst machInst); 473385SN/A 4812616Sgabeblack@google.com Fault execute(ExecContext *, Trace::InstRecord *) const override; 4912616Sgabeblack@google.com Fault initiateAcc(ExecContext *, 5012616Sgabeblack@google.com Trace::InstRecord *) const override; 5112236Sgabeblack@google.com Fault completeAcc(PacketPtr, ExecContext *, 5212616Sgabeblack@google.com Trace::InstRecord *) const override; 533385SN/A }; 543385SN/A}}; 553385SN/A 562526SN/Alet {{ 574040Ssaidi@eecs.umich.edu def doMemFormat(code, execute, faultCode, name, Name, asi, opt_flags, postacc_code = ''): 582516SN/A addrCalcReg = 'EA = Rs1 + Rs2;' 592591SN/A addrCalcImm = 'EA = Rs1 + imm;' 603792Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'Mem', 614040Ssaidi@eecs.umich.edu {"code": code, "postacc_code" : postacc_code, 624648Sgblack@eecs.umich.edu "fault_check": faultCode, "ea_code": addrCalcReg, 634648Sgblack@eecs.umich.edu "EA_trunc": TruncateEA}, opt_flags) 643792Sgblack@eecs.umich.edu iop_imm = InstObjParams(name, Name + "Imm", 'MemImm', 654040Ssaidi@eecs.umich.edu {"code": code, "postacc_code" : postacc_code, 664648Sgblack@eecs.umich.edu "fault_check": faultCode, "ea_code": addrCalcImm, 674648Sgblack@eecs.umich.edu "EA_trunc": TruncateEA}, opt_flags) 683385SN/A header_output = MemDeclare.subst(iop) + MemDeclare.subst(iop_imm) 692516SN/A decoder_output = BasicConstructor.subst(iop) + BasicConstructor.subst(iop_imm) 702516SN/A decode_block = ROrImmDecode.subst(iop) 714040Ssaidi@eecs.umich.edu exec_output = doDualSplitExecute(code, postacc_code, addrCalcReg, 724040Ssaidi@eecs.umich.edu addrCalcImm, execute, faultCode, name, name + "Imm", 733950Sgblack@eecs.umich.edu Name, Name + "Imm", asi, opt_flags) 742526SN/A return (header_output, decoder_output, exec_output, decode_block) 752022SN/A}}; 762526SN/A 775096Sgblack@eecs.umich.edudef format LoadAlt(code, *opt_flags) {{ 784362Sgblack@eecs.umich.edu code = filterDoubles(code) 793272SN/A (header_output, 803272SN/A decoder_output, 813272SN/A exec_output, 823792Sgblack@eecs.umich.edu decode_block) = doMemFormat(code, LoadFuncs, 835096Sgblack@eecs.umich.edu AlternateASIPrivFaultCheck, name, Name, "EXT_ASI", opt_flags) 843272SN/A}}; 853272SN/A 865096Sgblack@eecs.umich.edudef format StoreAlt(code, *opt_flags) {{ 874362Sgblack@eecs.umich.edu code = filterDoubles(code) 883272SN/A (header_output, 893272SN/A decoder_output, 903272SN/A exec_output, 913792Sgblack@eecs.umich.edu decode_block) = doMemFormat(code, StoreFuncs, 925096Sgblack@eecs.umich.edu AlternateASIPrivFaultCheck, name, Name, "EXT_ASI", opt_flags) 933272SN/A}}; 943272SN/A 953272SN/Adef format Load(code, *opt_flags) {{ 964362Sgblack@eecs.umich.edu code = filterDoubles(code) 972526SN/A (header_output, 982526SN/A decoder_output, 992526SN/A exec_output, 1002526SN/A decode_block) = doMemFormat(code, 1013949Sgblack@eecs.umich.edu LoadFuncs, '', name, Name, 0, opt_flags) 1022526SN/A}}; 1032526SN/A 1043272SN/Adef format Store(code, *opt_flags) {{ 1054362Sgblack@eecs.umich.edu code = filterDoubles(code) 1062526SN/A (header_output, 1072526SN/A decoder_output, 1082526SN/A exec_output, 1092526SN/A decode_block) = doMemFormat(code, 1103949Sgblack@eecs.umich.edu StoreFuncs, '', name, Name, 0, opt_flags) 1112526SN/A}}; 1124040Ssaidi@eecs.umich.edu 1135893Sgblack@eecs.umich.edudef format StoreFsr(code, *opt_flags) {{ 1145893Sgblack@eecs.umich.edu code = filterDoubles(code) 1155893Sgblack@eecs.umich.edu (header_output, 1165893Sgblack@eecs.umich.edu decoder_output, 1175893Sgblack@eecs.umich.edu exec_output, 1185893Sgblack@eecs.umich.edu decode_block) = doMemFormat(code, 1195893Sgblack@eecs.umich.edu StoreFuncs, '', name, Name, 0, opt_flags, 1205893Sgblack@eecs.umich.edu 'Fsr = insertBits(Fsr,16,14,0);') 1215893Sgblack@eecs.umich.edu}}; 1225893Sgblack@eecs.umich.edu 1235096Sgblack@eecs.umich.edudef format TwinLoad(code, *opt_flags) {{ 1244040Ssaidi@eecs.umich.edu (header_output, 1254040Ssaidi@eecs.umich.edu decoder_output, 1264040Ssaidi@eecs.umich.edu exec_output, 1274040Ssaidi@eecs.umich.edu decode_block) = doMemFormat(code, LoadFuncs, 1284040Ssaidi@eecs.umich.edu AlternateASIPrivFaultCheck + TwinAlignmentFaultCheck, 1295096Sgblack@eecs.umich.edu name, Name, "EXT_ASI", opt_flags) 1304040Ssaidi@eecs.umich.edu}}; 1314040Ssaidi@eecs.umich.edu 132