operands.isa revision 8209
16019Shines@cs.fsu.edu// -*- mode:c++ -*- 27091Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited 37091Sgblack@eecs.umich.edu// All rights reserved 47091Sgblack@eecs.umich.edu// 57091Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall 67091Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual 77091Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating 87091Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software 97091Sgblack@eecs.umich.edu// licensed hereunder. You may use the software subject to the license 107091Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated 117091Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software, 127091Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form. 137091Sgblack@eecs.umich.edu// 146019Shines@cs.fsu.edu// Copyright (c) 2007-2008 The Florida State University 156019Shines@cs.fsu.edu// All rights reserved. 166019Shines@cs.fsu.edu// 176019Shines@cs.fsu.edu// Redistribution and use in source and binary forms, with or without 186019Shines@cs.fsu.edu// modification, are permitted provided that the following conditions are 196019Shines@cs.fsu.edu// met: redistributions of source code must retain the above copyright 206019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer; 216019Shines@cs.fsu.edu// redistributions in binary form must reproduce the above copyright 226019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer in the 236019Shines@cs.fsu.edu// documentation and/or other materials provided with the distribution; 246019Shines@cs.fsu.edu// neither the name of the copyright holders nor the names of its 256019Shines@cs.fsu.edu// contributors may be used to endorse or promote products derived from 266019Shines@cs.fsu.edu// this software without specific prior written permission. 276019Shines@cs.fsu.edu// 286019Shines@cs.fsu.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 296019Shines@cs.fsu.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 306019Shines@cs.fsu.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 316019Shines@cs.fsu.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 326019Shines@cs.fsu.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 336019Shines@cs.fsu.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 346019Shines@cs.fsu.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 356019Shines@cs.fsu.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 366019Shines@cs.fsu.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 376019Shines@cs.fsu.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 386019Shines@cs.fsu.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 396019Shines@cs.fsu.edu// 406019Shines@cs.fsu.edu// Authors: Stephen Hines 416019Shines@cs.fsu.edu 426019Shines@cs.fsu.edudef operand_types {{ 436019Shines@cs.fsu.edu 'sb' : ('signed int', 8), 446019Shines@cs.fsu.edu 'ub' : ('unsigned int', 8), 456019Shines@cs.fsu.edu 'sh' : ('signed int', 16), 466019Shines@cs.fsu.edu 'uh' : ('unsigned int', 16), 476019Shines@cs.fsu.edu 'sw' : ('signed int', 32), 486019Shines@cs.fsu.edu 'uw' : ('unsigned int', 32), 496019Shines@cs.fsu.edu 'ud' : ('unsigned int', 64), 507639Sgblack@eecs.umich.edu 'tud' : ('twin64 int', 64), 516019Shines@cs.fsu.edu 'sf' : ('float', 32), 526019Shines@cs.fsu.edu 'df' : ('float', 64) 536019Shines@cs.fsu.edu}}; 546019Shines@cs.fsu.edu 556312Sgblack@eecs.umich.edulet {{ 566312Sgblack@eecs.umich.edu maybePCRead = ''' 577720Sgblack@eecs.umich.edu ((%(reg_idx)s == PCReg) ? readPC(xc) : xc->%(func)s(this, %(op_idx)s)) 586312Sgblack@eecs.umich.edu ''' 597186Sgblack@eecs.umich.edu maybeAlignedPCRead = ''' 607720Sgblack@eecs.umich.edu ((%(reg_idx)s == PCReg) ? (roundDown(readPC(xc), 4)) : 617186Sgblack@eecs.umich.edu xc->%(func)s(this, %(op_idx)s)) 627186Sgblack@eecs.umich.edu ''' 636312Sgblack@eecs.umich.edu maybePCWrite = ''' 647093Sgblack@eecs.umich.edu ((%(reg_idx)s == PCReg) ? setNextPC(xc, %(final_val)s) : 656312Sgblack@eecs.umich.edu xc->%(func)s(this, %(op_idx)s, %(final_val)s)) 666312Sgblack@eecs.umich.edu ''' 677148Sgblack@eecs.umich.edu maybeIWPCWrite = ''' 687148Sgblack@eecs.umich.edu ((%(reg_idx)s == PCReg) ? setIWNextPC(xc, %(final_val)s) : 697148Sgblack@eecs.umich.edu xc->%(func)s(this, %(op_idx)s, %(final_val)s)) 707148Sgblack@eecs.umich.edu ''' 717184Sgblack@eecs.umich.edu maybeAIWPCWrite = ''' 727184Sgblack@eecs.umich.edu if (%(reg_idx)s == PCReg) { 737289Sgblack@eecs.umich.edu bool thumb = THUMB; 747289Sgblack@eecs.umich.edu if (thumb) { 757289Sgblack@eecs.umich.edu setNextPC(xc, %(final_val)s); 767289Sgblack@eecs.umich.edu } else { 777184Sgblack@eecs.umich.edu setIWNextPC(xc, %(final_val)s); 787184Sgblack@eecs.umich.edu } 797184Sgblack@eecs.umich.edu } else { 807184Sgblack@eecs.umich.edu xc->%(func)s(this, %(op_idx)s, %(final_val)s); 817184Sgblack@eecs.umich.edu } 827184Sgblack@eecs.umich.edu ''' 837797Sgblack@eecs.umich.edu 847797Sgblack@eecs.umich.edu #PCState operands need to have a sorting index (the number at the end) 857797Sgblack@eecs.umich.edu #less than all the integer registers which might update the PC. That way 867797Sgblack@eecs.umich.edu #if the flag bits of the pc state are updated and a branch happens through 877797Sgblack@eecs.umich.edu #R15, the updates are layered properly and the R15 update isn't lost. 887797Sgblack@eecs.umich.edu srtNormal = 5 897797Sgblack@eecs.umich.edu srtCpsr = 4 907797Sgblack@eecs.umich.edu srtBase = 3 917797Sgblack@eecs.umich.edu srtPC = 2 927797Sgblack@eecs.umich.edu srtMode = 1 937797Sgblack@eecs.umich.edu srtEPC = 0 947797Sgblack@eecs.umich.edu 957797Sgblack@eecs.umich.edu def floatReg(idx): 967797Sgblack@eecs.umich.edu return ('FloatReg', 'sf', idx, 'IsFloating', srtNormal) 977797Sgblack@eecs.umich.edu 987797Sgblack@eecs.umich.edu def intReg(idx): 997797Sgblack@eecs.umich.edu return ('IntReg', 'uw', idx, 'IsInteger', srtNormal, 1007797Sgblack@eecs.umich.edu maybePCRead, maybePCWrite) 1017797Sgblack@eecs.umich.edu 1027797Sgblack@eecs.umich.edu def intRegNPC(idx): 1037797Sgblack@eecs.umich.edu return ('IntReg', 'uw', idx, 'IsInteger', srtNormal) 1047797Sgblack@eecs.umich.edu 1057797Sgblack@eecs.umich.edu def intRegAPC(idx, id = srtNormal): 1067797Sgblack@eecs.umich.edu return ('IntReg', 'uw', idx, 'IsInteger', id, 1077797Sgblack@eecs.umich.edu maybeAlignedPCRead, maybePCWrite) 1087797Sgblack@eecs.umich.edu 1097797Sgblack@eecs.umich.edu def intRegIWPC(idx): 1107797Sgblack@eecs.umich.edu return ('IntReg', 'uw', idx, 'IsInteger', srtNormal, 1117797Sgblack@eecs.umich.edu maybePCRead, maybeIWPCWrite) 1127797Sgblack@eecs.umich.edu 1137797Sgblack@eecs.umich.edu def intRegAIWPC(idx): 1147797Sgblack@eecs.umich.edu return ('IntReg', 'uw', idx, 'IsInteger', srtNormal, 1157797Sgblack@eecs.umich.edu maybePCRead, maybeAIWPCWrite) 1167797Sgblack@eecs.umich.edu 1177797Sgblack@eecs.umich.edu def intRegCC(idx): 1187797Sgblack@eecs.umich.edu return ('IntReg', 'uw', idx, None, srtNormal) 1197797Sgblack@eecs.umich.edu 1207797Sgblack@eecs.umich.edu def cntrlReg(idx, id = srtNormal, type = 'uw'): 1217797Sgblack@eecs.umich.edu return ('ControlReg', type, idx, (None, None, 'IsControl'), id) 1227797Sgblack@eecs.umich.edu 1237797Sgblack@eecs.umich.edu def cntrlRegNC(idx, id = srtNormal, type = 'uw'): 1247797Sgblack@eecs.umich.edu return ('ControlReg', type, idx, None, id) 1257797Sgblack@eecs.umich.edu 1267797Sgblack@eecs.umich.edu def pcStateReg(idx, id): 1277797Sgblack@eecs.umich.edu return ('PCState', 'uw', idx, (None, None, 'IsControl'), id) 1286312Sgblack@eecs.umich.edu}}; 1296312Sgblack@eecs.umich.edu 1306019Shines@cs.fsu.edudef operands {{ 1317119Sgblack@eecs.umich.edu #Abstracted integer reg operands 1327797Sgblack@eecs.umich.edu 'Dest': intReg('dest'), 1337797Sgblack@eecs.umich.edu 'IWDest': intRegIWPC('dest'), 1347797Sgblack@eecs.umich.edu 'AIWDest': intRegAIWPC('dest'), 1357797Sgblack@eecs.umich.edu 'Dest2': intReg('dest2'), 1367797Sgblack@eecs.umich.edu 'Result': intReg('result'), 1377797Sgblack@eecs.umich.edu 'Base': intRegAPC('base', id = srtBase), 1387797Sgblack@eecs.umich.edu 'Index': intReg('index'), 1397797Sgblack@eecs.umich.edu 'Shift': intReg('shift'), 1407797Sgblack@eecs.umich.edu 'Op1': intReg('op1'), 1417797Sgblack@eecs.umich.edu 'Op2': intReg('op2'), 1427797Sgblack@eecs.umich.edu 'Op3': intReg('op3'), 1437797Sgblack@eecs.umich.edu 'Reg0': intReg('reg0'), 1447797Sgblack@eecs.umich.edu 'Reg1': intReg('reg1'), 1457797Sgblack@eecs.umich.edu 'Reg2': intReg('reg2'), 1467797Sgblack@eecs.umich.edu 'Reg3': intReg('reg3'), 1476019Shines@cs.fsu.edu 1487797Sgblack@eecs.umich.edu #Fixed index integer reg operands 1497797Sgblack@eecs.umich.edu 'SpMode': intRegNPC('intRegInMode((OperatingMode)regMode, INTREG_SP)'), 1507797Sgblack@eecs.umich.edu 'LR': intRegNPC('INTREG_LR'), 1517797Sgblack@eecs.umich.edu 'R7': intRegNPC('7'), 1528204SAli.Saidi@ARM.com # First four arguments are passed in registers 1537797Sgblack@eecs.umich.edu 'R0': intRegNPC('0'), 1548204SAli.Saidi@ARM.com 'R1': intRegNPC('1'), 1558204SAli.Saidi@ARM.com 'R2': intRegNPC('2'), 1568204SAli.Saidi@ARM.com 'R3': intRegNPC('3'), 1577797Sgblack@eecs.umich.edu 1587797Sgblack@eecs.umich.edu #Pseudo integer condition code registers 1597797Sgblack@eecs.umich.edu 'CondCodes': intRegCC('INTREG_CONDCODES'), 1607797Sgblack@eecs.umich.edu 'OptCondCodes': intRegCC( 1617422Sgblack@eecs.umich.edu '''(condCode == COND_AL || condCode == COND_UC) ? 1627797Sgblack@eecs.umich.edu INTREG_ZERO : INTREG_CONDCODES'''), 1637797Sgblack@eecs.umich.edu 'FpCondCodes': intRegCC('INTREG_FPCONDCODES'), 1647797Sgblack@eecs.umich.edu 1657797Sgblack@eecs.umich.edu #Abstracted floating point reg operands 1667797Sgblack@eecs.umich.edu 'FpDest': floatReg('(dest + 0)'), 1677797Sgblack@eecs.umich.edu 'FpDestP0': floatReg('(dest + 0)'), 1687797Sgblack@eecs.umich.edu 'FpDestP1': floatReg('(dest + 1)'), 1697797Sgblack@eecs.umich.edu 'FpDestP2': floatReg('(dest + 2)'), 1707797Sgblack@eecs.umich.edu 'FpDestP3': floatReg('(dest + 3)'), 1717797Sgblack@eecs.umich.edu 'FpDestP4': floatReg('(dest + 4)'), 1727797Sgblack@eecs.umich.edu 'FpDestP5': floatReg('(dest + 5)'), 1737797Sgblack@eecs.umich.edu 'FpDestP6': floatReg('(dest + 6)'), 1747797Sgblack@eecs.umich.edu 'FpDestP7': floatReg('(dest + 7)'), 1757797Sgblack@eecs.umich.edu 'FpDestS0P0': floatReg('(dest + step * 0 + 0)'), 1767797Sgblack@eecs.umich.edu 'FpDestS0P1': floatReg('(dest + step * 0 + 1)'), 1777797Sgblack@eecs.umich.edu 'FpDestS1P0': floatReg('(dest + step * 1 + 0)'), 1787797Sgblack@eecs.umich.edu 'FpDestS1P1': floatReg('(dest + step * 1 + 1)'), 1797797Sgblack@eecs.umich.edu 'FpDestS2P0': floatReg('(dest + step * 2 + 0)'), 1807797Sgblack@eecs.umich.edu 'FpDestS2P1': floatReg('(dest + step * 2 + 1)'), 1817797Sgblack@eecs.umich.edu 'FpDestS3P0': floatReg('(dest + step * 3 + 0)'), 1827797Sgblack@eecs.umich.edu 'FpDestS3P1': floatReg('(dest + step * 3 + 1)'), 1837797Sgblack@eecs.umich.edu 1847797Sgblack@eecs.umich.edu 'FpDest2': floatReg('(dest2 + 0)'), 1857797Sgblack@eecs.umich.edu 'FpDest2P0': floatReg('(dest2 + 0)'), 1867797Sgblack@eecs.umich.edu 'FpDest2P1': floatReg('(dest2 + 1)'), 1877797Sgblack@eecs.umich.edu 'FpDest2P2': floatReg('(dest2 + 2)'), 1887797Sgblack@eecs.umich.edu 'FpDest2P3': floatReg('(dest2 + 3)'), 1897797Sgblack@eecs.umich.edu 1907797Sgblack@eecs.umich.edu 'FpOp1': floatReg('(op1 + 0)'), 1917797Sgblack@eecs.umich.edu 'FpOp1P0': floatReg('(op1 + 0)'), 1927797Sgblack@eecs.umich.edu 'FpOp1P1': floatReg('(op1 + 1)'), 1937797Sgblack@eecs.umich.edu 'FpOp1P2': floatReg('(op1 + 2)'), 1947797Sgblack@eecs.umich.edu 'FpOp1P3': floatReg('(op1 + 3)'), 1957797Sgblack@eecs.umich.edu 'FpOp1P4': floatReg('(op1 + 4)'), 1967797Sgblack@eecs.umich.edu 'FpOp1P5': floatReg('(op1 + 5)'), 1977797Sgblack@eecs.umich.edu 'FpOp1P6': floatReg('(op1 + 6)'), 1987797Sgblack@eecs.umich.edu 'FpOp1P7': floatReg('(op1 + 7)'), 1997797Sgblack@eecs.umich.edu 'FpOp1S0P0': floatReg('(op1 + step * 0 + 0)'), 2007797Sgblack@eecs.umich.edu 'FpOp1S0P1': floatReg('(op1 + step * 0 + 1)'), 2017797Sgblack@eecs.umich.edu 'FpOp1S1P0': floatReg('(op1 + step * 1 + 0)'), 2027797Sgblack@eecs.umich.edu 'FpOp1S1P1': floatReg('(op1 + step * 1 + 1)'), 2037797Sgblack@eecs.umich.edu 'FpOp1S2P0': floatReg('(op1 + step * 2 + 0)'), 2047797Sgblack@eecs.umich.edu 'FpOp1S2P1': floatReg('(op1 + step * 2 + 1)'), 2057797Sgblack@eecs.umich.edu 'FpOp1S3P0': floatReg('(op1 + step * 3 + 0)'), 2067797Sgblack@eecs.umich.edu 'FpOp1S3P1': floatReg('(op1 + step * 3 + 1)'), 2077797Sgblack@eecs.umich.edu 2087797Sgblack@eecs.umich.edu 'FpOp2': floatReg('(op2 + 0)'), 2097797Sgblack@eecs.umich.edu 'FpOp2P0': floatReg('(op2 + 0)'), 2107797Sgblack@eecs.umich.edu 'FpOp2P1': floatReg('(op2 + 1)'), 2117797Sgblack@eecs.umich.edu 'FpOp2P2': floatReg('(op2 + 2)'), 2127797Sgblack@eecs.umich.edu 'FpOp2P3': floatReg('(op2 + 3)'), 2137797Sgblack@eecs.umich.edu 2147797Sgblack@eecs.umich.edu #Abstracted control reg operands 2157797Sgblack@eecs.umich.edu 'MiscDest': cntrlReg('dest'), 2167797Sgblack@eecs.umich.edu 'MiscOp1': cntrlReg('op1'), 2177797Sgblack@eecs.umich.edu 2187797Sgblack@eecs.umich.edu #Fixed index control regs 2197797Sgblack@eecs.umich.edu 'Cpsr': cntrlReg('MISCREG_CPSR', srtCpsr), 2207797Sgblack@eecs.umich.edu 'Spsr': cntrlRegNC('MISCREG_SPSR'), 2217797Sgblack@eecs.umich.edu 'Fpsr': cntrlRegNC('MISCREG_FPSR'), 2227797Sgblack@eecs.umich.edu 'Fpsid': cntrlRegNC('MISCREG_FPSID'), 2237797Sgblack@eecs.umich.edu 'Fpscr': cntrlRegNC('MISCREG_FPSCR'), 2247797Sgblack@eecs.umich.edu 'FpscrQc': cntrlRegNC('MISCREG_FPSCR_QC'), 2257797Sgblack@eecs.umich.edu 'FpscrExc': cntrlRegNC('MISCREG_FPSCR_EXC'), 2267797Sgblack@eecs.umich.edu 'Cpacr': cntrlReg('MISCREG_CPACR'), 2277797Sgblack@eecs.umich.edu 'Fpexc': cntrlRegNC('MISCREG_FPEXC'), 2287797Sgblack@eecs.umich.edu 'Sctlr': cntrlRegNC('MISCREG_SCTLR'), 2297797Sgblack@eecs.umich.edu 'SevMailbox': cntrlRegNC('MISCREG_SEV_MAILBOX'), 2308209SAli.Saidi@ARM.com 'LLSCLock': cntrlRegNC('MISCREG_LOCKFLAG'), 2316019Shines@cs.fsu.edu 2326308Sgblack@eecs.umich.edu #Register fields for microops 2338139SMatt.Horsnell@arm.com 'URa' : intReg('ura'), 2347797Sgblack@eecs.umich.edu 'IWRa' : intRegIWPC('ura'), 2357797Sgblack@eecs.umich.edu 'Fa' : floatReg('ura'), 2368139SMatt.Horsnell@arm.com 'URb' : intReg('urb'), 2378139SMatt.Horsnell@arm.com 'URc' : intReg('urc'), 2386308Sgblack@eecs.umich.edu 2396019Shines@cs.fsu.edu #Memory Operand 2407797Sgblack@eecs.umich.edu 'Mem': ('Mem', 'uw', None, ('IsMemRef', 'IsLoad', 'IsStore'), srtNormal), 2416019Shines@cs.fsu.edu 2427797Sgblack@eecs.umich.edu #PCState fields 2437797Sgblack@eecs.umich.edu 'PC': pcStateReg('instPC', srtPC), 2447797Sgblack@eecs.umich.edu 'NPC': pcStateReg('instNPC', srtPC), 2457797Sgblack@eecs.umich.edu 'pNPC': pcStateReg('instNPC', srtEPC), 2467797Sgblack@eecs.umich.edu 'IWNPC': pcStateReg('instIWNPC', srtPC), 2477797Sgblack@eecs.umich.edu 'Thumb': pcStateReg('thumb', srtPC), 2487797Sgblack@eecs.umich.edu 'NextThumb': pcStateReg('nextThumb', srtMode), 2497797Sgblack@eecs.umich.edu 'NextJazelle': pcStateReg('nextJazelle', srtMode), 2508205SAli.Saidi@ARM.com 'NextItState': pcStateReg('nextItstate', srtMode), 2518205SAli.Saidi@ARM.com 'Itstate': pcStateReg('itstate', srtMode), 2527797Sgblack@eecs.umich.edu 2537797Sgblack@eecs.umich.edu #Register operands depending on a field in the instruction encoding. These 2547797Sgblack@eecs.umich.edu #should be avoided since they may not be portable across different 2557797Sgblack@eecs.umich.edu #encodings of the same instruction. 2567797Sgblack@eecs.umich.edu 'Rd': intReg('RD'), 2577797Sgblack@eecs.umich.edu 'Rm': intReg('RM'), 2587797Sgblack@eecs.umich.edu 'Rs': intReg('RS'), 2597797Sgblack@eecs.umich.edu 'Rn': intReg('RN'), 2607797Sgblack@eecs.umich.edu 'Rt': intReg('RT') 2616019Shines@cs.fsu.edu}}; 262