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

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 17:47:57 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)
----------------
farzonl wrote:

Added sema `unroll.hlsl` tests

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


More information about the cfe-commits mailing list