Add PTWRITE builtins for x86

Programming / Compilers / GCC - ak [138bc75d-0d04-0410-961f-82ee72b054a4] - 9 November 2018 05:42 EST

Add builtins/intrinsics for PTWRITE. PTWRITE is a new instruction on Intel Gemini Lake/ Goldmont Plus that allows to write values into the Processor Trace log. This allows
very light weight instrumentation of programs.

The intrinsics are compatible to icc. Automatically enabled for Goldmont Plus.

gcc/:

2018-11-08 Andi Kleen

- common/config/i386/i386-common.c (OPTION_MASK_ISA_PTWRITE_SET): New. (OPTION_MASK_ISA_PTWRITE_UNSET): New. (ix86_handle_option): Handle OPT_mptwrite.
- config/i386/cpuid.h (bit_PTWRITE): Add.
- config/i386/driver-i386.c (host_detect_local_cpu): Detect ptwrite.
- config/i386/i386-builtin.def (BDESC): Add ptwrite32/64.
- config/i386/i386-c.c (ix86_target_macros_internal): Define __PTWRITE__.
- config/i386/i386.c (ix86_target_string): Handle ptwrite. (ix86_option_override_internal): Handle PTA_PTWRITE. (ix86_valid_target_attribute_inner_p): Define ptwrite. (def_builtin2): Force UINT64 to be 64bit only.
- config/i386/i386.h (TARGET_PTWRITE): Add. (TARGET_PTWRITE_P): Add. (PTA_PTWRITE): Add.
- config/i386/i386.md: Define ptwrite.
- config/i386/i386.opt: Add -mptwrite.
- config/i386/immintrin.h (_ptwrite64): Add. (_ptwrite32): Add
- doc/extend.texi: Document __builtin_ia32_ptwrite*.
- doc/invoke.texi: Document -mptwrite.

gcc/testsuite/:

2018-11-08 Andi Kleen

- gcc.target/i386/ptwrite1.c: New test.
- gcc.target/i386/ptwrite2.c: New test.

742da49920e Add PTWRITE builtins for x86
gcc/ChangeLog | 23 +++++++++++++++++++++++
gcc/common/config/i386/i386-common.c | 15 +++++++++++++++
gcc/config/i386/cpuid.h | 4 ++++
gcc/config/i386/driver-i386.c | 12 ++++++++++++
gcc/config/i386/i386-builtin.def | 4 ++++
gcc/config/i386/i386-c.c | 2 ++
gcc/config/i386/i386.c | 9 ++++++++-
gcc/config/i386/i386.h | 5 ++++-
gcc/config/i386/i386.md | 10 ++++++++++
gcc/config/i386/i386.opt | 4 ++++
gcc/config/i386/immintrin.h | 26 ++++++++++++++++++++++++++
gcc/doc/extend.texi | 9 +++++++++
gcc/doc/invoke.texi | 7 +++++--
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/gcc.target/i386/ptwrite1.c | 30 ++++++++++++++++++++++++++++++
gcc/testsuite/gcc.target/i386/ptwrite2.c | 14 ++++++++++++++
16 files changed, 175 insertions(+), 4 deletions(-)

Upstream: gcc.gnu.org


  • Share