logical.py revision 5081
12SN/A# Copyright (c) 2007 The Hewlett-Packard Development Company
21762SN/A# All rights reserved.
32SN/A#
42SN/A# Redistribution and use of this software in source and binary forms,
52SN/A# with or without modification, are permitted provided that the
62SN/A# following conditions are met:
72SN/A#
82SN/A# The software must be used only for Non-Commercial Use which means any
92SN/A# use which is NOT directed to receiving any direct monetary
102SN/A# compensation for, or commercial advantage from such use.  Illustrative
112SN/A# examples of non-commercial use are academic research, personal study,
122SN/A# teaching, education and corporate research & development.
132SN/A# Illustrative examples of commercial use are distributing products for
142SN/A# commercial advantage and providing services using the software for
152SN/A# commercial advantage.
162SN/A#
172SN/A# If you wish to use this software or functionality therein that may be
182SN/A# covered by patents for commercial use, please contact:
192SN/A#     Director of Intellectual Property Licensing
202SN/A#     Office of Strategy and Technology
212SN/A#     Hewlett-Packard Company
222SN/A#     1501 Page Mill Road
232SN/A#     Palo Alto, California  94304
242SN/A#
252SN/A# Redistributions of source code must retain the above copyright notice,
262SN/A# this list of conditions and the following disclaimer.  Redistributions
272665Ssaidi@eecs.umich.edu# in binary form must reproduce the above copyright notice, this list of
282665Ssaidi@eecs.umich.edu# conditions and the following disclaimer in the documentation and/or
292665Ssaidi@eecs.umich.edu# other materials provided with the distribution.  Neither the name of
302SN/A# the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
312SN/A# contributors may be used to endorse or promote products derived from
322SN/A# this software without specific prior written permission.  No right of
332SN/A# sublicense is granted herewith.  Derivatives of the software and
342SN/A# output created using the software may be prepared, but only for
352SN/A# Non-Commercial Uses.  Derivatives of the software may be shared with
361354SN/A# others provided: (i) the others agree to abide by the list of
371354SN/A# conditions herein which includes the Non-Commercial Use restrictions;
382SN/A# and (ii) such Derivatives of the software include the above copyright
392SN/A# notice to acknowledge the contribution from this software where
405501Snate@binkert.org# applicable, this list of conditions and the disclaimer below.
415546Snate@binkert.org#
427004Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
432SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
442SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4556SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
465769Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
472361SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
481354SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
496216Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5056SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
512SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
525543Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
532SN/A#
541354SN/A# Authors: Gabe Black
551354SN/A
562SN/Amicrocode = '''
572SN/Adef macroop OR_R_R
582SN/A{
592SN/A    or reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
605501Snate@binkert.org};
615501Snate@binkert.org
622SN/Adef macroop OR_M_I
63395SN/A{
642SN/A    limm t2, imm
652SN/A    ld t1, seg, sib, disp
662SN/A    or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
675769Snate@binkert.org    st t1, seg, sib, disp
685769Snate@binkert.org};
695769Snate@binkert.org
705769Snate@binkert.orgdef macroop OR_P_I
717059Snate@binkert.org{
727059Snate@binkert.org    limm t2, imm
737059Snate@binkert.org    rdip t7
747059Snate@binkert.org    ld t1, seg, riprel, disp
757059Snate@binkert.org    or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
767059Snate@binkert.org    st t1, seg, riprel, disp
777059Snate@binkert.org};
787059Snate@binkert.org
797059Snate@binkert.orgdef macroop OR_M_R
807059Snate@binkert.org{
817059Snate@binkert.org    ld t1, seg, sib, disp
827059Snate@binkert.org    or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
837059Snate@binkert.org    st t1, seg, sib, disp
847059Snate@binkert.org};
857059Snate@binkert.org
867059Snate@binkert.orgdef macroop OR_P_R
875769Snate@binkert.org{
887058Snate@binkert.org    rdip t7
897058Snate@binkert.org    ld t1, seg, riprel, disp
907058Snate@binkert.org    or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
912SN/A    st t1, seg, riprel, disp
925502Snate@binkert.org};
935502Snate@binkert.org
945502Snate@binkert.orgdef macroop OR_R_M
955503Snate@binkert.org{
965503Snate@binkert.org    ld t1, seg, sib, disp
975502Snate@binkert.org    or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
985502Snate@binkert.org};
995502Snate@binkert.org
1005502Snate@binkert.orgdef macroop OR_R_P
1015502Snate@binkert.org{
1025502Snate@binkert.org    rdip t7
1035502Snate@binkert.org    ld t1, seg, riprel, disp
1045602Snate@binkert.org    or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
1055602Snate@binkert.org};
1065501Snate@binkert.org
1075543Ssaidi@eecs.umich.edudef macroop OR_R_I
1087058Snate@binkert.org{
1095769Snate@binkert.org    limm t1, imm
1104016Sstever@eecs.umich.edu    or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
1114016Sstever@eecs.umich.edu};
1124016Sstever@eecs.umich.edu
1134016Sstever@eecs.umich.edudef macroop XOR_R_R
1144016Sstever@eecs.umich.edu{
1154016Sstever@eecs.umich.edu    xor reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
1164016Sstever@eecs.umich.edu};
1174016Sstever@eecs.umich.edu
1184016Sstever@eecs.umich.edudef macroop XOR_R_I
1195501Snate@binkert.org{
1205605Snate@binkert.org    limm t1, imm
1215605Snate@binkert.org    xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
1225605Snate@binkert.org};
1235605Snate@binkert.org
1245501Snate@binkert.orgdef macroop XOR_M_I
1254016Sstever@eecs.umich.edu{
1265577SSteve.Reinhardt@amd.com    limm t2, imm
1275501Snate@binkert.org    ld t1, seg, sib, disp
1285501Snate@binkert.org    xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
1295501Snate@binkert.org    st t1, seg, sib, disp
1305502Snate@binkert.org};
1315502Snate@binkert.org
1325605Snate@binkert.orgdef macroop XOR_P_I
1335502Snate@binkert.org{
1345502Snate@binkert.org    limm t2, imm
1355605Snate@binkert.org    rdip t7
1365605Snate@binkert.org    ld t1, seg, riprel, disp
1375605Snate@binkert.org    xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
1385577SSteve.Reinhardt@amd.com    st t1, seg, riprel, disp
1395502Snate@binkert.org};
1405502Snate@binkert.org
1415502Snate@binkert.orgdef macroop XOR_M_R
1425502Snate@binkert.org{
1432SN/A    ld t1, seg, sib, disp
1445769Snate@binkert.org    xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
1455769Snate@binkert.org    st t1, seg, sib, disp
1465769Snate@binkert.org};
1475769Snate@binkert.org
1485769Snate@binkert.orgdef macroop XOR_P_R
1495769Snate@binkert.org{
1502SN/A    rdip t7
1515769Snate@binkert.org    ld t1, seg, riprel, disp
1525769Snate@binkert.org    xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
1535769Snate@binkert.org    st t1, seg, riprel, disp
1547059Snate@binkert.org};
1555769Snate@binkert.org
1565769Snate@binkert.orgdef macroop XOR_R_M
1572SN/A{
1585769Snate@binkert.org    ld t1, seg, sib, disp
1595769Snate@binkert.org    xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
1605769Snate@binkert.org};
1615769Snate@binkert.org
1625769Snate@binkert.orgdef macroop XOR_R_P
1635769Snate@binkert.org{
1645769Snate@binkert.org    rdip t7
1655769Snate@binkert.org    ld t1, seg, riprel, disp
1665769Snate@binkert.org    xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
1675769Snate@binkert.org};
1685769Snate@binkert.org
1695769Snate@binkert.orgdef macroop AND_R_R
1705769Snate@binkert.org{
1715769Snate@binkert.org    and reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
1725769Snate@binkert.org};
1735769Snate@binkert.org
1745769Snate@binkert.orgdef macroop AND_R_M
1755769Snate@binkert.org{
1765769Snate@binkert.org    ld t1, seg, sib, disp
1775769Snate@binkert.org    and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
1785769Snate@binkert.org};
1795769Snate@binkert.org
1805769Snate@binkert.orgdef macroop AND_R_P
1815769Snate@binkert.org{
1825769Snate@binkert.org    rdip t7
1835769Snate@binkert.org    ld t1, seg, riprel, disp
1845769Snate@binkert.org    and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
1855769Snate@binkert.org};
1865501Snate@binkert.org
1875543Ssaidi@eecs.umich.edudef macroop AND_R_I
1882SN/A{
1892SN/A    limm t1, imm
190396SN/A    and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
191396SN/A};
192396SN/A
193396SN/Adef macroop AND_M_I
1945501Snate@binkert.org{
1957058Snate@binkert.org    ld t2, seg, sib, disp
1967058Snate@binkert.org    limm t1, imm
1973329Sstever@eecs.umich.edu    and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
1987058Snate@binkert.org    st t2, seg, sib, disp
1997058Snate@binkert.org};
2007058Snate@binkert.org
2017058Snate@binkert.orgdef macroop AND_P_I
202396SN/A{
2037058Snate@binkert.org    rdip t7
2047058Snate@binkert.org    ld t2, seg, riprel, disp
2057058Snate@binkert.org    limm t1, imm
2067058Snate@binkert.org    and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
2073329Sstever@eecs.umich.edu    st t2, seg, riprel, disp
2087058Snate@binkert.org};
2097058Snate@binkert.org
2107058Snate@binkert.orgdef macroop AND_M_R
2117058Snate@binkert.org{
2127058Snate@binkert.org    ld t1, seg, sib, disp
213396SN/A    and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
2147058Snate@binkert.org    st t1, seg, sib, disp
2157058Snate@binkert.org};
2167058Snate@binkert.org
2177058Snate@binkert.orgdef macroop AND_P_R
218396SN/A{
2197058Snate@binkert.org    rdip t7
2207058Snate@binkert.org    ld t1, seg, riprel, disp
221396SN/A    and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
2227058Snate@binkert.org    st t1, seg, riprel, disp
2237058Snate@binkert.org};
2247058Snate@binkert.org
2257058Snate@binkert.orgdef macroop NOT_R
226396SN/A{
2277058Snate@binkert.org    limm t1, -1
2287058Snate@binkert.org    xor reg, reg, t1
2297058Snate@binkert.org};
230396SN/A
2317058Snate@binkert.orgdef macroop NOT_M
2327058Snate@binkert.org{
2337058Snate@binkert.org    limm t1, -1
2344075Sbinkertn@umich.edu    ld t2, seg, sib, disp
2357058Snate@binkert.org    xor t2, t2, t1
2367058Snate@binkert.org    st t2, seg, sib, disp
2375501Snate@binkert.org};
2387058Snate@binkert.org
2397058Snate@binkert.orgdef macroop NOT_P
2407058Snate@binkert.org{
2417058Snate@binkert.org    limm t1, -1
2427058Snate@binkert.org    rdip t7
2437058Snate@binkert.org    ld t2, seg, riprel, disp
244396SN/A    xor t2, t2, t1
2452SN/A    st t2, seg, riprel, disp
2462SN/A};
2472SN/A'''
2482SN/A