|
From: <sv...@va...> - 2012-10-07 19:44:48
|
florian 2012-10-07 20:44:40 +0100 (Sun, 07 Oct 2012)
New Revision: 2548
Log:
Add data structures for cache representation to libvex.h:
VexCacheInfo, VexCache, and VexCacheKind.
VexArchInfo gets a VexCacheInfo member which LibVEX_default_VexArchInfo
initialises.
Modified files:
trunk/priv/main_main.c
trunk/pub/libvex.h
Modified: trunk/priv/main_main.c (+4 -0)
===================================================================
--- trunk/priv/main_main.c 2012-10-07 16:42:37 +01:00 (rev 2547)
+++ trunk/priv/main_main.c 2012-10-07 20:44:40 +01:00 (rev 2548)
@@ -1081,6 +1081,10 @@
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. */
Modified: trunk/pub/libvex.h (+39 -2)
===================================================================
--- trunk/pub/libvex.h 2012-10-07 16:42:37 +01:00 (rev 2547)
+++ trunk/pub/libvex.h 2012-10-07 20:44:40 +01:00 (rev 2548)
@@ -181,15 +181,52 @@
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
|