blob: db00fbae04e20eec0c9bdd84700d5eff336dd2cc [file] [log] [blame]
bellard79638562003-06-15 19:46:57 +00001/*
2 * dyngen defines for micro operation code
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
Blue Swirl8167ee82009-07-16 20:47:01 +000017 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
bellard79638562003-06-15 19:46:57 +000018 */
bellard67867302003-11-23 17:05:30 +000019#if !defined(__DYNGEN_EXEC_H__)
20#define __DYNGEN_EXEC_H__
21
Stefan Weil47b01cf2010-10-13 20:54:26 +020022#include "qemu-common.h"
bellard513b5002004-01-04 17:44:08 +000023
blueswir1128ab2f2008-08-15 18:33:42 +000024#ifdef __OpenBSD__
25#include <sys/types.h>
blueswir1128ab2f2008-08-15 18:33:42 +000026#endif
bellard79638562003-06-15 19:46:57 +000027
pbrook1057eaa2007-02-04 13:37:44 +000028/* XXX: This may be wrong for 64-bit ILP32 hosts. */
Anthony Liguoric227f092009-10-01 16:12:16 -050029typedef void * host_reg_t;
pbrook1057eaa2007-02-04 13:37:44 +000030
ths522777b2007-05-08 23:30:44 +000031#if defined(__i386__)
bellard79638562003-06-15 19:46:57 +000032#define AREG0 "ebp"
ths522777b2007-05-08 23:30:44 +000033#elif defined(__x86_64__)
ths43024c62007-02-10 18:21:04 +000034#define AREG0 "r14"
malce58ffeb2009-01-14 18:39:49 +000035#elif defined(_ARCH_PPC)
bellard79638562003-06-15 19:46:57 +000036#define AREG0 "r27"
ths522777b2007-05-08 23:30:44 +000037#elif defined(__arm__)
bellard79638562003-06-15 19:46:57 +000038#define AREG0 "r7"
aurel32f54b3f92008-04-12 20:14:54 +000039#elif defined(__hppa__)
40#define AREG0 "r17"
ths522777b2007-05-08 23:30:44 +000041#elif defined(__mips__)
Stefan Weil60bf84c2010-04-09 17:28:40 +020042#define AREG0 "s0"
ths522777b2007-05-08 23:30:44 +000043#elif defined(__sparc__)
Juan Quinteladfe5fff2009-07-27 16:12:40 +020044#ifdef CONFIG_SOLARIS
bellardfdbb4692006-06-14 17:32:25 +000045#define AREG0 "g2"
bellardfdbb4692006-06-14 17:32:25 +000046#else
bellard74ccb342006-07-18 21:23:34 +000047#ifdef __sparc_v9__
blueswir1e97b6402008-07-26 17:19:35 +000048#define AREG0 "g5"
bellard74ccb342006-07-18 21:23:34 +000049#else
bellard79638562003-06-15 19:46:57 +000050#define AREG0 "g6"
bellardfdbb4692006-06-14 17:32:25 +000051#endif
bellard74ccb342006-07-18 21:23:34 +000052#endif
ths522777b2007-05-08 23:30:44 +000053#elif defined(__s390__)
bellard79638562003-06-15 19:46:57 +000054#define AREG0 "r10"
ths522777b2007-05-08 23:30:44 +000055#elif defined(__alpha__)
bellard79638562003-06-15 19:46:57 +000056/* Note $15 is the frame pointer, so anything in op-i386.c that would
57 require a frame pointer, like alloca, would probably loose. */
58#define AREG0 "$15"
ths522777b2007-05-08 23:30:44 +000059#elif defined(__mc68000)
bellard38e584a2003-08-10 22:14:22 +000060#define AREG0 "%a5"
ths522777b2007-05-08 23:30:44 +000061#elif defined(__ia64__)
bellardb8076a72005-04-07 22:20:31 +000062#define AREG0 "r7"
ths522777b2007-05-08 23:30:44 +000063#else
64#error unsupported CPU
bellard79638562003-06-15 19:46:57 +000065#endif
66
bellard79638562003-06-15 19:46:57 +000067#define xglue(x, y) x ## y
68#define glue(x, y) xglue(x, y)
bellard96213392003-07-11 15:17:41 +000069#define stringify(s) tostring(s)
70#define tostring(s) #s
bellard79638562003-06-15 19:46:57 +000071
pbrook9b7b85d2008-05-25 00:36:06 +000072/* The return address may point to the start of the next instruction.
73 Subtracting one gets us the call instruction itself. */
Alexander Graf28278222009-12-05 12:44:23 +010074#if defined(__s390__) && !defined(__s390x__)
pbrook9b7b85d2008-05-25 00:36:06 +000075# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
76#elif defined(__arm__)
77/* Thumb return addresses have the low bit set, so we need to subtract two.
78 This is still safe in ARM mode because instructions are 4 bytes. */
79# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
80#else
81# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
82#endif
83
bellard67867302003-11-23 17:05:30 +000084#endif /* !defined(__DYNGEN_EXEC_H__) */