Line 0
Link Here
|
|
|
1 |
--- gcc/config/msp430/msp430-builtins.c.orig 2012-09-26 12:24:42.000000000 +0800 |
2 |
+++ gcc/config/msp430/msp430-builtins.c 2012-09-26 12:28:31.000000000 +0800 |
3 |
@@ -59,6 +59,7 @@ |
4 |
MSP430_BUILTIN_GET_WATCHDOG_CLEAR_VALUE, |
5 |
MSP430_BUILTIN_SET_WATCHDOG_CLEAR_VALUE, |
6 |
MSP430_BUILTIN_WATCHDOG_CLEAR, |
7 |
+ MSP430_BUILTIN_EVEN_IN_RANGE, |
8 |
MSP430_BUILTIN_last_enum |
9 |
}; |
10 |
|
11 |
@@ -153,6 +154,13 @@ |
12 |
add_builtin_function ("__watchdog_clear", |
13 |
build_function_type_list (void_type_node, NULL_TREE), |
14 |
MSP430_BUILTIN_WATCHDOG_CLEAR, BUILT_IN_MD, NULL, NULL_TREE); |
15 |
+ add_builtin_function ("__even_in_range", |
16 |
+ build_function_type_list (unsigned_type_node, |
17 |
+ unsigned_type_node, |
18 |
+ unsigned_type_node, |
19 |
+ NULL_TREE), |
20 |
+ MSP430_BUILTIN_EVEN_IN_RANGE, BUILT_IN_MD, |
21 |
+ NULL, NULL_TREE); |
22 |
} |
23 |
|
24 |
rtx |
25 |
@@ -432,6 +440,30 @@ |
26 |
emit_move_insn (retval, arg); |
27 |
insn = gen_bswaphi1 (retval); |
28 |
break; |
29 |
+ case MSP430_BUILTIN_EVEN_IN_RANGE: |
30 |
+ { |
31 |
+ tree key_tree = CALL_EXPR_ARG (exp, 0); |
32 |
+ tree limit_tree = CALL_EXPR_ARG (exp, 1); |
33 |
+ rtx key; |
34 |
+ HOST_WIDE_INT limit_val; |
35 |
+ |
36 |
+ need_insn = false; |
37 |
+ if (!cst_and_fits_in_hwi (limit_tree) |
38 |
+ || (0 > ((limit_val = int_cst_value (limit_tree))))) |
39 |
+ { |
40 |
+ error |
41 |
+ ("__even_in_range second argument must be non-negative integer constant"); |
42 |
+ break; |
43 |
+ } |
44 |
+ key = expand_expr (key_tree, NULL_RTX, VOIDmode, EXPAND_NORMAL); |
45 |
+ retval = gen_reg_rtx (HImode); |
46 |
+ /* This is a stub. To complete this, we need to attach notes |
47 |
+ * that assert that the value is, in fact, even and between 0 |
48 |
+ * and the second argument. No idea how to do that in a way |
49 |
+ * that gcc's tablejump will pay any attention to. */ |
50 |
+ emit_move_insn (retval, key); |
51 |
+ break; |
52 |
+ } |
53 |
} |
54 |
|
55 |
if (insn) |