The /Gt (Set Data Value) Option

The /Gt option works differently on Alpha platforms than on x86. It sets the size threshold for small data. Although Alpha processors do not use the same concept of segment architecture as 16-bit Windows, the Alpha edition of Visual C++ does use the /Gt option to determine which data items to access with the GP register. The reason for this is that offsets in memory instructions are only 16 bits long. Therefore, ordinary load and store operations take ldah_H^addr() and ldl_L^addr(). With /Gt, small data is placed in .Sdata instead, and only one instruction is needed.

Using /Gt to Optimize Data Allocation

The Alpha edition of Visual C++ uses the /Gt option to control how data items are accessed through registers. You use this option to optimally allocate data for an application. For best results, you should add the /Gt option to external makefiles that produce applications. As mentioned in Testing the Processor Type in Makefiles, however, you may need to test the PROCESSOR_ARCHITECTURE string in makefiles to ensure that /Gt is used only on Alpha platforms. The /Gt option is not supported for 32-bit applications running on the x86 platform.

The following list provides guidelines for using the /Gt option:

Alpha processors use a GP (Global Pointer) register to efficiently access frequently used memory. Data in the GP area can be accessed with one machine instruction rather than two. Because the GP register is used in conjunction with a 16-bit offset, the area of memory that can be accessed through the GP register is 32K. With their flat address space, systems using the Alpha processor do not have segmented memory. However, the area of memory accessed through GP is similar to the concept of a near data segment and is also called the “small data area” or “fast data area.”

On Alpha platforms, the /Gt option controls how data is placed into the area accessed through the GP register; for a given setting /Gtn, objects smaller than n are placed into this fast data area. If you get linker errors, try a smaller /Gt value.

Important   Use of /Gt32 requires that every object to which your application links must also use /Gt32, except for external library code that doesn't have externally defined data references. If you are building code that will be used as others as a library or .DLL, build with /Gt0 unless you are sure that anything calling your code is also built with /Gt32.

If you are linking manually, see the Linking Objects_Built with the /Gt Switch topic in this chapter.