comparison gcc/doc/md.texi @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents 58ad6c70ea60
children f6334be47118
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
550 @cindex @code{#} in template 550 @cindex @code{#} in template
551 As a special case, a template consisting of the single character @code{#} 551 As a special case, a template consisting of the single character @code{#}
552 instructs the compiler to first split the insn, and then output the 552 instructs the compiler to first split the insn, and then output the
553 resulting instructions separately. This helps eliminate redundancy in the 553 resulting instructions separately. This helps eliminate redundancy in the
554 output templates. If you have a @code{define_insn} that needs to emit 554 output templates. If you have a @code{define_insn} that needs to emit
555 multiple assembler instructions, and there is an matching @code{define_split} 555 multiple assembler instructions, and there is a matching @code{define_split}
556 already defined, then you can simply use @code{#} as the output template 556 already defined, then you can simply use @code{#} as the output template
557 instead of writing an output template that emits the multiple assembler 557 instead of writing an output template that emits the multiple assembler
558 instructions. 558 instructions.
559 559
560 If the macro @code{ASSEMBLER_DIALECT} is defined, you can use construct 560 If the macro @code{ASSEMBLER_DIALECT} is defined, you can use construct
858 This predicate allows any immediate, register, or memory operand 858 This predicate allows any immediate, register, or memory operand
859 valid for @var{mode}. 859 valid for @var{mode}.
860 @end defun 860 @end defun
861 861
862 @noindent 862 @noindent
863 Finally, there is one generic operator predicate. 863 Finally, there are two generic operator predicates.
864 864
865 @defun comparison_operator 865 @defun comparison_operator
866 This predicate matches any expression which performs an arithmetic 866 This predicate matches any expression which performs an arithmetic
867 comparison in @var{mode}; that is, @code{COMPARISON_P} is true for the 867 comparison in @var{mode}; that is, @code{COMPARISON_P} is true for the
868 expression code. 868 expression code.
869 @end defun
870
871 @defun ordered_comparison_operator
872 This predicate matches any expression which performs an arithmetic
873 comparison in @var{mode} and whose expression code is valid for integer
874 modes; that is, the expression code will be one of @code{eq}, @code{ne},
875 @code{lt}, @code{ltu}, @code{le}, @code{leu}, @code{gt}, @code{gtu},
876 @code{ge}, @code{geu}.
869 @end defun 877 @end defun
870 878
871 @node Defining Predicates 879 @node Defining Predicates
872 @subsection Defining Machine-Specific Predicates 880 @subsection Defining Machine-Specific Predicates
873 @cindex defining predicates 881 @cindex defining predicates
1746 1754
1747 @item G 1755 @item G
1748 A floating point constant 0.0 1756 A floating point constant 0.0
1749 1757
1750 @item R 1758 @item R
1751 Integer constant in the range -6 @dots{} 5. 1759 Integer constant in the range @minus{}6 @dots{} 5.
1752 1760
1753 @item Q 1761 @item Q
1754 A memory address based on Y or Z pointer with displacement. 1762 A memory address based on Y or Z pointer with displacement.
1755 @end table 1763 @end table
1756 1764
1777 1785
1778 @item K 1786 @item K
1779 Constant that fits in 5 bits 1787 Constant that fits in 5 bits
1780 1788
1781 @item L 1789 @item L
1782 Constant that is one of -1, 4, -4, 7, 8, 12, 16, 20, 32, 48 1790 Constant that is one of @minus{}1, 4, @minus{}4, 7, 8, 12, 16, 20, 32, 48
1783 1791
1784 @item G 1792 @item G
1785 Floating point constant that is legal for store immediate 1793 Floating point constant that is legal for store immediate
1786 @end table 1794 @end table
1787 1795
1899 @item PowerPC and IBM RS6000---@file{config/rs6000/rs6000.h} 1907 @item PowerPC and IBM RS6000---@file{config/rs6000/rs6000.h}
1900 @table @code 1908 @table @code
1901 @item b 1909 @item b
1902 Address base register 1910 Address base register
1903 1911
1912 @item d
1913 Floating point register (containing 64-bit value)
1914
1904 @item f 1915 @item f
1905 Floating point register 1916 Floating point register (containing 32-bit value)
1906 1917
1907 @item v 1918 @item v
1908 Vector register 1919 Altivec vector register
1920
1921 @item wd
1922 VSX vector register to hold vector double data
1923
1924 @item wf
1925 VSX vector register to hold vector float data
1926
1927 @item ws
1928 VSX vector register to hold scalar float data
1929
1930 @item wa
1931 Any VSX register
1909 1932
1910 @item h 1933 @item h
1911 @samp{MQ}, @samp{CTR}, or @samp{LINK} register 1934 @samp{MQ}, @samp{CTR}, or @samp{LINK} register
1912 1935
1913 @item q 1936 @item q
1959 1982
1960 @item H 1983 @item H
1961 Integer/Floating point constant that can be loaded into a register using 1984 Integer/Floating point constant that can be loaded into a register using
1962 three instructions 1985 three instructions
1963 1986
1987 @item m
1988 Memory operand. Note that on PowerPC targets, @code{m} can include
1989 addresses that update the base register. It is therefore only safe
1990 to use @samp{m} in an @code{asm} statement if that @code{asm} statement
1991 accesses the operand exactly once. The @code{asm} statement must also
1992 use @samp{%U@var{<opno>}} as a placeholder for the ``update'' flag in the
1993 corresponding load or store instruction. For example:
1994
1995 @smallexample
1996 asm ("st%U0 %1,%0" : "=m" (mem) : "r" (val));
1997 @end smallexample
1998
1999 is correct but:
2000
2001 @smallexample
2002 asm ("st %1,%0" : "=m" (mem) : "r" (val));
2003 @end smallexample
2004
2005 is not. Use @code{es} rather than @code{m} if you don't want the
2006 base register to be updated.
2007
2008 @item es
2009 A ``stable'' memory operand; that is, one which does not include any
2010 automodification of the base register. Unlike @samp{m}, this constraint
2011 can be used in @code{asm} statements that might access the operand
2012 several times, or that might not access it at all.
2013
1964 @item Q 2014 @item Q
1965 Memory operand that is an offset from a register (@samp{m} is preferable 2015 Memory operand that is an offset from a register (it is usually better
1966 for @code{asm} statements) 2016 to use @samp{m} or @samp{es} in @code{asm} statements)
1967 2017
1968 @item Z 2018 @item Z
1969 Memory operand that is an indexed or indirect from a register (@samp{m} is 2019 Memory operand that is an indexed or indirect from a register (it is
1970 preferable for @code{asm} statements) 2020 usually better to use @samp{m} or @samp{es} in @code{asm} statements)
1971 2021
1972 @item R 2022 @item R
1973 AIX TOC entry 2023 AIX TOC entry
1974 2024
1975 @item a 2025 @item a
1988 @item t 2038 @item t
1989 AND masks that can be performed by two rldic@{l, r@} instructions 2039 AND masks that can be performed by two rldic@{l, r@} instructions
1990 2040
1991 @item W 2041 @item W
1992 Vector constant that does not require memory 2042 Vector constant that does not require memory
2043
2044 @item j
2045 Vector constant that is all zeros.
1993 2046
1994 @end table 2047 @end table
1995 2048
1996 @item Intel 386---@file{config/i386/constraints.md} 2049 @item Intel 386---@file{config/i386/constraints.md}
1997 @table @code 2050 @table @code
2326 2379
2327 @item w 2380 @item w
2328 Any register except accumulators or CC. 2381 Any register except accumulators or CC.
2329 2382
2330 @item Ksh 2383 @item Ksh
2331 Signed 16 bit integer (in the range -32768 to 32767) 2384 Signed 16 bit integer (in the range @minus{}32768 to 32767)
2332 2385
2333 @item Kuh 2386 @item Kuh
2334 Unsigned 16 bit integer (in the range 0 to 65535) 2387 Unsigned 16 bit integer (in the range 0 to 65535)
2335 2388
2336 @item Ks7 2389 @item Ks7
2337 Signed 7 bit integer (in the range -64 to 63) 2390 Signed 7 bit integer (in the range @minus{}64 to 63)
2338 2391
2339 @item Ku7 2392 @item Ku7
2340 Unsigned 7 bit integer (in the range 0 to 127) 2393 Unsigned 7 bit integer (in the range 0 to 127)
2341 2394
2342 @item Ku5 2395 @item Ku5
2343 Unsigned 5 bit integer (in the range 0 to 31) 2396 Unsigned 5 bit integer (in the range 0 to 31)
2344 2397
2345 @item Ks4 2398 @item Ks4
2346 Signed 4 bit integer (in the range -8 to 7) 2399 Signed 4 bit integer (in the range @minus{}8 to 7)
2347 2400
2348 @item Ks3 2401 @item Ks3
2349 Signed 3 bit integer (in the range -3 to 4) 2402 Signed 3 bit integer (in the range @minus{}3 to 4)
2350 2403
2351 @item Ku3 2404 @item Ku3
2352 Unsigned 3 bit integer (in the range 0 to 7) 2405 Unsigned 3 bit integer (in the range 0 to 7)
2353 2406
2354 @item P@var{n} 2407 @item P@var{n}
2456 @item Rpa 2509 @item Rpa
2457 Matches multiple registers in a PARALLEL to form a larger register. 2510 Matches multiple registers in a PARALLEL to form a larger register.
2458 Used to match function return values. 2511 Used to match function return values.
2459 2512
2460 @item Is3 2513 @item Is3
2461 -8 @dots{} 7 2514 @minus{}8 @dots{} 7
2462 2515
2463 @item IS1 2516 @item IS1
2464 -128 @dots{} 127 2517 @minus{}128 @dots{} 127
2465 2518
2466 @item IS2 2519 @item IS2
2467 -32768 @dots{} 32767 2520 @minus{}32768 @dots{} 32767
2468 2521
2469 @item IU2 2522 @item IU2
2470 0 @dots{} 65535 2523 0 @dots{} 65535
2471 2524
2472 @item In4 2525 @item In4
2473 -8 @dots{} -1 or 1 @dots{} 8 2526 @minus{}8 @dots{} @minus{}1 or 1 @dots{} 8
2474 2527
2475 @item In5 2528 @item In5
2476 -16 @dots{} -1 or 1 @dots{} 16 2529 @minus{}16 @dots{} @minus{}1 or 1 @dots{} 16
2477 2530
2478 @item In6 2531 @item In6
2479 -32 @dots{} -1 or 1 @dots{} 32 2532 @minus{}32 @dots{} @minus{}1 or 1 @dots{} 32
2480 2533
2481 @item IM2 2534 @item IM2
2482 -65536 @dots{} -1 2535 @minus{}65536 @dots{} @minus{}1
2483 2536
2484 @item Ilb 2537 @item Ilb
2485 An 8 bit value with exactly one bit set. 2538 An 8 bit value with exactly one bit set.
2486 2539
2487 @item Ilw 2540 @item Ilw
2505 @item Ss 2558 @item Ss
2506 Memory addressed using the small base register ($sb). 2559 Memory addressed using the small base register ($sb).
2507 2560
2508 @item S1 2561 @item S1
2509 $r1h 2562 $r1h
2563 @end table
2564
2565 @item MeP---@file{config/mep/constraints.md}
2566 @table @code
2567
2568 @item a
2569 The $sp register.
2570
2571 @item b
2572 The $tp register.
2573
2574 @item c
2575 Any control register.
2576
2577 @item d
2578 Either the $hi or the $lo register.
2579
2580 @item em
2581 Coprocessor registers that can be directly loaded ($c0-$c15).
2582
2583 @item ex
2584 Coprocessor registers that can be moved to each other.
2585
2586 @item er
2587 Coprocessor registers that can be moved to core registers.
2588
2589 @item h
2590 The $hi register.
2591
2592 @item j
2593 The $rpc register.
2594
2595 @item l
2596 The $lo register.
2597
2598 @item t
2599 Registers which can be used in $tp-relative addressing.
2600
2601 @item v
2602 The $gp register.
2603
2604 @item x
2605 The coprocessor registers.
2606
2607 @item y
2608 The coprocessor control registers.
2609
2610 @item z
2611 The $0 register.
2612
2613 @item A
2614 User-defined register set A.
2615
2616 @item B
2617 User-defined register set B.
2618
2619 @item C
2620 User-defined register set C.
2621
2622 @item D
2623 User-defined register set D.
2624
2625 @item I
2626 Offsets for $gp-rel addressing.
2627
2628 @item J
2629 Constants that can be used directly with boolean insns.
2630
2631 @item K
2632 Constants that can be moved directly to registers.
2633
2634 @item L
2635 Small constants that can be added to registers.
2636
2637 @item M
2638 Long shift counts.
2639
2640 @item N
2641 Small constants that can be compared to registers.
2642
2643 @item O
2644 Constants that can be loaded into the top half of registers.
2645
2646 @item S
2647 Signed 8-bit immediates.
2648
2649 @item T
2650 Symbols encoded for $tp-rel or $gp-rel addressing.
2651
2652 @item U
2653 Non-constant addresses for loading/saving coprocessor registers.
2654
2655 @item W
2656 The top half of a symbol's value.
2657
2658 @item Y
2659 A register indirect address without offset.
2660
2661 @item Z
2662 Symbolic references to the control bus.
2663
2664
2665
2510 @end table 2666 @end table
2511 2667
2512 @item MIPS---@file{config/mips/constraints.md} 2668 @item MIPS---@file{config/mips/constraints.md}
2513 @table @code 2669 @table @code
2514 @item d 2670 @item d
2559 @item M 2715 @item M
2560 A constant that cannot be loaded using @code{lui}, @code{addiu} 2716 A constant that cannot be loaded using @code{lui}, @code{addiu}
2561 or @code{ori}. 2717 or @code{ori}.
2562 2718
2563 @item N 2719 @item N
2564 A constant in the range -65535 to -1 (inclusive). 2720 A constant in the range @minus{}65535 to @minus{}1 (inclusive).
2565 2721
2566 @item O 2722 @item O
2567 A signed 15-bit constant. 2723 A signed 15-bit constant.
2568 2724
2569 @item P 2725 @item P
2717 @item O 2873 @item O
2718 Constant integer 16 2874 Constant integer 16
2719 2875
2720 @item P 2876 @item P
2721 Constants in the range @minus{}8 to 2 2877 Constants in the range @minus{}8 to 2
2878
2879 @end table
2880
2881 @item Moxie---@file{config/moxie/constraints.md}
2882 @table @code
2883 @item A
2884 An absolute address
2885
2886 @item B
2887 An offset address
2888
2889 @item W
2890 A register indirect memory operand
2891
2892 @item I
2893 A constant in the range of 0 to 255.
2894
2895 @item N
2896 A constant in the range of 0 to @minus{}255.
2897
2898 @end table
2899
2900 @item RX---@file{config/rx/constraints.md}
2901 @table @code
2902 @item Q
2903 An address which does not involve register indirect addressing or
2904 pre/post increment/decrement addressing.
2905
2906 @item Symbol
2907 A symbol reference.
2908
2909 @item Int08
2910 A constant in the range @minus{}256 to 255, inclusive.
2911
2912 @item Sint08
2913 A constant in the range @minus{}128 to 127, inclusive.
2914
2915 @item Sint16
2916 A constant in the range @minus{}32768 to 32767, inclusive.
2917
2918 @item Sint24
2919 A constant in the range @minus{}8388608 to 8388607, inclusive.
2920
2921 @item Uint04
2922 A constant in the range 0 to 15, inclusive.
2722 2923
2723 @end table 2924 @end table
2724 2925
2725 @need 1000 2926 @need 1000
2726 @item SPARC---@file{config/sparc/sparc.h} 2927 @item SPARC---@file{config/sparc/sparc.h}
2835 3036
2836 @item D 3037 @item D
2837 An immediate for the @code{iohl} instruction. const_int is treated as a 32 bit value. 3038 An immediate for the @code{iohl} instruction. const_int is treated as a 32 bit value.
2838 3039
2839 @item I 3040 @item I
2840 A constant in the range [-64, 63] for shift/rotate instructions. 3041 A constant in the range [@minus{}64, 63] for shift/rotate instructions.
2841 3042
2842 @item J 3043 @item J
2843 An unsigned 7-bit constant for conversion/nop/channel instructions. 3044 An unsigned 7-bit constant for conversion/nop/channel instructions.
2844 3045
2845 @item K 3046 @item K
2906 @item L 3107 @item L
2907 Value appropriate as displacement. 3108 Value appropriate as displacement.
2908 @table @code 3109 @table @code
2909 @item (0..4095) 3110 @item (0..4095)
2910 for short displacement 3111 for short displacement
2911 @item (-524288..524287) 3112 @item (@minus{}524288..524287)
2912 for long displacement 3113 for long displacement
2913 @end table 3114 @end table
2914 3115
2915 @item M 3116 @item M
2916 Constant integer with a value of 0x7fffffff. 3117 Constant integer with a value of 0x7fffffff.
3313 register. The constraint letter @samp{Q} is defined to represent a 3514 register. The constraint letter @samp{Q} is defined to represent a
3314 memory address of this type. If @samp{Q} is defined with 3515 memory address of this type. If @samp{Q} is defined with
3315 @code{define_memory_constraint}, a @samp{Q} constraint can handle any 3516 @code{define_memory_constraint}, a @samp{Q} constraint can handle any
3316 memory operand, because @code{reload} knows it can simply copy the 3517 memory operand, because @code{reload} knows it can simply copy the
3317 memory address into a base register if required. This is analogous to 3518 memory address into a base register if required. This is analogous to
3318 the way a @samp{o} constraint can handle any memory operand. 3519 the way an @samp{o} constraint can handle any memory operand.
3319 3520
3320 The syntax and semantics are otherwise identical to 3521 The syntax and semantics are otherwise identical to
3321 @code{define_constraint}. 3522 @code{define_constraint}.
3322 @end deffn 3523 @end deffn
3323 3524
4226 4427
4227 @cindex @code{one_cmpl@var{m}2} instruction pattern 4428 @cindex @code{one_cmpl@var{m}2} instruction pattern
4228 @item @samp{one_cmpl@var{m}2} 4429 @item @samp{one_cmpl@var{m}2}
4229 Store the bitwise-complement of operand 1 into operand 0. 4430 Store the bitwise-complement of operand 1 into operand 0.
4230 4431
4231 @cindex @code{cmp@var{m}} instruction pattern
4232 @item @samp{cmp@var{m}}
4233 Compare operand 0 and operand 1, and set the condition codes.
4234 The RTL pattern should look like this:
4235
4236 @smallexample
4237 (set (cc0) (compare (match_operand:@var{m} 0 @dots{})
4238 (match_operand:@var{m} 1 @dots{})))
4239 @end smallexample
4240
4241 @cindex @code{tst@var{m}} instruction pattern
4242 @item @samp{tst@var{m}}
4243 Compare operand 0 against zero, and set the condition codes.
4244 The RTL pattern should look like this:
4245
4246 @smallexample
4247 (set (cc0) (match_operand:@var{m} 0 @dots{}))
4248 @end smallexample
4249
4250 @samp{tst@var{m}} patterns should not be defined for machines that do
4251 not use @code{(cc0)}. Doing so would confuse the optimizer since it
4252 would no longer be clear which @code{set} operations were comparisons.
4253 The @samp{cmp@var{m}} patterns should be used instead.
4254
4255 @cindex @code{movmem@var{m}} instruction pattern 4432 @cindex @code{movmem@var{m}} instruction pattern
4256 @item @samp{movmem@var{m}} 4433 @item @samp{movmem@var{m}}
4257 Block move instruction. The destination and source blocks of memory 4434 Block move instruction. The destination and source blocks of memory
4258 are the first two operands, and both are @code{mem:BLK}s with an 4435 are the first two operands, and both are @code{mem:BLK}s with an
4259 address in mode @code{Pmode}. 4436 address in mode @code{Pmode}.
4512 Similar to @samp{mov@var{mode}cc} but for conditional addition. Conditionally 4689 Similar to @samp{mov@var{mode}cc} but for conditional addition. Conditionally
4513 move operand 2 or (operands 2 + operand 3) into operand 0 according to the 4690 move operand 2 or (operands 2 + operand 3) into operand 0 according to the
4514 comparison in operand 1. If the comparison is true, operand 2 is moved into 4691 comparison in operand 1. If the comparison is true, operand 2 is moved into
4515 operand 0, otherwise (operand 2 + operand 3) is moved. 4692 operand 0, otherwise (operand 2 + operand 3) is moved.
4516 4693
4517 @cindex @code{s@var{cond}} instruction pattern 4694 @cindex @code{cstore@var{mode}4} instruction pattern
4518 @item @samp{s@var{cond}} 4695 @item @samp{cstore@var{mode}4}
4519 Store zero or nonzero in the operand according to the condition codes. 4696 Store zero or nonzero in operand 0 according to whether a comparison
4520 Value stored is nonzero iff the condition @var{cond} is true. 4697 is true. Operand 1 is a comparison operator. Operand 2 and operand 3
4521 @var{cond} is the name of a comparison operation expression code, such 4698 are the first and second operand of the comparison, respectively.
4522 as @code{eq}, @code{lt} or @code{leu}. 4699 You specify the mode that operand 0 must have when you write the
4523 4700 @code{match_operand} expression. The compiler automatically sees which
4524 You specify the mode that the operand must have when you write the 4701 mode you have used and supplies an operand of that mode.
4525 @code{match_operand} expression. The compiler automatically sees
4526 which mode you have used and supplies an operand of that mode.
4527 4702
4528 The value stored for a true condition must have 1 as its low bit, or 4703 The value stored for a true condition must have 1 as its low bit, or
4529 else must be negative. Otherwise the instruction is not suitable and 4704 else must be negative. Otherwise the instruction is not suitable and
4530 you should omit it from the machine description. You describe to the 4705 you should omit it from the machine description. You describe to the
4531 compiler exactly which value is stored by defining the macro 4706 compiler exactly which value is stored by defining the macro
4538 integer comparisons, it is best to omit these patterns. 4713 integer comparisons, it is best to omit these patterns.
4539 4714
4540 If these operations are omitted, the compiler will usually generate code 4715 If these operations are omitted, the compiler will usually generate code
4541 that copies the constant one to the target and branches around an 4716 that copies the constant one to the target and branches around an
4542 assignment of zero to the target. If this code is more efficient than 4717 assignment of zero to the target. If this code is more efficient than
4543 the potential instructions used for the @samp{s@var{cond}} pattern 4718 the potential instructions used for the @samp{cstore@var{mode}4} pattern
4544 followed by those required to convert the result into a 1 or a zero in 4719 followed by those required to convert the result into a 1 or a zero in
4545 @code{SImode}, you should omit the @samp{s@var{cond}} operations from 4720 @code{SImode}, you should omit the @samp{cstore@var{mode}4} operations from
4546 the machine description. 4721 the machine description.
4547
4548 @cindex @code{b@var{cond}} instruction pattern
4549 @item @samp{b@var{cond}}
4550 Conditional branch instruction. Operand 0 is a @code{label_ref} that
4551 refers to the label to jump to. Jump if the condition codes meet
4552 condition @var{cond}.
4553
4554 Some machines do not follow the model assumed here where a comparison
4555 instruction is followed by a conditional branch instruction. In that
4556 case, the @samp{cmp@var{m}} (and @samp{tst@var{m}}) patterns should
4557 simply store the operands away and generate all the required insns in a
4558 @code{define_expand} (@pxref{Expander Definitions}) for the conditional
4559 branch operations. All calls to expand @samp{b@var{cond}} patterns are
4560 immediately preceded by calls to expand either a @samp{cmp@var{m}}
4561 pattern or a @samp{tst@var{m}} pattern.
4562
4563 Machines that use a pseudo register for the condition code value, or
4564 where the mode used for the comparison depends on the condition being
4565 tested, should also use the above mechanism. @xref{Jump Patterns}.
4566
4567 The above discussion also applies to the @samp{mov@var{mode}cc} and
4568 @samp{s@var{cond}} patterns.
4569 4722
4570 @cindex @code{cbranch@var{mode}4} instruction pattern 4723 @cindex @code{cbranch@var{mode}4} instruction pattern
4571 @item @samp{cbranch@var{mode}4} 4724 @item @samp{cbranch@var{mode}4}
4572 Conditional branch instruction combined with a compare instruction. 4725 Conditional branch instruction combined with a compare instruction.
4573 Operand 0 is a comparison operator. Operand 1 and operand 2 are the 4726 Operand 0 is a comparison operator. Operand 1 and operand 2 are the
4719 4872
4720 @item 4873 @item
4721 A label to jump to if the index has a value outside the bounds. 4874 A label to jump to if the index has a value outside the bounds.
4722 @end enumerate 4875 @end enumerate
4723 4876
4724 The table is a @code{addr_vec} or @code{addr_diff_vec} inside of a 4877 The table is an @code{addr_vec} or @code{addr_diff_vec} inside of a
4725 @code{jump_insn}. The number of elements in the table is one plus the 4878 @code{jump_insn}. The number of elements in the table is one plus the
4726 difference between the upper bound and the lower bound. 4879 difference between the upper bound and the lower bound.
4727 4880
4728 @cindex @code{tablejump} instruction pattern 4881 @cindex @code{tablejump} instruction pattern
4729 @item @samp{tablejump} 4882 @item @samp{tablejump}
4880 maintaining the back chain. Define this pattern to emit those 5033 maintaining the back chain. Define this pattern to emit those
4881 operations in addition to updating the stack pointer. 5034 operations in addition to updating the stack pointer.
4882 5035
4883 @cindex @code{check_stack} instruction pattern 5036 @cindex @code{check_stack} instruction pattern
4884 @item @samp{check_stack} 5037 @item @samp{check_stack}
4885 If stack checking cannot be done on your system by probing the stack with 5038 If stack checking (@pxref{Stack Checking}) cannot be done on your system by
4886 a load or store instruction (@pxref{Stack Checking}), define this pattern 5039 probing the stack, define this pattern to perform the needed check and signal
4887 to perform the needed check and signaling an error if the stack 5040 an error if the stack has overflowed. The single operand is the address in
4888 has overflowed. The single operand is the location in the stack furthest 5041 the stack farthest from the current stack pointer that you need to validate.
4889 from the current stack pointer that you need to validate. Normally, 5042 Normally, on platforms where this pattern is needed, you would obtain the
4890 on machines where this pattern is needed, you would obtain the stack 5043 stack limit from a global or thread-specific variable or register.
4891 limit from a global or thread-specific variable or register. 5044
5045 @cindex @code{probe_stack} instruction pattern
5046 @item @samp{probe_stack}
5047 If stack checking (@pxref{Stack Checking}) can be done on your system by
5048 probing the stack but doing it with a ``store zero'' instruction is not valid
5049 or optimal, define this pattern to do the probing differently and signal an
5050 error if the stack has overflowed. The single operand is the memory reference
5051 in the stack that needs to be probed.
4892 5052
4893 @cindex @code{nonlocal_goto} instruction pattern 5053 @cindex @code{nonlocal_goto} instruction pattern
4894 @item @samp{nonlocal_goto} 5054 @item @samp{nonlocal_goto}
4895 Emit code to generate a non-local goto, e.g., a jump from one function 5055 Emit code to generate a non-local goto, e.g., a jump from one function
4896 to a label in an outer function. This pattern has four arguments, 5056 to a label in an outer function. This pattern has four arguments,
4939 the @code{jmp_buf}. Note that the buffer is five words long and that 5099 the @code{jmp_buf}. Note that the buffer is five words long and that
4940 the first three are normally used by the generic mechanism. 5100 the first three are normally used by the generic mechanism.
4941 5101
4942 @cindex @code{builtin_setjmp_receiver} instruction pattern 5102 @cindex @code{builtin_setjmp_receiver} instruction pattern
4943 @item @samp{builtin_setjmp_receiver} 5103 @item @samp{builtin_setjmp_receiver}
4944 This pattern, if defined, contains code needed at the site of an 5104 This pattern, if defined, contains code needed at the site of a
4945 built-in setjmp that isn't needed at the site of a nonlocal goto. You 5105 built-in setjmp that isn't needed at the site of a nonlocal goto. You
4946 will not normally need to define this pattern. A typical reason why you 5106 will not normally need to define this pattern. A typical reason why you
4947 might need this pattern is if some value, such as a pointer to a global 5107 might need this pattern is if some value, such as a pointer to a global
4948 table, must be restored. It takes one argument, which is the label 5108 table, must be restored. It takes one argument, which is the label
4949 to which builtin_longjmp transfered control; this pattern may be emitted 5109 to which builtin_longjmp transfered control; this pattern may be emitted
5015 @item @samp{trap} 5175 @item @samp{trap}
5016 This pattern, if defined, signals an error, typically by causing some 5176 This pattern, if defined, signals an error, typically by causing some
5017 kind of signal to be raised. Among other places, it is used by the Java 5177 kind of signal to be raised. Among other places, it is used by the Java
5018 front end to signal `invalid array index' exceptions. 5178 front end to signal `invalid array index' exceptions.
5019 5179
5020 @cindex @code{conditional_trap} instruction pattern 5180 @cindex @code{ctrap@var{MM}4} instruction pattern
5021 @item @samp{conditional_trap} 5181 @item @samp{ctrap@var{MM}4}
5022 Conditional trap instruction. Operand 0 is a piece of RTL which 5182 Conditional trap instruction. Operand 0 is a piece of RTL which
5023 performs a comparison. Operand 1 is the trap code, an integer. 5183 performs a comparison, and operands 1 and 2 are the arms of the
5024 5184 comparison. Operand 3 is the trap code, an integer.
5025 A typical @code{conditional_trap} pattern looks like 5185
5026 5186 A typical @code{ctrap} pattern looks like
5027 @smallexample 5187
5028 (define_insn "conditional_trap" 5188 @smallexample
5189 (define_insn "ctrapsi4"
5029 [(trap_if (match_operator 0 "trap_operator" 5190 [(trap_if (match_operator 0 "trap_operator"
5030 [(cc0) (const_int 0)]) 5191 [(match_operand 1 "register_operand")
5031 (match_operand 1 "const_int_operand" "i"))] 5192 (match_operand 2 "immediate_operand")])
5193 (match_operand 3 "const_int_operand" "i"))]
5032 "" 5194 ""
5033 "@dots{}") 5195 "@dots{}")
5034 @end smallexample 5196 @end smallexample
5035 5197
5036 @cindex @code{prefetch} instruction pattern 5198 @cindex @code{prefetch} instruction pattern
5081 This pattern must issue any memory barrier instructions such that all 5243 This pattern must issue any memory barrier instructions such that all
5082 memory operations before the atomic operation occur before the atomic 5244 memory operations before the atomic operation occur before the atomic
5083 operation and all memory operations after the atomic operation occur 5245 operation and all memory operations after the atomic operation occur
5084 after the atomic operation. 5246 after the atomic operation.
5085 5247
5086 @cindex @code{sync_compare_and_swap_cc@var{mode}} instruction pattern 5248 For targets where the success or failure of the compare-and-swap
5087 @item @samp{sync_compare_and_swap_cc@var{mode}} 5249 operation is available via the status flags, it is possible to
5088 5250 avoid a separate compare operation and issue the subsequent
5089 This pattern is just like @code{sync_compare_and_swap@var{mode}}, except 5251 branch or store-flag operation immediately after the compare-and-swap.
5090 it should act as if compare part of the compare-and-swap were issued via 5252 To this end, GCC will look for a @code{MODE_CC} set in the
5091 @code{cmp@var{m}}. This comparison will only be used with @code{EQ} and 5253 output of @code{sync_compare_and_swap@var{mode}}; if the machine
5092 @code{NE} branches and @code{setcc} operations. 5254 description includes such a set, the target should also define special
5093 5255 @code{cbranchcc4} and/or @code{cstorecc4} instructions. GCC will then
5094 Some targets do expose the success or failure of the compare-and-swap 5256 be able to take the destination of the @code{MODE_CC} set and pass it
5095 operation via the status flags. Ideally we wouldn't need a separate 5257 to the @code{cbranchcc4} or @code{cstorecc4} pattern as the first
5096 named pattern in order to take advantage of this, but the combine pass 5258 operand of the comparison (the second will be @code{(const_int 0)}).
5097 does not handle patterns with multiple sets, which is required by
5098 definition for @code{sync_compare_and_swap@var{mode}}.
5099 5259
5100 @cindex @code{sync_add@var{mode}} instruction pattern 5260 @cindex @code{sync_add@var{mode}} instruction pattern
5101 @cindex @code{sync_sub@var{mode}} instruction pattern 5261 @cindex @code{sync_sub@var{mode}} instruction pattern
5102 @cindex @code{sync_ior@var{mode}} instruction pattern 5262 @cindex @code{sync_ior@var{mode}} instruction pattern
5103 @cindex @code{sync_and@var{mode}} instruction pattern 5263 @cindex @code{sync_and@var{mode}} instruction pattern
5269 @node Dependent Patterns 5429 @node Dependent Patterns
5270 @section Interdependence of Patterns 5430 @section Interdependence of Patterns
5271 @cindex Dependent Patterns 5431 @cindex Dependent Patterns
5272 @cindex Interdependence of Patterns 5432 @cindex Interdependence of Patterns
5273 5433
5274 Every machine description must have a named pattern for each of the
5275 conditional branch names @samp{b@var{cond}}. The recognition template
5276 must always have the form
5277
5278 @smallexample
5279 (set (pc)
5280 (if_then_else (@var{cond} (cc0) (const_int 0))
5281 (label_ref (match_operand 0 "" ""))
5282 (pc)))
5283 @end smallexample
5284
5285 @noindent
5286 In addition, every machine description must have an anonymous pattern
5287 for each of the possible reverse-conditional branches. Their templates
5288 look like
5289
5290 @smallexample
5291 (set (pc)
5292 (if_then_else (@var{cond} (cc0) (const_int 0))
5293 (pc)
5294 (label_ref (match_operand 0 "" ""))))
5295 @end smallexample
5296
5297 @noindent
5298 They are necessary because jump optimization can turn direct-conditional
5299 branches into reverse-conditional branches.
5300
5301 It is often convenient to use the @code{match_operator} construct to
5302 reduce the number of patterns that must be specified for branches. For
5303 example,
5304
5305 @smallexample
5306 (define_insn ""
5307 [(set (pc)
5308 (if_then_else (match_operator 0 "comparison_operator"
5309 [(cc0) (const_int 0)])
5310 (pc)
5311 (label_ref (match_operand 1 "" ""))))]
5312 "@var{condition}"
5313 "@dots{}")
5314 @end smallexample
5315
5316 In some cases machines support instructions identical except for the 5434 In some cases machines support instructions identical except for the
5317 machine mode of one or more operands. For example, there may be 5435 machine mode of one or more operands. For example, there may be
5318 ``sign-extend halfword'' and ``sign-extend byte'' instructions whose 5436 ``sign-extend halfword'' and ``sign-extend byte'' instructions whose
5319 patterns are 5437 patterns are
5320 5438
5351 @node Jump Patterns 5469 @node Jump Patterns
5352 @section Defining Jump Instruction Patterns 5470 @section Defining Jump Instruction Patterns
5353 @cindex jump instruction patterns 5471 @cindex jump instruction patterns
5354 @cindex defining jump instruction patterns 5472 @cindex defining jump instruction patterns
5355 5473
5356 For most machines, GCC assumes that the machine has a condition code. 5474 GCC does not assume anything about how the machine realizes jumps.
5357 A comparison insn sets the condition code, recording the results of both 5475 The machine description should define a single pattern, usually
5358 signed and unsigned comparison of the given operands. A separate branch 5476 a @code{define_expand}, which expands to all the required insns.
5359 insn tests the condition code and branches or not according its value. 5477
5360 The branch insns come in distinct signed and unsigned flavors. Many 5478 Usually, this would be a comparison insn to set the condition code
5361 common machines, such as the VAX, the 68000 and the 32000, work this 5479 and a separate branch insn testing the condition code and branching
5362 way. 5480 or not according to its value. For many machines, however,
5363 5481 separating compares and branches is limiting, which is why the
5364 Some machines have distinct signed and unsigned compare instructions, and 5482 more flexible approach with one @code{define_expand} is used in GCC.
5365 only one set of conditional branch instructions. The easiest way to handle 5483 The machine description becomes clearer for architectures that
5366 these machines is to treat them just like the others until the final stage 5484 have compare-and-branch instructions but no condition code. It also
5367 where assembly code is written. At this time, when outputting code for the 5485 works better when different sets of comparison operators are supported
5368 compare instruction, peek ahead at the following branch using 5486 by different kinds of conditional branches (e.g. integer vs. floating-point),
5369 @code{next_cc0_user (insn)}. (The variable @code{insn} refers to the insn 5487 or by conditional branches with respect to conditional stores.
5370 being output, in the output-writing code in an instruction pattern.) If 5488
5371 the RTL says that is an unsigned branch, output an unsigned compare; 5489 Two separate insns are always used if the machine description represents
5372 otherwise output a signed compare. When the branch itself is output, you 5490 a condition code register using the legacy RTL expression @code{(cc0)},
5373 can treat signed and unsigned branches identically. 5491 and on most machines that use a separate condition code register
5374 5492 (@pxref{Condition Code}). For machines that use @code{(cc0)}, in
5375 The reason you can do this is that GCC always generates a pair of 5493 fact, the set and use of the condition code must be separate and
5376 consecutive RTL insns, possibly separated by @code{note} insns, one to 5494 adjacent@footnote{@code{note} insns can separate them, though.}, thus
5377 set the condition code and one to test it, and keeps the pair inviolate 5495 allowing flags in @code{cc_status} to be used (@pxref{Condition Code}) and
5378 until the end. 5496 so that the comparison and branch insns could be located from each other
5379 5497 by using the functions @code{prev_cc0_setter} and @code{next_cc0_user}.
5380 To go with this technique, you must define the machine-description macro 5498
5381 @code{NOTICE_UPDATE_CC} to do @code{CC_STATUS_INIT}; in other words, no 5499 Even in this case having a single entry point for conditional branches
5382 compare instruction is superfluous. 5500 is advantageous, because it handles equally well the case where a single
5383 5501 comparison instruction records the results of both signed and unsigned
5384 Some machines have compare-and-branch instructions and no condition code. 5502 comparison of the given operands (with the branch insns coming in distinct
5385 A similar technique works for them. When it is time to ``output'' a 5503 signed and unsigned flavors) as in the x86 or SPARC, and the case where
5386 compare instruction, record its operands in two static variables. When 5504 there are distinct signed and unsigned compare instructions and only
5387 outputting the branch-on-condition-code instruction that follows, actually 5505 one set of conditional branch instructions as in the PowerPC.
5388 output a compare-and-branch instruction that uses the remembered operands.
5389
5390 It also works to define patterns for compare-and-branch instructions.
5391 In optimizing compilation, the pair of compare and branch instructions
5392 will be combined according to these patterns. But this does not happen
5393 if optimization is not requested. So you must use one of the solutions
5394 above in addition to any special patterns you define.
5395
5396 In many RISC machines, most instructions do not affect the condition
5397 code and there may not even be a separate condition code register. On
5398 these machines, the restriction that the definition and use of the
5399 condition code be adjacent insns is not necessary and can prevent
5400 important optimizations. For example, on the IBM RS/6000, there is a
5401 delay for taken branches unless the condition code register is set three
5402 instructions earlier than the conditional branch. The instruction
5403 scheduler cannot perform this optimization if it is not permitted to
5404 separate the definition and use of the condition code register.
5405
5406 On these machines, do not use @code{(cc0)}, but instead use a register
5407 to represent the condition code. If there is a specific condition code
5408 register in the machine, use a hard register. If the condition code or
5409 comparison result can be placed in any general register, or if there are
5410 multiple condition registers, use a pseudo register.
5411
5412 @findex prev_cc0_setter
5413 @findex next_cc0_user
5414 On some machines, the type of branch instruction generated may depend on
5415 the way the condition code was produced; for example, on the 68k and
5416 SPARC, setting the condition code directly from an add or subtract
5417 instruction does not clear the overflow bit the way that a test
5418 instruction does, so a different branch instruction must be used for
5419 some conditional branches. For machines that use @code{(cc0)}, the set
5420 and use of the condition code must be adjacent (separated only by
5421 @code{note} insns) allowing flags in @code{cc_status} to be used.
5422 (@xref{Condition Code}.) Also, the comparison and branch insns can be
5423 located from each other by using the functions @code{prev_cc0_setter}
5424 and @code{next_cc0_user}.
5425
5426 However, this is not true on machines that do not use @code{(cc0)}. On
5427 those machines, no assumptions can be made about the adjacency of the
5428 compare and branch insns and the above methods cannot be used. Instead,
5429 we use the machine mode of the condition code register to record
5430 different formats of the condition code register.
5431
5432 Registers used to store the condition code value should have a mode that
5433 is in class @code{MODE_CC}. Normally, it will be @code{CCmode}. If
5434 additional modes are required (as for the add example mentioned above in
5435 the SPARC), define them in @file{@var{machine}-modes.def}
5436 (@pxref{Condition Code}). Also define @code{SELECT_CC_MODE} to choose
5437 a mode given an operand of a compare.
5438
5439 If it is known during RTL generation that a different mode will be
5440 required (for example, if the machine has separate compare instructions
5441 for signed and unsigned quantities, like most IBM processors), they can
5442 be specified at that time.
5443
5444 If the cases that require different modes would be made by instruction
5445 combination, the macro @code{SELECT_CC_MODE} determines which machine
5446 mode should be used for the comparison result. The patterns should be
5447 written using that mode. To support the case of the add on the SPARC
5448 discussed above, we have the pattern
5449
5450 @smallexample
5451 (define_insn ""
5452 [(set (reg:CC_NOOV 0)
5453 (compare:CC_NOOV
5454 (plus:SI (match_operand:SI 0 "register_operand" "%r")
5455 (match_operand:SI 1 "arith_operand" "rI"))
5456 (const_int 0)))]
5457 ""
5458 "@dots{}")
5459 @end smallexample
5460
5461 The @code{SELECT_CC_MODE} macro on the SPARC returns @code{CC_NOOVmode}
5462 for comparisons whose argument is a @code{plus}.
5463 5506
5464 @end ifset 5507 @end ifset
5465 @ifset INTERNALS 5508 @ifset INTERNALS
5466 @node Looping Patterns 5509 @node Looping Patterns
5467 @section Defining Looping Instruction Patterns 5510 @section Defining Looping Instruction Patterns
5613 @item 5656 @item
5614 In combinations of @code{neg}, @code{mult}, @code{plus}, and 5657 In combinations of @code{neg}, @code{mult}, @code{plus}, and
5615 @code{minus}, the @code{neg} operations (if any) will be moved inside 5658 @code{minus}, the @code{neg} operations (if any) will be moved inside
5616 the operations as far as possible. For instance, 5659 the operations as far as possible. For instance,
5617 @code{(neg (mult A B))} is canonicalized as @code{(mult (neg A) B)}, but 5660 @code{(neg (mult A B))} is canonicalized as @code{(mult (neg A) B)}, but
5618 @code{(plus (mult (neg A) B) C)} is canonicalized as 5661 @code{(plus (mult (neg B) C) A)} is canonicalized as
5619 @code{(minus A (mult B C))}. 5662 @code{(minus A (mult B C))}.
5620 5663
5621 @cindex @code{compare}, canonicalization of 5664 @cindex @code{compare}, canonicalization of
5622 @item 5665 @item
5623 For the @code{compare} operator, a constant is always the second operand 5666 For the @code{compare} operator, a constant is always the second operand
5624 on machines where @code{cc0} is used (@pxref{Jump Patterns}). On other 5667 if the first argument is a condition code register or @code{(cc0)}.
5625 machines, there are rare cases where the compiler might want to construct 5668
5626 a @code{compare} with a constant as the first operand. However, these 5669 @item
5627 cases are not common enough for it to be worthwhile to provide a pattern
5628 matching a constant as the first operand unless the machine actually has
5629 such an instruction.
5630
5631 An operand of @code{neg}, @code{not}, @code{mult}, @code{plus}, or 5670 An operand of @code{neg}, @code{not}, @code{mult}, @code{plus}, or
5632 @code{minus} is made the first operand under the same conditions as 5671 @code{minus} is made the first operand under the same conditions as
5633 above. 5672 above.
5634 5673
5635 @item 5674 @item
5692 the form 5731 the form
5693 5732
5694 @smallexample 5733 @smallexample
5695 (plus:@var{m} (plus:@var{m} @var{x} @var{y}) @var{constant}) 5734 (plus:@var{m} (plus:@var{m} @var{x} @var{y}) @var{constant})
5696 @end smallexample 5735 @end smallexample
5697
5698 @item
5699 On machines that do not use @code{cc0},
5700 @code{(compare @var{x} (const_int 0))} will be converted to
5701 @var{x}.
5702 5736
5703 @cindex @code{zero_extract}, canonicalization of 5737 @cindex @code{zero_extract}, canonicalization of
5704 @cindex @code{sign_extract}, canonicalization of 5738 @cindex @code{sign_extract}, canonicalization of
5705 @item 5739 @item
5706 Equality comparisons of a group of bits (usually a single bit) with zero 5740 Equality comparisons of a group of bits (usually a single bit) with zero
6108 jump. When new sequence contains multiple jump instructions or new labels, 6142 jump. When new sequence contains multiple jump instructions or new labels,
6109 more assistance is needed. Splitter is required to create only unconditional 6143 more assistance is needed. Splitter is required to create only unconditional
6110 jumps, or simple conditional jump instructions. Additionally it must attach a 6144 jumps, or simple conditional jump instructions. Additionally it must attach a
6111 @code{REG_BR_PROB} note to each conditional jump. A global variable 6145 @code{REG_BR_PROB} note to each conditional jump. A global variable
6112 @code{split_branch_probability} holds the probability of the original branch in case 6146 @code{split_branch_probability} holds the probability of the original branch in case
6113 it was an simple conditional jump, @minus{}1 otherwise. To simplify 6147 it was a simple conditional jump, @minus{}1 otherwise. To simplify
6114 recomputing of edge frequencies, the new sequence is required to have only 6148 recomputing of edge frequencies, the new sequence is required to have only
6115 forward jumps to the newly created labels. 6149 forward jumps to the newly created labels.
6116 6150
6117 @findex define_insn_and_split 6151 @findex define_insn_and_split
6118 For the common case where the pattern of a define_split exactly matches the 6152 For the common case where the pattern of a define_split exactly matches the
7502 two insns as parameters. If the function returns zero the bypass will 7536 two insns as parameters. If the function returns zero the bypass will
7503 be ignored for this case. The additional guard is necessary to 7537 be ignored for this case. The additional guard is necessary to
7504 recognize complicated bypasses, e.g.@: when the consumer is only an address 7538 recognize complicated bypasses, e.g.@: when the consumer is only an address
7505 of insn @samp{store} (not a stored value). 7539 of insn @samp{store} (not a stored value).
7506 7540
7541 If there are more one bypass with the same output and input insns, the
7542 chosen bypass is the first bypass with a guard in description whose
7543 guard function returns nonzero. If there is no such bypass, then
7544 bypass without the guard function is chosen.
7545
7507 @findex exclusion_set 7546 @findex exclusion_set
7508 @findex presence_set 7547 @findex presence_set
7509 @findex final_presence_set 7548 @findex final_presence_set
7510 @findex absence_set 7549 @findex absence_set
7511 @findex final_absence_set 7550 @findex final_absence_set