diff options
| author | hachem <im@hachem.wtf> | 2026-09-10 05:52:08 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-10 05:52:08 +0200 |
| commit | d50af2e474281a1e88d191f783c2792824698974 (patch) | |
| tree | 571afdff3ac141bbfcee37bc61dfdb6ea8fda163 /src/ast.h | |
| parent | bf157cf09b8b0888c54a165b887309a4e801f608 (diff) | |
feat: conditional select
Diffstat (limited to 'src/ast.h')
| -rw-r--r-- | src/ast.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -119,6 +119,7 @@ enum StatementKind STATEMENT_CALL, STATEMENT_STACK, STATEMENT_INSTRUCTION, + STATEMENT_SELECT, }; struct AssignStatement @@ -187,6 +188,18 @@ struct InstructionStatement size_t operand_capacity; }; +// a branchless conditional move: `target = if_value if left cmp right else +// else_value`. Lowers to csel on AArch64 and cmov on x86. +struct SelectStatement +{ + struct Token target; + struct Expr* if_value; + struct Expr* left; + struct Token comparison; + struct Expr* right; + struct Expr* else_value; +}; + struct Statement { enum StatementKind kind; @@ -200,6 +213,7 @@ struct Statement struct CallStatement call; struct StackStatement stack; struct InstructionStatement instruction; + struct SelectStatement select; }; }; |
