summaryrefslogtreecommitdiff
path: root/src/ir/branch-utils.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-04-03 08:22:08 -0700
committerGitHub <noreply@github.com>2024-04-03 08:22:08 -0700
commit58f06ccd1e94953292057bb61dc670bfcee0dd05 (patch)
tree45a27d2d57b06e11584e7afad5a6933dc6105ab4 /src/ir/branch-utils.h
parent35df5043764b41d7c23d15db5518cfe8becb3564 (diff)
downloadbinaryen-58f06ccd1e94953292057bb61dc670bfcee0dd05.tar.gz
binaryen-58f06ccd1e94953292057bb61dc670bfcee0dd05.tar.bz2
binaryen-58f06ccd1e94953292057bb61dc670bfcee0dd05.zip
[NFC] Generalize and simplify wasm-delegations-fields.h (#6465)
This removes the hard-coded generation of a switch and cases, and allows the user to define the boilerplate at the start and end of the main output, and of what is generated for each expression. By default we still emit a switch and cases. Also standardize the output by never emitting ; unnecessarily, which we were inconsistent about. This serves two goals: First, it will make using embind on Binaryen simpler as embind needs to generate C++ template logic for each expression, and not a switch (and we cannot have extra ; in embind notation). Second, this makes the format much simple to parse, which is a stepping stone for #6460, e.g. before we had case Expression::Id::LoopId: { DELEGATE_START(Loop); DELEGATE_FIELD_CHILD(Loop, body); DELEGATE_FIELD_SCOPE_NAME_DEF(Loop, name); DELEGATE_END(Loop); break; } and now we have DELEGATE_FIELD_CASE_START(Loop) DELEGATE_FIELD_CHILD(Loop, body) DELEGATE_FIELD_SCOPE_NAME_DEF(Loop, name) DELEGATE_FIELD_CASE_END(Loop) The main part of this diff was autogenerated by this python: for l in x.splitlines(): if l.startswith(' case'): id = l.split(':')[4][:-2] print(f'DELEGATE_FIELD_CASE_START({id})') if l.startswith(' DELEGATE_FIELD'): print(l) if l.startswith(' DELEGATE_END'): id = l[17:-2] print(f'DELEGATE_FIELD_CASE_END({id})') print()
Diffstat (limited to 'src/ir/branch-utils.h')
-rw-r--r--src/ir/branch-utils.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/ir/branch-utils.h b/src/ir/branch-utils.h
index 28e29ede4..d90f3a194 100644
--- a/src/ir/branch-utils.h
+++ b/src/ir/branch-utils.h
@@ -132,7 +132,7 @@ template<typename T> void operateOnScopeNameDefs(Expression* expr, T func) {
#define DELEGATE_GET_FIELD(id, field) cast->field
-#define DELEGATE_FIELD_SCOPE_NAME_DEF(id, field) func(cast->field)
+#define DELEGATE_FIELD_SCOPE_NAME_DEF(id, field) func(cast->field);
#define DELEGATE_FIELD_CHILD(id, field)
#define DELEGATE_FIELD_INT(id, field)