xref: /freebsd/contrib/llvm-project/compiler-rt/lib/xray/xray_x86_64.inc (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1//===-- xray_x86_64.inc -----------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of XRay, a dynamic runtime instrumentation system.
10//
11//===----------------------------------------------------------------------===//
12
13#include <cstdint>
14
15#include "sanitizer_common/sanitizer_internal_defs.h"
16#include "xray_defs.h"
17
18namespace __xray {
19
20ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
21  unsigned LongCPU;
22  unsigned long Rax, Rdx;
23  __asm__ __volatile__("rdtscp\n" : "=a"(Rax), "=d"(Rdx), "=c"(LongCPU) ::);
24  CPU = LongCPU;
25  return (Rdx << 32) + Rax;
26}
27
28uint64_t getTSCFrequency();
29
30bool probeRequiredCPUFeatures();
31
32} // namespace __xray
33