This is the first in a series of patches to simplify the way NVPTX attaches metadata to functions, function arguments, and global variables. Currently all NVPTX metadata is found via the !nvvm.annotations module-level metadata. This means that reading metadata for one function, argument, or global variable requires iterating over *all* of the module's NVPTX metadata. (We have a janky, global cache that attempts to fix this, but doesn't really succeed.)
We aim to incrementally change the NVPTX metadata format so that our annotations are attached to the objects they describe. This will simplify the format and obviate the need for the cache.
NVPTX has the notion of "image" arguments to kernel functions. These correspond to the .surfref and .texref argument annotations [1], and whether or not an argument is an image is used in NVPTXImageOptimizer. An image argument may be either read-only, read-write, or write-only. This patch:
- Adds an LLVM "image" attribute,
- Lets us mark non-pointers as read-only / write-only (images can be i64s), and
- Changes the NVPTX "isImage" functions to recognize the new format, e.g. "define void @foo(i64 readonly image %img)".
[1] http://docs.nvidia.com/cuda/parallel-thread-execution/#texture-sampler-and-surface-types
Update comment?