From e010b1396bebc7e3ccace4247114f92f544082d6 Mon Sep 17 00:00:00 2001 From: seyko Date: Sat, 16 Apr 2016 12:41:53 +0300 Subject: __builtin_expect no-op Taken from David Mertens tcc branch on github https://github.com/run4flat/tinycc.git --- tccgen.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index 4b2893a..8bf7007 100644 --- a/tccgen.c +++ b/tccgen.c @@ -84,6 +84,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_re static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, int scope); static int decl0(int l, int is_for_loop_init); static void expr_eq(void); +static void expr_lor_const(void); static void unary_type(CType *type); static void vla_runtime_type_size(CType *type, int *a); static void vla_sp_restore(void); @@ -3938,6 +3939,22 @@ ST_FUNC void unary(void) vtop->type.t |= VT_UNSIGNED; break; + case TOK_builtin_expect: + { + /* __builtin_expect is a no-op for now */ + int saved_nocode_wanted; + next(); + skip('('); + expr_eq(); + skip(','); + saved_nocode_wanted = nocode_wanted; + nocode_wanted = 1; + expr_lor_const(); + vpop(); + nocode_wanted = saved_nocode_wanted; + skip(')'); + } + break; case TOK_builtin_types_compatible_p: { CType type1, type2; @@ -4466,6 +4483,26 @@ static void expr_or(void) } } +/* XXX: fix this mess */ +static void expr_land_const(void) +{ + expr_or(); + while (tok == TOK_LAND) { + next(); + expr_or(); + gen_op(TOK_LAND); + } +} +static void expr_lor_const(void) +{ + expr_land_const(); + while (tok == TOK_LOR) { + next(); + expr_land_const(); + gen_op(TOK_LOR); + } +} + static void expr_land(void) { expr_or(); -- cgit v1.3.1