]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add data structures for cache representation to libvex.h:
authorFlorian Krohm <florian@eich-krohm.de>
Sun, 7 Oct 2012 19:44:40 +0000 (19:44 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sun, 7 Oct 2012 19:44:40 +0000 (19:44 +0000)
VexCacheInfo, VexCache, and VexCacheKind.
VexArchInfo gets a VexCacheInfo member which LibVEX_default_VexArchInfo
initialises.

git-svn-id: svn://svn.valgrind.org/vex/trunk@2548

VEX/priv/main_main.c
VEX/pub/libvex.h

index a04a10f70ddc4a85959d29a51814ffafd36df395..bb178b02e208891d60548e7f37a61b5957e30c96 100644 (file)
@@ -1081,6 +1081,10 @@ void LibVEX_default_VexArchInfo ( /*OUT*/VexArchInfo* vai )
    vai->ppc_dcbz_szB       = 0;
    vai->ppc_dcbzl_szB      = 0;
 
+   vai->hwcache_info.num_levels = 0;
+   vai->hwcache_info.num_caches = 0;
+   vai->hwcache_info.caches = NULL;
+   vai->hwcache_info.icaches_maintain_coherence = True;  // whatever
 }
 
 /* Write default settings info *vbi. */
index 9d7f8bd7dd10ec8cc4b1e110545ac6848c88f60b..ddbf87bf33f30d0aaf281abd05ec331702c7ef1d 100644 (file)
@@ -181,15 +181,52 @@ typedef
 extern const HChar* LibVEX_ppVexArch    ( VexArch );
 extern const HChar* LibVEX_ppVexHwCaps  ( VexArch, UInt );
 
+/* The various kinds of caches */
+typedef enum {
+   DATA_CACHE,
+   INSN_CACHE,
+   UNIFIED_CACHE
+} VexCacheKind;
+
+/* Information about a particular cache */
+typedef struct {
+   VexCacheKind kind;
+   UInt level;         /* level this cache is at, e.g. 1 for L1 cache */
+   UInt sizeB;         /* size of this cache in bytes */
+   UInt line_sizeB;    /* cache line size in bytes */
+   UInt assoc;         /* set associativity */
+} VexCache;
+
+/* Convenience macro to initialise a VexCache */
+#define VEX_CACHE_INIT(_kind, _level, _size, _line_size, _assoc)         \
+         ({ (VexCache) { .kind = _kind, .level = _level, .sizeB = _size, \
+                         .line_sizeB = _line_size, .assoc = _assoc }; })
+
+/* Information about the cache system as a whole */
+typedef struct {
+   UInt num_levels;
+   UInt num_caches;
+   /* Unordered array of caches for this host. NULL if there are
+      no caches. Users can assume that the array contains at most one
+      cache of a given kind per cache level. Additionally, if there exists
+      a unified cache at a particular level then no other cache exists
+      at that level. */
+   VexCache *caches;
+   Bool icaches_maintain_coherence;
+} VexCacheInfo;
+
 
 /* This struct is a bit of a hack, but is needed to carry misc
    important bits of info about an arch.  Fields which are meaningless
-   or ignored for the platform in question should be set to zero. */
+   or ignored for the platform in question should be set to zero.
+   Nb: if you add fields to the struct make sure to update function
+   LibVEX_default_VexArchInfo. */
 
 typedef
    struct {
-      /* This is the only mandatory field. */
+      /* The following two fields are mandatory. */
       UInt hwcaps;
+      VexCacheInfo hwcache_info;
       /* PPC32/PPC64 only: size of cache line */
       Int ppc_cache_line_szB;
       /* PPC32/PPC64 only: sizes zeroed by the dcbz/dcbzl instructions