div.isa revision 7760
17318Sgblack@eecs.umich.edu// -*- mode:c++ -*-
27318Sgblack@eecs.umich.edu
37318Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited
47318Sgblack@eecs.umich.edu// All rights reserved
57318Sgblack@eecs.umich.edu//
67318Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall
77318Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual
87318Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating
97318Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software
107318Sgblack@eecs.umich.edu// licensed hereunder.  You may use the software subject to the license
117318Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated
127318Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software,
137318Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form.
147318Sgblack@eecs.umich.edu//
157318Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
167318Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
177318Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright
187318Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
197318Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
207318Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
217318Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution;
227318Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its
237318Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
247318Sgblack@eecs.umich.edu// this software without specific prior written permission.
257318Sgblack@eecs.umich.edu//
267318Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
277318Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
287318Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
297318Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
307318Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
317318Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
327318Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
337318Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
347318Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
357318Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
367318Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
377318Sgblack@eecs.umich.edu//
387318Sgblack@eecs.umich.edu// Authors: Gabe Black
397318Sgblack@eecs.umich.edu
407318Sgblack@eecs.umich.edulet {{
417318Sgblack@eecs.umich.edu    sdivCode = '''
427318Sgblack@eecs.umich.edu    if (Op2.sw == 0) {
437361Sgblack@eecs.umich.edu        if (((SCTLR)Sctlr).dz) {
447361Sgblack@eecs.umich.edu#if FULL_SYSTEM
457361Sgblack@eecs.umich.edu            return new UndefinedInstruction;
467361Sgblack@eecs.umich.edu#else
477361Sgblack@eecs.umich.edu            return new UndefinedInstruction(false, mnemonic);
487361Sgblack@eecs.umich.edu#endif
497361Sgblack@eecs.umich.edu        }
507318Sgblack@eecs.umich.edu        Dest.sw = 0;
517318Sgblack@eecs.umich.edu    } else if (Op1.sw == INT_MIN && Op2.sw == -1) {
527318Sgblack@eecs.umich.edu        Dest.sw = INT_MIN;
537318Sgblack@eecs.umich.edu    } else {
547318Sgblack@eecs.umich.edu        Dest.sw = Op1.sw / Op2.sw;
557318Sgblack@eecs.umich.edu    }
567318Sgblack@eecs.umich.edu    '''
577318Sgblack@eecs.umich.edu    sdivIop = InstObjParams("sdiv", "Sdiv", "RegRegRegOp",
587318Sgblack@eecs.umich.edu                            { "code": sdivCode,
597760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
607760SGiacomo.Gabrielli@arm.com                              "op_class": "IntDivOp"}, [])
617318Sgblack@eecs.umich.edu    header_output = RegRegRegOpDeclare.subst(sdivIop)
627318Sgblack@eecs.umich.edu    decoder_output = RegRegRegOpConstructor.subst(sdivIop)
637318Sgblack@eecs.umich.edu    exec_output = PredOpExecute.subst(sdivIop)
647319Sgblack@eecs.umich.edu
657319Sgblack@eecs.umich.edu    udivCode = '''
667319Sgblack@eecs.umich.edu    if (Op2.uw == 0) {
677361Sgblack@eecs.umich.edu        if (((SCTLR)Sctlr).dz) {
687361Sgblack@eecs.umich.edu#if FULL_SYSTEM
697361Sgblack@eecs.umich.edu            return new UndefinedInstruction;
707361Sgblack@eecs.umich.edu#else
717361Sgblack@eecs.umich.edu            return new UndefinedInstruction(false, mnemonic);
727361Sgblack@eecs.umich.edu#endif
737361Sgblack@eecs.umich.edu        }
747319Sgblack@eecs.umich.edu        Dest.uw = 0;
757319Sgblack@eecs.umich.edu    } else {
767319Sgblack@eecs.umich.edu        Dest.uw = Op1.uw / Op2.uw;
777319Sgblack@eecs.umich.edu    }
787319Sgblack@eecs.umich.edu    '''
797319Sgblack@eecs.umich.edu    udivIop = InstObjParams("udiv", "Udiv", "RegRegRegOp",
807319Sgblack@eecs.umich.edu                            { "code": udivCode,
817760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
827760SGiacomo.Gabrielli@arm.com                              "op_class": "IntDivOp"}, [])
837319Sgblack@eecs.umich.edu    header_output += RegRegRegOpDeclare.subst(udivIop)
847319Sgblack@eecs.umich.edu    decoder_output += RegRegRegOpConstructor.subst(udivIop)
857319Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(udivIop)
867318Sgblack@eecs.umich.edu}};
87