macromem.isa revision 7422
16019SN/A// -*- mode:c++ -*-
26019SN/A
37134Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited
47134Sgblack@eecs.umich.edu// All rights reserved
57134Sgblack@eecs.umich.edu//
67134Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall
77134Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual
87134Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating
97134Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software
107134Sgblack@eecs.umich.edu// licensed hereunder.  You may use the software subject to the license
117134Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated
127134Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software,
137134Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form.
147134Sgblack@eecs.umich.edu//
156019SN/A// Copyright (c) 2007-2008 The Florida State University
166019SN/A// All rights reserved.
176019SN/A//
186019SN/A// Redistribution and use in source and binary forms, with or without
196019SN/A// modification, are permitted provided that the following conditions are
206019SN/A// met: redistributions of source code must retain the above copyright
216019SN/A// notice, this list of conditions and the following disclaimer;
226019SN/A// redistributions in binary form must reproduce the above copyright
236019SN/A// notice, this list of conditions and the following disclaimer in the
246019SN/A// documentation and/or other materials provided with the distribution;
256019SN/A// neither the name of the copyright holders nor the names of its
266019SN/A// contributors may be used to endorse or promote products derived from
276019SN/A// this software without specific prior written permission.
286019SN/A//
296019SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
306019SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
316019SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
326019SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
336019SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
346019SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
356019SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
366019SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
376019SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
386019SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
396019SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
406019SN/A//
416019SN/A// Authors: Stephen Hines
426308SN/A//          Gabe Black
436308SN/A
446309SN/A////////////////////////////////////////////////////////////////////
456309SN/A//
466309SN/A// Load/store microops
476309SN/A//
486309SN/A
497134Sgblack@eecs.umich.edulet {{
507296Sgblack@eecs.umich.edu    microLdrUopCode = "IWRa = cSwap(Mem.uw, ((CPSR)Cpsr).e);"
516309SN/A    microLdrUopIop = InstObjParams('ldr_uop', 'MicroLdrUop',
526309SN/A                                   'MicroMemOp',
537296Sgblack@eecs.umich.edu                                   {'memacc_code': microLdrUopCode,
547134Sgblack@eecs.umich.edu                                    'ea_code': 'EA = Rb + (up ? imm : -imm);',
556309SN/A                                    'predicate_test': predicateTest},
566309SN/A                                   ['IsMicroop'])
576309SN/A
587342Sgblack@eecs.umich.edu    microLdrFpUopCode = "Fa.uw = cSwap(Mem.uw, ((CPSR)Cpsr).e);"
597174Sgblack@eecs.umich.edu    microLdrFpUopIop = InstObjParams('ldrfp_uop', 'MicroLdrFpUop',
607174Sgblack@eecs.umich.edu                                     'MicroMemOp',
617296Sgblack@eecs.umich.edu                                     {'memacc_code': microLdrFpUopCode,
627174Sgblack@eecs.umich.edu                                      'ea_code': 'EA = Rb + (up ? imm : -imm);',
637174Sgblack@eecs.umich.edu                                      'predicate_test': predicateTest},
647174Sgblack@eecs.umich.edu                                     ['IsMicroop'])
657174Sgblack@eecs.umich.edu
666754SN/A    microLdrRetUopCode = '''
677296Sgblack@eecs.umich.edu        CPSR cpsr = Cpsr;
687400SAli.Saidi@ARM.com        SCTLR sctlr = Sctlr;
697134Sgblack@eecs.umich.edu        uint32_t newCpsr =
707400SAli.Saidi@ARM.com            cpsrWriteByInstr(cpsr | CondCodes, Spsr, 0xF, true, sctlr.nmfi);
717134Sgblack@eecs.umich.edu        Cpsr = ~CondCodesMask & newCpsr;
727134Sgblack@eecs.umich.edu        CondCodes = CondCodesMask & newCpsr;
737296Sgblack@eecs.umich.edu        IWNPC = cSwap(Mem.uw, cpsr.e) | ((Spsr & 0x20) ? 1 : 0);
746754SN/A    '''
756754SN/A    microLdrRetUopIop = InstObjParams('ldr_ret_uop', 'MicroLdrRetUop',
766754SN/A                                      'MicroMemOp',
776754SN/A                                      {'memacc_code': microLdrRetUopCode,
786754SN/A                                       'ea_code':
797134Sgblack@eecs.umich.edu                                          'EA = Rb + (up ? imm : -imm);',
807422Sgblack@eecs.umich.edu                                       'predicate_test': condPredicateTest},
816754SN/A                                      ['IsMicroop'])
826754SN/A
837296Sgblack@eecs.umich.edu    microStrUopCode = "Mem = cSwap(Ra.uw, ((CPSR)Cpsr).e);"
846309SN/A    microStrUopIop = InstObjParams('str_uop', 'MicroStrUop',
856309SN/A                                   'MicroMemOp',
867296Sgblack@eecs.umich.edu                                   {'memacc_code': microStrUopCode,
877303Sgblack@eecs.umich.edu                                    'postacc_code': "",
887134Sgblack@eecs.umich.edu                                    'ea_code': 'EA = Rb + (up ? imm : -imm);',
896309SN/A                                    'predicate_test': predicateTest},
906309SN/A                                   ['IsMicroop'])
916309SN/A
927296Sgblack@eecs.umich.edu    microStrFpUopCode = "Mem = cSwap(Fa.uw, ((CPSR)Cpsr).e);"
937174Sgblack@eecs.umich.edu    microStrFpUopIop = InstObjParams('strfp_uop', 'MicroStrFpUop',
947174Sgblack@eecs.umich.edu                                     'MicroMemOp',
957296Sgblack@eecs.umich.edu                                     {'memacc_code': microStrFpUopCode,
967303Sgblack@eecs.umich.edu                                      'postacc_code': "",
977174Sgblack@eecs.umich.edu                                      'ea_code': 'EA = Rb + (up ? imm : -imm);',
987174Sgblack@eecs.umich.edu                                      'predicate_test': predicateTest},
997174Sgblack@eecs.umich.edu                                     ['IsMicroop'])
1007174Sgblack@eecs.umich.edu
1017174Sgblack@eecs.umich.edu    header_output = decoder_output = exec_output = ''
1027174Sgblack@eecs.umich.edu
1037174Sgblack@eecs.umich.edu    loadIops = (microLdrUopIop, microLdrFpUopIop, microLdrRetUopIop)
1047174Sgblack@eecs.umich.edu    storeIops = (microStrUopIop, microStrFpUopIop)
1057174Sgblack@eecs.umich.edu    for iop in loadIops + storeIops:
1067174Sgblack@eecs.umich.edu        header_output += MicroMemDeclare.subst(iop)
1077174Sgblack@eecs.umich.edu        decoder_output += MicroMemConstructor.subst(iop)
1087174Sgblack@eecs.umich.edu    for iop in loadIops:
1097174Sgblack@eecs.umich.edu        exec_output += LoadExecute.subst(iop) + \
1107174Sgblack@eecs.umich.edu                       LoadInitiateAcc.subst(iop) + \
1117174Sgblack@eecs.umich.edu                       LoadCompleteAcc.subst(iop)
1127174Sgblack@eecs.umich.edu    for iop in storeIops:
1137174Sgblack@eecs.umich.edu        exec_output += StoreExecute.subst(iop) + \
1147174Sgblack@eecs.umich.edu                       StoreInitiateAcc.subst(iop) + \
1157174Sgblack@eecs.umich.edu                       StoreCompleteAcc.subst(iop)
1166309SN/A}};
1176308SN/A
1186308SN/A////////////////////////////////////////////////////////////////////
1196308SN/A//
1206308SN/A// Integer = Integer op Immediate microops
1216308SN/A//
1226308SN/A
1236308SN/Alet {{
1246308SN/A    microAddiUopIop = InstObjParams('addi_uop', 'MicroAddiUop',
1256308SN/A                                    'MicroIntOp',
1266308SN/A                                    {'code': 'Ra = Rb + imm;',
1276308SN/A                                     'predicate_test': predicateTest},
1286308SN/A                                    ['IsMicroop'])
1296308SN/A
1306308SN/A    microSubiUopIop = InstObjParams('subi_uop', 'MicroSubiUop',
1316308SN/A                                    'MicroIntOp',
1326308SN/A                                    {'code': 'Ra = Rb - imm;',
1336308SN/A                                     'predicate_test': predicateTest},
1346308SN/A                                    ['IsMicroop'])
1356308SN/A
1366308SN/A    header_output = MicroIntDeclare.subst(microAddiUopIop) + \
1376308SN/A                    MicroIntDeclare.subst(microSubiUopIop)
1387134Sgblack@eecs.umich.edu    decoder_output = MicroIntConstructor.subst(microAddiUopIop) + \
1397134Sgblack@eecs.umich.edu                     MicroIntConstructor.subst(microSubiUopIop)
1406308SN/A    exec_output = PredOpExecute.subst(microAddiUopIop) + \
1416308SN/A                  PredOpExecute.subst(microSubiUopIop)
1426308SN/A}};
1436019SN/A
1447134Sgblack@eecs.umich.edulet {{
1457170Sgblack@eecs.umich.edu    iop = InstObjParams("ldmstm", "LdmStm", 'MacroMemOp', "", [])
1467134Sgblack@eecs.umich.edu    header_output = MacroMemDeclare.subst(iop)
1477134Sgblack@eecs.umich.edu    decoder_output = MacroMemConstructor.subst(iop)
1487179Sgblack@eecs.umich.edu
1497179Sgblack@eecs.umich.edu    vfpIop = InstObjParams("vldmstm", "VLdmStm", 'MacroVFPMemOp', "", [])
1507179Sgblack@eecs.umich.edu    header_output += MacroVFPMemDeclare.subst(vfpIop)
1517179Sgblack@eecs.umich.edu    decoder_output += MacroVFPMemConstructor.subst(vfpIop)
1526019SN/A}};
153