================
@@ -945,13 +945,18 @@ static void defineHLSLInterlockedFunc(Sema &S, 
NamespaceDecl *NS,
 
 // Synthesize the compare-and-swap overload sets: {int, uint, int64_t,
 // uint64_t} x {groupshared, device}. Each function has one form only.
+// The float-bitwise operations have their own names and take float only.
 static void defineHLSLInterlockedCompareFunc(Sema &S, NamespaceDecl *NS,
                                              StringRef FuncName,
                                              StringRef BuiltinName,
-                                             AtomicOverloadShape Shape) {
+                                             AtomicOverloadShape Shape,
+                                             bool FloatOnly = false) {
   ASTContext &AST = S.getASTContext();
-  QualType Elems[] = {AST.IntTy, AST.UnsignedIntTy, AST.LongTy,
-                      AST.UnsignedLongTy};
+  QualType IntElems[] = {AST.IntTy, AST.UnsignedIntTy, AST.LongTy,
+                         AST.UnsignedLongTy};
+  QualType FloatElems[] = {AST.FloatTy};
+  ArrayRef<QualType> Elems =
+      FloatOnly ? ArrayRef<QualType>(FloatElems) : 
ArrayRef<QualType>(IntElems);
----------------
hekota wrote:

I am not a fan of creating arrays or other constructs that are not used. I 
think it would be better to have a standalone function for the float type:
```
static void defineHLSLInterlockedCompareFuncFloat(Sema &S, NamespaceDecl *NS,
                                             StringRef FuncName,
                                             StringRef BuiltinName,
                                             AtomicOverloadShape Shape) {
  ASTContext &AST = S.getASTContext();
  for (LangAS AS : {LangAS::hlsl_groupshared, LangAS::hlsl_device})
    buildAtomicOverload(S, NS, FuncName, BuiltinName, AST.FloatTy, AS, Shape);
}
```

https://github.com/llvm/llvm-project/pull/222166
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to