internals.texinfo 138 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419
  1. \input texinfo @c -*-texinfo-*-
  2. @settitle Internals of GNU CC
  3. @setfilename internals
  4. @ifinfo
  5. This file documents the internals of the GNU compiler.
  6. Copyright (C) 1987 Richard M. Stallman.
  7. Permission is granted to make and distribute verbatim copies of
  8. this manual provided the copyright notice and this permission notice
  9. are preserved on all copies.
  10. @ignore
  11. Permission is granted to process this file through Tex and print the
  12. results, provided the printed document carries copying permission
  13. notice identical to this one except for the removal of this paragraph
  14. (this paragraph not being relevant to the printed manual).
  15. @end ignore
  16. Permission is granted to copy and distribute modified versions of this
  17. manual under the conditions for verbatim copying, provided also that the
  18. section entitled ``GNU CC General Public License'' is included exactly as
  19. in the original, and provided that the entire resulting derived work is
  20. distributed under the terms of a permission notice identical to this one.
  21. Permission is granted to copy and distribute translations of this manual
  22. into another language, under the above conditions for modified versions,
  23. except that the section entitled ``GNU CC General Public License'' may be
  24. included in a translation approved by the author instead of in the original
  25. English.
  26. @end ifinfo
  27. @setchapternewpage odd
  28. @titlepage
  29. @center @titlefont{Internals of GNU CC}
  30. @sp 2
  31. @center Richard M. Stallman
  32. @page
  33. @vskip 0pt plus 1filll
  34. Copyright @copyright{} 1987 Richard M. Stallman.
  35. Permission is granted to make and distribute verbatim copies of
  36. this manual provided the copyright notice and this permission notice
  37. are preserved on all copies.
  38. Permission is granted to copy and distribute modified versions of this
  39. manual under the conditions for verbatim copying, provided also that the
  40. section entitled ``GNU CC General Public License'' is included exactly as
  41. in the original, and provided that the entire resulting derived work is
  42. distributed under the terms of a permission notice identical to this one.
  43. Permission is granted to copy and distribute translations of this manual
  44. into another language, under the above conditions for modified versions,
  45. except that the section entitled ``GNU CC General Public License'' may be
  46. included in a translation approved by the author instead of in the original
  47. English.
  48. @end titlepage
  49. @page
  50. @ifinfo
  51. @node Top, Switches, , (DIR)
  52. Introduction
  53. ************
  54. This manual documents how to install and port the GNU C compiler.
  55. @end ifinfo
  56. @menu
  57. * Copying:: GNU CC General Public License says
  58. how you can copy and share GNU CC.
  59. * Switches:: Command switches supported by @samp{gcc}.
  60. * Installation:: How to configure, compile and install GNU CC.
  61. * Portability:: Goals of GNU CC's portability features.
  62. * Passes:: Order of passes, what they do, and what each file is for.
  63. * RTL:: The intermediate representation that most passes work on.
  64. * Machine Desc:: How to write machine description instruction patterns.
  65. * Machine Macros:: How to write the machine description C macros.
  66. @end menu
  67. @node Copying, Switches, Top, Top
  68. @unnumbered GNU CC GENERAL PUBLIC LICENSE
  69. The license agreements of most software companies keep you at the
  70. mercy of those companies. By contrast, our general public license is
  71. intended to give everyone the right to share GNU CC. To make sure that
  72. you get the rights we want you to have, we need to make restrictions
  73. that forbid anyone to deny you these rights or to ask you to surrender
  74. the rights. Hence this license agreement.
  75. Specifically, we want to make sure that you have the right to give
  76. away copies of GNU CC, that you receive source code or else can get it
  77. if you want it, that you can change GNU CC or use pieces of it in new
  78. free programs, and that you know you can do these things.
  79. To make sure that everyone has such rights, we have to forbid you to
  80. deprive anyone else of these rights. For example, if you distribute
  81. copies of GNU CC, you must give the recipients all the rights that you
  82. have. You must make sure that they, too, receive or can get the
  83. source code. And you must tell them their rights.
  84. Also, for our own protection, we must make certain that everyone
  85. finds out that there is no warranty for GNU CC. If GNU CC is modified by
  86. someone else and passed on, we want its recipients to know that what
  87. they have is not what we distributed, so that any problems introduced
  88. by others will not reflect on our reputation.
  89. Therefore we (Richard Stallman and the Free Software Fundation,
  90. Inc.) make the following terms which say what you must do to be
  91. allowed to distribute or change GNU CC.
  92. @unnumberedsec COPYING POLICIES
  93. @enumerate
  94. @item
  95. You may copy and distribute verbatim copies of GNU CC source code as
  96. you receive it, in any medium, provided that you conspicuously and
  97. appropriately publish on each copy a valid copyright notice
  98. ``Copyright @copyright{} 1987 Free Software Foundation, Inc.'' (or
  99. with the year updated if that is appropriate); keep intact the notices
  100. on all files that refer to this License Agreement and to the absence
  101. of any warranty; and give any other recipients of the GNU CC program a
  102. copy of this License Agreement along with the program. You may charge
  103. a distribution fee for the physical act of transferring a copy.
  104. @item
  105. You may modify your copy or copies of GNU CC or any portion of it,
  106. and copy and distribute such modifications under the terms of
  107. Paragraph 1 above, provided that you also do the following:
  108. @itemize @bullet
  109. @item
  110. cause the modified files to carry prominent notices stating
  111. that you changed the files and the date of any change; and
  112. @item
  113. cause the whole of any work that you distribute or publish,
  114. that in whole or in part contains or is a derivative of GNU CC or
  115. any part thereof, to be licensed at no charge to all third
  116. parties on terms identical to those contained in this License
  117. Agreement (except that you may choose to grant more extensive
  118. warranty protection to some or all third parties, at your
  119. option).
  120. @item
  121. You may charge a distribution fee for the physical act of
  122. transferring a copy, and you may at your option offer warranty
  123. protection in exchange for a fee.
  124. @end itemize
  125. @item
  126. You may copy and distribute GNU CC or any portion of it in
  127. compiled, executable or object code form under the terms of Paragraphs
  128. 1 and 2 above provided that you do the following:
  129. @itemize @bullet
  130. @item
  131. cause each such copy to be accompanied by the
  132. corresponding machine-readable source code, which must
  133. be distributed under the terms of Paragraphs 1 and 2 above; or,
  134. @item
  135. cause each such copy to be accompanied by a
  136. written offer, with no time limit, to give any third party
  137. free (except for a nominal shipping charge) a machine readable
  138. copy of the corresponding source code, to be distributed
  139. under the terms of Paragraphs 1 and 2 above; or,
  140. @item
  141. in the case of a recipient of GNU CC in compiled, executable
  142. or object code form (without the corresponding source code) you
  143. shall cause copies you distribute to be accompanied by a copy
  144. of the written offer of source code which you received along
  145. with the copy you received.
  146. @end itemize
  147. @item
  148. You may not copy, sublicense, distribute or transfer GNU CC
  149. except as expressly provided under this License Agreement. Any attempt
  150. otherwise to copy, sublicense, distribute or transfer GNU CC is void and
  151. your rights to use the program under this License agreement shall be
  152. automatically terminated. However, parties who have received computer
  153. software programs from you with this License Agreement will not have
  154. their licenses terminated so long as such parties remain in full compliance.
  155. @item
  156. If you wish to incorporate parts of GNU CC into other free programs
  157. whose distribution conditions are different, write to the Free Software
  158. Foundation at 1000 Mass Ave, Cambridge, MA 02138. We have not yet worked
  159. out a simple rule that can be stated here, but we will often permit this.
  160. We will be guided by the two goals of preserving the free status of all
  161. derivatives our free software and of promoting the sharing and reuse of
  162. software.
  163. @end enumerate
  164. Your comments and suggestions about our licensing policies and our
  165. software are welcome! Please contact the Free Software Foundation, Inc.,
  166. 1000 Mass Ave, Cambridge, MA 02138, or call (617) 876-3296.
  167. @unnumberedsec NO WARRANTY
  168. BECAUSE GNU CC IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO
  169. WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
  170. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  171. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE GNU CC "AS IS" WITHOUT
  172. WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
  173. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  174. A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
  175. PERFORMANCE OF GNU CC IS WITH YOU. SHOULD GNU CC PROVE DEFECTIVE, YOU
  176. ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  177. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  178. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  179. WHO MAY MODIFY AND REDISTRIBUTE GNU CC AS PERMITTED ABOVE, BE LIABLE TO
  180. YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
  181. SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  182. INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  183. BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
  184. FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GNU CC, EVEN
  185. IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR
  186. ANY CLAIM BY ANY OTHER PARTY.
  187. @node Switches, Installation, Copying, Top
  188. @chapter GNU CC Switches
  189. @table @samp
  190. @item -O
  191. Do optimize.
  192. @item -g
  193. Produce debugging information in DBX format.
  194. @item -c
  195. Compile but do not link the object files.
  196. @item -o @var{file}
  197. Place linker output in file @var{file}.
  198. @item -S
  199. Compile into assembler code but do not assemble.
  200. @item -m@var{machinespec}
  201. Machine-dependent switch specifying something about the type
  202. of target machine. For example, using the 68000 machine description,
  203. @samp{-m68000} specifies do not use the 68020 instructions,
  204. and @samp{-msoft-float} specifies do not use the 68881 floating point
  205. instructions.
  206. @item -d@var{letters}
  207. Says to make debugging dumps at times specified by @var{letters}.
  208. Here are the possible letters:
  209. @table @samp
  210. @item t
  211. Dump syntax-tree.
  212. @item r
  213. Dump after RTL generation.
  214. @item j
  215. Dump after first jump optimization.
  216. @item s
  217. Dump after CSE.
  218. @item L
  219. Dump after loop optimization.
  220. @item f
  221. Dump after flow analysis.
  222. @item c
  223. Dump after instruction combination.
  224. @item l
  225. Dump after local register allocation.
  226. @item g
  227. Dump after global register allocation.
  228. @end table
  229. @item -pedantic
  230. Attempt to support strict ANSI standard C. Valid ANSI standard C
  231. programs should compile properly with or without this switch.
  232. However, without this switch, certain useful or traditional constructs
  233. banned by the standard are supported. With this switch, they are
  234. rejected. There is no reason to use this switch; it exists only
  235. to satisfy pedants.
  236. @item E
  237. Preprocess the input files and output the results to standard output.
  238. @item C
  239. Tell the preprocessor not to discard comments. Used with the @samp{-E}
  240. switch.
  241. @item I@var{dir}
  242. Search directory @var{dir} for include files.
  243. @item D@var{macro}
  244. Define macro @var{macro} with the empty string as its definition.
  245. @item D@var{macro}=@var{defn}
  246. Define macro @var{macro} as @var{defn}.
  247. @item U@var{macro}
  248. Undefine macro @var{macro}.
  249. @item w
  250. Inhibit warning messages.
  251. @item v
  252. Compiler driver program prints the commands it executes as it runs
  253. the preprocessor, compiler proper, assembler and linker.
  254. @item B@var{prefix}
  255. Compiler driver program tries @var{prefix} as a prefix for each program
  256. it tries to run. These programs are @file{cpp}, @file{cc1},
  257. @file{as} and @file{ld}.
  258. For each subprogram to be run, the compiler driver first tries the
  259. @samp{-B} prefix, if any. If that name is not found, or if @samp{-B}
  260. was not specified, the driver tries two standard prefixes, which are
  261. @file{/usr/lib/gcc-} and @file{/usr/local/lib/gcc-}. If neither of
  262. those results in a file name that is found, the unmodified program
  263. name is searched for using the @samp{PATH} environment variable.
  264. @end table
  265. @node Installation, Portability, Switches, Top
  266. @chapter Installing GNU CC
  267. @enumerate
  268. @item
  269. Choose configuration files.
  270. @itemize @bullet
  271. @item
  272. Make a symbolic link from file @file{config.h} to the top-level
  273. config file for the machine you are using. Its name should be
  274. @file{config-@var{machine}.h}. This file is responsible for
  275. defining information about the host machine. It includes
  276. @file{tm.h}.
  277. @item
  278. Make a symbolic link from @file{tm.h} to the machine-description
  279. macro file for your machine (its name should be
  280. @file{tm-@var{machine}.h}).
  281. @item
  282. Make a symbolic link from @file{md} to the
  283. machine description pattern file (its name should be
  284. @file{@var{machine}.md}).
  285. @item
  286. Make a symbolic link from
  287. @file{aux-output.c} to the output-subroutine file for your machine
  288. (its name should be @file{@var{machine}-output.c}).
  289. @end itemize
  290. @item
  291. Make sure the Bison parser generator is installed.
  292. @item
  293. Build the compiler. Just type @samp{make} in the compiler directory.
  294. @item
  295. Delete @file{*.o} in the compiler directory. The executables from
  296. the previous step remain for the next step.
  297. @item
  298. Remake the compiler with
  299. @example
  300. make CC=./gcc CFLAGS="-g -O -I."
  301. @end example
  302. @item
  303. Install the compiler's passes. Copy the file @file{cc1} made by the
  304. compiler to the name @file{/usr/local/lib/gcc-cc1}.
  305. Make the file @file{/usr/local/lib/gcc-cpp} either a link to @file{/lib/cpp}
  306. or a copy of the file @file{cpp} generated by @samp{make}.
  307. @strong{Warning: the GNU CPP may not work for @file{ioctl.h}.} This
  308. cannot be fixed in the GNU CPP because the bug is in @file{ioctl.h}:
  309. at least on some machines, it relies on behavior that is incompatible
  310. with ANSI C. This behavior consists of substituting for macro
  311. argument names when they appear inside of character constants.
  312. @item
  313. Install the compiler driver. This is the file @file{gcc} generated
  314. by @samp{make}.
  315. @end enumerate
  316. @node Portability, Passes, Installation, Top
  317. @chapter GNU CC and Portability
  318. The main goal of GNU CC was to make a good, fast compiler for machines in
  319. the class that the GNU system aims to run on: 32-bit machines that address
  320. 8-bit bytes and have several general registers. Elegance, theoretical
  321. power and simplicity are only secondary.
  322. GNU CC gets most of the information about the target machine from a machine
  323. description which gives an algebraic formula for each of the machine's
  324. instructions. This is a very clean way to describe the target. But when
  325. the compiler needs information that is difficult to express in this
  326. fashion, I have not hesitated to define an ad-hoc parameter to the machine
  327. description. The purpose of portability is to reduce the total work needed
  328. on the compiler; it was not of interest for its own sake.
  329. GNU CC does not contain machine dependent code, but it does contain code
  330. that depends on machine parameters such as endianness (whether the most
  331. significant byte has the highest or lowest address of the bytes in a word)
  332. and the availability of autoincrement addressing. In the RTL-generation
  333. pass, it is often necessary to have multiple strategies for generating code
  334. for a particular kind of syntax tree, strategies that are usable for different
  335. combinations of parameters. Often I have not tried to address all possible
  336. cases, but only the common ones or only the ones that I have encountered.
  337. As a result, a new target may require additional strategies. You will know
  338. if this happens because the compiler will call @code{abort}. Fortunately,
  339. the new strategies can be added to all versions of the compiler, and will
  340. be relevant only for target machines that need them.
  341. @node Passes, RTL, Portability, Top
  342. @chapter Passes and Files of the Compiler
  343. The overall control structure of the compiler is in @file{toplev.c}. This
  344. file is responsible for initialization, decoding arguments, opening and
  345. closing files, and sequencing the passes.
  346. The parsing pass is invoked only once, to parse the entire input. Each
  347. time a complete function definition or top-level data definition is read,
  348. the parsing pass calls the function @code{rest_of_compilation} in
  349. @file{toplev.c}, which is responsible for all further processing necessary,
  350. ending with output of the assembler language. All other compiler passes
  351. run, in sequence, within @code{rest_of_compilation}. After
  352. @code{rest_of_compilation} returns from compiling a function definition,
  353. the storage used for its compilation is entirely freed.
  354. Here is a list of all the passes of the compiler and their source files.
  355. Also included is a description of where debugging dumps can be requested
  356. with @samp{-d} switches.
  357. @itemize @bullet
  358. @item
  359. Parsing. This pass reads the entire text of a function definition,
  360. constructing a syntax tree. The tree representation does not entirely
  361. follow C syntax, because it is intended to support other languages as well.
  362. C data type analysis is also done in this pass, and every tree node that
  363. represents an expression has a data type attached. Variables are represented
  364. as declaration nodes.
  365. Constant folding and associative-law simplifications are also done during
  366. this pass.
  367. The source files of the parsing pass are @file{parse.y}, @file{decl.c},
  368. @file{typecheck.c}, @file{stor-layout.c}, @file{fold-const.c}, and
  369. @file{tree.c}. The last three are intended to be language-independent.
  370. There are also header files @file{parse.h}, @file{c-tree.h},
  371. @file{tree.h} and @file{tree.def}. The last two define the format of
  372. the tree representation.
  373. @item
  374. RTL generation. This pass converts the tree structure for one
  375. function into RTL code.
  376. This is where the bulk of target-parameter-dependent code is found,
  377. since often it is necessary for strategies to apply only when certain
  378. standard kinds of instructions are available. The purpose of named
  379. instruction patterns is to provide this information to the RTL
  380. generation pass.
  381. Optimization is done in this pass for @code{if}-conditions that are
  382. comparisons, boolean operations or conditional expressions. Tail
  383. recursion is detected at this time also. Decisions are made about how
  384. best to arrange loops and how to output @code{switch} statements.
  385. The files of the RTL generation pass are @file{stmt.c}, @file{expr.c},
  386. @file{explow.c}, @file{expmed.c}, @file{optabs.c} and @file{emit-rtl.c}.
  387. Also, the file @file{insn-emit.c}, generated from the machine description
  388. by the program @code{genemit}, is used in this pass. The header files
  389. @file{expr.h} is used for communication within this pass.
  390. The header files @file{insn-flags.h} and @file{insn-codes.h}, generated from
  391. the machine description by the programs @code{genflags} and @code{gencodes},
  392. tell this pass which standard names are available for use and which patterns
  393. correspond to them.
  394. Aside from debugging information output, none of the following passes
  395. refers to the tree structure representation of the function.
  396. The switch @samp{-dr} causes a debugging dump of the RTL code after this
  397. pass. This dump file's name is made by appending @samp{.rtl} to the
  398. input file name.
  399. @item
  400. Jump optimization. This pass simplifies jumps to the following instruction,
  401. jumps across jumps, and jumps to jumps. It deletes unreferenced labels
  402. and unreachable code, except that unreachable code that contains a loop
  403. is not recognized as unreachable in this pass. (Such loops are deleted
  404. later in the basic block analysis.)
  405. Jump optimization is performed two or three times. The first time is
  406. immediately following RTL generation.
  407. The source file of this pass is @file{jump.c}.
  408. The switch @samp{-dj} causes a debugging dump of the RTL code after this
  409. pass is run for the first time. This dump file's name is made by appending
  410. @samp{.jump} to the input file name.
  411. @item
  412. Register scan. This pass finds the first and last use of each
  413. register, as a guide for common subexpression elimination. Its source
  414. is in @file{regclass.c}.
  415. @item
  416. Common subexpression elimination. This pass also does constant
  417. propagation. Its source file is @file{cse.c}. If constant
  418. propagation causes conditional jumps to become unconditional or to
  419. become no-ops, jump optimization is run again when cse is finished.
  420. The switch @samp{-ds} causes a debugging dump of the RTL code after
  421. this pass. This dump file's name is made by appending @samp{.cse} to
  422. the input file name.
  423. @item
  424. Loop optimization. This pass moves constant expressions out of loops.
  425. Its source file is @file{loop.c}.
  426. The switch @samp{-dL} causes a debugging dump of the RTL code after
  427. this pass. This dump file's name is made by appending @samp{.loop} to
  428. the input file name.
  429. @item
  430. Stupid register allocation is performed at this point in a
  431. nonoptimizing compilation. It does a little data flow analysis as
  432. well. When stupid register allocation is in use, the next pass
  433. executed is the reloading pass; the others in between are skipped.
  434. The source file is @file{stupid.c}, with header file @file{stupid.h}
  435. used for communication with the RTL generation pass.
  436. @item
  437. Data flow analysis (@file{flow.c}). This pass divides the program
  438. into basic blocks (and in the process deletes unreachable loops); then
  439. it computes which pseudo-registers are live at each point in the
  440. program, and makes the first instruction that uses a value point at
  441. the instruction that computed the value.
  442. This pass also deletes computations whose results are never used, and
  443. combines memory references with add or subtract instructions to make
  444. autoincrement or autodecrement addressing.
  445. The switch @samp{-df} causes a debugging dump of the RTL code after
  446. this pass. This dump file's name is made by appending @samp{.flow} to
  447. the input file name. If stupid register allocation is in use, this
  448. dump file reflects the full results of such allocation.
  449. @item
  450. Instruction combination (@file{combine.c}). This pass attempts to
  451. combine groups of two or three instructions that are related by data
  452. flow into single instructions. It combines the RTL expressions for
  453. the instructions by substitution, simplifies the result using algebra,
  454. and then attempts to match the result against the machine description.
  455. The switch @samp{-dc} causes a debugging dump of the RTL code after
  456. this pass. This dump file's name is made by appending @samp{.combine}
  457. to the input file name.
  458. @item
  459. Register class preferencing. The RTL code is scanned to find out
  460. which register class is best for each pseudo register. The source file
  461. is @file{regclass.c}.
  462. @item
  463. Local register allocation (@file{local-alloc.c}). This pass allocates
  464. hard registers to pseudo registers that are used only within one basic
  465. block. Because the basic block is linear, it can use fast and powerful
  466. techniques to do a very good job.
  467. The switch @samp{-dl} causes a debugging dump of the RTL code after
  468. this pass. This dump file's name is made by appending @samp{.lreg} to
  469. the input file name.
  470. @item
  471. Global register allocation (@file{global-alloc.c}). This pass
  472. allocates hard registers for the remaining pseudo registers (those
  473. whose life spans are not contained in one basic block).
  474. @item
  475. Reloading. This pass finds instructions that are invalid because a
  476. value has failed to end up in a register, or has ended up in a
  477. register of the wrong kind. It fixes up these instructions by
  478. reloading the problematical values into registers temporarily.
  479. Additional instructions are generated to do the copying.
  480. Source files are @file{reload.c} and @file{reload1.c}, plus the header
  481. @file{reload.h} used for communication between them.
  482. The switch @samp{-dg} causes a debugging dump of the RTL code after
  483. this pass. This dump file's name is made by appending @samp{.greg} to
  484. the input file name.
  485. @item
  486. Jump optimization is repeated, this time including cross-jumping.
  487. @item
  488. Final. This pass outputs the assembler code for the function. It is
  489. also responsible for identifying no-op move instructions and spurious
  490. test and compare instructions. The function entry and exit sequences
  491. are generated directly as assembler code in this pass; they never
  492. exist as RTL. Pseudo registers that did not get hard registers are
  493. given stack slots in this pass.
  494. The source files are @file{final.c} plus @file{insn-output.c}; the
  495. latter is generated automatically from the machine description by the
  496. tool @file{genoutput}. The header file @file{conditions.h} is used
  497. for communication between these files.
  498. @item
  499. Debugging information output. This is run after final because it must
  500. output the stack slot offsets for pseudo registers that did not get
  501. hard registers. Source files are @file{dbxout.c} for DBX symbol table
  502. format and @file{symout.c} for GDB's own symbol table format.
  503. @end itemize
  504. Some additional files are used by all or many passes:
  505. @itemize @bullet
  506. @item
  507. Every pass uses @file{machmode.def}, which defines the machine modes.
  508. @item
  509. All the passes that work with RTL use the header files @file{rtl.h}
  510. and @file{rtl.def}, and subroutines in file @file{rtl.c}. The
  511. tools @code{gen*} also use these files to read and work with the
  512. machine description RTL.
  513. @item
  514. Several passes refer to the header file @file{insn-config.h} which
  515. contains a few parameters (C macro definitions) generated
  516. automatically from the machine description RTL by the tool
  517. @code{genconfig}.
  518. @item
  519. Several passes use the instruction recognizer, which consists of
  520. @file{recog.c} and @file{recog.h}, plus the files @file{insn-recog.c}
  521. and @file{insn-extract.c} that are generated automatically from the
  522. machine description by the tools @file{genrecog} and @file{genextract}.
  523. @item
  524. Several passes use the header file @file{regs.h} which defines the
  525. information recorded about pseudo register usage, @file{basic-block.h}
  526. which defines the information recorded about basic blocks.
  527. @item
  528. @file{hard-reg-set.h} defines the type @code{HARD_REG_SET}, a bit-vector
  529. with a bit for each hard register, and some macros to manipulate it.
  530. This type is just @code{int} if the machine has few enough hard registers;
  531. otherwise it is an array of @code{int} and some of the macros expand
  532. into loops.
  533. @end itemize
  534. @node RTL, Machine Desc, Passes, Top
  535. @chapter RTL Representation
  536. Most of the work of the compiler is done on an intermediate representation
  537. called register tranfer language. In this language, the instructions to be
  538. output are described, pretty much one by one, in an algebraic form that
  539. describes what the instruction does.
  540. RTL is inspired by Lisp lists. It has both an internal form, made up of
  541. structures that point at other structures, and a textual form that is used
  542. in the machine description and in printed debugging dumps. The textual
  543. form uses nested parentheses to indicate the pointers in the internal form.
  544. @menu
  545. * RTL Objects:: Expressions vs vectors vs strings vs integers.
  546. * Accessors:: Macros to access expression operands or vector elts.
  547. * Machine Modes:: Describing the size and format of a datum.
  548. * Constants:: Expressions with constant values.
  549. * Regs and Memory:: Expressions representing register contents or memory.
  550. * Arithmetic:: Expressions representing arithmetic on other expressions.
  551. * Comparisons:: Expressions representing comparison of expressions.
  552. * Bit Fields:: Expressions representing bit-fields in memory or reg.
  553. * Conversions:: Extending, truncating, floating or fixing.
  554. * RTL Declarations:: Declaring volatility, constancy, etc.
  555. * Side Effects:: Expressions for storing in registers, etc.
  556. * Incdec:: Embedded side-effects for autoincrement addressing.
  557. * Insns:: Expression types for entire insns.
  558. * Sharing:: Some expressions are unique; others *must* be copied.
  559. @end menu
  560. @node RTL Objects, Accessors, RTL, RTL
  561. @section RTL Object Types
  562. RTL uses four kinds of objects: expressions, integers, strings and vectors.
  563. Expressions are the most important ones. An RTL expression is a C
  564. structure, but it is usually referred to with a pointer; a type that is
  565. given the typedef name @code{rtx}.
  566. An integer is simply an @code{int}, and a string is a @code{char *}.
  567. Within rtl code, strings appear only inside @samp{symbol_ref} expressions,
  568. but they appear in other contexts in the rtl expressions that make up
  569. machine descriptions. Their written form uses decimal digits.
  570. A string is a sequence of characters. In core it is represented as a
  571. @code{char *} in usual C fashion, and they are written in C syntax as well.
  572. However, strings in RTL may never be null. If you write an empty string in
  573. a machine description, it is represented in core as a null pointer rather
  574. than as a pointer to a null character. In certain contexts, these null
  575. pointers instead of strings are valid.
  576. A vector contains an arbitrary, specified number of pointers to
  577. expressions. The number of elements in the vector is explicitly present in
  578. the vector. The written form of a vector consists of square brackets
  579. (@samp{[@dots{}]}) surrounding the elements, in sequence and with
  580. whitespace separating them. Vectors of length zero are not created; null
  581. pointers are used instead.
  582. Expressions are classified by @dfn{expression code}. The expression code
  583. is a name defined in @file{rtl.def}, which is also (in upper case) a C
  584. enumeration constant. The possible expression codes and their meanings are
  585. machine-independent. The code of an rtx can be extracted with the macro
  586. @code{GET_CODE (@var{x})} and altered with @code{PUT_CODE (@var{x},
  587. @var{newcode})}.
  588. The expression code determines how many operands the expression contains,
  589. and what kinds of objects they are. In RTL, unlike Lisp, you cannot tell
  590. by looking at an operand what kind of object it is. Instead, you must know
  591. from its context---from the expression code of the containing expression.
  592. For example, in an expression of code @code{subreg}, the first operand is
  593. to be regarded as an expression and the second operand as an integer. In
  594. an expression of code @code{plus}, there are two operands, both of which
  595. are to be regarded as expressions. In a @code{symbol_ref} expression,
  596. there is one operand, which is to be regarded as a string.
  597. Expressions are written as parentheses containing the name of the
  598. expression type, its flags and machine mode if any, and then the operands
  599. of the expression (separated by spaces).
  600. In a few contexts a null pointer is valid where an expression is normally
  601. wanted. The written form of this is @samp{(nil)}.
  602. @node Accessors, Machine Modes, RTL Objects, RTL
  603. @section Access to Operands
  604. For each expression type @file{rtl.def} specifies the number of contained
  605. objects and their kinds, with four possibilities: @samp{e} for expression
  606. (actually a pointer to an expression), @samp{i} for integer, @samp{s} for
  607. string, and @samp{E} for vector of expressions. The sequence of letters
  608. for an expression code is called its @dfn{format}. Thus, the format of
  609. @code{subreg} is @samp{ei}.
  610. Two other format characters are used occasionally: @samp{u} and @samp{0}.
  611. @samp{u} is equivalent to @samp{e} except that it is printed differently in
  612. debugging dumps, and @samp{0} means a slot whose contents do not fit any
  613. normal category. @samp{0} slots are not printed at all in dumps, and are
  614. often used in special ways by small parts of the compiler.
  615. There are macros to get the number of operands and the format of an
  616. expression code:
  617. @table @code
  618. @item GET_RTX_LENGTH (@var{code})
  619. Number of operands of an rtx of code @var{code}.
  620. @item GET_RTX_FORMAT (@var{code})
  621. The format of an rtx of code @var{code}, as a C string.
  622. @end table
  623. Operands of expressions are accessed using the macros @code{XEXP},
  624. @code{XINT} and @code{XSTR}. Each of these macros takes two arguments: an
  625. expression-pointer (rtx) and an operand number (counting from zero). Thus,
  626. @example
  627. XEXP (x, 2)
  628. @end example
  629. @noindent
  630. accesses operand 2 of expression @var{x}, as an expression.
  631. @example
  632. XINT (x, 2)
  633. @end example
  634. @noindent
  635. accesses the same operand as an integer. @code{XSTR}, used in the same
  636. fashion, would access it as a string.
  637. Any operand can be accessed as an integer, as an expression or as a string.
  638. You must choose the correct method of access for the kind of value actually
  639. stored in the operand. You would do this based on the expression code of
  640. the containing expression. That is also how you would know how many
  641. operands there are.
  642. For example, if @var{x} is a @samp{subreg} expression, you know that it has
  643. two operands which can be correctly accessed as @code{XEXP (x, 0)} and
  644. @code{XINT (x, 1)}. If you did @code{XINT (x, 0)}, you would get the
  645. address of the expression operand but cast as an integer; that might
  646. occasionally be useful, but it would be cleaner to write @code{(int) XEXP
  647. (x, 0)}. @code{XEXP (x, 1)} would also compile without error, and would
  648. return the second, integer operand cast as an expression pointer, which
  649. would probably result in a crash when accessed. Nothing stops you from
  650. writing @code{XEXP (x, 28)} either, but this will access memory past the
  651. end of the expression with unpredictable results.
  652. Access to operands which are vectors is more complicated. You can use the
  653. macro @code{XVEC} to get the vector-pointer itself, or the macros
  654. @code{XVECEXP} and @code{XVECLEN} to access the elements and length of a
  655. vector.
  656. @table @code
  657. @item XVEC (@var{exp}, @var{idx})
  658. Access the vector-pointer which is operand number @var{idx} in @var{exp}.
  659. @item XVECLEN (@var{exp}, @var{idx})
  660. Access the length (number of elements) in the vector which is
  661. in operand number @var{idx} in @var{exp}. This value is an @code{int}.
  662. @item XVECLEN (@var{exp}, @var{idx}, @var{eltnum})
  663. Access element number @var{eltnum} in the vector which is
  664. in operand number @var{idx} in @var{exp}. This value is an @code{rtx}.
  665. It is up to you to make sure that @var{eltnum} is not negative
  666. and is less than @code{XVECLEN (@var{exp}, @var{idx})}.
  667. @end table
  668. All the macros defined in this section expand into lvalues and therefore
  669. can be used to assign the operands, lengths and vector elements as well as
  670. to access them.
  671. @node Machine Modes, Constants, Accessors, RTL
  672. @section Machine Modes
  673. A machine mode describes a size of data object and the representation used
  674. for it. In the C code, machine modes are represented by an enumeration
  675. type, @code{enum machine_mode}. Each rtl expression has room for a machine
  676. mode and so do certain kinds of tree expressions (declarations and types,
  677. to be precise).
  678. In debugging dumps and machine descriptions, the machine mode of an RTL
  679. expression is written after the expression code with a colon to separate
  680. them. The letters @samp{mode} which appear at the end of each machine mode
  681. name are omitted. For example, @code{(reg:SI 38)} is a @samp{reg}
  682. expression with machine mode @code{SImode}. If the mode is
  683. @code{VOIDmode}, it is not written at all.
  684. Here is a table of machine modes.
  685. @table @code
  686. @item QImode
  687. ``Quarter-Integer'' mode represents a single byte treated as an integer.
  688. @item HImode
  689. ``Half-Integer'' mode represents a two-byte integer.
  690. @item SImode
  691. ``Single Integer'' mode represents a four-byte integer.
  692. @item DImode
  693. ``Double Integer'' mode represents an eight-byte integer.
  694. @item TImode
  695. ``Tetra Integer'' (?) mode represents a sixteen-byte integer.
  696. @item SFmode
  697. ``Single Floating'' mode represents a single-precision (four byte) floating
  698. point number.
  699. @item DFmode
  700. ``Double Floating'' mode represents a double-precision (eight byte) floating
  701. point number.
  702. @item TFmode
  703. ``Tetra Floating'' mode represents a quadruple-precision (sixteen byte)
  704. floating point number.
  705. @item BLKmode
  706. ``Block'' mode represents values that are aggregates to which none of
  707. the other modes apply. In rtl, only memory references can have this mode,
  708. and only if they appear in string-move or vector instructions. On machines
  709. which have no such instructions, @code{BLKmode} will not appear in RTL.
  710. @item VOIDmode
  711. Void mode means the absence of a mode or an unspecified mode.
  712. For example, RTL expresslons of code @samp{const_int} have mode
  713. @code{VOIDmode} because they can be taken to have whatever mode the context
  714. requires. In debugging dumps of RTL, @code{VOIDmode} is expressed by
  715. the absence of any mode.
  716. @item EPmode
  717. ``Entry Pointer'' mode is intended to be used for function variables in
  718. Pascal and other block structured languages. Such values contain
  719. both a function address and a static chain pointer for access to
  720. automatic variables of outer levels. This mode is only partially
  721. implemented since C does not use it.
  722. @item CSImode@r{, @dots{}}
  723. ``Complex Single Integer'' mode stands for a complex number represented
  724. as a pair of @code{SImode} integers. Any of the integer and floating modes
  725. may have @samp{C} prefixed to its name to obtain a complex number mode.
  726. For example, there are @code{CQImode}, @code{CSFmode}, and @code{CDFmode}.
  727. Since C does not support complex numbers, these machine modes are only
  728. partially implemented.
  729. @item BImode
  730. This is the machine mode of a bit-field in a structure. It is used
  731. only in the syntax tree, never in RTL, and in the syntax tree it appears
  732. only in declaration nodes. In C, it appears only in @code{FIELD_DECL}
  733. nodes for structure fields defined with a bit size.
  734. @end table
  735. The machine description defines @code{Pmode} as a C macro which expands
  736. into the machine mode used for addresses. Normally this is @code{SImode}.
  737. The only modes which a machine description @i{must} support are
  738. @code{QImode}, @code{SImode}, @code{SFmode} and @code{DFmode}. The
  739. compiler will attempt to use @code{DImode} for two-word structures and
  740. unions, but it would not be hard to program it to avoid this. Likewise,
  741. you can arrange for the C type @code{short int} to avoid using
  742. @code{HImode}. In the long term it would be desirable to make the set of
  743. available machine modes machine-dependent and eliminate all assumptions
  744. about specific machine modes or their uses from the machine-independent
  745. code of the compiler.
  746. Here are some C macros that relate to machine modes:
  747. @table @code
  748. @item GET_MODE (@var{x})
  749. Returns the machine mode of the rtx @var{x}.
  750. @item PUT_MODE (@var{x}, @var{newmode})
  751. Alters the machine mode of the rtx @var{x} to be @var{newmode}.
  752. @item GET_MODE_SIZE (@var{m})
  753. Returns the size in bytes of a datum of mode @var{m}.
  754. @item GET_MODE_BITSIZE (@var{m})
  755. Returns the size in bits of a datum of mode @var{m}.
  756. @item GET_MODE_UNIT_SIZE (@var{m})
  757. Returns the size in bits of the subunits of a datum of mode @var{m}.
  758. This is the same as @code{GET_MODE_SIZE} except in the case of
  759. complex modes and @code{EPmode}. For them, the unit size ithe
  760. size of the real or imaginary part, or the size of the function
  761. pointer or the context pointer.
  762. @end table
  763. @node Constants, Regs and Memory, Machine Modes, RTL
  764. @section Constant Expression Types
  765. The simplest RTL expressions are those that represent constant values.
  766. @table @code
  767. @item (const_int @var{i})
  768. This type of expression represents the integer value @var{i}. @var{i}
  769. is customarily accessed with the macro @code{INTVAL} as in
  770. @code{INTVAL (exp)}, which is equivalent to @code{XINT (exp, 0)}.
  771. There is only one expression object for the integer value zero;
  772. it is the value of the variable @code{const0_rtx}. Likewise, the
  773. only expression for integer value one is found in @code{const1_rtx}.
  774. Any attempt to create an expression of code @code{const_int} and
  775. value zero or one will return @code{const0_rtx} or @code{const1_rtx}
  776. as appropriate.
  777. @item (const_double:@var{m} @var{i0} @var{i1})
  778. Represents a floating point constant value of mode @var{m}. The two
  779. integers @var{i0} and @var{i1} together contain the bits of a
  780. @code{double} value. To convert them to a @code{double}, do
  781. @example
  782. union { double d; int i[2];} u;
  783. u.i[0] = XINT (x, 0);
  784. u.i[1] = XINT (x, 1);
  785. @end example
  786. @noindent
  787. and then refer to @code{u.d}. The value of the constant is
  788. represented as a double in this fashion even if the value represented
  789. is single-precision.
  790. @code{dconst0_rtx} and @code{fconst0_rtx} are @samp{CONST_DOUBLE}
  791. expressions with value 0 and modes @code{DFmode} and @code{SFmode}.
  792. @item (symbol_ref @var{symbol})
  793. Represents the value of an assembler label for data. @var{symbol} is
  794. a string that describes the name of the assembler label. If it starts
  795. with a @samp{*}, the label is the rest of @var{symbol} not including
  796. the @samp{*}. Otherwise, the label is @var{symbol}, prefixed with
  797. @samp{_}.
  798. @item (label_ref @var{label})
  799. Represents the value of an assembler label for code. It contains one
  800. operand, an expression, which must be a @code{code_label} that appears
  801. in the instruction sequence to identify the place where the label
  802. should go.
  803. The reason for using a distinct expression type for code label
  804. references is so that jump optimization can distinguish them.
  805. @item (const @var{exp})
  806. Represents a constant that is the result of an assembly-time
  807. arithmetic computation. The operand, @var{exp}, is an expression that
  808. contains only constants (@samp{const_int}, @samp{symbol_ref} and
  809. @samp{label_ref} expressions) combined with @samp{plus} and
  810. @samp{minus}. However, not all combinations are valid, since the
  811. assembler cannot do arbitrary arithmetic on relocatable symbols.
  812. @end table
  813. @node Regs and Memory, Arithmetic, Constants, RTL
  814. @section Registers and Memory
  815. Here are the RTL expression types for describing access to machine
  816. registers and to main memory.
  817. @table @code
  818. @item (reg:@var{m} @var{n})
  819. For small values of the integer @var{n} (less than
  820. @code{FIRST_PSEUDO_REGISTER}), this stands for a reference to machine
  821. register number @var{n}: a @dfn{hard register}. For larger values of
  822. @var{n}, it stands for a temporary value or @dfn{pseudo register}.
  823. The compiler's strategy is to generate code assuming an unlimited
  824. number of such pseudo registers, and later convert them into hard
  825. registers or into memory references.
  826. The symbol @code{FIRST_PSEUDO_REGISTER} is defined by the machine
  827. description, since the number of hard registers on the machine is an
  828. invariant characteristic of the machine. Note, however, that not
  829. all of the machine registers must be general registers. All the
  830. machine registers that can be used for storage of data are given
  831. hard register numbers, even those that can be used only in certain
  832. instructions or can hold only certain types of data.
  833. Each pseudo register number used in a function's rtl code is
  834. represented by a unique @samp{reg} expression.
  835. @var{m} is the machine mode of the reference. It is necessary because
  836. machines can generally refer to each register in more than one mode.
  837. For example, a register may contain a full word but there may be
  838. instructions to refer to it as a half word or as a single byte, as
  839. well as instructions to refer to it as a floating point number of
  840. various precisions.
  841. Even for a register that the machine can access in only one mode,
  842. the mode must always be specified.
  843. A hard register may be accessed in various modes throughout one
  844. function, but each pseudo register is given a natural mode
  845. and is accessed only in that mode. When it is necessary to describe
  846. an access to a pseudo register using a nonnatural mode, a @samp{subreg}
  847. expression is used.
  848. A @samp{reg} expression with a machine mode that specifies more than
  849. one word of data may actually stand for several consecutive registers.
  850. If in addition the register number specifies a hardware register, then
  851. it actually represents several consecutive hardware registers starting
  852. with the specified one.
  853. Such multi-word hardware register @samp{reg} expressions may not be live
  854. across the boundary of a basic block. The lifetime analysis pass does not
  855. know how to record properly that several consecutive registers are
  856. actually live there, and therefore register allocation would be confused.
  857. The CSE pass must go out of its way to make sure the situation does
  858. not arise.
  859. @item (subreg:@var{m} @var{reg} @var{wordnum})
  860. @samp{subreg} expressions are used to refer to a register in a machine
  861. mode other than its natural one, or to refer to one register of
  862. a multi-word @samp{reg} that actually refers to several registers.
  863. Each pseudo-register has a natural mode. If it is necessary to
  864. operate on it in a different mode---for example, to perform a fullword
  865. move instruction on a pseudo-register that contains a single byte---
  866. the pseudo-register must be enclosed in a @samp{subreg}. In such
  867. a case, @var{wordnum} is zero.
  868. The other use of @samp{subreg} is to extract the individual registers
  869. of a multi-register value. Machine modes such as @code{DImode} and
  870. @code{EPmode} indicate values longer than a word, values which usually
  871. require two consecutive registers. To access one of the registers,
  872. use a @samp{subreg} with mode @code{SImode} and a @var{wordnum} that
  873. says which register.
  874. The compilation parameter @code{WORDS_BIG_ENDIAN}, if defined, says
  875. that word number zero is the most significant part; otherwise, it is
  876. the least significant part.
  877. Note that it is not valid to access a @code{DFmode} value in @code{SFmode}
  878. using a @samp{subreg}. On some machines the most significant part of a
  879. @code{DFmode} value does not have the same format as a single-precision
  880. floating value.
  881. @item (cc0)
  882. This refers to the machine's condition code register. It has no
  883. operands and may not have a machine mode. It may be validly used in
  884. only two contexts: as the destination of an assignment (in test and
  885. compare instructions) and in comparison operators comparing against
  886. zero (@code{const_int} with value zero; that is to say,
  887. @code{const0_rtx}.
  888. There is only one expression object of code @code{cc0}; it is the
  889. value of the variable @code{cc0_rtx}. Any attempt to create an
  890. expression of code @code{cc0} will return @code{cc0_rtx}.
  891. One special thing about the condition code register is that instructions
  892. can set it implicitly. On many machines, nearly all instructions set
  893. the condition code based on the value that they compute or store.
  894. It is not necessary to record these actions explicitly in the RTL
  895. because the machine description includes a prescription for recognizing
  896. the instructions that do so (by means of the macro @code{NOTICE_UPDATE_CC}).
  897. Only instructions whose sole purpose is to set the condition code,
  898. and instructions that use the condition code, need mention @code{(cc0)}.
  899. @item (pc)
  900. This represents the machine's program counter. It has no operands and
  901. may not have a machine mode. @code{(pc)} may be validly used only in
  902. certain specific contexts in jump instructions.
  903. There is only one expression object of code @code{pc}; it is the value of
  904. the variable @code{pc_rtx}. Any attempt to create an expression of code
  905. @code{pc} will return @code{pc_rtx}.
  906. All instructions that do not jump alter the program counter implicitly,
  907. but there is no need to mention this in the RTL.
  908. @item (mem:@var{m} @var{addr})
  909. This rtx represents a reference to main memory at an address
  910. represented by the expression @var{addr}. @var{m} specifies how
  911. large a unit of memory is accessed.
  912. @end table
  913. @node Arithmetic, Comparisons, Regs and Memory, RTL
  914. @section RTL Expressions for Arithmetic
  915. @table @code
  916. @item (plus:@var{m} @var{x} @var{y})
  917. Represents the sum of the values represented by @var{x} and @var{y}
  918. carried out in machine mode @var{m}. This is valid only if
  919. @var{x} and @var{y} both are valid for mode @var{m}.
  920. @item (minus:@var{m} @var{x} @var{y})
  921. Like @samp{plus} but represents subtraction.
  922. @item (minus @var{x} @var{y})
  923. Represents the result of subtracting @var{y} from @var{x}
  924. for purposes of comparison. The absence of a machine mode
  925. in the @samp{minus} expression indicates that the result is
  926. computed without overflow, as if with infinite precision.
  927. Of course, machines can't really subtract with infinite precision.
  928. However, they can pretend to do so when only the sign of the
  929. result will be used, which is the case when the result is stored
  930. in @code{(cc0)}. And that is the only was this kind of expression
  931. may validly be used: as a value to be stored in the condition codes.
  932. @item (neg:@var{m} @var{x})
  933. Represents the negation (subtraction from zero) of the value
  934. represented by @var{x}, carried out in mode @var{m}. @var{x} must be
  935. valid for mode @var{m}.
  936. @item (mult:@var{m} @var{x} @var{y})
  937. Represents the signed product of the values represented by @var{x} and
  938. @var{y} carried out in machine mode @var{m}. If
  939. @var{x} and @var{y} are both valid for mode @var{m}, this is ordinary
  940. size-preserving multiplication. Alteratively, both @var{x} and @var{y}
  941. may be valid for a different, narrower mode. This represents the
  942. kind of multiplication that generates a product wider than the operands.
  943. Widening multiplication and same-size multiplication are completely
  944. distinct and supported by different machine instructions; machines may
  945. support one but not the other.
  946. @samp{mult} may be used for floating point division as well.
  947. Then @var{m} is a floating point machine mode.
  948. @item (umult:@var{m} @var{x} @var{y})
  949. Like @samp{mult} but represents unsigned multiplication. It may be
  950. used in both same-size and widening forms, like @samp{mult}.
  951. @samp{umult} is used only for fixed-point division.
  952. @item (div:@var{m} @var{x} @var{y})
  953. Represents the quotient in signed division of @var{x} by @var{y},
  954. carried out in machine mode @var{m}. If @var{m} is a floating-point
  955. mode, it represents the exact quotient; otherwise, the integerized
  956. quotient. If @var{x} and @var{y} are both valid for mode @var{m},
  957. this is ordinary size-preserving division. Some machines have
  958. division instructions in which the operands and quotient widths are
  959. not all the same; such instructions are represented by @samp{div}
  960. expressions in which the machine modes are not all the same.
  961. @item (udiv:@var{m} @var{x} @var{y})
  962. Like @samp{div} but represents unsigned division.
  963. @item (mod:@var{m} @var{x} @var{y})
  964. @itemx (umod:@var{m} @var{x} @var{y})
  965. Like @samp{div} and @samp{udiv} but represent the remainder instead of
  966. the quotient.
  967. @item (not:@var{m} @var{x})
  968. Represents the bitwise complement of the value represented by @var{x},
  969. carried out in mode @var{m}, which must be a fixed-point machine mode.
  970. @var{x} must be valid for mode @var{m}, which must be a fixed-point mode.
  971. @item (and:@var{m} @var{x} @var{y})
  972. Represents the bitwise logical-and of the values represented by
  973. @var{x} and @var{y}, carried out in machine mode @var{m}. This is
  974. valid only if @var{x} and @var{y} both are valid for mode @var{m},
  975. which must be a fixed-point mode.
  976. @item (ior:@var{m} @var{x} @var{y})
  977. Represents the bitwise inclusive-or of the values represented by
  978. @var{x} and @var{y}, carried out in machine mode @var{m}. This is
  979. valid only if @var{x} and @var{y} both are valid for mode @var{m},
  980. which must be a fixed-point mode.
  981. @item (xor:@var{m} @var{x} @var{y})
  982. Represents the bitwise exclusive-or of the values represented by
  983. @var{x} and @var{y}, carried out in machine mode @var{m}. This is
  984. valid only if @var{x} and @var{y} both are valid for mode @var{m},
  985. which must be a fixed-point mode.
  986. @item (lshift:@var{m} @var{x} @var{c})
  987. Represents the result of logically shifting @var{x} left by @var{c}
  988. places. @var{x} must be valid for the mode @var{m}, a fixed-point
  989. machine mode. @var{c} must be valid for a fixed-point mode;
  990. which mode is determined by the mode called for in the machine
  991. description entry for the left-shift instruction. For example,
  992. on the Vax, the mode of @var{c} is @code{QImode} regardless of @var{m}.
  993. On some machines, negative values of @var{c} may be meaningful; this
  994. is why logical left shift an arithmetic left shift are distinguished.
  995. For example, Vaxes have no right-shift instructions, and right shifts
  996. are represented as left-shift instructions whose counts happen
  997. to be negative constants or else computed (in a previous instruction)
  998. by negation.
  999. @item (ashift:@var{m} @var{x} @var{c})
  1000. Like @samp{lshift} but for arithmetic left shift.
  1001. @item (lshiftrt:@var{m} @var{x} @var{c})
  1002. @itemx (ashiftrt:@var{m} @var{x} @var{c})
  1003. Like @samp{lshift} and @samp{ashift} but for right shift.
  1004. @item (rotate:@var{m} @var{x} @var{c})
  1005. @itemx (rotatert:@var{m} @var{x} @var{c})
  1006. Similar but represent left and right rotate.
  1007. @item (abs:@var{m} @var{x})
  1008. Represents the absolute value of @var{x}, computed in mode @var{m}.
  1009. @var{x} must be valid for @var{m}.
  1010. @item (sqrt:@var{m} @var{x})
  1011. Represents the square root of @var{x}, computed in mode @var{m}.
  1012. @var{x} must be valid for @var{m}. Most often @var{m} will be
  1013. a floating point mode.
  1014. @end table
  1015. @node Comparisons, Bit Fields, Arithmetic, RTL
  1016. @section Comparison Operations
  1017. Comparison operators test a relation on two operands and are considered to
  1018. represent the value 1 if the relation holds, or zero if it does not. The
  1019. mode of the comparison is determined by the operands; they must both be
  1020. valid for a common machine mode. A comparison with both operands constant
  1021. would be invalid as the machine mode could not be deduced from it, but such
  1022. a comparison should never exist in rtl due to constant folding.
  1023. Inequality comparisons come in two flavors, signed and unsigned. Thus,
  1024. there are distinct expression codes @samp{GT} and @samp{GTU} for signed and
  1025. unsigned greater-than. These can produce different results for the same
  1026. pair of integer values: for example, 1 is signed greater-than -1 but not
  1027. unsigned greater-than, because -1 when regarded as unsigned is actually
  1028. 0xffffffff which is greater than 1.
  1029. The signed comparisons are also used for floating point values. Floating
  1030. point comparisons are distinguished by the machine modes of the operands.
  1031. The comparison operators may be used to compare the condition codes
  1032. @code{(cc0)} against zero, as in @code{(eq (cc0) (const_int 0))}.
  1033. Such a construct actually refers to the result of the preceding
  1034. instruction in which the condition codes were set. The above
  1035. example stands for 1 if the condition codes were set to say
  1036. ``zero'' or ``equal'', 0 otherwise. Although the same comparison
  1037. operators are used for this as may be used in other contexts
  1038. on actual data, no confusion can result since the machine description
  1039. would never allow both kinds of uses in the same context.
  1040. @table @code
  1041. @item (eq @var{x} @var{y})
  1042. 1 if the values represented by @var{x} and @var{y} are equal,
  1043. otherwise 0.
  1044. @item (ne @var{x} @var{y})
  1045. 1 if the values represented by @var{x} and @var{y} are not equal,
  1046. otherwise 0.
  1047. @item (gt @var{x} @var{y})
  1048. 1 if the @var{x} is greater than @var{y}. If they are fixed-point,
  1049. the comparison is done in a signed sense.
  1050. @item (gtu @var{x} @var{y})
  1051. Like @samp{gt} but does unsigned comparison, on fixed-point numbers only.
  1052. @item (lt @var{x} @var{y})
  1053. @item (ltu @var{x} @var{y})
  1054. Like @samp{gt} and @samp{gtu} but test for ``less than''.
  1055. @item (ge @var{x} @var{y})
  1056. @item (geu @var{x} @var{y})
  1057. Like @samp{gt} and @samp{gtu} but test for ``greater than or equal''.
  1058. @item (le @var{x} @var{y})
  1059. @item (leu @var{x} @var{y})
  1060. Like @samp{gt} and @samp{gtu} but test for ``less than or equal''.
  1061. @item (if_then_else @var{cond} @var{then} @var{else})
  1062. This is not a comparison operation but is listed here because it is
  1063. always used in conjunction with a comparison operation. To be
  1064. precise, @var{cond} is a comparison expression. This expression
  1065. represents a choice, according to @var{cond}, between the value
  1066. represented by @var{then} and the one represented by @var{else}.
  1067. On most machines, @samp{if_then_else} expressions are valid only
  1068. to express conditional jumps.
  1069. @end table
  1070. @node Bit Fields, Conversions, Comparisons, RTL
  1071. @section Bit-fields
  1072. Special expression codes exist to represent bit-field instructions.
  1073. These types of expressions are lvalues in rtl; they may appear
  1074. on the left side of a assignment, indicating insertion of a value
  1075. into the specified bit field.
  1076. @table @code
  1077. @item (sign_extract:SI @var{loc} @var{size} @var{pos})
  1078. This represents a reference to a sign-extended bit-field contained or
  1079. starting in @var{loc} (a memory or register reference). The bit field
  1080. is @var{size} bits wide and starts at bit @var{pos}. The compilation
  1081. switch @code{BITS_BIG_ENDIAN} says which end of the memory unit
  1082. @var{pos} counts from.
  1083. Which machine modes are valid for @var{loc} depends on the machine,
  1084. but typically @var{loc} should be a single byte when in memory
  1085. or a full word in a register.
  1086. @item (zero_extract:SI @var{loc} @var{pos} @var{size})
  1087. Like @samp{sign_extract} but refers to an unsigned or zero-extended
  1088. bit field. The same sequence of bits are extracted, but they
  1089. are filled to an entire word with zeros instead of by sign-extension.
  1090. @end table
  1091. @node Conversions, RTL Declarations, Bit Fields, RTL
  1092. @section Conversions
  1093. All conversions between machine modes must be represented by
  1094. explicit conversion operations. For example, an expression
  1095. which the sum of a byte and a full word cannot be written as
  1096. @code{(plus:SI (reg:QI 34) (reg:SI 80))} because the @samp{plus}
  1097. operation requires two operands of the same machine mode.
  1098. Therefore, the byte-sized operand is enclosed in a conversion
  1099. operation, as in
  1100. @example
  1101. (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
  1102. @end example
  1103. The conversion operation is not a mere placeholder, because there
  1104. may be more than one way of converting from a given starting mode
  1105. to the desired final mode. The conversion operation code says how
  1106. to do it.
  1107. @table @code
  1108. @item (sign_extend:@var{m} @var{x})
  1109. Represents the result of sign-extending the value @var{x}
  1110. to machine mode @var{m}. @var{m} must be a fixed-point mode
  1111. and @var{x} a fixed-point value of a mode narrower than @var{m}.
  1112. @item (zero_extend:@var{m} @var{x})
  1113. Represents the result of zero-extending the value @var{x}
  1114. to machine mode @var{m}. @var{m} must be a fixed-point mode
  1115. and @var{x} a fixed-point value of a mode narrower than @var{m}.
  1116. @item (float_extend:@var{m} @var{x})
  1117. Represents the result of extending the value @var{x}
  1118. to machine mode @var{m}. @var{m} must be a floating point mode
  1119. and @var{x} a floating point value of a mode narrower than @var{m}.
  1120. @item (truncate:@var{m} @var{x})
  1121. Represents the result of truncating the value @var{x}
  1122. to machine mode @var{m}. @var{m} must be a fixed-point mode
  1123. and @var{x} a fixed-point value of a mode wider than @var{m}.
  1124. @item (float_truncate:@var{m} @var{x})
  1125. Represents the result of truncating the value @var{x}
  1126. to machine mode @var{m}. @var{m} must be a floating point mode
  1127. and @var{x} a floating point value of a mode wider than @var{m}.
  1128. @item (float:@var{m} @var{x})
  1129. Represents the result of converting fixed point value @var{x}
  1130. to floating point mode @var{m}.
  1131. @item (fix:@var{m} @var{x})
  1132. Represents the result of converting floating point value @var{x}
  1133. to fixed point mode @var{m}. How rounding is done is not specified.
  1134. @end table
  1135. @node RTL Declarations, Side Effects, Conversions, RTL
  1136. @section Declarations
  1137. Declaration expression codes do not represent arithmetic operations
  1138. but rather state assertions about their operands.
  1139. @table @code
  1140. @item (volatile:@var{m} @var{x})
  1141. Represents the same value @var{x} does, but makes the assertion
  1142. that it should be treated as a volatile value. This forbids
  1143. coalescing multiple accesses or deleting them even if it would
  1144. appear to have no effect on the program. @var{x} must be a @samp{mem}
  1145. expression with mode @var{m}.
  1146. The first thing the reload pass does to an insn is to remove all
  1147. @samp{volatile} expressions from it; each one is replaced by its
  1148. operand.
  1149. Recognizers will never recognize anything with @samp{volatile} in it.
  1150. This automatically prevents some optimizations on such things
  1151. (such as instruction combination). After the reload pass removes
  1152. all volatility information, the insns can be recognized.
  1153. Cse removes @samp{volatile} from destinations of @samp{set}'s, because
  1154. no optimizations reorder such @samp{set}s. This is not required for
  1155. correct code and is done to permit some optimization on the value to
  1156. be stored.
  1157. @item (unchanging:@var{m} @var{x})
  1158. Represents the same value @var{x} does, but makes the assertion
  1159. that its value is effectively constant during the execution
  1160. of the current function. This permits references to @var{x}
  1161. to be moved freely within the function. @var{x} must be a @samp{reg}
  1162. expression with mode @var{m}.
  1163. @item (strict_low_part (subreg:@var{m} (reg:@var{n} @var{r}) 0))
  1164. This expression code is used in only one context: operand 0 of a
  1165. @samp{set} expression. In addition, the operand of this expression
  1166. must be a @samp{subreg} expression.
  1167. The presence of @samp{strict_low_part} says that the part of the
  1168. register which is meaningful in mode @var{n} but is not part of
  1169. mode @var{m} is not to be altered. Normally, an assignment to such
  1170. a subreg is allowed to have undefined effects on the rest of the
  1171. register when @var{m} is less than a word.
  1172. @end table
  1173. @node Side Effects, Incdec, RTL Declarations, RTL
  1174. @section Side Effect Expressions
  1175. The expression codes described so far represent values, not actions.
  1176. But machine instructions never produce values; they are meaningful
  1177. only for their side effects on the state of the machine. Special
  1178. expression codes are used to represent side effects.
  1179. The body of an instruction is always one of these side effect codes;
  1180. the codes described above, which represent values, appear only as
  1181. the operands of these.
  1182. @table @code
  1183. @item (set @var{lval} @var{x})
  1184. Represents the action of storing the value of @var{x} into the place
  1185. represented by @var{lval}. @var{lval} must be an expression
  1186. representing a place that can be stored in: @samp{reg} (or
  1187. @samp{subreg} or @samp{strict_low_part}), @samp{mem}, @samp{pc} or
  1188. @samp{cc0}.
  1189. If @var{lval} is a @samp{reg}, @samp{subreg} or @samp{mem}, it has a
  1190. machine mode; then @var{x} must be valid for that mode.
  1191. If @var{lval} is a @samp{reg} whose machine mode is less than the full
  1192. width of the register, then it means that the part of the register
  1193. specified by the machine mode is given the specified value and the
  1194. rest of the register receives an undefined value. Likewise, if
  1195. @var{lval} is a @samp{subreg} whose machine mode is narrower than
  1196. @code{SImode}, the rest of the register can be changed in an undefined way.
  1197. If @var{lval} is a @samp{strict_low_part} of a @samp{subreg}, then the
  1198. part of the register specified by the machine mode of the
  1199. @samp{subreg} is given the value @var{x} and the rest of the register
  1200. is not changed.
  1201. If @var{lval} is @code{(cc0)}, it has no machine mode, and @var{x} may
  1202. have any mode. This represents a ``test'' or ``compare'' instruction.
  1203. If @var{lval} is @code{(pc)}, we have a jump instruction, and the
  1204. possibilities for @var{x} are very limited. It may be a
  1205. @samp{label_ref} expression (unconditional jump). It may be an
  1206. @samp{if_then_else} (conditional jump), in which case either the
  1207. second or the third operand must be @code{(pc)} (for the case which
  1208. does not jump) and the other of the two must be a @samp{label_ref}
  1209. (for the case which does jump). @var{x} may also be a @samp{mem} or
  1210. @code{(plus:SI (pc) @var{y})}, where @var{y} may be a @samp{reg} or a
  1211. @samp{mem}; these unusual patterns are used to represent jumps through
  1212. branch tables.
  1213. @item (return)
  1214. Represents a return from the current function, on machines where
  1215. this can be done with one instruction, such as Vaxen. On machines
  1216. where a multi-instruction ``epilogue'' must be executed in order
  1217. to return from the function, returning is done by jumping to a
  1218. label which precedes the epilogue, and the @samp{return} expression
  1219. code is never used.
  1220. @item (call @var{function} @var{nargs})
  1221. Represents a function call. @var{function} is a @samp{mem} expression
  1222. whose address is the address of the function to be called. @var{nargs}
  1223. is an expression representing the number of words of argument.
  1224. Each machine has a standard machine mode which @var{function} must
  1225. have. The machine descripion defines macro @code{FUNCTION_MODE} to
  1226. expand into the requisite mode name. The purpose of this mode is to
  1227. specify what kind of addressing is allowed, on machines where the
  1228. allowed kinds of addressing depend on the machine mode being
  1229. addressed.
  1230. @item (clobber @var{x})
  1231. Represents the storing or possible storing of an unpredictable,
  1232. undescribed value into @var{x}, which must be a @samp{reg} or
  1233. @samp{mem} expression.
  1234. One place this is used is in string instructions that store standard
  1235. values into particular hard registers. It may not be worth the
  1236. trouble to describe the values that are stored, but it is essential
  1237. to inform the compiler that the registers will be altered, lest it
  1238. attempt to keep data in them across the string instruction.
  1239. @var{x} may also be null---a null C pointer, no expression at all.
  1240. Such a @code{(clobber (null))} expression means that all memory
  1241. locations must be presumed clobbered.
  1242. Note that the machine description classifies certain hard registers as
  1243. ``call-clobbered''. All function call instructions are assumed by
  1244. default to clobber these registers, so there is no need to use
  1245. @samp{clobber} expressions to indicate this fact. Also, each function
  1246. call is assumed to have the potential to alter any memory location.
  1247. @item (use @var{x})
  1248. Represents the use of the value of @var{x}. It indicates that
  1249. the value in @var{x} at this point in the program is needed,
  1250. even though it may not be apparent whythis is so. Therefore, the
  1251. compiler will not attempt to delete instructions whose only
  1252. effect is to store a value in @var{x}. @var{x} must be a @samp{reg}
  1253. expression.
  1254. @item (parallel [@var{x0} @var{x1} @dots{}])
  1255. Represents several side effects performed in parallel. The square
  1256. brackets stand for a vector; the operand of @samp{parallel} is a
  1257. vector of expressions. @var{x0}, @var{x1} and so on are individual
  1258. side effects---expressions of code @samp{set}, @samp{call},
  1259. @samp{return}, @samp{clobber} or @samp{use}.
  1260. ``In parallel'' means that first all the values used in
  1261. the individual side-effects are computed, and second all the actual
  1262. side-effects are performed. For example,
  1263. @example
  1264. (parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
  1265. (set (mem:SI (reg:SI 1)) (reg:SI 1))])
  1266. @end example
  1267. @noindent
  1268. says unambiguously that the values of hard register 1 and the memory
  1269. location addressed by it are interchanged. In both places where
  1270. @code{(reg:SI 1)} appears as a memory address it refers to the value
  1271. in register 1 @i{before} the execution of the instruction.
  1272. @end table
  1273. Three expression codes appear in place of a side effect, as the body
  1274. of an insn, though strictly speaking they do not describe side effects
  1275. as such:
  1276. @table @code
  1277. @item (asm_input @var{s})
  1278. Represents literal assembler code as described by the string @var{s}.
  1279. @item (addr_vec:@var{m} [@var{lr0} @var{lr1} @dots{}])
  1280. Represents a table of jump addresses. @var{lr0} etc. are
  1281. @samp{label_ref} expressions. The mode @var{m} specifies how much
  1282. space is given to each address; normally @var{m} would be
  1283. @code{Pmode}.
  1284. @item (addr_diff_vec:@var{m} @var{base} [@var{lr0} @var{lr1} @dots{}])
  1285. Represents a table of jump addresses expressed as offsets from
  1286. @var{base}. @var{lr0} etc. are @samp{label_ref} expressions and so is
  1287. @var{base}. The mode @var{m} specifies how much space is given to
  1288. each address-difference.
  1289. @end table
  1290. @node Incdec, Insns, Side Effects, RTL
  1291. @section Embedded Side-Effects on Addresses
  1292. Four special side-effect expression codes appear as memory addresses.
  1293. @table @code
  1294. @item (pre_dec:@var{m} @var{x})
  1295. Represents the side effect of decrementing @var{x} by a standard
  1296. amount and represents also the value that @var{x} has after being
  1297. decremented. @var{x} must be a @samp{reg} or @samp{mem}, but most
  1298. machines allow only a @samp{reg}. @var{m} must be the machine mode
  1299. for pointers on the machine in use. The amount @var{x} is decrement
  1300. by is the length in bytes of the machine mode of the containing memory
  1301. reference of which this expression serves as the address. Here is an
  1302. example of its use:
  1303. @example
  1304. (mem:DF (pre_dec:SI (reg:SI 39)))
  1305. @end example
  1306. @noindent
  1307. This says to decrement pseudo register 39 by the length of a @code{DFmode}
  1308. value and use the result to address a @code{DFmode} value.
  1309. @item (pre_inc:@var{m} @var{x})
  1310. Similar, but specifies incrementing @var{x} instead of decrementing it.
  1311. @item (post_dec:@var{m} @var{x})
  1312. Represents the same side effect as @samp{pre_decrement} but a different
  1313. value. The value represented here is the value @var{x} has @i{before}
  1314. being decremented.
  1315. @item (post_inc:@var{m} @var{x})
  1316. Similar, but specifies incrementing @var{x} instead of decrementing it.
  1317. @end table
  1318. These embedded side effect expressions must be used with care. Instruction
  1319. patterns may not use them. Until the @samp{flow} pass of the compiler,
  1320. they may occur only to represent pushes onto the stack. The @samp{flow}
  1321. pass finds cases where registers are incremented or decremented in one
  1322. instruction and used as an address shortly before or after; these cases are
  1323. then transformed to use pre- or post-increment or -decrement.
  1324. Explicit popping of the stack could be represented with these embedded
  1325. side effect operators, but that would not be safe; the instruction
  1326. combination pass could move the popping past pushes, thus changing
  1327. the meaning of the code.
  1328. An instruction that can be represented with an embedded side effect
  1329. could also be represented using @samp{parallel} containing an additional
  1330. @samp{set} to describe how the address register is altered. This is not
  1331. done because machines that allow these operations at all typically
  1332. allow them wherever a memory address is called for. Describing them as
  1333. additional parallel stores would require doubling the number of entries
  1334. in the machine description.
  1335. @node Insns, Sharing, Incdec, RTL
  1336. @section Insns
  1337. The RTL representation of the code for a function is a doubly-linked
  1338. chain of objects called @dfn{insns}. Insns are expressions with
  1339. special codes that are used for no other purpose. Some insns are
  1340. actual instructions; others represent dispatch tables for @code{switch}
  1341. statements; others represent labels to jump to or various sorts of
  1342. declaratory information.
  1343. In addition to its own specific data, each insn must have a unique id number
  1344. that distinguishes it from all other insns in the current function, and
  1345. chain pointers to the preceding and following insns. These three fields
  1346. occupy the same position in every insn, independent of the expression code
  1347. of the insn. They could be accessed with @code{XEXP} and @code{XINT},
  1348. but instead three special macros are always used:
  1349. @table @code
  1350. @item INSN_UID (@var{i})
  1351. Accesses the unique id of insn @var{i}.
  1352. @item PREV_INSN (@var{i})
  1353. Accesses the chain pointer to the insn preceding @var{i}.
  1354. If @var{i} is the first insn, this is a null pointer.
  1355. @item NEXT_INSN (@var{i})
  1356. Accesses the chain pointer to the insn following @var{i}.
  1357. If @var{i} is the last insn, this is a null pointer.
  1358. @end table
  1359. The @code{NEXT_INSN} and @code{PREV_INSN} pointers must always
  1360. correspond: if @var{i} is not the first insn,
  1361. @example
  1362. NEXT_INSN (PREV_INSN (@var{insn})) == @var{insn}
  1363. @end example
  1364. @noindent
  1365. is always true.
  1366. Every insn has one of the following six expression codes:
  1367. @table @code
  1368. @item insn
  1369. The expression code @samp{insn} is used for instructions that do not jump
  1370. and do not do function calls. Insns with code @samp{insn} have four
  1371. additional fields beyond the three mandatory ones listed above.
  1372. These four are described in a table below.
  1373. @item jump_insn
  1374. The expression code @samp{jump_insn} is used for instructions that may jump
  1375. (or, more generally, may contain @samp{label_ref} expressions).
  1376. @samp{jump_insn} insns have the same extra fields as @samp{insn} insns,
  1377. accessed in the same way.
  1378. @item call_insn
  1379. The expression code @samp{call_insn} is used for instructions that may do
  1380. function calls. It is important to distinguish these instructions because
  1381. they imply that certain registers and memory locations may be altered
  1382. unpredictably.
  1383. @samp{call_insn} insns have the same extra fields as @samp{insn} insns,
  1384. accessed in the same way.
  1385. @item code_label
  1386. A @samp{code_label} insn represents a label that a jump insn can jump to.
  1387. It contains one special field of data in addition to the three standard ones.
  1388. It is used to hold the @dfn{label number}, a number that identifies this
  1389. label uniquely among all the labels in the compilation (not just in the
  1390. current function). Ultimately, the label is represented in the assembler
  1391. output as an assembler label @samp{L@var{n}} where @var{n} is the label number.
  1392. @item barrier
  1393. Barriers are placed in the instruction stream after unconditional
  1394. jump instructions to indicate that the jumps are unconditional.
  1395. They contain no information beyond the three standard fields.
  1396. @item note
  1397. @samp{note} insns are used to represent additional debugging and
  1398. declaratory information. They contain two nonstandard fields, an
  1399. integer which is accessed with the macro @code{NOTE_LINE_NUMBER} and a
  1400. string accessed with @code{NOTE_SOURCE_FILE}.
  1401. If @code{NOTE_LINE_NUMBER} is positive, the note represents the
  1402. position of a source line and @code{NOTE_SOURCE_FILE} is the source file name
  1403. that the line came from. These notes control generation of line
  1404. number data in the assembler output.
  1405. Otherwise, @code{NOTE_LINE_NUMBER} is not really a line number but a
  1406. code with one of the following values (and @code{NOTE_SOURCE_FILE}
  1407. must contain a null pointer):
  1408. @table @code
  1409. @item NOTE_INSN_DELETED
  1410. Such a note is completely ignorable. Some passes of the compiler
  1411. delete insns by altering them into notes of this kind.
  1412. @item NOTE_INSN_BLOCK_BEG
  1413. @itemx NOTE_INSN_BLOCK_END
  1414. These types of notes indicate the position of the beginning and end
  1415. of a level of scoping of variable names. They control the output
  1416. of debugging information.
  1417. @item NOTE_INSN_LOOP_BEG
  1418. @itemx NOTE_INSN_LOOP_END
  1419. These types of notes indicate the position of the beginning and end
  1420. of a @code{while} or @code{for} loop. They enable the loop optimizer
  1421. to find loops quickly.
  1422. @end table
  1423. @end table
  1424. Here is a table of the extra fields of @samp{insn}, @samp{jump_insn}
  1425. and @samp{call_insn} insns:
  1426. @table @code
  1427. @item PATTERN (@var{i})
  1428. An expression for the side effect performed by this insn.
  1429. @item REG_NOTES (@var{i})
  1430. A list (chain of @samp{expr_list} expressions) giving information
  1431. about the usage of registers in this insn. This list is set up by the
  1432. @code{flow} pass; it is a null pointer until then.
  1433. @item LOG_LINKS (@var{i})
  1434. A list (chain of @samp{insn_list} expressions) of previous ``related''
  1435. insns: insns which store into registers values that are used for the
  1436. first time in this insn. (An additional constraint is that neither a
  1437. jump nor a label may come between the related insns). This list is
  1438. set up by the @code{flow} pass; it is a null pointer until then.
  1439. @item INSN_CODE (@var{i})
  1440. An integer that says which pattern in the machine description matches
  1441. this insn, or -1 if the matching has not yet been attempted.
  1442. Such matching is never attempted and this field is not used on an insn
  1443. whose pattern consists of a single @samp{use}, @samp{clobber},
  1444. @samp{asm}, @samp{addr_vec} or @samp{addr_diff_vec} expression.
  1445. @end table
  1446. The @code{LOG_LINKS} field of an insn is a chain of @samp{insn_list}
  1447. expressions. Each of these has two operands: the first is an insn,
  1448. and the second is another @samp{insn_list} expression (the next one in
  1449. the chain). The last @samp{insn_list} in the chain has a null pointer
  1450. as second operand. The significant thing about the chain is which
  1451. insns apepar in it (as first operands of @samp{insn_list}
  1452. expressions). Their order is not significant.
  1453. The @code{REG_NOTES} field of an insn is a similar chain but of
  1454. @samp{expr_list} expressions instead of @samp{insn_list}. The first
  1455. operand is a @samp{reg} rtx. Its presence in the list can have three
  1456. possible meanings, distinguished by a value that is stored in the
  1457. machine-mode field of the @samp{expr_list} because that is a
  1458. conveniently available space, but that is not really a machine mode.
  1459. These values belong to the C type @code{enum reg_note} and there are
  1460. three of them:
  1461. @table @code
  1462. @item REG_DEAD
  1463. The @samp{reg} listed dies in this insn; that is to say, altering
  1464. the value immediately after this insn would not affect the future
  1465. behavior of the program.
  1466. @item REG_INC
  1467. The @samp{reg} listed is incremented (or decremented; at this level
  1468. there is no distinction) by an embedded side effect inside this insn.
  1469. @item REG_CONST
  1470. The @samp{reg} listed has a value that could safely be replaced
  1471. everywhere by the value that this insn copies into it. (``Safety''
  1472. here refers to the data flow of the program; such replacement may
  1473. require reloading into registers for some of the insns in which
  1474. the @samp{reg} is replaced.)
  1475. @item REG_WAS_0
  1476. The @samp{reg} listed contained zero before this insn. You can rely
  1477. on this note if it is present; its absence implies nothing.
  1478. @end table
  1479. (The only difference between the expression codes @samp{insn_list} and
  1480. @samp{expr_list} is that the first operand of an @samp{insn_list} is
  1481. assumed to be an insn and is printed in debugging dumps as the insn's
  1482. unique id; the first operand of an @samp{expr_list} is printed in the
  1483. ordinary way as an expression.)
  1484. @node Sharing,, Insns, RTL
  1485. @section Structure Sharing Assumptions
  1486. The compiler assumes that certain kinds of RTL expressions are unique;
  1487. there do not exist two distinct objects representing the same value.
  1488. In other cases, it makes an opposite assumption: that no RTL expression
  1489. object of a certain kind appears in more than one place in the
  1490. containing structure.
  1491. These assumptions refer to a single function; except for the RTL
  1492. objects that describe global variables and external functions,
  1493. no RTL objects are common to two functions.
  1494. @itemize @bullet
  1495. @item
  1496. Each pseudo-register has only a single @samp{reg} object to represent it,
  1497. and therefore only a single machine mode.
  1498. @item
  1499. For any symbolic label, there is only one @samp{symbol_ref} object
  1500. referring to it.
  1501. @item
  1502. There is only one @samp{const_int} expression with value zero,
  1503. and only one with value one.
  1504. @item
  1505. There is only one @samp{pc} expression.
  1506. @item
  1507. There is only one @samp{cc0} expression.
  1508. @item
  1509. There is only one @samp{const_double} expression with mode
  1510. @code{SFmode} and value zero, and only one with mode @code{DFmode} and
  1511. value zero.
  1512. @item
  1513. No @samp{label_ref} appears in more than one place in the RTL structure;
  1514. in other words, it is safe to do a tree-walk of all the insns in the function
  1515. and assume that each time a @samp{label_ref} is seen it is distinct from all
  1516. other @samp{label_refs} seen.
  1517. @item
  1518. Aside from the cases listed above, the only kind of expression
  1519. object that may appear in more than one place is the @samp{mem}
  1520. object that describes a stack slot or a static variable.
  1521. @end itemize
  1522. @node Machine Desc, Machine Macros, RTL, Top
  1523. @chapter Machine Descriptions
  1524. A machine description has two parts: a file of instruction patterns
  1525. (@file{.md} file) and a C header file of macro definitions.
  1526. The @file{.md} file for a target machine contains a pattern for each
  1527. instruction that the target machine supports (or at least each instruction
  1528. that is worth telling the compiler about). It may also contain comments.
  1529. A semicolon causes the rest of the line to be a comment, unless the semicolon
  1530. is inside a quoted string.
  1531. See the next chapter for information on the C header file.
  1532. @menu
  1533. * Patterns:: How to write instruction patterns.
  1534. * Example:: Example of an instruction pattern.
  1535. * Constraints:: When not all operands are general operands.
  1536. * Standard Names:: Names mark patterns to use for code generation.
  1537. * Dependent Patterns:: Having one pattern may make you need another.
  1538. @end menu
  1539. @node Patterns, Example, Machine Desc, Machine Desc
  1540. @section Instruction Patterns
  1541. Each instruction pattern contains an incomplete RTL expression, with pieces
  1542. to be filled in later, operand constraints that restrict how the pieces can
  1543. be filled in, and an output pattern or C code to generate the assembler
  1544. output, all wrapped up in a @samp{define_insn} expression.
  1545. Sometimes an insn can match more than one instruction pattern. Then the
  1546. pattern that appears first in the machine description is the one used.
  1547. Therefore, more specific patterns should usually go first in the
  1548. description.
  1549. The @samp{define_insn} expression contains four operands:
  1550. @enumerate
  1551. @item
  1552. An optional name. The presence of a name indicate that this instruction
  1553. pattern can perform a certain standard job for the RTL-generation
  1554. pass of the compiler. This pass knows certain names and will use
  1555. the instruction patterns with those names, if the names are defined
  1556. in the machine description.
  1557. The absence of a name is indicated by writing an empty string
  1558. where the name should go. Nameless instruction patterns are never
  1559. used for generating RTL code, but they may permit several simpler insns
  1560. to be combined later on.
  1561. Names that are not thus known and used in RTL-generation have no
  1562. effect; they are equivalent to no name at all.
  1563. @item
  1564. The recognition template. This is a vector of incomplete RTL
  1565. expressions which show what the instruction should look like. It is
  1566. incomplete because it may contain @samp{match_operand} and
  1567. @samp{match_dup} expressions that stand for operands of the
  1568. instruction.
  1569. If the vector has only one element, that element is what the
  1570. instruction should look like. If the vector has multiple elements,
  1571. then the instruction looks like a @samp{parallel} expression
  1572. containing that many elements as described.
  1573. @item
  1574. A condition. This is a string which contains a C expression that is
  1575. the final test to decide whether an insn body matches this pattern.
  1576. For a named pattern, the condition (if present) may not depend on
  1577. the data in the insn being matched, but only the target-machine-type
  1578. flags. The compiler needs to test these conditions during
  1579. initialization in order to learn exactly which named instructions are
  1580. available in a particular run.
  1581. For nameless patterns, the condition is applied only when matching an
  1582. individual insn, and only after the insn has matched the pattern's
  1583. recognition template. The insn's operands may be found in the vector
  1584. @code{operands}.
  1585. @item
  1586. A string that says how to output matching insns as assembler code. In
  1587. the simpler case, the string is an output template, much like a
  1588. @code{printf} control string. @samp{%} in the string specifies where
  1589. to insert the operands of the instruction; the @samp{%} is followed by
  1590. a single-digit operand number.
  1591. @samp{%c@var{digit}} can be used to subtitute an operand that is a
  1592. constant value without the syntax that normally indicates an immediate
  1593. operand.
  1594. @samp{%a@var{digit}} can be used to substitute an operand as if it
  1595. were a memory reference, with the actual operand treated as the address.
  1596. This may be useful when outputting a ``load address'' instruction,
  1597. because often the assembler syntax for such an instruction requires
  1598. you to write the operand as if it were a memory reference.
  1599. The template may generate multiple assembler instructions.
  1600. Write the text for the instructions, with @samp{\;} between them.
  1601. If the output control string starts with a @samp{*}, then it is not an
  1602. output template but rather a piece of C program that should compute a
  1603. template. It should execute a @code{return} statement to return the
  1604. template-string you want. Most such templates use C string literals,
  1605. which require doublequote characters to delimit them. To include
  1606. these doublequote characters in the string, prefix each one with
  1607. @samp{\}.
  1608. The operands may be found in the array @code{operands}, whose C
  1609. data type is @code{rtx []}.
  1610. It is possible to output an assembler instruction and then go on to
  1611. output or compute more of them, using the subroutine
  1612. @code{output_asm_insn}. This receives two arguments: a
  1613. template-string and a vector of operands. The vector may be
  1614. @code{operands}, or it may be another array of @code{rtx} that you
  1615. declare locally and initialize yourself.
  1616. @end enumerate
  1617. The recognition template is used also, for named patterns, for
  1618. constructing insns. Construction involves substituting specified
  1619. operands into a copy of the template. Matching involves determining
  1620. the values that serve as the operands in the insn being matched. Both
  1621. of these activities are controlled by two special expression types
  1622. that direct matching and substitution of the operands.
  1623. @table @code
  1624. @item (match_operand:@var{m} @var{n} @var{testfn} @var{constraint})
  1625. This expression is a placeholder for operand number @var{n} of
  1626. the insn. When constructing an insn, operand number @var{n}
  1627. will be substituted at this point. When matching an insn, whatever
  1628. appears at this position in the insn will be taken as operand
  1629. number @var{n}; but it must satisfy @var{testfn} or this instruction
  1630. pattern will not match at all.
  1631. Operand numbers must be chosen consecutively counting from zero in
  1632. each instruction pattern. There may be only one @samp{match_operand}
  1633. expression in the pattern for each expression number, and they must
  1634. appear in order of increasing expression number.
  1635. @var{testfn} is a string that is the name of a C function that accepts
  1636. two arguments, a machine mode and an expression. During matching,
  1637. the function will be called with @var{m} as the mode argument
  1638. and the putative operand as the other argument. If it returns zero,
  1639. this instruction pattern fails to match. @var{testfn} may be
  1640. an empty string; then it means no test is to be done on the operand.
  1641. Most often, @var{testfn} is @code{"general_operand"}. It checks
  1642. that the putative operand is either a constant, a register or a
  1643. memory reference, and that it is valid for mode @var{m}.
  1644. @var{constraint} is explained later.
  1645. @item (match_dup @var{n})
  1646. This expression is also a placeholder for operand number @var{n}.
  1647. It is used when the operand needs to appear more than once in the
  1648. insn.
  1649. In construction, @samp{match_dup} behaves exactly like
  1650. @var{match_operand}: the operand is substituted into the insn being
  1651. constructed. But in matching, @samp{match_dup} behaves differently.
  1652. It assumes that operand number @var{n} has already been determined by
  1653. a @samp{match_operand} apparing earlier in the recognition template,
  1654. and it matches only an identical-looking expression.
  1655. @item (address (match_operand:@var{m} @var{n} "address_operand" ""))
  1656. This complex of expressions is a placeholder for an operand number
  1657. @var{n} in a ``load address'' instruction: an operand which specifies
  1658. a memory location in the usual way, but for which the actual operand
  1659. value used is the address of the location, not the contents of the
  1660. location.
  1661. @samp{address} expressions never appear in RTL code, only in machine
  1662. descriptions. And they are used only in machine descriptions that do
  1663. not use the operand constraint feature. When operand constraints are
  1664. in use, the letter @samp{p} in the constraint serves this purpose.
  1665. @var{m} is the machine mode of the @emph{memory location being
  1666. addressed}, not the machine mode of the address itself. That mode is
  1667. always the same on a given target machine (it is @code{Pmode}, which
  1668. normally is @code{SImode}), so there is no point in mentioning it;
  1669. thus, no machine mode is written in the @samp{address} expression. If
  1670. some day support is added for machines in which addresses of different
  1671. kinds of objects appear differently or are used differently (such as
  1672. the PDP-10), different formats would perhaps need different machine
  1673. modes and these modes might be written in the @samp{address}
  1674. expression.
  1675. @end table
  1676. @node Example, Constraints, Patterns, Machine Desc
  1677. @section Example of @samp{define_insn}
  1678. Here is an actual example of an instruction pattern, for the 68000/68020.
  1679. @example
  1680. (define_insn "tstsi"
  1681. [(set (cc0)
  1682. (match_operand:SI 0 "general_operand" "rm"))]
  1683. ""
  1684. "*
  1685. @{ if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  1686. return \"tstl %0\";
  1687. return \"cmpl #0,%0\"; @}")
  1688. @end example
  1689. This is an instruction that sets the condition codes based on the value of
  1690. a general operand. It has no condition, so any insn whose RTL description
  1691. has the form shown may be handled according to this pattern. The name
  1692. @samp{tstsi} means ``test a @code{SImode} value'' and tells the RTL generation
  1693. pass that, when it is necessary to test such a value, an insn to do so
  1694. can be constructed using this pattern.
  1695. The output control string is a piece of C code which chooses which
  1696. output template to return based on the kind of operand and the specific
  1697. type of CPU for which code is being generated.
  1698. @samp{"rm"} is an operand constraint. Its meaning is explained below.
  1699. @node Constraints, Standard Names, Example, Machine Desc
  1700. @section Operand Constraints
  1701. Each @samp{match_operand} in an instruction pattern can specify a
  1702. constraint for the type of operands allowed. Constraints can say whether
  1703. an operand may be in a register, and which kinds of register; whether the
  1704. operand can be a memory reference, and which kinds of address; whether the
  1705. operand may be an immediate constant, and which possible values it may
  1706. have. Constraints can also require two operands to match.
  1707. @menu
  1708. * Simple Constraints:: Basic use of constraints.
  1709. * Multi-alternative:: When an insn has two alternative constraint-patterns.
  1710. * Class Preferences:: Constraints guide which hard register to put things in.
  1711. * Modifiers:: More precise control over effects of constraints.
  1712. * No Constraints:: Describing a clean machine without constraints.
  1713. @end menu
  1714. @node Simple Constraints, Multi-Alternative, Constraints, Constraints
  1715. @subsection Simple Constraints
  1716. The simplest kind of constraint is a string full of letters, each of
  1717. which describes one kind of operand that is permitted. Here are
  1718. the letters that are allowed:
  1719. @table @samp
  1720. @item m
  1721. A memory operand is allowed, with any kind of address that the machine
  1722. supports in general.
  1723. @item o
  1724. A memory operand is allowed, but only if the address is @dfn{offsetable}.
  1725. This means that adding a small integer (actually, the width in bytes of the
  1726. operand, as determined by its machine mode) may be added to the address
  1727. and the result is also a valid memory address. For example, an address
  1728. which is constant is offsetable; so is an address that is the sum of
  1729. a register and a constant (as long as a slightly larger constant is also
  1730. within the range of address-offsets supported by the machine); but an
  1731. autoincrement or autodecrement address is not offsetable. More complicated
  1732. indirect/indexed addresses may or may not be offsetable depending on the
  1733. other addressing modes that the machine supports.
  1734. @item <
  1735. A memory operand with autodecrement addressing (either predecrement or
  1736. postdecrement) is allowed.
  1737. @item >
  1738. A memory operand with autoincrement addressing (either preincrement or
  1739. postincrement) is allowed.
  1740. @item r
  1741. A register operand is allowed provided that it is in a general register.
  1742. @item d
  1743. @itemx a
  1744. @itemx f
  1745. @itemx @dots{}
  1746. Other letters can be defined in machine-dependent fashion to stand for
  1747. particular classes of registers. @samp{d}, @samp{a} and @samp{f} are
  1748. defined on the 68000/68020 to stand for data, address and floating point
  1749. registers.
  1750. @item i
  1751. An immediate integer operand (one with constant value) is allowed.
  1752. @item I
  1753. @item J
  1754. @item K
  1755. @itemx @dots{}
  1756. Other letters in the range @samp{I} through @samp{M} may be defined in a
  1757. machine-dependent fashion to permit immediate integer operands with
  1758. explicit integer values in specified ranges. For example, on the 68000,
  1759. @samp{I} is defined to stand for the range of values 1 to 8. This is the
  1760. range permitted as a shift count in the shift instructions.
  1761. @item F
  1762. An immediate floating operand (expression code @samp{const_double}) is
  1763. allowed.
  1764. @item G
  1765. @itemx H
  1766. @samp{G} and @samp{H} may be defined in a machine-dependent fashion to
  1767. permit immediate floating operands in particular ranges of values.
  1768. @item s
  1769. An immediate integer operand whose value is not an explicit integer is
  1770. allowed. This might appear strange; if an insn allows a constant operand
  1771. with a value not known at compile time, it certainly must allow any known
  1772. value. So why use @samp{s} instead of @samp{i}? Sometimes it allows
  1773. better code to be generated. For example, on the 68000 in a fullword
  1774. instruction it is possible to use an immediate operand; but if the
  1775. immediate value is between -32 and 31, better code results from loading the
  1776. value into a register and using the register. This is because the load
  1777. into the register can be done with a @samp{moveq} instruction. We arrange
  1778. for this to happen by defining the letter @samp{K} to mean ``any integer
  1779. outside the range -32 to 31'', and then specifying @samp{Ks} in the operand
  1780. constraints.
  1781. @item g
  1782. Any register, memory or immediate integer operand is allowed, except for
  1783. registers that are not general registers.
  1784. @item @r{@var{n}, a digit}
  1785. An operand identical to operand number @var{n} is allowed.
  1786. If a digit is used together with letters, the digit should come last.
  1787. @item p
  1788. An operand that is a valid memory address is allowed. This is
  1789. for ``load address'' and ``push address'' instructions.
  1790. If @samp{p} is used in the constraint, the test-function in the
  1791. @samp{match_operand} must be @code{address_operand}.
  1792. @end table
  1793. In order to have valid assembler code, each operand must satisfy
  1794. its constraint. But a failure to do so does not prevent the pattern
  1795. from applying to an insn. Instead, it directs the compiler to modify
  1796. the code such that the constraint will be satisfied. Usually this is
  1797. done by copying an operand into a register.
  1798. Contrast, therefore, the two instruction patterns that follow:
  1799. @example
  1800. (define_insn ""
  1801. [(set (match_operand:SI 0 "general_operand" "r")
  1802. (plus:SI (match_dup 0)
  1803. (match_operand:SI 1 "general_operand" "r")))]
  1804. ""
  1805. "@dots{}")
  1806. @end example
  1807. @noindent
  1808. which has two operands, one of which must appear in two places, and
  1809. @example
  1810. (define_insn ""
  1811. [(set (match_operand:SI 0 "general_operand" "r")
  1812. (plus:SI (match_operand:SI 1 "general_operand" "0")
  1813. (match_operand:SI 2 "general_operand" "r")))]
  1814. ""
  1815. "@dots{}")
  1816. @end example
  1817. @noindent
  1818. which has three operands, two of which are required by a constraint to be
  1819. identical. If we are considering an insn of the form
  1820. @example
  1821. (insn @var{n} @var{prev} @var{next}
  1822. (set (reg:SI 3)
  1823. (plus:SI (reg:SI 6) (reg:SI 109)))
  1824. @dots{})
  1825. @end example
  1826. @noindent
  1827. the first pattern would not apply at all, because this insn does not
  1828. contain two identical subexpressions in the right place. The pattern would
  1829. say, ``That does not look like an add instruction; try other patterns.''
  1830. The second pattern would say, ``Yes, that's an add instruction, but there
  1831. is something wrong with it.'' It would direct the reload pass of the
  1832. compiler to generate additional insns to make the constraint true. The
  1833. results might look like this:
  1834. @example
  1835. (insn @var{n2} @var{prev} @var{n}
  1836. (set (reg:SI 3) (reg:SI 6))
  1837. @dots{})
  1838. (insn @var{n} @var{n2} @var{next}
  1839. (set (reg:SI 3)
  1840. (plus:SI (reg:SI 3) (reg:SI 109)))
  1841. @dots{})
  1842. @end example
  1843. Because insns that don't fit the constraints are fixed up by loading
  1844. operands into registers, every instruction pattern's constraints must
  1845. permit the case where all the operands are in registers. It need not
  1846. permit all classes of registers; the compiler knows how to copy registers
  1847. into other registers of the proper class in order to make an instruction
  1848. valid. But if no registers are permitted, the compiler will be stymied: it
  1849. does not know how to save a register in memory in order to make an
  1850. instruction valid. Instruction patterns that reject registers can be
  1851. made valid by attaching a condition-expression that refuses to match
  1852. an insn at all if the crucial operand is a register.
  1853. @node Multi-Alternative, Class Preferences, Simple Constraints, Constraints
  1854. @subsection Multiple Alternative Constraints
  1855. Sometimes a single instruction has multiple alternative sets of possible
  1856. operands. For example, on the 68000, a logical-or instruction can combine
  1857. register or an immediate value into memory, or it can combine any kind of
  1858. operand into a register; but it cannot combine one memory location into
  1859. another.
  1860. These constraints are represented as multiple alternatives. An alternative
  1861. can be described by a series of letters for each operand. The overall
  1862. constraint for an operand is made from the letters for this operand
  1863. from the first alternative, a comma, the letters for this operand from
  1864. the second alternative, a comma, and so on until the last alternative.
  1865. Here is how it is done for fullword logical-or on the 68000:
  1866. @example
  1867. (define_insn "iorsi3"
  1868. [(set (match_operand:SI 0 "general_operand" "=%m,d")
  1869. (ior:SI (match_operand:SI 1 "general_operand" "0,0")
  1870. (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  1871. @dots{})
  1872. @end example
  1873. The first alternative has @samp{m} (memory) for operand 0, @samp{0} for
  1874. operand 1 (meaning it must match operand 0), and @samp{dKs} for operand 2.
  1875. The second alternative has @samp{d} (data register) for operand 0, @samp{0}
  1876. for operand 1, and @samp{dmKs} for operand 2. The @samp{=} and @samp{%} in
  1877. the constraint for operand 0 are not part of any alternative; their meaning
  1878. is explained in the next section.
  1879. If all the operands fit any one alternative, the instruction is valid.
  1880. Otherwise, for each alternative, the compiler counts how many instructions
  1881. must be added to copy the operands so that that alternative applies.
  1882. The alternative requiring the least copying is chosen. If two alternatives
  1883. need the same amount of copying, the one that comes first is chosen.
  1884. These choices can be altered with the @samp{?} and @samp{!} characters:
  1885. @table @samp
  1886. @item ?
  1887. Disparage slightly the alternative that the @samp{?} appears in,
  1888. as a choice when no alternative applies exactly. The compiler regards
  1889. this alternative as one unit more costly for each @samp{?} that appears
  1890. in it.
  1891. @item !
  1892. Disparage severely the alternative that the @samp{!} appears in.
  1893. When operands must be copied into registers, the compiler will
  1894. never choose this alternative as the one to strive for.
  1895. @end table
  1896. @node Class Preferences, Modifiers, Multi-Alternative, Constraints
  1897. @subsection Register Class Preferences
  1898. The operand constraints have another function: they enable the compiler
  1899. to decide which kind of hardware register a pseudo register is best
  1900. allocated to. The compiler examines the constraints that apply to the
  1901. insns that use the pseudo register, looking for the machine-dependent
  1902. letters such as @samp{d} and @samp{a} that specify classes of registers.
  1903. The pseudo register is put in whichever class gets the most ``votes''.
  1904. The constraint letters @samp{g} and @samp{r} also vote: they vote in
  1905. favor of a general register. The machine description says which registers
  1906. are considered general.
  1907. Of course, on some machines all registers are equivalent, and no register
  1908. classes are defined. Then none of this complexity is relevant.
  1909. @node Modifiers, No Constraints, Class Preferences, Constraints
  1910. @subsection Constraint Modifier Characters
  1911. @table @samp
  1912. @item =
  1913. Means that this operand is written by the instruction, but its previous
  1914. value is not used.
  1915. @item +
  1916. Means that this operand is both read and written by the instruction.
  1917. When the compiler fixes up the operands to satisfy the constraints,
  1918. it needs to know which operands are inputs to the instruction and
  1919. which are outputs from it. @samp{=} identifies an output; @samp{+}
  1920. identifies an operand that is both input and output; all other operands
  1921. are assumed to be input only.
  1922. @item %
  1923. Declares the instruction to be commutative for operands 1 and 2.
  1924. This means that the compiler may interchange operands 1 and 2
  1925. if that will make the operands fit their constraints.
  1926. @item #
  1927. Says that all following characters, up to the next comma, are to be ignored
  1928. as a constraint. They are significant only for choosing register preferences.
  1929. @item *
  1930. Says that the following character should be ignored when choosing
  1931. register preferences. @samp{*} has no effect on the meaning of
  1932. the constraint as a constraint.
  1933. @end table
  1934. @node No Constraints,, Modifiers, Constraints
  1935. @subsection Not Using Constraints
  1936. Some machines are so clean that operand constraints are not required. For
  1937. example, on the Vax, an operand valid in one context is valid in any other
  1938. context. On such a machine, every operand constraint would be @samp{"g"},
  1939. excepting only operands of ``load address'' instructions which are
  1940. written as if they referred to a memory location's contents but actual
  1941. refer to its address. They would have constraint @samp{"p"}.
  1942. For such machines, instead of writing @samp{"g"} and @samp{"p"} for all
  1943. the constraints, you can choose to write a description with empty constraints.
  1944. Then you write @samp{""} for the constraint in every @samp{match_operand}.
  1945. Address operands are identified by writing an @samp{address} expression
  1946. around the @samp{match_operand}, not by their constraints.
  1947. When the machine description has just empty constraints, certain parts
  1948. of compilation are skipped, making the compiler faster.
  1949. @node Standard Names, Dependent Patterns, Constraints, Machine Desc
  1950. @section Standard Insn Names
  1951. Here is a table of the instruction names that are meaningful in the RTL
  1952. generation pass of the compiler. Giving one of these names to an
  1953. instruction pattern tells the RTL generation pass that it can use the
  1954. pattern in to accomplish a certain task.
  1955. @table @samp
  1956. @item mov@var{m}
  1957. Here @var{m} is a two-letter machine mode name, in lower case. This
  1958. instruction pattern moves data with that machine mode from operand 1 to
  1959. operand 0. For example, @samp{movsi} moves full-word data.
  1960. If operand 0 is a @samp{subreg} with mode @var{m} of a register whose
  1961. natural mode is wider than @var{m}, the effect of this instruction is
  1962. to store the specified value in the part of the register that corresponds
  1963. to mode @var{m}. The effect on the rest of the register is undefined.
  1964. @item movstrict@var{m}
  1965. Like @samp{mov@var{m}} except that if operand 0 is a @samp{subreg}
  1966. with mode @var{m} of a register whose natural mode is wider,
  1967. the @samp{movstrict@var{m}} instruction is guaranteed not to alter
  1968. any of the register except the part which belongs to mode @var{m}.
  1969. @item add@var{m}3
  1970. Add operand 2 and operand 1, storing the result in operand 0. All operands
  1971. must have mode @var{m}. This can be used even on two-address machines, by
  1972. means of constraints requiring operands 1 and 0 to be the same location.
  1973. @item sub@var{m}3
  1974. @itemx mul@var{m}3
  1975. @itemx umul@var{m}3
  1976. @itemx div@var{m}3
  1977. @itemx udiv@var{m}3
  1978. @itemx mod@var{m}3
  1979. @itemx umod@var{m}3
  1980. @itemx and@var{m}3
  1981. @itemx ior@var{m}3
  1982. @itemx xor@var{m}3
  1983. Similar, for other arithmetic operations.
  1984. @item andcb@var{m}3
  1985. Bitwise logical-and operand 1 with the complement of operand 2
  1986. and store the result in operand 0.
  1987. @item mulhisi3
  1988. Multiply operands 1 and 2, which have mode @code{HImode}, and store
  1989. a @code{SImode} product in operand 0.
  1990. @item mulqihi3
  1991. @itemx mulsidi3
  1992. Similar widening-multiplication instructions of other widths.
  1993. @item umulqihi3
  1994. @item umulhisi3
  1995. @item umulsidi3
  1996. Similar widening-multiplication instructions that do unsigned
  1997. multiplication.
  1998. @item divmod@var{m}4
  1999. Signed division that produces both a quotient and a remainder.
  2000. Operand 1 is divided by operand 2 to produce a quotient stored
  2001. in operand 0 and a remainder stored in operand 3.
  2002. @item udivmod@var{m}4
  2003. Similar, but does unsigned division.
  2004. @item divmod@var{m}@var{n}4
  2005. Like @samp{divmod@var{m}4} except that only the dividend has mode
  2006. @var{m}; the divisor, quotient and remainder have mode @var{n}.
  2007. For example, the Vax has a @samp{divmoddisi4} instruction
  2008. (but it is omitted from the machine description, because it
  2009. is so slow that it is faster to compute remainders by the
  2010. circumlocution that the compiler will use if this instruction is
  2011. not available).
  2012. @item ashl@var{m}3
  2013. Arithmetic-shift operand 1 left by a number of bits specified by
  2014. operand 2, and store the result in operand 0. Operand 2 has
  2015. mode @code{SImode}, not mode @var{m}.
  2016. @item ashr@var{m}3
  2017. @itemx lshl@var{m}3
  2018. @itemx lshr@var{m}3
  2019. @itemx rotl@var{m}3
  2020. @itemx rotr@var{m}3
  2021. Other shift and rotate instructions.
  2022. @item neg@var{m}2
  2023. Negate operand 1 and store the result in operand 0.
  2024. @item abs@var{m}2
  2025. Store the absolute value of operand 1 into operand 0.
  2026. @item sqrt@var{m}2
  2027. Store the square root of operand 1 into operand 0.
  2028. @item one_cmpl@var{m}2
  2029. Store the bitwise-complement of operand 1 into operand 0.
  2030. @item cmp@var{m}
  2031. Compare operand 0 and operand 1, and set the condition codes.
  2032. @item tst@var{m}
  2033. Compare operand 0 against zero, and set the condition codes.
  2034. @item movstr@var{m}
  2035. Block move instruction. The addresses of the destination and source
  2036. strings are the first two operands, and both are in mode @code{Pmode}.
  2037. The number of bytes to move is the third operand, in mode @var{m}.
  2038. @item cmpstr@var{m}
  2039. Block compare instruction, with operands like @samp{movstr@var{m}}
  2040. except that the two memory blocks are compared byte by byte
  2041. in lexicographic order. The effect of the instruction is to set
  2042. the condition codes.
  2043. @item float@var{m}@var{n}2
  2044. Convert operand 1 (valid for floating point mode @var{m}) to fixed
  2045. point mode @var{n} and store in operand 0 (which has mode @var{n}).
  2046. @item fix@var{m}@var{n}2
  2047. Convert operand 1 (valid for fixed point mode @var{m}) to floating
  2048. point mode @var{n} and store in operand 0 (which has mode @var{n}).
  2049. @item trunc@var{m}@var{n}
  2050. Truncate operand 1 (valid for mode @var{m}) to mode @var{n} and
  2051. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  2052. point or both floating point.
  2053. @item extend@var{m}@var{n}
  2054. Sign-extend operand 1 (valid for mode @var{m}) to mode @var{n} and
  2055. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  2056. point or both floating point.
  2057. @item zero_extend@var{m}@var{n}
  2058. Zero-extend operand 1 (valid for mode @var{m}) to mode @var{n} and
  2059. store in operand 0 (which has mode @var{n}). Both modes must be fixed
  2060. point.
  2061. @item extv
  2062. Extract a bit-field from operand 1 (a register or memory operand),
  2063. where operand 2 specifies the width in bits and operand 3 the starting
  2064. bit, and store it in operand 0. Operand 0 must have @code{Simode}.
  2065. Operand 1 may have mode @code{QImode} or @code{SImode}; often
  2066. @code{SImode} is allowed only for registers. Operands 2 and 3 must be
  2067. valid for @code{SImode}.
  2068. The RTL generation pass generates this instruction only with constants
  2069. for operands 2 and 3.
  2070. The bit-field value is sign-extended to a full word integer
  2071. before it is stored in operand 0.
  2072. @item extzv
  2073. Like @samp{extv} except that the bit-field value is zero-extended.
  2074. @item insv
  2075. Store operand 3 (which must be valid for @code{SImode}) into a
  2076. bit-field in operand 0, where operand 1 specifies the width in bits
  2077. and operand 2 the starting bit. Operand 0 may have mode @code{QImode}
  2078. or @code{SImode}; often @code{SImode} is allowed only for registers.
  2079. Operands 1 and 2 must be valid for @code{SImode}.
  2080. The RTL generation pass generates this instruction only with constants
  2081. for operands 1 and 2.
  2082. @item s@var{cond}@var{m}
  2083. Store zero or -1 in the operand (with mode @var{m}) according to the
  2084. condition codes. Value stored is -1 iff the condition @var{cond} is
  2085. true. @var{cond} is the name of a comparison operation rtx code, such
  2086. as @samp{eq}, @samp{lt} or @samp{leu}.
  2087. @item b@var{cond}
  2088. Conditional branch instruction. Operand 0 is a @samp{label_ref}
  2089. that refers to the label to jump to. Jump if the condition codes
  2090. meet condition @var{cond}.
  2091. @item call
  2092. Subroutine call instruction. Operand 1 is the number of arguments
  2093. and operand 0 is the function to call. Operand 1 should be a @samp{mem}
  2094. rtx whose address is the address of the function.
  2095. @item return
  2096. Subroutine return instruction. This instruction pattern name should be
  2097. defined only if a single instruction can do all the work of returning
  2098. from a function.
  2099. @item tablejump
  2100. @item case@var{m}
  2101. @end table
  2102. @node Dependent Patterns,, Standard Names, Machine Desc
  2103. @section Patterns Require Other Patterns
  2104. Every machine description must have a named pattern for each of the
  2105. conditional branch names @samp{b@var{cond}}. The recognition template
  2106. must always have the form
  2107. @example
  2108. (set (pc)
  2109. (if_then_else (@var{cond} (cc0) (const_int 0))
  2110. (label_ref (match_operand 0 "" ""))
  2111. (pc)))
  2112. @end example
  2113. @noindent
  2114. In addition, every machine description must have an anonymous pattern
  2115. for each of the possible reverse-conditional branches. These patterns
  2116. look like
  2117. @example
  2118. (set (pc)
  2119. (if_then_else (@var{cond} (cc0) (const_int 0))
  2120. (pc)
  2121. (label_ref (match_operand 0 "" ""))))
  2122. @end example
  2123. @noindent
  2124. They are necessary because jump optimization can turn direct-conditional
  2125. branches into reverse-conditional branches.
  2126. The compiler does more with RTL than just create it from patterns
  2127. and recognize the patterns: it can perform arithmetic expression codes
  2128. when constant values for their operands can be determined. As a result,
  2129. sometimes having one pattern can require other patterns. For example, the
  2130. Vax has no `and' instruction, but it has `and not' instructions. Here
  2131. is the definition of one of them:
  2132. @example
  2133. (define_insn "andcbsi2"
  2134. [(set (match_operand:SI 0 "general_operand" "")
  2135. (and:SI (match_dup 0)
  2136. (not:SI (match_operand:SI
  2137. 1 "general_operand" ""))))]
  2138. ""
  2139. "bicl2 %1,%0")
  2140. @end example
  2141. @noindent
  2142. If operand 1 is an explicit integer constant, an instruction constructed
  2143. using that pattern can end up looking like
  2144. @example
  2145. (set (reg:SI 41)
  2146. (and:SI (reg:SI 41)
  2147. (const_int 0xffff7fff)))
  2148. @end example
  2149. @noindent
  2150. (where the integer constant is the one's complement of what
  2151. appeared in the original instruction).
  2152. To avoid a fatal error, the compiler must have a pattern that recognizes
  2153. such an instruction. Here is what is used:
  2154. @example
  2155. (define_insn ""
  2156. [(set (match_operand:SI 0 "general_operand" "")
  2157. (and:SI (match_dup 0)
  2158. (match_operand:SI 1 "general_operand" "")))]
  2159. "GET_CODE (operands[1]) == CONST_INT"
  2160. "*
  2161. { operands[1]
  2162. = gen_rtx (CONST_INT, VOIDmode, ~INTVAL (operands[1]));
  2163. return \"bicl2 %1,%0\";
  2164. }")
  2165. @end example
  2166. @noindent
  2167. Whereas a pattern to match a general `and' instruction is impossible to
  2168. support on the Vax, this pattern is possible because it matches only a
  2169. constant second argument: a special case that can be output as an `and not'
  2170. instruction.
  2171. @node Machine Macros,, Machine Desc, Top
  2172. @chapter Machine Description Macros
  2173. The other half of the machine description is a C header file conventionally
  2174. given the name @file{tm-@var{machine}.h}. The file @file{tm.h} should be a
  2175. link to it. The header file @file{config.h} includes @file{tm.h} and most
  2176. compiler source files include @file{config.h}.
  2177. @menu
  2178. * Run-time Target:: Defining -m switches like -m68000 and -m68020.
  2179. * Storage Layout:: Defining sizes and alignments of data types.
  2180. * Registers:: Naming and describing the hardware registers.
  2181. * Register Classes:: Defining the classes of hardware registers.
  2182. * Stack Layout:: Defining which way the stack grows and by how much.
  2183. * Addressing Modes:: Defining addressing modes valid for memory operands.
  2184. * Condition Code:: Defining how insns update the condition code.
  2185. * Assembler Format:: Defining how to write insns and pseudo-ops to output.
  2186. * Misc:: Everything else.
  2187. @end menu
  2188. @node Run-time Target, Storage Layout, Machine Macros, Machine Macros
  2189. @section Run-time Target Specification
  2190. @table @code
  2191. @item CPP_PREDEFINES
  2192. Define this to be a string constant containing @samp{-D} switches
  2193. to define the predefined macros that identify this machine and system.
  2194. For example, on the Sun, one can use the value
  2195. @example
  2196. "-Dmc68000 -Dsun"
  2197. @end example
  2198. @item extern int target_flags;
  2199. This declaration should be present.
  2200. @item TARGET_@dots{}
  2201. This series of macros is to allow compiler command arguments to
  2202. enable or disable the use of optional features of the target machine.
  2203. For example, one machine description serves both the 68000 and
  2204. the 68020; a command argument tells the compiler whether it should
  2205. use 68020-only instructions or not. This command argument works
  2206. by means of a macro @code{TARGET_68020} that tests a bit in
  2207. @code{target_flags}.
  2208. Define a macro @code{TARGET_@var{featurename}} for each such option.
  2209. Its definition should test a bit in @code{target_flags}; for example:
  2210. @example
  2211. #define TARGET_68020 (target_flags & 1)
  2212. @end example
  2213. One place where these macros are used is in the condition-expressions
  2214. of instruction patterns. Note how @code{TARGET_68020} appears
  2215. frequently in the 68000 machine description file, @file{m68000.md}.
  2216. Another place they are used is in the definitions of the other
  2217. macros in the @file{tm-@var{machine}.h} file.
  2218. @item TARGET_SWITCHES
  2219. This macro defines names of command switches to set and clear
  2220. bits in @code{target_flags}. Its definition is an initializer
  2221. with a subgrouping for each command switches.
  2222. Each subgrouping contains a string constant, that defines the switch
  2223. name, and a number, which contains the bits to set in
  2224. @code{target_flags}. A negative number says to clear bits instead;
  2225. the negative of the number is which bits to clear. The actual switch
  2226. name is made by appending @samp{-m} to the specified name.
  2227. One of the subgroupings should have a null string. The number in
  2228. this grouping is the default value for @code{target_flags}. Any
  2229. target switches act starting with that value.
  2230. Here is an example which defines @samp{-m68000} and @samp{-m68020}
  2231. with opposite meanings, and picks the latter as the default:
  2232. @example
  2233. #define TARGET_SWITCHES \
  2234. @{ @{ "68020", 1@}, \
  2235. @{ "68000", -1@}, \
  2236. @{ "", 1@}@}
  2237. @end example
  2238. @end table
  2239. @node Storage Layout, Registers, Run-time Target, Machine Macros
  2240. @section Storage Layout
  2241. @table @code
  2242. @item BITS_BIG_ENDIAN
  2243. Define this macro if the most significant bit in a byte has the lowest
  2244. number. This means that bit-field instructions count from the most
  2245. significant bit. If the machine has no bit-field instructions, this
  2246. macro is irrelevant.
  2247. @item BYTES_BIG_ENDIAN
  2248. Define this macro if the most significant byte in a word has the
  2249. lowest number.
  2250. @item WORDS_BIG_ENDIAN
  2251. Define this macro if, in a multiword object, the most signficant
  2252. word has the lowest number.
  2253. @item BITS_PER_UNIT
  2254. Number of bits in an addressable storage unit (byte); normally 8.
  2255. @item BITS_PER_WORD
  2256. Number of bits in a word; normally 32.
  2257. @item UNITS_PER_WORD
  2258. Number of storage units in a word; normally 4.
  2259. @item POINTER_SIZE
  2260. Width of a pointer, in bits.
  2261. @item PARM_BOUNDARY
  2262. Alignment required for pointers, in bits.
  2263. @item FUNCTION_BOUNDARY
  2264. Alignment required for a function entry point, in bits.
  2265. @item BIGGEST_ALIGNMENT
  2266. Biggest alignment that anything can require on this machine, in bits.
  2267. @item STRICT_ALIGNMENT
  2268. Define this if instructions will fail to work if given data not
  2269. on the nominal alignment. If instructions will merely go slower
  2270. in that case, do not define this macro.
  2271. @end table
  2272. @node Registers, Register Classes, Storage Layout, Machine Macros
  2273. @section Register Usage
  2274. @table @code
  2275. @item FIRST_PSEUDO_REGISTER
  2276. Number of hardware registers known to the compiler. They receive
  2277. numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
  2278. pseudo register's number really is assigned the number7
  2279. @code{FIRST_PSEUDO_REGISTER}.
  2280. @item FIXED_REGISTERS
  2281. An initializer that says which registers are used for fixed purposes
  2282. all throughout the compiled code and are therefore not available for
  2283. general allocation. These would inclue the stack pointer, the frame
  2284. pointer, the program counter on machines where that is considered one
  2285. of the addressable registers, and any other numbered register with a
  2286. standard use.
  2287. This information is expressed as a sequence of numbers, separated by
  2288. commas and surrounded by braces. The @var{n}th number is 1 if
  2289. register @var{n} is fixed, 0 otherwise
  2290. @item CALL_USED_REGISTERS
  2291. Like @code{FIXED_REGISTERS} but has 1 for each register that is
  2292. clobbered (in general) by function calls as well as for fixed
  2293. registers. This macro therefore identifies the registers that are not
  2294. available for general allocation of values that must live across
  2295. function calls.
  2296. If a registers has 0 in @code{CALL_USED_REGISTERS}, the compiler
  2297. automatically saves it on function entry and restores it on function
  2298. exit, if the register is used within the function.
  2299. @item HARD_REGNO_REGS (@var{regno}, @var{mode})
  2300. A C expression for the number of consecutive hard registers, starting
  2301. at register number @var{regno}, required to hold a value of mode
  2302. @var{mode}.
  2303. On a machine where all registers are exactly one word, a suitable
  2304. definition of this macro is
  2305. @example
  2306. #define HARD_REGNO_NREGS(REGNO, MODE) \
  2307. ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
  2308. / UNITS_PER_WORD))
  2309. @end example
  2310. @item HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
  2311. A C expression that is nonzero if it is permissible to store a value
  2312. of mode @var{mode} in hard register number @var{regno} (or in several
  2313. registers starting with that one). For a machine where all registers
  2314. are equivalent, a suitable definition is
  2315. @example
  2316. #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
  2317. @end example
  2318. It is not necessary for this macro to check for fixed register numbers
  2319. because the allocation mechanism considers them to be always occupied.
  2320. @item MODES_TIEABLE_P (@var{mode1}, @var{mode2})
  2321. A C expression that is nonzero if it is desirable to choose register
  2322. allocation so as to avoid move instructions between a value of mode
  2323. @var{mode1} and a value of mode @var{mode2}.
  2324. If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
  2325. @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are ever different
  2326. for any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1},
  2327. @var{mode2})} must be zero.
  2328. @item PC_REGNUM
  2329. If the program counter has a register number, define this as that
  2330. register number. Otherwise, do not define it.
  2331. @item STACK_POINTER_REGNUM
  2332. The register number of the stack pointer register, which must also be
  2333. a fixed register according to @code{FIXED_REGISTERS}. On many
  2334. machines, the hardware determines which register this is.
  2335. @item FRAME_POINTER_REGNUM
  2336. The register number of the frame pointer register, which is used to
  2337. access automatic variables in the stack frame. It must also described
  2338. in @code{FIXED_REGISTERS} as a fixed register. On some machines, the
  2339. hardware determines which register this is. On other machines, you
  2340. can choose any register you wish for this purpose.
  2341. @item ARG_POINTER_REGNUM
  2342. The register number of the arg pointer register, which is used to
  2343. access the function's argument list. On some machines, this is the
  2344. same as the frame pointer register. On some machines, the hardware
  2345. determines which register this is. On other machines, you can choose
  2346. any register you wish for this purpose. It must in any case be a
  2347. fixed register according to @code{FIXED_REGISTERS}.
  2348. @item STATIC_CHAIN_REGNUM
  2349. The register number used for passing a function's static chain
  2350. pointer. This is needed for languages such as Pascal and Algol where
  2351. functions defined within other functions can access the local
  2352. variables of the outer functions; it is not currently used because C
  2353. does not provide this feature.
  2354. The static chain register need not be a fixed register.
  2355. @item FUNCTION_VALUE_REGNUM
  2356. The register number used for returning values from a function. This
  2357. must be one of the call-used registers (since function calls alter
  2358. it!) but should not be a fixed register. When the value being
  2359. returned has a multi-word machine mode, multiple consecutive registers
  2360. starting with the specified one are used.
  2361. @item STRUCT_VALUE_REGNUM
  2362. When a function's value's mode is @code{BLKmode}, the value is not returned
  2363. in the register @code{FUNCTION_VALUE_REGNUM}. Instead, the caller passes
  2364. the address of a block of memory in which the value should be stored.
  2365. @code{STRUCT_VALUE_REGNUM} is the register in which this address is passed.
  2366. @end table
  2367. @node Register Classes, Stack Layout, Registers, Machine Macros
  2368. @section Register Classes
  2369. On many machines, the numbered registers are not all equivalent.
  2370. For example, certain registers may not be allowed for indexed addressing;
  2371. certain registers may not be allowed in some instructions. These machine
  2372. restrictions are described to the compiler using @dfn{register classes}.
  2373. You define a number of register classes, giving each one a name and saying
  2374. which of the registers belong to it. Then you can specify register classes
  2375. that are allowed as operands to particular instruction patterns.
  2376. In general, each register will belong to several classes. In fact, one
  2377. class must be named @code{ALL_REGS} and contain all the registers. Another
  2378. class must be named @code{NO_REGS} and contain no registers. Often the
  2379. union of two classes will be another class; however, this is not required.
  2380. One of the classes must be named @code{GENERAL_REGS}. There is nothing
  2381. terribly special about the name, but the operand constraint letters
  2382. @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is
  2383. the same as @code{ALL_REGS}, just define it as a macro which expands
  2384. to @code{ALL_REGS}.
  2385. The way classes other than @code{GENERAL_REGS} are specified in operand
  2386. constraints is through machine-dependent operand constraint letters.
  2387. You can define such letters to correspond to various classes, then use
  2388. them in operand constraints.
  2389. You must also specify certain redundant information about the register
  2390. classes: for each class, which classes contain it and which ones are
  2391. contained in it; for each pair of classes, the largest class contained
  2392. in their union.
  2393. @table @code
  2394. @item enum reg_class
  2395. An enumeral type that must be defined with all the register class names
  2396. as enumeral values. @code{NO_REGS} must be first. @code{ALL_REGS}
  2397. must be the last register class, followed by one more enumeral value,
  2398. @code{LIM_REG_CLASSES}, which is not a register class but rather
  2399. tells how many classes there are.
  2400. Each register class has a number, which is the value of casting
  2401. the class name to type @code{int}. The number serves as an index
  2402. in many of the tables described below.
  2403. @item REG_CLASS_NAMES
  2404. An initializer containing the names of the register classes as C string
  2405. constants. These names are used in writing some of the debugging dumps.
  2406. @item REG_CLASS_CONTENTS
  2407. An initializer containing the contents of the register classes, as integers
  2408. which are bit masks. The @var{n}th integer specifies the contents of class
  2409. @var{n}. The way the integer @var{mask} is interpreted is that
  2410. register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
  2411. When the machine has more than 32 registers, an integer does not suffice.
  2412. Then the integers are replaced by sub-initializers, braced groupings containing
  2413. several integers. Each sub-initializer must be suitable as an initializer
  2414. for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
  2415. @item REGNO_REG_CLASS (@var{regno})
  2416. A C expression whose value is a register class containing hard register
  2417. @var{regno}. In general there is more that one such class; choose a class
  2418. which is @dfn{minimal}, meaning that no smaller class also contains the
  2419. register.
  2420. @item REG_CLASS_SUPERCLASSES
  2421. A two-level initializer that says, for each class, which classes contain
  2422. it. The @var{n}th element of the initializer is a sub-initializer for
  2423. class @var{n}; it contains the names of the othe classes that contain class
  2424. @var{n} (but not the name of class @var{n} itself), followed by
  2425. @code{LIM_REG_CLASSES} to mark the end of the element.
  2426. @item REG_CLASS_SUBCLASSES
  2427. Similar to @code{REG_CLASS_SUPERCLASSES}, except that element @var{n} lists
  2428. the classes @emph{contained in} class @var{n}, followed once again by
  2429. @code{LIM_REG_CLASSES} to mark the end of the element.
  2430. @item REG_CLASS_SUBUNION
  2431. An two-level initializer for a two-dimensional array. The element
  2432. (@var{m}, @var{n}) of this array must be a class that is ``close to''
  2433. being the union of classes @var{m} and @var{n}. If there is a class
  2434. that is exactly that union, use it; otherwise, choose some smaller
  2435. class, preferably as large as possible but certainly not containing
  2436. any register that is neither in class @var{m} nor in class @var{n}.
  2437. @item INDEX_REG_CLASS
  2438. A macro whose definition is the name of the class to which a valid index
  2439. register must belong.
  2440. @item REG_CLASS_FROM_LETTER (@var{char})
  2441. A C expression which defines the machine-dependent operand constraint
  2442. letters for register classes. If @var{char} is such a letter, the value
  2443. should be the register class corresponding to it. Otherwise, the value
  2444. should be @code{NO_REGS}.
  2445. @item REGNO_OK_FOR_CLASS_P (@var{regno}, @var{class})
  2446. A C expression which is nonzero if register number @var{regno} is a hard
  2447. register belonging to class @var{class}. The expression is always zero if
  2448. @var{regno} is a pseudo register.
  2449. @item REG_OK_FOR_CLASS_P (@var{reg}, @var{class})
  2450. A C expression which is nonzero if @var{reg} (an rtx assumed to have
  2451. code @samp{reg}) belongs to class @var{class}.
  2452. What about pseudo registers? There are two alternatives, and the machine
  2453. description header file must be able to do either one on command. If the
  2454. macro @code{REG_OK_STRICT} is defined, this macro should be defined to
  2455. reject all pseudo registers (return 0 for them). Otherwise, this macro
  2456. should be defined to accept all pseudo registers (return 1 for them).
  2457. Some source files of the compiler define @code{REG_OK_STRICT} before
  2458. including the machine description header file, while others do not,
  2459. according to the needs of that part of the compiler.
  2460. @item PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
  2461. A C expression that places additional restrictions on the register class
  2462. to use when it is necessary to copy value @var{x} into a register in class
  2463. @var{class}. The value is a register class; perhaps @var{class}, or perhaps
  2464. another, smaller class. @var{class} is always safe as a value. In fact,
  2465. the definition
  2466. @example
  2467. #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
  2468. @end example
  2469. @noindent
  2470. is always safe. However, sometimes returning a more restrictive class
  2471. makes better code. For example, on the 68000, when @var{x} is an
  2472. integer constant that is in range for a @samp{moveq} instruction,
  2473. the value of this macro is always @code{DATA_REGS} as long as
  2474. @var{class} includes the data registers. Requiring a data register
  2475. guarantees that a @samp{moveq} will be used.
  2476. @end table
  2477. Two other special macros
  2478. @table @code
  2479. @item CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
  2480. A C expression that defines the machine-dependent operand constraint letters
  2481. that specify particular ranges of integer values. If @var{c} is one
  2482. of those letters, the expression should check that @var{value}, an integer,
  2483. is in the appropriate range and return 1 if so, 0 otherwise. If @var{c} is
  2484. not one of those letters, the value should be 0 regardless of @var{value}.
  2485. @item CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
  2486. A C expression that defines the machine-dependent operand constraint
  2487. letters that specify particular ranges of floating values. If @var{c} is
  2488. one of those letters, the expression should check that @var{value}, an rtx
  2489. of code @samp{const_double}, is in the appropriate range and return 1 if
  2490. so, 0 otherwise. If @var{c} is not one of those letters, the value should
  2491. be 0 regardless of @var{value}.
  2492. @end table
  2493. @node Stack Layout, Addressing Modes, Register Classes, Machine Macros
  2494. @section Describing Stack Layout
  2495. @table @code
  2496. @item STACK_GROWS_DOWNWARD
  2497. Define this macro if pushing a word onto the stack moves the stack
  2498. pointer to a smaller address. The definition is irrelevant because the
  2499. compiler checks this macro with @code{#ifdef}.
  2500. @item FRAME_GROWS_DOWNWARD
  2501. Define this macro if the addresses of local variable slots are at negative
  2502. offsets from the frame pointer.
  2503. @item STARTING_FRAME_OFFSET
  2504. Offset from the frame pointer to the first local variable slot to be allocated.
  2505. If @code{FRAME_GROWS_DOWNWARD}, the next slot's offset is found by
  2506. subtracting the length of the first slot from @code{STARTING_FRAME_OFFSET}.
  2507. Otherwise, it is found by adding the length of the first slot to
  2508. the value @code{STARTING_FRAME_OFFSET}.
  2509. @item PUSH_ROUNDING (@var{npushed})
  2510. A C expression that is the number of bytes actually pushed onto the
  2511. stack when an instruction attempts to push @var{npushed} bytes.
  2512. On some machines, the definition
  2513. @example
  2514. #define PUSH_ROUNDING(BYTES) (BYTES)
  2515. @end example
  2516. @noindent
  2517. will suffice. But on other machines, instructions that appear
  2518. to push one byte actually push two bytes in an attempt to maintain
  2519. alignment. Then the definition should be
  2520. @example
  2521. #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
  2522. @end example
  2523. @item FIRST_PARM_OFFSET
  2524. Offset from the argument pointer register to the first argument's address.
  2525. @item RETURN_POPS_ARGS
  2526. Define this macro if returning from a function automatically pops the
  2527. function's arguments. Do not define it if the caller must pop them.
  2528. @item FUNCTION_PROLOGUE (@var{file}, @var{size})
  2529. A C compound statement that outputs the assembler code for entry to a
  2530. function. The prologue is responsible for setting up the stack frame,
  2531. initializing the frame pointer register, saving registers that must be
  2532. saved, and allocating @var{size} additional bytes of storage for the local
  2533. variables. @var{size} is an integer. @var{file} is a stdio stream to
  2534. which the assembler code should be output.
  2535. The label for the beginning of the function need not be output by this
  2536. macro. That has already been done when the macro is run.
  2537. To determine which registers to save, the macro can refer to the array
  2538. @code{regs_ever_live}: element @var{r} is nonzero if hard register @var{r}
  2539. is used anywhere within the function. This implies the function prologue
  2540. should save register @var{r}, but not if it is one of the call-used
  2541. registers.
  2542. @item FUNCTION_EPILOGUE (@var{file}, @var{size})
  2543. A C compound statement that outputs the assembler code for exit from a
  2544. function. The epilogue is responsible for restoring the saved
  2545. registers and stack pointer to their values when the function was
  2546. called, and returning control to the caller. This macro takes the
  2547. same arguments as the macro @code{FUNCTION_PROLOGUE}, and the
  2548. registers to restore are determined from @code{regs_ever_live} and
  2549. @code{CALL_USED_REGISTERS} in the same way.
  2550. On some machines, there is a single instruction that does all the work of
  2551. returning from the function. On these machines, give that instruction the
  2552. name @samp{return} and do not define the macro @code{FUNCTION_EPILOGUE} at
  2553. all.
  2554. @end table
  2555. @node Addressing Modes, Misc, Stack Layout, Machine Macros
  2556. @section Addressing Modes
  2557. @table @code
  2558. @item HAVE_POST_INCREMENT
  2559. Define this macro if the machine supports post-increment addressing.
  2560. @item HAVE_PRE_INCREMENT
  2561. @itemx HAVE_POST_DECREMENT
  2562. @itemx HAVE_PRE_DECREMENT
  2563. Similar for other kinds of addressing.
  2564. @item CONSTANT_ADDRESS_P (@var{x})
  2565. A C expression that is 1 if the rtx @var{x} is a constant whose value
  2566. is an integer. This includes integers whose values are not explicitly
  2567. known, such as @samp{symbol_ref} and @samp{label_ref} expressions
  2568. and @samp{const} arithmetic expressions.
  2569. @item MAX_REGS_PER_ADDRESS
  2570. A number, the maximum number of registers that can appear in a valid
  2571. memory address.
  2572. @item GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label})
  2573. A C compound statement with a conditional @code{goto @var{label};}
  2574. executed if @var{x} (an rtx) is a legitimate memory address on
  2575. the target machine for a memory operand of mode @var{mode}.
  2576. It usually pays to define several simpler macros to serve as
  2577. subroutines for this one. Otherwise it may be too complicated
  2578. to understand.
  2579. @item LEGITIMIZE_ADDRESS (@var{x}, @var{oldx}, @var{mode}, @var{win})
  2580. A C compound statement that attempts to replace @var{x} with a valid
  2581. memory address for an operand of mode @var{mode}. @var{win} will be
  2582. a C statement label elsewhere in the code; the macro definition
  2583. may use
  2584. @example
  2585. GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{win});
  2586. @end example
  2587. @noindent
  2588. to avoid further processing if the address has become legitimate.
  2589. @var{x} will always be the result of a call to @code{break_out_memory_refs},
  2590. and @var{oldx} will be the operand that was given to that function to produce
  2591. @var{x}.
  2592. The code generated by this macro should not alter the substructure of @var{x}.
  2593. If it transforms @var{x} into a more legitimate form, it should assign @var{x}
  2594. (which will always be a C variable) a new value.
  2595. It is not necessary for this macro to come up with a legitimate address.
  2596. The compiler has standard ways of doing so in all cases. In fact, it is
  2597. safe for this macro to do nothing. But often a machine-dependent strategy
  2598. can generate better code.
  2599. @end table
  2600. @node Misc, Condition Code, Addressing Modes, Machine Macros
  2601. @section Miscellaneous Parameters
  2602. @table @code
  2603. @item CASE_VECTOR_MODE
  2604. An alias for a machine mode name. This is the machine mode that elements
  2605. of a jump-table should have.
  2606. @item CASE_VECTOR_PC_RELATIVE
  2607. Define this macro if jump-tables should contain relative addresses.
  2608. @item IMPLICIT_FIX_EXPR
  2609. An alias for a tree code that should be used by default for conversion
  2610. of floating point values to fixed point. Normally, @code{FIX_ROUND_EXPR}
  2611. is used.
  2612. @item EASY_DIV_EXPR
  2613. An alias for a tree code that is the easiest kind of division to compile
  2614. code for in the general case. It may be @code{TRUNC_DIV_EXPR},
  2615. @code{FLOOR_DIV_EXPR}, @code{CEIL_DIV_EXPR} or @code{ROUND_DIV_EXPR}.
  2616. These differ in how they round the result to an integer.
  2617. @code{EASY_DIV_EXPR} is used when it is permissible to use any of those
  2618. kinds of division and the choice should be made on the basis of efficiency.
  2619. @item MOVE_MAX
  2620. The maximum number of bytes that a single instruction can move quickly
  2621. from memory to memory.
  2622. @item SLOW_ZERO_EXTEND
  2623. Define this macro if zero-extension (of chars or shorts to integers)
  2624. can be done faster if the destination is a register that is known to be zero.
  2625. @item SHIFT_COUNT_TRUNCATED
  2626. Define this macro if shift instructions ignore all but the lowest few
  2627. bits of the shift count. It implies that a sign-extend or zero-extend
  2628. instruction for the shift count can be omitted.
  2629. @item TRULY_NOOP_TRUNCATON (@var{outprec}, @var{inprec})
  2630. A C expression which is nonzero if on this machine it is safe to
  2631. ``convert'' an integer of @var{inprec} bits to one of @var{outprec} bits
  2632. (where @var{outprec} is smaller than @var{inprec}) by merely operating
  2633. on it as if it had only @var{inprec} bits.
  2634. On many machines, this expression can be 1.
  2635. @item Pmode
  2636. An alias for the machine mode for pointers. Normally the definition can be
  2637. @example
  2638. #define Pmode SImode
  2639. @end example
  2640. @item FUNCTION_MODE
  2641. An alias for the machine mode used for memory references to functions being
  2642. called, in @samp{call} RTL expressions. On most machines this should be
  2643. @code{QImode}.
  2644. @item CONST_COST (@var{x}, @var{code})
  2645. A part of a C @code{switch} statement that describes the relative costs of
  2646. constant RTL expressions. It must contain @code{case} labels for
  2647. expression codes @samp{const_int}, @samp{const}, @samp{symbol_ref},
  2648. @samp{label_ref} and @code{const_double}. Each case must ultimately reach
  2649. a @code{return} statement to return the relative cost of the use of that
  2650. kind of constant value in an expression. The cost may depend on the
  2651. precise value of the constant, which is available for examination in
  2652. @var{x}.
  2653. @var{code} is the expression code---redundant, since it can be obtained with
  2654. @code{GET_CODE (@var{x})}.
  2655. @end table
  2656. @node Condition Code, Assembler Format, Misc, Machine Macros
  2657. @section Condition Code Information
  2658. The file @file{conditions.h} defines a variable @code{cc_status} to
  2659. describe how the condition code was computed (in case the interpretation of
  2660. the condition code depends on the instruction that it was set by). This
  2661. variable contains the RTL expressions on which the condition code is
  2662. currently based, and several standard flags.
  2663. Sometimes additional machine-specific flags must be defined in the machine
  2664. description header file. It can also add additional machine-specific
  2665. information by defining @code{CC_STATUS_MDEP}.
  2666. @table @code
  2667. @item CC_STATUS_MDEP
  2668. A type, with which the @code{mdep} component of @code{cc_status} should
  2669. be declared. It defaults to @code{int}.
  2670. @item CC_STATUS_MDEP_INIT
  2671. A C expression for the initial value of the @code{mdep} field.
  2672. It defaults to 0.
  2673. @item NOTICE_UPDATE_CC (@var{exp})
  2674. A C compound statement to set the components of @code{cc_status}
  2675. appropriately for an insn whose body is @var{exp}. It is this
  2676. macro's responsibility to recognize insns that set the condition code
  2677. as a byproduct of other activity as well as those that explicitly
  2678. set @code{(cc0)}.
  2679. If there are insn that do not set the condition code but do alter other
  2680. machine registers, this macro must check to see whether they invalidate the
  2681. expressions that the condition code is recorded as reflecting. For
  2682. example, on the 68000, insns that store in address registers do not set the
  2683. condition code, which means that usually @code{NOTICE_UPDATE_CC} can leave
  2684. @code{cc_status} unaltered for such insns. But suppose that the previous
  2685. insn set the condition code based on location @code{a4@@(102)} and the
  2686. current insn stores a new value in @code{a4}. Although the condition code
  2687. is not changed by this, it will no longer be true that it reflects the
  2688. contents of @code{a4@@(102)}. Therefore, @code{NOTICE_UPDATE_CC} must alter
  2689. @code{cc_status} in this case to say that nothing is known about the
  2690. condition code value.
  2691. @end table
  2692. @node Assembler Format,, Condition Code, Machine Macros
  2693. @section Output of Assembler Code
  2694. @table @code
  2695. @item TEXT_SECTION_ASM_OP
  2696. A C string constant for the assembler operation that should precede
  2697. instructions and read-only data. Normally @code{".text"} is right.
  2698. @item DATA_SECTION_ASM_OP
  2699. A C string constant for the assembler operation to identify the following
  2700. data as writable initialized data. Normally @code{".data"} is right.
  2701. @item REGISTER_NAMES
  2702. A C initializer containing the assembler's names for the machine registers,
  2703. each one as a C string constant. This is what translates register numbers
  2704. in the compiler into assembler language.
  2705. @item DBX_REGISTER_NUMBER (@var{regno})
  2706. A C expression that returns the DBX register number for the compiler register
  2707. number @var{regno}. In simple cases, the value of this expression may be
  2708. @var{regno} itself. But sometimes there are some registers that the compiler
  2709. knows about and DBX does not, or vice versa. In such cases, some register
  2710. may need to have one number in the compiler and another for DBX.
  2711. @item ASM_OUTPUT_DOUBLE (@var{file}, @var{value})
  2712. A C statement to output to the stdio stream @var{file} an assembler
  2713. instruction to assemble a @code{double} constant whose value is
  2714. @var{value}. @var{value} will be a C expression of type @code{double}.
  2715. @item ASM_OUTPUT_FLOAT (@var{file}, @var{value})
  2716. A C statement to output to the stdio stream @var{file} an assembler
  2717. instruction to assemble a @code{float} constant whose value is @var{value}.
  2718. @var{value} will be a C expression of type @code{float}.
  2719. @item ASM_OUTPUT_SKIP (@var{file}, @var{nbytes})
  2720. A C statement to output to the stdio stream @var{file} an assembler
  2721. instruction to advance the location counter by @var{nbytes} bytes.
  2722. @var{nbytes} will be a C expression of type @code{int}.
  2723. @item ASM_OUTPUT_ALIGN (@var{file}, @var{power})
  2724. A C statement to output to the stdio stream @var{file} an assembler
  2725. instruction to advance the location counter to a multiple of 2 to the
  2726. @var{power} bytes. @var{power} will be a C expression of type @code{int}.
  2727. @item ASM_INT_OP
  2728. A C string constant for the assembler operation that assembles constants of
  2729. C type @code{int}. A space must follow the operation name. Normally
  2730. @code{".long@ "}.
  2731. @item ASM_SHORT_OP
  2732. @itemx ASM_CHAR_OP
  2733. Likewise, for C types @code{short} and @code{char}. Normally @code{".word@ "}
  2734. and @code{".byte@ "}.
  2735. @item TARGET_BELL
  2736. A C constant expression for the integer value for escape sequence @samp{\a}.
  2737. @item TARGET_BS
  2738. @itemx TARGET_TAB
  2739. @itemx TARGET_NEWLINE
  2740. C constant expressions for the integer values for escape sequences
  2741. @samp{\b}, @samp{\t} and @samp{\n}.
  2742. @item TARGET_VT
  2743. @itemx TARGET_FF
  2744. @itemx TARGET_CR
  2745. C constant expressions for the integer values for escape sequences
  2746. @samp{\v}, @samp{\f} and @samp{\r}.
  2747. @item PRINT_OPERAND (@var{file}, @var{x})
  2748. A C compound statement to output to stdio stream @var{file}
  2749. the assembler syntax for an instruction operand @var{x}.
  2750. @var{x} is an RTL expression.
  2751. If @var{x} is a register, this macro should print the register's name. The
  2752. names can be found in an array @code{reg_names} whose type is @code{char
  2753. *[]}. @code{reg_names} is initialized from @code{REGISTER_NAMES}.
  2754. @item PRINT_OPERAND_ADDRESS (@var{file}, @var{x})
  2755. A C compound statement to output to stdio stream @var{file} the assembler
  2756. syntax for an instruction operand that is a memory reference whose address
  2757. is @var{x}. @var{x} is an RTL expression.
  2758. @end table
  2759. @contents
  2760. @bye