Movatterモバイル変換


[0]ホーム

URL:


Next:, Previous:, Up:RTL Representation   [Contents][Index]


13.6 Machine Modes

A machine mode describes a size of data object and the representation usedfor it. In the C code, machine modes are represented by an enumerationtype,machine_mode, defined inmachmode.def. Each RTLexpression has room for a machine mode and so do certain kinds of treeexpressions (declarations and types, to be precise).

In debugging dumps and machine descriptions, the machine mode of an RTLexpression is written after the expression code with a colon to separatethem. The letters ‘mode’ which appear at the end of each machine modename are omitted. For example,(reg:SI 38) is aregexpression with machine modeSImode. If the mode isVOIDmode, it is not written at all.

Here is a table of machine modes. The term “byte” below refers to anobject ofBITS_PER_UNIT bits (seeStorage Layout).

BImode

“Bit” mode represents a single bit, for predicate registers.

QImode

“Quarter-Integer” mode represents a single byte treated as an integer.

HImode

“Half-Integer” mode represents a two-byte integer.

PSImode

“Partial Single Integer” mode represents an integer which occupiesfour bytes but which doesn’t really use all four. On some machines,this is the right mode to use for pointers.

SImode

“Single Integer” mode represents a four-byte integer.

PDImode

“Partial Double Integer” mode represents an integer which occupieseight bytes but which doesn’t really use all eight. On some machines,this is the right mode to use for certain pointers.

DImode

“Double Integer” mode represents an eight-byte integer.

TImode

“Tetra Integer” (?) mode represents a sixteen-byte integer.

OImode

“Octa Integer” (?) mode represents a thirty-two-byte integer.

XImode

“Hexadeca Integer” (?) mode represents a sixty-four-byte integer.

QFmode

“Quarter-Floating” mode represents a quarter-precision (single byte)floating point number.

HFmode

“Half-Floating” mode represents a half-precision (two byte) floatingpoint number.

TQFmode

“Three-Quarter-Floating” (?) mode represents a three-quarter-precision(three byte) floating point number.

SFmode

“Single Floating” mode represents a four byte floating point number.In the common case, of a processor with IEEE arithmetic and 8-bit bytes,this is a single-precision IEEE floating point number; it can also beused for double-precision (on processors with 16-bit bytes) andsingle-precision VAX and IBM types.

DFmode

“Double Floating” mode represents an eight byte floating point number.In the common case, of a processor with IEEE arithmetic and 8-bit bytes,this is a double-precision IEEE floating point number.

XFmode

“Extended Floating” mode represents an IEEE extended floating pointnumber. This mode only has 80 meaningful bits (ten bytes). Someprocessors require such numbers to be padded to twelve bytes, othersto sixteen; this mode is used for either.

SDmode

“Single Decimal Floating” mode represents a four byte decimalfloating point number (as distinct from conventional binary floatingpoint).

DDmode

“Double Decimal Floating” mode represents an eight byte decimalfloating point number.

TDmode

“Tetra Decimal Floating” mode represents a sixteen byte decimalfloating point number all 128 of whose bits are meaningful.

TFmode

“Tetra Floating” mode represents a sixteen byte floating point numberall 128 of whose bits are meaningful. One common use is theIEEE quad-precision format.

QQmode

“Quarter-Fractional” mode represents a single byte treated as a signedfractional number. The default format is “s.7”.

HQmode

“Half-Fractional” mode represents a two-byte signed fractional number.The default format is “s.15”.

SQmode

“Single Fractional” mode represents a four-byte signed fractional number.The default format is “s.31”.

DQmode

“Double Fractional” mode represents an eight-byte signed fractional number.The default format is “s.63”.

TQmode

“Tetra Fractional” mode represents a sixteen-byte signed fractional number.The default format is “s.127”.

UQQmode

“Unsigned Quarter-Fractional” mode represents a single byte treated as anunsigned fractional number. The default format is “.8”.

UHQmode

“Unsigned Half-Fractional” mode represents a two-byte unsigned fractionalnumber. The default format is “.16”.

