[all-commits] [llvm/llvm-project] bb1765: [TTI] Simplify implementation (NFCI) (#136674)

Sergei Barannikov via All-commits all-commits at lists.llvm.org
Sat Apr 26 05:26:02 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bb1765179e1fe7d671edf92eba22da2ed4173848
      https://github.com/llvm/llvm-project/commit/bb1765179e1fe7d671edf92eba22da2ed4173848
  Author: Sergei Barannikov <barannikov88 at gmail.com>
  Date:   2025-04-26 (Sat, 26 Apr 2025)

  Changed paths:
    M llvm/include/llvm/Analysis/TargetTransformInfo.h
    M llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
    M llvm/include/llvm/CodeGen/BasicTTIImpl.h
    M llvm/lib/Analysis/TargetTransformInfo.cpp
    M llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
    M llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
    M llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
    M llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
    M llvm/lib/Target/AMDGPU/R600TargetMachine.cpp
    M llvm/lib/Target/AMDGPU/R600TargetTransformInfo.h
    M llvm/lib/Target/ARC/ARCTargetMachine.cpp
    M llvm/lib/Target/ARC/ARCTargetTransformInfo.h
    M llvm/lib/Target/ARM/ARMTargetMachine.cpp
    M llvm/lib/Target/ARM/ARMTargetTransformInfo.h
    M llvm/lib/Target/BPF/BPFTargetMachine.cpp
    M llvm/lib/Target/BPF/BPFTargetTransformInfo.h
    M llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
    M llvm/lib/Target/DirectX/DirectXTargetTransformInfo.h
    M llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
    M llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h
    M llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
    M llvm/lib/Target/Lanai/LanaiTargetTransformInfo.h
    M llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp
    M llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.h
    M llvm/lib/Target/Mips/MipsTargetMachine.cpp
    M llvm/lib/Target/Mips/MipsTargetTransformInfo.h
    M llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
    M llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h
    M llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
    M llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
    M llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h
    M llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
    M llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
    M llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
    M llvm/lib/Target/SPIRV/SPIRVTargetTransformInfo.h
    M llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
    M llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h
    M llvm/lib/Target/VE/VETargetMachine.cpp
    M llvm/lib/Target/VE/VETargetTransformInfo.h
    M llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h
    M llvm/lib/Target/X86/X86TargetMachine.cpp
    M llvm/lib/Target/X86/X86TargetTransformInfo.h
    M llvm/lib/Target/XCore/XCoreTargetMachine.cpp
    M llvm/lib/Target/XCore/XCoreTargetTransformInfo.h

  Log Message:
  -----------
  [TTI] Simplify implementation (NFCI) (#136674)

Replace "concept based polymorphism" with simpler PImpl idiom.

This pursues two goals:
* Enforce static type checking. Previously, target implementations hid
base class methods and type checking was impossible. Now that they
override the methods, the compiler will complain on mismatched
signatures.
* Make the code easier to navigate. Previously, if you asked your
favorite LSP server to show a method (e.g. `getInstructionCost()`), it
would show you methods from `TTI`, `TTI::Concept`, `TTI::Model`,
`TTIImplBase`, and target overrides. Now it is two less :)

There are three commits to hopefully simplify the review.

The first commit removes `TTI::Model`. This is done by deriving
`TargetTransformInfoImplBase` from `TTI::Concept`. This is possible
because they implement the same set of interfaces with identical
signatures.

The first commit makes `TargetTransformImplBase` polymorphic, which
means all derived classes should `override` its methods. This is done in
second commit to make the first one smaller. It appeared infeasible to
extract this into a separate PR because the first commit landed
separately would result in tons of `-Woverloaded-virtual` warnings (and
break `-Werror` builds).

The third commit eliminates `TTI::Concept` by merging it with the only
derived class `TargetTransformImplBase`. This commit could be extracted
into a separate PR, but it touches the same lines in
`TargetTransformInfoImpl.h` (removes `override` added by the second
commit and adds `virtual`), so I thought it may make sense to land these
two commits together.

Pull Request: https://github.com/llvm/llvm-project/pull/136674



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list