This is an archive of the discontinued LLVM Phabricator instance.

[HLSL] [clang] Add vector version of abs for HLSL
ClosedPublic

Authored by python3kgae on Sep 12 2022, 4:00 PM.

Details

Summary

Add vector version of abs as

__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
int2 abs (int2 );
__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
int3 abs (int3 );

To make this work.
Allowed custom type checking builtins to be recelareable.

Diff Detail

Event Timeline

python3kgae created this revision.Sep 12 2022, 4:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2022, 4:00 PM
Herald added a subscriber: Anastasia. · View Herald Transcript
python3kgae requested review of this revision.Sep 12 2022, 4:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2022, 4:00 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
fhahn added a comment.Sep 13 2022, 2:24 AM

I'm not familiar with HLSL but I think making use of the existing vector builtins makes sense here!

I'm not familiar with HLSL but I think making use of the existing vector builtins makes sense here!

Does it make sense to be using the vector builtin for non-vectors?

The elementwise builtins should work for scalars as well (and IIRC we do test this as well).

RKSimon edited the summary of this revision. (Show Details)Sep 16 2022, 4:33 AM
fhahn added a comment.Sep 16 2022, 7:04 AM

The elementwise builtins should work for scalars as well (and IIRC we do test this as well).

Yep they should, it is specially specified here: https://clang.llvm.org/docs/LanguageExtensions.html#vector-builtins

For scalar types, consider the operation applied to a vector with a single element.

Only allow redecl custom type checking builtin for HLSL.

This revision is now accepted and ready to land.Sep 18 2022, 12:47 AM
This revision was automatically updated to reflect the committed changes.