USQmode

“Unsigned Single Fractional” mode represents a four-byte unsigned fractionalnumber. The default format is “.32”.

UDQmode

“Unsigned Double Fractional” mode represents an eight-byte unsignedfractional number. The default format is “.64”.

UTQmode

“Unsigned Tetra Fractional” mode represents a sixteen-byte unsignedfractional number. The default format is “.128”.

HAmode

“Half-Accumulator” mode represents a two-byte signed accumulator.The default format is “s8.7”.

SAmode

“Single Accumulator” mode represents a four-byte signed accumulator.The default format is “s16.15”.

DAmode

“Double Accumulator” mode represents an eight-byte signed accumulator.The default format is “s32.31”.

TAmode

“Tetra Accumulator” mode represents a sixteen-byte signed accumulator.The default format is “s64.63”.

UHAmode

“Unsigned Half-Accumulator” mode represents a two-byte unsigned accumulator.The default format is “8.8”.

USAmode

“Unsigned Single Accumulator” mode represents a four-byte unsignedaccumulator. The default format is “16.16”.

UDAmode

“Unsigned Double Accumulator” mode represents an eight-byte unsignedaccumulator. The default format is “32.32”.

UTAmode

“Unsigned Tetra Accumulator” mode represents a sixteen-byte unsignedaccumulator. The default format is “64.64”.

CCmode

“Condition Code” mode represents the value of a condition code, whichis a machine-specific set of bits used to represent the result of acomparison operation. Other machine-specific modes may also be used forthe condition code. (seeCondition Code Status).

BLKmode

“Block” mode represents values that are aggregates to which none ofthe other modes apply. In RTL, only memory references can have this mode,and only if they appear in string-move or vector instructions. On machineswhich have no such instructions,BLKmode will not appear in RTL.

VOIDmode

Void mode means the absence of a mode or an unspecified mode.For example, RTL expressions of codeconst_int have modeVOIDmode because they can be taken to have whatever mode the contextrequires. In debugging dumps of RTL,VOIDmode is expressed bythe absence of any mode.

QCmode, HCmode, SCmode, DCmode, XCmode, TCmode

These modes stand for a complex number represented as a pair of floatingpoint values. The floating point values are inQFmode,HFmode,SFmode,DFmode,XFmode, andTFmode, respectively.

CQImode, CHImode, CSImode, CDImode, CTImode, COImode, CPSImode

These modes stand for a complex number represented as a pair of integervalues. The integer values are inQImode,HImode,SImode,DImode,TImode,OImode, andPSImode,respectively.

BND32mode BND64mode

These modes stand for bounds for pointer of 32 and 64 bit size respectively.Mode size is double pointer mode size.

The machine description definesPmode as a C macro which expandsinto the machine mode used for addresses. Normally this is the modewhose size isBITS_PER_WORD,SImode on 32-bit machines.

The only modes which a machine descriptionmust support areQImode, and the modes corresponding toBITS_PER_WORD,C typefloat and C typedouble.The compiler will attempt to useDImode for 8-byte structures andunions, but this can be prevented by overriding the definition ofMAX_FIXED_MODE_SIZE. Alternatively, you can have the compileruseTImode for 16-byte structures and unions. Likewise, you canarrange for the C typeshort int to avoid usingHImode.

Very few explicit references to machine modes remain in the compiler andthese few references will soon be removed. Instead, the machine modesare divided into mode classes. These are represented by the enumerationtypeenum mode_class defined inmachmode.h. The possiblemode classes are:

MODE_INT

Integer modes. By default these areBImode,QImode,HImode,SImode,DImode,TImode, andOImode.

MODE_PARTIAL_INT

The “partial integer” modes,PQImode,PHImode,PSImode andPDImode.

MODE_FLOAT

Floating point modes. By default these areQFmode,HFmode,TQFmode,SFmode,DFmode,XFmode andTFmode.

MODE_DECIMAL_FLOAT

Decimal floating point modes. By default these areSDmode,DDmode andTDmode.

MODE_FRACT

Signed fractional modes. By default these areQQmode,HQmode,SQmode,DQmode andTQmode.

MODE_UFRACT

Unsigned fractional modes. By default these areUQQmode,UHQmode,USQmode,UDQmode andUTQmode.

MODE_ACCUM

Signed accumulator modes. By default these areHAmode,SAmode,DAmode andTAmode.

MODE_UACCUM

Unsigned accumulator modes. By default these areUHAmode,USAmode,UDAmode andUTAmode.

MODE_COMPLEX_INT

Complex integer modes. (These are not currently implemented).

MODE_COMPLEX_FLOAT

Complex floating point modes. By default these areQCmode,HCmode,SCmode,DCmode,XCmode, andTCmode.

MODE_CC

Modes representing condition code values. These areCCmode plusanyCC_MODE modes listed in themachine-modes.def.SeeDefining Jump Instruction Patterns,also seeCondition Code Status.

MODE_POINTER_BOUNDS

Pointer bounds modes. Used to represent values of pointer bounds type.Operations in these modes may be executed as NOPs depending on hardwarefeatures and environment setup.

MODE_OPAQUE

This is a mode class for modes that don’t want to provide operationsother than register moves, memory moves, loads, stores, andunspecs. They have a size and precision and that’s all.

MODE_RANDOM

This is a catchall mode class for modes which don’t fit into the aboveclasses. CurrentlyVOIDmode andBLKmode are inMODE_RANDOM.

machmode.h also defines various wrapper classes that combine amachine_mode with a static assertion that a particularcondition holds. The classes are:

scalar_int_mode

A mode that has classMODE_INT orMODE_PARTIAL_INT.

scalar_float_mode

A mode that has classMODE_FLOAT orMODE_DECIMAL_FLOAT.

scalar_mode

A mode that holds a single numerical value. In practice this meansthat the mode is ascalar_int_mode, is ascalar_float_mode,or has classMODE_FRACT,MODE_UFRACT,MODE_ACCUM,MODE_UACCUM orMODE_POINTER_BOUNDS.

complex_mode

A mode that has classMODE_COMPLEX_INT orMODE_COMPLEX_FLOAT.

fixed_size_mode

A mode whose size is known at compile time.

Named modes use the most constrained of the available wrapper classes,if one exists, otherwise they usemachine_mode. For example,QImode is ascalar_int_mode,SFmode is ascalar_float_mode andBLKmode is a plainmachine_mode. It is possible to refer to any mode as a rawmachine_mode by adding theE_ prefix, whereEstands for “enumeration”. For example, the rawmachine_modenames of the modes just mentioned areE_QImode,E_SFmodeandE_BLKmode respectively.

The wrapper classes implicitly convert tomachine_mode and to anywrapper class that represents a more general condition; for examplescalar_int_mode andscalar_float_mode both converttoscalar_mode and all three convert tofixed_size_mode.The classes act likemachine_modes that accept only certainnamed modes.

machmode.h also defines a template classopt_mode<T>that holds aT or nothing, whereT can be eithermachine_mode or one of the wrapper classes above. The mainoperations on anopt_mode<T>x are as follows:

x.exists ()

Return true ifx holds a mode rather than nothing.

x.exists (&y)

Return true ifx holds a mode rather than nothing, storing themode iny if so.y must be assignment-compatible withT.

x.require ()

Assert thatx holds a mode rather than nothing and return that mode.

x =y

Setx toy, wherey is aT or implicitly convertsto aT.

The default constructor sets anopt_mode<T> to nothing.There is also a constructor that takes an initial value of typeT.

It is possible to use theis-a.h accessors on amachine_modeor machine mode wrapperx:

is_a <T> (x)

Return true ifx meets the conditions for wrapper classT.

is_a <T> (x, &y)

Return true ifx meets the conditions for wrapper classT,storing it iny if so.y must be assignment-compatible withT.

as_a <T> (x)

Assert thatx meets the conditions for wrapper classTand return it as aT.

