Skip to content

Conversation

@jcranmer-intel
Copy link
Contributor

One of the reasons behind this change is to make code more easily deal with the future prospect of opaque types, so that helper methods (like adjusting image types) can handle both pointer type and opaque type representations simply by querying if the input type is a TypedPointerType or an OpaqueType [name for the latter still pending].

The set of changes are:

  • OCLTypeToSPIRV now uses TypedPointerType internally
  • adaptSPIRVImageType and getSPIRVStructTypeByChangeBaseTypeName are collapsed into one method (adjustImageType) that works with TypedPointerTypes.
  • A few isStructType methods have been reverted back to isType methods, taking a TypedPointerType parameter instead.
  • BuiltinCallHelper::addSPIRVCall{Pair} allows for the creation of SPIR-V calls that can use TypedPointerType or actual type for parameters and return value.
  • BuiltinCallHelper::getCallValue{Type} is a simple helper that hides many of the uses of getParameterTypes.
  • The Type* parameter of the callback in BuiltinCallMutator::mapArg now provides a TypedPointerType or the actual type, instead of the pointer element type.
  • BuiltinCallMutator::ValueTypePair similarly takes a TypedPointerType or the actual type.
  • getParameterTypes (when passed a SmallVector<Type *>) does a similar thing. (The SmallVector<TypedPointerType *> variant has been removed in favor of only using the other one.)

Note that the last few changes do change the semantics of function parameters without changing the function name or signature.

One of the reasons behind this change is to make code more easily deal with the
future prospect of opaque types, so that helper methods (like adjusting image
types) can handle both pointer type and opaque type representations simply by
querying if the input type is a TypedPointerType or an OpaqueType [name for the
latter still pending].

The set of changes are:
* OCLTypeToSPIRV now uses TypedPointerType internally
* adaptSPIRVImageType and getSPIRVStructTypeByChangeBaseTypeName are collapsed
  into one method (adjustImageType) that works with TypedPointerTypes.
* A few is*StructType methods have been reverted back to is*Type methods, taking
  a TypedPointerType parameter instead.
* BuiltinCallHelper::addSPIRVCall{Pair} allows for the creation of SPIR-V calls
  that can use TypedPointerType or actual type for parameters and return value.
* BuiltinCallHelper::getCallValue{Type} is a simple helper that hides many of
  the uses of getParameterTypes.
* The Type* parameter of the callback in BuiltinCallMutator::mapArg now provides
  a TypedPointerType or the actual type, instead of the pointer element type.
* BuiltinCallMutator::ValueTypePair similarly takes a TypedPointerType or the
  actual type.
* getParameterTypes (when passed a SmallVector<Type *>) does a similar thing.
  (The SmallVector<TypedPointerType *> variant has been removed in favor of only
  using the other one.)

Note that the last few changes do change the semantics of function parameters
without changing the function name or signature.
@MrSidims MrSidims requested review from MrSidims and svenvh October 27, 2022 23:16
std::move(NameMapFn));
if (!DidDemangle) {
// TODO: PipeBlocking.ll causes demangling failures.
// assert(isNonMangledOCLBuiltin(CI->getCalledFunction()->getName()) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does look like that if a function name has .1 in the end (for example
declare spir_func void @_Z30__spirv_WritePipeBlockingINTELPU3AS115__spirv_Pipe__1PU3AS4iii.1(%opencl.pipe_wo_t addrspace(1)* %0, i9 addrspace(4)* %1, i32 %2, i32 %3)
RootNode will be nullptr
auto *RootNode = dyn_cast_or_null<FunctionEncoding>(Demangler.parse());
unsure if it's expected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the .1 is added, then the function name isn't a valid mangled name which is... probably problematic, but that requires some more investigation.

Copy link
Contributor

@MrSidims MrSidims Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. May be it ends up a problem with pipes translation.

MangledName.end());
// We expect to see only function name encodings here. If it's not a function
// name encoding, bail out.
auto *RootNode = dyn_cast_or_null<FunctionEncoding>(Demangler.parse());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is from where we get false to trigger the assert.

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
@jcranmer-intel
Copy link
Contributor Author

Friendly review ping?

@svenvh
Copy link
Member

svenvh commented Nov 4, 2022

Friendly review ping?

Sorry for the delay, I was already working through it, but as it has a lot of scattered changes I'll need some more time.

@svenvh svenvh merged commit 5ce6a99 into KhronosGroup:main Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants