internals-6 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. Info file internals, produced by Makeinfo, -*- Text -*-
  2. from input file internals.texinfo.
  3. This file documents the internals of the GNU compiler.
  4. Copyright (C) 1988 Free Software Foundation, Inc.
  5. Permission is granted to make and distribute verbatim copies of
  6. this manual provided the copyright notice and this permission notice
  7. are preserved on all copies.
  8. Permission is granted to copy and distribute modified versions of this
  9. manual under the conditions for verbatim copying, provided also that the
  10. section entitled ``GNU CC General Public License'' is included exactly as
  11. in the original, and provided that the entire resulting derived work is
  12. distributed under the terms of a permission notice identical to this one.
  13. Permission is granted to copy and distribute translations of this manual
  14. into another language, under the above conditions for modified versions,
  15. except that the section entitled ``GNU CC General Public License'' and
  16. this permission notice may be included in translations approved by the
  17. Free Software Foundation instead of in the original English.
  18. 
  19. File: internals, Node: Misc, Next: Condition Code, Prev: Addressing Modes, Up: Machine Macros
  20. Miscellaneous Parameters
  21. ========================
  22. `CASE_VECTOR_MODE'
  23. An alias for a machine mode name. This is the machine mode that
  24. elements of a jump-table should have.
  25. `CASE_VECTOR_PC_RELATIVE'
  26. Define this macro if jump-tables should contain relative addresses.
  27. `CASE_DROPS_THROUGH'
  28. Define this if control falls through a `case' insn when the index
  29. value is out of range. This means the specified default-label is
  30. actually ignored by the `case' insn proper.
  31. `IMPLICIT_FIX_EXPR'
  32. An alias for a tree code that should be used by default for conversion
  33. of floating point values to fixed point. Normally, `FIX_ROUND_EXPR'
  34. is used.
  35. `FIXUNS_TRUNC_LIKE_FIX_TRUNC'
  36. Define this macro if the same instructions that convert a floating
  37. point number to a signed fixed point number also convert validly to an
  38. unsigned one.
  39. `EASY_DIV_EXPR'
  40. An alias for a tree code that is the easiest kind of division to
  41. compile code for in the general case. It may be `TRUNC_DIV_EXPR',
  42. `FLOOR_DIV_EXPR', `CEIL_DIV_EXPR' or `ROUND_DIV_EXPR'. These four
  43. division operators differ in how they round the result to an integer.
  44. `EASY_DIV_EXPR' is used when it is permissible to use any of those
  45. kinds of division and the choice should be made on the basis of
  46. efficiency.
  47. `DEFAULT_SIGNED_CHAR'
  48. An expression whose value is 1 or 0, according to whether the type
  49. `char' should be signed or unsigned by default. The user can always
  50. override this default with the options `-fsigned-char' and
  51. `-funsigned-char'.
  52. `SCCS_DIRECTIVE'
  53. Define this if the preprocessor should ignore `#sccs' directives with
  54. no error message.
  55. `MOVE_MAX'
  56. The maximum number of bytes that a single instruction can move quickly
  57. from memory to memory.
  58. `INT_TYPE_SIZE'
  59. A C expression for the size in bits of the type `int' on the target
  60. machine.
  61. `SLOW_BYTE_ACCESS'
  62. Define this macro as a C expression which is nonzero if accessing less
  63. than a word of memory (i.e. a `char' or a `short') is slow (requires
  64. more than one instruction).
  65. `SLOW_ZERO_EXTEND'
  66. Define this macro if zero-extension (of a `char' or `short' to an
  67. `int') can be done faster if the destination is a register that is
  68. known to be zero.
  69. If you define this macro, you must have instruction patterns that
  70. recognize RTL structures like this:
  71. (set (strict-low-part (subreg:QI (reg:SI ...) 0)) ...)
  72. and likewise for `HImode'.
  73. `SHIFT_COUNT_TRUNCATED'
  74. Define this macro if shift instructions ignore all but the lowest few
  75. bits of the shift count. It implies that a sign-extend or zero-extend
  76. instruction for the shift count can be omitted.
  77. `TRULY_NOOP_TRUNCATION (OUTPREC, INPREC)'
  78. A C expression which is nonzero if on this machine it is safe to
  79. ``convert'' an integer of INPREC bits to one of OUTPREC bits (where
  80. OUTPREC is smaller than INPREC) by merely operating on it as if it had
  81. only OUTPREC bits.
  82. On many machines, this expression can be 1.
  83. `NO_FUNCTION_CSE'
  84. Define this macro if it is as good or better to call a constant
  85. function address than to call an address kept in a register.
  86. `STORE_FLAG_VALUE'
  87. A C expression for the value stored by a store-flag instruction
  88. (`sCOND') when the condition is true. This is usually 1 or -1; it is
  89. required to be an odd number.
  90. Do not define `STORE_FLAG_VALUE' if the machine has no store-flag
  91. instructions.
  92. `Pmode'
  93. An alias for the machine mode for pointers. Normally the definition
  94. can be
  95. #define Pmode SImode
  96. `FUNCTION_MODE'
  97. An alias for the machine mode used for memory references to functions
  98. being called, in `call' RTL expressions. On most machines this should
  99. be `QImode'.
  100. `CONST_COST (X, CODE)'
  101. A part of a C `switch' statement that describes the relative costs of
  102. constant RTL expressions. It must contain `case' labels for
  103. expression codes `const_int', `const', `symbol_ref', `label_ref' and
  104. `const_double'. Each case must ultimately reach a `return' statement
  105. to return the relative cost of the use of that kind of constant value
  106. in an expression. The cost may depend on the precise value of the
  107. constant, which is available for examination in X.
  108. CODE is the expression code---redundant, since it can be obtained with
  109. `GET_CODE (X)'.
  110. `DOLLARS_IN_IDENTIFIERS'
  111. Define this if the character `$' should be allowed in identifier names.
  112. 
  113. File: internals, Node: Condition Code, Next: Assembler Format, Prev: Misc, Up: Machine Macros
  114. Condition Code Information
  115. ==========================
  116. The file `conditions.h' defines a variable `cc_status' to describe how the
  117. condition code was computed (in case the interpretation of the condition
  118. code depends on the instruction that it was set by). This variable
  119. contains the RTL expressions on which the condition code is currently
  120. based, and several standard flags.
  121. Sometimes additional machine-specific flags must be defined in the machine
  122. description header file. It can also add additional machine-specific
  123. information by defining `CC_STATUS_MDEP'.
  124. `CC_STATUS_MDEP'
  125. C code for a data type which is used for declaring the `mdep'
  126. component of `cc_status'. It defaults to `int'.
  127. `CC_STATUS_MDEP_INIT'
  128. A C expression for the initial value of the `mdep' field. It defaults
  129. to 0.
  130. `NOTICE_UPDATE_CC (EXP)'
  131. A C compound statement to set the components of `cc_status'
  132. appropriately for an insn whose body is EXP. It is this macro's
  133. responsibility to recognize insns that set the condition code as a
  134. byproduct of other activity as well as those that explicitly set
  135. `(cc0)'.
  136. If there are insn that do not set the condition code but do alter
  137. other machine registers, this macro must check to see whether they
  138. invalidate the expressions that the condition code is recorded as
  139. reflecting. For example, on the 68000, insns that store in address
  140. registers do not set the condition code, which means that usually
  141. `NOTICE_UPDATE_CC' can leave `cc_status' unaltered for such insns.
  142. But suppose that the previous insn set the condition code based on
  143. location `a4@(102)' and the current insn stores a new value in `a4'.
  144. Although the condition code is not changed by this, it will no longer
  145. be true that it reflects the contents of `a4@(102)'. Therefore,
  146. `NOTICE_UPDATE_CC' must alter `cc_status' in this case to say that
  147. nothing is known about the condition code value.
  148. 
  149. File: internals, Node: Assembler Format, Prev: Condition Code, Up: Machine Macros
  150. Output of Assembler Code
  151. ========================
  152. `ASM_SPEC'
  153. A C string constant that tells the GNU CC driver program options to
  154. pass to the assembler. It can also specify how to translate options
  155. you give to GNU CC into options for GNU CC to pass to the assembler.
  156. See the file `tm-sun3.h' for an example of this.
  157. Do not define this macro if it does not need to do anything.
  158. `LINK_SPEC'
  159. A C string constant that tells the GNU CC driver program options to
  160. pass to the linker. It can also specify how to translate options you
  161. give to GNU CC into options for GNU CC to pass to the linker.
  162. Do not define this macro if it does not need to do anything.
  163. `ASM_FILE_START'
  164. A C string constant for text to be output at the start of each
  165. assembler output file. Normally this is `"#NO_APP"', which is a
  166. comment that has no effect on most assemblers but tells the GNU
  167. assembler that it can save time by not checking for certain assembler
  168. constructs.
  169. `ASM_APP_ON'
  170. A C string constant for text to be output before each `asm' statement
  171. or group of consecutive ones. Normally this is `"#APP"', which is a
  172. comment that has no effect on most assemblers but tells the GNU
  173. assembler that it must check the lines that follow for all valid
  174. assembler constructs.
  175. `ASM_APP_OFF'
  176. A C string constant for text to be output after each `asm' statement
  177. or group of consecutive ones. Normally this is `"#NO_APP"', which
  178. tells the GNU assembler to resume making the time-saving assumptions
  179. that are valid for ordinary compiler output.
  180. `TEXT_SECTION_ASM_OP'
  181. A C string constant for the assembler operation that should precede
  182. instructions and read-only data. Normally `".text"' is right.
  183. `DATA_SECTION_ASM_OP'
  184. A C string constant for the assembler operation to identify the
  185. following data as writable initialized data. Normally `".data"' is
  186. right.
  187. `REGISTER_NAMES'
  188. A C initializer containing the assembler's names for the machine
  189. registers, each one as a C string constant. This is what translates
  190. register numbers in the compiler into assembler language.
  191. `DBX_REGISTER_NUMBER (REGNO)'
  192. A C expression that returns the DBX register number for the compiler
  193. register number REGNO. In simple cases, the value of this expression
  194. may be REGNO itself. But sometimes there are some registers that the
  195. compiler knows about and DBX does not, or vice versa. In such cases,
  196. some register may need to have one number in the compiler and another
  197. for DBX.
  198. `DBX_NO_XREFS'
  199. Define this macro if DBX on your system does not support the construct
  200. `xsTAGNAME'. On some systems, this construct is used to describe a
  201. forward reference to a structure named TAGNAME. On other systems,
  202. this construct is not supported at all.
  203. `DBX_CONTIN_LENGTH'
  204. A symbol name in DBX-format debugging information is normally
  205. continued (split into two separate `.stabs' directives) when it
  206. exceeds a certain length (by default, 80 characters). On some
  207. operating systems, DBX requires this splitting; on others, splitting
  208. must not be done. You can inhibit splitting by defining this macro
  209. with the value zero. You can override the default splitting-length by
  210. defining this macro as an expression for the length you desire.
  211. `DBX_CONTIN_CHAR'
  212. Normally continuation is indicated by adding a `\' character to the
  213. end of a `.stabs' string when a continuation follows. To use a
  214. different character instead, define this macro as a character constant
  215. for the character you want to use. Do not define this macro if
  216. backslash is correct for your system.
  217. `ASM_OUTPUT_LABEL (FILE, NAME)'
  218. A C statement (sans semicolon) to output to the stdio stream FILE the
  219. assembler definition of a label named NAME. Use the expression
  220. `assemble_name (FILE, NAME)' to output the name itself; before and
  221. after that, output the additional assembler syntax for defining the
  222. name, and a newline.
  223. `ASM_DECLARE_FUNCTION_NAME (FILE, NAME)'
  224. A C statement (sans semicolon) to output to the stdio stream FILE any
  225. text necessary for declaring the name of a function which is being
  226. defined. This macro is responsible for outputting the label
  227. definition (perhaps using `ASM_OUTPUT_LABEL').
  228. If this macro is not defined, then the function name is defined in the
  229. usual manner as a label (by means of `ASM_OUTPUT_LABEL').
  230. `ASM_GLOBALIZE_LABEL (FILE, NAME)'
  231. A C statement (sans semicolon) to output to the stdio stream FILE some
  232. commands that will make the label NAME global; that is, available for
  233. reference from other files. Use the expression `assemble_name (FILE,
  234. NAME)' to output the name itself; before and after that, output the
  235. additional assembler syntax for making that name global, and a newline.
  236. `ASM_OUTPUT_EXTERNAL (FILE, NAME)'
  237. A C statement (sans semicolon) to output to the stdio stream FILE any
  238. text necessary for declaring the name of an external symbol which is
  239. referenced in this compilation but not defined.
  240. This macro need not be defined if it does not need to output anything.
  241. The GNU assembler and most Unix assemblers don't require anything.
  242. `ASM_OUTPUT_LABELREF (FILE, NAME)'
  243. A C statement to output to the stdio stream FILE a reference in
  244. assembler syntax to a label named NAME. The character `_' should be
  245. added to the front of the name, if that is customary on your operating
  246. system, as it is in most Berkeley Unix systems. This macro is used in
  247. `assemble_name'.
  248. `ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM)'
  249. A C statement to output to the stdio stream FILE a label whose name is
  250. made from the string PREFIX and the number NUM. These labels are used
  251. for internal purposes, and there is no reason for them to appear in
  252. the symbol table of the object file. On many systems, the letter `L'
  253. at the beginning of a label has this effect. The usual definition of
  254. this macro is as follows:
  255. fprintf (FILE, "L%s%d:\n", PREFIX, NUM)
  256. `ASM_OUTPUT_CASE_LABEL (FILE, PREFIX, NUM, TABLE)'
  257. Define this if the label before a jump-table needs to be output
  258. specially. The first three arguments are the same as for
  259. `ASM_OUTPUT_INTERNAL_LABEL'; the fourth argument is the jump-table
  260. which follows (a `jump_insn' containing an `addr_vec' or
  261. `addr_diff_vec').
  262. This feature is used on system V to output a `swbeg' statement for the
  263. table.
  264. If this macro is not defined, these labels are output with
  265. `ASM_OUTPUT_INTERNAL_LABEL'.
  266. `ASM_FORMAT_PRIVATE_NAME (OUTVAR, NAME, NUMBER)'
  267. A C expression to assign to OUTVAR (which is a variable of type `char
  268. *') a newly allocated string made from the string NAME and the number
  269. NUMBER, with some suitable punctuation added. Use `alloca' to get
  270. space for the string.
  271. This string will be used as the argument to `ASM_OUTPUT_LABELREF' to
  272. produce an assembler label for an internal static variable whose name
  273. is NAME. Therefore, the string must be such as to result in valid
  274. assembler code. The argument NUMBER is different each time this macro
  275. is executed; it prevents conflicts between similarly-named internal
  276. static variables in different scopes.
  277. Ideally this string should not be a valid C identifier, to prevent any
  278. conflict with the user's own symbols. Most assemblers allow periods
  279. or percent signs in assembler symbols; putting at least one of these
  280. between the name and the number will suffice.
  281. `ASM_OUTPUT_ADDR_DIFF_ELT (FILE, VALUE, REL)'
  282. This macro should be provided on machines where the addresses in a
  283. dispatch table are relative to the table's own address.
  284. The definition should be a C statement to output to the stdio stream
  285. FILE an assembler pseudo-instruction to generate a difference between
  286. two labels. VALUE and REL are the numbers of two internal labels.
  287. The definitions of these labels are output using
  288. `ASM_OUTPUT_INTERNAL_LABEL', and they must be printed in the same way
  289. here. For example,
  290. fprintf (FILE, "\t.word L%d-L%d\n",
  291. VALUE, REL)
  292. `ASM_OUTPUT_ADDR_VEC_ELT (FILE, VALUE)'
  293. This macro should be provided on machines where the addresses in a
  294. dispatch table are absolute.
  295. The definition should be a C statement to output to the stdio stream
  296. FILE an assembler pseudo-instruction to generate a reference to a
  297. label. VALUE is the number of an internal label whose definition is
  298. output using `ASM_OUTPUT_INTERNAL_LABEL'. For example,
  299. fprintf (FILE, "\t.word L%d\n", VALUE)
  300. `ASM_OUTPUT_DOUBLE (FILE, VALUE)'
  301. A C statement to output to the stdio stream FILE an assembler
  302. instruction to assemble a `double' constant whose value is VALUE.
  303. VALUE will be a C expression of type `double'.
  304. `ASM_OUTPUT_FLOAT (FILE, VALUE)'
  305. A C statement to output to the stdio stream FILE an assembler
  306. instruction to assemble a `float' constant whose value is VALUE.
  307. VALUE will be a C expression of type `float'.
  308. `ASM_OUTPUT_INT (FILE, EXP)'
  309. `ASM_OUTPUT_SHORT (FILE, EXP)'
  310. `ASM_OUTPUT_CHAR (FILE, EXP)'
  311. A C statement to output to the stdio stream FILE an assembler
  312. instruction to assemble a `int', `short' or `char' constant whose
  313. value is VALUE. The argument EXP will be an RTL expression which
  314. represents a constant value. Use `output_addr_const (EXP)' to output
  315. this value as an assembler expression.
  316. `ASM_OUTPUT_BYTE (FILE, VALUE)'
  317. A C statement to output to the stdio stream FILE an assembler
  318. instruction to assemble a single byte containing the number VALUE.
  319. `ASM_OUTPUT_ASCII (FILE, PTR, LEN)'
  320. A C statement to output to the stdio stream FILE an assembler
  321. instruction to assemble a string constant containing the LEN bytes at
  322. PTR. PTR will be a C expression of type `char *' and LEN a C
  323. expression of type `int'.
  324. If the assembler has a `.ascii' pseudo-op as found in the Berkeley
  325. Unix assembler, do not define the macro `ASM_OUTPUT_ASCII'.
  326. `ASM_OUTPUT_SKIP (FILE, NBYTES)'
  327. A C statement to output to the stdio stream FILE an assembler
  328. instruction to advance the location counter by NBYTES bytes. NBYTES
  329. will be a C expression of type `int'.
  330. `ASM_OUTPUT_ALIGN (FILE, POWER)'
  331. A C statement to output to the stdio stream FILE an assembler
  332. instruction to advance the location counter to a multiple of 2 to the
  333. POWER bytes. POWER will be a C expression of type `int'.
  334. `ASM_OUTPUT_COMMON (FILE, NAME, SIZE)'
  335. A C statement (sans semicolon) to output to the stdio stream FILE the
  336. assembler definition of a common-label named NAME whose size is SIZE
  337. bytes. Use the expression `assemble_name (FILE, NAME)' to output the
  338. name itself; before and after that, output the additional assembler
  339. syntax for defining the name, and a newline.
  340. This macro controls how the assembler definitions of uninitialized
  341. global variables are output.
  342. `ASM_OUTPUT_LOCAL (FILE, NAME, SIZE)'
  343. A C statement (sans semicolon) to output to the stdio stream FILE the
  344. assembler definition of a local-common-label named NAME whose size is
  345. SIZE bytes. Use the expression `assemble_name (FILE, NAME)' to output
  346. the name itself; before and after that, output the additional
  347. assembler syntax for defining the name, and a newline.
  348. This macro controls how the assembler definitions of uninitialized
  349. static variables are output.
  350. `TARGET_BELL'
  351. A C constant expression for the integer value for escape sequence `\a'.
  352. `TARGET_BS'
  353. `TARGET_TAB'
  354. `TARGET_NEWLINE'
  355. C constant expressions for the integer values for escape sequences
  356. `\b', `\t' and `\n'.
  357. `TARGET_VT'
  358. `TARGET_FF'
  359. `TARGET_CR'
  360. C constant expressions for the integer values for escape sequences
  361. `\v', `\f' and `\r'.
  362. `ASM_OUTPUT_OPCODE (FILE, PTR)'
  363. Define this macro if you are using an unusual assembler that requires
  364. different names for the machine instructions.
  365. The definition is a C statement or statements which output an
  366. assembler instruction opcode to the stdio stream FILE. The
  367. macro-operand PTR is a variable of type `char *' which points to the
  368. opcode name in its ``internal'' form---the form that is written in the
  369. machine description. The definition should output the opcode name to
  370. FILE, performing any translation you desire, and increment the
  371. variABLE PTR to point at the end of the opcode so that it will not be
  372. output twice.
  373. In fact, your macro definition may process less than the entire opcode
  374. name, or more than the opcode name; but if you want to process text
  375. that includes `%'-sequences to substitute operands, you must take care
  376. of the substitution yourself. Just be sure to increment PTR over
  377. whatever text should not be output normally.
  378. If the macro definition does nothing, the instruction is output in the
  379. usual way.
  380. `PRINT_OPERAND (FILE, X, CODE)'
  381. A C compound statement to output to stdio stream FILE the assembler
  382. syntax for an instruction operand X. X is an RTL expression.
  383. CODE is a value that can be used to specify one of several ways of
  384. printing the operand. It is used when identical operands must be
  385. printed differently depending on the context. CODE comes from the `%'
  386. specification that was used to request printing of the operand. If
  387. the specification was just `%DIGIT' then CODE is 0; if the
  388. specification was `%LTR DIGIT' then CODE is the ASCII code for LTR.
  389. If X is a register, this macro should print the register's name. The
  390. names can be found in an array `reg_names' whose type is `char *[]'.
  391. `reg_names' is initialized from `REGISTER_NAMES'.
  392. When the machine description has a specification `%PUNCT' (a `%'
  393. followed by a punctuation character), this macro is called with a null
  394. pointer for X and the punctuation character for CODE.
  395. `PRINT_OPERAND_ADDRESS (FILE, X)'
  396. A C compound statement to output to stdio stream FILE the assembler
  397. syntax for an instruction operand that is a memory reference whose
  398. address is X. X is an RTL expression.
  399. `ASM_OPEN_PAREN'
  400. `ASM_CLOSE_PAREN'
  401. These macros are defined as C string constant, describing the syntax
  402. in the assembler for grouping arithmetic expressions. The following
  403. definitions are correct for most assemblers:
  404. #define ASM_OPEN_PAREN "("
  405. #define ASM_CLOSE_PAREN ")"
  406. 
  407. File: internals, Node: Config, Prev: Machine Macros, Up: Top
  408. The Configuration File
  409. **********************
  410. The configuration file `config-MACHINE.h' contains macro definitions that
  411. describe the machine and system on which the compiler is running. Most of
  412. the values in it are actually the same on all machines that GNU CC runs on,
  413. so most all configuration files are identical. But there are some macros
  414. that vary:
  415. `FAILURE_EXIT_CODE'
  416. A C expression for the status code to be returned when the compiler
  417. exits after serious errors.
  418. `SUCCESS_EXIT_CODE'
  419. A C expression for the status code to be returned when the compiler
  420. exits without serious errors.
  421.