⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 248729 in webkit


Ignore:
Timestamp:
Aug 15, 2019, 10:49:38 AM (7 years ago)
Author:
rmorisset@apple.com
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r248728 r248729  
     12019-08-15  Robin Morisset  <rmorisset@apple.com>
     2
     3        [WHLSL] Trivial clean-up of the MSL code generated
     4        https://bugs.webkit.org/show_bug.cgi?id=200525
     5
     6        Reviewed by Darin Adler.
     7
     8        Emit simpler code for ternary expressions
     9        Remove duplicate {} around functions
     10
     11        No new tests as it is covered by the existing ones.
     12
     13        * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:
     14        (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit):
     15
    1162019-08-15  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp

    r248650 r248729  
    248248            m_stringBuilder.flexibleAppend(m_typeNamer.mangledNameForType(*parameter->type()), ' ', parameterName);
    249249        }
    250         m_stringBuilder.append(") {\n");
     250        m_stringBuilder.append(")\n");
    251251        checkErrorAndVisit(functionDefinition.block());
    252252        ASSERT(m_stack.isEmpty());
    253         m_stringBuilder.append("}\n");
     253        m_stringBuilder.append('\n');
    254254    }
    255255}
     
    680680    checkErrorAndVisit(ternaryExpression.predicate());
    681681    auto check = takeLastValue();
    682 
    683     auto variableName = generateNextVariableName();
    684     m_stringBuilder.flexibleAppend(
    685         m_typeNamer.mangledNameForType(ternaryExpression.resolvedType()), ' ', variableName, ";\n"
    686         "if (", check, ") {\n"
    687     );
    688682    checkErrorAndVisit(ternaryExpression.bodyExpression());
    689     m_stringBuilder.flexibleAppend(
    690         variableName, " = ", takeLastValue(), ";\n"
    691         "} else {\n"
    692     );
     683    auto body = takeLastValue();
    693684    checkErrorAndVisit(ternaryExpression.elseExpression());
    694     m_stringBuilder.flexibleAppend(
    695         variableName, " = ", takeLastValue(), ";\n"
    696         "}\n"
    697     );
     685    auto elseBody = takeLastValue();
     686
     687    auto variableName = generateNextVariableName();
     688    m_stringBuilder.flexibleAppend(m_typeNamer.mangledNameForType(ternaryExpression.resolvedType()), ' ', variableName, " = ", check, " ? ", body, " : ", elseBody, ";\n");
    698689    appendRightValue(ternaryExpression, variableName);
    699690}
Note: See TracChangeset for help on using the changeset viewer.