LLVM 20.0.0git
SPIRVTargetTransformInfo.h
Go to the documentation of this file.
1//===- SPIRVTargetTransformInfo.h - SPIR-V specific 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// \file
9// This file contains a TargetTransformInfo::Concept conforming object specific
10// to the SPIRV target machine. It uses the target's detailed information to
11// provide more precise answers to certain TTI queries, while letting the
12// target independent and default TTI implementations handle the rest.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVTARGETTRANSFORMINFO_H
17#define LLVM_LIB_TARGET_SPIRV_SPIRVTARGETTRANSFORMINFO_H
18
19#include "SPIRV.h"
20#include "SPIRVTargetMachine.h"
23
24namespace llvm {
25class SPIRVTTIImpl : public BasicTTIImplBase<SPIRVTTIImpl> {
28
29 friend BaseT;
30
31 const SPIRVSubtarget *ST;
32 const SPIRVTargetLowering *TLI;
33
34 const TargetSubtargetInfo *getST() const { return ST; }
35 const SPIRVTargetLowering *getTLI() const { return TLI; }
36
37public:
38 explicit SPIRVTTIImpl(const SPIRVTargetMachine *TM, const Function &F)
39 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
40 TLI(ST->getTargetLowering()) {}
41
43 // SPIR-V natively supports OpBitcount, per 3.53.14 in the spec, as such it
44 // is reasonable to assume the Op is fast / preferable to the expanded loop.
45 // Furthermore, this prevents information being lost if transforms are
46 // applied to SPIR-V before lowering to a concrete target.
47 if (!isPowerOf2_32(TyWidth) || TyWidth > 64)
48 return TTI::PSK_Software; // Arbitrary bit-width INT is not core SPIR-V.
50 }
51};
52
53} // namespace llvm
54
55#endif // LLVM_LIB_TARGET_SPIRV_SPIRVTARGETTRANSFORMINFO_H
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
#define F(x, y, z)
Definition: MD5.cpp:55
This pass exposes codegen information to IR-level passes.
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:80
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
SPIRVTTIImpl(const SPIRVTargetMachine *TM, const Function &F)
TargetSubtargetInfo - Generic base class for all target subtargets.
const DataLayout & getDataLayout() const
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
PopcntSupportKind
Flags indicating the kind of support for population count.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:291