GCC Middle and Back End API Reference
machmode.h File Reference
#include "insn-modes.h"
#include "mode-classes.def"
Include dependency graph for machmode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  bit_field_mode_iterator

Macros

#define GET_MODE_NAME(MODE)   mode_name[MODE]
#define DEF_MODE_CLASS(M)   M
#define GET_MODE_CLASS(MODE)   ((enum mode_class) mode_class[MODE])
#define INTEGRAL_MODE_P(MODE)
#define FLOAT_MODE_P(MODE)
#define COMPLEX_MODE_P(MODE)
#define VECTOR_MODE_P(MODE)
#define SCALAR_INT_MODE_P(MODE)
#define SCALAR_FLOAT_MODE_P(MODE)
#define DECIMAL_FLOAT_MODE_P(MODE)   (GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
#define SCALAR_FRACT_MODE_P(MODE)   (GET_MODE_CLASS (MODE) == MODE_FRACT)
#define SCALAR_UFRACT_MODE_P(MODE)   (GET_MODE_CLASS (MODE) == MODE_UFRACT)
#define ALL_SCALAR_FRACT_MODE_P(MODE)   (SCALAR_FRACT_MODE_P (MODE) || SCALAR_UFRACT_MODE_P (MODE))
#define SCALAR_ACCUM_MODE_P(MODE)   (GET_MODE_CLASS (MODE) == MODE_ACCUM)
#define SCALAR_UACCUM_MODE_P(MODE)   (GET_MODE_CLASS (MODE) == MODE_UACCUM)
#define ALL_SCALAR_ACCUM_MODE_P(MODE)   (SCALAR_ACCUM_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
#define SIGNED_SCALAR_FIXED_POINT_MODE_P(MODE)   (SCALAR_FRACT_MODE_P (MODE) || SCALAR_ACCUM_MODE_P (MODE))
#define UNSIGNED_SCALAR_FIXED_POINT_MODE_P(MODE)   (SCALAR_UFRACT_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
#define ALL_SCALAR_FIXED_POINT_MODE_P(MODE)
#define FRACT_MODE_P(MODE)
#define UFRACT_MODE_P(MODE)
#define ALL_FRACT_MODE_P(MODE)   (FRACT_MODE_P (MODE) || UFRACT_MODE_P (MODE))
#define ACCUM_MODE_P(MODE)
#define UACCUM_MODE_P(MODE)
#define ALL_ACCUM_MODE_P(MODE)   (ACCUM_MODE_P (MODE) || UACCUM_MODE_P (MODE))
#define SIGNED_FIXED_POINT_MODE_P(MODE)   (FRACT_MODE_P (MODE) || ACCUM_MODE_P (MODE))
#define UNSIGNED_FIXED_POINT_MODE_P(MODE)   (UFRACT_MODE_P (MODE) || UACCUM_MODE_P (MODE))
#define ALL_FIXED_POINT_MODE_P(MODE)
#define CLASS_HAS_WIDER_MODES_P(CLASS)
#define POINTER_BOUNDS_MODE_P(MODE)   (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS)
#define GET_MODE_SIZE(MODE)   ((unsigned short) mode_size[MODE])
#define GET_MODE_BITSIZE(MODE)   ((unsigned short) (GET_MODE_SIZE (MODE) * BITS_PER_UNIT))
#define GET_MODE_PRECISION(MODE)   mode_precision[MODE]
#define GET_MODE_IBIT(MODE)   mode_ibit[MODE]
#define GET_MODE_FBIT(MODE)   mode_fbit[MODE]
#define GET_MODE_MASK(MODE)   mode_mask_array[MODE]
#define GET_MODE_INNER(MODE)   ((enum machine_mode) mode_inner[MODE])
#define GET_MODE_UNIT_SIZE(MODE)
#define GET_MODE_UNIT_BITSIZE(MODE)   ((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))
#define GET_MODE_UNIT_PRECISION(MODE)
#define GET_MODE_NUNITS(MODE)   mode_nunits[MODE]
#define GET_MODE_WIDER_MODE(MODE)   ((enum machine_mode) mode_wider[MODE])
#define GET_MODE_2XWIDER_MODE(MODE)   ((enum machine_mode) mode_2xwider[MODE])
#define GET_MODE_ALIGNMENT(MODE)   get_mode_alignment (MODE)
#define GET_CLASS_NARROWEST_MODE(CLASS)   ((enum machine_mode) class_narrowest_mode[CLASS])
#define TRULY_NOOP_TRUNCATION_MODES_P(MODE1, MODE2)
#define HWI_COMPUTABLE_MODE_P(MODE)

