3 * The 'abi' structure is pretty much just a grab-bag of machine
4 * dependencies and structure-layout information. Part of the latter
5 * is shared with trans and semant.
7 * Make some attempt to factor it as time goes by.
10 (* Word offsets for structure fields in rust-internal.h, and elsewhere in
13 let rc_base_field_refcnt = 0;;
15 let task_field_refcnt = rc_base_field_refcnt;;
16 let task_field_stk = task_field_refcnt + 1;;
17 let task_field_runtime_sp = task_field_stk + 1;;
18 let task_field_rust_sp = task_field_runtime_sp + 1;;
19 let task_field_gc_alloc_chain = task_field_rust_sp + 1;;
20 let task_field_dom = task_field_gc_alloc_chain + 1;;
21 let n_visible_task_fields = task_field_dom + 1;;
23 let dom_field_interrupt_flag = 0;;
25 let frame_glue_fns_field_mark = 0;;
26 let frame_glue_fns_field_drop = 1;;
27 let frame_glue_fns_field_reloc = 2;;
29 let exterior_rc_slot_field_refcnt = 0;;
30 let exterior_rc_slot_field_body = 1;;
32 let exterior_gc_slot_field_next = (-2);;
33 let exterior_gc_slot_field_ctrl = (-1);;
34 let exterior_gc_slot_field_refcnt = 0;;
35 let exterior_gc_slot_field_body = 1;;
37 let exterior_rc_header_size = 1;;
38 let exterior_gc_header_size = 3;;
40 let exterior_gc_malloc_return_adjustment = 2;;
42 let stk_field_valgrind_id = 0 + 1;;
43 let stk_field_limit = stk_field_valgrind_id + 1;;
44 let stk_field_data = stk_field_limit + 1;;
46 let binding_size = 2;;
47 let binding_field_item = 0;;
48 let binding_field_binding = 1;;
50 let general_code_alignment = 16;;
52 let tydesc_field_first_param = 0;;
53 let tydesc_field_size = 1;;
54 let tydesc_field_align = 2;;
55 let tydesc_field_copy_glue = 3;;
56 let tydesc_field_drop_glue = 4;;
57 let tydesc_field_free_glue = 5;;
58 let tydesc_field_mark_glue = 6;;
59 let tydesc_field_obj_drop_glue = 7;;
62 let vec_elt_alloc = 1;;
63 let vec_elt_fill = 2;;
64 let vec_elt_data = 3;;
66 let calltup_elt_out_ptr = 0;;
67 let calltup_elt_task_ptr = 1;;
68 let calltup_elt_ty_params = 2;;
69 let calltup_elt_args = 3;;
70 let calltup_elt_iterator_args = 4;;
71 let calltup_elt_indirect_args = 5;;
73 let iterator_args_elt_block_fn = 0;;
74 let iterator_args_elt_outer_frame_ptr = 1;;
76 let indirect_args_elt_closure = 0;;
78 (* ty_params, src, dst, tydesc, taskptr. *)
79 let worst_case_glue_call_args = 5;;
84 abi_word_bits: Il.bits;
85 abi_word_ty: Common.ty_mach;
87 abi_is_2addr_machine: bool;
88 abi_has_pcrel_data: bool;
89 abi_has_pcrel_code: bool;
92 abi_str_of_hardreg: (int -> string);
94 abi_prealloc_quad: (Il.quad' -> Il.quad');
95 abi_constrain_vregs: (Il.quad -> Bits.t array -> unit);
97 abi_emit_fn_prologue: (Il.emitter
98 -> Common.size (* framesz *)
99 -> Common.size (* callsz *)
101 -> Common.fixup (* grow_task *)
104 abi_emit_fn_epilogue: (Il.emitter -> unit);
106 abi_emit_fn_tail_call: (Il.emitter
107 -> int64 (* caller_callsz *)
108 -> int64 (* caller_argsz *)
109 -> Il.code (* callee_code *)
110 -> int64 (* callee_argsz *)
113 abi_clobbers: (Il.quad -> Il.hreg list);
115 abi_emit_native_call: (Il.emitter
118 -> Common.fixup (* callee *)
119 -> Il.operand array (* args *)
122 abi_emit_native_void_call: (Il.emitter
124 -> Common.fixup (* callee *)
125 -> Il.operand array (* args *)
128 abi_emit_native_call_in_thunk: (Il.emitter
131 -> Il.operand (* callee *)
132 -> Il.operand array (* args *)
134 abi_emit_inline_memcpy: (Il.emitter
135 -> int64 (* n_bytes *)
136 -> Il.reg (* dst_ptr *)
137 -> Il.reg (* src_ptr *)
138 -> Il.reg (* tmp_reg *)
139 -> bool (* ascending *)
143 abi_activate: (Il.emitter -> unit);
144 abi_yield: (Il.emitter -> unit);
145 abi_unwind: (Il.emitter -> Common.nabi -> Common.fixup -> unit);
146 abi_get_next_pc_thunk:
147 ((Il.reg (* output *)
148 * Common.fixup (* thunk in objfile *)
149 * (Il.emitter -> unit)) (* fn to make thunk *)
154 abi_dwarf_fp_reg: int;
155 abi_tp_cell: Il.cell;
156 abi_implicit_args_sz: int64;
157 abi_frame_base_sz: int64;
158 abi_frame_info_sz: int64;
159 abi_spill_slot: (Il.spill -> Il.mem);
170 let cell = Il.Reg (out_reg, Il.AddrTy rty) in
171 let op = Il.ImmPtr (fix, rty) in
172 Il.emit e (Il.lea cell op);
175 let load_fixup_codeptr
179 (has_pcrel_code:bool)
185 load_fixup_addr e out_reg fixup (Il.ScalarTy (Il.AddrTy Il.CodeTy));
186 Il.CodePtr (Il.Cell (Il.Mem (Il.RegIn (out_reg, None),
187 Il.ScalarTy (Il.AddrTy Il.CodeTy))))
191 then (Il.CodePtr (Il.ImmPtr (fixup, Il.CodeTy)))
194 load_fixup_addr e out_reg fixup Il.CodeTy;
195 Il.CodePtr (Il.Cell (Il.Reg (out_reg, Il.AddrTy Il.CodeTy)))
203 * indent-tabs-mode: nil
204 * buffer-file-coding-system: utf-8-unix
205 * compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";