operands.isa revision 8205
17259Sgblack@eecs.umich.edu// -*- mode:c++ -*- 212669Schuan.zhu@arm.com// Copyright (c) 2010 ARM Limited 37259Sgblack@eecs.umich.edu// All rights reserved 47259Sgblack@eecs.umich.edu// 57259Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall 67259Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual 77259Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating 87259Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software 97259Sgblack@eecs.umich.edu// licensed hereunder. You may use the software subject to the license 107259Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated 117259Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software, 127259Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form. 137259Sgblack@eecs.umich.edu// 147259Sgblack@eecs.umich.edu// Copyright (c) 2007-2008 The Florida State University 157259Sgblack@eecs.umich.edu// All rights reserved. 167259Sgblack@eecs.umich.edu// 177259Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without 187259Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are 197259Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright 207259Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer; 217259Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright 227259Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the 237259Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution; 247259Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its 257259Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 267259Sgblack@eecs.umich.edu// this software without specific prior written permission. 277259Sgblack@eecs.umich.edu// 287259Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 297259Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 307259Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 317259Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 327259Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 337259Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 347259Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 357259Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 367259Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 377259Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 387405SAli.Saidi@ARM.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3910037SARM gem5 Developers// 407259Sgblack@eecs.umich.edu// Authors: Stephen Hines 417259Sgblack@eecs.umich.edu 4211793Sbrandon.potter@amd.comdef operand_types {{ 4311793Sbrandon.potter@amd.com 'sb' : ('signed int', 8), 4411939Snikos.nikoleris@arm.com 'ub' : ('unsigned int', 8), 4511939Snikos.nikoleris@arm.com 'sh' : ('signed int', 16), 467405SAli.Saidi@ARM.com 'uh' : ('unsigned int', 16), 4712334Sgabeblack@google.com 'sw' : ('signed int', 32), 4810037SARM gem5 Developers 'uw' : ('unsigned int', 32), 4910828SGiacomo.Gabrielli@arm.com 'ud' : ('unsigned int', 64), 507259Sgblack@eecs.umich.edu 'tud' : ('twin64 int', 64), 517259Sgblack@eecs.umich.edu 'sf' : ('float', 32), 527259Sgblack@eecs.umich.edu 'df' : ('float', 64) 537259Sgblack@eecs.umich.edu}}; 547259Sgblack@eecs.umich.edu 558868SMatt.Horsnell@arm.comlet {{ 568868SMatt.Horsnell@arm.com maybePCRead = ''' 578868SMatt.Horsnell@arm.com ((%(reg_idx)s == PCReg) ? readPC(xc) : xc->%(func)s(this, %(op_idx)s)) 588868SMatt.Horsnell@arm.com ''' 5910037SARM gem5 Developers maybeAlignedPCRead = ''' 608868SMatt.Horsnell@arm.com ((%(reg_idx)s == PCReg) ? (roundDown(readPC(xc), 4)) : 6110037SARM gem5 Developers xc->%(func)s(this, %(op_idx)s)) 628868SMatt.Horsnell@arm.com ''' 6310037SARM gem5 Developers maybePCWrite = ''' 6410037SARM gem5 Developers ((%(reg_idx)s == PCReg) ? setNextPC(xc, %(final_val)s) : 6510037SARM gem5 Developers xc->%(func)s(this, %(op_idx)s, %(final_val)s)) 6610037SARM gem5 Developers ''' 6710037SARM gem5 Developers maybeIWPCWrite = ''' 6810037SARM gem5 Developers ((%(reg_idx)s == PCReg) ? setIWNextPC(xc, %(final_val)s) : 6910037SARM gem5 Developers xc->%(func)s(this, %(op_idx)s, %(final_val)s)) 708868SMatt.Horsnell@arm.com ''' 7110037SARM gem5 Developers maybeAIWPCWrite = ''' 7210037SARM gem5 Developers if (%(reg_idx)s == PCReg) { 7310037SARM gem5 Developers bool thumb = THUMB; 7410037SARM gem5 Developers if (thumb) { 7510037SARM gem5 Developers setNextPC(xc, %(final_val)s); 7610037SARM gem5 Developers } else { 7710037SARM gem5 Developers setIWNextPC(xc, %(final_val)s); 7810037SARM gem5 Developers } 7910037SARM gem5 Developers } else { 8010037SARM gem5 Developers xc->%(func)s(this, %(op_idx)s, %(final_val)s); 8110037SARM gem5 Developers } 829959Schander.sudanthi@arm.com ''' 8310037SARM gem5 Developers 849959Schander.sudanthi@arm.com #PCState operands need to have a sorting index (the number at the end) 859959Schander.sudanthi@arm.com #less than all the integer registers which might update the PC. That way 869959Schander.sudanthi@arm.com #if the flag bits of the pc state are updated and a branch happens through 879959Schander.sudanthi@arm.com #R15, the updates are layered properly and the R15 update isn't lost. 889959Schander.sudanthi@arm.com srtNormal = 5 899959Schander.sudanthi@arm.com srtCpsr = 4 909959Schander.sudanthi@arm.com srtBase = 3 919959Schander.sudanthi@arm.com srtPC = 2 929959Schander.sudanthi@arm.com srtMode = 1 9310037SARM gem5 Developers srtEPC = 0 949959Schander.sudanthi@arm.com 9510037SARM gem5 Developers def floatReg(idx): 9610037SARM gem5 Developers return ('FloatReg', 'sf', idx, 'IsFloating', srtNormal) 9710037SARM gem5 Developers 9810037SARM gem5 Developers def intReg(idx): 9910037SARM gem5 Developers return ('IntReg', 'uw', idx, 'IsInteger', srtNormal, 10010037SARM gem5 Developers maybePCRead, maybePCWrite) 10110037SARM gem5 Developers 10210037SARM gem5 Developers def intRegNPC(idx): 10310037SARM gem5 Developers return ('IntReg', 'uw', idx, 'IsInteger', srtNormal) 10410037SARM gem5 Developers 10510037SARM gem5 Developers def intRegAPC(idx, id = srtNormal): 1068868SMatt.Horsnell@arm.com return ('IntReg', 'uw', idx, 'IsInteger', id, 10710037SARM gem5 Developers maybeAlignedPCRead, maybePCWrite) 10810037SARM gem5 Developers 10910037SARM gem5 Developers def intRegIWPC(idx): 11010037SARM gem5 Developers return ('IntReg', 'uw', idx, 'IsInteger', srtNormal, 11110037SARM gem5 Developers maybePCRead, maybeIWPCWrite) 11210037SARM gem5 Developers 11310037SARM gem5 Developers def intRegAIWPC(idx): 11410037SARM gem5 Developers return ('IntReg', 'uw', idx, 'IsInteger', srtNormal, 11510037SARM gem5 Developers maybePCRead, maybeAIWPCWrite) 11610037SARM gem5 Developers 11710037SARM gem5 Developers def intRegCC(idx): 11810037SARM gem5 Developers return ('IntReg', 'uw', idx, None, srtNormal) 11910037SARM gem5 Developers 12010037SARM gem5 Developers def cntrlReg(idx, id = srtNormal, type = 'uw'): 12110037SARM gem5 Developers return ('ControlReg', type, idx, (None, None, 'IsControl'), id) 1228868SMatt.Horsnell@arm.com 12310037SARM gem5 Developers def cntrlRegNC(idx, id = srtNormal, type = 'uw'): 12410037SARM gem5 Developers return ('ControlReg', type, idx, None, id) 12510037SARM gem5 Developers 12610037SARM gem5 Developers def pcStateReg(idx, id): 12710037SARM gem5 Developers return ('PCState', 'uw', idx, (None, None, 'IsControl'), id) 1288868SMatt.Horsnell@arm.com}}; 12910037SARM gem5 Developers 13010037SARM gem5 Developersdef operands {{ 1318868SMatt.Horsnell@arm.com #Abstracted integer reg operands 1327259Sgblack@eecs.umich.edu 'Dest': intReg('dest'), 1337259Sgblack@eecs.umich.edu 'IWDest': intRegIWPC('dest'), 1347259Sgblack@eecs.umich.edu 'AIWDest': intRegAIWPC('dest'), 1357259Sgblack@eecs.umich.edu 'Dest2': intReg('dest2'), 1367259Sgblack@eecs.umich.edu 'Result': intReg('result'), 1377259Sgblack@eecs.umich.edu 'Base': intRegAPC('base', id = srtBase), 1387259Sgblack@eecs.umich.edu 'Index': intReg('index'), 1397259Sgblack@eecs.umich.edu 'Shift': intReg('shift'), 1407259Sgblack@eecs.umich.edu 'Op1': intReg('op1'), 1417259Sgblack@eecs.umich.edu 'Op2': intReg('op2'), 1427259Sgblack@eecs.umich.edu 'Op3': intReg('op3'), 1437259Sgblack@eecs.umich.edu 'Reg0': intReg('reg0'), 1447259Sgblack@eecs.umich.edu 'Reg1': intReg('reg1'), 1457351Sgblack@eecs.umich.edu 'Reg2': intReg('reg2'), 1467351Sgblack@eecs.umich.edu 'Reg3': intReg('reg3'), 1477259Sgblack@eecs.umich.edu 1487259Sgblack@eecs.umich.edu #Fixed index integer reg operands 14910037SARM gem5 Developers 'SpMode': intRegNPC('intRegInMode((OperatingMode)regMode, INTREG_SP)'), 15010037SARM gem5 Developers 'LR': intRegNPC('INTREG_LR'), 1517259Sgblack@eecs.umich.edu 'R7': intRegNPC('7'), 1527259Sgblack@eecs.umich.edu # First four arguments are passed in registers 1537259Sgblack@eecs.umich.edu 'R0': intRegNPC('0'), 1547259Sgblack@eecs.umich.edu 'R1': intRegNPC('1'), 1557259Sgblack@eecs.umich.edu 'R2': intRegNPC('2'), 1567259Sgblack@eecs.umich.edu 'R3': intRegNPC('3'), 1577259Sgblack@eecs.umich.edu 1587259Sgblack@eecs.umich.edu #Pseudo integer condition code registers 1597259Sgblack@eecs.umich.edu 'CondCodes': intRegCC('INTREG_CONDCODES'), 1607259Sgblack@eecs.umich.edu 'OptCondCodes': intRegCC( 1617259Sgblack@eecs.umich.edu '''(condCode == COND_AL || condCode == COND_UC) ? 1627259Sgblack@eecs.umich.edu INTREG_ZERO : INTREG_CONDCODES'''), 1637259Sgblack@eecs.umich.edu 'FpCondCodes': intRegCC('INTREG_FPCONDCODES'), 1647259Sgblack@eecs.umich.edu 1657259Sgblack@eecs.umich.edu #Abstracted floating point reg operands 1667259Sgblack@eecs.umich.edu 'FpDest': floatReg('(dest + 0)'), 1677259Sgblack@eecs.umich.edu 'FpDestP0': floatReg('(dest + 0)'), 1687259Sgblack@eecs.umich.edu 'FpDestP1': floatReg('(dest + 1)'), 1697259Sgblack@eecs.umich.edu 'FpDestP2': floatReg('(dest + 2)'), 1707259Sgblack@eecs.umich.edu 'FpDestP3': floatReg('(dest + 3)'), 1717259Sgblack@eecs.umich.edu 'FpDestP4': floatReg('(dest + 4)'), 1727259Sgblack@eecs.umich.edu 'FpDestP5': floatReg('(dest + 5)'), 1737259Sgblack@eecs.umich.edu 'FpDestP6': floatReg('(dest + 6)'), 1747259Sgblack@eecs.umich.edu 'FpDestP7': floatReg('(dest + 7)'), 1757259Sgblack@eecs.umich.edu 'FpDestS0P0': floatReg('(dest + step * 0 + 0)'), 1767259Sgblack@eecs.umich.edu 'FpDestS0P1': floatReg('(dest + step * 0 + 1)'), 1777259Sgblack@eecs.umich.edu 'FpDestS1P0': floatReg('(dest + step * 1 + 0)'), 1787259Sgblack@eecs.umich.edu 'FpDestS1P1': floatReg('(dest + step * 1 + 1)'), 1797259Sgblack@eecs.umich.edu 'FpDestS2P0': floatReg('(dest + step * 2 + 0)'), 1807259Sgblack@eecs.umich.edu 'FpDestS2P1': floatReg('(dest + step * 2 + 1)'), 1817259Sgblack@eecs.umich.edu 'FpDestS3P0': floatReg('(dest + step * 3 + 0)'), 1827259Sgblack@eecs.umich.edu 'FpDestS3P1': floatReg('(dest + step * 3 + 1)'), 1837259Sgblack@eecs.umich.edu 1847259Sgblack@eecs.umich.edu 'FpDest2': floatReg('(dest2 + 0)'), 1857259Sgblack@eecs.umich.edu 'FpDest2P0': floatReg('(dest2 + 0)'), 1867259Sgblack@eecs.umich.edu 'FpDest2P1': floatReg('(dest2 + 1)'), 1877259Sgblack@eecs.umich.edu 'FpDest2P2': floatReg('(dest2 + 2)'), 1887259Sgblack@eecs.umich.edu 'FpDest2P3': floatReg('(dest2 + 3)'), 1897259Sgblack@eecs.umich.edu 1907259Sgblack@eecs.umich.edu 'FpOp1': floatReg('(op1 + 0)'), 1917259Sgblack@eecs.umich.edu 'FpOp1P0': floatReg('(op1 + 0)'), 1927259Sgblack@eecs.umich.edu 'FpOp1P1': floatReg('(op1 + 1)'), 1937259Sgblack@eecs.umich.edu 'FpOp1P2': floatReg('(op1 + 2)'), 1947259Sgblack@eecs.umich.edu 'FpOp1P3': floatReg('(op1 + 3)'), 1957259Sgblack@eecs.umich.edu 'FpOp1P4': floatReg('(op1 + 4)'), 1967259Sgblack@eecs.umich.edu 'FpOp1P5': floatReg('(op1 + 5)'), 1977259Sgblack@eecs.umich.edu 'FpOp1P6': floatReg('(op1 + 6)'), 1987259Sgblack@eecs.umich.edu 'FpOp1P7': floatReg('(op1 + 7)'), 1997259Sgblack@eecs.umich.edu 'FpOp1S0P0': floatReg('(op1 + step * 0 + 0)'), 2007259Sgblack@eecs.umich.edu 'FpOp1S0P1': floatReg('(op1 + step * 0 + 1)'), 2017259Sgblack@eecs.umich.edu 'FpOp1S1P0': floatReg('(op1 + step * 1 + 0)'), 2027259Sgblack@eecs.umich.edu 'FpOp1S1P1': floatReg('(op1 + step * 1 + 1)'), 2037259Sgblack@eecs.umich.edu 'FpOp1S2P0': floatReg('(op1 + step * 2 + 0)'), 2047259Sgblack@eecs.umich.edu 'FpOp1S2P1': floatReg('(op1 + step * 2 + 1)'), 2057259Sgblack@eecs.umich.edu 'FpOp1S3P0': floatReg('(op1 + step * 3 + 0)'), 2067259Sgblack@eecs.umich.edu 'FpOp1S3P1': floatReg('(op1 + step * 3 + 1)'), 2077259Sgblack@eecs.umich.edu 2087259Sgblack@eecs.umich.edu 'FpOp2': floatReg('(op2 + 0)'), 2097259Sgblack@eecs.umich.edu 'FpOp2P0': floatReg('(op2 + 0)'), 2107259Sgblack@eecs.umich.edu 'FpOp2P1': floatReg('(op2 + 1)'), 2117259Sgblack@eecs.umich.edu 'FpOp2P2': floatReg('(op2 + 2)'), 2127259Sgblack@eecs.umich.edu 'FpOp2P3': floatReg('(op2 + 3)'), 2137259Sgblack@eecs.umich.edu 2147259Sgblack@eecs.umich.edu #Abstracted control reg operands 21510037SARM gem5 Developers 'MiscDest': cntrlReg('dest'), 21610037SARM gem5 Developers 'MiscOp1': cntrlReg('op1'), 21710037SARM gem5 Developers 21810037SARM gem5 Developers #Fixed index control regs 21910037SARM gem5 Developers 'Cpsr': cntrlReg('MISCREG_CPSR', srtCpsr), 22010037SARM gem5 Developers 'Spsr': cntrlRegNC('MISCREG_SPSR'), 22110037SARM gem5 Developers 'Fpsr': cntrlRegNC('MISCREG_FPSR'), 22210037SARM gem5 Developers 'Fpsid': cntrlRegNC('MISCREG_FPSID'), 2237259Sgblack@eecs.umich.edu 'Fpscr': cntrlRegNC('MISCREG_FPSCR'), 2247259Sgblack@eecs.umich.edu 'FpscrQc': cntrlRegNC('MISCREG_FPSCR_QC'), 2257259Sgblack@eecs.umich.edu 'FpscrExc': cntrlRegNC('MISCREG_FPSCR_EXC'), 2267351Sgblack@eecs.umich.edu 'Cpacr': cntrlReg('MISCREG_CPACR'), 2277351Sgblack@eecs.umich.edu 'Fpexc': cntrlRegNC('MISCREG_FPEXC'), 2287351Sgblack@eecs.umich.edu 'Sctlr': cntrlRegNC('MISCREG_SCTLR'), 2297351Sgblack@eecs.umich.edu 'SevMailbox': cntrlRegNC('MISCREG_SEV_MAILBOX'), 2307351Sgblack@eecs.umich.edu 2317351Sgblack@eecs.umich.edu #Register fields for microops 2327351Sgblack@eecs.umich.edu 'URa' : intReg('ura'), 2337351Sgblack@eecs.umich.edu 'IWRa' : intRegIWPC('ura'), 2347351Sgblack@eecs.umich.edu 'Fa' : floatReg('ura'), 2357351Sgblack@eecs.umich.edu 'URb' : intReg('urb'), 2367351Sgblack@eecs.umich.edu 'URc' : intReg('urc'), 2377351Sgblack@eecs.umich.edu 2387351Sgblack@eecs.umich.edu #Memory Operand 2397351Sgblack@eecs.umich.edu 'Mem': ('Mem', 'uw', None, ('IsMemRef', 'IsLoad', 'IsStore'), srtNormal), 2407351Sgblack@eecs.umich.edu 2417351Sgblack@eecs.umich.edu #PCState fields 2427351Sgblack@eecs.umich.edu 'PC': pcStateReg('instPC', srtPC), 2437351Sgblack@eecs.umich.edu 'NPC': pcStateReg('instNPC', srtPC), 2447351Sgblack@eecs.umich.edu 'pNPC': pcStateReg('instNPC', srtEPC), 2457351Sgblack@eecs.umich.edu 'IWNPC': pcStateReg('instIWNPC', srtPC), 24610037SARM gem5 Developers 'Thumb': pcStateReg('thumb', srtPC), 24710037SARM gem5 Developers 'NextThumb': pcStateReg('nextThumb', srtMode), 24810037SARM gem5 Developers 'NextJazelle': pcStateReg('nextJazelle', srtMode), 24910037SARM gem5 Developers 'NextItState': pcStateReg('nextItstate', srtMode), 25010037SARM gem5 Developers 'Itstate': pcStateReg('itstate', srtMode), 25110037SARM gem5 Developers 25210037SARM gem5 Developers #Register operands depending on a field in the instruction encoding. These 25310037SARM gem5 Developers #should be avoided since they may not be portable across different 25410037SARM gem5 Developers #encodings of the same instruction. 25510037SARM gem5 Developers 'Rd': intReg('RD'), 25610037SARM gem5 Developers 'Rm': intReg('RM'), 25710037SARM gem5 Developers 'Rs': intReg('RS'), 25810037SARM gem5 Developers 'Rn': intReg('RN'), 25910037SARM gem5 Developers 'Rt': intReg('RT') 26010037SARM gem5 Developers}}; 26110037SARM gem5 Developers