optabs.c 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430
  1. /* Expand the basic unary and binary arithmetic operations, for GNU compiler.
  2. Copyright (C) 1987 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. #include "config.h"
  18. #include "rtl.h"
  19. #include "tree.h"
  20. #include "insn-flags.h"
  21. #include "insn-codes.h"
  22. #include "expr.h"
  23. #include "insn-config.h"
  24. #include "recog.h"
  25. /* Each optab contains info on how this target machine
  26. can perform a particular operation
  27. for all sizes and kinds of operands.
  28. The operation to be performed is often specified
  29. by passing one of these optabs as an argument.
  30. See expr.h for documentation of these optabs. */
  31. optab add_optab;
  32. optab sub_optab;
  33. optab smul_optab;
  34. optab umul_optab;
  35. optab smul_widen_optab;
  36. optab umul_widen_optab;
  37. optab sdiv_optab;
  38. optab sdivmod_optab;
  39. optab udiv_optab;
  40. optab udivmod_optab;
  41. optab smod_optab;
  42. optab umod_optab;
  43. optab flodiv_optab;
  44. optab and_optab;
  45. optab andcb_optab;
  46. optab ior_optab;
  47. optab xor_optab;
  48. optab ashl_optab;
  49. optab lshr_optab;
  50. optab lshl_optab;
  51. optab ashr_optab;
  52. optab rotl_optab;
  53. optab rotr_optab;
  54. optab mov_optab;
  55. optab movstrict_optab;
  56. optab neg_optab;
  57. optab abs_optab;
  58. optab one_cmpl_optab;
  59. optab cmp_optab;
  60. optab tst_optab;
  61. /* Generate code to perform an operation specified by BINOPTAB
  62. on operands OP0 and OP1, with result having machine-mode MODE.
  63. UNSIGNEDP is for the case where we have to widen the operands
  64. to perform the operation. It says to use zero-extension.
  65. If TARGET is nonzero, the value
  66. is generated there, if it is convenient to do so.
  67. In all cases an rtx is returned for the locus of the value;
  68. this may or may not be TARGET. */
  69. rtx
  70. expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
  71. enum machine_mode mode;
  72. optab binoptab;
  73. rtx op0, op1;
  74. rtx target;
  75. int unsignedp;
  76. enum optab_methods methods;
  77. {
  78. register rtx temp;
  79. int target_is_not_an_operand = 0;
  80. /* We may get better code by generating the result in a register
  81. when the target is not one of the operands. */
  82. if (target && ! rtx_equal_p (target, op1) && ! rtx_equal_p (target, op0))
  83. target_is_not_an_operand = 1;
  84. op0 = protect_from_queue (op0, 0);
  85. op1 = protect_from_queue (op1, 0);
  86. if (target)
  87. target = protect_from_queue (target, 1);
  88. if (force_mem)
  89. {
  90. op0 = force_not_mem (op0);
  91. op1 = force_not_mem (op1);
  92. }
  93. /* If operation is commutative,
  94. try to make the first operand a register.
  95. Even better, try to make it the same as the target.
  96. Also try to make the last operand a constant. */
  97. if (binoptab == add_optab
  98. || binoptab == and_optab
  99. || binoptab == ior_optab
  100. || binoptab == xor_optab
  101. || binoptab == smul_optab
  102. || binoptab == umul_optab
  103. || binoptab == smul_widen_optab
  104. || binoptab == umul_widen_optab)
  105. {
  106. if (((target == 0 || GET_CODE (target) == REG)
  107. ? ((GET_CODE (op1) == REG
  108. && GET_CODE (op0) != REG)
  109. || target == op1)
  110. : rtx_equal_p (op1, target))
  111. ||
  112. GET_CODE (op0) == CONST_INT)
  113. {
  114. temp = op1;
  115. op1 = op0;
  116. op0 = temp;
  117. }
  118. }
  119. /* If we can do it with a three-operand insn, do so. */
  120. if (binoptab[(int) mode].insn_code != CODE_FOR_nothing)
  121. {
  122. if (target)
  123. temp = target;
  124. else
  125. temp = gen_reg_rtx (mode);
  126. if (GET_MODE (op0) != VOIDmode
  127. && GET_MODE (op0) != insn_operand_mode[(int) binoptab[(int) mode].insn_code][1])
  128. op0 = convert_to_mode (insn_operand_mode[(int) binoptab[(int) mode].insn_code][1], op0);
  129. if (GET_MODE (op1) != VOIDmode
  130. && GET_MODE (op1) != insn_operand_mode[(int) binoptab[(int) mode].insn_code][2])
  131. op1 = convert_to_mode (insn_operand_mode[(int) binoptab[(int) mode].insn_code][2], op1);
  132. emit_insn (GEN_FCN (binoptab[(int) mode].insn_code) (temp, op0, op1));
  133. return temp;
  134. }
  135. /* Otherwise, do it with a two-operand insn
  136. plus a move insn if the target is not an operand. */
  137. /* It can't be open-coded in this mode.
  138. Use a library call if one is available and caller says that's ok. */
  139. if (binoptab[(int) mode].lib_call
  140. && (methods == OPTAB_LIB || methods == OPTAB_LIB_WIDEN))
  141. {
  142. emit_library_call (gen_rtx (SYMBOL_REF, Pmode,
  143. binoptab[(int) mode].lib_call),
  144. 2, op0, mode, op1, mode);
  145. target = temp = function_value (mode);
  146. return temp;
  147. }
  148. /* It can't be done in this mode. Can we do it in a wider mode? */
  149. if (! (methods == OPTAB_WIDEN || methods == OPTAB_LIB_WIDEN))
  150. return 0; /* Caller says, don't even try. */
  151. /* Compute the value of METHODS to pass to recursive calls.
  152. Don't allow widening to be tried recursively. */
  153. methods = (methods == OPTAB_LIB_WIDEN ? OPTAB_LIB : OPTAB_DIRECT);
  154. if ((mode == HImode || mode == QImode)
  155. && (binoptab[(int) SImode].insn_code != CODE_FOR_nothing
  156. || (methods == OPTAB_LIB && binoptab[(int) SImode].lib_call)))
  157. {
  158. temp = gen_reg_rtx (SImode);
  159. convert_move (temp, op0, unsignedp);
  160. op0 = temp;
  161. temp = gen_reg_rtx (SImode);
  162. convert_move (temp, op1, unsignedp);
  163. op1 = temp;
  164. target = expand_binop (SImode, binoptab, op0, op1, 0,
  165. unsignedp, methods);
  166. return gen_lowpart (mode, target);
  167. }
  168. if ((mode == HImode || mode == QImode || mode == SImode)
  169. && (binoptab[(int) DImode].insn_code != CODE_FOR_nothing
  170. || (methods == OPTAB_LIB && binoptab[(int) DImode].lib_call)))
  171. {
  172. temp = gen_reg_rtx (DImode);
  173. convert_move (temp, op0, unsignedp);
  174. op0 = temp;
  175. temp = gen_reg_rtx (DImode);
  176. convert_move (temp, op1, unsignedp);
  177. op1 = temp;
  178. target = expand_binop (DImode, binoptab, op0, op1, 0,
  179. unsignedp, methods);
  180. return gen_lowpart (mode, target);
  181. }
  182. if (mode == SFmode
  183. && (binoptab[(int) DFmode].insn_code != CODE_FOR_nothing
  184. || (methods == OPTAB_LIB && binoptab[(int) DFmode].lib_call)))
  185. {
  186. temp = gen_reg_rtx (DFmode);
  187. convert_move (temp, op0, 0);
  188. op0 = temp;
  189. temp = gen_reg_rtx (DFmode);
  190. convert_move (temp, op1, 0);
  191. op1 = temp;
  192. temp = expand_binop (DFmode, binoptab, op0, op1, 0, 0, methods);
  193. if (target == 0)
  194. target = gen_reg_rtx (SFmode);
  195. convert_move (target, temp, 0);
  196. return target;
  197. }
  198. return 0;
  199. }
  200. /* Generate code to perform an operation specified by BINOPTAB
  201. on operands OP0 and OP1, with two results to TARG1 and TARG2.
  202. We assume that the order of the operands for the instruction
  203. is TARG0, OP0, OP1, TARG1, which would fit a pattern like
  204. [(set TARG0 (operate OP0 OP1)) (set TARG1 (operate ...))].
  205. Either TARG0 or TARG1 may be zero, but what that means is that
  206. that result is not actually wanted. We will generate it into
  207. a dummy pseudo-reg and discard it. They may not both be zero.
  208. Returns 1 if this operation can be performed; 0 if not. */
  209. int
  210. expand_twoval_binop (binoptab, op0, op1, targ0, targ1, unsignedp)
  211. optab binoptab;
  212. rtx op0, op1;
  213. rtx targ0, targ1;
  214. int unsignedp;
  215. {
  216. register rtx temp;
  217. enum machine_mode mode = GET_MODE (targ0 ? targ0 : targ1);
  218. op0 = protect_from_queue (op0, 0);
  219. op1 = protect_from_queue (op1, 0);
  220. if (force_mem)
  221. {
  222. op0 = force_not_mem (op0);
  223. op1 = force_not_mem (op1);
  224. }
  225. if (targ0)
  226. targ0 = protect_from_queue (targ0, 1);
  227. else
  228. targ0 = gen_reg_rtx (mode);
  229. if (targ1)
  230. targ1 = protect_from_queue (targ1, 1);
  231. else
  232. targ1 = gen_reg_rtx (mode);
  233. if (binoptab[(int) mode].insn_code != CODE_FOR_nothing)
  234. {
  235. emit_insn (GEN_FCN (binoptab[(int) mode].insn_code)
  236. (targ0, op0, op1, targ1));
  237. return 1;
  238. }
  239. /* It can't be done in this mode. Can we do it in a wider mode? */
  240. if ((mode == HImode || mode == QImode)
  241. && binoptab[(int) SImode].insn_code != CODE_FOR_nothing)
  242. {
  243. expand_twoval_binop_convert (binoptab, SImode, op0, op1,
  244. targ0, targ1, unsignedp);
  245. return 1;
  246. }
  247. if ((mode == HImode || mode == QImode || mode == SImode)
  248. && binoptab[(int) DImode].insn_code != CODE_FOR_nothing)
  249. {
  250. expand_twoval_binop_convert (binoptab, DImode, op0, op1,
  251. targ0, targ1, unsignedp);
  252. return 1;
  253. }
  254. if (mode == SFmode && binoptab[(int) DFmode].insn_code != CODE_FOR_nothing)
  255. {
  256. expand_twoval_binop_convert (binoptab, DFmode, op0, op1,
  257. targ0, targ1, unsignedp);
  258. return 1;
  259. }
  260. return 0;
  261. }
  262. int
  263. expand_twoval_binop_convert (binoptab, mode, op0, op1, targ0, targ1, unsignedp)
  264. register optab binoptab;
  265. register rtx op0, op1, targ0, targ1;
  266. int unsignedp;
  267. {
  268. register rtx t0 = gen_reg_rtx (SImode);
  269. register rtx t1 = gen_reg_rtx (SImode);
  270. register rtx temp;
  271. temp = gen_reg_rtx (SImode);
  272. convert_move (temp, op0, unsignedp);
  273. op0 = temp;
  274. temp = gen_reg_rtx (SImode);
  275. convert_move (temp, op1, unsignedp);
  276. op1 = temp;
  277. expand_twoval_binop (binoptab, op0, op1, t0, t1, unsignedp);
  278. convert_move (targ0, t0, unsignedp);
  279. convert_move (targ1, t1, unsignedp);
  280. return 1;
  281. }
  282. /* Generate code to perform an operation specified by UNOPTAB
  283. on operand OP0, with result having machine-mode MODE.
  284. UNSIGNEDP is for the case where we have to widen the operands
  285. to perform the operation. It says to use zero-extension.
  286. If TARGET is nonzero, the value
  287. is generated there, if it is convenient to do so.
  288. In all cases an rtx is returned for the locus of the value;
  289. this may or may not be TARGET. */
  290. rtx
  291. expand_unop (mode, unoptab, op0, target, unsignedp)
  292. enum machine_mode mode;
  293. optab unoptab;
  294. rtx op0;
  295. rtx target;
  296. int unsignedp;
  297. {
  298. register rtx temp;
  299. op0 = protect_from_queue (op0, 0);
  300. if (force_mem)
  301. {
  302. op0 = force_not_mem (op0);
  303. }
  304. if (target)
  305. target = protect_from_queue (target, 1);
  306. if (unoptab[(int) mode].insn_code != CODE_FOR_nothing)
  307. {
  308. if (target)
  309. temp = target;
  310. else
  311. temp = gen_reg_rtx (mode);
  312. if (GET_MODE (op0) != VOIDmode
  313. && GET_MODE (op0) != insn_operand_mode[(int) unoptab[(int) mode].insn_code][1])
  314. op0 = convert_to_mode (insn_operand_mode[(int) unoptab[(int) mode].insn_code][1], op0);
  315. emit_insn (GEN_FCN (unoptab[(int) mode].insn_code) (temp, op0));
  316. return temp;
  317. }
  318. else if (unoptab[(int) mode].lib_call)
  319. {
  320. emit_library_call (gen_rtx (SYMBOL_REF, Pmode,
  321. unoptab[(int) mode].lib_call),
  322. 1, op0, mode);
  323. target = temp = function_value (mode);
  324. return temp;
  325. }
  326. /* It can't be done in this mode. Can we do it in a wider mode? */
  327. if ((mode == HImode || mode == QImode)
  328. && (unoptab[(int) SImode].insn_code != CODE_FOR_nothing
  329. || unoptab[(int) SImode].lib_call))
  330. {
  331. temp = gen_reg_rtx (SImode);
  332. convert_move (temp, op0, unsignedp);
  333. op0 = temp;
  334. target = expand_unop (SImode, unoptab, op0, 0, unsignedp);
  335. return gen_lowpart (mode, target);
  336. }
  337. if ((mode == HImode || mode == QImode || mode == SImode)
  338. && (unoptab[(int) DImode].insn_code != CODE_FOR_nothing
  339. || unoptab[(int) DImode].lib_call))
  340. {
  341. temp = gen_reg_rtx (DImode);
  342. convert_move (temp, op0, unsignedp);
  343. op0 = temp;
  344. target = expand_unop (DImode, unoptab, op0, unsignedp);
  345. return gen_lowpart (mode, target);
  346. }
  347. if (mode == SFmode
  348. && (unoptab[(int) DFmode].insn_code != CODE_FOR_nothing
  349. || unoptab[(int) DFmode].lib_call))
  350. {
  351. temp = gen_reg_rtx (DFmode);
  352. convert_move (temp, op0, 0);
  353. op0 = temp;
  354. temp = expand_unop (DFmode, unoptab, op0, 0, 0);
  355. if (target == 0)
  356. target = gen_reg_rtx (SFmode);
  357. convert_move (target, temp, 0);
  358. return target;
  359. }
  360. return 0;
  361. }
  362. /* Generate code to store zero in X. */
  363. void
  364. emit_clr_insn (x)
  365. rtx x;
  366. {
  367. emit_move_insn (x, const0_rtx);
  368. }
  369. /* Generate code to store 1 in X
  370. assuming it contains zero beforehand. */
  371. void
  372. emit_0_to_1_insn (x)
  373. rtx x;
  374. {
  375. emit_move_insn (x, const1_rtx);
  376. }
  377. /* Generate code to compare X with Y
  378. so that the condition codes are set.
  379. If they have mode BLKmode, then SIZE specifies the size of block. */
  380. void
  381. emit_cmp_insn (x, y, size, unsignedp)
  382. rtx x, y;
  383. rtx size;
  384. int unsignedp;
  385. {
  386. enum machine_mode mode = GET_MODE (x);
  387. if (mode == VOIDmode) mode = GET_MODE (y);
  388. /* They could both be VOIDmode if both args are immediate constants,
  389. but we should fold that at an earlier stage.
  390. With no special code here, this will call abort,
  391. reminding the programmer to implement such folding. */
  392. emit_queue ();
  393. x = protect_from_queue (x, 0);
  394. y = protect_from_queue (y, 0);
  395. if (mode != BLKmode && force_mem)
  396. {
  397. x = force_not_mem (x);
  398. y = force_not_mem (y);
  399. }
  400. if (mode == BLKmode)
  401. {
  402. if (size == 0)
  403. abort ();
  404. #ifdef HAVE_cmpstrsi
  405. if (HAVE_cmpstrsi)
  406. emit_insn (gen_cmpstr (x, y, convert_to_mode (SImode, size)));
  407. else
  408. #else
  409. {
  410. emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcmp"),
  411. 3, x, Pmode, y, Pmode, size, Pmode);
  412. emit_cmp_insn (hard_function_value (SImode), const0_rtx, 0, 0);
  413. }
  414. #endif
  415. }
  416. else if ((y == const0_rtx || y == fconst0_rtx || y == dconst0_rtx)
  417. && tst_optab[(int) mode].insn_code != CODE_FOR_nothing)
  418. emit_insn (GEN_FCN (tst_optab[(int) mode].insn_code) (x));
  419. else if (cmp_optab[(int) mode].insn_code != CODE_FOR_nothing)
  420. emit_insn (GEN_FCN (cmp_optab[(int) mode].insn_code) (x, y));
  421. else if ((mode == QImode || mode == HImode)
  422. && cmp_optab[(int) SImode].insn_code != CODE_FOR_nothing)
  423. {
  424. x = convert_to_mode (SImode, x, unsignedp);
  425. y = convert_to_mode (SImode, y, unsignedp);
  426. emit_cmp_insn (x, y, 0, unsignedp);
  427. }
  428. else if ((mode == QImode || mode == HImode || mode == SImode)
  429. && cmp_optab[(int) DImode].insn_code != CODE_FOR_nothing)
  430. {
  431. x = convert_to_mode (DImode, x, unsignedp);
  432. y = convert_to_mode (DImode, y, unsignedp);
  433. emit_cmp_insn (x, y, 0, unsignedp);
  434. }
  435. else if (mode == SFmode
  436. && cmp_optab[(int) DFmode].insn_code != CODE_FOR_nothing)
  437. {
  438. x = convert_to_mode (DFmode, x, unsignedp);
  439. y = convert_to_mode (DFmode, y, unsignedp);
  440. emit_cmp_insn (x, y, 0, unsignedp);
  441. }
  442. else if (cmp_optab[(int) mode].lib_call)
  443. {
  444. emit_library_call (gen_rtx (SYMBOL_REF, Pmode,
  445. cmp_optab[(int) mode].lib_call),
  446. 2, x, mode, y, mode);
  447. emit_cmp_insn (hard_function_value (SImode), const0_rtx, 0, 0);
  448. }
  449. else if ((mode == QImode || mode == HImode)
  450. && (cmp_optab[(int) SImode].insn_code != CODE_FOR_nothing
  451. || cmp_optab[(int) SImode].lib_call != 0))
  452. {
  453. x = convert_to_mode (SImode, x, unsignedp);
  454. y = convert_to_mode (SImode, y, unsignedp);
  455. emit_cmp_insn (x, y, 0, unsignedp);
  456. }
  457. else if ((mode == QImode || mode == HImode || mode == SImode)
  458. && (cmp_optab[(int) DImode].insn_code != CODE_FOR_nothing
  459. || cmp_optab[(int) DImode].lib_call != 0))
  460. {
  461. x = convert_to_mode (DImode, x, unsignedp);
  462. y = convert_to_mode (DImode, y, unsignedp);
  463. emit_cmp_insn (x, y, 0, unsignedp);
  464. }
  465. else if (mode == SFmode
  466. && (cmp_optab[(int) DFmode].insn_code != CODE_FOR_nothing
  467. || cmp_optab[(int) DFmode].lib_call != 0))
  468. {
  469. x = convert_to_mode (DFmode, x, unsignedp);
  470. y = convert_to_mode (DFmode, y, unsignedp);
  471. emit_cmp_insn (x, y, 0, unsignedp);
  472. }
  473. else
  474. abort ();
  475. }
  476. /* Generate code to compare X with zero
  477. so that the condition codes are set. */
  478. void
  479. emit_tst_insn (x)
  480. rtx x;
  481. {
  482. enum machine_mode mode = GET_MODE (x);
  483. emit_queue ();
  484. x = protect_from_queue (x, 0);
  485. if (tst_optab[(int) mode].insn_code != CODE_FOR_nothing)
  486. emit_insn (GEN_FCN (tst_optab[(int) mode].insn_code) (x));
  487. else if (cmp_optab[(int) mode].lib_call)
  488. {
  489. emit_library_call (gen_rtx (SYMBOL_REF, Pmode,
  490. cmp_optab[(int) mode].lib_call),
  491. 2, x, mode, const0_rtx, mode);
  492. emit_cmp_insn (hard_function_value (SImode), const0_rtx, 0, 0);
  493. }
  494. else
  495. abort ();
  496. }
  497. /* These three functions generate an insn body and return it
  498. rather than emitting the insn.
  499. They do not protect from queued increments,
  500. because they may be used 1) in protect_from_queue itself
  501. and 2) in other passes where there is no queue. */
  502. /* Generate and return an insn body to add Y to X. */
  503. rtx
  504. gen_add2_insn (x, y)
  505. rtx x, y;
  506. {
  507. return (GEN_FCN (add_optab[(int) GET_MODE (x)].insn_code)
  508. (x, copy_rtx (x), y));
  509. }
  510. /* Generate and return an insn body to subtract Y from X. */
  511. rtx
  512. gen_sub2_insn (x, y)
  513. rtx x, y;
  514. {
  515. return (GEN_FCN (sub_optab[(int) GET_MODE (x)].insn_code)
  516. (x, copy_rtx (x), y));
  517. }
  518. /* Generate the body of an instruction to copy Y into X. */
  519. rtx
  520. gen_move_insn (x, y)
  521. rtx x, y;
  522. {
  523. return (GEN_FCN (mov_optab[(int) GET_MODE (x)].insn_code) (x, y));
  524. }
  525. /* can_fix_p and can_float_p say whether the target machine
  526. can directly convert a given fixed point type to
  527. a given floating point type, or vice versa. */
  528. static rtxfun fixtab[2][2];
  529. static rtxfun floattab[2][2];
  530. rtxfun
  531. can_fix_p (fixmode, fltmode)
  532. enum machine_mode fltmode, fixmode;
  533. {
  534. return fixtab[fltmode != SFmode][fixmode != SImode];
  535. }
  536. rtxfun
  537. can_float_p (fltmode, fixmode)
  538. enum machine_mode fixmode, fltmode;
  539. {
  540. return floattab[fltmode != SFmode][fixmode != SImode];
  541. }
  542. void
  543. init_fixtab ()
  544. {
  545. #ifdef HAVE_fixsfsi2
  546. if (HAVE_fixsfsi2)
  547. fixtab[0][0] = gen_fixsfsi2;
  548. #endif
  549. #ifdef HAVE_fixsfdi2
  550. if (HAVE_fixsfdi2)
  551. fixtab[0][1] = gen_fixsfdi2;
  552. #endif
  553. #ifdef HAVE_fixdfsi2
  554. if (HAVE_fixdfsi2)
  555. fixtab[1][0] = gen_fixdfsi2;
  556. #endif
  557. #ifdef HAVE_fixdfdi2
  558. if (HAVE_fixdfdi2)
  559. fixtab[1][1] = gen_fixdfdi2;
  560. #endif
  561. }
  562. void
  563. init_floattab ()
  564. {
  565. #ifdef HAVE_floatsisf2
  566. if (HAVE_floatsisf2)
  567. floattab[0][0] = gen_floatsisf2;
  568. #endif
  569. #ifdef HAVE_floatdisf2
  570. if (HAVE_floatdisf2)
  571. floattab[0][1] = gen_floatdisf2;
  572. #endif
  573. #ifdef HAVE_floatsidf2
  574. if (HAVE_floatsidf2)
  575. floattab[1][0] = gen_floatsidf2;
  576. #endif
  577. #ifdef HAVE_floatdidf2
  578. if (HAVE_floatdidf2)
  579. floattab[1][1] = gen_floatdidf2;
  580. #endif
  581. }
  582. /* Generate code to convert FROM to floating point
  583. and store in TO. FROM must be fixed point. */
  584. void
  585. expand_float (to, from)
  586. rtx to, from;
  587. {
  588. register rtxfun fun;
  589. register rtx target;
  590. to = protect_from_queue (to, 1);
  591. from = protect_from_queue (from, 0);
  592. if (force_mem)
  593. {
  594. from = force_not_mem (from);
  595. }
  596. if (fun = can_float_p (GET_MODE (to), GET_MODE (from)))
  597. {
  598. emit_insn ((*fun) (to, from));
  599. return;
  600. }
  601. if (GET_MODE (to) == SFmode && (fun = can_float_p (GET_MODE (from), DFmode)))
  602. {
  603. register rtx temp = gen_reg_rtx (DFmode);
  604. emit_insn ((*fun) (temp, from));
  605. convert_move (to, temp, 0);
  606. return;
  607. }
  608. if (GET_MODE (from) != DImode)
  609. {
  610. register rtx tem = gen_reg_rtx (DImode);
  611. convert_move (tem, from, 0);
  612. from = tem;
  613. }
  614. if (fun = can_float_p (GET_MODE (to), GET_MODE (from)))
  615. {
  616. emit_insn ((*fun) (to, from));
  617. return;
  618. }
  619. if (fun = can_float_p (DFmode, DImode))
  620. {
  621. target = gen_reg_rtx (DFmode);
  622. emit_insn ((*fun) (target, from));
  623. }
  624. else
  625. {
  626. emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "floatdidf"),
  627. 1, from, DImode);
  628. target = function_value (DFmode);
  629. }
  630. if (GET_MODE (to) == DFmode)
  631. emit_move_insn (to, target);
  632. else
  633. convert_move (to, target, 0);
  634. }
  635. /* Generate code to convert FROM to fixed point
  636. and store in TO. FROM must be floating point. */
  637. void
  638. expand_fix (to, from)
  639. register rtx to, from;
  640. {
  641. register rtxfun fun;
  642. register rtx target;
  643. to = protect_from_queue (to, 1);
  644. from = protect_from_queue (from, 0);
  645. if (force_mem)
  646. {
  647. from = force_not_mem (from);
  648. }
  649. if (fun = can_fix_p (GET_MODE (to), GET_MODE (from)))
  650. {
  651. emit_insn ((*fun) (to, from));
  652. return;
  653. }
  654. if (GET_MODE (to) == SImode && (fun = can_fix_p (DImode, GET_MODE (from))))
  655. {
  656. register rtx temp = gen_reg_rtx (DImode);
  657. emit_insn ((*fun) (temp, from));
  658. convert_move (to, temp, 0);
  659. return;
  660. }
  661. if (GET_MODE (from) != DFmode)
  662. {
  663. register rtx tem = gen_reg_rtx (DFmode);
  664. convert_move (tem, from, 0);
  665. from = tem;
  666. }
  667. if (fun = can_fix_p (GET_MODE (to), GET_MODE (from)))
  668. {
  669. emit_insn ((*fun) (to, from));
  670. return;
  671. }
  672. if (fun = can_fix_p (DImode, DFmode))
  673. {
  674. target = gen_reg_rtx (DImode);
  675. emit_insn ((*fun) (target, from));
  676. }
  677. else
  678. {
  679. emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "fixdfdi"),
  680. 1, from, DFmode);
  681. target = function_value (DImode);
  682. }
  683. if (GET_MODE (to) == DImode)
  684. emit_move_insn (to, target);
  685. else
  686. convert_move (to, target, 0);
  687. }
  688. static void
  689. blank_optab (op)
  690. optab op;
  691. {
  692. int i;
  693. for (i = 0; i < NUM_MACHINE_MODES; i++)
  694. op[i].insn_code = CODE_FOR_nothing;
  695. }
  696. /* Call this once to initialize the contents of the optabs
  697. appropriately for the current target machine. */
  698. void
  699. init_optabs ()
  700. {
  701. init_fixtab ();
  702. init_floattab ();
  703. init_comparisons ();
  704. blank_optab (add_optab);
  705. blank_optab (sub_optab);
  706. blank_optab (smul_optab);
  707. blank_optab (umul_optab);
  708. blank_optab (smul_widen_optab);
  709. blank_optab (umul_widen_optab);
  710. blank_optab (sdiv_optab);
  711. blank_optab (sdivmod_optab);
  712. blank_optab (udiv_optab);
  713. blank_optab (udivmod_optab);
  714. blank_optab (smod_optab);
  715. blank_optab (umod_optab);
  716. blank_optab (flodiv_optab);
  717. blank_optab (and_optab);
  718. blank_optab (andcb_optab);
  719. blank_optab (ior_optab);
  720. blank_optab (xor_optab);
  721. blank_optab (ashl_optab);
  722. blank_optab (ashr_optab);
  723. blank_optab (lshl_optab);
  724. blank_optab (lshr_optab);
  725. blank_optab (rotl_optab);
  726. blank_optab (rotr_optab);
  727. blank_optab (mov_optab);
  728. blank_optab (movstrict_optab);
  729. blank_optab (cmp_optab);
  730. blank_optab (tst_optab);
  731. blank_optab (neg_optab);
  732. blank_optab (abs_optab);
  733. blank_optab (one_cmpl_optab);
  734. #ifdef HAVE_addqi3
  735. if (HAVE_addqi3)
  736. add_optab[(int) QImode].insn_code = CODE_FOR_addqi3;
  737. #endif
  738. #ifdef HAVE_addhi3
  739. if (HAVE_addhi3)
  740. add_optab[(int) HImode].insn_code = CODE_FOR_addhi3;
  741. #endif
  742. #ifdef HAVE_addsi3
  743. if (HAVE_addsi3)
  744. add_optab[(int) SImode].insn_code = CODE_FOR_addsi3;
  745. #endif
  746. #ifdef HAVE_adddi3
  747. if (HAVE_adddi3)
  748. add_optab[(int) DImode].insn_code = CODE_FOR_adddi3;
  749. #endif
  750. #ifdef HAVE_addsf3
  751. if (HAVE_addsf3)
  752. add_optab[(int) SFmode].insn_code = CODE_FOR_addsf3;
  753. #endif
  754. #ifdef HAVE_adddf3
  755. if (HAVE_adddf3)
  756. add_optab[(int) DFmode].insn_code = CODE_FOR_adddf3;
  757. #endif
  758. add_optab[(int) DImode].lib_call = "adddi3";
  759. add_optab[(int) SFmode].lib_call = "addsf3";
  760. add_optab[(int) DFmode].lib_call = "adddf3";
  761. #ifdef HAVE_subqi3
  762. if (HAVE_subqi3)
  763. sub_optab[(int) QImode].insn_code = CODE_FOR_subqi3;
  764. #endif
  765. #ifdef HAVE_subhi3
  766. if (HAVE_subhi3)
  767. sub_optab[(int) HImode].insn_code = CODE_FOR_subhi3;
  768. #endif
  769. #ifdef HAVE_subsi3
  770. if (HAVE_subsi3)
  771. sub_optab[(int) SImode].insn_code = CODE_FOR_subsi3;
  772. #endif
  773. #ifdef HAVE_subdi3
  774. if (HAVE_subdi3)
  775. sub_optab[(int) DImode].insn_code = CODE_FOR_subdi3;
  776. #endif
  777. #ifdef HAVE_subsf3
  778. if (HAVE_subsf3)
  779. sub_optab[(int) SFmode].insn_code = CODE_FOR_subsf3;
  780. #endif
  781. #ifdef HAVE_subdf3
  782. if (HAVE_subdf3)
  783. sub_optab[(int) DFmode].insn_code = CODE_FOR_subdf3;
  784. #endif
  785. sub_optab[(int) DImode].lib_call = "subdi3";
  786. sub_optab[(int) SFmode].lib_call = "subsf3";
  787. sub_optab[(int) DFmode].lib_call = "subdf3";
  788. #ifdef HAVE_mulqi3
  789. if (HAVE_mulqi3)
  790. smul_optab[(int) QImode].insn_code = CODE_FOR_mulqi3;
  791. #endif
  792. #ifdef HAVE_mulhi3
  793. if (HAVE_mulhi3)
  794. smul_optab[(int) HImode].insn_code = CODE_FOR_mulhi3;
  795. #endif
  796. #ifdef HAVE_mulsi3
  797. if (HAVE_mulsi3)
  798. smul_optab[(int) SImode].insn_code = CODE_FOR_mulsi3;
  799. #endif
  800. #ifdef HAVE_muldi3
  801. if (HAVE_muldi3)
  802. smul_optab[(int) DImode].insn_code = CODE_FOR_muldi3;
  803. #endif
  804. #ifdef HAVE_mulsf3
  805. if (HAVE_mulsf3)
  806. smul_optab[(int) SFmode].insn_code = CODE_FOR_mulsf3;
  807. #endif
  808. #ifdef HAVE_muldf3
  809. if (HAVE_muldf3)
  810. smul_optab[(int) DFmode].insn_code = CODE_FOR_muldf3;
  811. #endif
  812. smul_optab[(int) SImode].lib_call = "mulsi3";
  813. smul_optab[(int) DImode].lib_call = "muldi3";
  814. smul_optab[(int) SFmode].lib_call = "mulsf3";
  815. smul_optab[(int) DFmode].lib_call = "muldf3";
  816. #ifdef HAVE_mulqihi3
  817. if (HAVE_mulqihi3)
  818. smul_widen_optab[(int) HImode].insn_code = CODE_FOR_mulqihi3;
  819. #endif
  820. #ifdef HAVE_mulhisi3
  821. if (HAVE_mulhisi3)
  822. smul_widen_optab[(int) SImode].insn_code = CODE_FOR_mulhisi3;
  823. #endif
  824. #ifdef HAVE_mulsidi3
  825. if (HAVE_mulsidi3)
  826. smul_widen_optab[(int) DImode].insn_code = CODE_FOR_mulsidi3;
  827. #endif
  828. #ifdef HAVE_umulqi3
  829. if (HAVE_umulqi3)
  830. umul_optab[(int) QImode].insn_code = CODE_FOR_umulqi3;
  831. #endif
  832. #ifdef HAVE_umulhi3
  833. if (HAVE_umulhi3)
  834. umul_optab[(int) HImode].insn_code = CODE_FOR_umulhi3;
  835. #endif
  836. #ifdef HAVE_umulsi3
  837. if (HAVE_umulsi3)
  838. umul_optab[(int) SImode].insn_code = CODE_FOR_umulsi3;
  839. #endif
  840. #ifdef HAVE_umuldi3
  841. if (HAVE_umuldi3)
  842. umul_optab[(int) DImode].insn_code = CODE_FOR_umuldi3;
  843. #endif
  844. #ifdef HAVE_umulsf3
  845. if (HAVE_umulsf3)
  846. umul_optab[(int) SFmode].insn_code = CODE_FOR_umulsf3;
  847. #endif
  848. #ifdef HAVE_umuldf3
  849. if (HAVE_umuldf3)
  850. umul_optab[(int) DFmode].insn_code = CODE_FOR_umuldf3;
  851. #endif
  852. umul_optab[(int) SImode].lib_call = "umulsi3";
  853. umul_optab[(int) DImode].lib_call = "umuldi3";
  854. umul_optab[(int) SFmode].lib_call = "umulsf3";
  855. umul_optab[(int) DFmode].lib_call = "umuldf3";
  856. #ifdef HAVE_umulqihi3
  857. if (HAVE_umulqihi3)
  858. umul_widen_optab[(int) HImode].insn_code = CODE_FOR_umulqihi3;
  859. #endif
  860. #ifdef HAVE_umulhisi3
  861. if (HAVE_umulhisi3)
  862. umul_widen_optab[(int) SImode].insn_code = CODE_FOR_umulhisi3;
  863. #endif
  864. #ifdef HAVE_umulsidi3
  865. if (HAVE_umulsidi3)
  866. umul_widen_optab[(int) DImode].insn_code = CODE_FOR_umulsidi3;
  867. #endif
  868. #ifdef HAVE_divqi3
  869. if (HAVE_divqi3)
  870. sdiv_optab[(int) QImode].insn_code = CODE_FOR_divqi3;
  871. #endif
  872. #ifdef HAVE_divhi3
  873. if (HAVE_divhi3)
  874. sdiv_optab[(int) HImode].insn_code = CODE_FOR_divhi3;
  875. #endif
  876. #ifdef HAVE_divsi3
  877. if (HAVE_divsi3)
  878. sdiv_optab[(int) SImode].insn_code = CODE_FOR_divsi3;
  879. #endif
  880. #ifdef HAVE_divdi3
  881. if (HAVE_divdi3)
  882. sdiv_optab[(int) DImode].insn_code = CODE_FOR_divdi3;
  883. #endif
  884. sdiv_optab[(int) SImode].lib_call = "divsi3";
  885. sdiv_optab[(int) DImode].lib_call = "divdi3";
  886. #ifdef HAVE_udivqi3
  887. if (HAVE_udivqi3)
  888. udiv_optab[(int) QImode].insn_code = CODE_FOR_udivqi3;
  889. #endif
  890. #ifdef HAVE_udivhi3
  891. if (HAVE_udivhi3)
  892. udiv_optab[(int) HImode].insn_code = CODE_FOR_udivhi3;
  893. #endif
  894. #ifdef HAVE_udivsi3
  895. if (HAVE_udivsi3)
  896. udiv_optab[(int) SImode].insn_code = CODE_FOR_udivsi3;
  897. #endif
  898. #ifdef HAVE_udivdi3
  899. if (HAVE_udivdi3)
  900. udiv_optab[(int) DImode].insn_code = CODE_FOR_udivdi3;
  901. #endif
  902. udiv_optab[(int) SImode].lib_call = "udivsi3";
  903. udiv_optab[(int) DImode].lib_call = "udivdi3";
  904. #ifdef HAVE_divmodqi4
  905. if (HAVE_divmodqi4)
  906. sdivmod_optab[(int) QImode].insn_code = CODE_FOR_divmodqi4;
  907. #endif
  908. #ifdef HAVE_divmodhi4
  909. if (HAVE_divmodhi4)
  910. sdivmod_optab[(int) HImode].insn_code = CODE_FOR_divmodhi4;
  911. #endif
  912. #ifdef HAVE_divmodsi4
  913. if (HAVE_divmodsi4)
  914. sdivmod_optab[(int) SImode].insn_code = CODE_FOR_divmodsi4;
  915. #endif
  916. #ifdef HAVE_divmoddi4
  917. if (HAVE_divmoddi4)
  918. sdivmod_optab[(int) DImode].insn_code = CODE_FOR_divmoddi4;
  919. #endif
  920. #ifdef HAVE_udivmodqi4
  921. if (HAVE_udivmodqi4)
  922. udivmod_optab[(int) QImode].insn_code = CODE_FOR_udivmodqi4;
  923. #endif
  924. #ifdef HAVE_udivmodhi4
  925. if (HAVE_udivmodhi4)
  926. udivmod_optab[(int) HImode].insn_code = CODE_FOR_udivmodhi4;
  927. #endif
  928. #ifdef HAVE_udivmodsi4
  929. if (HAVE_udivmodsi4)
  930. udivmod_optab[(int) SImode].insn_code = CODE_FOR_udivmodsi4;
  931. #endif
  932. #ifdef HAVE_udivmoddi4
  933. if (HAVE_udivmoddi4)
  934. udivmod_optab[(int) DImode].insn_code = CODE_FOR_udivmoddi4;
  935. #endif
  936. #ifdef HAVE_modqi3
  937. if (HAVE_modqi3)
  938. smod_optab[(int) QImode].insn_code = CODE_FOR_modqi3;
  939. #endif
  940. #ifdef HAVE_modhi3
  941. if (HAVE_modhi3)
  942. smod_optab[(int) HImode].insn_code = CODE_FOR_modhi3;
  943. #endif
  944. #ifdef HAVE_modsi3
  945. if (HAVE_modsi3)
  946. smod_optab[(int) SImode].insn_code = CODE_FOR_modsi3;
  947. #endif
  948. #ifdef HAVE_moddi3
  949. if (HAVE_moddi3)
  950. smod_optab[(int) DImode].insn_code = CODE_FOR_moddi3;
  951. #endif
  952. smod_optab[(int) SImode].lib_call = "modsi3";
  953. smod_optab[(int) DImode].lib_call = "moddi3";
  954. #ifdef HAVE_umodqi3
  955. if (HAVE_umodqi3)
  956. umod_optab[(int) QImode].insn_code = CODE_FOR_umodqi3;
  957. #endif
  958. #ifdef HAVE_umodhi3
  959. if (HAVE_umodhi3)
  960. umod_optab[(int) HImode].insn_code = CODE_FOR_umodhi3;
  961. #endif
  962. #ifdef HAVE_umodsi3
  963. if (HAVE_umodsi3)
  964. umod_optab[(int) SImode].insn_code = CODE_FOR_umodsi3;
  965. #endif
  966. #ifdef HAVE_umoddi3
  967. if (HAVE_umoddi3)
  968. umod_optab[(int) DImode].insn_code = CODE_FOR_umoddi3;
  969. #endif
  970. umod_optab[(int) SImode].lib_call = "umodsi3";
  971. umod_optab[(int) DImode].lib_call = "umoddi3";
  972. #ifdef HAVE_divsf3
  973. if (HAVE_divsf3)
  974. flodiv_optab[(int) SFmode].insn_code = CODE_FOR_divsf3;
  975. #endif
  976. #ifdef HAVE_divdf3
  977. if (HAVE_divdf3)
  978. flodiv_optab[(int) DFmode].insn_code = CODE_FOR_divdf3;
  979. #endif
  980. flodiv_optab[(int) SFmode].lib_call = "divsf3";
  981. flodiv_optab[(int) DFmode].lib_call = "divdf3";
  982. #ifdef HAVE_andqi3
  983. if (HAVE_andqi3)
  984. and_optab[(int) QImode].insn_code = CODE_FOR_andqi3;
  985. #endif
  986. #ifdef HAVE_andhi3
  987. if (HAVE_andhi3)
  988. and_optab[(int) HImode].insn_code = CODE_FOR_andhi3;
  989. #endif
  990. #ifdef HAVE_andsi3
  991. if (HAVE_andsi3)
  992. and_optab[(int) SImode].insn_code = CODE_FOR_andsi3;
  993. #endif
  994. and_optab[(int) DImode].lib_call = "anddi3";
  995. #ifdef HAVE_andcbqi3
  996. if (HAVE_andcbqi3)
  997. andcb_optab[(int) QImode].insn_code = CODE_FOR_andcbqi3;
  998. #endif
  999. #ifdef HAVE_andcbhi3
  1000. if (HAVE_andcbhi3)
  1001. andcb_optab[(int) HImode].insn_code = CODE_FOR_andcbhi3;
  1002. #endif
  1003. #ifdef HAVE_andcbsi3
  1004. if (HAVE_andcbsi3)
  1005. andcb_optab[(int) SImode].insn_code = CODE_FOR_andcbsi3;
  1006. #endif
  1007. andcb_optab[(int) DImode].lib_call = "andcbdi3";
  1008. #ifdef HAVE_iorqi3
  1009. if (HAVE_iorqi3)
  1010. ior_optab[(int) QImode].insn_code = CODE_FOR_iorqi3;
  1011. #endif
  1012. #ifdef HAVE_iorhi3
  1013. if (HAVE_iorhi3)
  1014. ior_optab[(int) HImode].insn_code = CODE_FOR_iorhi3;
  1015. #endif
  1016. #ifdef HAVE_iorsi3
  1017. if (HAVE_iorsi3)
  1018. ior_optab[(int) SImode].insn_code = CODE_FOR_iorsi3;
  1019. #endif
  1020. ior_optab[(int) DImode].lib_call = "iordi3";
  1021. #ifdef HAVE_xorqi3
  1022. if (HAVE_xorqi3)
  1023. xor_optab[(int) QImode].insn_code = CODE_FOR_xorqi3;
  1024. #endif
  1025. #ifdef HAVE_xorhi3
  1026. if (HAVE_xorhi3)
  1027. xor_optab[(int) HImode].insn_code = CODE_FOR_xorhi3;
  1028. #endif
  1029. #ifdef HAVE_xorsi3
  1030. if (HAVE_xorsi3)
  1031. xor_optab[(int) SImode].insn_code = CODE_FOR_xorsi3;
  1032. #endif
  1033. xor_optab[(int) DImode].lib_call = "xordi3";
  1034. #ifdef HAVE_ashlqi3
  1035. if (HAVE_ashlqi3)
  1036. ashl_optab[(int) QImode].insn_code = CODE_FOR_ashlqi3;
  1037. #endif
  1038. #ifdef HAVE_ashlhi3
  1039. if (HAVE_ashlhi3)
  1040. ashl_optab[(int) HImode].insn_code = CODE_FOR_ashlhi3;
  1041. #endif
  1042. #ifdef HAVE_ashlsi3
  1043. if (HAVE_ashlsi3)
  1044. ashl_optab[(int) SImode].insn_code = CODE_FOR_ashlsi3;
  1045. #endif
  1046. #ifdef HAVE_ashldi3
  1047. if (HAVE_ashldi3)
  1048. ashl_optab[(int) DImode].insn_code = CODE_FOR_ashldi3;
  1049. #endif
  1050. ashl_optab[(int) SImode].lib_call = "ashlsi3";
  1051. ashl_optab[(int) DImode].lib_call = "ashldi3";
  1052. #ifdef HAVE_ashrqi3
  1053. if (HAVE_ashrqi3)
  1054. ashr_optab[(int) QImode].insn_code = CODE_FOR_ashrqi3;
  1055. #endif
  1056. #ifdef HAVE_ashrhi3
  1057. if (HAVE_ashrhi3)
  1058. ashr_optab[(int) HImode].insn_code = CODE_FOR_ashrhi3;
  1059. #endif
  1060. #ifdef HAVE_ashrsi3
  1061. if (HAVE_ashrsi3)
  1062. ashr_optab[(int) SImode].insn_code = CODE_FOR_ashrsi3;
  1063. #endif
  1064. #ifdef HAVE_ashrdi3
  1065. if (HAVE_ashrdi3)
  1066. ashr_optab[(int) DImode].insn_code = CODE_FOR_ashrdi3;
  1067. #endif
  1068. ashr_optab[(int) SImode].lib_call = "ashrsi3";
  1069. ashr_optab[(int) DImode].lib_call = "ashrdi3";
  1070. #ifdef HAVE_lshlqi3
  1071. if (HAVE_lshlqi3)
  1072. lshl_optab[(int) QImode].insn_code = CODE_FOR_lshlqi3;
  1073. #endif
  1074. #ifdef HAVE_lshlhi3
  1075. if (HAVE_lshlhi3)
  1076. lshl_optab[(int) HImode].insn_code = CODE_FOR_lshlhi3;
  1077. #endif
  1078. #ifdef HAVE_lshlsi3
  1079. if (HAVE_lshlsi3)
  1080. lshl_optab[(int) SImode].insn_code = CODE_FOR_lshlsi3;
  1081. #endif
  1082. #ifdef HAVE_lshldi3
  1083. if (HAVE_lshldi3)
  1084. lshl_optab[(int) DImode].insn_code = CODE_FOR_lshldi3;
  1085. #endif
  1086. lshl_optab[(int) SImode].lib_call = "lshlsi3";
  1087. lshl_optab[(int) DImode].lib_call = "lshldi3";
  1088. #ifdef HAVE_lshrqi3
  1089. if (HAVE_lshrqi3)
  1090. lshr_optab[(int) QImode].insn_code = CODE_FOR_lshrqi3;
  1091. #endif
  1092. #ifdef HAVE_lshrhi3
  1093. if (HAVE_lshrhi3)
  1094. lshr_optab[(int) HImode].insn_code = CODE_FOR_lshrhi3;
  1095. #endif
  1096. #ifdef HAVE_lshrsi3
  1097. if (HAVE_lshrsi3)
  1098. lshr_optab[(int) SImode].insn_code = CODE_FOR_lshrsi3;
  1099. #endif
  1100. #ifdef HAVE_lshrdi3
  1101. if (HAVE_lshrdi3)
  1102. lshr_optab[(int) DImode].insn_code = CODE_FOR_lshrdi3;
  1103. #endif
  1104. lshr_optab[(int) SImode].lib_call = "lshrsi3";
  1105. lshr_optab[(int) DImode].lib_call = "lshrdi3";
  1106. #ifdef HAVE_rotlqi3
  1107. if (HAVE_rotlqi3)
  1108. rotl_optab[(int) QImode].insn_code = CODE_FOR_rotlqi3;
  1109. #endif
  1110. #ifdef HAVE_rotlhi3
  1111. if (HAVE_rotlhi3)
  1112. rotl_optab[(int) HImode].insn_code = CODE_FOR_rotlhi3;
  1113. #endif
  1114. #ifdef HAVE_rotlsi3
  1115. if (HAVE_rotlsi3)
  1116. rotl_optab[(int) SImode].insn_code = CODE_FOR_rotlsi3;
  1117. #endif
  1118. #ifdef HAVE_rotldi3
  1119. if (HAVE_rotldi3)
  1120. rotl_optab[(int) DImode].insn_code = CODE_FOR_rotldi3;
  1121. #endif
  1122. rotl_optab[(int) SImode].lib_call = "rotlsi3";
  1123. rotl_optab[(int) DImode].lib_call = "rotldi3";
  1124. #ifdef HAVE_rotrqi3
  1125. if (HAVE_rotrqi3)
  1126. rotr_optab[(int) QImode].insn_code = CODE_FOR_rotrqi3;
  1127. #endif
  1128. #ifdef HAVE_rotrhi3
  1129. if (HAVE_rotrhi3)
  1130. rotr_optab[(int) HImode].insn_code = CODE_FOR_rotrhi3;
  1131. #endif
  1132. #ifdef HAVE_rotrsi3
  1133. if (HAVE_rotrsi3)
  1134. rotr_optab[(int) SImode].insn_code = CODE_FOR_rotrsi3;
  1135. #endif
  1136. #ifdef HAVE_rotrdi3
  1137. if (HAVE_rotrdi3)
  1138. rotr_optab[(int) DImode].insn_code = CODE_FOR_rotrdi3;
  1139. #endif
  1140. rotr_optab[(int) SImode].lib_call = "rotrsi3";
  1141. rotr_optab[(int) DImode].lib_call = "rotrdi3";
  1142. #ifdef HAVE_negqi2
  1143. if (HAVE_negqi2)
  1144. neg_optab[(int) QImode].insn_code = CODE_FOR_negqi2;
  1145. #endif
  1146. #ifdef HAVE_neghi2
  1147. if (HAVE_neghi2)
  1148. neg_optab[(int) HImode].insn_code = CODE_FOR_neghi2;
  1149. #endif
  1150. #ifdef HAVE_negsi2
  1151. if (HAVE_negsi2)
  1152. neg_optab[(int) SImode].insn_code = CODE_FOR_negsi2;
  1153. #endif
  1154. #ifdef HAVE_negsf2
  1155. if (HAVE_negsf2)
  1156. neg_optab[(int) SFmode].insn_code = CODE_FOR_negsf2;
  1157. #endif
  1158. #ifdef HAVE_negdf2
  1159. if (HAVE_negdf2)
  1160. neg_optab[(int) DFmode].insn_code = CODE_FOR_negdf2;
  1161. #endif
  1162. neg_optab[(int) SImode].lib_call = "negsi2";
  1163. neg_optab[(int) DImode].lib_call = "negdi2";
  1164. neg_optab[(int) SFmode].lib_call = "negsf2";
  1165. neg_optab[(int) DFmode].lib_call = "negdf2";
  1166. #ifdef HAVE_absqi2
  1167. if (HAVE_absqi2)
  1168. abs_optab[(int) QImode].insn_code = CODE_FOR_absqi2;
  1169. #endif
  1170. #ifdef HAVE_abshi2
  1171. if (HAVE_abshi2)
  1172. abs_optab[(int) HImode].insn_code = CODE_FOR_abshi2;
  1173. #endif
  1174. #ifdef HAVE_abssi2
  1175. if (HAVE_abssi2)
  1176. abs_optab[(int) SImode].insn_code = CODE_FOR_abssi2;
  1177. #endif
  1178. #ifdef HAVE_abssf2
  1179. if (HAVE_abssf2)
  1180. abs_optab[(int) SFmode].insn_code = CODE_FOR_abssf2;
  1181. #endif
  1182. #ifdef HAVE_absdf2
  1183. if (HAVE_absdf2)
  1184. abs_optab[(int) DFmode].insn_code = CODE_FOR_absdf2;
  1185. #endif
  1186. /* No library calls here! If there is no abs instruction,
  1187. expand_expr will generate a conditional negation. */
  1188. #ifdef HAVE_one_cmplqi2
  1189. if (HAVE_one_cmplqi2)
  1190. one_cmpl_optab[(int) QImode].insn_code = CODE_FOR_one_cmplqi2;
  1191. #endif
  1192. #ifdef HAVE_one_cmplhi2
  1193. if (HAVE_one_cmplhi2)
  1194. one_cmpl_optab[(int) HImode].insn_code = CODE_FOR_one_cmplhi2;
  1195. #endif
  1196. #ifdef HAVE_one_cmplsi2
  1197. if (HAVE_one_cmplsi2)
  1198. one_cmpl_optab[(int) SImode].insn_code = CODE_FOR_one_cmplsi2;
  1199. #endif
  1200. one_cmpl_optab[(int) SImode].lib_call = "one_cmplsi2";
  1201. one_cmpl_optab[(int) DImode].lib_call = "one_cmpldi2";
  1202. #ifdef HAVE_movqi
  1203. if (HAVE_movqi)
  1204. mov_optab[(int) QImode].insn_code = CODE_FOR_movqi;
  1205. #endif
  1206. #ifdef HAVE_movhi
  1207. if (HAVE_movhi)
  1208. mov_optab[(int) HImode].insn_code = CODE_FOR_movhi;
  1209. #endif
  1210. #ifdef HAVE_movsi
  1211. if (HAVE_movsi)
  1212. mov_optab[(int) SImode].insn_code = CODE_FOR_movsi;
  1213. #endif
  1214. #ifdef HAVE_movdi
  1215. if (HAVE_movdi)
  1216. mov_optab[(int) DImode].insn_code = CODE_FOR_movdi;
  1217. #endif
  1218. #ifdef HAVE_movsf
  1219. if (HAVE_movsf)
  1220. mov_optab[(int) SFmode].insn_code = CODE_FOR_movsf;
  1221. #endif
  1222. #ifdef HAVE_movdf
  1223. if (HAVE_movdf)
  1224. mov_optab[(int) DFmode].insn_code = CODE_FOR_movdf;
  1225. #endif
  1226. #ifdef HAVE_movstrictqi
  1227. if (HAVE_movstrictqi)
  1228. movstrict_optab[(int) QImode].insn_code = CODE_FOR_movstrictqi;
  1229. #endif
  1230. #ifdef HAVE_movstricthi
  1231. if (HAVE_movstricthi)
  1232. movstrict_optab[(int) HImode].insn_code = CODE_FOR_movstricthi;
  1233. #endif
  1234. #ifdef HAVE_movstrictsi
  1235. if (HAVE_movstrictsi)
  1236. movstrict_optab[(int) SImode].insn_code = CODE_FOR_movstrictsi;
  1237. #endif
  1238. #ifdef HAVE_movstrictdi
  1239. if (HAVE_movstrictdi)
  1240. movstrict_optab[(int) DImode].insn_code = CODE_FOR_movstrictdi;
  1241. #endif
  1242. #ifdef HAVE_cmpqi
  1243. if (HAVE_cmpqi)
  1244. cmp_optab[(int) QImode].insn_code = CODE_FOR_cmpqi;
  1245. #endif
  1246. #ifdef HAVE_cmphi
  1247. if (HAVE_cmphi)
  1248. cmp_optab[(int) HImode].insn_code = CODE_FOR_cmphi;
  1249. #endif
  1250. #ifdef HAVE_cmpsi
  1251. if (HAVE_cmpsi)
  1252. cmp_optab[(int) SImode].insn_code = CODE_FOR_cmpsi;
  1253. #endif
  1254. #ifdef HAVE_cmpsf
  1255. if (HAVE_cmpsf)
  1256. cmp_optab[(int) SFmode].insn_code = CODE_FOR_cmpsf;
  1257. #endif
  1258. #ifdef HAVE_cmpdf
  1259. if (HAVE_cmpdf)
  1260. cmp_optab[(int) DFmode].insn_code = CODE_FOR_cmpdf;
  1261. #endif
  1262. #ifdef HAVE_tstqi
  1263. if (HAVE_tstqi)
  1264. tst_optab[(int) QImode].insn_code = CODE_FOR_tstqi;
  1265. #endif
  1266. #ifdef HAVE_tsthi
  1267. if (HAVE_tsthi)
  1268. tst_optab[(int) HImode].insn_code = CODE_FOR_tsthi;
  1269. #endif
  1270. #ifdef HAVE_tstsi
  1271. if (HAVE_tstsi)
  1272. tst_optab[(int) SImode].insn_code = CODE_FOR_tstsi;
  1273. #endif
  1274. #ifdef HAVE_tstsf
  1275. if (HAVE_tstsf)
  1276. tst_optab[(int) SFmode].insn_code = CODE_FOR_tstsf;
  1277. #endif
  1278. #ifdef HAVE_tstdf
  1279. if (HAVE_tstdf)
  1280. tst_optab[(int) DFmode].insn_code = CODE_FOR_tstdf;
  1281. #endif
  1282. cmp_optab[(int) SImode].lib_call = "cmpsi2";
  1283. cmp_optab[(int) DImode].lib_call = "cmpdi2";
  1284. cmp_optab[(int) SFmode].lib_call = "cmpsf2";
  1285. cmp_optab[(int) DFmode].lib_call = "cmpdf2";
  1286. }