aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2024-07-19 18:22:26 +0200
committerGeorg-Johann Lay <avr@gjlay.de>2024-07-19 18:24:35 +0200
commit9116490c1b03dac18f10e42df03731a3aed0b4e9 (patch)
treec34aeb3c3e1f3dfd743fd1b0cdb1f0048ebc7222 /gcc/doc
parent8d6994f33a98a168151a57a3d21395b19196cd9d (diff)
downloadgcc-9116490c1b03dac18f10e42df03731a3aed0b4e9.zip
gcc-9116490c1b03dac18f10e42df03731a3aed0b4e9.tar.gz
gcc-9116490c1b03dac18f10e42df03731a3aed0b4e9.tar.bz2
AVR: Support new built-in function __builtin_avr_mask1.
gcc/ * config/avr/builtins.def (MASK1): New DEF_BUILTIN. * config/avr/avr.cc (avr_rtx_costs_1): Handle rtx costs for expressions like __builtin_avr_mask1. (avr_init_builtins) <uintQI_ftype_uintQI_uintQI>: New tree type. (avr_expand_builtin) [AVR_BUILTIN_MASK1]: Diagnose unexpected forms. (avr_fold_builtin) [AVR_BUILTIN_MASK1]: Handle case. * config/avr/avr.md (gen_mask1): New expand helper. (mask1_0x01_split, mask1_0x80_split, mask1_0xfe_split): New insn-and-split. (*mask1_0x01, *mask1_0x80, *mask1_0xfe): New insns. * doc/extend.texi (AVR Built-in Functions) <__builtin_avr_mask1>: Document new built-in function. gcc/testsuite/ * gcc.target/avr/torture/builtin-mask1.c: New test.
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 0b572af..4b77599 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -16974,6 +16974,23 @@ __builtin_avr_insert_bits (0x01234567, bits, 0);
@end smallexample
@enddefbuiltin
+@defbuiltin{uint8_t __builtin_avr_mask1 (uint8_t @var{mask}, uint8_t @var{offs})}
+Rotate the 8-bit constant value @var{mask} by an offset of @var{offs},
+where @var{mask} is in @{ 0x01, 0xfe, 0x7f, 0x80 @}.
+This built-in can be use as an alternative to 8-bit expressions like
+@code{1 << offs} when their computation consumes too much
+time, and @var{offs} is known to be in the range 0@dots{}7.
+@example
+__builtin_avr_mask1 (1, offs) // same like 1 << offs
+__builtin_avr_mask1 (~1, offs) // same like ~(1 << offs)
+__builtin_avr_mask1 (0x80, offs) // same like 0x80 >> offs
+__builtin_avr_mask1 (~0x80, offs) // same like ~(0x80 >> offs)
+@end example
+The open coded C versions take at least @code{5 + 4 * @var{offs}} cycles
+(and 5 instructions), whereas the built-in takes 7 cycles and instructions
+(8 cycles and instructions in the case of @code{@var{mask} = 0x7f}).
+@enddefbuiltin
+
@defbuiltin{void __builtin_avr_nops (uint16_t @var{count})}
Insert @var{count} @code{NOP} instructions.
The number of instructions must be a compile-time integer constant.