base.isa revision 12275
13931Ssaidi@eecs.umich.edu// Copyright (c) 2006-2007 The Regents of The University of Michigan
22632Sstever@eecs.umich.edu// All rights reserved.
32632Sstever@eecs.umich.edu//
42632Sstever@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
52632Sstever@eecs.umich.edu// modification, are permitted provided that the following conditions are
62632Sstever@eecs.umich.edu// met: redistributions of source code must retain the above copyright
72632Sstever@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
82632Sstever@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
92632Sstever@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
102632Sstever@eecs.umich.edu// documentation and/or other materials provided with the distribution;
112632Sstever@eecs.umich.edu// neither the name of the copyright holders nor the names of its
122632Sstever@eecs.umich.edu// contributors may be used to endorse or promote products derived from
132632Sstever@eecs.umich.edu// this software without specific prior written permission.
142632Sstever@eecs.umich.edu//
152632Sstever@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162632Sstever@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172632Sstever@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182632Sstever@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192632Sstever@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202632Sstever@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212632Sstever@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222632Sstever@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232632Sstever@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242632Sstever@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252632Sstever@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262632Sstever@eecs.umich.edu//
272632Sstever@eecs.umich.edu// Authors: Ali Saidi
282632Sstever@eecs.umich.edu//          Gabe Black
292632Sstever@eecs.umich.edu//          Steve Reinhardt
302632Sstever@eecs.umich.edu
312482SN/Adef template ROrImmDecode {{
322482SN/A    {
332482SN/A        return (I ? (SparcStaticInst *)(new %(class_name)sImm(machInst))
342482SN/A                  : (SparcStaticInst *)(new %(class_name)s(machInst)));
352482SN/A    }
362482SN/A}};
372482SN/A
384362Sgblack@eecs.umich.eduoutput header {{
394362Sgblack@eecs.umich.edu    union DoubleSingle
404362Sgblack@eecs.umich.edu    {
414362Sgblack@eecs.umich.edu        double d;
424362Sgblack@eecs.umich.edu        uint64_t ui;
434362Sgblack@eecs.umich.edu        uint32_t s[2];
444362Sgblack@eecs.umich.edu        DoubleSingle(double _d) : d(_d)
454362Sgblack@eecs.umich.edu        {}
464362Sgblack@eecs.umich.edu        DoubleSingle(uint64_t _ui) : ui(_ui)
474362Sgblack@eecs.umich.edu        {}
484362Sgblack@eecs.umich.edu        DoubleSingle(uint32_t _s0, uint32_t _s1)
494362Sgblack@eecs.umich.edu        {
504362Sgblack@eecs.umich.edu            s[0] = _s0;
514362Sgblack@eecs.umich.edu            s[1] = _s1;
524362Sgblack@eecs.umich.edu        }
534362Sgblack@eecs.umich.edu    };
544362Sgblack@eecs.umich.edu}};
554362Sgblack@eecs.umich.edu
564362Sgblack@eecs.umich.edulet {{
574362Sgblack@eecs.umich.edu    def filterDoubles(code):
584362Sgblack@eecs.umich.edu        assignRE = re.compile(r'\s*=(?!=)', re.MULTILINE)
594362Sgblack@eecs.umich.edu        for opName in ("Frd", "Frs1", "Frs2", "Frd_N"):
604362Sgblack@eecs.umich.edu            next_pos = 0
614362Sgblack@eecs.umich.edu            operandsREString = (r'''
628588Sgblack@eecs.umich.edu            (?<!\w)             # neg. lookbehind assertion: prevent partial matches
638588Sgblack@eecs.umich.edu            ((%s)(?:_([^\W_]+))?)   # match: operand with optional '.' then suffix
648588Sgblack@eecs.umich.edu            (?!\w)             # neg. lookahead assertion: prevent partial matches
654362Sgblack@eecs.umich.edu            ''' % opName)
664362Sgblack@eecs.umich.edu            operandsRE = re.compile(operandsREString, re.MULTILINE|re.VERBOSE)
674362Sgblack@eecs.umich.edu            is_src = False
684362Sgblack@eecs.umich.edu            is_dest = False
694362Sgblack@eecs.umich.edu            extension = None
704362Sgblack@eecs.umich.edu            foundOne = False
714362Sgblack@eecs.umich.edu            while 1:
724362Sgblack@eecs.umich.edu                match = operandsRE.search(code, next_pos)
734362Sgblack@eecs.umich.edu                if not match:
744362Sgblack@eecs.umich.edu                    break
754362Sgblack@eecs.umich.edu                foundOne = True
764362Sgblack@eecs.umich.edu                op = match.groups()
774362Sgblack@eecs.umich.edu                (op_full, op_base, op_ext) = op
784362Sgblack@eecs.umich.edu                is_dest_local = (assignRE.match(code, match.end()) != None)
794362Sgblack@eecs.umich.edu                is_dest = is_dest or is_dest_local
804362Sgblack@eecs.umich.edu                is_src = is_src or not is_dest_local
814362Sgblack@eecs.umich.edu                if extension and extension != op_ext:
824362Sgblack@eecs.umich.edu                    raise Exception, "Inconsistent extensions in double filter."
834362Sgblack@eecs.umich.edu                extension = op_ext
844362Sgblack@eecs.umich.edu                next_pos = match.end()
854362Sgblack@eecs.umich.edu            if foundOne:
864362Sgblack@eecs.umich.edu                # Get rid of any unwanted extension
874362Sgblack@eecs.umich.edu                code = operandsRE.sub(op_base, code)
884362Sgblack@eecs.umich.edu                is_int = False
894362Sgblack@eecs.umich.edu                member = "d"
904362Sgblack@eecs.umich.edu                if extension in ("sb", "ub", "shw", "uhw", "sw", "uw", "sdw", "udw"):
914362Sgblack@eecs.umich.edu                    is_int = True
924362Sgblack@eecs.umich.edu                    member = "ui"
934362Sgblack@eecs.umich.edu                if is_src:
944362Sgblack@eecs.umich.edu                    code = ("%s = DoubleSingle(%s_high, %s_low).%s;" % \
954362Sgblack@eecs.umich.edu                        (opName, opName, opName, member)) + code
964362Sgblack@eecs.umich.edu                if is_dest:
974362Sgblack@eecs.umich.edu                    code += '''
984362Sgblack@eecs.umich.edu                        %s_low = DoubleSingle(%s).s[1];
994362Sgblack@eecs.umich.edu                        %s_high = DoubleSingle(%s).s[0];''' % \
1004362Sgblack@eecs.umich.edu                             (opName, opName, opName, opName)
1014362Sgblack@eecs.umich.edu                if is_int:
1024362Sgblack@eecs.umich.edu                    code = ("uint64_t %s;" % opName) + code
1034362Sgblack@eecs.umich.edu                else:
1044362Sgblack@eecs.umich.edu                    code = ("double %s;" % opName) + code
1054362Sgblack@eecs.umich.edu        return code
1064362Sgblack@eecs.umich.edu}};
1074362Sgblack@eecs.umich.edu
1082482SN/Alet {{
1092482SN/A    def splitOutImm(code):
1108588Sgblack@eecs.umich.edu        matcher = re.compile(r'Rs(?P<rNum>\d)_or_imm(?P<iNum>\d+)(?P<typeQual>_[^\W_]+)?')
1112482SN/A        rOrImmMatch = matcher.search(code)
1122482SN/A        if (rOrImmMatch == None):
1132516SN/A            return (False, code, '', '', '')
1142516SN/A        rString = rOrImmMatch.group("rNum")
1152614SN/A        if (rOrImmMatch.group("typeQual") != None):
1162614SN/A            rString += rOrImmMatch.group("typeQual")
1172516SN/A        iString = rOrImmMatch.group("iNum")
1182482SN/A        orig_code = code
1192614SN/A        code = matcher.sub('Rs' + rString, orig_code)
1202482SN/A        imm_code = matcher.sub('imm', orig_code)
1212516SN/A        return (True, code, imm_code, rString, iString)
1222030SN/A}};
1232030SN/A
1243931Ssaidi@eecs.umich.eduoutput exec {{
1253931Ssaidi@eecs.umich.edu    /// Check "FP enabled" machine status bit.  Called when executing any FP
1268565Sgblack@eecs.umich.edu    /// instruction.
1273931Ssaidi@eecs.umich.edu    /// @retval Full-system mode: NoFault if FP is enabled, FpDisabled
1283931Ssaidi@eecs.umich.edu    /// if not.  Non-full-system mode: always returns NoFault.
1298565Sgblack@eecs.umich.edu    static inline Fault
13012234Sgabeblack@google.com    checkFpEnableFault(ExecContext *xc)
1313931Ssaidi@eecs.umich.edu    {
1328738Sgblack@eecs.umich.edu        if (FullSystem) {
1338829Sgblack@eecs.umich.edu            PSTATE pstate = xc->readMiscReg(MISCREG_PSTATE);
1348829Sgblack@eecs.umich.edu            if (pstate.pef && xc->readMiscReg(MISCREG_FPRS) & 0x4) {
1358565Sgblack@eecs.umich.edu                return NoFault;
1368565Sgblack@eecs.umich.edu            } else {
13710474Sandreas.hansson@arm.com                return std::make_shared<FpDisabled>();
1388565Sgblack@eecs.umich.edu            }
1398565Sgblack@eecs.umich.edu        } else {
1403931Ssaidi@eecs.umich.edu            return NoFault;
1417741Sgblack@eecs.umich.edu        }
1423931Ssaidi@eecs.umich.edu    }
14312275Sgabeblack@google.com
14412110SRekai.GonzalezAlberquilla@arm.com    static inline Fault
14512234Sgabeblack@google.com    checkVecEnableFault(ExecContext *xc)
14612110SRekai.GonzalezAlberquilla@arm.com    {
14712110SRekai.GonzalezAlberquilla@arm.com        return std::make_shared<VecDisabled>();
14812110SRekai.GonzalezAlberquilla@arm.com    }
1493931Ssaidi@eecs.umich.edu}};
1503931Ssaidi@eecs.umich.edu
1513931Ssaidi@eecs.umich.edu
152