dyn_cast <T> (x)

Return anopt_mode<T> that holdsx ifx meetsthe conditions for wrapper classT and that holds nothing otherwise.

The purpose of these wrapper classes is to give stronger static typechecking. For example, if a function takes ascalar_int_mode,a caller that has a generalmachine_mode must either check orassert that the code is indeed a scalar integer first, using one ofthe functions above.

The wrapper classes are normal C++ classes, with user-definedconstructors. Sometimes it is useful to have a POD version ofthe same type, particularly if the type appears in aunion.The template classpod_mode<T> provides a POD versionof wrapper classT. It is assignment-compatible withTand implicitly converts to bothmachine_mode andT.

Here are some C macros that relate to machine modes:

GET_MODE (x)

Returns the machine mode of the RTXx.

PUT_MODE (x,newmode)

Alters the machine mode of the RTXx to benewmode.

NUM_MACHINE_MODES

Stands for the number of machine modes available on the targetmachine. This is one greater than the largest numeric value of anymachine mode.

GET_MODE_NAME (m)

Returns the name of modem as a string.

GET_MODE_CLASS (m)

Returns the mode class of modem.

GET_MODE_WIDER_MODE (m)

Returns the next wider natural mode. For example, the expressionGET_MODE_WIDER_MODE (QImode) returnsHImode.

GET_MODE_SIZE (m)

Returns the size in bytes of a datum of modem.

GET_MODE_BITSIZE (m)

Returns the size in bits of a datum of modem.

GET_MODE_IBIT (m)

Returns the number of integral bits of a datum of fixed-point modem.

GET_MODE_FBIT (m)

Returns the number of fractional bits of a datum of fixed-point modem.

GET_MODE_MASK (m)

Returns a bitmask containing 1 for all bits in a word that fit withinmodem. This macro can only be used for modes whose bitsize isless than or equal toHOST_BITS_PER_INT.

GET_MODE_ALIGNMENT (m)

Return the required alignment, in bits, for an object of modem.

GET_MODE_INNER (m)

Returns the mode of the basic parts of modem. For vector modesthis is the mode of the vector elements. For complex modes it is themode of the real and imaginary parts. For other modes it is modemitself.

GET_MODE_UNIT_SIZE (m)

Returns the size in bytes of the subunits of a datum of modem.This is the same asGET_MODE_SIZE except in the case of complexmodes. For them, the unit size is the size of the real or imaginarypart.

GET_MODE_NUNITS (m)

Returns the number of units contained in a mode, i.e.,GET_MODE_SIZE divided byGET_MODE_UNIT_SIZE.

GET_CLASS_NARROWEST_MODE (c)

Returns the narrowest mode in mode classc.

The following 3 variables are defined on every target. They can beused to allocate buffers that are guaranteed to be large enough tohold any value that can be represented on the target. The first twocan be overridden by defining them in the target’s mode.def file,however, the value must be a constant that can determined very earlyin the compilation process. The third symbol cannot be overridden.

BITS_PER_UNIT

The number of bits in an addressable storage unit (byte). If you donot define this, the default is 8.

MAX_BITSIZE_MODE_ANY_INT

The maximum bitsize of any mode that is used in integer math. Thisshould be overridden by the target if it uses large integers ascontainers for larger vectors but otherwise never uses the contents tocompute integer values.

MAX_BITSIZE_MODE_ANY_MODE

The bitsize of the largest mode on the target. The default value isthe largest mode size given in the mode definition file, which isalways correct for targets whose modes have a fixed size. Targetsthat might increase the size of a mode beyond this default should defineMAX_BITSIZE_MODE_ANY_MODE to the actual upper limit inmachine-modes.def.

The global variablesbyte_mode andword_mode contain modeswhose classes areMODE_INT and whose bitsizes are eitherBITS_PER_UNIT orBITS_PER_WORD, respectively. On 32-bitmachines, these areQImode andSImode, respectively.


Next:Constant Expression Types, Previous:Flags in an RTL Expression, Up:RTL Representation   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp