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 BACKEND_H 28 #define BACKEND_H 29 30 struct scope; 31 struct expr; 32 struct type; 33 struct decl; 34 struct reg; 35 struct vreg; 36 struct token; 37 struct function; 38 struct icode_instr; 39 struct icode_list; 40 struct scope; 41 struct stack_block; 42 struct initializer; 43 struct sym_entry; 44 struct fcall_data; 45 struct init_with_name; 46 struct inline_asm_io; 47 struct ty_string; 48 struct gas_token; 49 struct copystruct; 50 struct allocadata; 51 52 struct vlasizedata; 53 54 #include <stdio.h> 55 #include <stdarg.h> 56 #include "builtins.h" 57 #include "attribute.h" 58 59 extern int optimizing; 60 extern char *tunit_name; 61 extern size_t tunit_size; 62 63 64 struct vreg *get_parent_struct(struct vreg *); 65 size_t calc_align_bytes( 66 size_t offset, 67 struct type *cur, 68 struct type *next, 69 int struct_member); 70 int calc_slot_rightadjust_bytes(int size, int total_size); 71 int is_immediate_vla_type(struct type *ty); 72 int 73 xlate_icode(struct function *f, 74 struct icode_list *ilp, 75 struct icode_instr **lastret); 76 77 int 78 botch_x86_alignment(struct type *ty); 79 80 void 81 store_preg_to_var_off(struct decl *d, size_t off, size_t size, struct reg *r, 82 struct reg *temp); 83 84 struct vreg * 85 vreg_static_alloc(struct type *ty, struct initializer *init); 86 87 struct vreg * 88 vreg_stack_alloc(struct type *ty, struct icode_list *il, int on_frame, 89 struct initializer *init); 90 91 struct initializer * 92 make_null_block(struct sym_entry *se, 93 struct type *ty, struct type * 94 struct_ty, int remaining); 95 96 struct init_with_name * 97 make_init_name(struct initializer *init); 98 99 size_t 100 get_sizeof_const(struct token *constant); 101 102 size_t 103 get_sizeof_elem_type(struct type *ty); 104 105 size_t 106 get_sizeof_decl(struct decl *, struct token *); 107 108 size_t 109 get_align_type(struct type *ty); 110 size_t 111 get_struct_align_type(struct type *ty); 112 113 unsigned long 114 calc_offsets(struct vreg *); 115 116 int 117 generic_same_representation(struct type *dest, struct type *src); 118 119 void 120 generic_conv_to_or_from_ldouble(struct vreg *ret, struct type *to, struct type *from, 121 struct icode_list *il); 122 123 int 124 generic_pass_struct_union( 125 struct vreg *vr, /*int *gprs_used, int *fprs_used,*/ 126 int *slots_used, 127 size_t *stack_bytes_used, 128 size_t *real_stack_bytes_used, 129 struct icode_list *il); 130 131 void 132 generic_store_struct_arg_slots(struct function *f, struct sym_entry *se); 133 134 135 /* XXX Move function below to icodeinstr.c?! (originally from SPARC backend) */ 136 void 137 generic_icode_initialize_pic(struct function *f, struct icode_list *il); 138 139 int 140 arch_without_offset_limit(void); 141 142 void 143 save_struct_ptr(struct decl *); 144 145 void 146 reload_struct_ptr(struct decl *); 147 148 struct reg * /*icode_instr **/ 149 make_addrof_structret(struct vreg *struct_lvalue, struct icode_list *il); 150 151 152 153 struct stupidtrace_entry { 154 struct function *func; 155 char *bufname; 156 struct stupidtrace_entry *next; 157 }; 158 159 struct stupidtrace_entry * 160 put_stupidtrace_list(struct function *f); 161 162 extern struct stupidtrace_entry *stupidtrace_list_head; 163 extern struct stupidtrace_entry *stupidtrace_list_tail; 164 165 166 167 168 /* as/gas-specific emitter functions. Work at least with x86 gas and SGI as */ 169 void as_align_for_type(FILE *o, struct type *, int struct_member); 170 171 void as_print_string_init(FILE *o, size_t howmany, struct ty_string *str); 172 173 174 typedef int (*have_immediate_op_func_t)(struct type *ty, int op); 175 typedef int (*init_func_t)(FILE *fd, struct scope *s); 176 typedef int (*is_multi_reg_obj_func_t)(struct type *t); 177 178 typedef int (*gen_function_func_t)(struct function *f); 179 typedef int (*gen_code_func_t)(void); 180 181 182 typedef int (*gen_prepare_output_func_t)(void); 183 typedef int (*gen_finish_output_func_t)(void); 184 185 typedef int (*gen_var_func_t)(struct decl *d, int is_glob, int inited); 186 typedef int (*get_ptr_size_func_t)(void); 187 typedef struct type *(*get_size_t_func_t)(void); 188 typedef struct type *(*get_uintptr_t_func_t)(void); 189 typedef struct type *(*get_wchar_t_func_t)(void); 190 typedef size_t (*get_sizeof_basic_func_t)(int code); 191 typedef size_t (*get_sizeof_type_func_t)(struct type *ty, 192 struct token *tok); 193 typedef size_t (*get_sizeof_elem_type_func_t)(struct type *ty); 194 typedef size_t (*get_sizeof_decl_func_t)(struct decl *d, 195 struct token *tok); 196 typedef size_t (*get_sizeof_const_func_t)(struct token *t); 197 typedef struct vreg *(*get_sizeof_vla_type_func_t)(struct type *, 198 struct icode_list *); 199 typedef size_t (*get_align_type_func_t)(struct type *ty); 200 typedef struct reg (*reg_alloc_func_t)(void); 201 typedef int (*reg_free_func_t)(void); 202 203 #define INV_FOR_FCALL 1 204 typedef void (*invalidate_gprs_func_t)(struct icode_list *il, 205 int saveregs, int for_fcall); 206 typedef void (*invalidate_except_func_t)(struct icode_list *il, 207 int save, int for_fcall,...); 208 typedef struct reg *(*alloc_gpr_func_t)( 209 struct function *f, 210 int size, 211 struct icode_list *, 212 struct reg *dontwipe, int line); 213 typedef struct reg *(*alloc_16_or_32bit_noesiedi_func_t)( 214 struct function *f, 215 size_t size, 216 struct icode_list *, 217 struct reg *dontwipe); 218 219 typedef struct reg *(*alloc_fpr_func_t)( 220 struct function *f, 221 int size, 222 struct icode_list *, 223 struct reg *dontwipe); 224 typedef void (*free_preg_func_t)(struct reg *, struct icode_list *); 225 typedef void (*flush_func_t)(void); 226 typedef void (*wbreg_func_t)(struct vreg *vr, struct reg *pr); 227 typedef void (*icode_prepare_op_func_t)( 228 struct vreg **dest, 229 struct vreg **src, 230 int op, 231 struct icode_list *il); 232 233 typedef void (*icode_prepare_load_addrlabel_func_t)( 234 struct icode_instr *label); 235 236 typedef struct vreg *(*icode_make_cast_func_t) 237 (struct vreg *src, struct type *to, struct icode_list *il); 238 239 typedef void (*icode_make_structreloc_func_t)(struct copystruct *cs, 240 struct icode_list *il); 241 typedef void (*icode_complete_func_t)(struct function *f, 242 struct icode_list *il); 243 typedef void (*icode_initialize_pic_func_t)(struct function *f, 244 struct icode_list *il); 245 246 typedef struct initializer * 247 (*make_null_block_func_t)( 248 struct sym_entry *se, 249 struct type *t, 250 struct type *struct_ty, 251 int remaining); 252 typedef struct init_with_name * 253 (*make_init_name_func_t)(struct initializer *); 254 typedef void (*debug_print_gprs_func_t)(void); 255 typedef struct reg *(*name_to_reg_func_t)(const char *name); 256 typedef struct reg * 257 (*asmvreg_to_reg_func_t)(struct vreg **, int, 258 struct inline_asm_io*, struct icode_list*, int faultin); 259 typedef char *(*get_inlineasm_label_func_t)(const char *); 260 typedef void (*do_ret_func_t)(struct function *, struct icode_instr *); 261 262 typedef struct reg *(*get_abi_reg_func_t)(int index, struct type *ty); 263 typedef struct reg *(*get_abi_ret_reg_func_t)(struct type *p); 264 typedef int (*same_representation_func_t)(struct type *dest, 265 struct type *src); 266 267 268 269 struct emitter; 270 struct reg; 271 struct copystruct; 272 struct copyreg; 273 274 #include "archdefs.h" 275 #include "features.h" 276 277 struct backend { 278 /* Various backend-specific settings and flags */ 279 int arch; 280 int abi; 281 int multi_gpr_object; 282 int struct_align; 283 int need_pic_init; 284 int emulate_long_double; 285 int relax_alloc_gpr_order; 286 long max_displacement; 287 long min_displacement; 288 have_immediate_op_func_t have_immediate_op; 289 290 /* Initialization */ 291 init_func_t init; 292 293 /* Code translation support functions */ 294 is_multi_reg_obj_func_t is_multi_reg_obj; 295 get_ptr_size_func_t get_ptr_size; 296 get_size_t_func_t get_size_t; 297 get_uintptr_t_func_t get_uintptr_t; 298 get_wchar_t_func_t get_wchar_t; 299 get_sizeof_basic_func_t get_sizeof_basic; 300 get_sizeof_type_func_t get_sizeof_type; 301 get_sizeof_elem_type_func_t get_sizeof_elem_type; 302 get_sizeof_decl_func_t get_sizeof_decl; 303 get_sizeof_const_func_t get_sizeof_const; 304 get_sizeof_vla_type_func_t get_sizeof_vla_type; 305 get_align_type_func_t get_align_type; 306 307 308 /* Final code output functions (write asm file) */ 309 gen_function_func_t generate_function; 310 311 #if XLATE_IMMEDIATELY 312 gen_prepare_output_func_t gen_prepare_output; 313 gen_finish_output_func_t gen_finish_output; 314 #else 315 gen_code_func_t generate_program; 316 #endif 317 318 319 /* Emitter */ 320 struct emitter *emit; 321 322 /* XXX unused???? */ 323 struct reg *esp; 324 325 /* Code translation support functions (continued - XXX) */ 326 invalidate_gprs_func_t invalidate_gprs; 327 invalidate_except_func_t invalidate_except; 328 alloc_gpr_func_t alloc_gpr; 329 alloc_16_or_32bit_noesiedi_func_t alloc_16_or_32bit_noesiedi; 330 alloc_fpr_func_t alloc_fpr; 331 free_preg_func_t free_preg; 332 struct vreg *(*icode_make_fcall)( 333 struct fcall_data *, 334 struct vreg **vrs, 335 int nvrs, 336 struct icode_list * 337 ); 338 int (*icode_make_return)( 339 struct vreg *vr, struct icode_list *il 340 ); 341 flush_func_t flushregs; 342 icode_prepare_op_func_t icode_prepare_op; 343 icode_prepare_load_addrlabel_func_t icode_prepare_load_addrlabel; 344 icode_make_cast_func_t icode_make_cast; 345 icode_make_structreloc_func_t icode_make_structreloc; 346 icode_initialize_pic_func_t icode_initialize_pic; 347 icode_complete_func_t icode_complete_func; 348 make_null_block_func_t make_null_block; 349 make_init_name_func_t make_init_name; 350 debug_print_gprs_func_t debug_print_gprs; 351 name_to_reg_func_t name_to_reg; 352 asmvreg_to_reg_func_t asmvreg_to_reg; 353 get_inlineasm_label_func_t get_inlineasm_label; 354 do_ret_func_t do_ret; 355 get_abi_reg_func_t get_abi_reg; 356 get_abi_ret_reg_func_t get_abi_ret_reg; 357 same_representation_func_t same_representation; 358 }; 359 360 struct scope; 361 struct vreg; 362 struct inline_asm_stmt; 363 struct gas_token; 364 struct decl; 365 struct copystruct; 366 struct int_memcpy_data; 367 struct builtinframeaddressdata; 368 struct putstructregs; 369 370 int init_backend(FILE *fd, struct scope *s); 371 int do_xlate(struct function *, struct icode_instr **); 372 struct reg *generic_alloc_gpr(struct function *f, 373 int size, struct icode_list *il, struct reg *dontwipe, 374 struct reg *regset, int nregs, int *csave_map, int line); 375 size_t get_sizeof_type(struct type *, struct token *); 376 struct vreg *get_sizeof_vla_type(struct type *, struct icode_list *); 377 struct vreg *get_sizeof_elem_vla_type(struct type *, struct icode_list *); 378 size_t generic_print_init_var(FILE *out, struct decl *d, size_t segoff, 379 void (*print_init_expr)(struct type *, struct expr *), 380 int skip_is_space); 381 void generic_print_init_list(FILE *out, struct decl *, struct initializer *, 382 void (*print_init_expr)(struct type *, struct expr *)); 383 void new_generic_print_init_list(FILE *out, struct decl *, struct initializer *, 384 void (*print_init_expr)(struct type *, struct expr *)); 385 void relocate_struct_regs(struct copystruct *cs, struct reg *r0, 386 struct reg *r1, struct reg *r2, struct icode_list *il); 387 void copy_struct_regstack(struct decl *dec); 388 void store_reg_to_stack_block(struct reg *, struct stack_block *); 389 unsigned long align_for_cur_auto_var(struct type *ty, unsigned long off); 390 char *generic_elf_section_name(int value); 391 char *generic_mach_o_section_name(int value); 392 struct decl *get_next_auto_decl_in_scope(struct scope *, int); 393 394 #include <stdarg.h> 395 396 /* Various declarations (struct init, strings, etc) */ 397 398 /* 399 * 03/22/08: New: Support declarations for assemblers like nasm that need 400 * them to e.g. call memcpy() when assigning structs by value 401 */ 402 typedef void (*support_decls_func_t)(void); 403 404 typedef void (*extern_decls_func_t)(void); 405 /* 406 * 03/22/08: New: Global declarations split from extern/static variable 407 * definitions 408 */ 409 typedef void (*global_extern_decls_func_t)(struct decl **d, int ndecls); 410 typedef void (*global_static_decls_func_t)(struct decl **d, int ndecls); 411 412 #if 0 413 typedef void (*static_decls_func_t)(void); 414 #endif 415 typedef void (*static_init_vars_func_t)(struct decl *list); 416 typedef void (*static_uninit_vars_func_t)(struct decl *list); 417 typedef void (*static_init_thread_vars_func_t)(struct decl *list); 418 typedef void (*static_uninit_thread_vars_func_t)(struct decl *list); 419 420 421 typedef void (*struct_defs_func_t)(void); 422 typedef void (*struct_inits_func_t)(struct init_with_name *list); 423 424 struct ty_float; 425 struct ty_llong; 426 427 typedef void (*strings_func_t)(struct ty_string *str); 428 typedef void (*fp_constants_func_t)(struct ty_float *fp); /* opt */ 429 typedef void (*llong_constants_func_t)(struct ty_llong *ll); /* opt */ 430 typedef void (*support_buffers_func_t)(void); /* opt, fp conv, etc */ 431 typedef void (*pic_support_func_t)(void); /* opt, cmdline */ 432 433 434 435 typedef void (*comment_func_t)(const char *fmt, ...); 436 typedef void (*dwarf2_line_func_t)(struct token *); 437 typedef void (*dwarf2_files_func_t)(void); 438 typedef void (*inlineasm_func_t)(struct inline_asm_stmt *); 439 typedef void (*genunimpl_func_t)(void); 440 typedef void (*empty_func_t)(void); 441 typedef void (*label_func_t)(const char *label, int is_func); 442 typedef void (*call_func_t)(const char *name); 443 typedef void (*call_indir_func_t)(struct reg *r); 444 typedef void (*func_header_t)(struct function *f); 445 typedef void (*func_intro_t)(struct function *f); 446 typedef void (*func_outro_t)(struct function *f); 447 typedef void (*define_func_t)(const char *name, const char *fmt, ...); 448 typedef void (*push_func_t)(struct function *f, struct icode_instr *); 449 typedef void (*allocstack_func_t)(struct function *f, size_t bytes); 450 typedef void (*freestack_func_t)(struct function *f, size_t *bytes); 451 typedef void (*adj_allocated_func_t)(struct function *f, int *bytes); 452 typedef void (*inc_func_t)(struct icode_instr *); 453 typedef void (*dec_func_t)(struct icode_instr *); 454 typedef void (*load_func_t)(struct reg *r, struct vreg *vr); 455 typedef void (*load_addrlabel_func_t)(struct reg *r, struct icode_instr *label); 456 typedef void (*comp_goto_func_t)(struct reg *addr); 457 typedef void (*store_func_t)(struct vreg *dest, struct vreg *src); 458 typedef void (*neg_func_t)(struct reg **dest, struct icode_instr *src); 459 typedef void (*sub_func_t)(struct reg **dest, struct icode_instr *src); 460 typedef void (*add_func_t)(struct reg **dest, struct icode_instr *src); 461 typedef void 462 (*div_func_t)(struct reg **dest, struct icode_instr *src, int); 463 typedef void (*mod_func_t)(struct reg **dest, struct icode_instr *src); 464 typedef void (*mul_func_t)(struct reg **dest, struct icode_instr *src); 465 typedef void (*shl_func_t)(struct reg **dest, struct icode_instr *src); 466 typedef void (*shr_func_t)(struct reg **dest, struct icode_instr *src); 467 typedef void (*or_func_t)(struct reg **dest, struct icode_instr *src); 468 typedef void (*preg_or_func_t)(struct reg **dest, struct icode_instr *src); 469 typedef void (*and_func_t)(struct reg **dest, struct icode_instr *src); 470 typedef void (*xor_func_t)(struct reg **dest, struct icode_instr *src); 471 typedef void (*not_func_t)(struct reg **dest, struct icode_instr *src); 472 typedef void (*cmp_func_t)(struct reg **dest, struct icode_instr *ii); 473 typedef void (*extend_sign_func_t)(struct icode_instr *ii); 474 typedef void (*conv_fp_func_t)(struct icode_instr *ii); 475 typedef void (*conv_to_ldouble_func_t)(struct icode_instr *ii); 476 typedef void (*conv_from_ldouble_func_t)(struct icode_instr *ii); 477 typedef void (*branch_func_t)(struct icode_instr *ii); 478 479 #define SECTION_STACK 1 /* never used? */ 480 #define SECTION_UNINIT 2 481 #define SECTION_INIT 3 482 #define SECTION_TEXT 4 483 #define SECTION_RODATA 5 484 485 /* 02/02/08: TLS sections */ 486 #define SECTION_INIT_THREAD 6 487 #define SECTION_UNINIT_THREAD 7 488 489 /* 12/25/08: PPC TOC */ 490 #define SECTION_TOC 8 491 492 493 typedef void (*setsection_func_t)(int value); 494 typedef void (*alloc_func_t)(size_t nbytes); 495 typedef void (*ret_func_t)(struct icode_instr *ii); 496 typedef void (*mov_func_t)(struct copyreg *cr); 497 typedef void (*setreg_func_t)(struct reg *dest, int *value); 498 typedef void (*xchg_func_t)(struct reg *r1, struct reg *r2); 499 typedef void (*addrof_func_t)(struct reg *dest, struct vreg *src, 500 struct vreg *structtop); 501 typedef void (*initialize_pic_func_t)(struct function *f); 502 typedef void (*copyinit_func_t)(struct decl *dec); 503 typedef void (*putstructregs_func_t)(struct putstructregs *ps); 504 typedef void (*copystruct_func_t)(struct copystruct *cs); 505 typedef void (*intrinsic_memcpy_func_t)(struct int_memcpy_data *cs); 506 typedef void (*zerostack_func_t)(struct stack_block *addr, size_t nbytes); 507 typedef void (*alloca_func_t)(struct allocadata *ad); 508 typedef void (*dealloca_func_t)(struct stack_block *sb, struct reg *r); 509 typedef void (*alloc_vla_func_t)(struct stack_block *ad); 510 typedef void (*dealloc_vla_func_t)(struct stack_block *sb, struct reg *r); 511 typedef void (*put_vla_size_func_t)(struct vlasizedata *data); 512 typedef void (*retr_vla_size_func_t)(struct vlasizedata *data); 513 typedef void (*load_vla_func_t)(struct reg *r, struct stack_block *sb); 514 typedef void (*builtin_frame_address_func_t)(struct builtinframeaddressdata *); 515 typedef void (*save_ret_addr_func_t)(struct function *, 516 struct stack_block *); 517 typedef void 518 (*check_ret_addr_func_t)(struct function *, struct stack_block *); 519 typedef void (*print_mem_operand_func_t)(struct vreg *, struct token *); 520 typedef void (*finish_program_func_t)(void); 521 522 typedef void (*stupidtrace_func_t)(struct stupidtrace_entry *f); 523 typedef void (*finish_stupidtrace_func_t)(struct stupidtrace_entry *e); 524 525 struct emitter { 526 /* 527 * 04/08/08: New flag to specify whether the assembler demands 528 * explicit symbol declarations when referencing external symbols, 529 * like nasm and yasm (but not gas) do 530 */ 531 int need_explicit_extern_decls; 532 init_func_t init; 533 strings_func_t strings; 534 fp_constants_func_t fp_constants; /* half-opt */ 535 llong_constants_func_t llong_constants; /* opt */ 536 support_buffers_func_t support_buffers; /* opt */ 537 pic_support_func_t pic_support; /* opt */ 538 539 support_decls_func_t support_decls; /* opt */ 540 extern_decls_func_t extern_decls; 541 global_extern_decls_func_t global_extern_decls; 542 global_static_decls_func_t global_static_decls; 543 #if 0 544 static_decls_func_t static_decls; 545 #endif 546 static_init_vars_func_t static_init_vars; 547 static_uninit_vars_func_t static_uninit_vars; 548 static_init_thread_vars_func_t static_init_thread_vars; 549 static_uninit_thread_vars_func_t static_uninit_thread_vars; 550 551 struct_defs_func_t struct_defs; 552 comment_func_t comment; 553 554 /* 10 */ 555 dwarf2_line_func_t dwarf2_line; 556 dwarf2_files_func_t dwarf2_files; 557 inlineasm_func_t inlineasm; 558 genunimpl_func_t genunimpl; 559 empty_func_t empty; 560 label_func_t label; 561 call_func_t call; 562 call_indir_func_t callindir; 563 func_header_t func_header; 564 func_intro_t intro; 565 566 /* 20 */ 567 func_outro_t outro; 568 define_func_t define; 569 push_func_t push; 570 allocstack_func_t allocstack; 571 freestack_func_t freestack; 572 adj_allocated_func_t adj_allocated; 573 inc_func_t inc; 574 dec_func_t dec; 575 load_func_t load; 576 load_addrlabel_func_t load_addrlabel; 577 comp_goto_func_t comp_goto; 578 store_func_t store; 579 580 /* 30 */ 581 setsection_func_t setsection; 582 alloc_func_t alloc; 583 neg_func_t neg; 584 sub_func_t sub; 585 add_func_t add; 586 div_func_t div; 587 mod_func_t mod; 588 mul_func_t mul; 589 shl_func_t shl; 590 shr_func_t shr; 591 592 /* 40 */ 593 or_func_t or; 594 preg_or_func_t preg_or; 595 and_func_t and; 596 xor_func_t xor; 597 not_func_t not; 598 ret_func_t ret; 599 cmp_func_t cmp; 600 extend_sign_func_t extend_sign; 601 conv_fp_func_t conv_fp; 602 conv_from_ldouble_func_t conv_from_ldouble; 603 conv_to_ldouble_func_t conv_to_ldouble; 604 branch_func_t branch; 605 606 /* 50 */ 607 mov_func_t mov; 608 setreg_func_t setreg; 609 xchg_func_t xchg; 610 addrof_func_t addrof; 611 initialize_pic_func_t initialize_pic; 612 copyinit_func_t copyinit; 613 putstructregs_func_t putstructregs; 614 copystruct_func_t copystruct; 615 intrinsic_memcpy_func_t intrinsic_memcpy; 616 zerostack_func_t zerostack; 617 alloca_func_t alloca_; 618 619 /* 60 */ 620 dealloca_func_t dealloca; 621 alloc_vla_func_t alloc_vla; 622 dealloc_vla_func_t dealloc_vla; 623 put_vla_size_func_t put_vla_size; 624 retr_vla_size_func_t retr_vla_size; 625 load_vla_func_t load_vla; 626 builtin_frame_address_func_t frame_address; 627 struct_inits_func_t struct_inits; 628 save_ret_addr_func_t save_ret_addr; 629 check_ret_addr_func_t check_ret_addr; 630 631 /* 70 */ 632 print_mem_operand_func_t print_mem_operand; 633 finish_program_func_t finish_program; 634 635 stupidtrace_func_t stupidtrace; 636 finish_stupidtrace_func_t finish_stupidtrace; 637 }; 638 639 extern struct backend *backend; 640 extern struct emitter *emit; 641 extern struct reg *tmpgpr; 642 extern struct reg *tmpgpr2; 643 extern struct reg *tmpfpr; 644 extern struct reg *pic_reg; 645 extern int host_endianness; 646 extern struct init_with_name *init_list_head; 647 extern struct init_with_name *init_list_tail; 648 extern int backend_warn_inv; 649 650 651 struct allocation { 652 int unused; 653 }; 654 655 #define ALLOC_GPR(func, size, il, dontwipe) \ 656 backend->alloc_gpr((func), (size), (il), (dontwipe), __LINE__) 657 658 #include "x86_gen.h" 659 #include "mips_gen.h" 660 #include "amd64_gen.h" 661 #include "power_gen.h" 662 #include "sparc_gen.h" 663 #include "reg.h" 664 #include "stack.h" 665 666 #endif 667 668