[qfcc] Allow more control of intrinsic functions

If `@intrinsic()` is followed by `[expr_list]` then those expresses will
be used to create the intrinsic rather than the function's parameters,
allowing for reordering, adding extra parameters or even complex
expressions.

However, only the parsing is implemented.
This commit is contained in:
Bill Currie 2025-01-15 18:36:01 +09:00
parent 92b476bf04
commit 2c29dcd7d9
3 changed files with 12 additions and 0 deletions

View file

@ -388,6 +388,7 @@ typedef struct {
const expr_t *opcode;
const type_t *res_type;
ex_list_t operands;
const expr_t *extra;
} ex_intrinsic_t;
typedef struct {

View file

@ -473,6 +473,11 @@ print_intrinsic (dstring_t *dstr, const expr_t *e, int level, int id,
{
int indent = level * 2 + 2;
if (e->intrinsic.extra) {
_print_expr (dstr, e->intrinsic.extra, level, id, next);
dasprintf (dstr, "%*se_%p -> \"e_%p\" [label=\"extra\"];\n",
indent, "", e, e->intrinsic.extra);
}
_print_expr (dstr, e->intrinsic.opcode, level, id, next);
for (auto l = e->intrinsic.operands.head; l; l = l->next) {
_print_expr (dstr, l->expr, level, id, next);

View file

@ -1253,6 +1253,12 @@ function_body
intrinsic
: INTRINSIC '(' expr_list ')' { $$ = new_intrinsic_expr ($3); }
| INTRINSIC '(' expr_list ')' vector_expr
{
auto e = new_intrinsic_expr ($3);
e->intrinsic.extra = $5;
$$ = e;
}
;
storage_class