compare_strings.py revision 7087:fb8d5786ff30
19384SAndreas.Sandberg@arm.com# Copyright (c) 2007-2008 The Hewlett-Packard Development Company 29384SAndreas.Sandberg@arm.com# All rights reserved. 39384SAndreas.Sandberg@arm.com# 49384SAndreas.Sandberg@arm.com# The license below extends only to copyright in the software and shall 59384SAndreas.Sandberg@arm.com# not be construed as granting a license to any other intellectual 69384SAndreas.Sandberg@arm.com# property including but not limited to intellectual property relating 79384SAndreas.Sandberg@arm.com# to a hardware implementation of the functionality of the software 89384SAndreas.Sandberg@arm.com# licensed hereunder. You may use the software subject to the license 99384SAndreas.Sandberg@arm.com# terms below provided that you ensure that this notice is replicated 109384SAndreas.Sandberg@arm.com# unmodified and in its entirety in all distributions of the software, 119384SAndreas.Sandberg@arm.com# modified or unmodified, in source code or in binary form. 129384SAndreas.Sandberg@arm.com# 139384SAndreas.Sandberg@arm.com# Redistribution and use in source and binary forms, with or without 149384SAndreas.Sandberg@arm.com# modification, are permitted provided that the following conditions are 159384SAndreas.Sandberg@arm.com# met: redistributions of source code must retain the above copyright 169384SAndreas.Sandberg@arm.com# notice, this list of conditions and the following disclaimer; 179384SAndreas.Sandberg@arm.com# redistributions in binary form must reproduce the above copyright 189384SAndreas.Sandberg@arm.com# notice, this list of conditions and the following disclaimer in the 199384SAndreas.Sandberg@arm.com# documentation and/or other materials provided with the distribution; 209384SAndreas.Sandberg@arm.com# neither the name of the copyright holders nor the names of its 219384SAndreas.Sandberg@arm.com# contributors may be used to endorse or promote products derived from 229384SAndreas.Sandberg@arm.com# this software without specific prior written permission. 239384SAndreas.Sandberg@arm.com# 249384SAndreas.Sandberg@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 259384SAndreas.Sandberg@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 269384SAndreas.Sandberg@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 279384SAndreas.Sandberg@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 289384SAndreas.Sandberg@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 299384SAndreas.Sandberg@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 309384SAndreas.Sandberg@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 319384SAndreas.Sandberg@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 329384SAndreas.Sandberg@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 339384SAndreas.Sandberg@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 349384SAndreas.Sandberg@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 359384SAndreas.Sandberg@arm.com# 369384SAndreas.Sandberg@arm.com# Authors: Gabe Black 379384SAndreas.Sandberg@arm.com 389384SAndreas.Sandberg@arm.commicrocode = ''' 399384SAndreas.Sandberg@arm.comdef macroop CMPS_M_M { 409384SAndreas.Sandberg@arm.com # Find the constant we need to either add or subtract from rdi 419384SAndreas.Sandberg@arm.com ruflag t0, 10 429384SAndreas.Sandberg@arm.com movi t3, t3, dsz, flags=(CEZF,), dataSize=asz 439384SAndreas.Sandberg@arm.com subi t4, t0, dsz, dataSize=asz 44 mov t3, t3, t4, flags=(nCEZF,), dataSize=asz 45 46 ld t1, seg, [1, t0, rsi] 47 ld t2, es, [1, t0, rdi] 48 sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) 49 50 add rdi, rdi, t3, dataSize=asz 51 add rsi, rsi, t3, dataSize=asz 52}; 53 54# 55# Versions which have the rep prefix. These could benefit from some loop 56# unrolling. 57# 58 59def macroop CMPS_E_M_M { 60 and t0, rcx, rcx, flags=(EZF,), dataSize=asz 61 br label("end"), flags=(CEZF,) 62 63 # Find the constant we need to either add or subtract from rdi 64 ruflag t0, 10 65 movi t3, t3, dsz, flags=(CEZF,), dataSize=asz 66 subi t4, t0, dsz, dataSize=asz 67 mov t3, t3, t4, flags=(nCEZF,), dataSize=asz 68 69topOfLoop: 70 ld t1, seg, [1, t0, rsi] 71 ld t2, es, [1, t0, rdi] 72 sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) 73 74 subi rcx, rcx, 1, flags=(EZF,), dataSize=asz 75 add rdi, rdi, t3, dataSize=asz 76 add rsi, rsi, t3, dataSize=asz 77 br label("topOfLoop"), flags=(CSTRZnEZF,) 78end: 79 fault "NoFault" 80}; 81 82def macroop CMPS_N_M_M { 83 and t0, rcx, rcx, flags=(EZF,), dataSize=asz 84 br label("end"), flags=(CEZF,) 85 86 # Find the constant we need to either add or subtract from rdi 87 ruflag t0, 10 88 movi t3, t3, dsz, flags=(CEZF,), dataSize=asz 89 subi t4, t0, dsz, dataSize=asz 90 mov t3, t3, t4, flags=(nCEZF,), dataSize=asz 91 92topOfLoop: 93 ld t1, seg, [1, t0, rsi] 94 ld t2, es, [1, t0, rdi] 95 sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) 96 97 subi rcx, rcx, 1, flags=(EZF,), dataSize=asz 98 add rdi, rdi, t3, dataSize=asz 99 add rsi, rsi, t3, dataSize=asz 100 br label("topOfLoop"), flags=(CSTRnZnEZF,) 101end: 102 fault "NoFault" 103}; 104''' 105