LLVM  14.0.0git
Functions | Variables
R600OpenCLImageTypeLoweringPass.cpp File Reference
#include "R600.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils/Cloning.h"
Include dependency graph for R600OpenCLImageTypeLoweringPass.cpp:

Go to the source code of this file.

Functions

static bool IsImageType (StringRef TypeString)
 
static bool IsSamplerType (StringRef TypeString)
 
static FunctionGetFunctionFromMDNode (MDNode *Node)
 
static StringRef AccessQualFromMD (MDNode *KernelMDNode, unsigned ArgIdx)
 
static StringRef ArgTypeFromMD (MDNode *KernelMDNode, unsigned ArgIdx)
 
static MDVector GetArgMD (MDNode *KernelMDNode, unsigned OpIdx)
 
static void PushArgMD (KernelArgMD &MD, const MDVector &V)
 

Variables

static StringRef GetImageSizeFunc = "llvm.OpenCL.image.get.size"
 
static StringRef GetImageFormatFunc = "llvm.OpenCL.image.get.format"
 
static StringRef GetImageResourceIDFunc = "llvm.OpenCL.image.get.resource.id"
 
static StringRef GetSamplerResourceIDFunc
 
static StringRef ImageSizeArgMDType = "__llvm_image_size"
 
static StringRef ImageFormatArgMDType = "__llvm_image_format"
 
static StringRef KernelsMDNodeName = "opencl.kernels"
 
static StringRef KernelArgMDNodeNames []
 
static const unsigned NumKernelArgMDNodes = 5
 

Detailed Description

This pass resolves calls to OpenCL image attribute, image resource ID and sampler resource ID getter functions.

Image attributes (size and format) are expected to be passed to the kernel as kernel arguments immediately following the image argument itself, therefore this pass adds image size and format arguments to the kernel functions in the module. The kernel functions with image arguments are re-created using the new signature. The new arguments are added to the kernel metadata with kernel_arg_type set to "image_size" or "image_format". Note: this pass may invalidate pointers to functions.

Resource IDs of read-only images, write-only images and samplers are defined to be their index among the kernel arguments of the same type and access qualifier.

Definition in file R600OpenCLImageTypeLoweringPass.cpp.

Function Documentation

◆ AccessQualFromMD()

static StringRef AccessQualFromMD ( MDNode KernelMDNode,
unsigned  ArgIdx 
)
static

Definition at line 109 of file R600OpenCLImageTypeLoweringPass.cpp.

References llvm::MDNode::getOperand().

◆ ArgTypeFromMD()

static StringRef ArgTypeFromMD ( MDNode KernelMDNode,
unsigned  ArgIdx 
)
static

Definition at line 115 of file R600OpenCLImageTypeLoweringPass.cpp.

References llvm::MDNode::getOperand().

◆ GetArgMD()

static MDVector GetArgMD ( MDNode KernelMDNode,
unsigned  OpIdx 
)
static

Definition at line 121 of file R600OpenCLImageTypeLoweringPass.cpp.

References i, and NumKernelArgMDNodes.

◆ GetFunctionFromMDNode()

static Function* GetFunctionFromMDNode ( MDNode Node)
static

Definition at line 77 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ IsImageType()

static bool IsImageType ( StringRef  TypeString)
inlinestatic

Definition at line 67 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ IsSamplerType()

static bool IsSamplerType ( StringRef  TypeString)
inlinestatic

Definition at line 72 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ PushArgMD()

static void PushArgMD ( KernelArgMD &  MD,
const MDVector &  V 
)
static

Definition at line 131 of file R600OpenCLImageTypeLoweringPass.cpp.

References assert(), i, and NumKernelArgMDNodes.

Variable Documentation

◆ GetImageFormatFunc

StringRef GetImageFormatFunc = "llvm.OpenCL.image.get.format"
static

Definition at line 40 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ GetImageResourceIDFunc

StringRef GetImageResourceIDFunc = "llvm.OpenCL.image.get.resource.id"
static

Definition at line 41 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ GetImageSizeFunc

StringRef GetImageSizeFunc = "llvm.OpenCL.image.get.size"
static

Definition at line 39 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ GetSamplerResourceIDFunc

StringRef GetSamplerResourceIDFunc
static
Initial value:
=
"llvm.OpenCL.sampler.get.resource.id"

Definition at line 42 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ ImageFormatArgMDType

StringRef ImageFormatArgMDType = "__llvm_image_format"
static

Definition at line 46 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ ImageSizeArgMDType

StringRef ImageSizeArgMDType = "__llvm_image_size"
static

Definition at line 45 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ KernelArgMDNodeNames

StringRef KernelArgMDNodeNames[]
static
Initial value:
= {
"kernel_arg_addr_space",
"kernel_arg_access_qual",
"kernel_arg_type",
"kernel_arg_base_type",
"kernel_arg_type_qual"}

Definition at line 49 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ KernelsMDNodeName

StringRef KernelsMDNodeName = "opencl.kernels"
static

Definition at line 48 of file R600OpenCLImageTypeLoweringPass.cpp.

◆ NumKernelArgMDNodes

const unsigned NumKernelArgMDNodes = 5
static

Definition at line 55 of file R600OpenCLImageTypeLoweringPass.cpp.

Referenced by GetArgMD(), and PushArgMD().