str.isa revision 7120
17119SN/A// -*- mode:c++ -*- 27119SN/A 37119SN/A// Copyright (c) 2010 ARM Limited 47119SN/A// All rights reserved 57119SN/A// 67119SN/A// The license below extends only to copyright in the software and shall 77119SN/A// not be construed as granting a license to any other intellectual 87119SN/A// property including but not limited to intellectual property relating 97119SN/A// to a hardware implementation of the functionality of the software 107119SN/A// licensed hereunder. You may use the software subject to the license 117119SN/A// terms below provided that you ensure that this notice is replicated 127119SN/A// unmodified and in its entirety in all distributions of the software, 137119SN/A// modified or unmodified, in source code or in binary form. 147119SN/A// 157119SN/A// Redistribution and use in source and binary forms, with or without 167119SN/A// modification, are permitted provided that the following conditions are 177119SN/A// met: redistributions of source code must retain the above copyright 187119SN/A// notice, this list of conditions and the following disclaimer; 197119SN/A// redistributions in binary form must reproduce the above copyright 207119SN/A// notice, this list of conditions and the following disclaimer in the 217119SN/A// documentation and/or other materials provided with the distribution; 227119SN/A// neither the name of the copyright holders nor the names of its 237119SN/A// contributors may be used to endorse or promote products derived from 247119SN/A// this software without specific prior written permission. 257119SN/A// 267119SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 277119SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 287119SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 297119SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 307119SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 317119SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 327119SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 337119SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 347119SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 357119SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 367119SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 377119SN/A// 387119SN/A// Authors: Gabe Black 397119SN/A 407119SN/Alet {{ 417119SN/A 427119SN/A header_output = "" 437119SN/A decoder_output = "" 447119SN/A exec_output = "" 457119SN/A 467120Sgblack@eecs.umich.edu def storeImmClassName(post, add, writeback, \ 477120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 487120Sgblack@eecs.umich.edu return memClassName("STORE_IMM", post, add, writeback, 497119SN/A size, sign, user) 507119SN/A 517120Sgblack@eecs.umich.edu def storeRegClassName(post, add, writeback, \ 527120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 537120Sgblack@eecs.umich.edu return memClassName("STORE_REG", post, add, writeback, 547119SN/A size, sign, user) 557119SN/A 567120Sgblack@eecs.umich.edu def emitStore(name, Name, imm, eaCode, accCode, memFlags, instFlags, base): 577119SN/A global header_output, decoder_output, exec_output 587119SN/A 597119SN/A (newHeader, 607119SN/A newDecoder, 617119SN/A newExec) = newLoadStoreBase(name, Name, imm, 627119SN/A eaCode, accCode, 637119SN/A memFlags, instFlags, 647120Sgblack@eecs.umich.edu base, execTemplateBase = 'Store') 657119SN/A 667119SN/A header_output += newHeader 677119SN/A decoder_output += newDecoder 687119SN/A exec_output += newExec 697119SN/A 707120Sgblack@eecs.umich.edu def buildImmStore(mnem, post, add, writeback, \ 717120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 727119SN/A name = mnem 737120Sgblack@eecs.umich.edu Name = storeImmClassName(post, add, writeback, \ 747120Sgblack@eecs.umich.edu size, sign, user) 757119SN/A 767119SN/A if add: 777119SN/A op = " +" 787119SN/A else: 797119SN/A op = " -" 807119SN/A 817119SN/A offset = op + " imm" 827119SN/A eaCode = "EA = Base" 837119SN/A if not post: 847119SN/A eaCode += offset 857119SN/A eaCode += ";" 867119SN/A 877120Sgblack@eecs.umich.edu accCode = "Mem%s = Dest;\n" % buildMemSuffix(sign, size) 887119SN/A if writeback: 897119SN/A accCode += "Base = Base %s;\n" % offset 907119SN/A base = buildMemBase("MemoryNewImm", post, writeback) 917119SN/A 927120Sgblack@eecs.umich.edu emitStore(name, Name, True, eaCode, accCode, [], [], base) 937119SN/A 947120Sgblack@eecs.umich.edu def buildRegStore(mnem, post, add, writeback, \ 957120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 967119SN/A name = mnem 977120Sgblack@eecs.umich.edu Name = storeRegClassName(post, add, writeback, 987120Sgblack@eecs.umich.edu size, sign, user) 997119SN/A 1007119SN/A if add: 1017119SN/A op = " +" 1027119SN/A else: 1037119SN/A op = " -" 1047119SN/A 1057119SN/A offset = op + " shift_rm_imm(Index, shiftAmt," + \ 1067119SN/A " shiftType, CondCodes<29:>)" 1077119SN/A eaCode = "EA = Base" 1087119SN/A if not post: 1097119SN/A eaCode += offset 1107119SN/A eaCode += ";" 1117119SN/A 1127120Sgblack@eecs.umich.edu accCode = "Mem%s = Dest;\n" % buildMemSuffix(sign, size) 1137119SN/A if writeback: 1147119SN/A accCode += "Base = Base %s;\n" % offset 1157119SN/A base = buildMemBase("MemoryNewReg", post, writeback) 1167119SN/A 1177120Sgblack@eecs.umich.edu emitStore(name, Name, False, eaCode, accCode, [], [], base) 1187119SN/A 1197120Sgblack@eecs.umich.edu def buildStores(mnem, size=4, sign=False, user=False): 1207120Sgblack@eecs.umich.edu buildImmStore(mnem, True, True, True, size, sign, user) 1217120Sgblack@eecs.umich.edu buildRegStore(mnem, True, True, True, size, sign, user) 1227120Sgblack@eecs.umich.edu buildImmStore(mnem, True, False, True, size, sign, user) 1237120Sgblack@eecs.umich.edu buildRegStore(mnem, True, False, True, size, sign, user) 1247120Sgblack@eecs.umich.edu buildImmStore(mnem, False, True, True, size, sign, user) 1257120Sgblack@eecs.umich.edu buildRegStore(mnem, False, True, True, size, sign, user) 1267120Sgblack@eecs.umich.edu buildImmStore(mnem, False, False, True, size, sign, user) 1277120Sgblack@eecs.umich.edu buildRegStore(mnem, False, False, True, size, sign, user) 1287120Sgblack@eecs.umich.edu buildImmStore(mnem, False, True, False, size, sign, user) 1297120Sgblack@eecs.umich.edu buildRegStore(mnem, False, True, False, size, sign, user) 1307120Sgblack@eecs.umich.edu buildImmStore(mnem, False, False, False, size, sign, user) 1317120Sgblack@eecs.umich.edu buildRegStore(mnem, False, False, False, size, sign, user) 1327119SN/A 1337120Sgblack@eecs.umich.edu buildStores("str") 1347120Sgblack@eecs.umich.edu buildStores("strt", user=True) 1357120Sgblack@eecs.umich.edu buildStores("strb", size=1) 1367120Sgblack@eecs.umich.edu buildStores("strbt", size=1, user=True) 1377120Sgblack@eecs.umich.edu buildStores("strh", size=2) 1387120Sgblack@eecs.umich.edu buildStores("strht", size=2, user=True) 1397119SN/A}}; 140