emit-rtl.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  1. /* Emit RTL for the GNU C-Compiler expander.
  2. Copyright (C) 1987, 1988 Free Software Foundation, Inc.
  3. This file is part of GNU CC.
  4. GNU CC is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY. No author or distributor
  6. accepts responsibility to anyone for the consequences of using it
  7. or for whether it serves any particular purpose or works at all,
  8. unless he says so in writing. Refer to the GNU CC General Public
  9. License for full details.
  10. Everyone is granted permission to copy, modify and redistribute
  11. GNU CC, but only under the conditions described in the
  12. GNU CC General Public License. A copy of this license is
  13. supposed to have been given to you along with GNU CC so you
  14. can know your rights and responsibilities. It should be in a
  15. file named COPYING. Among other things, the copyright notice
  16. and this notice must be preserved on all copies. */
  17. /* Middle-to-low level generation of rtx code and insns.
  18. This file contains the functions `gen_rtx', `gen_reg_rtx'
  19. and `gen_label_rtx' that are the usual ways of creating rtl
  20. expressions for most purposes.
  21. It also has the functions for creating insns and linking
  22. them in the doubly-linked chain.
  23. The patterns of the insns are created by machine-dependent
  24. routines in insn-emit.c, which is generated automatically from
  25. the machine description. These routines use `gen_rtx' to make
  26. the individual rtx's of the pattern; what is machine dependent
  27. is the kind of rtx's they make and what arguments they use. */
  28. #include "config.h"
  29. #include <stdio.h>
  30. #include "varargs.h"
  31. #include "rtl.h"
  32. #include "regs.h"
  33. #include "insn-config.h"
  34. #define max(A,B) ((A) > (B) ? (A) : (B))
  35. #define min(A,B) ((A) < (B) ? (A) : (B))
  36. /* This is reset to FIRST_PSEUDO_REGISTER at the start each function.
  37. After rtl generation, it is 1 plus the largest register number used. */
  38. int reg_rtx_no = FIRST_PSEUDO_REGISTER;
  39. /* This is *not* reset after each function. It gives each CODE_LABEL
  40. in the entire compilation a unique label number. */
  41. static int label_num = 1;
  42. /* Value of `label_num' at start of current function. */
  43. static int first_label_num;
  44. /* Nonzero means do not generate NOTEs for source line numbers. */
  45. static int no_line_numbers;
  46. /* Commonly used rtx's, so that we only need space for one copy.
  47. These are initialized once for the entire compilation.
  48. All of these except perhaps fconst0_rtx and dconst0_rtx
  49. are unique; no other rtx-object will be equal to any of these. */
  50. rtx pc_rtx; /* (PC) */
  51. rtx cc0_rtx; /* (CC0) */
  52. rtx cc1_rtx; /* (CC1) (not actually used nowadays) */
  53. rtx const0_rtx; /* (CONST_INT 0) */
  54. rtx const1_rtx; /* (CONST_INT 1) */
  55. rtx fconst0_rtx; /* (CONST_DOUBLE:SF 0) */
  56. rtx dconst0_rtx; /* (CONST_DOUBLE:DF 0) */
  57. /* All references to the following fixed hard registers go through
  58. these unique rtl objects. On machines where the frame-pointer and
  59. arg-pointer are the same register, they use the same unique object.
  60. After register allocation, other rtl objects which used to be pseudo-regs
  61. may be clobbered to refer to the frame-pointer register.
  62. But references that were originally to the frame-pointer can be
  63. distinguished from the others because they contain frame_pointer_rtx.
  64. In an inline procedure, the stack and frame pointer rtxs may not be
  65. used for anything else. */
  66. rtx stack_pointer_rtx; /* (REG:Pmode STACK_POINTER_REGNUM) */
  67. rtx frame_pointer_rtx; /* (REG:Pmode FRAME_POINTER_REGNUM) */
  68. rtx arg_pointer_rtx; /* (REG:Pmode ARG_POINTER_REGNUM) */
  69. rtx struct_value_rtx; /* (REG:Pmode STRUCT_VALUE_REGNUM) */
  70. rtx struct_value_incoming_rtx; /* (REG:Pmode STRUCT_VALUE_INCOMING_REGNUM) */
  71. rtx static_chain_rtx; /* (REG:Pmode STATIC_CHAIN_REGNUM) */
  72. rtx static_chain_incoming_rtx; /* (REG:Pmode STATIC_CHAIN_INCOMING_REGNUM) */
  73. /* The ends of the doubly-linked chain of rtl for the current function.
  74. Both are reset to null at the start of rtl generation for the function. */
  75. static rtx first_insn = NULL;
  76. static rtx last_insn = NULL;
  77. /* The ends of a similar chain of rtl insns to become part
  78. of the SEQUENCE returned by a gen_... function (in insn-emit.c).
  79. This allows define_expand to use subroutines that call emit_insn. */
  80. static rtx sequence_first_insn = NULL;
  81. static rtx sequence_last_insn = NULL;
  82. /* Nonzero if emit_insn should add to the sequence_first_insn chain
  83. instead of the ordinary chain. */
  84. int emit_to_sequence;
  85. /* First insn used for something other than copying parms or changing their modes. */
  86. static rtx first_noninit_insn = NULL;
  87. /* INSN_UID for next insn emitted.
  88. Reset to 1 for each function compiled. */
  89. static int cur_insn_uid = 1;
  90. /* Line number and source file of the last line-number NOTE emitted.
  91. This is used to avoid generating duplicates. */
  92. static int last_linenum = 0;
  93. static char *last_filename = 0;
  94. /* A vector indexed by pseudo reg number. The allocated length
  95. of this vector is regno_pointer_flag_length. Since this
  96. vector is needed during the expansion phase when the total
  97. number of registers in the function is not yet known,
  98. it is copied and made bigger when necessary. */
  99. char *regno_pointer_flag;
  100. int regno_pointer_flag_length;
  101. /* Indexed by pseudo register number, gives the rtx for that pseudo.
  102. Allocated in parallel with regno_pointer_flag. */
  103. rtx *regno_reg_rtx;
  104. /* Chain of all CONST_DOUBLEs made for this function;
  105. so we can uniquize them. */
  106. rtx real_constant_chain;
  107. /* rtx gen_rtx (code, mode, [element1, ..., elementn])
  108. **
  109. ** This routine generates an RTX of the size specified by
  110. ** <code>, which is an RTX code. The RTX structure is initialized
  111. ** from the arguments <element1> through <elementn>, which are
  112. ** interpreted according to the specific RTX type's format. The
  113. ** special machine mode associated with the rtx (if any) is specified
  114. ** in <mode>.
  115. **
  116. ** gen_rtx() can be invoked in a way which resembles the lisp-like
  117. ** rtx it will generate. For example, the following rtx structure:
  118. **
  119. ** (plus:QI (mem:QI (reg:SI 1))
  120. ** (mem:QI (plusw:SI (reg:SI 2) (reg:SI 3))))
  121. **
  122. ** ...would be generated by the following C code:
  123. **
  124. ** gen_rtx (PLUS, QImode,
  125. ** gen_rtx (MEM, QImode,
  126. ** gen_rtx (REG, SImode, 1)),
  127. ** gen_rtx (MEM, QImode,
  128. ** gen_rtx (PLUS, SImode,
  129. ** gen_rtx (REG, SImode, 2),
  130. ** gen_rtx (REG, SImode, 3)))),
  131. */
  132. /*VARARGS2*/
  133. rtx
  134. gen_rtx (va_alist)
  135. va_dcl
  136. {
  137. va_list p;
  138. enum rtx_code code;
  139. enum machine_mode mode;
  140. register char *argp; /* Pointer to arguments... */
  141. register int i; /* Array indices... */
  142. register char *fmt; /* Current rtx's format... */
  143. register rtx rt_val; /* RTX to return to caller... */
  144. va_start (p);
  145. code = va_arg (p, enum rtx_code);
  146. mode = va_arg (p, enum machine_mode);
  147. if (code == CONST_INT)
  148. {
  149. int arg = va_arg (p, int);
  150. if (arg == 0)
  151. return const0_rtx;
  152. if (arg == 1)
  153. return const1_rtx;
  154. rt_val = rtx_alloc (code);
  155. INTVAL (rt_val) = arg;
  156. }
  157. else if (code == CONST_DOUBLE)
  158. {
  159. int arg0 = va_arg (p, int);
  160. int arg1 = va_arg (p, int);
  161. if (arg0 == XINT (fconst0_rtx, 0)
  162. && arg1 == XINT (fconst0_rtx, 1))
  163. return (mode == DFmode ? dconst0_rtx : fconst0_rtx);
  164. rt_val = rtx_alloc (code);
  165. rt_val->mode = mode;
  166. XINT (rt_val, 0) = arg0;
  167. XINT (rt_val, 1) = arg1;
  168. }
  169. else
  170. {
  171. rt_val = rtx_alloc (code); /* Allocate the storage space. */
  172. rt_val->mode = mode; /* Store the machine mode... */
  173. fmt = GET_RTX_FORMAT (code); /* Find the right format... */
  174. for (i = 0; i < GET_RTX_LENGTH (code); i++)
  175. {
  176. switch (*fmt++)
  177. {
  178. case '0': /* Unused field. */
  179. break;
  180. case 'i': /* An integer? */
  181. XINT (rt_val, i) = va_arg (p, int);
  182. break;
  183. case 's': /* A string? */
  184. XSTR (rt_val, i) = va_arg (p, char *);
  185. break;
  186. case 'e': /* An expression? */
  187. case 'u': /* An insn? Same except when printing. */
  188. XEXP (rt_val, i) = va_arg (p, rtx);
  189. break;
  190. case 'E': /* An RTX vector? */
  191. XVEC (rt_val, i) = va_arg (p, rtvec);
  192. break;
  193. default:
  194. abort();
  195. }
  196. }
  197. }
  198. va_end (p);
  199. return rt_val; /* Return the new RTX... */
  200. }
  201. /* gen_rtvec (n, [rt1, ..., rtn])
  202. **
  203. ** This routine creates an rtvec and stores within it the
  204. ** pointers to rtx's which are its arguments.
  205. */
  206. /*VARARGS1*/
  207. rtvec
  208. gen_rtvec (va_alist)
  209. va_dcl
  210. {
  211. int n, i;
  212. rtx first;
  213. va_list p;
  214. rtx *vector;
  215. va_start (p);
  216. n = va_arg (p, int);
  217. if (n == 0)
  218. return NULL_RTVEC; /* Don't allocate an empty rtvec... */
  219. vector = (rtx *) alloca (n * sizeof (rtx));
  220. for (i = 0; i < n; i++)
  221. vector[i] = va_arg (p, rtx);
  222. va_end (p);
  223. return gen_rtvec_v (n, vector);
  224. }
  225. rtvec
  226. gen_rtvec_v (n, argp)
  227. int n;
  228. rtx *argp;
  229. {
  230. register int i;
  231. register rtvec rt_val;
  232. if (n == 0)
  233. return NULL_RTVEC; /* Don't allocate an empty rtvec... */
  234. rt_val = rtvec_alloc (n); /* Allocate an rtvec... */
  235. for (i = 0; i < n; i++)
  236. rt_val->elem[i].rtx = *argp++;
  237. return rt_val;
  238. }
  239. /* Generate a REG rtx for a new pseudo register of mode MODE.
  240. This pseudo is assigned the next sequential register number. */
  241. rtx
  242. gen_reg_rtx (mode)
  243. enum machine_mode mode;
  244. {
  245. register rtx val;
  246. /* Make sure regno_pointer_flag and regno_reg_rtx are large
  247. enough to have an element for this pseudo reg number. */
  248. if (reg_rtx_no == regno_pointer_flag_length)
  249. {
  250. rtx *new1;
  251. char *new =
  252. (char *) oballoc (regno_pointer_flag_length * 2);
  253. bzero (new, regno_pointer_flag_length * 2);
  254. bcopy (regno_pointer_flag, new, regno_pointer_flag_length);
  255. regno_pointer_flag = new;
  256. new1 = (rtx *) oballoc (regno_pointer_flag_length * 2 * sizeof (rtx));
  257. bzero (new1, regno_pointer_flag_length * 2 * sizeof (rtx));
  258. bcopy (regno_reg_rtx, new1, regno_pointer_flag_length * sizeof (rtx));
  259. regno_reg_rtx = new1;
  260. regno_pointer_flag_length *= 2;
  261. }
  262. val = gen_rtx (REG, mode, reg_rtx_no);
  263. regno_reg_rtx[reg_rtx_no++] = val;
  264. return val;
  265. }
  266. /* Identify REG as a probable pointer register. */
  267. void
  268. mark_reg_pointer (reg)
  269. rtx reg;
  270. {
  271. REGNO_POINTER_FLAG (REGNO (reg)) = 1;
  272. }
  273. /* Return 1 plus largest pseudo reg number used in the current function. */
  274. int
  275. max_reg_num ()
  276. {
  277. return reg_rtx_no;
  278. }
  279. /* Return 1 + the largest label number used so far. */
  280. int
  281. max_label_num ()
  282. {
  283. return label_num;
  284. }
  285. /* Return first label number used in this function (if any were used). */
  286. int
  287. get_first_label_num ()
  288. {
  289. return first_label_num;
  290. }
  291. /* Assuming that X is an rtx (MEM or REG) for a fixed-point number,
  292. return a MEM or SUBREG rtx that refers to the least-significant part of X.
  293. If X is a MEM whose address is a QUEUED, the value may be so also. */
  294. rtx
  295. gen_lowpart (mode, x)
  296. enum machine_mode mode;
  297. register rtx x;
  298. {
  299. if (GET_CODE (x) == SUBREG)
  300. {
  301. /* The code we have is correct only under these conditions. */
  302. if (! subreg_lowpart_p (x))
  303. abort ();
  304. if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
  305. abort ();
  306. return (GET_MODE (SUBREG_REG (x)) == mode
  307. ? SUBREG_REG (x)
  308. : gen_rtx (SUBREG, mode, SUBREG_REG (x), SUBREG_WORD (x)));
  309. }
  310. if (GET_MODE (x) == mode)
  311. return x;
  312. if (GET_CODE (x) == CONST_INT)
  313. return gen_rtx (CONST_INT, VOIDmode, INTVAL (x) & GET_MODE_MASK (mode));
  314. if (GET_CODE (x) == MEM)
  315. {
  316. register int offset = 0;
  317. #ifdef WORDS_BIG_ENDIAN
  318. offset = (max (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
  319. - max (GET_MODE_SIZE (mode), UNITS_PER_WORD));
  320. #endif
  321. #ifdef BYTES_BIG_ENDIAN
  322. /* Adjust the address so that the address-after-the-data
  323. is unchanged. */
  324. offset -= (min (UNITS_PER_WORD, GET_MODE_SIZE (mode))
  325. - min (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
  326. #endif
  327. return gen_rtx (MEM, mode,
  328. memory_address (mode,
  329. plus_constant (XEXP (x, 0), offset)));
  330. }
  331. else if (GET_CODE (x) == REG)
  332. {
  333. #ifdef WORDS_BIG_ENDIAN
  334. if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
  335. {
  336. return gen_rtx (SUBREG, mode, x,
  337. ((GET_MODE_SIZE (GET_MODE (x))
  338. - max (GET_MODE_SIZE (mode), UNITS_PER_WORD))
  339. / UNITS_PER_WORD));
  340. }
  341. #endif
  342. return gen_rtx (SUBREG, mode, x, 0);
  343. }
  344. else
  345. abort ();
  346. }
  347. /* Like `gen_lowpart', but refer to the most significant part. */
  348. rtx
  349. gen_highpart (mode, x)
  350. enum machine_mode mode;
  351. register rtx x;
  352. {
  353. if (GET_CODE (x) == MEM)
  354. {
  355. register int offset = 0;
  356. #ifndef WORDS_BIG_ENDIAN
  357. offset = (max (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
  358. - max (GET_MODE_SIZE (mode), UNITS_PER_WORD));
  359. #endif
  360. #ifndef BYTES_BIG_ENDIAN
  361. if (GET_MODE_SIZE (mode) < UNITS_PER_WORD)
  362. offset -= (GET_MODE_SIZE (mode)
  363. - min (UNITS_PER_WORD,
  364. GET_MODE_SIZE (GET_MODE (x))));
  365. #endif
  366. return gen_rtx (MEM, mode,
  367. memory_address (mode,
  368. plus_constant (XEXP (x, 0), offset)));
  369. }
  370. else if (GET_CODE (x) == REG)
  371. {
  372. #ifndef WORDS_BIG_ENDIAN
  373. if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
  374. {
  375. return gen_rtx (SUBREG, mode, x,
  376. ((GET_MODE_SIZE (GET_MODE (x))
  377. - max (GET_MODE_SIZE (mode), UNITS_PER_WORD))
  378. / UNITS_PER_WORD));
  379. }
  380. #endif
  381. return gen_rtx (SUBREG, mode, x, 0);
  382. }
  383. else
  384. abort ();
  385. }
  386. /* Return 1 iff X, assumed to be a SUBREG,
  387. refers to the least significant part of its containing reg.
  388. If X is not a SUBREG, always return 1 (it is its own low part!). */
  389. int
  390. subreg_lowpart_p (x)
  391. rtx x;
  392. {
  393. if (GET_CODE (x) != SUBREG)
  394. return 1;
  395. #ifdef WORDS_BIG_ENDIAN
  396. if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
  397. {
  398. register enum machine_mode mode = GET_MODE (SUBREG_REG (x));
  399. return (SUBREG_WORD (x)
  400. == ((GET_MODE_SIZE (GET_MODE (x))
  401. - max (GET_MODE_SIZE (mode), UNITS_PER_WORD))
  402. / UNITS_PER_WORD));
  403. }
  404. #endif
  405. return SUBREG_WORD (x) == 0;
  406. }
  407. /* Return a memory reference like MEMREF, but with its mode changed
  408. to MODE and its address changed to ADDR.
  409. (VOIDmode means don't change the mode.
  410. NULL for ADDR means don't change the address.) */
  411. rtx
  412. change_address (memref, mode, addr)
  413. rtx memref;
  414. enum machine_mode mode;
  415. rtx addr;
  416. {
  417. rtx new;
  418. if (mode == VOIDmode)
  419. mode = GET_MODE (memref);
  420. if (addr == 0)
  421. addr = XEXP (memref, 0);
  422. new = gen_rtx (MEM, mode, memory_address (mode, addr));
  423. new->volatil = memref->volatil;
  424. new->unchanging = memref->unchanging;
  425. new->in_struct = memref->in_struct;
  426. return new;
  427. }
  428. /* Return a newly created CODE_LABEL rtx with a unique label number. */
  429. rtx
  430. gen_label_rtx ()
  431. {
  432. register rtx label = gen_rtx (CODE_LABEL, VOIDmode, 0, 0, 0, label_num++);
  433. LABEL_NUSES (label) = 0;
  434. return label;
  435. }
  436. /* For procedure integration. */
  437. /* Return a newly created INLINE_HEADER rtx. Should allocate this
  438. from a permanent obstack when the opportunity arises. */
  439. rtx
  440. gen_inline_header_rtx (insn, last_insn,
  441. first_labelno, last_labelno,
  442. max_parm_regnum, max_regnum, args_size)
  443. rtx insn, last_insn;
  444. int first_labelno, last_labelno, max_parm_regnum, max_regnum, args_size;
  445. {
  446. rtx header = gen_rtx (INLINE_HEADER, VOIDmode,
  447. cur_insn_uid++, NULL,
  448. insn, last_insn,
  449. first_labelno, last_labelno,
  450. max_parm_regnum, max_regnum, args_size);
  451. return header;
  452. }
  453. /* Install new pointers to the first and last insns in the chain.
  454. Used for an inline-procedure after copying the insn chain. */
  455. void
  456. set_new_first_and_last_insn (first, last)
  457. rtx first, last;
  458. {
  459. first_insn = first;
  460. last_insn = last;
  461. }
  462. /* Go through all the RTL insn bodies and copy any invalid shared structure.
  463. It does not work to do this twice, because the mark bits set here
  464. are not cleared afterwards. */
  465. static int unshare_copies = 0; /* Count rtx's that were copied. */
  466. static rtx copy_rtx_if_shared ();
  467. void
  468. unshare_all_rtl (insn)
  469. register rtx insn;
  470. {
  471. for (; insn; insn = NEXT_INSN (insn))
  472. if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN
  473. || GET_CODE (insn) == CALL_INSN)
  474. {
  475. rtx tail;
  476. PATTERN (insn) = copy_rtx_if_shared (PATTERN (insn));
  477. /* Copy the contents of the reg-notes */
  478. for (tail = REG_NOTES (insn); tail; tail = XEXP (tail, 1))
  479. /* But if contents are an insn, don't copy that. */
  480. if (GET_CODE (tail) == EXPR_LIST)
  481. XEXP (tail, 0) = copy_rtx_if_shared (XEXP (tail, 0));
  482. }
  483. }
  484. /* Mark ORIG as in use, and return a copy of it if it was already in use.
  485. Recursively does the same for subexpressions. */
  486. static rtx
  487. copy_rtx_if_shared (orig)
  488. rtx orig;
  489. {
  490. register rtx x = orig;
  491. register int i;
  492. register enum rtx_code code;
  493. register char *format_ptr;
  494. int copied = 0;
  495. code = GET_CODE (x);
  496. /* These types may be freely shared. */
  497. switch (code)
  498. {
  499. case REG:
  500. case QUEUED:
  501. case CONST_INT:
  502. case CONST_DOUBLE:
  503. case SYMBOL_REF:
  504. case CODE_LABEL:
  505. case PC:
  506. case CC0:
  507. return x;
  508. case MEM:
  509. /* A MEM is allowed to be shared if its address is constant
  510. or is a constant plus one of the special registers. */
  511. if (CONSTANT_ADDRESS_P (XEXP (x, 0)))
  512. return x;
  513. if (GET_CODE (XEXP (x, 0)) == PLUS
  514. && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
  515. && (REGNO (XEXP (XEXP (x, 0), 0)) == FRAME_POINTER_REGNUM
  516. || REGNO (XEXP (XEXP (x, 0), 0)) == ARG_POINTER_REGNUM)
  517. && CONSTANT_ADDRESS_P (XEXP (XEXP (x, 0), 1)))
  518. if (GET_CODE (XEXP (x, 0)) == REG
  519. && (REGNO (XEXP (x, 0)) == FRAME_POINTER_REGNUM
  520. || REGNO (XEXP (x, 0)) == ARG_POINTER_REGNUM)
  521. && CONSTANT_ADDRESS_P (XEXP (x, 1)))
  522. return x;
  523. }
  524. /* This rtx may not be shared. If it has already been seen,
  525. replace it with a copy of itself. */
  526. if (x->used)
  527. {
  528. register rtx copy;
  529. unshare_copies++;
  530. copy = rtx_alloc (code);
  531. bcopy (x, copy, sizeof (int) * (GET_RTX_LENGTH (code) + 1));
  532. x = copy;
  533. copied = 1;
  534. }
  535. x->used = 1;
  536. /* Now scan the subexpressions recursively.
  537. We can store any replaced subexpressions directly into X
  538. since we know X is not shared! Any vectors in X
  539. must be copied if X was copied. */
  540. format_ptr = GET_RTX_FORMAT (code);
  541. for (i = 0; i < GET_RTX_LENGTH (code); i++)
  542. {
  543. switch (*format_ptr++)
  544. {
  545. case 'e':
  546. XEXP (x, i) = copy_rtx_if_shared (XEXP (x, i));
  547. break;
  548. case 'E':
  549. if (XVEC (x, i) != NULL)
  550. {
  551. register int j;
  552. if (copied)
  553. XVEC (x, i) = gen_rtvec_v (XVECLEN (x, i), &XVECEXP (x, i, 0));
  554. for (j = 0; j < XVECLEN (x, i); j++)
  555. XVECEXP (x, i, j)
  556. = copy_rtx_if_shared (XVECEXP (x, i, j));
  557. }
  558. break;
  559. }
  560. }
  561. return x;
  562. }
  563. /* Copy X if necessary so that it won't be altered by changes in OTHER.
  564. Return X or the rtx for the pseudo reg the value of X was copied into.
  565. OTHER must be valid as a SET_DEST. */
  566. rtx
  567. make_safe_from (x, other)
  568. rtx x, other;
  569. {
  570. rtx out = other;
  571. while (1)
  572. switch (GET_CODE (other))
  573. {
  574. case SUBREG:
  575. other = SUBREG_REG (other);
  576. break;
  577. case STRICT_LOW_PART:
  578. case SIGN_EXTEND:
  579. case ZERO_EXTEND:
  580. other = XEXP (other, 0);
  581. break;
  582. default:
  583. goto done;
  584. }
  585. done:
  586. if ((GET_CODE (other) == MEM
  587. && ! CONSTANT_P (x)
  588. && GET_CODE (x) != CONST_DOUBLE
  589. && GET_CODE (x) != REG)
  590. || (GET_CODE (other) == REG
  591. && (REGNO (other) < FIRST_PSEUDO_REGISTER
  592. || reg_mentioned_p (other, x))))
  593. {
  594. rtx temp = gen_reg_rtx (GET_MODE (x));
  595. emit_move_insn (temp, x);
  596. return temp;
  597. }
  598. return x;
  599. }
  600. /* Emission of insns (adding them to the doubly-linked list). */
  601. /* Return the first insn of the current function. */
  602. rtx
  603. get_insns ()
  604. {
  605. return first_insn;
  606. }
  607. /* Return the last insn of the current function. */
  608. rtx
  609. get_last_insn ()
  610. {
  611. return last_insn;
  612. }
  613. /* Return a number larger than any instruction's uid in this function. */
  614. int
  615. get_max_uid ()
  616. {
  617. return cur_insn_uid;
  618. }
  619. /* Make and return an INSN rtx, initializing all its slots.
  620. Store PATTERN in the pattern slots.
  621. PAT_FORMALS is an idea that never really went anywhere. */
  622. static rtx
  623. make_insn_raw (pattern, pat_formals)
  624. rtx pattern;
  625. rtvec pat_formals;
  626. {
  627. register rtx insn;
  628. insn = rtx_alloc(INSN);
  629. INSN_UID(insn) = cur_insn_uid++;
  630. PATTERN (insn) = pattern;
  631. INSN_CODE (insn) = -1;
  632. LOG_LINKS(insn) = NULL;
  633. REG_NOTES(insn) = NULL;
  634. return insn;
  635. }
  636. /* Like `make_insn' but make a JUMP_INSN instead of an insn. */
  637. static rtx
  638. make_jump_insn_raw (pattern, pat_formals)
  639. rtx pattern;
  640. rtvec pat_formals;
  641. {
  642. register rtx insn;
  643. insn = rtx_alloc(JUMP_INSN);
  644. INSN_UID(insn) = cur_insn_uid++;
  645. PATTERN (insn) = pattern;
  646. INSN_CODE (insn) = -1;
  647. LOG_LINKS(insn) = NULL;
  648. REG_NOTES(insn) = NULL;
  649. JUMP_LABEL(insn) = NULL;
  650. return insn;
  651. }
  652. #if 0
  653. /* No longer needed, now that SEQUENCEs contain insns rather than bodies. */
  654. /* Return an indication of which type of insn should have X as a body.
  655. The value is CODE_LABEL, INSN, CALL_INSN or JUMP_INSN. */
  656. /* Note this is no longer correct now that a CALL can appear inside a SET. */
  657. enum rtx_code
  658. classify_insn (x)
  659. rtx x;
  660. {
  661. if (GET_CODE (x) == CODE_LABEL)
  662. return CODE_LABEL;
  663. if (GET_CODE (x) == CALL)
  664. return CALL_INSN;
  665. if (GET_CODE (x) == SET)
  666. {
  667. if (SET_DEST (x) == pc_rtx)
  668. return JUMP_INSN;
  669. else
  670. return INSN;
  671. }
  672. if (GET_CODE (x) == PARALLEL)
  673. {
  674. register int j;
  675. for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
  676. if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
  677. return CALL_INSN;
  678. else if (GET_CODE (XVECEXP (x, 0, j)) == SET
  679. && SET_DEST (XVECEXP (x, 0, j)) == pc_rtx)
  680. return JUMP_INSN;
  681. }
  682. return INSN;
  683. }
  684. #endif
  685. /* Add INSN to the end of the doubly-linked list.
  686. INSN may be an INSN, JUMP_INSN, CALL_INSN, CODE_LABEL, BARRIER or NOTE. */
  687. static void
  688. add_insn (insn)
  689. register rtx insn;
  690. {
  691. if (emit_to_sequence)
  692. {
  693. PREV_INSN (insn) = sequence_last_insn;
  694. NEXT_INSN (insn) = 0;
  695. if (NULL != sequence_last_insn)
  696. NEXT_INSN (sequence_last_insn) = insn;
  697. if (NULL == sequence_first_insn)
  698. sequence_first_insn = insn;
  699. sequence_last_insn = insn;
  700. }
  701. else
  702. {
  703. PREV_INSN (insn) = last_insn;
  704. NEXT_INSN (insn) = 0;
  705. if (NULL != last_insn)
  706. NEXT_INSN (last_insn) = insn;
  707. if (NULL == first_insn)
  708. first_insn = insn;
  709. last_insn = insn;
  710. }
  711. }
  712. /* Add INSN, an rtx of code INSN, into the doubly-linked list
  713. after insn AFTER. */
  714. static void
  715. add_insn_after (insn, after)
  716. rtx insn, after;
  717. {
  718. NEXT_INSN (insn) = NEXT_INSN (after);
  719. PREV_INSN (insn) = after;
  720. if (NEXT_INSN (insn))
  721. PREV_INSN (NEXT_INSN (insn)) = insn;
  722. else
  723. last_insn = insn;
  724. NEXT_INSN (after) = insn;
  725. }
  726. /* Delete all insns made since FROM.
  727. FROM becomes the new last instruction. */
  728. void
  729. delete_insns_since (from)
  730. rtx from;
  731. {
  732. NEXT_INSN (from) = 0;
  733. last_insn = from;
  734. }
  735. /* Move a consecutive bunch of insns to a different place in the chain.
  736. The insns to be moved are those between FROM and TO.
  737. They are moved to a new position after the insn AFTER. */
  738. void
  739. reorder_insns (from, to, after)
  740. rtx from, to, after;
  741. {
  742. /* Splice this bunch out of where it is now. */
  743. if (PREV_INSN (from))
  744. NEXT_INSN (PREV_INSN (from)) = NEXT_INSN (to);
  745. if (NEXT_INSN (to))
  746. PREV_INSN (NEXT_INSN (to)) = PREV_INSN (from);
  747. if (last_insn == to)
  748. last_insn = PREV_INSN (from);
  749. if (first_insn == from)
  750. first_insn = NEXT_INSN (to);
  751. /* Make the new neighbors point to it and it to them. */
  752. if (NEXT_INSN (after))
  753. {
  754. PREV_INSN (NEXT_INSN (after)) = to;
  755. NEXT_INSN (to) = NEXT_INSN (after);
  756. }
  757. PREV_INSN (from) = after;
  758. NEXT_INSN (after) = from;
  759. if (after == last_insn)
  760. last_insn = to;
  761. }
  762. /* Emit an insn of given code and pattern
  763. at a specified place within the doubly-linked list. */
  764. /* Make an instruction with body PATTERN
  765. and output it before the instruction BEFORE. */
  766. rtx
  767. emit_insn_before (pattern, before)
  768. register rtx pattern, before;
  769. {
  770. register rtx insn;
  771. if (GET_CODE (pattern) == SEQUENCE)
  772. {
  773. register int i;
  774. /* For an empty sequence, emit nothing. */
  775. if (XVEC (pattern, 0))
  776. for (i = 0; i < XVECLEN (pattern, 0); i++)
  777. add_insn_after (XVECEXP (pattern, 0, i), PREV_INSN (before));
  778. return PREV_INSN (before);
  779. }
  780. insn = make_insn_raw (pattern, 0);
  781. PREV_INSN (insn) = PREV_INSN (before);
  782. NEXT_INSN (insn) = before;
  783. if (PREV_INSN (insn))
  784. NEXT_INSN (PREV_INSN (insn)) = insn;
  785. else
  786. first_insn = insn;
  787. PREV_INSN (before) = insn;
  788. return insn;
  789. }
  790. /* Make an instruction with body PATTERN and code JUMP_INSN
  791. and output it before the instruction BEFORE. */
  792. rtx
  793. emit_jump_insn_before (pattern, before)
  794. register rtx pattern, before;
  795. {
  796. register rtx insn = make_jump_insn_raw (pattern, 0);
  797. PREV_INSN (insn) = PREV_INSN (before);
  798. NEXT_INSN (insn) = before;
  799. if (PREV_INSN (insn))
  800. NEXT_INSN (PREV_INSN (insn)) = insn;
  801. else
  802. first_insn = insn;
  803. PREV_INSN (before) = insn;
  804. return insn;
  805. }
  806. /* Make an insn of code INSN with body PATTERN
  807. and output it after the insn AFTER. */
  808. rtx
  809. emit_insn_after (pattern, after)
  810. register rtx pattern, after;
  811. {
  812. if (GET_CODE (pattern) == SEQUENCE)
  813. {
  814. register int i;
  815. /* For an empty sequence, emit nothing. */
  816. if (XVEC (pattern, 0))
  817. for (i = 0; i < XVECLEN (pattern, 0); i++)
  818. {
  819. add_insn_after (XVECEXP (pattern, 0, i), after);
  820. after = NEXT_INSN (after);
  821. }
  822. return after;
  823. }
  824. else
  825. {
  826. register rtx insn = make_insn_raw (pattern, 0);
  827. add_insn_after (insn, after);
  828. return insn;
  829. }
  830. }
  831. /* Make an insn of code JUMP_INSN with body PATTERN
  832. and output it after the insn AFTER. */
  833. rtx
  834. emit_jump_insn_after (pattern, after)
  835. register rtx pattern, after;
  836. {
  837. register rtx insn = make_jump_insn_raw (pattern, 0);
  838. add_insn_after (insn, after);
  839. return insn;
  840. }
  841. /* Make an insn of code BARRIER
  842. and output it after the insn AFTER. */
  843. rtx
  844. emit_barrier_after (after)
  845. register rtx after;
  846. {
  847. register rtx insn = rtx_alloc (BARRIER);
  848. INSN_UID (insn) = cur_insn_uid++;
  849. add_insn_after (insn, after);
  850. return insn;
  851. }
  852. /* Emit the label LABEL after the insn AFTER. */
  853. void
  854. emit_label_after (label, after)
  855. rtx label, after;
  856. {
  857. /* This can be called twice for the same label
  858. as a result of the confusion that follows a syntax error!
  859. So make it harmless. */
  860. if (INSN_UID (label) == 0)
  861. {
  862. INSN_UID (label) = cur_insn_uid++;
  863. add_insn_after (label, after);
  864. }
  865. }
  866. /* Emit a note of subtype SUBTYPE after the insn AFTER. */
  867. void
  868. emit_note_after (subtype, after)
  869. int subtype;
  870. rtx after;
  871. {
  872. register rtx note = rtx_alloc (NOTE);
  873. INSN_UID (note) = cur_insn_uid++;
  874. XSTR (note, 3) = 0;
  875. XINT (note, 4) = subtype;
  876. add_insn_after (note, after);
  877. }
  878. /* Make an insn of code INSN with pattern PATTERN
  879. and add it to the end of the doubly-linked list.
  880. If PATTERN is a SEQUENCE, take the elements of it
  881. and emit an insn for each element.
  882. Returns the last insn emitted. */
  883. rtx
  884. emit_insn (pattern)
  885. rtx pattern;
  886. {
  887. rtx insn;
  888. if (GET_CODE (pattern) == SEQUENCE)
  889. {
  890. register int i;
  891. /* For an empty sequence, emit nothing. */
  892. if (XVEC (pattern, 0))
  893. for (i = 0; i < XVECLEN (pattern, 0); i++)
  894. add_insn (insn = XVECEXP (pattern, 0, i));
  895. }
  896. else
  897. {
  898. insn = make_insn_raw (pattern, NULL);
  899. add_insn (insn);
  900. }
  901. return insn;
  902. }
  903. /* Make an insn of code JUMP_INSN with pattern PATTERN
  904. and add it to the end of the doubly-linked list. */
  905. rtx
  906. emit_jump_insn (pattern)
  907. rtx pattern;
  908. {
  909. if (GET_CODE (pattern) == SEQUENCE)
  910. return emit_insn (pattern);
  911. else
  912. {
  913. register rtx insn = make_jump_insn_raw (pattern, NULL);
  914. add_insn (insn);
  915. return insn;
  916. }
  917. }
  918. /* Make an insn of code CALL_INSN with pattern PATTERN
  919. and add it to the end of the doubly-linked list. */
  920. rtx
  921. emit_call_insn (pattern)
  922. rtx pattern;
  923. {
  924. if (GET_CODE (pattern) == SEQUENCE)
  925. return emit_insn (pattern);
  926. else
  927. {
  928. register rtx insn = make_insn_raw (pattern, NULL);
  929. add_insn (insn);
  930. PUT_CODE (insn, CALL_INSN);
  931. return insn;
  932. }
  933. }
  934. /* Add the label LABEL to the end of the doubly-linked list. */
  935. void
  936. emit_label (label)
  937. rtx label;
  938. {
  939. /* This can be called twice for the same label
  940. as a result of the confusion that follows a syntax error!
  941. So make it harmless. */
  942. if (INSN_UID (label) == 0)
  943. {
  944. INSN_UID (label) = cur_insn_uid++;
  945. add_insn (label);
  946. }
  947. }
  948. /* Make an insn of code BARRIER
  949. and add it to the end of the doubly-linked list. */
  950. void
  951. emit_barrier ()
  952. {
  953. register rtx barrier = rtx_alloc (BARRIER);
  954. INSN_UID (barrier) = cur_insn_uid++;
  955. add_insn (barrier);
  956. }
  957. /* Make an insn of code NOTE
  958. with data-fields specified by FILE and LINE
  959. and add it to the end of the doubly-linked list. */
  960. rtx
  961. emit_note (file, line)
  962. char *file;
  963. int line;
  964. {
  965. register rtx note;
  966. if (no_line_numbers && line > 0)
  967. return 0;
  968. if (line > 0)
  969. {
  970. if (file && last_filename && !strcmp (file, last_filename)
  971. && line == last_linenum)
  972. return 0;
  973. last_filename = file;
  974. last_linenum = line;
  975. }
  976. note = rtx_alloc (NOTE);
  977. INSN_UID (note) = cur_insn_uid++;
  978. XSTR (note, 3) = file;
  979. XINT (note, 4) = line;
  980. add_insn (note);
  981. return note;
  982. }
  983. /* Generate a SEQUENCE rtx containing the insn-patterns in VEC
  984. following any insns previously placed on sequence_first_insn.
  985. This is how the gen_... function from a DEFINE_EXPAND
  986. constructs the SEQUENCE that it returns. */
  987. rtx
  988. gen_sequence ()
  989. {
  990. rtx tem;
  991. rtvec newvec;
  992. int i;
  993. int len;
  994. /* Count the insns in the chain. */
  995. len = 0;
  996. for (tem = sequence_first_insn; tem; tem = NEXT_INSN (tem))
  997. len++;
  998. /* For an empty sequence... */
  999. if (len == 0)
  1000. return gen_rtx (SEQUENCE, VOIDmode, NULL);
  1001. /* If only one insn, return its pattern rather than a SEQUENCE. */
  1002. if (len == 1)
  1003. {
  1004. tem = PATTERN (sequence_first_insn);
  1005. sequence_first_insn = 0;
  1006. sequence_last_insn = 0;
  1007. return tem;
  1008. }
  1009. /* Put them in a vector. */
  1010. newvec = rtvec_alloc (len);
  1011. i = 0;
  1012. for (tem = sequence_first_insn; tem; tem = NEXT_INSN (tem), i++)
  1013. newvec->elem[i].rtx = tem;
  1014. /* Clear the chain and make a SEQUENCE from this vector. */
  1015. sequence_first_insn = 0;
  1016. sequence_last_insn = 0;
  1017. return gen_rtx (SEQUENCE, VOIDmode, newvec);
  1018. }
  1019. /* Set up regno_reg_rtx, reg_rtx_no and regno_pointer_flag
  1020. according to the chain of insns starting with FIRST.
  1021. This is used when an inline function's rtl is saved
  1022. and passed to rest_of_compilation later. */
  1023. static void restore_reg_data_1 ();
  1024. void
  1025. restore_reg_data (first)
  1026. rtx first;
  1027. {
  1028. rtx insn;
  1029. int i;
  1030. for (insn = first; insn; insn = NEXT_INSN (insn))
  1031. {
  1032. switch (GET_CODE (insn))
  1033. {
  1034. case NOTE:
  1035. case CODE_LABEL:
  1036. case BARRIER:
  1037. break;
  1038. case JUMP_INSN:
  1039. case CALL_INSN:
  1040. case INSN:
  1041. restore_reg_data_1 (PATTERN (insn));
  1042. break;
  1043. }
  1044. }
  1045. /* Fill in holes that need to exist. */
  1046. for (i = FIRST_PSEUDO_REGISTER; i < reg_rtx_no; i++)
  1047. if (regno_reg_rtx[i] == 0)
  1048. regno_reg_rtx[i] = gen_rtx (REG, SImode, i);
  1049. }
  1050. static void
  1051. restore_reg_data_1 (orig)
  1052. rtx orig;
  1053. {
  1054. register rtx x = orig;
  1055. register int i;
  1056. register enum rtx_code code;
  1057. register char *format_ptr;
  1058. code = GET_CODE (x);
  1059. switch (code)
  1060. {
  1061. case QUEUED:
  1062. case CONST_INT:
  1063. case CONST_DOUBLE:
  1064. case SYMBOL_REF:
  1065. case CODE_LABEL:
  1066. case PC:
  1067. case CC0:
  1068. case LABEL_REF:
  1069. return;
  1070. case REG:
  1071. if (REGNO (x) >= FIRST_PSEUDO_REGISTER)
  1072. {
  1073. /* Make sure regno_pointer_flag and regno_reg_rtx are large
  1074. enough to have an element for this pseudo reg number. */
  1075. if (REGNO (x) >= reg_rtx_no)
  1076. {
  1077. reg_rtx_no = REGNO (x);
  1078. if (reg_rtx_no == regno_pointer_flag_length)
  1079. {
  1080. rtx *new1;
  1081. char *new =
  1082. (char *) oballoc (regno_pointer_flag_length * 2);
  1083. bzero (new, regno_pointer_flag_length * 2);
  1084. bcopy (regno_pointer_flag, new, regno_pointer_flag_length);
  1085. regno_pointer_flag = new;
  1086. new1 = (rtx *) oballoc (regno_pointer_flag_length * 2 * sizeof (rtx));
  1087. bzero (new1, regno_pointer_flag_length * 2 * sizeof (rtx));
  1088. bcopy (regno_reg_rtx, new1, regno_pointer_flag_length * sizeof (rtx));
  1089. regno_reg_rtx = new1;
  1090. regno_pointer_flag_length *= 2;
  1091. }
  1092. reg_rtx_no ++;
  1093. }
  1094. regno_reg_rtx[REGNO (x)] = x;
  1095. }
  1096. return;
  1097. case MEM:
  1098. restore_reg_data_1 (XEXP (x, 0));
  1099. return;
  1100. }
  1101. /* Now scan the subexpressions recursively. */
  1102. format_ptr = GET_RTX_FORMAT (code);
  1103. for (i = 0; i < GET_RTX_LENGTH (code); i++)
  1104. {
  1105. switch (*format_ptr++)
  1106. {
  1107. case 'e':
  1108. restore_reg_data_1 (XEXP (x, i));
  1109. break;
  1110. case 'E':
  1111. if (XVEC (x, i) != NULL)
  1112. {
  1113. register int j;
  1114. for (j = 0; j < XVECLEN (x, i); j++)
  1115. restore_reg_data_1 (XVECEXP (x, i, j));
  1116. }
  1117. break;
  1118. }
  1119. }
  1120. }
  1121. /* Initialize data structures and variables in this file
  1122. before generating rtl for each function.
  1123. WRITE_SYMBOLS is nonzero if any kind of debugging info
  1124. is to be generated. */
  1125. void
  1126. init_emit (write_symbols)
  1127. int write_symbols;
  1128. {
  1129. first_insn = NULL;
  1130. last_insn = NULL;
  1131. cur_insn_uid = 1;
  1132. reg_rtx_no = FIRST_PSEUDO_REGISTER;
  1133. last_linenum = 0;
  1134. last_filename = 0;
  1135. real_constant_chain = 0;
  1136. first_label_num = label_num;
  1137. sequence_first_insn = NULL;
  1138. sequence_last_insn = NULL;
  1139. emit_to_sequence = 0;
  1140. no_line_numbers = ! write_symbols;
  1141. /* Init the tables that describe all the pseudo regs. */
  1142. regno_pointer_flag_length = 100;
  1143. regno_pointer_flag
  1144. = (char *) oballoc (regno_pointer_flag_length);
  1145. bzero (regno_pointer_flag, regno_pointer_flag_length);
  1146. regno_reg_rtx
  1147. = (rtx *) oballoc (regno_pointer_flag_length * sizeof (rtx));
  1148. bzero (regno_reg_rtx, regno_pointer_flag_length * sizeof (rtx));
  1149. }
  1150. /* Create some permanent unique rtl objects shared between all functions. */
  1151. void
  1152. init_emit_once ()
  1153. {
  1154. /* Create the unique rtx's for certain rtx codes and operand values. */
  1155. pc_rtx = gen_rtx (PC, VOIDmode);
  1156. cc0_rtx = gen_rtx (CC0, VOIDmode);
  1157. /* Don't use gen_rtx here since gen_rtx in this case
  1158. tries to use these variables. */
  1159. const0_rtx = rtx_alloc (CONST_INT);
  1160. INTVAL (const0_rtx) = 0;
  1161. const1_rtx = rtx_alloc (CONST_INT);
  1162. INTVAL (const1_rtx) = 1;
  1163. fconst0_rtx = rtx_alloc (CONST_DOUBLE);
  1164. {
  1165. union { double d; int i[2]; } u;
  1166. u.d = 0;
  1167. XINT (fconst0_rtx, 0) = u.i[0];
  1168. XINT (fconst0_rtx, 1) = u.i[1];
  1169. XEXP (fconst0_rtx, 2) = const0_rtx;
  1170. }
  1171. PUT_MODE (fconst0_rtx, SFmode);
  1172. dconst0_rtx = rtx_alloc (CONST_DOUBLE);
  1173. {
  1174. union { double d; int i[2]; } u;
  1175. u.d = 0;
  1176. XINT (dconst0_rtx, 0) = u.i[0];
  1177. XINT (dconst0_rtx, 1) = u.i[1];
  1178. XEXP (dconst0_rtx, 2) = const0_rtx;
  1179. }
  1180. PUT_MODE (dconst0_rtx, DFmode);
  1181. stack_pointer_rtx = gen_rtx (REG, Pmode, STACK_POINTER_REGNUM);
  1182. frame_pointer_rtx = gen_rtx (REG, Pmode, FRAME_POINTER_REGNUM);
  1183. struct_value_rtx = gen_rtx (REG, Pmode, STRUCT_VALUE_REGNUM);
  1184. #ifdef STRUCT_VALUE_INCOMING_REGNUM
  1185. if (STRUCT_VALUE_INCOMING_REGNUM != STRUCT_VALUE_REGNUM)
  1186. struct_value_incoming_rtx = gen_rtx (REG, Pmode, STRUCT_VALUE_INCOMING_REGNUM);
  1187. else
  1188. #endif
  1189. struct_value_incoming_rtx = struct_value_rtx;
  1190. static_chain_rtx = gen_rtx (REG, Pmode, STATIC_CHAIN_REGNUM);
  1191. #ifdef STATIC_CHAIN_INCOMING_REGNUM
  1192. if (STATIC_CHAIN_INCOMING_REGNUM != STATIC_CHAIN_REGNUM)
  1193. static_chain_incoming_rtx = gen_rtx (REG, Pmode, STATIC_CHAIN_INCOMING_REGNUM);
  1194. else
  1195. #endif
  1196. static_chain_incoming_rtx = static_chain_rtx;
  1197. if (FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM)
  1198. arg_pointer_rtx = frame_pointer_rtx;
  1199. else
  1200. arg_pointer_rtx = gen_rtx (REG, Pmode, ARG_POINTER_REGNUM);
  1201. }