Enumerations

enum  mode_class { MODE_CLASSES, MAX_MODE_CLASS, MODE_CLASSES, MAX_MODE_CLASS }

Functions

enum machine_mode mode_for_size (unsigned int, enum mode_class, int)
enum machine_mode smallest_mode_for_size (unsigned int, enum mode_class)
enum machine_mode int_mode_for_mode (enum machine_mode)
enum machine_mode mode_for_vector (enum machine_mode, unsigned)
enum machine_mode get_best_mode (int, int, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, unsigned int, enum machine_mode, bool)
unsigned get_mode_alignment (enum machine_mode)
unsigned int element_precision (enum machine_mode)
void init_adjust_machine_modes (void)

Variables

const char *const mode_name [NUM_MACHINE_MODES]
const unsigned char mode_class [NUM_MACHINE_MODES]
CONST_MODE_SIZE unsigned char mode_size [NUM_MACHINE_MODES]
const unsigned short mode_precision [NUM_MACHINE_MODES]
CONST_MODE_IBIT unsigned char mode_ibit [NUM_MACHINE_MODES]
CONST_MODE_FBIT unsigned char mode_fbit [NUM_MACHINE_MODES]
const unsigned HOST_WIDE_INT mode_mask_array [NUM_MACHINE_MODES]
const unsigned char mode_inner [NUM_MACHINE_MODES]
const unsigned char mode_nunits [NUM_MACHINE_MODES]
const unsigned char mode_wider [NUM_MACHINE_MODES]
const unsigned char mode_2xwider [NUM_MACHINE_MODES]
CONST_MODE_BASE_ALIGN unsigned char mode_base_align [NUM_MACHINE_MODES]
const unsigned char class_narrowest_mode [MAX_MODE_CLASS]
enum machine_mode byte_mode
enum machine_mode word_mode
enum machine_mode ptr_mode

Macro Definition Documentation

#define ACCUM_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_ACCUM \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM)

Nonzero if MODE is a scalar/vector accum mode.

#define ALL_ACCUM_MODE_P (   MODE)    (ACCUM_MODE_P (MODE) || UACCUM_MODE_P (MODE))

Nonzero if MODE is a scalar/vector accum or uaccum mode.

#define ALL_FIXED_POINT_MODE_P (   MODE)
Value:

Nonzero if MODE is a scalar/vector fract, ufract, accum or uaccum mode.

Referenced by gen_int_signed_fixed_libfunc(), and gen_int_unsigned_fixed_libfunc().

#define ALL_FRACT_MODE_P (   MODE)    (FRACT_MODE_P (MODE) || UFRACT_MODE_P (MODE))

Nonzero if MODE is a scalar/vector fract or ufract mode.

#define ALL_SCALAR_ACCUM_MODE_P (   MODE)    (SCALAR_ACCUM_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))

Nonzero if MODE is a scalar accum or uaccum mode.

Referenced by build_string().

#define ALL_SCALAR_FIXED_POINT_MODE_P (   MODE)
Value:

Nonzero if MODE is a scalar fract, ufract, accum or uaccum mode.

#define ALL_SCALAR_FRACT_MODE_P (   MODE)    (SCALAR_FRACT_MODE_P (MODE) || SCALAR_UFRACT_MODE_P (MODE))

Nonzero if MODE is a scalar fract or ufract mode.

#define CLASS_HAS_WIDER_MODES_P (   CLASS)
Value:
(CLASS == MODE_INT \
|| CLASS == MODE_PARTIAL_INT \
|| CLASS == MODE_FLOAT \
|| CLASS == MODE_DECIMAL_FLOAT \
|| CLASS == MODE_COMPLEX_FLOAT \
|| CLASS == MODE_FRACT \
|| CLASS == MODE_UFRACT \
|| CLASS == MODE_ACCUM \
|| CLASS == MODE_UACCUM)

Nonzero if CLASS modes can be widened.

Referenced by expand_doubleword_clz().

#define COMPLEX_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
|| GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)

Nonzero if MODE is a complex mode.

Referenced by clear_by_pieces(), and validate_subreg().

#define DECIMAL_FLOAT_MODE_P (   MODE)    (GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)

Nonzero if MODE is a decimal floating point mode.

Referenced by expand_sfix_optab(), fixed_zerop(), gen_int_fp_signed_fixed_libfunc(), and gen_libfunc().

#define DEF_MODE_CLASS (   M)    M

Mode classes.

#define FLOAT_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_FLOAT \
|| GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT \
|| GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)

Nonzero if MODE is a floating-point mode.

Referenced by calculate_bb_reg_pressure(), expand_debug_parm_decl(), print_value(), and unroll_loop_stupid().

#define FRACT_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_FRACT \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT)

Nonzero if MODE is a scalar/vector fract mode.

#define GET_CLASS_NARROWEST_MODE (   CLASS)    ((enum machine_mode) class_narrowest_mode[CLASS])
#define GET_MODE_2XWIDER_MODE (   MODE)    ((enum machine_mode) mode_2xwider[MODE])
#define GET_MODE_FBIT (   MODE)    mode_fbit[MODE]
#define GET_MODE_IBIT (   MODE)    mode_ibit[MODE]

Referenced by fixed_convert_from_int().

#define GET_MODE_INNER (   MODE)    ((enum machine_mode) mode_inner[MODE])
#define GET_MODE_NAME (   MODE)    mode_name[MODE]
#define GET_MODE_NUNITS (   MODE)    mode_nunits[MODE]
#define GET_MODE_SIZE (   MODE)    ((unsigned short) mode_size[MODE])
#define GET_MODE_UNIT_BITSIZE (   MODE)    ((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))
#define GET_MODE_UNIT_PRECISION (   MODE)
Value:
(GET_MODE_INNER (MODE) == VOIDmode \
? GET_MODE_PRECISION (MODE) \

Referenced by simplify_replace_rtx().

#define GET_MODE_UNIT_SIZE (   MODE)
Value:
(GET_MODE_INNER (MODE) == VOIDmode \
? GET_MODE_SIZE (MODE) \

Get the size in bytes or bites of the basic parts of an object of mode MODE.

Referenced by init_optabs(), and set_reg_attrs_from_value().

#define HWI_COMPUTABLE_MODE_P (   MODE)
#define INTEGRAL_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_INT \
|| GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \
|| GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_INT)

Nonzero if MODE is an integral mode.

Referenced by simplify_byte_swapping_operation(), and simplify_relational_operation_1().

#define POINTER_BOUNDS_MODE_P (   MODE)    (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS)
#define SCALAR_ACCUM_MODE_P (   MODE)    (GET_MODE_CLASS (MODE) == MODE_ACCUM)

Nonzero if MODE is a scalar accum mode.

Referenced by int_mode_for_mode().

#define SCALAR_FLOAT_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_FLOAT \
|| GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)

Nonzero if MODE is a scalar floating point mode.

Referenced by expand_widening_mult(), int_mode_for_mode(), simplify_relational_operation_1(), subst_reloads(), and validate_simplify_insn().

#define SCALAR_FRACT_MODE_P (   MODE)    (GET_MODE_CLASS (MODE) == MODE_FRACT)

Nonzero if MODE is a scalar fract mode.

Referenced by int_mode_for_mode().

#define SCALAR_INT_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_INT \
|| GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT)

Nonzero if MODE is a scalar integral mode.

Referenced by compress_float_constant(), make_compound_operation(), make_extraction(), ok_for_index_p_nonstrict(), and simplify_set().

#define SCALAR_UACCUM_MODE_P (   MODE)    (GET_MODE_CLASS (MODE) == MODE_UACCUM)

Nonzero if MODE is a scalar uaccum mode.

Referenced by int_mode_for_mode().

#define SCALAR_UFRACT_MODE_P (   MODE)    (GET_MODE_CLASS (MODE) == MODE_UFRACT)

Nonzero if MODE is a scalar ufract mode.

Referenced by int_mode_for_mode().

