Title: [248729] trunk/Source/WebCore
Revision
248729
Author
[email protected]
Date
2019-08-15 10:49:38 -0700 (Thu, 15 Aug 2019)

Log Message

[WHLSL] Trivial clean-up of the MSL code generated
https://bugs.webkit.org/show_bug.cgi?id=200525

Reviewed by Darin Adler.

Emit simpler code for ternary expressions
Remove duplicate {} around functions

No new tests as it is covered by the existing ones.

* Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:
(WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (248728 => 248729)


--- trunk/Source/WebCore/ChangeLog	2019-08-15 17:44:07 UTC (rev 248728)
+++ trunk/Source/WebCore/ChangeLog	2019-08-15 17:49:38 UTC (rev 248729)
@@ -1,3 +1,18 @@
+2019-08-15  Robin Morisset  <[email protected]>
+
+        [WHLSL] Trivial clean-up of the MSL code generated
+        https://bugs.webkit.org/show_bug.cgi?id=200525
+
+        Reviewed by Darin Adler.
+
+        Emit simpler code for ternary expressions
+        Remove duplicate {} around functions
+
+        No new tests as it is covered by the existing ones.
+
+        * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:
+        (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit):
+
 2019-08-15  Youenn Fablet  <[email protected]>
 
         Always create a Document with a valid SessionID

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp (248728 => 248729)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp	2019-08-15 17:44:07 UTC (rev 248728)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp	2019-08-15 17:49:38 UTC (rev 248729)
@@ -247,10 +247,10 @@
             ASSERT_UNUSED(addResult, addResult.isNewEntry);
             m_stringBuilder.flexibleAppend(m_typeNamer.mangledNameForType(*parameter->type()), ' ', parameterName);
         }
-        m_stringBuilder.append(") {\n");
+        m_stringBuilder.append(")\n");
         checkErrorAndVisit(functionDefinition.block());
         ASSERT(m_stack.isEmpty());
-        m_stringBuilder.append("}\n");
+        m_stringBuilder.append('\n');
     }
 }
 
@@ -679,22 +679,13 @@
 {
     checkErrorAndVisit(ternaryExpression.predicate());
     auto check = takeLastValue();
+    checkErrorAndVisit(ternaryExpression.bodyExpression());
+    auto body = takeLastValue();
+    checkErrorAndVisit(ternaryExpression.elseExpression());
+    auto elseBody = takeLastValue();
 
     auto variableName = generateNextVariableName();
-    m_stringBuilder.flexibleAppend(
-        m_typeNamer.mangledNameForType(ternaryExpression.resolvedType()), ' ', variableName, ";\n"
-        "if (", check, ") {\n"
-    );
-    checkErrorAndVisit(ternaryExpression.bodyExpression());
-    m_stringBuilder.flexibleAppend(
-        variableName, " = ", takeLastValue(), ";\n"
-        "} else {\n"
-    );
-    checkErrorAndVisit(ternaryExpression.elseExpression());
-    m_stringBuilder.flexibleAppend(
-        variableName, " = ", takeLastValue(), ";\n"
-        "}\n"
-    );
+    m_stringBuilder.flexibleAppend(m_typeNamer.mangledNameForType(ternaryExpression.resolvedType()), ' ', variableName, " = ", check, " ? ", body, " : ", elseBody, ";\n");
     appendRightValue(ternaryExpression, variableName);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to