LLVM 23.0.0git
DirectXTargetTransformInfo.h
Go to the documentation of this file.
1//===- DirectXTargetTransformInfo.h - DirectX TTI ---------------*- 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//===----------------------------------------------------------------------===//
10
11#ifndef LLVM_DIRECTX_DIRECTXTARGETTRANSFORMINFO_H
12#define LLVM_DIRECTX_DIRECTXTARGETTRANSFORMINFO_H
13
14#include "DirectXSubtarget.h"
17#include "llvm/IR/Constants.h"
18#include "llvm/IR/Function.h"
19#include "llvm/IR/Metadata.h"
20#include "llvm/IR/Module.h"
21
22namespace llvm {
23class DirectXTTIImpl final : public BasicTTIImplBase<DirectXTTIImpl> {
25 using TTI = TargetTransformInfo;
26
27 friend BaseT;
28
29 const DirectXSubtarget *ST;
30 const DirectXTargetLowering *TLI;
31 // True when native 16-bit types are enabled (i.e. -enable-16bit-types was
32 // passed), indicated by the dx.nativelowprec module flag.
33 const bool HasNativeLowPrecision;
34
35 const DirectXSubtarget *getST() const { return ST; }
36 const DirectXTargetLowering *getTLI() const { return TLI; }
37
38 static bool readNativeLowPrecisionFlag(const Function &F) {
40 F.getParent()->getModuleFlag("dx.nativelowprec")))
41 return Flag->getValue().getBoolValue();
42 return false;
43 }
44
45public:
46 explicit DirectXTTIImpl(const DirectXTargetMachine *TM, const Function &F)
47 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
48 TLI(ST->getTargetLowering()),
49 HasNativeLowPrecision(readNativeLowPrecisionFlag(F)) {}
50 unsigned getMinVectorRegisterBitWidth() const override { return 32; }
52 unsigned ScalarOpdIdx) const override;
54 int OpdIdx) const override;
55 unsigned getMinimumLookupTableEntryBitWidth() const override;
56
58 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
60 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
62 std::optional<FastMathFlags> FMF) const override {
64 }
65};
66} // namespace llvm
67
68#endif // LLVM_DIRECTX_DIRECTXTARGETTRANSFORMINFO_H
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
This file contains the declarations for metadata subclasses.
BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
InstructionCost getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, TTI::PartialReductionExtendKind OpAExtend, TTI::PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp, TTI::TargetCostKind CostKind, std::optional< FastMathFlags > FMF) const override
unsigned getMinimumLookupTableEntryBitWidth() const override
bool isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, unsigned ScalarOpdIdx) const override
DirectXTTIImpl(const DirectXTargetMachine *TM, const Function &F)
unsigned getMinVectorRegisterBitWidth() const override
bool isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, int OpdIdx) const override
static InstructionCost getInvalid(CostType Val=0)
virtual const DataLayout & getDataLayout() const
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
TargetCostKind
The kind of cost model.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
Definition Metadata.h:683
This is an optimization pass for GlobalISel generic memory operations.