aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2016-04-16 12:41:53 +0300
committerseyko <seyko2@gmail.com>2016-04-16 12:41:53 +0300
commite010b1396bebc7e3ccace4247114f92f544082d6 (patch)
tree82cd4f8bc47c2425e78b3de9678a25e25e67171a
parent5ee097fce9dee7eb4dc782c5d6bce75c01243d63 (diff)
downloadtinycc-e010b1396bebc7e3ccace4247114f92f544082d6.tar.gz
tinycc-e010b1396bebc7e3ccace4247114f92f544082d6.tar.bz2
__builtin_expect no-op
Taken from David Mertens tcc branch on github https://github.com/run4flat/tinycc.git
-rw-r--r--tccgen.c37
-rw-r--r--tcctok.h1
2 files changed, 38 insertions, 0 deletions
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();
diff --git a/tcctok.h b/tcctok.h
index b2fbebf..2cb310b 100644
--- a/tcctok.h
+++ b/tcctok.h
@@ -131,6 +131,7 @@
DEF(TOK_builtin_constant_p, "__builtin_constant_p")
DEF(TOK_builtin_frame_address, "__builtin_frame_address")
DEF(TOK_builtin_return_address, "__builtin_return_address")
+ DEF(TOK_builtin_expect, "__builtin_expect")
#ifdef TCC_TARGET_X86_64
#ifdef TCC_TARGET_PE
DEF(TOK_builtin_va_start, "__builtin_va_start")