1de4a1d01951937632098a6cda45859afa587a06fsewardj 2de4a1d01951937632098a6cda45859afa587a06fsewardj/*--------------------------------------------------------------------*/ 32e8f4efe5e30be3bb52cd8fbf37c107de41eb40dnjn/*--- Asm-only TransTab stuff. pub_core_transtab_asm.h ---*/ 4de4a1d01951937632098a6cda45859afa587a06fsewardj/*--------------------------------------------------------------------*/ 5de4a1d01951937632098a6cda45859afa587a06fsewardj 6de4a1d01951937632098a6cda45859afa587a06fsewardj/* 7b9c427c63a278cc612ae0ec573be7bb1abaa447fnjn This file is part of Valgrind, a dynamic binary instrumentation 8b9c427c63a278cc612ae0ec573be7bb1abaa447fnjn framework. 9de4a1d01951937632098a6cda45859afa587a06fsewardj 100f157ddb404bcde7815a1c5bf2d7e41c114f3d73sewardj Copyright (C) 2000-2013 Julian Seward 11de4a1d01951937632098a6cda45859afa587a06fsewardj jseward@acm.org 12de4a1d01951937632098a6cda45859afa587a06fsewardj 13de4a1d01951937632098a6cda45859afa587a06fsewardj This program is free software; you can redistribute it and/or 14de4a1d01951937632098a6cda45859afa587a06fsewardj modify it under the terms of the GNU General Public License as 15de4a1d01951937632098a6cda45859afa587a06fsewardj published by the Free Software Foundation; either version 2 of the 16de4a1d01951937632098a6cda45859afa587a06fsewardj License, or (at your option) any later version. 17de4a1d01951937632098a6cda45859afa587a06fsewardj 18de4a1d01951937632098a6cda45859afa587a06fsewardj This program is distributed in the hope that it will be useful, but 19de4a1d01951937632098a6cda45859afa587a06fsewardj WITHOUT ANY WARRANTY; without even the implied warranty of 20de4a1d01951937632098a6cda45859afa587a06fsewardj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21de4a1d01951937632098a6cda45859afa587a06fsewardj General Public License for more details. 22de4a1d01951937632098a6cda45859afa587a06fsewardj 23de4a1d01951937632098a6cda45859afa587a06fsewardj You should have received a copy of the GNU General Public License 24de4a1d01951937632098a6cda45859afa587a06fsewardj along with this program; if not, write to the Free Software 25de4a1d01951937632098a6cda45859afa587a06fsewardj Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26de4a1d01951937632098a6cda45859afa587a06fsewardj 02111-1307, USA. 27de4a1d01951937632098a6cda45859afa587a06fsewardj 28e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn The GNU General Public License is contained in the file COPYING. 29de4a1d01951937632098a6cda45859afa587a06fsewardj*/ 30de4a1d01951937632098a6cda45859afa587a06fsewardj 312e8f4efe5e30be3bb52cd8fbf37c107de41eb40dnjn#ifndef __PUB_CORE_TRANSTAB_ASM_H 322e8f4efe5e30be3bb52cd8fbf37c107de41eb40dnjn#define __PUB_CORE_TRANSTAB_ASM_H 3391f62781dc79427890da7a45aa19fe78457722c8sewardj 343387dda4479102751d544c176a7bfc24f3766669sewardj/* Constants for the fast translation lookup cache. It is a direct 353387dda4479102751d544c176a7bfc24f3766669sewardj mapped cache, with 2^VG_TT_FAST_BITS entries. 363387dda4479102751d544c176a7bfc24f3766669sewardj 373387dda4479102751d544c176a7bfc24f3766669sewardj On x86/amd64, the cache index is computed as 383387dda4479102751d544c176a7bfc24f3766669sewardj 'address[VG_TT_FAST_BITS-1 : 0]'. 393387dda4479102751d544c176a7bfc24f3766669sewardj 40f0c1250e324f6684757c6a15545366447ef1d64fsewardj On ppc32/ppc64/mips32/mips64/arm64, the bottom two bits of 41f0c1250e324f6684757c6a15545366447ef1d64fsewardj instruction addresses are zero, which means that function causes 42f0c1250e324f6684757c6a15545366447ef1d64fsewardj only 1/4 of the entries to ever be used. So instead the function 43f0c1250e324f6684757c6a15545366447ef1d64fsewardj is '(address >>u 2)[VG_TT_FAST_BITS-1 : 0]' on those targets. 4459570ffbe31930ab4d678754daaeec0715117a3dsewardj 45291849fb0285e0998b4c9e33eb153eb3373c4a88sewardj On ARM we shift by 1, since Thumb insns can be of size 2, hence to 46291849fb0285e0998b4c9e33eb153eb3373c4a88sewardj minimise collisions and maximise cache utilisation we need to take 47291849fb0285e0998b4c9e33eb153eb3373c4a88sewardj into account all but the least significant bit. 48b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj 49b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj On s390x the rightmost bit of an instruction address is zero. 50b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj For best table utilization shift the address to the right by 1 bit. */ 513387dda4479102751d544c176a7bfc24f3766669sewardj 52ce29f37ca00de9c5689191a9fa3fda07ce2871d4sewardj#define VG_TT_FAST_BITS 15 53de4a1d01951937632098a6cda45859afa587a06fsewardj#define VG_TT_FAST_SIZE (1 << VG_TT_FAST_BITS) 54de4a1d01951937632098a6cda45859afa587a06fsewardj#define VG_TT_FAST_MASK ((VG_TT_FAST_SIZE) - 1) 55de4a1d01951937632098a6cda45859afa587a06fsewardj 563387dda4479102751d544c176a7bfc24f3766669sewardj/* This macro isn't usable in asm land; nevertheless this seems 573387dda4479102751d544c176a7bfc24f3766669sewardj like a good place to put it. */ 584778c66fe34526f0b09745e4191eb561342f49b6sewardj 593387dda4479102751d544c176a7bfc24f3766669sewardj#if defined(VGA_x86) || defined(VGA_amd64) 603387dda4479102751d544c176a7bfc24f3766669sewardj# define VG_TT_FAST_HASH(_addr) ((((UWord)(_addr)) ) & VG_TT_FAST_MASK) 614778c66fe34526f0b09745e4191eb561342f49b6sewardj 624778c66fe34526f0b09745e4191eb561342f49b6sewardj#elif defined(VGA_s390x) || defined(VGA_arm) 63b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj# define VG_TT_FAST_HASH(_addr) ((((UWord)(_addr)) >> 1) & VG_TT_FAST_MASK) 644778c66fe34526f0b09745e4191eb561342f49b6sewardj 65cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#elif defined(VGA_ppc32) || defined(VGA_ppc64be) || defined(VGA_ppc64le) \ 66cae0cc22b83ffb260ee8379e92099c5a701944cbcarll || defined(VGA_mips32) || defined(VGA_mips64) || defined(VGA_arm64) 674778c66fe34526f0b09745e4191eb561342f49b6sewardj# define VG_TT_FAST_HASH(_addr) ((((UWord)(_addr)) >> 2) & VG_TT_FAST_MASK) 684778c66fe34526f0b09745e4191eb561342f49b6sewardj 69112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#elif defined(VGA_tilegx) 70112711afefcfcd43680c7c4aa8d38ef180e8811esewardj# define VG_TT_FAST_HASH(_addr) ((((UWord)(_addr)) >> 3) & VG_TT_FAST_MASK) 71112711afefcfcd43680c7c4aa8d38ef180e8811esewardj 723387dda4479102751d544c176a7bfc24f3766669sewardj#else 733387dda4479102751d544c176a7bfc24f3766669sewardj# error "VG_TT_FAST_HASH: unknown platform" 743387dda4479102751d544c176a7bfc24f3766669sewardj#endif 753387dda4479102751d544c176a7bfc24f3766669sewardj 762e8f4efe5e30be3bb52cd8fbf37c107de41eb40dnjn#endif // __PUB_CORE_TRANSTAB_ASM_H 77de4a1d01951937632098a6cda45859afa587a06fsewardj 78de4a1d01951937632098a6cda45859afa587a06fsewardj/*--------------------------------------------------------------------*/ 795a2664c7e26ac5053ebde6954a6e789144df570enethercote/*--- end ---*/ 80de4a1d01951937632098a6cda45859afa587a06fsewardj/*--------------------------------------------------------------------*/ 81