#define SIGNED_FIXED_POINT_MODE_P (   MODE)    (FRACT_MODE_P (MODE) || ACCUM_MODE_P (MODE))

Nonzero if MODE is a scalar/vector fract or accum mode.

Referenced by fixed_compare(), and fold_convert_const_int_from_int().

#define SIGNED_SCALAR_FIXED_POINT_MODE_P (   MODE)    (SCALAR_FRACT_MODE_P (MODE) || SCALAR_ACCUM_MODE_P (MODE))

Nonzero if MODE is a scalar fract or accum mode.

#define TRULY_NOOP_TRUNCATION_MODES_P (   MODE1,
  MODE2 
)
Value:
TRULY_NOOP_TRUNCATION (GET_MODE_PRECISION (MODE1), \

Referenced by expand_binop().

#define UACCUM_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_UACCUM \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)

Nonzero if MODE is a scalar/vector uaccum mode.

#define UFRACT_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_UFRACT \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT)

Nonzero if MODE is a scalar/vector ufract mode.

#define UNSIGNED_FIXED_POINT_MODE_P (   MODE)    (UFRACT_MODE_P (MODE) || UACCUM_MODE_P (MODE))

Nonzero if MODE is a scalar/vector ufract or uaccum mode.

#define UNSIGNED_SCALAR_FIXED_POINT_MODE_P (   MODE)    (SCALAR_UFRACT_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))

Nonzero if MODE is a scalar ufract or uaccum mode.

#define VECTOR_MODE_P (   MODE)
Value:
(GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM \
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)

Nonzero if MODE is a vector mode.

Referenced by decompose_register(), find_comparison_args(), init_optabs(), validate_subreg(), and vect_build_slp_tree_1().


Enumeration Type Documentation

enum mode_class
Enumerator:
MODE_CLASSES 
MAX_MODE_CLASS 
MODE_CLASSES 
MAX_MODE_CLASS 

Function Documentation

unsigned int element_precision ( enum  machine_mode)

Get the precision of the mode or its inner mode if it has one.

enum machine_mode get_best_mode ( int  bitsize,
int  bitpos,
unsigned HOST_WIDE_INT  bitregion_start,
unsigned HOST_WIDE_INT  bitregion_end,
unsigned int  align,
enum machine_mode  largest_mode,
bool  volatilep 
)

Find the best mode to use to access a bit field.

Find the best machine mode to use when referencing a bit field of length BITSIZE bits starting at BITPOS.

BITREGION_START is the bit position of the first bit in this sequence of bit fields. BITREGION_END is the last bit in this sequence. If these two fields are non-zero, we should restrict the memory access to that range. Otherwise, we are allowed to touch any adjacent non bit-fields.

The underlying object is known to be aligned to a boundary of ALIGN bits. If LARGEST_MODE is not VOIDmode, it means that we should not use a mode larger than LARGEST_MODE (usually SImode).

If no mode meets all these conditions, we return VOIDmode.

If VOLATILEP is false and SLOW_BYTE_ACCESS is false, we return the smallest mode meeting these conditions.

If VOLATILEP is false and SLOW_BYTE_ACCESS is true, we return the largest mode (but a mode no wider than UNITS_PER_WORD) that meets all the conditions.

If VOLATILEP is true the narrow_volatile_bitfields target hook is used to decide which of the above modes should be used.

??? For historical reasons, reject modes that would normally receive greater alignment, even if unaligned accesses are acceptable. This has both advantages and disadvantages. Removing this check means that something like:

struct s { unsigned int x; unsigned int y; }; int f (struct s *s) { return s->x == 0 && s->y == 0; }

can be implemented using a single load and compare on 64-bit machines that have no alignment restrictions. For example, on powerpc64-linux-gnu, we would generate:

    ld 3,0(3)
    cntlzd 3,3
    srdi 3,3,6
    blr

rather than:

    lwz 9,0(3)
    cmpwi 7,9,0
    bne 7,.L3
    lwz 3,4(3)
    cntlzw 3,3
    srwi 3,3,5
    extsw 3,3
    blr
    .p2align 4,,15

.L3: li 3,0 blr

However, accessing more than one field can make life harder for the gimple optimizers. For example, gcc.dg/vect/bb-slp-5.c has a series of unsigned short copies followed by a series of unsigned short comparisons. With this check, both the copies and comparisons remain 16-bit accesses and FRE is able to eliminate the latter. Without the check, the comparisons can be done using 2 64-bit operations, which FRE isn't able to handle in the same way.

Either way, it would probably be worth disabling this check during expand. One particular example where removing the check would help is the get_best_mode call in store_bit_field. If we are given a memory bitregion of 128 bits that is aligned to a 64-bit boundary, and the bitfield we want to modify is in the second half of the bitregion, this check causes store_bitfield to turn the memory into a 64-bit reference to the first half of the region. We later use adjust_bitfield_address to get a reference to the correct half, but doing so looks to adjust_bitfield_address as though we are moving past the end of the original object, so it drops the associated MEM_EXPR and MEM_OFFSET. Removing the check causes store_bit_field to keep a 128-bit memory reference, so that the final bitfield reference still has a MEM_EXPR and MEM_OFFSET.

Referenced by store_bit_field().

unsigned get_mode_alignment ( enum  machine_mode)

Referenced by emit_move_change_mode().

void init_adjust_machine_modes ( void  )

Target-dependent machine mode initialization - in insn-modes.c.

enum machine_mode int_mode_for_mode ( enum  machine_mode)

Return an integer mode of the exact same size as the input mode, or BLKmode on failure.

Referenced by expand_abs(), find_shift_sequence(), and make_compound_operation().

enum machine_mode mode_for_size ( unsigned  int,
enum  mode_class,
int   
)

Return the mode for data of a given size SIZE and mode class CLASS. If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE. The value is BLKmode if no other mode is found.

Referenced by assign_mem_slot(), decompose_register(), distribute_and_simplify_rtx(), expand_builtin___clear_cache(), expand_builtin_compare_and_swap(), finish_bitfield_layout(), int_mode_for_mode(), and spill_failure().

enum machine_mode mode_for_vector ( enum  machine_mode,
unsigned   
)

Return a mode that is suitable for representing a vector, or BLKmode on failure.

Referenced by finish_bitfield_layout(), and init_optabs().

enum machine_mode smallest_mode_for_size ( unsigned  int,
enum  mode_class 
)

Similar, but find the smallest mode for a given width.

Referenced by finish_bitfield_layout().


Variable Documentation

enum machine_mode byte_mode

Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD and the mode whose class is Pmode and whose size is POINTER_SIZE.

Commonly used modes.

Referenced by clear_storage_hints().

const unsigned char class_narrowest_mode[MAX_MODE_CLASS]

For each class, get the narrowest mode in that class.

const unsigned char mode_2xwider[NUM_MACHINE_MODES]

For scalars, this is a mode with twice the precision. For vectors, this is a mode with the same inner mode but with twice the elements.

CONST_MODE_BASE_ALIGN unsigned char mode_base_align[NUM_MACHINE_MODES]

Determine alignment, 1<=result<=BIGGEST_ALIGNMENT.

Referenced by mode_for_vector().

const unsigned char mode_class[NUM_MACHINE_MODES]

Get the general kind of object that mode MODE represents (integer, floating, complex, etc.)

CONST_MODE_FBIT unsigned char mode_fbit[NUM_MACHINE_MODES]

Get the number of fractional bits of an object of mode MODE.

CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES]

Get the number of integral bits of an object of mode MODE.

const unsigned char mode_inner[NUM_MACHINE_MODES]

Return the mode of the inner elements in a vector.

const unsigned HOST_WIDE_INT mode_mask_array[NUM_MACHINE_MODES]

Get a bitmask containing 1 for all bits in a word that fit within mode MODE.

const char* const mode_name[NUM_MACHINE_MODES]

Machine mode definitions for GCC; included by rtl.h and tree.h. Copyright (C) 1991-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. Make an enum class that gives all the machine modes. Get the name of mode MODE as a string.

const unsigned char mode_nunits[NUM_MACHINE_MODES]

Get the number of units in the object.

const unsigned short mode_precision[NUM_MACHINE_MODES]

Get the number of value bits of an object of mode MODE.

CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES]

Get the size in bytes and bits of an object of mode MODE.

const unsigned char mode_wider[NUM_MACHINE_MODES]

Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI).