Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream-replay' into staging
[qemu/ar7.git] / include / exec / tb-hash.h
blob0f4e8a08afe0e6f964245bd1fbd3ce1ff4284979
1 /*
2 * internal execution defines for qemu
4 * Copyright (c) 2003 Fabrice Bellard
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.
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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef EXEC_TB_HASH
21 #define EXEC_TB_HASH
23 /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for
24 addresses on the same page. The top bits are the same. This allows
25 TLB invalidation to quickly clear a subset of the hash table. */
26 #define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2)
27 #define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS)
28 #define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1)
29 #define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE)
31 static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc)
33 target_ulong tmp;
34 tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS));
35 return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK;
38 static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc)
40 target_ulong tmp;
41 tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS));
42 return (((tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK)
43 | (tmp & TB_JMP_ADDR_MASK));
46 static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc)
48 return (pc >> 2) & (CODE_GEN_PHYS_HASH_SIZE - 1);
51 #endif