mem.isa revision 7120
16019Shines@cs.fsu.edu// -*- mode:c++ -*- 26019Shines@cs.fsu.edu 37100Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited 47100Sgblack@eecs.umich.edu// All rights reserved 57100Sgblack@eecs.umich.edu// 67100Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall 77100Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual 87100Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating 97100Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software 107100Sgblack@eecs.umich.edu// licensed hereunder. You may use the software subject to the license 117100Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated 127100Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software, 137100Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form. 147100Sgblack@eecs.umich.edu// 156019Shines@cs.fsu.edu// Redistribution and use in source and binary forms, with or without 166019Shines@cs.fsu.edu// modification, are permitted provided that the following conditions are 176019Shines@cs.fsu.edu// met: redistributions of source code must retain the above copyright 186019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer; 196019Shines@cs.fsu.edu// redistributions in binary form must reproduce the above copyright 206019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer in the 216019Shines@cs.fsu.edu// documentation and/or other materials provided with the distribution; 226019Shines@cs.fsu.edu// neither the name of the copyright holders nor the names of its 236019Shines@cs.fsu.edu// contributors may be used to endorse or promote products derived from 246019Shines@cs.fsu.edu// this software without specific prior written permission. 256019Shines@cs.fsu.edu// 266019Shines@cs.fsu.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 276019Shines@cs.fsu.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 286019Shines@cs.fsu.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 296019Shines@cs.fsu.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 306019Shines@cs.fsu.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 316019Shines@cs.fsu.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 326019Shines@cs.fsu.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 336019Shines@cs.fsu.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 346019Shines@cs.fsu.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 356019Shines@cs.fsu.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 366019Shines@cs.fsu.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 376019Shines@cs.fsu.edu// 386019Shines@cs.fsu.edu// Authors: Gabe Black 396019Shines@cs.fsu.edu 406019Shines@cs.fsu.edulet {{ 416019Shines@cs.fsu.edu def newLoadStoreBase(name, Name, imm, eaCode, accCode, memFlags, 426757SAli.Saidi@ARM.com instFlags, base = 'MemoryNew', execTemplateBase = ''): 436019Shines@cs.fsu.edu # Make sure flags are in lists (convert to lists if not). 446019Shines@cs.fsu.edu memFlags = makeList(memFlags) 456019Shines@cs.fsu.edu instFlags = makeList(instFlags) 466019Shines@cs.fsu.edu 476019Shines@cs.fsu.edu # This shouldn't be part of the eaCode, but until the exec templates 486019Shines@cs.fsu.edu # are converted over it's the easiest place to put it. 496019Shines@cs.fsu.edu eaCode += '\n unsigned memAccessFlags = ' 506019Shines@cs.fsu.edu if memFlags: 517170Sgblack@eecs.umich.edu eaCode += (string.join(memFlags, '|') + ';') 526253Sgblack@eecs.umich.edu else: 537202Sgblack@eecs.umich.edu eaCode += '0;' 546253Sgblack@eecs.umich.edu 556253Sgblack@eecs.umich.edu predicateTest = 'testPredicate(CondCodes, condCode)' 567396Sgblack@eecs.umich.edu 577405SAli.Saidi@ARM.com iop = InstObjParams(name, Name, base, 587259Sgblack@eecs.umich.edu {'ea_code': eaCode, 597423Sgblack@eecs.umich.edu 'memacc_code': accCode, 606397Sgblack@eecs.umich.edu 'predicate_test': predicateTest}, 616019Shines@cs.fsu.edu instFlags) 626757SAli.Saidi@ARM.com 637752SWilliam.Wang@arm.com fullExecTemplate = eval(execTemplateBase + 'Execute') 646019Shines@cs.fsu.edu initiateAccTemplate = eval(execTemplateBase + 'InitiateAcc') 656397Sgblack@eecs.umich.edu completeAccTemplate = eval(execTemplateBase + 'CompleteAcc') 666019Shines@cs.fsu.edu 676397Sgblack@eecs.umich.edu if imm: 686019Shines@cs.fsu.edu declareTemplate = LoadStoreImmDeclare 697404SAli.Saidi@ARM.com constructTemplate = LoadStoreImmConstructor 706735Sgblack@eecs.umich.edu else: 717100Sgblack@eecs.umich.edu declareTemplate = LoadStoreRegDeclare 726019Shines@cs.fsu.edu constructTemplate = LoadStoreRegConstructor 736757SAli.Saidi@ARM.com 746757SAli.Saidi@ARM.com # (header_output, decoder_output, decode_block, exec_output) 756757SAli.Saidi@ARM.com return (declareTemplate.subst(iop), 767694SAli.Saidi@ARM.com constructTemplate.subst(iop), 777585SAli.Saidi@arm.com fullExecTemplate.subst(iop) 787404SAli.Saidi@ARM.com + initiateAccTemplate.subst(iop) 796757SAli.Saidi@ARM.com + completeAccTemplate.subst(iop)) 806757SAli.Saidi@ARM.com 816757SAli.Saidi@ARM.com def memClassName(base, post, add, writeback, \ 826019Shines@cs.fsu.edu size=4, sign=False, user=False): 836019Shines@cs.fsu.edu Name = base 846019Shines@cs.fsu.edu 856019Shines@cs.fsu.edu if post: 866019Shines@cs.fsu.edu Name += '_PY' 876019Shines@cs.fsu.edu else: 886019Shines@cs.fsu.edu Name += '_PN' 896019Shines@cs.fsu.edu 906019Shines@cs.fsu.edu if add: 916019Shines@cs.fsu.edu Name += '_AY' 926019Shines@cs.fsu.edu else: 936019Shines@cs.fsu.edu Name += '_AN' 94 95 if writeback: 96 Name += '_WY' 97 else: 98 Name += '_WN' 99 100 Name += ('_SZ%d' % size) 101 102 if sign: 103 Name += '_SY' 104 else: 105 Name += '_SN' 106 107 if user: 108 Name += '_UY' 109 else: 110 Name += '_UN' 111 112 return Name 113 114 def buildMemSuffix(sign, size): 115 if size == 4: 116 memSuffix = '' 117 elif size == 2: 118 if sign: 119 memSuffix = '.sh' 120 else: 121 memSuffix = '.uh' 122 elif size == 1: 123 if sign: 124 memSuffix = '.sb' 125 else: 126 memSuffix = '.ub' 127 else: 128 raise Exception, "Unrecognized size for load %d" % size 129 130 return memSuffix 131 132 def buildMemBase(base, post, writeback): 133 if post and writeback: 134 base = "MemoryNewPostIndex<%s>" % base 135 elif not post and writeback: 136 base = "MemoryNewPreIndex<%s>" % base 137 elif not post and not writeback: 138 base = "MemoryNewOffset<%s>" % base 139 else: 140 raise Exception, "Illegal combination of post and writeback" 141 return base 142}}; 143 144