operands.isa revision 7186:d4fc47ea5775
16242Sgblack@eecs.umich.edu// -*- mode:c++ -*-
211575SDylan.Johnson@ARM.com// Copyright (c) 2010 ARM Limited
37093Sgblack@eecs.umich.edu// All rights reserved
47093Sgblack@eecs.umich.edu//
57093Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall
67093Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual
77093Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating
87093Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software
97093Sgblack@eecs.umich.edu// licensed hereunder.  You may use the software subject to the license
107093Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated
117093Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software,
127093Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form.
137093Sgblack@eecs.umich.edu//
146242Sgblack@eecs.umich.edu// Copyright (c) 2007-2008 The Florida State University
156242Sgblack@eecs.umich.edu// All rights reserved.
166242Sgblack@eecs.umich.edu//
176242Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
186242Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
196242Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright
206242Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
216242Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
226242Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
236242Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution;
246242Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its
256242Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
266242Sgblack@eecs.umich.edu// this software without specific prior written permission.
276242Sgblack@eecs.umich.edu//
286242Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
296242Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
306242Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
316242Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
326242Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
336242Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
346242Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
356242Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
366242Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
376242Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
386242Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
396242Sgblack@eecs.umich.edu//
406242Sgblack@eecs.umich.edu// Authors: Stephen Hines
4110037SARM gem5 Developers
426242Sgblack@eecs.umich.edudef operand_types {{
436242Sgblack@eecs.umich.edu    'sb' : ('signed int', 8),
446242Sgblack@eecs.umich.edu    'ub' : ('unsigned int', 8),
456242Sgblack@eecs.umich.edu    'sh' : ('signed int', 16),
4610037SARM gem5 Developers    'uh' : ('unsigned int', 16),
4710037SARM gem5 Developers    'sw' : ('signed int', 32),
486242Sgblack@eecs.umich.edu    'uw' : ('unsigned int', 32),
499256SAndreas.Sandberg@arm.com    'ud' : ('unsigned int', 64),
506242Sgblack@eecs.umich.edu    'sf' : ('float', 32),
5110037SARM gem5 Developers    'df' : ('float', 64)
5210037SARM gem5 Developers}};
5310037SARM gem5 Developers
546242Sgblack@eecs.umich.edulet {{
556242Sgblack@eecs.umich.edu    maybePCRead = '''
566242Sgblack@eecs.umich.edu        ((%(reg_idx)s == PCReg) ? (readPC(xc) & ~PcModeMask) :
5710037SARM gem5 Developers         xc->%(func)s(this, %(op_idx)s))
5810037SARM gem5 Developers    '''
5910037SARM gem5 Developers    maybeAlignedPCRead = '''
6010037SARM gem5 Developers        ((%(reg_idx)s == PCReg) ? (roundDown(readPC(xc) & ~PcModeMask, 4)) :
6110037SARM gem5 Developers         xc->%(func)s(this, %(op_idx)s))
6210037SARM gem5 Developers    '''
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))
7010037SARM gem5 Developers    '''
7110037SARM gem5 Developers    maybeAIWPCWrite = '''
727259Sgblack@eecs.umich.edu        if (%(reg_idx)s == PCReg) {
7310037SARM gem5 Developers            if (xc->readPC() & (ULL(1) << PcTBitShift)) {
7410037SARM gem5 Developers                setIWNextPC(xc, %(final_val)s);
7510037SARM gem5 Developers            } else {
7610037SARM gem5 Developers                setNextPC(xc, %(final_val)s);
7710037SARM gem5 Developers            }
7810037SARM gem5 Developers        } else {
7910037SARM gem5 Developers            xc->%(func)s(this, %(op_idx)s, %(final_val)s);
8010037SARM gem5 Developers        }
8110037SARM gem5 Developers    '''
8210037SARM gem5 Developers
8310037SARM gem5 Developers    readNPC = 'xc->readNextPC() & ~PcModeMask'
8410037SARM gem5 Developers    writeNPC = 'setNextPC(xc, %(final_val)s)'
8510037SARM gem5 Developers    writeIWNPC = 'setIWNextPC(xc, %(final_val)s)'
8610037SARM gem5 Developers    forceNPC = 'xc->setNextPC(%(final_val)s)'
8710037SARM gem5 Developers}};
8810037SARM gem5 Developers
898868SMatt.Horsnell@arm.comdef operands {{
9010037SARM gem5 Developers    #Abstracted integer reg operands
9110037SARM gem5 Developers    'Dest': ('IntReg', 'uw', 'dest', 'IsInteger', 0,
9210037SARM gem5 Developers             maybePCRead, maybePCWrite),
9310037SARM gem5 Developers    'IWDest': ('IntReg', 'uw', 'dest', 'IsInteger', 0,
9410037SARM gem5 Developers               maybePCRead, maybeIWPCWrite),
9510037SARM gem5 Developers    'AIWDest': ('IntReg', 'uw', 'dest', 'IsInteger', 0,
9610037SARM gem5 Developers                maybePCRead, maybeAIWPCWrite),
9710037SARM gem5 Developers    'Base': ('IntReg', 'uw', 'base', 'IsInteger', 1,
9810037SARM gem5 Developers             maybeAlignedPCRead, maybePCWrite),
9910037SARM gem5 Developers    'Index': ('IntReg', 'uw', 'index', 'IsInteger', 2,
10010037SARM gem5 Developers              maybePCRead, maybePCWrite),
10110037SARM gem5 Developers    'Op1': ('IntReg', 'uw', 'op1', 'IsInteger', 3,
10210037SARM gem5 Developers              maybePCRead, maybePCWrite),
10310037SARM gem5 Developers    'Op2': ('IntReg', 'uw', 'op2', 'IsInteger', 4,
10410037SARM gem5 Developers              maybePCRead, maybePCWrite),
10510037SARM gem5 Developers    'Shift': ('IntReg', 'uw', 'shift', 'IsInteger', 5,
10610037SARM gem5 Developers              maybePCRead, maybePCWrite),
10710037SARM gem5 Developers    'Reg0': ('IntReg', 'uw', 'reg0', 'IsInteger', 6,
10810037SARM gem5 Developers              maybePCRead, maybePCWrite),
10910037SARM gem5 Developers    'Reg1': ('IntReg', 'uw', 'reg1', 'IsInteger', 7,
11010037SARM gem5 Developers              maybePCRead, maybePCWrite),
11110037SARM gem5 Developers    'Reg2': ('IntReg', 'uw', 'reg2', 'IsInteger', 8,
11210037SARM gem5 Developers              maybePCRead, maybePCWrite),
11310037SARM gem5 Developers    'Reg3': ('IntReg', 'uw', 'reg3', 'IsInteger', 9,
11410037SARM gem5 Developers              maybePCRead, maybePCWrite),
11510037SARM gem5 Developers    #General Purpose Integer Reg Operands
11610037SARM gem5 Developers    'Rd': ('IntReg', 'uw', 'RD', 'IsInteger', 1, maybePCRead, maybePCWrite),
11710037SARM gem5 Developers    'Rm': ('IntReg', 'uw', 'RM', 'IsInteger', 2, maybePCRead, maybePCWrite),
11810037SARM gem5 Developers    'Rs': ('IntReg', 'uw', 'RS', 'IsInteger', 3, maybePCRead, maybePCWrite),
11910037SARM gem5 Developers    'Rn': ('IntReg', 'uw', 'RN', 'IsInteger', 4, maybePCRead, maybePCWrite),
12010037SARM gem5 Developers    'R7': ('IntReg', 'uw', '7', 'IsInteger', 5),
12110037SARM gem5 Developers    'R0': ('IntReg', 'uw', '0', 'IsInteger', 0),
12210037SARM gem5 Developers
12310037SARM gem5 Developers    #Destination register for load/store double instructions
12410037SARM gem5 Developers    'Rdo': ('IntReg', 'uw', '(RD & ~1)', 'IsInteger', 4, maybePCRead, maybePCWrite),
12510037SARM gem5 Developers    'Rde': ('IntReg', 'uw', '(RD | 1)', 'IsInteger', 5, maybePCRead, maybePCWrite),
12610037SARM gem5 Developers
12710037SARM gem5 Developers    'LR': ('IntReg', 'uw', 'INTREG_LR', 'IsInteger', 9),
12810037SARM gem5 Developers    'CondCodes': ('IntReg', 'uw', 'INTREG_CONDCODES', None, 10),
12910037SARM gem5 Developers
13010037SARM gem5 Developers    #Register fields for microops
13110037SARM gem5 Developers    'Ra' : ('IntReg', 'uw', 'ura', 'IsInteger', 11, maybePCRead, maybePCWrite),
13210037SARM gem5 Developers    'Fa' : ('FloatReg', 'sf', 'ura', 'IsFloating', 11),
13310037SARM gem5 Developers    'Rb' : ('IntReg', 'uw', 'urb', 'IsInteger', 12, maybePCRead, maybePCWrite),
13410037SARM gem5 Developers
13510037SARM gem5 Developers    #General Purpose Floating Point Reg Operands
13610037SARM gem5 Developers    'Fd': ('FloatReg', 'df', 'FD', 'IsFloating', 20),
13710037SARM gem5 Developers    'Fn': ('FloatReg', 'df', 'FN', 'IsFloating', 21),
13810037SARM gem5 Developers    'Fm': ('FloatReg', 'df', 'FM', 'IsFloating', 22),
13910037SARM gem5 Developers
14010037SARM gem5 Developers    #Memory Operand
1417351Sgblack@eecs.umich.edu    'Mem': ('Mem', 'uw', None, ('IsMemRef', 'IsLoad', 'IsStore'), 30),
14210037SARM gem5 Developers
14310037SARM gem5 Developers    'Cpsr': ('ControlReg', 'uw', 'MISCREG_CPSR', (None, None, 'IsControl'), 40),
14410037SARM gem5 Developers    'Spsr': ('ControlReg', 'uw', 'MISCREG_SPSR', None, 41),
14510037SARM gem5 Developers    'Fpsr': ('ControlReg', 'uw', 'MISCREG_FPSR', None, 42),
14610037SARM gem5 Developers    'Fpsid': ('ControlReg', 'uw', 'MISCREG_FPSID', None, 43),
14710037SARM gem5 Developers    'Fpscr': ('ControlReg', 'uw', 'MISCREG_FPSCR', None, 44),
14810037SARM gem5 Developers    'Fpexc': ('ControlReg', 'uw', 'MISCREG_FPEXC', None, 45),
14910037SARM gem5 Developers    'NPC': ('NPC', 'ud', None, (None, None, 'IsControl'), 51,
15010037SARM gem5 Developers            readNPC, writeNPC),
15110037SARM gem5 Developers    'FNPC': ('NPC', 'ud', None, (None, None, 'IsControl'), 51,
15210037SARM gem5 Developers             readNPC, forceNPC),
15310037SARM gem5 Developers    'IWNPC': ('NPC', 'ud', None, (None, None, 'IsControl'), 51,
15410037SARM gem5 Developers              readNPC, writeIWNPC),
15510037SARM gem5 Developers}};
15610037SARM gem5 Developers