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
46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
//===- DirectXTargetTransformInfo.h - DirectX TTI ---------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_DIRECTX_DIRECTXTARGETTRANSFORMINFO_H
|
|
#define LLVM_DIRECTX_DIRECTXTARGETTRANSFORMINFO_H
|
|
|
|
#include "DirectXSubtarget.h"
|
|
#include "DirectXTargetMachine.h"
|
|
#include "llvm/CodeGen/BasicTTIImpl.h"
|
|
#include "llvm/IR/Function.h"
|
|
|
|
namespace llvm {
|
|
class DirectXTTIImpl : public BasicTTIImplBase<DirectXTTIImpl> {
|
|
using BaseT = BasicTTIImplBase<DirectXTTIImpl>;
|
|
using TTI = TargetTransformInfo;
|
|
|
|
friend BaseT;
|
|
|
|
const DirectXSubtarget *ST;
|
|
const DirectXTargetLowering *TLI;
|
|
|
|
const DirectXSubtarget *getST() const { return ST; }
|
|
const DirectXTargetLowering *getTLI() const { return TLI; }
|
|
|
|
public:
|
|
explicit DirectXTTIImpl(const DirectXTargetMachine *TM, const Function &F)
|
|
: BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
|
TLI(ST->getTargetLowering()) {}
|
|
unsigned getMinVectorRegisterBitWidth() const override { return 32; }
|
|
bool isTargetIntrinsicTriviallyScalarizable(Intrinsic::ID ID) const override;
|
|
bool isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
|
|
unsigned ScalarOpdIdx) const override;
|
|
bool isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
|
|
int OpdIdx) const override;
|
|
};
|
|
} // namespace llvm
|
|
|
|
#endif // LLVM_DIRECTX_DIRECTXTARGETTRANSFORMINFO_H
|