[PATCH] D158811: [X86] __builtin_cpu_supports: support x86-64{,-v2,-v3,-v4}

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 21:34:25 PDT 2023


MaskRay created this revision.
MaskRay added reviewers: FreddyYe, pengfei, RKSimon, skan, erichkeane.
Herald added a subscriber: hiraditya.
Herald added a reviewer: ctetreau.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

GCC 12 (https://gcc.gnu.org/PR101696) allows
__builtin_cpu_supports("x86-64") (and -v2 -v3 -v4).
This patch ports the feature.

- Add `FEATURE_X86_64_{BASELINE,V2,V3,V4}` to enum ProcessorFeatures, but keep CPU_FEATURE_MAX unchanged to make FeatureInfos/FeatureInfos_WithPLUS happy.
- Change validateCpuSupports to allow `x86-64{,-v2,-v3,-v4}`
- Change getCpuSupportsMask to return `std::array<uint32_t, 4> where `x86-64{,-v2,-v3,-v4}` set bits `FEATURE_X86_64_{BASELINE,V2,V3,V4}`.
- `cpu_dispatch` feels legacy. It doesn't support `x86-64{,-v2,-v3,-v4}`. Add tests.

Close https://github.com/llvm/llvm-project/issues/55830


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158811

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/builtin-cpu-supports.c
  clang/test/Sema/attr-cpuspecific.c
  clang/test/Sema/attr-target.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/TargetParser/X86TargetParser.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158811.553348.patch
Type: text/x-patch
Size: 9650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230825/a7b366dc/attachment-0001.bin>


More information about the cfe-commits mailing list