1 /*
2  * Copyright (c) 2005 - 2010, Nils R. Weller
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 #ifndef ICODE_H
28 #define ICODE_H
29 
30 struct statement;
31 struct vreg;
32 struct reg;
33 struct expr;
34 struct fcall_data;
35 struct store_data;
36 struct stack_block;
37 struct type;
38 struct function;
39 struct control;
40 struct label;
41 struct token;
42 struct decl;
43 struct inline_asm_stmt;
44 
45 struct copystruct {
46 	struct vreg	*dest_vreg;
47 	struct vreg	*src_vreg;
48 	struct reg	*dest_preg;
49 	struct reg	*src_preg;
50 	struct reg	*dest_from_ptr;
51 	struct reg	*src_from_ptr;
52 	struct reg	*dest_from_ptr_struct;
53 	struct reg	*src_from_ptr_struct;
54 	struct reg	*startreg;
55 };
56 
57 struct putstructregs {
58 	struct reg	*destreg;
59 	struct reg	*ptrreg;
60 	struct vreg	*src_vreg;
61 };
62 
63 struct copyreg {
64 	struct reg	*src_preg;
65 	struct reg	*dest_preg;
66 	struct type	*src_type;
67 	struct type	*dest_type;
68 };
69 
70 struct allocadata {
71 	struct reg		*result_reg;
72 	struct reg		*size_reg;
73 	struct stack_block	*addr;
74 };
75 
76 struct vlasizedata {
77 	struct reg		*size;
78 	struct stack_block	*blockaddr;
79 	int			offset;
80 };
81 /* XXX used by conv_fp and extend_sign */
82 struct extendsign {
83 	struct reg	*dest_preg;
84 	struct reg	*src_preg; /* XXX conv_fp-only */
85 	struct type	*src_type;
86 	struct type	*dest_type;
87 };
88 
89 struct amd64_ulong_to_float {
90 	struct reg	*src_gpr;
91 	struct reg	*temp_gpr;
92 	struct reg	*dest_sse_reg;
93 	int		code;
94 };
95 
96 struct amd64_negmask_data {
97 	struct reg	*target_fpr;
98 	struct reg	*support_gpr;
99 };
100 
101 #include <stddef.h>
102 
103 
104 struct allocstack {
105 	size_t		nbytes;
106 	struct vreg	*patchme;
107 };
108 
109 struct icode_instr {
110 	int			type;
111 #define INSTR_SEQPOINT		1 /* pseudo */
112 #define INSTR_LABEL		2
113 #define INSTR_JUMP		3 /* Unconditional branch */
114 #define INSTR_CMP		5
115 #define INSTR_EXTEND_SIGN	10 /* pseudo */
116 #define INSTR_CONV_FP		11 /* pseudo */
117 #define INSTR_CONV_TO_LDOUBLE	12 /* pseudo */
118 #define INSTR_CONV_FROM_LDOUBLE	13 /* pseudo */
119 #define INSTR_CALL		20
120 #define INSTR_CALLINDIR		21
121 #define INSTR_LOAD		30
122 #define INSTR_LOAD_ADDRLABEL	31	/* 07/20/08 */
123 #define INSTR_COMP_GOTO		32	/* 07/20/08 */
124 #define INSTR_STORE		35
125 #define INSTR_WRITEBACK		37
126 #define INSTR_COPYINIT		40 /* pseudo */
127 #define INSTR_COPYSTRUCT	41 /* pseudo */
128 #define INSTR_ASM		42 /* pseudo */
129 #define INSTR_ALLOCA		43 /* pseudo */
130 #define INSTR_INTRINSIC_MEMCPY	44 /* pseudo */
131 #define INSTR_DEALLOCA		45 /* pseudo */
132 
133 #define INSTR_BUILTIN_FRAME_ADDRESS	46 /* pseudo */
134 
135 #define INSTR_PUTSTRUCTREGS	47 /* 11/06/08: pseudo */
136 
137 #define INSTR_ALLOC_VLA		50 /* pseudo */
138 #define INSTR_DEALLOC_VLA	51 /* pseudo */
139 
140 #define INSTR_PUT_VLA_SIZE	52 /* pseudo */
141 #define INSTR_RETR_VLA_SIZE	53 /* pseudo */
142 
143 #define INSTR_LOAD_VLA		55
144 
145 #define INSTR_PUSH		60
146 #define INSTR_FREESTACK		70
147 #define INSTR_ALLOCSTACK	71
148 #define INSTR_INDIR		80
149 #define INSTR_ADDROF		81
150 #define INSTR_DEC		89
151 #define INSTR_INC		90
152 #define INSTR_NEG		91
153 #define INSTR_SETREG		92
154 #define INSTR_XCHG		93
155 #define INSTR_MOV		100
156 #define INSTR_ADD		110
157 #define INSTR_SUB		111
158 #define INSTR_MUL		112
159 #define INSTR_DIV		113
160 #define INSTR_MOD		114
161 #define INSTR_SHL		115
162 #define INSTR_SHR		116
163 #define INSTR_AND		117
164 #define INSTR_OR		118
165 #define INSTR_XOR		119
166 #define INSTR_NOT		120
167 
168 #define INSTR_PREG_OR		121
169 
170 #define INSTR_SETITEM		125 /* pseudo */
171 #define INSTR_UNIMPL		126 /* pseudo */
172 #define INSTR_DEBUG		130 /* pseudo */
173 #define INSTR_PROPVREG		131 /* pseudo */
174 #define INSTR_ADJ_ALLOCATED	132 /* pseudo */
175 #define INSTR_INITIALIZE_PIC	133 /* pseudo */
176 
177 #define INSTR_DBGINFO_LINE	135 /* debugging pseudo */
178 
179 #define INSTR_BR_EQUAL		140
180 #define INSTR_BR_NEQUAL		141
181 #define INSTR_BR_GREATER	142
182 #define INSTR_BR_SMALLER	143
183 #define INSTR_BR_GREATEREQ	144
184 #define INSTR_BR_SMALLEREQ	145
185 
186 #define INSTR_RET		160
187 
188 #define INSTR_X86_FXCH		500
189 #define INSTR_X86_FFREE		501
190 #define INSTR_X86_FNSTCW	502
191 #define INSTR_X86_FLDCW		503
192 #define INSTR_X86_CDQ		520
193 
194 
195 #define INSTR_X86_FILD		530
196 #define INSTR_X86_FIST		531
197 
198 #define INSTR_MIPS_MFC1		600
199 #define INSTR_MIPS_MTC1		601
200 #define INSTR_MIPS_CVT		602
201 #define INSTR_MIPS_TRUNC	603
202 #define INSTR_MIPS_MAKE_32BIT_MASK	604
203 
204 #define INSTR_AMD64_CVTSI2SD	700
205 #define INSTR_AMD64_CVTSI2SS	701
206 #define INSTR_AMD64_CVTTSD2SI	702
207 #define INSTR_AMD64_CVTTSS2SI	703
208 #define INSTR_AMD64_CVTSD2SS	704
209 #define INSTR_AMD64_CVTSS2SD	705
210 
211 /*
212  * 04/11/08: The missing link!! Instructions for 64bit integer to SSE fp conversion
213  */
214 #define INSTR_AMD64_CVTSI2SDQ	706
215 #define INSTR_AMD64_CVTSI2SSQ	707
216 
217 /*
218  * 04/12/08: Negation for SSE values
219  */
220 #define INSTR_AMD64_LOAD_NEGMASK	708	/* pseudo */
221 #define INSTR_AMD64_XORPS		709
222 #define INSTR_AMD64_XORPD		710
223 /* 08/01/08: 64bit target cvttsd/ss versions */
224 #define INSTR_AMD64_CVTTSD2SIQ  711
225 #define INSTR_AMD64_CVTTSS2SIQ  712
226 
227 /* 08/02/08: New pseudo instr for absurd unsigned long (long) to float conv */
228 
229 
230 #define INSTR_AMD64_ULONG_TO_FLOAT	713
231 
232 
233 #define INSTR_POWER_SRAWI	800
234 #define INSTR_POWER_RLWINM	801
235 #define INSTR_POWER_SLWI	802
236 #define INSTR_POWER_EXTSH	803
237 #define INSTR_POWER_RLDICL	804
238 #define INSTR_POWER_EXTSB	805
239 #define INSTR_POWER_EXTSW	806
240 #define INSTR_POWER_FCFID	807
241 #define INSTR_POWER_FRSP	808
242 #define INSTR_POWER_SET_LOAD_DOUBLE	810
243 #define INSTR_POWER_UNSET_LOAD_DOUBLE	811
244 #define INSTR_POWER_XORIS	820
245 #define INSTR_POWER_LIS		821
246 #define INSTR_POWER_LOADUP4	822
247 #define INSTR_POWER_FCTIWZ	823
248 
249 #define INSTR_SPARC_LOAD_INT_FROM_LDOUBLE	830
250 
251 #if 0
252 	void			*data;
253 	struct vreg		*then_vreg;
254 #endif
255 	/*
256 	 * Virtual and physical source/destination registers. The reason
257 	 * pregs need to be recorded as well is that vr->preg cannot be
258 	 * used in the backend because any vreg may have multiple pregs
259 	 * associated with it during its lifetime
260 	 *
261 	 * XXX Some of these things are probably only needed for loads/
262 	 * stores. By specializing more, we can save memory
263 	 */
264 	struct reg		**dest_pregs;
265 	struct vreg		*dest_vreg;
266 	struct reg		**src_pregs;
267 	struct vreg		*src_vreg;
268 	struct vreg		*src_parent_struct;
269 	struct vreg		*dest_parent_struct;
270 	struct reg		*src_ptr_preg;
271 	struct reg		*dest_ptr_preg;
272 	void			*dat;
273 	struct icode_instr	*next;
274 	unsigned long		seqno;
275 
276 	/*
277 	 * 01/18/09: Append sequence number. This can give us a rough estimate
278 	 * of the distance between two icode instructions. E.g. a list of
279 	 *
280 	 *    LOAD; ADD; STORE
281 	 *
282 	 * will have append sequence numbers N, N+1 and N+2. Currently we only
283 	 * use this on PPC to decide whether a branch instruction requires an
284 	 * indirect branch because the target label (which is also an icode
285 	 * instruction) is too far away. The indirect branch case is more
286 	 * expensive in code size and performance, so we wish to avoid it if
287 	 * possible).
288 	 *
289 	 * Note that this is imprecise for two reasons:
290 	 *
291 	 *     - An icode instruction may map to multiple target instructions,
292 	 * the number of which is not taken into account (e.g. it may expand to
293 	 * a memcpy() call with some preparations, or it may be a list of inline
294 	 * asm instructions)
295 	 *
296 	 *     - There is a possibility for sequence numbers to get mixed up
297 	 * when icode lists are merged in reverse order (but this possibly rarely
298 	 * or never happens currently)
299 	 */
300 	unsigned long		append_seqno;
301 	int			hints; /* 06/02/08 */
302 #define HINT_INSTR_NEXT_NOT_SECOND_LLONG_WORD	1
303 #define HINT_INSTR_GENERIC_MODIFIER		(1 << 1) /* instruction-specific */
304 	/*
305 	 * 01/29/08: Specifically requests an unsigned variant of the instruction.
306 	 * This is currently only used for PPC32 long long comparison; The less
307 	 * significant word has to be compared unsigned. This worked without a
308 	 * hint on x86 because the signed/unsigned distinction is done for the
309 	 * branch, not cmp.
310 	 *
311 	 * XXX Maybe there is a better way to fix it (e.g. change vregs of cmp
312 	 * to unsigned)
313 	 */
314 #define HINT_INSTR_UNSIGNED			(1 << 2)
315 #define HINT_INSTR_RENAMED			(1 << 3)
316 };
317 
318 struct icode_list {
319 	struct icode_instr	*head;
320 	struct icode_instr	*tail;
321 	struct vreg		*res;
322 };
323 
324 unsigned long
325 get_label_count(void);
326 
327 int
328 icode_list_length(struct icode_list *);
329 
330 void
331 boolify_result(struct vreg *vr, struct icode_list *il);
332 
333 int
334 pro_mote(struct vreg **, struct icode_list *, int eval);
335 
336 /*
337  * Functions for creating icode instructions
338  */
339 
340 void
341 icode_make_copystruct(
342 	struct vreg *dest,
343 	struct vreg *src,
344 	struct icode_list *il);
345 
346 void
347 icode_make_putstructregs(
348 	struct reg *dest,
349 	struct reg *ptrreg,
350 	struct vreg *src,
351 	struct icode_list *il);
352 
353 struct int_memcpy_data {
354 	struct reg	*dest_addr;
355 	struct reg	*src_addr;
356 	struct reg	*nbytes;
357 	struct reg	*temp_reg;
358 	int		type;  /* BUILTIN_MEMCPY or _MEMSET */
359 };
360 
361 void
362 icode_make_intrinsic_memcpy_or_memset(
363 	int type,  /* BUILTIN_MEMCPY or _MEMSET */
364 	struct vreg *dest,
365 	struct vreg *src,
366 	struct vreg *nbytes,
367 	int may_call_lib,
368 	struct icode_list *il);
369 
370 void
371 icode_make_alloca(struct reg *r, struct vreg *size_vr,
372 	struct stack_block *sb,
373 	struct icode_list *il);
374 
375 void
376 icode_make_alloc_vla(struct stack_block *vla,
377 	struct icode_list *il);
378 
379 
380 void
381 icode_make_put_vla_size(struct reg *size, struct stack_block *sb, int idx,
382 	struct icode_list *il);
383 
384 void
385 icode_make_put_vla_whole_size(struct reg *size, struct stack_block *sb,
386 		        struct icode_list *il);
387 
388 struct vreg *
389 icode_make_retr_vla_size(struct reg *size, struct stack_block *sb, int idx,
390 	struct icode_list *il);
391 
392 
393 struct builtinframeaddressdata {
394 	struct reg	*result_reg;
395 	struct reg	*temp_reg;
396 	size_t		*count;
397 };
398 
399 void
400 icode_make_builtin_frame_address(struct reg *r, struct reg *r2, size_t *n,
401 	struct icode_list *il);
402 
403 void
404 icode_make_allocstack(struct vreg *vr, size_t size, struct icode_list *il);
405 
406 void
407 icode_make_copyreg(struct reg *dest, struct reg *src,
408 		struct type *desttype, struct type *srctype,
409 		struct icode_list *il);
410 
411 struct icode_instr *
412 icode_make_setreg(struct reg *r, int value);
413 
414 struct icode_instr *
415 icode_make_neg(struct vreg *vr);
416 
417 void
418 icode_make_xchg(struct reg *r1, struct reg *r2, struct icode_list *il);
419 
420 struct icode_instr *
421 icode_make_branch(struct icode_instr *dest, int btype, struct vreg *vr);
422 
423 struct icode_instr *
424 icode_make_jump(struct icode_instr *label);
425 
426 struct icode_instr *
427 icode_make_sub(struct vreg *dest, struct vreg *src);
428 
429 struct icode_instr *
430 icode_make_add(struct vreg *dest, struct vreg *src);
431 
432 struct icode_instr *
433 icode_make_mul(struct vreg *dest, struct vreg *src);
434 
435 struct icode_instr *
436 icode_make_div(struct vreg *dest, struct vreg *src);
437 
438 struct icode_instr *
439 icode_make_shl(struct vreg *dest, struct vreg *src);
440 
441 struct icode_instr *
442 icode_make_shr(struct vreg *dest, struct vreg *src);
443 
444 struct icode_instr *
445 icode_make_mod(struct vreg *dest, struct vreg *src);
446 
447 struct icode_instr *
448 icode_make_or(struct vreg *dest, struct vreg *src);
449 
450 void
451 icode_make_preg_or(struct reg *dest, struct reg *src, struct icode_list *il);
452 
453 struct icode_instr *
454 icode_make_and(struct vreg *dest, struct vreg *src);
455 
456 struct icode_instr *
457 icode_make_indir(struct reg *);
458 
459 void
460 icode_make_copyinit(struct decl *, struct icode_list *);
461 
462 void
463 icode_make_asm(struct inline_asm_stmt *, struct icode_list *);
464 
465 struct icode_instr *
466 icode_make_store_indir(struct vreg *dest, struct vreg *src);
467 
468 struct icode_instr *
469 icode_make_call(const char *name);
470 
471 
472 struct icode_instr *
473 icode_make_call_indir(struct reg *r);
474 
475 struct icode_instr *
476 icode_make_push(struct vreg *vr, struct icode_list *il);
477 
478 struct icode_instr *
479 icode_make_xor(struct vreg *dest, struct vreg *src);
480 
481 struct icode_instr *
482 icode_make_not(struct vreg *vr);
483 
484 struct icode_instr *
485 icode_make_setitem(struct vreg *vr);
486 
487 struct icode_instr *
488 icode_make_propvreg(struct vreg *vr);
489 
490 void
491 icode_make_load(struct reg *r, struct vreg *parent_struct,
492 	int is_not_first_load, struct icode_list *il);
493 
494 void
495 icode_make_load_addrlabel(struct reg *r, struct icode_instr *label,
496 	struct icode_list *il);
497 
498 extern int	unimpl_instr;
499 
500 void
501 icode_make_unimpl(struct icode_list *il);
502 
503 void
504 icode_make_debug(struct icode_list *il, const char *msg, ...);
505 
506 
507 struct statement;
508 
509 void
510 icode_make_dbginfo_line(struct statement *stmt, struct icode_list *il);
511 
512 void
513 do_add_sub(struct vreg **left, struct vreg **right,
514 	int op, struct token *optok, struct icode_list *il, int eval);
515 
516 void
517 icode_make_store(struct function *f, struct vreg *dest,
518 	struct vreg *src, struct icode_list *il);
519 
520 struct icode_instr *
521 icode_make_freestack(size_t bytes);
522 
523 struct icode_instr *
524 icode_make_adj_allocated(int bytes);
525 
526 #if 0
527 struct icode_instr *
528 icode_make_seqpoint(struct var_access *stores);
529 #endif
530 
531 struct icode_instr *
532 icode_make_indir(struct reg *r);
533 
534 struct reg * /*icode_instr **/
535 icode_make_addrof(struct reg *r, struct vreg *vr, struct icode_list *il);
536 
537 struct icode_instr *
538 icode_make_inc(struct vreg *vr);
539 
540 struct icode_instr *
541 icode_make_dec(struct vreg *vr);
542 
543 struct icode_instr *
544 icode_make_label(const char *tmpl);
545 
546 struct icode_instr *
547 icode_make_ret(struct vreg *vr);
548 
549 struct icode_instr *
550 icode_make_cmp(struct vreg *dest, struct vreg *src);
551 
552 void
553 icode_make_initialize_pic(struct function *f, struct icode_list *il);
554 
555 void
556 icode_make_extend_sign(struct vreg *vr, struct type *to, struct type *from,
557 	struct icode_list *il);
558 
559 void
560 icode_make_conv_fp(struct reg *destr, struct reg *srcr, struct type *to,
561 	struct type *from,
562 	struct icode_list *il);
563 
564 void
565 icode_make_conv_to_ldouble(struct vreg *dest, struct vreg *src,
566 	struct icode_list *il);
567 
568 void
569 icode_make_conv_from_ldouble(struct vreg *dest, struct vreg *src,
570 	struct icode_list *il);
571 
572 void
573 icode_make_x86_fxch(struct reg *r, struct reg *r2, struct icode_list *il);
574 
575 void
576 icode_make_x86_ffree(struct reg *r, struct icode_list *il);
577 
578 void
579 icode_make_x86_store_x87cw(struct vreg *vr, struct icode_list *il);
580 
581 void
582 icode_make_x86_load_x87cw(struct vreg *vr, struct icode_list *il);
583 
584 void
585 icode_make_x86_cdq(struct icode_list *il);
586 
587 struct filddata {
588 	struct reg	*r;
589 	struct vreg	*vr;
590 };
591 
592 struct fistdata {
593 	struct reg	*r;
594 	struct reg	*r2;
595 	struct vreg	*vr;
596 	struct type	*target_type;
597 };
598 
599 void
600 icode_make_comp_goto(struct reg *addr, struct icode_list *il);
601 
602 struct stack_block *
603 icode_alloc_reg_stack_block(struct function *, size_t bytes);
604 
605 void
606 icode_make_x86_fild(struct reg *r, struct vreg *vr, struct icode_list *il);
607 
608 void
609 icode_make_x86_fist(struct reg *r, struct vreg *vr, struct type *ty,
610 	struct icode_list *il);
611 
612 void
613 icode_make_mips_mtc1(struct reg *dest, struct vreg *src,
614 struct icode_list *il);
615 
616 void
617 icode_make_mips_cvt(struct vreg *dest, struct vreg *src,
618 struct icode_list *il);
619 
620 void
621 icode_make_mips_trunc(struct vreg *dest, struct vreg *src,
622 struct icode_list *il);
623 
624 void
625 icode_make_mips_make_32bit_mask(struct reg *r, struct icode_list *il);
626 
627 void
628 icode_make_mips_mfc1(struct reg *dest, struct vreg *src,
629 struct icode_list *il);
630 
631 void
632 icode_make_power_srawi(struct reg *dest, struct reg *src, int bits,
633 struct icode_list *il);
634 
635 void
636 icode_make_power_rldicl(struct reg *dest, struct reg *src, int bits,
637 struct icode_list *il);
638 
639 void
640 icode_make_power_fcfid(struct reg *dest, struct reg *src,
641 struct icode_list *il);
642 
643 void
644 icode_make_power_frsp(struct reg *dest, struct icode_list *il);
645 
646 void
647 icode_make_power_rlwinm(struct reg *dest, struct reg *src, int value,
648 struct icode_list *il);
649 
650 void
651 icode_make_power_slwi(struct reg *dest, struct reg *src, int bits,
652 struct icode_list *il);
653 
654 void
655 icode_make_power_extsb(struct reg *dest, struct icode_list *il);
656 
657 void
658 icode_make_power_extsh(struct reg *dest, struct icode_list *il);
659 
660 void
661 icode_make_power_extsw(struct reg *dest, struct icode_list *il);
662 
663 void
664 icode_make_power_xoris(struct reg *, int, struct icode_list *il);
665 
666 void
667 icode_make_power_lis(struct reg *, int, struct icode_list *il);
668 
669 void
670 icode_make_power_loadup4(struct reg *r, struct vreg *vr,
671 struct icode_list *il);
672 
673 void
674 icode_make_power_fctiwz(struct reg *r, int for_unsigned, struct icode_list *il);
675 
676 void
677 icode_make_power_extsh(struct reg *r, struct icode_list *il);
678 
679 void
680 icode_make_amd64_cvtsi2sd(struct reg *dest, struct vreg *src,
681 struct icode_list *il);
682 
683 void
684 icode_make_amd64_cvtsi2ss(struct reg *dest, struct vreg *src,
685 struct icode_list *il);
686 
687 void
688 icode_make_amd64_cvttsd2si(struct reg *dest, struct reg *src,
689 struct icode_list *il);
690 
691 void
692 icode_make_amd64_cvttsd2siq(struct reg *dest, struct reg *src,
693 struct icode_list *il);
694 
695 void
696 icode_make_amd64_cvttss2si(struct reg *dest, struct reg *src,
697 struct icode_list *il);
698 
699 void
700 icode_make_amd64_cvttss2siq(struct reg *dest, struct reg *src,
701 struct icode_list *il);
702 
703 void
704 icode_make_amd64_cvtsd2ss(struct reg *r, struct icode_list *il);
705 
706 void
707 icode_make_amd64_cvtss2sd(struct reg *r, struct icode_list *il);
708 
709 void
710 icode_make_amd64_cvtsi2sdq(
711 	struct reg *dest,
712 	struct vreg *src,
713 	struct icode_list *il);
714 
715 void
716 icode_make_amd64_cvtsi2ssq(
717 	struct reg *dest,
718 	struct vreg *src,
719 	struct icode_list *il);
720 
721 
722 void
723 icode_make_amd64_load_negmask(struct reg *dest, struct reg *support, int for_double,
724 	struct icode_list *il);
725 
726 void
727 icode_make_amd64_ulong_to_float(struct reg *src_gpr, struct reg *temp,
728 	struct reg *dest_sse_reg, int is_double, struct icode_list *il);
729 
730 void
731 icode_make_amd64_xorps(struct vreg *dest, struct reg *r, struct icode_list *);
732 void
733 icode_make_amd64_xorpd(struct vreg *dest, struct reg *r, struct icode_list *);
734 
735 void
736 icode_make_sparc_load_int_from_ldouble(struct reg *, struct vreg *,
737 	struct icode_list *il);
738 
739 struct icode_instr *
740 icode_make_writeback(struct function *f, struct vreg *vr);
741 
742 struct type *
743 promote(struct vreg **left, struct vreg **right,
744 	int op0, struct token *optok, struct icode_list *il, int eval);
745 
746 
747 void init_to_icode(struct decl *d, struct icode_list *il);
748 
749 int
750 emul_conv_ldouble_to_double(struct vreg **temp_lres,
751 	struct vreg **temp_rres,
752 	struct vreg *lres,
753 	struct vreg *rres,
754 	struct icode_list *ilp,
755 	int eval);
756 
757 void
758 icode_align_ptr_up_to(struct vreg *ptr,
759 			int target_alignment,
760 			int addend,
761 			struct icode_list *il);
762 
763 /*
764  * Compile an expression to icode
765  */
766 struct vreg *
767 expr_to_icode(struct expr *e, struct vreg *lvalue, struct icode_list *il,
768 		int purpose, int resval_not_used, int eval);
769 
770 struct vreg *
771 fcall_to_icode(struct fcall_data *, struct icode_list *, struct token *t,
772 		int eval);
773 
774 struct stack_block *
775 vla_decl_to_icode(struct type *ty, struct icode_list *il);
776 
777 struct icode_instr *
778 compare_vreg_with_zero(struct vreg *vr, struct icode_list *il);
779 
780 /*
781  * Functions to manipulate icode lists
782  */
783 struct icode_list *
784 alloc_icode_list(void);
785 
786 
787 
788 void
789 append_icode_list(struct icode_list *, struct icode_instr *);
790 
791 void
792 merge_icode_lists(struct icode_list *dest, struct icode_list *src);
793 
794 void
795 put_label_scope(struct label *l);
796 
797 void
798 put_expr_scope(struct expr *e);
799 
800 void
801 put_ctrl_scope(struct control *c);
802 
803 struct icode_list *
804 ctrl_to_icode(struct control *);
805 
806 struct icode_list *
807 xlate_to_icode(struct statement *slist, int inv_gprs_first);
808 
809 void
810 xlate_func_to_icode(struct function *func);
811 
812 struct icode_instr *
813 copy_icode_instr(struct icode_instr *);
814 
815 struct vreg *
816 promote_bitfield(struct vreg *vr, struct icode_list *il);
817 
818 void
819 mask_source_for_bitfield(struct type *ty, struct vreg *vr,
820 		struct icode_list *il, int for_reading);
821 
822 void
823 load_and_decode_bitfield(struct vreg **, struct icode_list *);
824 
825 
826 void
827 decode_bitfield(struct type *ty, struct vreg *vr, struct icode_list *il);
828 
829 
830 void
831 write_back_bitfield(struct vreg *destvr, struct vreg *lres,
832 		struct type *desttype, struct icode_list *il);
833 
834 void
835 write_back_bitfield_by_assignment(struct vreg *lres, struct vreg *rres,
836 		struct icode_list *ilp);
837 
838 void
839 add_const_to_vreg(struct vreg *valist_vr, int size, struct icode_list *il);
840 
841 
842 #endif
843 
844