Handle gcc __builtin_strcmp using 128/256 bit vectors with sse4.1, avx/avx2
[valgrind.git] / include / pub_tool_rangemap.h
blob02e125147d56b29fbab91d1216dda31ff45d2aed
2 /*--------------------------------------------------------------------*/
3 /*--- A mapping where the keys exactly cover the address space. ---*/
4 /*--- pub_tool_rangemap.h ---*/
5 /*--------------------------------------------------------------------*/
7 /*
8 This file is part of Valgrind, a dynamic binary instrumentation
9 framework.
11 Copyright (C) 2014-2017 Mozilla Foundation
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 /* Contributed by Julian Seward <jseward@acm.org> */
31 #ifndef __PUB_TOOL_RANGEMAP_H
32 #define __PUB_TOOL_RANGEMAP_H
34 //--------------------------------------------------------------------
35 // PURPOSE: a mapping from the host machine word (UWord) ranges to
36 // arbitrary other UWord values. The set of ranges exactly covers all
37 // possible UWord values.
38 // --------------------------------------------------------------------
40 /* It's an abstract type. */
41 typedef struct _RangeMap RangeMap;
43 /* Create a new RangeMap, using given allocation and free functions.
44 alloc_fn must not return NULL (that is, if it returns it must have
45 succeeded.) The new array will contain a single range covering the
46 entire key space, which will be bound to the value |initialVal|.
47 This function never returns NULL. */
48 RangeMap* VG_(newRangeMap) ( Alloc_Fn_t alloc_fn,
49 const HChar* cc,
50 Free_Fn_t free_fn,
51 UWord initialVal );
53 /* Free all memory associated with a RangeMap. */
54 void VG_(deleteRangeMap) ( RangeMap* );
56 /* Bind the range [key_min, key_max] to val, overwriting any other
57 bindings existing in the range. Asserts if key_min > key_max. If
58 as a result of this addition, there come to be multiple adjacent
59 ranges with the same value, these ranges are merged together. Note
60 that this is slow: O(N) in the number of existing ranges. */
61 void VG_(bindRangeMap) ( RangeMap* rm,
62 UWord key_min, UWord key_max, UWord val );
64 /* Looks up |key| in the array and returns the associated value and
65 the key bounds. Can never fail since the RangeMap covers the
66 entire key space. This is fast: O(log N) in the number of
67 ranges. */
68 void VG_(lookupRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
69 /*OUT*/UWord* val, const RangeMap* rm, UWord key );
71 /* How many elements are there in the map? */
72 UInt VG_(sizeRangeMap) ( const RangeMap* rm );
74 /* Get the i'th component */
75 void VG_(indexRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
76 /*OUT*/UWord* val, const RangeMap* rm, Word ix );
78 #endif // __PUB_TOOL_RANGEMAP_H
80 /*--------------------------------------------------------------------*/
81 /*--- end pub_tool_rangemap.h ---*/
82 /*--------------------------------------------------------------------*/