LLVM 23.0.0git
SPIRVTargetTransformInfo.cpp
Go to the documentation of this file.
1//===- SPIRVTargetTransformInfo.cpp - 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
10#include "SPIRVSubtarget.h"
11#include "llvm/IR/IntrinsicsSPIRV.h"
12
13using namespace llvm;
14
16 SmallVectorImpl<int> &OpIndexes, Intrinsic::ID IID) const {
17 switch (IID) {
18 case Intrinsic::spv_generic_cast_to_ptr_explicit:
19 OpIndexes.push_back(0);
20 return true;
21 default:
22 return false;
23 }
24}
25
27 Value *OldV,
28 Value *NewV) const {
29 auto IntrID = II->getIntrinsicID();
30 switch (IntrID) {
31 case Intrinsic::spv_generic_cast_to_ptr_explicit: {
32 unsigned NewAS = NewV->getType()->getPointerAddressSpace();
33 unsigned DstAS = II->getType()->getPointerAddressSpace();
34 return NewAS == DstAS ? NewV
36 PointerType::get(NewV->getContext(), DstAS));
37 }
38 default:
39 return nullptr;
40 }
41}
42
43bool SPIRVTTIImpl::isLegalMaskedGather(Type *DataType, Align Alignment) const {
44 return ST->canUseExtension(SPIRV::Extension::SPV_INTEL_masked_gather_scatter);
45}
46
47bool SPIRVTTIImpl::isLegalMaskedScatter(Type *DataType, Align Alignment) const {
48 return ST->canUseExtension(SPIRV::Extension::SPV_INTEL_masked_gather_scatter);
49}
uint64_t IntrinsicInst * II
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
A wrapper class for inspecting calls to intrinsic functions.
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Value * rewriteIntrinsicWithAddressSpace(IntrinsicInst *II, Value *OldV, Value *NewV) const override
bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override
bool collectFlatAddressOperands(SmallVectorImpl< int > &OpIndexes, Intrinsic::ID IID) const override
bool isLegalMaskedGather(Type *DataType, Align Alignment) const override
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:259
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39