diff options
author | MITSUNARI Shigeo <[email protected]> | 2013-04-11 10:07:58 +0900 |
---|---|---|
committer | MITSUNARI Shigeo <[email protected]> | 2013-04-11 10:07:58 +0900 |
commit | aea8056dfa6dd7ce325fb8fa690b99635a08fc7e (patch) | |
tree | 3f5609b42dcd1ae06dd0f389f816b7d6e51af7fc | |
parent | 179ec01ab3d6b1e844142734bc95ec846c5a5b6c (diff) | |
download | xbyak-aea8056dfa6dd7ce325fb8fa690b99635a08fc7e.tar.gz xbyak-aea8056dfa6dd7ce325fb8fa690b99635a08fc7e.zip |
get displayModel
-rw-r--r-- | sample/test_util.cpp | 11 | ||||
-rw-r--r-- | xbyak/xbyak_util.h | 39 |
2 files changed, 50 insertions, 0 deletions
diff --git a/sample/test_util.cpp b/sample/test_util.cpp index 7d526a5..4ad683f 100644 --- a/sample/test_util.cpp +++ b/sample/test_util.cpp @@ -57,6 +57,17 @@ void putCPUinfo() printf("popcnt ng %d %d\n", r, ok); } } + /* + displayFamily displayModel + Opteron 2376 10 4 + Core2 Duo T7100 6 F + Core i3-2120T 6 2A + Core i7-2600 6 2A + Xeon X5650 6 2C + Core i7-3517 6 3A + Core i7-3930K 6 2D + */ + cpu.putFamily(); } #ifdef XBYAK32 diff --git a/xbyak/xbyak_util.h b/xbyak/xbyak_util.h index d1415c8..70bc31a 100644 --- a/xbyak/xbyak_util.h +++ b/xbyak/xbyak_util.h @@ -61,7 +61,39 @@ class Cpu { { return x[0] | (x[1] << 8) | (x[2] << 16) | (x[3] << 24); } + unsigned int mask(int n) const + { + return (1U << n) - 1; + } + void setFamily() + { + unsigned int data[4]; + getCpuid(1, data); + stepping = data[0] & mask(4); + model = (data[0] >> 4) & mask(4); + family = (data[0] >> 8) & mask(4); + // type = (data[0] >> 12) & mask(2); + extModel = (data[0] >> 16) & mask(4); + extFamily = (data[0] >> 20) & mask(8); + if (family == 0x0f) { + displayFamily = family + extFamily; + } else { + displayFamily = family; + } + if (family == 6 || family == 0x0f) { + displayModel = (extModel << 4) + model; + } else { + displayModel = model; + } + } public: + int model; + int family; + int stepping; + int extModel; + int extFamily; + int displayFamily; // family + extFamily + int displayModel; // model + extModel static inline void getCpuid(unsigned int eaxIn, unsigned int data[4]) { #ifdef _WIN32 @@ -153,6 +185,13 @@ public: if (data[3] & (1U << 23)) type_ |= tMMX; if (data[3] & (1U << 25)) type_ |= tMMX2 | tSSE; if (data[3] & (1U << 26)) type_ |= tSSE2; + setFamily(); + } + void putFamily() + { + printf("family=%d, model=%X, stepping=%d, extFamily=%d, extModel=%X\n", + family, model, stepping, extFamily, extModel); + printf("display:family=%X, model=%X\n", displayFamily, displayModel); } bool has(Type type) const { |