[clang] [HLSL] add loop unroll (PR #93879)

David Peixotto via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 12:10:34 PDT 2024


================
@@ -584,6 +585,32 @@ static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A,
   return ::new (S.Context) OpenCLUnrollHintAttr(S.Context, A, UnrollFactor);
 }
 
+static Attr *handleHLSLLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A,
+                                    SourceRange Range) {
+  unsigned UnrollFactor = 0;
+  if (A.getNumArgs() == 1) {
+    Expr *E = A.getArgAsExpr(0);
+    std::optional<llvm::APSInt> ArgVal;
+
+    if (!(ArgVal = E->getIntegerConstantExpr(S.Context))) {
+      S.Diag(A.getLoc(), diag::err_attribute_argument_type)
----------------
dmpots wrote:

Are these errors or warnings? It looks like the non-integer expr is a warning in dxc, but the negative constant is an error.

Are we trying to match dxc behavior here?

In any case, I think we should have tests for these error paths.

https://github.com/llvm/llvm-project/pull/93879


More information about the cfe-commits mailing list