summaryrefslogtreecommitdiff
path: root/src/passes
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-03-29 12:46:52 -0700
committerGitHub <noreply@github.com>2024-03-29 19:46:52 +0000
commit88eabaaddeeff6fb8295a2e35c8e29927df04724 (patch)
tree64bf4d085244fcc2adad324ba265a8bc8519b010 /src/passes
parenteae2638a53e778e24e1ed042f2e16aa0b3b127a5 (diff)
downloadbinaryen-88eabaaddeeff6fb8295a2e35c8e29927df04724.tar.gz
binaryen-88eabaaddeeff6fb8295a2e35c8e29927df04724.tar.bz2
binaryen-88eabaaddeeff6fb8295a2e35c8e29927df04724.zip
[Strings] Lower string.concat in StringLowering (#6453)
Diffstat (limited to 'src/passes')
-rw-r--r--src/passes/StringLowering.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/passes/StringLowering.cpp b/src/passes/StringLowering.cpp
index 322f0deb2..df2d66860 100644
--- a/src/passes/StringLowering.cpp
+++ b/src/passes/StringLowering.cpp
@@ -298,6 +298,7 @@ struct StringLowering : public StringGathering {
Name fromCharCodeArrayImport;
Name intoCharCodeArrayImport;
Name fromCodePointImport;
+ Name concatImport;
Name equalsImport;
Name compareImport;
Name lengthImport;
@@ -328,6 +329,8 @@ struct StringLowering : public StringGathering {
module, "fromCharCodeArray", {nullArray16, Type::i32, Type::i32}, nnExt);
// string.fromCodePoint: codepoint -> ext
fromCodePointImport = addImport(module, "fromCodePoint", Type::i32, nnExt);
+ // string.concat: string, string -> string
+ concatImport = addImport(module, "concat", {nullExt, nullExt}, nnExt);
// string.intoCharCodeArray: string, array, start -> num written
intoCharCodeArrayImport = addImport(module,
"intoCharCodeArray",
@@ -375,6 +378,12 @@ struct StringLowering : public StringGathering {
}
}
+ void visitStringConcat(StringConcat* curr) {
+ Builder builder(*getModule());
+ replaceCurrent(builder.makeCall(
+ lowering.concatImport, {curr->left, curr->right}, lowering.nnExt));
+ }
+
void visitStringAs(StringAs* curr) {
// There is no difference between strings and views with imported
// strings: they are all just JS strings, so no conversion is needed.