LLVM 22.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 "llvm/IR/IntrinsicsSPIRV.h"
11
12using namespace llvm;
13
15 SmallVectorImpl<int> &OpIndexes, Intrinsic::ID IID) const {
16 switch (IID) {
17 case Intrinsic::spv_generic_cast_to_ptr_explicit:
18 OpIndexes.push_back(0);
19 return true;
20 default:
21 return false;
22 }
23}
24
26 Value *OldV,
27 Value *NewV) const {
28 auto IntrID = II->getIntrinsicID();
29 switch (IntrID) {
30 case Intrinsic::spv_generic_cast_to_ptr_explicit: {
31 unsigned NewAS = NewV->getType()->getPointerAddressSpace();
32 unsigned DstAS = II->getType()->getPointerAddressSpace();
33 return NewAS == DstAS ? NewV
35 PointerType::get(NewV->getContext(), DstAS));
36 }
37 default:
38 return nullptr;
39 }
40}
uint64_t IntrinsicInst * II
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition: Constants.cpp:1833
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:49
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 collectFlatAddressOperands(SmallVectorImpl< int > &OpIndexes, Intrinsic::ID IID) const override
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
void push_back(const T &Elt)
Definition: SmallVector.h:414
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
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1101
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18