operands.isa revision 7783:9b880b40ac10
12929Sktlim@umich.edu// -*- mode:c++ -*-
22929Sktlim@umich.edu// Copyright (c) 2010 ARM Limited
32932Sktlim@umich.edu// All rights reserved
42929Sktlim@umich.edu//
52929Sktlim@umich.edu// The license below extends only to copyright in the software and shall
62929Sktlim@umich.edu// not be construed as granting a license to any other intellectual
72929Sktlim@umich.edu// property including but not limited to intellectual property relating
82929Sktlim@umich.edu// to a hardware implementation of the functionality of the software
92929Sktlim@umich.edu// licensed hereunder.  You may use the software subject to the license
102929Sktlim@umich.edu// terms below provided that you ensure that this notice is replicated
112929Sktlim@umich.edu// unmodified and in its entirety in all distributions of the software,
122929Sktlim@umich.edu// modified or unmodified, in source code or in binary form.
132929Sktlim@umich.edu//
142929Sktlim@umich.edu// Copyright (c) 2007-2008 The Florida State University
152929Sktlim@umich.edu// All rights reserved.
162929Sktlim@umich.edu//
172929Sktlim@umich.edu// Redistribution and use in source and binary forms, with or without
182929Sktlim@umich.edu// modification, are permitted provided that the following conditions are
192929Sktlim@umich.edu// met: redistributions of source code must retain the above copyright
202929Sktlim@umich.edu// notice, this list of conditions and the following disclaimer;
212929Sktlim@umich.edu// redistributions in binary form must reproduce the above copyright
222929Sktlim@umich.edu// notice, this list of conditions and the following disclaimer in the
232929Sktlim@umich.edu// documentation and/or other materials provided with the distribution;
242929Sktlim@umich.edu// neither the name of the copyright holders nor the names of its
252929Sktlim@umich.edu// contributors may be used to endorse or promote products derived from
262929Sktlim@umich.edu// this software without specific prior written permission.
272929Sktlim@umich.edu//
282932Sktlim@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292932Sktlim@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302932Sktlim@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312929Sktlim@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
326007Ssteve.reinhardt@amd.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
337735SAli.Saidi@ARM.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342929Sktlim@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352929Sktlim@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362929Sktlim@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372929Sktlim@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382929Sktlim@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392929Sktlim@umich.edu//
402929Sktlim@umich.edu// Authors: Stephen Hines
412929Sktlim@umich.edu
422929Sktlim@umich.edudef operand_types {{
432929Sktlim@umich.edu    'sb' : ('signed int', 8),
442929Sktlim@umich.edu    'ub' : ('unsigned int', 8),
452929Sktlim@umich.edu    'sh' : ('signed int', 16),
462929Sktlim@umich.edu    'uh' : ('unsigned int', 16),
476007Ssteve.reinhardt@amd.com    'sw' : ('signed int', 32),
486007Ssteve.reinhardt@amd.com    'uw' : ('unsigned int', 32),
496007Ssteve.reinhardt@amd.com    'ud' : ('unsigned int', 64),
506007Ssteve.reinhardt@amd.com    'tud' : ('twin64 int', 64),
516007Ssteve.reinhardt@amd.com    'sf' : ('float', 32),
526007Ssteve.reinhardt@amd.com    'df' : ('float', 64)
536007Ssteve.reinhardt@amd.com}};
546007Ssteve.reinhardt@amd.com
556007Ssteve.reinhardt@amd.comlet {{
566007Ssteve.reinhardt@amd.com    maybePCRead = '''
576007Ssteve.reinhardt@amd.com        ((%(reg_idx)s == PCReg) ? readPC(xc) : xc->%(func)s(this, %(op_idx)s))
586007Ssteve.reinhardt@amd.com    '''
596007Ssteve.reinhardt@amd.com    maybeAlignedPCRead = '''
606007Ssteve.reinhardt@amd.com        ((%(reg_idx)s == PCReg) ? (roundDown(readPC(xc), 4)) :
616007Ssteve.reinhardt@amd.com         xc->%(func)s(this, %(op_idx)s))
626007Ssteve.reinhardt@amd.com    '''
636007Ssteve.reinhardt@amd.com    maybePCWrite = '''
646007Ssteve.reinhardt@amd.com        ((%(reg_idx)s == PCReg) ? setNextPC(xc, %(final_val)s) :
656007Ssteve.reinhardt@amd.com         xc->%(func)s(this, %(op_idx)s, %(final_val)s))
666007Ssteve.reinhardt@amd.com    '''
676007Ssteve.reinhardt@amd.com    maybeIWPCWrite = '''
686007Ssteve.reinhardt@amd.com        ((%(reg_idx)s == PCReg) ? setIWNextPC(xc, %(final_val)s) :
696007Ssteve.reinhardt@amd.com         xc->%(func)s(this, %(op_idx)s, %(final_val)s))
706007Ssteve.reinhardt@amd.com    '''
716007Ssteve.reinhardt@amd.com    maybeAIWPCWrite = '''
726007Ssteve.reinhardt@amd.com        if (%(reg_idx)s == PCReg) {
736007Ssteve.reinhardt@amd.com            bool thumb = THUMB;
746007Ssteve.reinhardt@amd.com            if (thumb) {
756007Ssteve.reinhardt@amd.com                setNextPC(xc, %(final_val)s);
762929Sktlim@umich.edu            } else {
772929Sktlim@umich.edu                setIWNextPC(xc, %(final_val)s);
782929Sktlim@umich.edu            }
796007Ssteve.reinhardt@amd.com        } else {
806007Ssteve.reinhardt@amd.com            xc->%(func)s(this, %(op_idx)s, %(final_val)s);
816007Ssteve.reinhardt@amd.com        }
826007Ssteve.reinhardt@amd.com    '''
836007Ssteve.reinhardt@amd.com}};
846007Ssteve.reinhardt@amd.com
852929Sktlim@umich.edudef operands {{
862929Sktlim@umich.edu    #Abstracted integer reg operands
872929Sktlim@umich.edu    'Dest': ('IntReg', 'uw', 'dest', 'IsInteger', 3,
882929Sktlim@umich.edu             maybePCRead, maybePCWrite),
892929Sktlim@umich.edu    'FpDest': ('FloatReg', 'sf', '(dest + 0)', 'IsFloating', 3),
906011Ssteve.reinhardt@amd.com    'FpDestP0': ('FloatReg', 'sf', '(dest + 0)', 'IsFloating', 3),
916007Ssteve.reinhardt@amd.com    'FpDestP1': ('FloatReg', 'sf', '(dest + 1)', 'IsFloating', 3),
926007Ssteve.reinhardt@amd.com    'FpDestP2': ('FloatReg', 'sf', '(dest + 2)', 'IsFloating', 3),
936007Ssteve.reinhardt@amd.com    'FpDestP3': ('FloatReg', 'sf', '(dest + 3)', 'IsFloating', 3),
946007Ssteve.reinhardt@amd.com    'FpDestP4': ('FloatReg', 'sf', '(dest + 4)', 'IsFloating', 3),
956007Ssteve.reinhardt@amd.com    'FpDestP5': ('FloatReg', 'sf', '(dest + 5)', 'IsFloating', 3),
966007Ssteve.reinhardt@amd.com    'FpDestP6': ('FloatReg', 'sf', '(dest + 6)', 'IsFloating', 3),
976007Ssteve.reinhardt@amd.com    'FpDestP7': ('FloatReg', 'sf', '(dest + 7)', 'IsFloating', 3),
986007Ssteve.reinhardt@amd.com    'FpDestS0P0': ('FloatReg', 'sf', '(dest + step * 0 + 0)', 'IsFloating', 3),
996007Ssteve.reinhardt@amd.com    'FpDestS0P1': ('FloatReg', 'sf', '(dest + step * 0 + 1)', 'IsFloating', 3),
1006007Ssteve.reinhardt@amd.com    'FpDestS1P0': ('FloatReg', 'sf', '(dest + step * 1 + 0)', 'IsFloating', 3),
1016007Ssteve.reinhardt@amd.com    'FpDestS1P1': ('FloatReg', 'sf', '(dest + step * 1 + 1)', 'IsFloating', 3),
1026007Ssteve.reinhardt@amd.com    'FpDestS2P0': ('FloatReg', 'sf', '(dest + step * 2 + 0)', 'IsFloating', 3),
1036007Ssteve.reinhardt@amd.com    'FpDestS2P1': ('FloatReg', 'sf', '(dest + step * 2 + 1)', 'IsFloating', 3),
1046007Ssteve.reinhardt@amd.com    'FpDestS3P0': ('FloatReg', 'sf', '(dest + step * 3 + 0)', 'IsFloating', 3),
1057735SAli.Saidi@ARM.com    'FpDestS3P1': ('FloatReg', 'sf', '(dest + step * 3 + 1)', 'IsFloating', 3),
1066011Ssteve.reinhardt@amd.com    'Result': ('IntReg', 'uw', 'result', 'IsInteger', 3,
1076007Ssteve.reinhardt@amd.com               maybePCRead, maybePCWrite),
1086007Ssteve.reinhardt@amd.com    'Dest2': ('IntReg', 'uw', 'dest2', 'IsInteger', 3,
1096007Ssteve.reinhardt@amd.com              maybePCRead, maybePCWrite),
1106007Ssteve.reinhardt@amd.com    'FpDest2': ('FloatReg', 'sf', '(dest2 + 0)', 'IsFloating', 3),
1117735SAli.Saidi@ARM.com    'FpDest2P0': ('FloatReg', 'sf', '(dest2 + 0)', 'IsFloating', 3),
1127735SAli.Saidi@ARM.com    'FpDest2P1': ('FloatReg', 'sf', '(dest2 + 1)', 'IsFloating', 3),
1137735SAli.Saidi@ARM.com    'FpDest2P2': ('FloatReg', 'sf', '(dest2 + 2)', 'IsFloating', 3),
1147735SAli.Saidi@ARM.com    'FpDest2P3': ('FloatReg', 'sf', '(dest2 + 3)', 'IsFloating', 3),
1157735SAli.Saidi@ARM.com    'IWDest': ('IntReg', 'uw', 'dest', 'IsInteger', 3,
1167735SAli.Saidi@ARM.com               maybePCRead, maybeIWPCWrite),
1177735SAli.Saidi@ARM.com    'AIWDest': ('IntReg', 'uw', 'dest', 'IsInteger', 3,
1187735SAli.Saidi@ARM.com                maybePCRead, maybeAIWPCWrite),
1197735SAli.Saidi@ARM.com    'SpMode': ('IntReg', 'uw',
1207735SAli.Saidi@ARM.com               'intRegInMode((OperatingMode)regMode, INTREG_SP)',
1217735SAli.Saidi@ARM.com               'IsInteger', 3),
1227735SAli.Saidi@ARM.com    'MiscDest': ('ControlReg', 'uw', 'dest', (None, None, 'IsControl'), 3),
1237735SAli.Saidi@ARM.com    'Base': ('IntReg', 'uw', 'base', 'IsInteger', 1,
1247735SAli.Saidi@ARM.com             maybeAlignedPCRead, maybePCWrite),
1256007Ssteve.reinhardt@amd.com    'Index': ('IntReg', 'uw', 'index', 'IsInteger', 3,
1267685Ssteve.reinhardt@amd.com              maybePCRead, maybePCWrite),
1276007Ssteve.reinhardt@amd.com    'Op1': ('IntReg', 'uw', 'op1', 'IsInteger', 3,
1286011Ssteve.reinhardt@amd.com              maybePCRead, maybePCWrite),
1296007Ssteve.reinhardt@amd.com    'FpOp1': ('FloatReg', 'sf', '(op1 + 0)', 'IsFloating', 3),
1306007Ssteve.reinhardt@amd.com    'FpOp1P0': ('FloatReg', 'sf', '(op1 + 0)', 'IsFloating', 3),
1316007Ssteve.reinhardt@amd.com    'FpOp1P1': ('FloatReg', 'sf', '(op1 + 1)', 'IsFloating', 3),
1326007Ssteve.reinhardt@amd.com    'FpOp1P2': ('FloatReg', 'sf', '(op1 + 2)', 'IsFloating', 3),
1336007Ssteve.reinhardt@amd.com    'FpOp1P3': ('FloatReg', 'sf', '(op1 + 3)', 'IsFloating', 3),
1346007Ssteve.reinhardt@amd.com    'FpOp1P4': ('FloatReg', 'sf', '(op1 + 4)', 'IsFloating', 3),
1356011Ssteve.reinhardt@amd.com    'FpOp1P5': ('FloatReg', 'sf', '(op1 + 5)', 'IsFloating', 3),
1366007Ssteve.reinhardt@amd.com    'FpOp1P6': ('FloatReg', 'sf', '(op1 + 6)', 'IsFloating', 3),
1376007Ssteve.reinhardt@amd.com    'FpOp1P7': ('FloatReg', 'sf', '(op1 + 7)', 'IsFloating', 3),
1386007Ssteve.reinhardt@amd.com    'FpOp1S0P0': ('FloatReg', 'sf', '(op1 + step * 0 + 0)', 'IsFloating', 3),
1396007Ssteve.reinhardt@amd.com    'FpOp1S0P1': ('FloatReg', 'sf', '(op1 + step * 0 + 1)', 'IsFloating', 3),
1406007Ssteve.reinhardt@amd.com    'FpOp1S1P0': ('FloatReg', 'sf', '(op1 + step * 1 + 0)', 'IsFloating', 3),
1416008Ssteve.reinhardt@amd.com    'FpOp1S1P1': ('FloatReg', 'sf', '(op1 + step * 1 + 1)', 'IsFloating', 3),
1426007Ssteve.reinhardt@amd.com    'FpOp1S2P0': ('FloatReg', 'sf', '(op1 + step * 2 + 0)', 'IsFloating', 3),
1436008Ssteve.reinhardt@amd.com    'FpOp1S2P1': ('FloatReg', 'sf', '(op1 + step * 2 + 1)', 'IsFloating', 3),
1446008Ssteve.reinhardt@amd.com    'FpOp1S3P0': ('FloatReg', 'sf', '(op1 + step * 3 + 0)', 'IsFloating', 3),
1456008Ssteve.reinhardt@amd.com    'FpOp1S3P1': ('FloatReg', 'sf', '(op1 + step * 3 + 1)', 'IsFloating', 3),
1466008Ssteve.reinhardt@amd.com    'MiscOp1': ('ControlReg', 'uw', 'op1', (None, None, 'IsControl'), 3),
1476008Ssteve.reinhardt@amd.com    'Op2': ('IntReg', 'uw', 'op2', 'IsInteger', 3,
1486008Ssteve.reinhardt@amd.com              maybePCRead, maybePCWrite),
1496008Ssteve.reinhardt@amd.com    'FpOp2': ('FloatReg', 'sf', '(op2 + 0)', 'IsFloating', 3),
1506007Ssteve.reinhardt@amd.com    'FpOp2P0': ('FloatReg', 'sf', '(op2 + 0)', 'IsFloating', 3),
1516007Ssteve.reinhardt@amd.com    'FpOp2P1': ('FloatReg', 'sf', '(op2 + 1)', 'IsFloating', 3),
1526007Ssteve.reinhardt@amd.com    'FpOp2P2': ('FloatReg', 'sf', '(op2 + 2)', 'IsFloating', 3),
1536007Ssteve.reinhardt@amd.com    'FpOp2P3': ('FloatReg', 'sf', '(op2 + 3)', 'IsFloating', 3),
1546007Ssteve.reinhardt@amd.com    'Op3': ('IntReg', 'uw', 'op3', 'IsInteger', 3,
1552929Sktlim@umich.edu              maybePCRead, maybePCWrite),
1562929Sktlim@umich.edu    'Shift': ('IntReg', 'uw', 'shift', 'IsInteger', 3,
1572929Sktlim@umich.edu              maybePCRead, maybePCWrite),
1582929Sktlim@umich.edu    'Reg0': ('IntReg', 'uw', 'reg0', 'IsInteger', 3,
1596007Ssteve.reinhardt@amd.com              maybePCRead, maybePCWrite),
1606007Ssteve.reinhardt@amd.com    'Reg1': ('IntReg', 'uw', 'reg1', 'IsInteger', 3,
1612929Sktlim@umich.edu              maybePCRead, maybePCWrite),
1622929Sktlim@umich.edu    'Reg2': ('IntReg', 'uw', 'reg2', 'IsInteger', 3,
1632929Sktlim@umich.edu              maybePCRead, maybePCWrite),
1642929Sktlim@umich.edu    'Reg3': ('IntReg', 'uw', 'reg3', 'IsInteger', 3,
1656007Ssteve.reinhardt@amd.com              maybePCRead, maybePCWrite),
1666007Ssteve.reinhardt@amd.com    #General Purpose Integer Reg Operands
1672929Sktlim@umich.edu    'Rd': ('IntReg', 'uw', 'RD', 'IsInteger', 3, maybePCRead, maybePCWrite),
1682929Sktlim@umich.edu    'Rm': ('IntReg', 'uw', 'RM', 'IsInteger', 3, maybePCRead, maybePCWrite),
1696007Ssteve.reinhardt@amd.com    'Rs': ('IntReg', 'uw', 'RS', 'IsInteger', 3, maybePCRead, maybePCWrite),
1702929Sktlim@umich.edu    'Rn': ('IntReg', 'uw', 'RN', 'IsInteger', 3, maybePCRead, maybePCWrite),
1712929Sktlim@umich.edu    'R7': ('IntReg', 'uw', '7', 'IsInteger', 3),
1722929Sktlim@umich.edu    'R0': ('IntReg', 'uw', '0', 'IsInteger', 3),
1732929Sktlim@umich.edu    'R1': ('IntReg', 'uw', '0', 'IsInteger', 3),
1742929Sktlim@umich.edu    'R2': ('IntReg', 'uw', '1', 'IsInteger', 3),
1752929Sktlim@umich.edu    'Rt' : ('IntReg', 'uw', 'RT', 'IsInteger', 3, maybePCRead, maybePCWrite),
1762929Sktlim@umich.edu
1774937Sstever@gmail.com    'LR': ('IntReg', 'uw', 'INTREG_LR', 'IsInteger', 3),
1784937Sstever@gmail.com    'CondCodes': ('IntReg', 'uw', 'INTREG_CONDCODES', None, 3),
1794937Sstever@gmail.com    'OptCondCodes': ('IntReg', 'uw',
1804937Sstever@gmail.com            '''(condCode == COND_AL || condCode == COND_UC) ?
1814937Sstever@gmail.com               INTREG_ZERO : INTREG_CONDCODES''', None, 3),
1824937Sstever@gmail.com    'FpCondCodes': ('IntReg', 'uw', 'INTREG_FPCONDCODES', None, 3),
1834937Sstever@gmail.com
1844937Sstever@gmail.com    #Register fields for microops
1854937Sstever@gmail.com    'Ra' : ('IntReg', 'uw', 'ura', 'IsInteger', 3, maybePCRead, maybePCWrite),
1865773Snate@binkert.org    'IWRa' : ('IntReg', 'uw', 'ura', 'IsInteger', 3,
1874937Sstever@gmail.com            maybePCRead, maybeIWPCWrite),
1884937Sstever@gmail.com    'Fa' : ('FloatReg', 'sf', 'ura', 'IsFloating', 3),
1894937Sstever@gmail.com    'Rb' : ('IntReg', 'uw', 'urb', 'IsInteger', 3, maybePCRead, maybePCWrite),
1902929Sktlim@umich.edu    'Rc' : ('IntReg', 'uw', 'urc', 'IsInteger', 3, maybePCRead, maybePCWrite),
1912929Sktlim@umich.edu
1922929Sktlim@umich.edu    #General Purpose Floating Point Reg Operands
1935773Snate@binkert.org    'Fd': ('FloatReg', 'df', 'FD', 'IsFloating', 3),
1942929Sktlim@umich.edu    'Fn': ('FloatReg', 'df', 'FN', 'IsFloating', 3),
1952929Sktlim@umich.edu    'Fm': ('FloatReg', 'df', 'FM', 'IsFloating', 3),
1962929Sktlim@umich.edu
1972929Sktlim@umich.edu    #Memory Operand
1982929Sktlim@umich.edu    'Mem': ('Mem', 'uw', None, ('IsMemRef', 'IsLoad', 'IsStore'), 3),
1992929Sktlim@umich.edu
2004937Sstever@gmail.com    'Cpsr': ('ControlReg', 'uw', 'MISCREG_CPSR', (None, None, 'IsControl'), 2),
2014937Sstever@gmail.com    'Itstate': ('ControlReg', 'ub', 'MISCREG_ITSTATE', None, 3),
2024937Sstever@gmail.com    'Spsr': ('ControlReg', 'uw', 'MISCREG_SPSR', None, 3),
2034937Sstever@gmail.com    'Fpsr': ('ControlReg', 'uw', 'MISCREG_FPSR', None, 3),
2044937Sstever@gmail.com    'Fpsid': ('ControlReg', 'uw', 'MISCREG_FPSID', None, 3),
2054937Sstever@gmail.com    'Fpscr': ('ControlReg', 'uw', 'MISCREG_FPSCR', None, 3),
2064937Sstever@gmail.com    'FpscrQc': ('ControlReg', 'uw', 'MISCREG_FPSCR_QC', None, 3),
2074937Sstever@gmail.com    'FpscrExc': ('ControlReg', 'uw', 'MISCREG_FPSCR_EXC', None, 3),
2084937Sstever@gmail.com    'Cpacr': ('ControlReg', 'uw', 'MISCREG_CPACR', (None, None, 'IsControl'), 3),
2094937Sstever@gmail.com    'Fpexc': ('ControlReg', 'uw', 'MISCREG_FPEXC', None, 3),
2104937Sstever@gmail.com    'Sctlr': ('ControlReg', 'uw', 'MISCREG_SCTLR', None, 3),
2114937Sstever@gmail.com    'SevMailbox': ('ControlReg', 'uw', 'MISCREG_SEV_MAILBOX', None, 3),
2124937Sstever@gmail.com    #PCS needs to have a sorting index (the number at the end) less than all
2134937Sstever@gmail.com    #the integer registers which might update the PC. That way if the flag
2144937Sstever@gmail.com    #bits of the pc state are updated and a branch happens through R15, the
2152929Sktlim@umich.edu    #updates are layered properly and the R15 update isn't lost.
2162929Sktlim@umich.edu    'PCS': ('PCState', 'uw', None, (None, None, 'IsControl'), 0)
2172929Sktlim@umich.edu}};
2182929Sktlim@umich.edu