aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2012-02-15 11:07:13 +0000
committerGeorg-Johann Lay <gjl@gcc.gnu.org>2012-02-15 11:07:13 +0000
commit0c578db6dd12d39618ad2500a80bae4ba38cf260 (patch)
treed0f461ea25e3c5aa9869284994ea04eb6955c835 /gcc/doc
parent1c4ae4e58752c06aaa99bae702aa0ae2e2123548 (diff)
downloadgcc-0c578db6dd12d39618ad2500a80bae4ba38cf260.zip
gcc-0c578db6dd12d39618ad2500a80bae4ba38cf260.tar.gz
gcc-0c578db6dd12d39618ad2500a80bae4ba38cf260.tar.bz2
builtin_insert_bits-1.c: New test.
gcc/testsuite/ * gcc.target/avr/torture/builtin_insert_bits-1.c: New test. * gcc.target/avr/torture/builtin_insert_bits-2.c: New test. gcc/ * doc/extend.texi (AVR Built-in Functions): Remove doc for __builtin_avr_map8, __builtin_avr_map16. Document __builtin_avr_insert_bits. * config/avr/avr.md (map_bitsqi, map_bitshi): Remove. (insert_bits): New insn. (adjust_len.map_bits): Rename to insert_bits. (UNSPEC_MAP_BITS): Rename to UNSPEC_INSERT_BITS. * avr-protos.h (avr_out_map_bits): Remove. (avr_out_insert_bits, avr_has_nibble_0xf): New. * config/avr/constraints.md (Cxf,C0f): New. * config/avr/avr.c (avr_cpu_cpp_builtins): Remove built-in defines __BUILTIN_AVR_MAP8, __BUILTIN_AVR_MAP16. New built-in define __BUILTIN_AVR_INSERT_BITS. * config/avr/avr.c (TARGET_FOLD_BUILTIN): New define. (enum avr_builtin_id): Add AVR_BUILTIN_INSERT_BITS. (avr_move_bits): Rewrite. (avr_fold_builtin, avr_map_metric, avr_map_decompose): New static functions. (avr_map_op_t): New typedef. (avr_map_op): New static variable. (avr_out_insert_bits, avr_has_nibble_0xf): New functions. (adjust_insn_length): Handle ADJUST_LEN_INSERT_BITS. (avr_init_builtins): Add definition for __builtin_avr_insert_bits. (bdesc_3arg, avr_expand_triop_builtin): New. (avr_expand_builtin): Use them. And handle AVR_BUILTIN_INSERT_BITS. (avr_revert_map, avr_swap_map, avr_id_map, avr_sig_map): Remove. (avr_map_hamming_byte, avr_map_hamming_nonstrict): Remove. (avr_map_equal_p, avr_map_sig_p): Remove. (avr_out_swap_bits, avr_out_revert_bits, avr_out_map_bits): Remove. (bdesc_2arg): Remove AVR_BUILTIN_MAP8, AVR_BUILTIN_MAP16. (adjust_insn_length): Remove handling for ADJUST_LEN_MAP_BITS. (enum avr_builtin_id): Remove AVR_BUILTIN_MAP8, AVR_BUILTIN_MAP16. (avr_init_builtins): Remove __builtin_avr_map8, __builtin_avr_map16. (avr_expand_builtin): Remove AVR_BUILTIN_MAP8, AVR_BUILTIN_MAP16. From-SVN: r184264
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi56
1 files changed, 38 insertions, 18 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 4c71960..b666a2e 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -8812,33 +8812,53 @@ might increase delay time. @code{ticks} must be a compile time
integer constant; delays with a variable number of cycles are not supported.
@smallexample
- unsigned char __builtin_avr_map8 (unsigned long map, unsigned char val)
+ unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
@end smallexample
@noindent
-Each bit of the result is copied from a specific bit of @code{val}.
-@code{map} is a compile time constant that represents a map composed
-of 8 nibbles (4-bit groups):
-The @var{n}-th nibble of @code{map} specifies which bit of @code{val}
-is to be moved to the @var{n}-th bit of the result.
-For example, @code{map = 0x76543210} represents identity: The MSB of
-the result is read from the 7-th bit of @code{val}, the LSB is
-read from the 0-th bit to @code{val}, etc.
-Two more examples: @code{0x01234567} reverses the bit order and
-@code{0x32107654} is equivalent to a @code{swap} instruction.
+Insert bits from @var{bits} into @var{val} and return the resulting
+value. The nibbles of @var{map} determine how the insertion is
+performed: Let @var{X} be the @var{n}-th nibble of @var{map}
+@enumerate
+@item If @var{X} is @code{0xf},
+then the @var{n}-th bit of @var{val} is returned unaltered.
+
+@item If X is in the range 0@dots{}7,
+then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
+
+@item If X is in the range 8@dots{}@code{0xe},
+then the @var{n}-th result bit is undefined.
+@end enumerate
@noindent
-One typical use case for this and the following built-in is adjusting input and
-output values to non-contiguous port layouts.
+One typical use case for this built-in is adjusting input and
+output values to non-contiguous port layouts. Some examples:
@smallexample
- unsigned int __builtin_avr_map16 (unsigned long long map, unsigned int val)
+// same as val, bits is unused
+__builtin_avr_insert_bits (0xffffffff, bits, val)
@end smallexample
-@noindent
-Similar to the previous built-in except that it operates on @code{int}
-and thus 16 bits are involved. Again, @code{map} must be a compile
-time constant.
+@smallexample
+// same as bits, val is unused
+__builtin_avr_insert_bits (0x76543210, bits, val)
+@end smallexample
+
+@smallexample
+// same as rotating bits by 4
+__builtin_avr_insert_bits (0x32107654, bits, 0)
+@end smallexample
+
+@smallexample
+// high-nibble of result is the high-nibble of val
+// low-nibble of result is the low-nibble of bits
+__builtin_avr_insert_bits (0xffff3210, bits, val)
+@end smallexample
+
+@smallexample
+// reverse the bit order of bits
+__builtin_avr_insert_bits (0x01234567, bits, 0)
+@end smallexample
@node Blackfin Built-in Functions
@subsection Blackfin Built-in Functions