⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tm.texi

📁 理解和实践操作系统的一本好书
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
@c Copyright (C) 1988,1989,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,@c 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.@c This is part of the GCC manual.@c For copying conditions, see the file gcc.texi.@node Target Macros@chapter Target Description Macros and Functions@cindex machine description macros@cindex target description macros@cindex macros, target description@cindex @file{tm.h} macrosIn addition to the file @file{@var{machine}.md}, a machine descriptionincludes a C header file conventionally given the name@file{@var{machine}.h} and a C source file named @file{@var{machine}.c}.The header file defines numerous macros that convey the informationabout the target machine that does not fit into the scheme of the@file{.md} file.  The file @file{tm.h} should be a link to@file{@var{machine}.h}.  The header file @file{config.h} includes@file{tm.h} and most compiler source files include @file{config.h}.  Thesource file defines a variable @code{targetm}, which is a structurecontaining pointers to functions and data relating to the targetmachine.  @file{@var{machine}.c} should also contain their definitions,if they are not defined elsewhere in GCC, and other functions calledthrough the macros defined in the @file{.h} file.@menu* Target Structure::    The @code{targetm} variable.* Driver::              Controlling how the driver runs the compilation passes.* Run-time Target::     Defining @samp{-m} options like @option{-m68000} and @option{-m68020}.* Per-Function Data::   Defining data structures for per-function information.* Storage Layout::      Defining sizes and alignments of data.* Type Layout::         Defining sizes and properties of basic user data types.* Registers::           Naming and describing the hardware registers.* Register Classes::    Defining the classes of hardware registers.* Old Constraints::     The old way to define machine-specific constraints.* Stack and Calling::   Defining which way the stack grows and by how much.* Varargs::		Defining the varargs macros.* Trampolines::         Code set up at run time to enter a nested function.* Library Calls::       Controlling how library routines are implicitly called.* Addressing Modes::    Defining addressing modes valid for memory operands.* Anchored Addresses::  Defining how @option{-fsection-anchors} should work.* Condition Code::      Defining how insns update the condition code.* Costs::               Defining relative costs of different operations.* Scheduling::          Adjusting the behavior of the instruction scheduler.* Sections::            Dividing storage into text, data, and other sections.* PIC::			Macros for position independent code.* Assembler Format::    Defining how to write insns and pseudo-ops to output.* Debugging Info::      Defining the format of debugging output.* Floating Point::      Handling floating point for cross-compilers.* Mode Switching::      Insertion of mode-switching instructions.* Target Attributes::   Defining target-specific uses of @code{__attribute__}.* MIPS Coprocessors::   MIPS coprocessor support and how to customize it.* PCH Target::          Validity checking for precompiled headers.* C++ ABI::             Controlling C++ ABI changes.* Misc::                Everything else.@end menu@node Target Structure@section The Global @code{targetm} Variable@cindex target hooks@cindex target functions@deftypevar {struct gcc_target} targetmThe target @file{.c} file must define the global @code{targetm} variablewhich contains pointers to functions and data relating to the targetmachine.  The variable is declared in @file{target.h};@file{target-def.h} defines the macro @code{TARGET_INITIALIZER} which isused to initialize the variable, and macros for the default initializersfor elements of the structure.  The @file{.c} file should override thosemacros for which the default definition is inappropriate.  For example:@smallexample#include "target.h"#include "target-def.h"/* @r{Initialize the GCC target structure.}  */#undef TARGET_COMP_TYPE_ATTRIBUTES#define TARGET_COMP_TYPE_ATTRIBUTES @var{machine}_comp_type_attributesstruct gcc_target targetm = TARGET_INITIALIZER;@end smallexample@end deftypevarWhere a macro should be defined in the @file{.c} file in this manner toform part of the @code{targetm} structure, it is documented below as a``Target Hook'' with a prototype.  Many macros will change in futurefrom being defined in the @file{.h} file to being part of the@code{targetm} structure.@node Driver@section Controlling the Compilation Driver, @file{gcc}@cindex driver@cindex controlling the compilation driver@c prevent bad page break with this lineYou can control the compilation driver.@defmac SWITCH_TAKES_ARG (@var{char})A C expression which determines whether the option @option{-@var{char}}takes arguments.  The value should be the number of arguments thatoption takes--zero, for many options.By default, this macro is defined as@code{DEFAULT_SWITCH_TAKES_ARG}, which handles the standard optionsproperly.  You need not define @code{SWITCH_TAKES_ARG} unless youwish to add additional options which take arguments.  Any redefinitionshould call @code{DEFAULT_SWITCH_TAKES_ARG} and then check foradditional options.@end defmac@defmac WORD_SWITCH_TAKES_ARG (@var{name})A C expression which determines whether the option @option{-@var{name}}takes arguments.  The value should be the number of arguments thatoption takes--zero, for many options.  This macro rather than@code{SWITCH_TAKES_ARG} is used for multi-character option names.By default, this macro is defined as@code{DEFAULT_WORD_SWITCH_TAKES_ARG}, which handles the standard optionsproperly.  You need not define @code{WORD_SWITCH_TAKES_ARG} unless youwish to add additional options which take arguments.  Any redefinitionshould call @code{DEFAULT_WORD_SWITCH_TAKES_ARG} and then check foradditional options.@end defmac@defmac SWITCH_CURTAILS_COMPILATION (@var{char})A C expression which determines whether the option @option{-@var{char}}stops compilation before the generation of an executable.  The value isboolean, nonzero if the option does stop an executable from beinggenerated, zero otherwise.By default, this macro is defined as@code{DEFAULT_SWITCH_CURTAILS_COMPILATION}, which handles the standardoptions properly.  You need not define@code{SWITCH_CURTAILS_COMPILATION} unless you wish to add additionaloptions which affect the generation of an executable.  Any redefinitionshould call @code{DEFAULT_SWITCH_CURTAILS_COMPILATION} and then checkfor additional options.@end defmac@defmac SWITCHES_NEED_SPACESA string-valued C expression which enumerates the options for whichthe linker needs a space between the option and its argument.If this macro is not defined, the default value is @code{""}.@end defmac@defmac TARGET_OPTION_TRANSLATE_TABLEIf defined, a list of pairs of strings, the first of which is apotential command line target to the @file{gcc} driver program, and thesecond of which is a space-separated (tabs and other whitespace are notsupported) list of options with which to replace the first option.  Thetarget defining this list is responsible for assuring that the resultsare valid.  Replacement options may not be the @code{--opt} style, theymust be the @code{-opt} style.  It is the intention of this macro toprovide a mechanism for substitution that affects the multilibs chosen,such as one option that enables many options, some of which selectmultilibs.  Example nonsensical definition, where @option{-malt-abi},@option{-EB}, and @option{-mspoo} cause different multilibs to be chosen:@smallexample#define TARGET_OPTION_TRANSLATE_TABLE \@{ "-fast",   "-march=fast-foo -malt-abi -I/usr/fast-foo" @}, \@{ "-compat", "-EB -malign=4 -mspoo" @}@end smallexample@end defmac@defmac DRIVER_SELF_SPECSA list of specs for the driver itself.  It should be a suitableinitializer for an array of strings, with no surrounding braces.The driver applies these specs to its own command line between loadingdefault @file{specs} files (but not command-line specified ones) andchoosing the multilib directory or running any subcommands.  Itapplies them in the order given, so each spec can depend on theoptions added by earlier ones.  It is also possible to remove optionsusing @samp{%<@var{option}} in the usual way.This macro can be useful when a port has several interdependent targetoptions.  It provides a way of standardizing the command line sothat the other specs are easier to write.Do not define this macro if it does not need to do anything.@end defmac@defmac OPTION_DEFAULT_SPECSA list of specs used to support configure-time default options (i.e.@:@option{--with} options) in the driver.  It should be a suitable initializerfor an array of structures, each containing two strings, without theoutermost pair of surrounding braces.The first item in the pair is the name of the default.  This must matchthe code in @file{config.gcc} for the target.  The second item is a specto apply if a default with this name was specified.  The string@samp{%(VALUE)} in the spec will be replaced by the value of the defaulteverywhere it occurs.The driver will apply these specs to its own command line between loadingdefault @file{specs} files and processing @code{DRIVER_SELF_SPECS}, usingthe same mechanism as @code{DRIVER_SELF_SPECS}.Do not define this macro if it does not need to do anything.@end defmac@defmac CPP_SPECA C string constant that tells the GCC driver program options topass to CPP@.  It can also specify how to translate options yougive to GCC into options for GCC to pass to the CPP@.Do not define this macro if it does not need to do anything.@end defmac@defmac CPLUSPLUS_CPP_SPECThis macro is just like @code{CPP_SPEC}, but is used for C++, ratherthan C@.  If you do not define this macro, then the value of@code{CPP_SPEC} (if any) will be used instead.@end defmac@defmac CC1_SPECA C string constant that tells the GCC driver program options topass to @code{cc1}, @code{cc1plus}, @code{f771}, and the other languagefront ends.It can also specify how to translate options you give to GCC into optionsfor GCC to pass to front ends.Do not define this macro if it does not need to do anything.@end defmac@defmac CC1PLUS_SPECA C string constant that tells the GCC driver program options topass to @code{cc1plus}.  It can also specify how to translate options yougive to GCC into options for GCC to pass to the @code{cc1plus}.Do not define this macro if it does not need to do anything.Note that everything defined in CC1_SPEC is already passed to@code{cc1plus} so there is no need to duplicate the contents ofCC1_SPEC in CC1PLUS_SPEC@.@end defmac@defmac ASM_SPECA C string constant that tells the GCC driver program options topass to the assembler.  It can also specify how to translate optionsyou give to GCC into options for GCC to pass to the assembler.See the file @file{sun3.h} for an example of this.Do not define this macro if it does not need to do anything.@end defmac@defmac ASM_FINAL_SPECA C string constant that tells the GCC driver program how torun any programs which cleanup after the normal assembler.Normally, this is not needed.  See the file @file{mips.h} foran example of this.Do not define this macro if it does not need to do anything.@end defmac@defmac AS_NEEDS_DASH_FOR_PIPED_INPUTDefine this macro, with no value, if the driver should give the assembleran argument consisting of a single dash, @option{-}, to instruct it toread from its standard input (which will be a pipe connected to theoutput of the compiler proper).  This argument is given after any@option{-o} option specifying the name of the output file.If you do not define this macro, the assembler is assumed to read itsstandard input if given no non-option arguments.  If your assemblercannot read standard input at all, use a @samp{%@{pipe:%e@}} construct;see @file{mips.h} for instance.@end defmac@defmac LINK_SPECA C string constant that tells the GCC driver program options topass to the linker.  It can also specify how to translate options yougive to GCC into options for GCC to pass to the linker.Do not define this macro if it does not need to do anything.@end defmac@defmac LIB_SPECAnother C string constant used much like @code{LINK_SPEC}.  The differencebetween the two is that @code{LIB_SPEC} is used at the end of thecommand given to the linker.If this macro is not defined, a default is provided thatloads the standard C library from the usual place.  See @file{gcc.c}.@end defmac@defmac LIBGCC_SPECAnother C string constant that tells the GCC driver programhow and when to place a reference to @file{libgcc.a} into thelinker command line.  This constant is placed both before and afterthe value of @code{LIB_SPEC}.If this macro is not defined, the GCC driver provides a default thatpasses the string @option{-lgcc} to the linker.@end defmac@defmac REAL_LIBGCC_SPECBy default, if @code{ENABLE_SHARED_LIBGCC} is defined, the@code{LIBGCC_SPEC} is not directly used by the driver program but isinstead modified to refer to different versions of @file{libgcc.a}depending on the values of the command line flags @option{-static},@option{-shared}, @option{-static-libgcc}, and @option{-shared-libgcc}.  Ontargets where these modifications are inappropriate, define@code{REAL_LIBGCC_SPEC} instead.  @code{REAL_LIBGCC_SPEC} tells thedriver how to place a reference to @file{libgcc} on the link commandline, but, unlike @code{LIBGCC_SPEC}, it is used unmodified.@end defmac@defmac USE_LD_AS_NEEDEDA macro that controls the modifications to @code{LIBGCC_SPEC}mentioned in @code{REAL_LIBGCC_SPEC}.  If nonzero, a spec will begenerated that uses --as-needed and the shared libgcc in place of thestatic exception handler library, when linking without any of@code{-static}, @code{-static-libgcc}, or @code{-shared-libgcc}.@end defmac

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -