4 * Copyright (C) 2003 Transmeta Corp.
5 * 2003-2004 Linus Torvalds
7 * Licensed under the Open Software License version 1.1
9 * expand constant expressions.
26 #include "expression.h"
28 /* Random cost numbers */
29 #define SIDE_EFFECTS 10000 /* The expression has side effects */
30 #define UNSAFE 100 /* The expression may be "infinitely costly" due to exceptions */
31 #define SELECT_COST 20 /* Cut-off for turning a conditional into a select */
32 #define BRANCH_COST 10 /* Cost of a conditional branch */
34 static int expand_expression(struct expression
*);
35 static int expand_statement(struct statement
*);
37 static int expand_symbol_expression(struct expression
*expr
)
39 struct symbol
*sym
= expr
->symbol
;
40 /* The cost of a symbol expression is lower for on-stack symbols */
41 return (sym
->ctype
.modifiers
& (MOD_STATIC
| MOD_EXTERN
)) ? 2 : 1;
44 static long long get_longlong(struct expression
*expr
)
46 int no_expand
= expr
->ctype
->ctype
.modifiers
& MOD_UNSIGNED
;
47 long long mask
= 1ULL << (expr
->ctype
->bit_size
- 1);
48 long long value
= expr
->value
;
49 long long ormask
, andmask
;
53 andmask
= mask
| (mask
-1);
57 return (value
& andmask
) | ormask
;
60 void cast_value(struct expression
*expr
, struct symbol
*newtype
,
61 struct expression
*old
, struct symbol
*oldtype
)
63 int old_size
= oldtype
->bit_size
;
64 int new_size
= newtype
->bit_size
;
65 long long value
, mask
, signmask
;
66 long long oldmask
, oldsignmask
, dropped
;
68 if (newtype
->ctype
.base_type
== &fp_type
||
69 oldtype
->ctype
.base_type
== &fp_type
)
72 // For pointers and integers, we can just move the value around
73 expr
->type
= EXPR_VALUE
;
74 if (old_size
== new_size
) {
75 expr
->value
= old
->value
;
79 // expand it to the full "long long" value
80 value
= get_longlong(old
);
83 // Truncate it to the new size
84 signmask
= 1ULL << (new_size
-1);
85 mask
= signmask
| (signmask
-1);
86 expr
->value
= value
& mask
;
88 // Check if we dropped any bits..
89 oldsignmask
= 1ULL << (old_size
-1);
90 oldmask
= oldsignmask
| (oldsignmask
-1);
91 dropped
= oldmask
& ~mask
;
93 // Ok if the bits were (and still are) purely sign bits
94 if (value
& dropped
) {
95 if (!(value
& oldsignmask
) || !(value
& signmask
) || (value
& dropped
) != dropped
)
96 warning(old
->pos
, "cast truncates bits from constant value (%llx becomes %llx)",
103 if (newtype
->ctype
.base_type
!= &fp_type
) {
104 value
= (long long)old
->fvalue
;
105 expr
->type
= EXPR_VALUE
;
109 if (oldtype
->ctype
.base_type
!= &fp_type
)
110 expr
->fvalue
= (long double)get_longlong(old
);
112 expr
->fvalue
= old
->value
;
114 if (!(newtype
->ctype
.modifiers
& MOD_LONGLONG
)) {
115 if ((newtype
->ctype
.modifiers
& MOD_LONG
))
116 expr
->fvalue
= (double)expr
->fvalue
;
118 expr
->fvalue
= (float)expr
->fvalue
;
120 expr
->type
= EXPR_FVALUE
;
123 static int check_shift_count(struct expression
*expr
, struct symbol
*ctype
, unsigned int count
)
125 if (count
>= ctype
->bit_size
) {
126 warning(expr
->pos
, "shift too big (%u) for type %s", count
, show_typename(ctype
));
127 count
&= ctype
->bit_size
-1;
133 * CAREFUL! We need to get the size and sign of the
136 #define CONVERT(op,s) (((op)<<1)+(s))
137 #define SIGNED(op) CONVERT(op, 1)
138 #define UNSIGNED(op) CONVERT(op, 0)
139 static int simplify_int_binop(struct expression
*expr
, struct symbol
*ctype
)
141 struct expression
*left
= expr
->left
, *right
= expr
->right
;
142 unsigned long long v
, l
, r
, mask
;
143 signed long long sl
, sr
;
146 if (right
->type
!= EXPR_VALUE
)
149 if (expr
->op
== SPECIAL_LEFTSHIFT
|| expr
->op
== SPECIAL_RIGHTSHIFT
) {
150 r
= check_shift_count(expr
, ctype
, r
);
153 if (left
->type
!= EXPR_VALUE
)
155 l
= left
->value
; r
= right
->value
;
156 is_signed
= !(ctype
->ctype
.modifiers
& MOD_UNSIGNED
);
157 mask
= 1ULL << (ctype
->bit_size
-1);
159 if (is_signed
&& (sl
& mask
))
161 if (is_signed
&& (sr
& mask
))
164 switch (CONVERT(expr
->op
,is_signed
)) {
201 if (l
== mask
&& sr
== -1)
222 case SIGNED(SPECIAL_LEFTSHIFT
):
223 case UNSIGNED(SPECIAL_LEFTSHIFT
):
227 case SIGNED(SPECIAL_RIGHTSHIFT
):
231 case UNSIGNED(SPECIAL_RIGHTSHIFT
):
238 mask
= mask
| (mask
-1);
239 expr
->value
= v
& mask
;
240 expr
->type
= EXPR_VALUE
;
243 warning(expr
->pos
, "division by zero");
246 warning(expr
->pos
, "constant integer operation overflow");
250 static int simplify_cmp_binop(struct expression
*expr
, struct symbol
*ctype
)
252 struct expression
*left
= expr
->left
, *right
= expr
->right
;
253 unsigned long long l
, r
, mask
;
254 signed long long sl
, sr
;
256 if (left
->type
!= EXPR_VALUE
|| right
->type
!= EXPR_VALUE
)
258 l
= left
->value
; r
= right
->value
;
259 mask
= 1ULL << (ctype
->bit_size
-1);
266 case '<': expr
->value
= sl
< sr
; break;
267 case '>': expr
->value
= sl
> sr
; break;
268 case SPECIAL_LTE
: expr
->value
= sl
<= sr
; break;
269 case SPECIAL_GTE
: expr
->value
= sl
>= sr
; break;
270 case SPECIAL_EQUAL
: expr
->value
= l
== r
; break;
271 case SPECIAL_NOTEQUAL
: expr
->value
= l
!= r
; break;
272 case SPECIAL_UNSIGNED_LT
:expr
->value
= l
< r
; break;
273 case SPECIAL_UNSIGNED_GT
:expr
->value
= l
> r
; break;
274 case SPECIAL_UNSIGNED_LTE
:expr
->value
= l
<= r
; break;
275 case SPECIAL_UNSIGNED_GTE
:expr
->value
= l
>= r
; break;
277 expr
->type
= EXPR_VALUE
;
281 static int simplify_float_binop(struct expression
*expr
)
283 struct expression
*left
= expr
->left
, *right
= expr
->right
;
284 unsigned long mod
= expr
->ctype
->ctype
.modifiers
;
285 long double l
, r
, res
;
287 if (left
->type
!= EXPR_FVALUE
|| right
->type
!= EXPR_FVALUE
)
293 if (mod
& MOD_LONGLONG
) {
295 case '+': res
= l
+ r
; break;
296 case '-': res
= l
- r
; break;
297 case '*': res
= l
* r
; break;
298 case '/': if (!r
) goto Div
;
302 } else if (mod
& MOD_LONG
) {
304 case '+': res
= (double) l
+ (double) r
; break;
305 case '-': res
= (double) l
- (double) r
; break;
306 case '*': res
= (double) l
* (double) r
; break;
307 case '/': if (!r
) goto Div
;
308 res
= (double) l
/ (double) r
; break;
313 case '+': res
= (float)l
+ (float)r
; break;
314 case '-': res
= (float)l
- (float)r
; break;
315 case '*': res
= (float)l
* (float)r
; break;
316 case '/': if (!r
) goto Div
;
317 res
= (float)l
/ (float)r
; break;
321 expr
->type
= EXPR_FVALUE
;
325 warning(expr
->pos
, "division by zero");
329 static int simplify_float_cmp(struct expression
*expr
, struct symbol
*ctype
)
331 struct expression
*left
= expr
->left
, *right
= expr
->right
;
334 if (left
->type
!= EXPR_FVALUE
|| right
->type
!= EXPR_FVALUE
)
340 case '<': expr
->value
= l
< r
; break;
341 case '>': expr
->value
= l
> r
; break;
342 case SPECIAL_LTE
: expr
->value
= l
<= r
; break;
343 case SPECIAL_GTE
: expr
->value
= l
>= r
; break;
344 case SPECIAL_EQUAL
: expr
->value
= l
== r
; break;
345 case SPECIAL_NOTEQUAL
: expr
->value
= l
!= r
; break;
347 expr
->type
= EXPR_VALUE
;
351 static int expand_binop(struct expression
*expr
)
355 cost
= expand_expression(expr
->left
);
356 cost
+= expand_expression(expr
->right
);
357 if (simplify_int_binop(expr
, expr
->ctype
))
359 if (simplify_float_binop(expr
))
364 static int expand_logical(struct expression
*expr
)
366 struct expression
*left
= expr
->left
;
367 struct expression
*right
;
370 /* Do immediate short-circuiting ... */
371 cost
= expand_expression(left
);
372 if (left
->type
== EXPR_VALUE
) {
373 if (expr
->op
== SPECIAL_LOGICAL_AND
) {
375 expr
->type
= EXPR_VALUE
;
381 expr
->type
= EXPR_VALUE
;
389 rcost
= expand_expression(right
);
390 if (left
->type
== EXPR_VALUE
&& right
->type
== EXPR_VALUE
) {
392 * We know the left value doesn't matter, since
393 * otherwise we would have short-circuited it..
395 expr
->type
= EXPR_VALUE
;
396 expr
->value
= right
->value
!= 0;
401 * If the right side is safe and cheaper than a branch,
402 * just avoid the branch and turn it into a regular binop
405 if (rcost
< BRANCH_COST
) {
406 expr
->type
= EXPR_BINOP
;
407 rcost
-= BRANCH_COST
- 1;
410 return cost
+ BRANCH_COST
+ rcost
;
413 static int expand_comma(struct expression
*expr
)
417 cost
= expand_expression(expr
->left
);
418 cost
+= expand_expression(expr
->right
);
419 if (expr
->left
->type
== EXPR_VALUE
|| expr
->left
->type
== EXPR_FVALUE
)
420 *expr
= *expr
->right
;
424 #define MOD_IGN (MOD_VOLATILE | MOD_CONST)
426 static int compare_types(int op
, struct symbol
*left
, struct symbol
*right
)
430 return !type_difference(left
, right
, MOD_IGN
, MOD_IGN
);
431 case SPECIAL_NOTEQUAL
:
432 return type_difference(left
, right
, MOD_IGN
, MOD_IGN
) != NULL
;
434 return left
->bit_size
< right
->bit_size
;
436 return left
->bit_size
> right
->bit_size
;
438 return left
->bit_size
<= right
->bit_size
;
440 return left
->bit_size
>= right
->bit_size
;
445 static int expand_compare(struct expression
*expr
)
447 struct expression
*left
= expr
->left
, *right
= expr
->right
;
450 cost
= expand_expression(left
);
451 cost
+= expand_expression(right
);
453 /* Type comparison? */
454 if (left
&& right
&& left
->type
== EXPR_TYPE
&& right
->type
== EXPR_TYPE
) {
456 expr
->type
= EXPR_VALUE
;
457 expr
->value
= compare_types(op
, left
->symbol
, right
->symbol
);
460 if (simplify_cmp_binop(expr
, left
->ctype
))
462 if (simplify_float_cmp(expr
, left
->ctype
))
467 static int expand_conditional(struct expression
*expr
)
469 struct expression
*cond
= expr
->conditional
;
470 struct expression
*true = expr
->cond_true
;
471 struct expression
*false = expr
->cond_false
;
474 cond_cost
= expand_expression(cond
);
475 if (cond
->type
== EXPR_VALUE
) {
481 return expand_expression(expr
);
484 cost
= expand_expression(true);
485 cost
+= expand_expression(false);
487 if (cost
< SELECT_COST
) {
488 expr
->type
= EXPR_SELECT
;
489 cost
-= BRANCH_COST
- 1;
492 return cost
+ cond_cost
+ BRANCH_COST
;
495 static int expand_assignment(struct expression
*expr
)
497 expand_expression(expr
->left
);
498 expand_expression(expr
->right
);
502 static int expand_addressof(struct expression
*expr
)
504 return expand_expression(expr
->unop
);
507 static int expand_dereference(struct expression
*expr
)
509 struct expression
*unop
= expr
->unop
;
511 expand_expression(unop
);
514 * NOTE! We get a bogus warning right now for some special
515 * cases: apparently I've screwed up the optimization of
516 * a zero-offset derefence, and the ctype is wrong.
518 * Leave the warning in anyway, since this is also a good
519 * test for me to get the type evaluation right..
521 if (expr
->ctype
->ctype
.modifiers
& MOD_NODEREF
)
522 warning(unop
->pos
, "dereference of noderef expression");
524 if (unop
->type
== EXPR_SYMBOL
) {
525 struct symbol
*sym
= unop
->symbol
;
527 /* Const symbol with a constant initializer? */
528 if (!(sym
->ctype
.modifiers
& (MOD_ASSIGNED
| MOD_ADDRESSABLE
))) {
529 struct expression
*value
= sym
->initializer
;
531 if (value
->type
== EXPR_VALUE
) {
532 expr
->type
= EXPR_VALUE
;
533 expr
->value
= value
->value
;
535 } else if (value
->type
== EXPR_FVALUE
) {
536 expr
->type
= EXPR_FVALUE
;
537 expr
->fvalue
= value
->fvalue
;
543 /* Direct symbol dereference? Cheap and safe */
544 return (sym
->ctype
.modifiers
& (MOD_STATIC
| MOD_EXTERN
)) ? 2 : 1;
549 static int simplify_preop(struct expression
*expr
)
551 struct expression
*op
= expr
->unop
;
552 unsigned long long v
, mask
;
554 if (op
->type
!= EXPR_VALUE
)
557 mask
= 1ULL << (expr
->ctype
->bit_size
-1);
562 if (v
== mask
&& !(expr
->ctype
->ctype
.modifiers
& MOD_UNSIGNED
))
566 case '!': v
= !v
; break;
567 case '~': v
= ~v
; break;
570 mask
= mask
| (mask
-1);
571 expr
->value
= v
& mask
;
572 expr
->type
= EXPR_VALUE
;
576 warning(expr
->pos
, "constant integer operation overflow");
580 static int simplify_float_preop(struct expression
*expr
)
582 struct expression
*op
= expr
->unop
;
585 if (op
->type
!= EXPR_FVALUE
)
590 case '-': v
= -v
; break;
594 expr
->type
= EXPR_FVALUE
;
599 * Unary post-ops: x++ and x--
601 static int expand_postop(struct expression
*expr
)
603 expand_expression(expr
->unop
);
607 static int expand_preop(struct expression
*expr
)
613 return expand_dereference(expr
);
616 return expand_addressof(expr
);
618 case SPECIAL_INCREMENT
:
619 case SPECIAL_DECREMENT
:
621 * From a type evaluation standpoint the pre-ops are
622 * the same as the postops
624 return expand_postop(expr
);
629 cost
= expand_expression(expr
->unop
);
631 if (simplify_preop(expr
))
633 if (simplify_float_preop(expr
))
638 static int expand_arguments(struct expression_list
*head
)
641 struct expression
*expr
;
643 FOR_EACH_PTR (head
, expr
) {
644 cost
+= expand_expression(expr
);
645 } END_FOR_EACH_PTR(expr
);
649 static int expand_cast(struct expression
*expr
)
652 struct expression
*target
= expr
->cast_expression
;
654 cost
= expand_expression(target
);
656 /* Simplify normal integer casts.. */
657 if (target
->type
== EXPR_VALUE
|| target
->type
== EXPR_FVALUE
) {
658 cast_value(expr
, expr
->ctype
, target
, target
->ctype
);
664 /* The arguments are constant if the cost of all of them is zero */
665 int expand_constant_p(struct expression
*expr
, int cost
)
667 expr
->type
= EXPR_VALUE
;
672 /* The arguments are safe, if their cost is less than SIDE_EFFECTS */
673 int expand_safe_p(struct expression
*expr
, int cost
)
675 expr
->type
= EXPR_VALUE
;
676 expr
->value
= (cost
< SIDE_EFFECTS
);
681 * expand a call expression with a symbol. This
682 * should expand builtins.
684 static int expand_symbol_call(struct expression
*expr
, int cost
)
686 struct expression
*fn
= expr
->fn
;
687 struct symbol
*ctype
= fn
->ctype
;
689 if (fn
->type
!= EXPR_PREOP
)
692 if (ctype
->op
&& ctype
->op
->expand
)
693 return ctype
->op
->expand(expr
, cost
);
698 static int expand_call(struct expression
*expr
)
702 struct expression
*fn
= expr
->fn
;
704 cost
= expand_arguments(expr
->args
);
707 error(expr
->pos
, "function has no type");
710 if (sym
->type
== SYM_NODE
)
711 return expand_symbol_call(expr
, cost
);
716 static int expand_expression_list(struct expression_list
*list
)
719 struct expression
*expr
;
721 FOR_EACH_PTR(list
, expr
) {
722 cost
+= expand_expression(expr
);
723 } END_FOR_EACH_PTR(expr
);
728 * We can simplify nested position expressions if
729 * this is a simple (single) positional expression.
731 static int expand_pos_expression(struct expression
*expr
)
733 struct expression
*nested
= expr
->init_expr
;
734 unsigned long offset
= expr
->init_offset
;
735 int nr
= expr
->init_nr
;
738 switch (nested
->type
) {
740 offset
+= nested
->init_offset
;
742 expr
->init_offset
= offset
;
746 case EXPR_INITIALIZER
: {
747 struct expression
*reuse
= nested
, *entry
;
749 FOR_EACH_PTR(expr
->expr_list
, entry
) {
750 if (entry
->type
== EXPR_POS
) {
751 entry
->init_offset
+= offset
;
755 * This happens rarely, but it can happen
756 * with bitfields that are all at offset
759 reuse
= alloc_expression(entry
->pos
, EXPR_POS
);
761 reuse
->type
= EXPR_POS
;
762 reuse
->ctype
= entry
->ctype
;
763 reuse
->init_offset
= offset
;
765 reuse
->init_expr
= entry
;
766 REPLACE_CURRENT_PTR(entry
, reuse
);
769 } END_FOR_EACH_PTR(entry
);
778 return expand_expression(nested
);
781 static int compare_expressions(const void *_a
, const void *_b
)
783 const struct expression
*a
= _a
;
784 const struct expression
*b
= _b
;
787 r
= (b
->type
!= EXPR_POS
) - (a
->type
!= EXPR_POS
);
790 if (a
->init_offset
< b
->init_offset
)
792 if (a
->init_offset
> b
->init_offset
)
794 /* Check bitfield offset.. */
798 if (a
->ctype
&& b
->ctype
) {
799 if (a
->ctype
->bit_offset
< b
->ctype
->bit_offset
)
807 static void sort_expression_list(struct expression_list
**list
)
809 sort_list((struct ptr_list
**)list
, compare_expressions
);
812 static int expand_expression(struct expression
*expr
)
819 switch (expr
->type
) {
826 return expand_symbol_expression(expr
);
828 return expand_binop(expr
);
831 return expand_logical(expr
);
834 return expand_comma(expr
);
837 return expand_compare(expr
);
839 case EXPR_ASSIGNMENT
:
840 return expand_assignment(expr
);
843 return expand_preop(expr
);
846 return expand_postop(expr
);
849 case EXPR_IMPLIED_CAST
:
850 return expand_cast(expr
);
853 return expand_call(expr
);
856 warning(expr
->pos
, "we should not have an EXPR_DEREF left at expansion time");
860 case EXPR_CONDITIONAL
:
861 return expand_conditional(expr
);
863 case EXPR_STATEMENT
: {
864 struct statement
*stmt
= expr
->statement
;
865 int cost
= expand_statement(stmt
);
867 if (stmt
->type
== STMT_EXPRESSION
)
868 *expr
= *stmt
->expression
;
875 case EXPR_INITIALIZER
:
876 sort_expression_list(&expr
->expr_list
);
877 return expand_expression_list(expr
->expr_list
);
879 case EXPR_IDENTIFIER
:
886 return expand_expression(expr
->base
) + 1;
889 return expand_pos_expression(expr
);
894 warning(expr
->pos
, "internal front-end error: sizeof in expansion?");
900 static void expand_const_expression(struct expression
*expr
, const char *where
)
903 expand_expression(expr
);
904 if (expr
->type
!= EXPR_VALUE
)
905 warning(expr
->pos
, "Expected constant expression in %s", where
);
909 void expand_symbol(struct symbol
*sym
)
911 struct symbol
*base_type
;
915 base_type
= sym
->ctype
.base_type
;
919 expand_expression(sym
->initializer
);
920 /* expand the body of the symbol */
921 if (base_type
->type
== SYM_FN
) {
923 expand_statement(base_type
->stmt
);
927 static void expand_return_expression(struct statement
*stmt
)
929 expand_expression(stmt
->expression
);
932 static int expand_if_statement(struct statement
*stmt
)
934 struct expression
*expr
= stmt
->if_conditional
;
936 if (!expr
|| !expr
->ctype
)
939 expand_expression(expr
);
941 /* This is only valid if nobody jumps into the "dead" side */
943 /* Simplify constant conditionals without even evaluating the false side */
944 if (expr
->type
== EXPR_VALUE
) {
945 struct statement
*simple
;
946 simple
= expr
->value
? stmt
->if_true
: stmt
->if_false
;
950 stmt
->type
= STMT_NONE
;
953 expand_statement(simple
);
958 expand_statement(stmt
->if_true
);
959 expand_statement(stmt
->if_false
);
964 * Expanding a compound statement is really just
965 * about adding up the costs of each individual
968 * We also collapse a simple compound statement:
969 * this would trigger for simple inline functions,
970 * except we would have to check the "return"
971 * symbol usage. Next time.
973 static int expand_compound(struct statement
*stmt
)
976 struct statement
*s
, *last
;
977 int cost
, symbols
, statements
;
980 FOR_EACH_PTR(stmt
->syms
, sym
) {
983 } END_FOR_EACH_PTR(sym
);
987 expand_symbol(stmt
->ret
);
993 FOR_EACH_PTR(stmt
->stmts
, s
) {
996 cost
+= expand_statement(s
);
997 } END_FOR_EACH_PTR(s
);
999 if (!symbols
&& statements
== 1)
1005 static int expand_statement(struct statement
*stmt
)
1010 switch (stmt
->type
) {
1012 expand_return_expression(stmt
);
1013 return SIDE_EFFECTS
;
1015 case STMT_EXPRESSION
:
1016 return expand_expression(stmt
->expression
);
1019 return expand_compound(stmt
);
1022 return expand_if_statement(stmt
);
1025 expand_expression(stmt
->iterator_pre_condition
);
1026 expand_expression(stmt
->iterator_post_condition
);
1027 expand_statement(stmt
->iterator_pre_statement
);
1028 expand_statement(stmt
->iterator_statement
);
1029 expand_statement(stmt
->iterator_post_statement
);
1030 return SIDE_EFFECTS
;
1033 expand_expression(stmt
->switch_expression
);
1034 expand_statement(stmt
->switch_statement
);
1035 return SIDE_EFFECTS
;
1038 expand_const_expression(stmt
->case_expression
, "case statement");
1039 expand_const_expression(stmt
->case_to
, "case statement");
1040 expand_statement(stmt
->case_statement
);
1041 return SIDE_EFFECTS
;
1044 expand_statement(stmt
->label_statement
);
1045 return SIDE_EFFECTS
;
1048 expand_expression(stmt
->goto_expression
);
1049 return SIDE_EFFECTS
;
1054 /* FIXME! Do the asm parameter evaluation! */
1057 expand_expression(stmt
->expression
);
1060 return SIDE_EFFECTS
;
1063 long long get_expression_value(struct expression
*expr
)
1065 long long value
, mask
;
1066 struct symbol
*ctype
;
1070 ctype
= evaluate_expression(expr
);
1072 warning(expr
->pos
, "bad constant expression type");
1075 expand_expression(expr
);
1076 if (expr
->type
!= EXPR_VALUE
) {
1077 warning(expr
->pos
, "bad constant expression");
1081 value
= expr
->value
;
1082 mask
= 1ULL << (ctype
->bit_size
-1);
1085 while (ctype
->type
!= SYM_BASETYPE
)
1086 ctype
= ctype
->ctype
.base_type
;
1087 if (!(ctype
->ctype
.modifiers
& MOD_UNSIGNED
))
1088 value
= value
| mask
| ~(mask
-1);