stack_operations.py revision 5081
17513SN/A# Copyright (c) 2007 The Hewlett-Packard Development Company 27513SN/A# All rights reserved. 37513SN/A# 48835SAli.Saidi@ARM.com# Redistribution and use of this software in source and binary forms, 57935SN/A# with or without modification, are permitted provided that the 67935SN/A# following conditions are met: 77935SN/A# 87513SN/A# The software must be used only for Non-Commercial Use which means any 97513SN/A# use which is NOT directed to receiving any direct monetary 107513SN/A# compensation for, or commercial advantage from such use. Illustrative 117513SN/A# examples of non-commercial use are academic research, personal study, 128835SAli.Saidi@ARM.com# teaching, education and corporate research & development. 139265SAli.Saidi@ARM.com# Illustrative examples of commercial use are distributing products for 148835SAli.Saidi@ARM.com# commercial advantage and providing services using the software for 158835SAli.Saidi@ARM.com# commercial advantage. 168835SAli.Saidi@ARM.com# 177513SN/A# If you wish to use this software or functionality therein that may be 188721SN/A# covered by patents for commercial use, please contact: 198721SN/A# Director of Intellectual Property Licensing 208835SAli.Saidi@ARM.com# Office of Strategy and Technology 218835SAli.Saidi@ARM.com# Hewlett-Packard Company 227935SN/A# 1501 Page Mill Road 237935SN/A# Palo Alto, California 94304 247935SN/A# 257935SN/A# Redistributions of source code must retain the above copyright notice, 267935SN/A# this list of conditions and the following disclaimer. Redistributions 277935SN/A# in binary form must reproduce the above copyright notice, this list of 287935SN/A# conditions and the following disclaimer in the documentation and/or 298893Ssaidi@eecs.umich.edu# other materials provided with the distribution. Neither the name of 307513SN/A# the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 317513SN/A# contributors may be used to endorse or promote products derived from 327513SN/A# this software without specific prior written permission. No right of 338835SAli.Saidi@ARM.com# sublicense is granted herewith. Derivatives of the software and 347513SN/A# output created using the software may be prepared, but only for 357513SN/A# Non-Commercial Uses. Derivatives of the software may be shared with 367513SN/A# others provided: (i) the others agree to abide by the list of 377513SN/A# conditions herein which includes the Non-Commercial Use restrictions; 387513SN/A# and (ii) such Derivatives of the software include the above copyright 398835SAli.Saidi@ARM.com# notice to acknowledge the contribution from this software where 407513SN/A# applicable, this list of conditions and the disclaimer below. 417513SN/A# 428983Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 437513SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 447513SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 458835SAli.Saidi@ARM.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 467513SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 477513SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 487513SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 497513SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 507513SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 517513SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 528835SAli.Saidi@ARM.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 537513SN/A# 547513SN/A# Authors: Gabe Black 557513SN/A 567513SN/Amicrocode = ''' 577513SN/Adef macroop POP_R { 587513SN/A # Make the default data size of pops 64 bits in 64 bit mode 597513SN/A .adjust_env oszIn64Override 608893Ssaidi@eecs.umich.edu 618893Ssaidi@eecs.umich.edu ld reg, ss, [1, t0, rsp] 627513SN/A addi rsp, rsp, dsz 637513SN/A}; 647513SN/A 658835SAli.Saidi@ARM.comdef macroop POP_M { 667513SN/A # Make the default data size of pops 64 bits in 64 bit mode 678835SAli.Saidi@ARM.com .adjust_env oszIn64Override 688835SAli.Saidi@ARM.com 698835SAli.Saidi@ARM.com ld t1, ss, [1, t0, rsp] 708835SAli.Saidi@ARM.com addi rsp, rsp, dsz 719265SAli.Saidi@ARM.com st t1, seg, sib, disp 729265SAli.Saidi@ARM.com}; 738835SAli.Saidi@ARM.com 748893Ssaidi@eecs.umich.edudef macroop POP_P { 758835SAli.Saidi@ARM.com # Make the default data size of pops 64 bits in 64 bit mode 768835SAli.Saidi@ARM.com .adjust_env oszIn64Override 778835SAli.Saidi@ARM.com 787513SN/A rdip t7 797513SN/A ld t1, ss, [1, t0, rsp] 807513SN/A addi rsp, rsp, dsz 818835SAli.Saidi@ARM.com st t1, seg, riprel, disp 827513SN/A}; 838835SAli.Saidi@ARM.com 848835SAli.Saidi@ARM.comdef macroop PUSH_R { 858835SAli.Saidi@ARM.com # Make the default data size of pops 64 bits in 64 bit mode 868835SAli.Saidi@ARM.com .adjust_env oszIn64Override 879265SAli.Saidi@ARM.com 889265SAli.Saidi@ARM.com # This needs to work slightly differently from the other versions of push 898835SAli.Saidi@ARM.com # because the -original- version of the stack pointer is what gets pushed 908893Ssaidi@eecs.umich.edu st reg, ss, [1, t0, rsp], "-env.dataSize" 917513SN/A subi rsp, rsp, dsz 927513SN/A}; 937513SN/A 947513SN/Adef macroop PUSH_I { 957513SN/A # Make the default data size of pops 64 bits in 64 bit mode 967513SN/A .adjust_env oszIn64Override 977513SN/A 989265SAli.Saidi@ARM.com limm t1, imm 997513SN/A subi rsp, rsp, dsz 1007513SN/A st t1, ss, [1, t0, rsp] 1017513SN/A}; 1027513SN/A 1039265SAli.Saidi@ARM.comdef macroop PUSH_M { 1047513SN/A # Make the default data size of pops 64 bits in 64 bit mode 1059265SAli.Saidi@ARM.com .adjust_env oszIn64Override 1067513SN/A 1077513SN/A ld t1, seg, sib, disp 1087513SN/A subi rsp, rsp, dsz 1097513SN/A st t1, ss, [1, t0, rsp] 1107513SN/A}; 1117513SN/A 1127513SN/Adef macroop PUSH_P { 1137513SN/A # Make the default data size of pops 64 bits in 64 bit mode 1147513SN/A .adjust_env oszIn64Override 1159055Ssaidi@eecs.umich.edu 1167513SN/A rdip t7 1177513SN/A ld t1, seg, riprel, disp 1187513SN/A subi rsp, rsp, dsz 1197524SN/A st t1, ss, [1, t0, rsp] 1209265SAli.Saidi@ARM.com}; 1219265SAli.Saidi@ARM.com 1228893Ssaidi@eecs.umich.edudef macroop PUSHA { 1237513SN/A st rax, ss, [1, t0, rsp], "-0 * env.dataSize" 1247513SN/A st rcx, ss, [1, t0, rsp], "-1 * env.dataSize" 1258983Snate@binkert.org st rdx, ss, [1, t0, rsp], "-2 * env.dataSize" 1269265SAli.Saidi@ARM.com st rbx, ss, [1, t0, rsp], "-3 * env.dataSize" 1279265SAli.Saidi@ARM.com st rsp, ss, [1, t0, rsp], "-4 * env.dataSize" 1288983Snate@binkert.org st rbp, ss, [1, t0, rsp], "-5 * env.dataSize" 1298983Snate@binkert.org st rsi, ss, [1, t0, rsp], "-6 * env.dataSize" 1307513SN/A st rdi, ss, [1, t0, rsp], "-7 * env.dataSize" 1317513SN/A subi rsp, rsp, "8 * env.dataSize" 1327513SN/A}; 1337513SN/A 1347513SN/Adef macroop POPA { 1358893Ssaidi@eecs.umich.edu ld rdi, ss, [1, t0, rsp], "0 * env.dataSize" 1367513SN/A ld rsi, ss, [1, t0, rsp], "1 * env.dataSize" 137 ld rbp, ss, [1, t0, rsp], "2 * env.dataSize" 138 ld rbx, ss, [1, t0, rsp], "4 * env.dataSize" 139 ld rdx, ss, [1, t0, rsp], "5 * env.dataSize" 140 ld rcx, ss, [1, t0, rsp], "6 * env.dataSize" 141 ld rax, ss, [1, t0, rsp], "7 * env.dataSize" 142 addi rsp, rsp, "8 * env.dataSize" 143}; 144 145def macroop LEAVE { 146 # Make the default data size of pops 64 bits in 64 bit mode 147 .adjust_env oszIn64Override 148 149 mov rsp, rsp, rbp 150 ld rbp, ss, [1, t0, rsp] 151 addi rsp, rsp, dsz 152}; 153''' 154#let {{ 155# class ENTER(Inst): 156# "GenFault ${new UnimpInstFault}" 157#}}; 158