Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design representation for OpenCL builtin types and other types lowered to llvm::TargetExtType #802

Open
seven-mile opened this issue Aug 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@seven-mile
Copy link
Collaborator

In the original SPIR-V CodeGen, llvm::TargetExtType is employed for OpenCL built-in types like pipe and image, which encapsulate certain type-specific parameters. This design choice is discussed in the RFC Adding opaque types to LLVM IR.

Opaque types are a new kind of fundamental LLVM type. The C++ API for this type, at least as far as type creation looks, would be as follows:

class OpaqueType : public Type {
public:
  static void get(LLVMContext &Ctx, StringRef Name);
  static void get(LLVMContext &Ctx, StringRef Name,
                  ArrayRef<Type *> Types, ArrayRef<unsigned> Parameters);
};

In LLVM IR terms, this would be written as:

opaque(“spirv.Image”, void, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
opaque(“spirv.Queue”)

The use of TargetExtType, or the previously known OpaqueType, is quite limited within LLVM until now, primarily involving OpenCL/SPIR-V and Arm's scalable vector extension. It's important to consider the appropriate level of abstraction for these types collectively, as the LLVM community has done.

From LLVM's standpoint, the goal is to maintain a clean type system. These target-specific types function similarly to pointers or unique handles, with the main purpose being to distinguish them from standard types like word-sized integers. This perspective is also relevant for ClangIR. However, we should proceed with caution when introducing an LLVM equivalent in ClangIR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant