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 X86_GEN_H 28 #define X86_GEN_H 29 30 struct backend; 31 struct vreg; 32 struct reg; 33 struct icode_list; 34 struct function; 35 36 struct init_with_name; 37 38 #if ! REMOVE_FLOATBUF 39 extern struct vreg floatbuf; 40 #endif 41 42 extern struct vreg x87cw_old; 43 extern struct vreg x87cw_new; 44 extern int allocated_sse_fpr; 45 46 47 void print_asmitem_x86(FILE *, void *, int, int, int); 48 struct reg *get_smaller_reg(struct reg *, size_t); 49 int x86_have_immediate_op(struct type *, int op); 50 51 struct reg * 52 alloc_sse_fpr(struct function *f, int size, struct icode_list *il, 53 struct reg *dontwipe); 54 55 56 #define CSAVE_EBX 1 57 #define CSAVE_ESI (1 << 1) 58 #define CSAVE_EDI (1 << 2) 59 60 #if 0 61 #define STUPID_X87(reg) \ 62 (0 && (backend->arch == ARCH_X86 && reg->type == REG_FPR) \ 63 || (backend->arch == ARCH_AMD64 \ 64 && reg->vreg && reg->vreg->type \ 65 && reg->vreg->type->code == TY_LDOUBLE)) 66 #endif 67 68 #include "reg.h" 69 70 struct filddata; 71 struct fistdata; 72 73 typedef void (*fxch_func_t)(struct reg *, struct reg *); 74 typedef void (*ffree_func_t)(struct reg *); 75 typedef void (*fnstcw_func_t)(struct vreg *vr); 76 typedef void (*fldcw_func_t)(struct vreg *vr); 77 typedef void (*cdq_func_t)(void); 78 typedef void (*fild_func_t)(struct filddata *); 79 typedef void (*fist_func_t)(struct fistdata *); 80 typedef void (*ulong_to_float_func_t)(struct icode_instr *); 81 82 struct emitter_x86 { 83 fxch_func_t fxch; 84 ffree_func_t ffree; 85 fnstcw_func_t fnstcw; 86 fldcw_func_t fldcw; 87 cdq_func_t cdq; 88 fist_func_t fist; 89 fild_func_t fild; 90 ulong_to_float_func_t ulong_to_float; 91 }; 92 93 extern struct backend x86_backend; 94 extern struct reg x86_gprs[7]; 95 extern struct reg x86_fprs[8]; 96 extern struct reg x86_sse_regs[8]; 97 extern int sse_csave_map[8]; 98 extern struct stack_block *saved_ret_addr; 99 extern struct emitter_x86 *emit_x86; 100 101 /* nonportable in ANSI */ 102 #define STUPID_X87(reg) \ 103 (reg >= x86_fprs && reg <= (x86_fprs + 7)) 104 105 extern struct init_with_name *init_list_head; 106 extern struct init_with_name *init_list_tail; 107 108 #endif 109 110