[PATCH] Add Clang support for intrinsic __rdpmc.
Andrea Di Biagio
andrea.dibiagio at gmail.com
Mon Jun 30 10:47:03 PDT 2014
Hi,
This patch adds Clang support for intrinsic __rdpmc in "ia32intrin.h".
Intrinsic __rdpmc is implemented as a call to the x86 builtin
'__builtin_ia32_rdpmc'.
It takes as input a value representing the index of the performance
counter to read.
The value of the performance counter is then returned as an unsigned
64-bit quantity.
LLVM support for builtin rdpmc has been committed already at revision 212049.
Please let me know if ok to submit.
Thanks!
Andrea
-------------- next part --------------
Index: lib/Headers/ia32intrin.h
===================================================================
--- lib/Headers/ia32intrin.h (revision 212049)
+++ lib/Headers/ia32intrin.h (working copy)
@@ -79,6 +79,11 @@
}
#endif /* !__x86_64__ */
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
+__rdpmc(int __A) {
+ return __builtin_ia32_rdpmc(__A);
+}
+
/* __rdtsc */
static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
__rdtsc(void) {
Index: include/clang/Basic/BuiltinsX86.def
===================================================================
--- include/clang/Basic/BuiltinsX86.def (revision 212049)
+++ include/clang/Basic/BuiltinsX86.def (working copy)
@@ -757,6 +757,7 @@
BUILTIN(__builtin_ia32_xend, "v", "")
BUILTIN(__builtin_ia32_xabort, "vIc", "")
BUILTIN(__builtin_ia32_xtest, "i", "")
+BUILTIN(__builtin_ia32_rdpmc, "ULLii", "")
BUILTIN(__builtin_ia32_rdtsc, "ULLi", "")
BUILTIN(__builtin_ia32_rdtscp, "ULLiUi*", "")
Index: test/CodeGen/builtins-x86.c
===================================================================
--- test/CodeGen/builtins-x86.c (revision 212049)
+++ test/CodeGen/builtins-x86.c (working copy)
@@ -266,6 +266,7 @@
tmp_i = __builtin_ia32_rdtsc();
tmp_i = __builtin_ia32_rdtscp(&tmp_Ui);
+ tmp_LLi = __builtin_ia32_rdpmc(tmp_i);
#ifdef USE_64
tmp_LLi = __builtin_ia32_cvtss2si64(tmp_V4f);
#endif
More information about the cfe-commits
mailing list