From 211cd657e0a69fd2bae965ad2bba051bdbcdb1c2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 6 Feb 2022 20:12:22 +0900 Subject: [PATCH] [qfcc] Alias entity to int for comparison The ruamoko ISA has no entity comparison operators because an entity is just an int in disguise. --- tools/qfcc/source/expr_binary.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/expr_binary.c b/tools/qfcc/source/expr_binary.c index e32e26ead..832abdc09 100644 --- a/tools/qfcc/source/expr_binary.c +++ b/tools/qfcc/source/expr_binary.c @@ -54,6 +54,7 @@ static expr_t *double_compare (int op, expr_t *e1, expr_t *e2); static expr_t *vector_compare (int op, expr_t *e1, expr_t *e2); static expr_t *vector_multiply (int op, expr_t *e1, expr_t *e2); static expr_t *vector_scale (int op, expr_t *e1, expr_t *e2); +static expr_t *entity_compare (int op, expr_t *e1, expr_t *e2); static expr_type_t string_string[] = { {'+', &type_string}, @@ -166,8 +167,8 @@ static expr_type_t vector_double[] = { }; static expr_type_t entity_entity[] = { - {EQ, &type_int}, - {NE, &type_int}, + {EQ, &type_int, 0, 0, entity_compare}, + {NE, &type_int, 0, 0, entity_compare}, {0, 0} }; @@ -812,6 +813,18 @@ double_compare (int op, expr_t *e1, expr_t *e2) return e; } +static expr_t * +entity_compare (int op, expr_t *e1, expr_t *e2) +{ + if (options.code.progsversion == PROG_VERSION) { + e1 = new_alias_expr (&type_int, e1); + e2 = new_alias_expr (&type_int, e2); + } + expr_t *e = new_binary_expr (op, e1, e2); + e->e.expr.type = &type_int; + return e; +} + static expr_t * invalid_binary_expr (int op, expr_t *e1, expr_t *e2) {