branch.isa revision 7154
16019Shines@cs.fsu.edu// -*- mode:c++ -*- 26019Shines@cs.fsu.edu 37152Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited 47152Sgblack@eecs.umich.edu// All rights reserved 57152Sgblack@eecs.umich.edu// 67152Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall 77152Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual 87152Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating 97152Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software 107152Sgblack@eecs.umich.edu// licensed hereunder. You may use the software subject to the license 117152Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated 127152Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software, 137152Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form. 147152Sgblack@eecs.umich.edu// 156019Shines@cs.fsu.edu// Copyright (c) 2007-2008 The Florida State University 166019Shines@cs.fsu.edu// All rights reserved. 176019Shines@cs.fsu.edu// 186019Shines@cs.fsu.edu// Redistribution and use in source and binary forms, with or without 196019Shines@cs.fsu.edu// modification, are permitted provided that the following conditions are 206019Shines@cs.fsu.edu// met: redistributions of source code must retain the above copyright 216019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer; 226019Shines@cs.fsu.edu// redistributions in binary form must reproduce the above copyright 236019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer in the 246019Shines@cs.fsu.edu// documentation and/or other materials provided with the distribution; 256019Shines@cs.fsu.edu// neither the name of the copyright holders nor the names of its 266019Shines@cs.fsu.edu// contributors may be used to endorse or promote products derived from 276019Shines@cs.fsu.edu// this software without specific prior written permission. 286019Shines@cs.fsu.edu// 296019Shines@cs.fsu.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 306019Shines@cs.fsu.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 316019Shines@cs.fsu.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 326019Shines@cs.fsu.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 336019Shines@cs.fsu.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 346019Shines@cs.fsu.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 356019Shines@cs.fsu.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 366019Shines@cs.fsu.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 376019Shines@cs.fsu.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 386019Shines@cs.fsu.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 396019Shines@cs.fsu.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 406019Shines@cs.fsu.edu// 416019Shines@cs.fsu.edu// Authors: Stephen Hines 426019Shines@cs.fsu.edu 436019Shines@cs.fsu.edu//////////////////////////////////////////////////////////////////// 446019Shines@cs.fsu.edu// 456019Shines@cs.fsu.edu// Control transfer instructions 466019Shines@cs.fsu.edu// 476019Shines@cs.fsu.edu 487152Sgblack@eecs.umich.edudef format ArmBBlxImm() {{ 497152Sgblack@eecs.umich.edu decode_block = ''' 507152Sgblack@eecs.umich.edu if (machInst.condCode == 0xF) { 517152Sgblack@eecs.umich.edu int32_t imm = (sext<26>(bits(machInst, 23, 0) << 2)) | 527152Sgblack@eecs.umich.edu (bits(machInst, 24) << 1); 537152Sgblack@eecs.umich.edu return new BlxImm(machInst, imm); 547152Sgblack@eecs.umich.edu } else { 557152Sgblack@eecs.umich.edu return new B(machInst, sext<26>(bits(machInst, 23, 0) << 2), 567152Sgblack@eecs.umich.edu (ConditionCode)(uint32_t)machInst.condCode); 577152Sgblack@eecs.umich.edu } 587152Sgblack@eecs.umich.edu ''' 597152Sgblack@eecs.umich.edu}}; 607152Sgblack@eecs.umich.edu 617152Sgblack@eecs.umich.edudef format ArmBlBlxImm() {{ 627152Sgblack@eecs.umich.edu decode_block = ''' 637152Sgblack@eecs.umich.edu if (machInst.condCode == 0xF) { 647152Sgblack@eecs.umich.edu int32_t imm = (sext<26>(bits(machInst, 23, 0) << 2)) | 657152Sgblack@eecs.umich.edu (bits(machInst, 24) << 1); 667152Sgblack@eecs.umich.edu return new BlxImm(machInst, imm); 677152Sgblack@eecs.umich.edu } else { 687152Sgblack@eecs.umich.edu return new Bl(machInst, sext<26>(bits(machInst, 23, 0) << 2), 697152Sgblack@eecs.umich.edu (ConditionCode)(uint32_t)machInst.condCode); 707152Sgblack@eecs.umich.edu } 717152Sgblack@eecs.umich.edu ''' 727152Sgblack@eecs.umich.edu}}; 737152Sgblack@eecs.umich.edu 747152Sgblack@eecs.umich.edudef format ArmBx() {{ 757152Sgblack@eecs.umich.edu decode_block = ''' 767152Sgblack@eecs.umich.edu return new BxReg(machInst, (IntRegIndex)(uint32_t)bits(machInst, 3, 0), 777152Sgblack@eecs.umich.edu (ConditionCode)(uint32_t)machInst.condCode); 787152Sgblack@eecs.umich.edu ''' 797152Sgblack@eecs.umich.edu}}; 807152Sgblack@eecs.umich.edu 817152Sgblack@eecs.umich.edudef format ArmBlxReg() {{ 827152Sgblack@eecs.umich.edu decode_block = ''' 837152Sgblack@eecs.umich.edu return new BlxReg(machInst, (IntRegIndex)(uint32_t)bits(machInst, 3, 0), 847152Sgblack@eecs.umich.edu (ConditionCode)(uint32_t)machInst.condCode); 857152Sgblack@eecs.umich.edu ''' 867152Sgblack@eecs.umich.edu}}; 877154Sgblack@eecs.umich.edu 887154Sgblack@eecs.umich.edudef format Thumb16CondBranchAndSvc() {{ 897154Sgblack@eecs.umich.edu decode_block = ''' 907154Sgblack@eecs.umich.edu if (bits(machInst, 11, 9) != 0x7) { 917154Sgblack@eecs.umich.edu return new B(machInst, sext<9>(bits(machInst, 7, 0) << 1), 927154Sgblack@eecs.umich.edu (ConditionCode)(uint32_t)bits(machInst, 11, 8)); 937154Sgblack@eecs.umich.edu } else if (bits(machInst, 8)) { 947154Sgblack@eecs.umich.edu return new WarnUnimplemented("svc", machInst); 957154Sgblack@eecs.umich.edu } else { 967154Sgblack@eecs.umich.edu // This space will not be allocated in the future. 977154Sgblack@eecs.umich.edu return new WarnUnimplemented("unimplemented", machInst); 987154Sgblack@eecs.umich.edu } 997154Sgblack@eecs.umich.edu ''' 1007154Sgblack@eecs.umich.edu}}; 1017154Sgblack@eecs.umich.edu 1027154Sgblack@eecs.umich.edudef format Thumb16UncondBranch() {{ 1037154Sgblack@eecs.umich.edu decode_block = ''' 1047154Sgblack@eecs.umich.edu return new B(machInst, sext<12>(bits(machInst, 10, 0) << 1), COND_UC); 1057154Sgblack@eecs.umich.edu ''' 1067154Sgblack@eecs.umich.edu}}; 1077154Sgblack@eecs.umich.edu 1087154Sgblack@eecs.umich.edudef format Thumb32 BranchesAndMiscCtrl() {{ 1097154Sgblack@eecs.umich.edu decode_block = ''' 1107154Sgblack@eecs.umich.edu return new WarnUnimplemented("Branches_and_miscellaneous_control", 1117154Sgblack@eecs.umich.edu machInst); 1127154Sgblack@eecs.umich.edu ''' 1137154Sgblack@eecs.umich.edu}}; 114