Damien | 429d719 | 2013-10-04 19:53:11 +0100 | [diff] [blame] | 1 | #define ASM_THUMB_PASS_1 (1) |
| 2 | #define ASM_THUMB_PASS_2 (2) |
| 3 | #define ASM_THUMB_PASS_3 (3) |
| 4 | |
| 5 | #define REG_R0 (0) |
| 6 | #define REG_R1 (1) |
| 7 | #define REG_R2 (2) |
| 8 | #define REG_R3 (3) |
| 9 | #define REG_R4 (4) |
| 10 | #define REG_R5 (5) |
| 11 | #define REG_R6 (6) |
| 12 | #define REG_R7 (7) |
| 13 | #define REG_R8 (8) |
| 14 | #define REG_R9 (9) |
| 15 | #define REG_R10 (10) |
| 16 | #define REG_R11 (11) |
| 17 | #define REG_R12 (12) |
| 18 | #define REG_R13 (13) |
| 19 | #define REG_R14 (14) |
| 20 | #define REG_R15 (15) |
| 21 | #define REG_LR (REG_R14) |
| 22 | |
| 23 | #define REG_RET REG_R0 |
| 24 | #define REG_ARG_1 REG_R0 |
| 25 | #define REG_ARG_2 REG_R1 |
| 26 | #define REG_ARG_3 REG_R2 |
| 27 | #define REG_ARG_4 REG_R3 |
| 28 | |
Damien | 1a6633a | 2013-11-03 13:58:19 +0000 | [diff] [blame] | 29 | #define THUMB_CC_EQ (0x0) |
| 30 | #define THUMB_CC_NE (0x1) |
| 31 | #define THUMB_CC_CS (0x2) |
| 32 | #define THUMB_CC_CC (0x3) |
| 33 | #define THUMB_CC_MI (0x4) |
| 34 | #define THUMB_CC_PL (0x5) |
| 35 | #define THUMB_CC_VS (0x6) |
| 36 | #define THUMB_CC_VC (0x7) |
| 37 | #define THUMB_CC_HI (0x8) |
| 38 | #define THUMB_CC_LS (0x9) |
| 39 | #define THUMB_CC_GE (0xa) |
| 40 | #define THUMB_CC_LT (0xb) |
| 41 | #define THUMB_CC_GT (0xc) |
| 42 | #define THUMB_CC_LE (0xd) |
| 43 | |
Damien | 429d719 | 2013-10-04 19:53:11 +0100 | [diff] [blame] | 44 | typedef struct _asm_thumb_t asm_thumb_t; |
| 45 | |
Damien | 5bfb759 | 2013-10-05 18:41:24 +0100 | [diff] [blame] | 46 | asm_thumb_t *asm_thumb_new(uint max_num_labels); |
Damien | 429d719 | 2013-10-04 19:53:11 +0100 | [diff] [blame] | 47 | void asm_thumb_free(asm_thumb_t *as, bool free_code); |
| 48 | void asm_thumb_start_pass(asm_thumb_t *as, int pass); |
| 49 | void asm_thumb_end_pass(asm_thumb_t *as); |
| 50 | uint asm_thumb_get_code_size(asm_thumb_t *as); |
| 51 | void *asm_thumb_get_code(asm_thumb_t *as); |
| 52 | |
| 53 | void asm_thumb_entry(asm_thumb_t *as, int num_locals); |
| 54 | void asm_thumb_exit(asm_thumb_t *as); |
| 55 | |
Damien | 429d719 | 2013-10-04 19:53:11 +0100 | [diff] [blame] | 56 | void asm_thumb_label_assign(asm_thumb_t *as, int label); |
| 57 | |
| 58 | // argument order follows ARM, in general dest is first |
Damien | 826005c | 2013-10-05 23:17:28 +0100 | [diff] [blame] | 59 | // note there is a difference between movw and mov.w, and many others! |
Damien | 429d719 | 2013-10-04 19:53:11 +0100 | [diff] [blame] | 60 | |
Damien | 826005c | 2013-10-05 23:17:28 +0100 | [diff] [blame] | 61 | void asm_thumb_movs_rlo_i8(asm_thumb_t *as, uint rlo_dest, int i8_src); |
| 62 | void asm_thumb_movw_reg_i16(asm_thumb_t *as, uint reg_dest, int i16_src); |
| 63 | void asm_thumb_movt_reg_i16(asm_thumb_t *as, uint reg_dest, int i16_src); |
Damien | 429d719 | 2013-10-04 19:53:11 +0100 | [diff] [blame] | 64 | void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src); |
Damien George | 47e1b85 | 2014-04-08 18:28:33 +0100 | [diff] [blame] | 65 | void asm_thumb_add_reg_reg_reg(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b); |
Damien | 826005c | 2013-10-05 23:17:28 +0100 | [diff] [blame] | 66 | void asm_thumb_subs_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src, int i3_src); |
Damien George | 47e1b85 | 2014-04-08 18:28:33 +0100 | [diff] [blame] | 67 | void asm_thumb_cmp_reg_reg(asm_thumb_t *as, uint rlo_a, uint rlo_b); |
Damien | 826005c | 2013-10-05 23:17:28 +0100 | [diff] [blame] | 68 | void asm_thumb_cmp_rlo_i8(asm_thumb_t *as, uint rlo, int i8); |
Damien George | 47e1b85 | 2014-04-08 18:28:33 +0100 | [diff] [blame] | 69 | void asm_thumb_ite_ge(asm_thumb_t *as); |
Damien | 03d4124 | 2013-10-06 00:36:05 +0100 | [diff] [blame] | 70 | void asm_thumb_b_n(asm_thumb_t *as, int label); |
Damien | 1a6633a | 2013-11-03 13:58:19 +0000 | [diff] [blame] | 71 | void asm_thumb_bcc_n(asm_thumb_t *as, int cond, int label); |
Damien | 429d719 | 2013-10-04 19:53:11 +0100 | [diff] [blame] | 72 | |
Damien | 826005c | 2013-10-05 23:17:28 +0100 | [diff] [blame] | 73 | void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, machine_uint_t i32_src); // convenience |
| 74 | void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int i32_src); // convenience |
| 75 | void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num_dest, uint rlo_src); // convenience |
| 76 | void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num); // convenience |
Damien | 9b9e996 | 2013-11-03 14:25:43 +0000 | [diff] [blame] | 77 | void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num); // convenience |
Damien | 429d719 | 2013-10-04 19:53:11 +0100 | [diff] [blame] | 78 | |
Damien | 826005c | 2013-10-05 23:17:28 +0100 | [diff] [blame] | 79 | void asm_thumb_b_label(asm_thumb_t *as, int label); // convenience ? |
Damien | 1a6633a | 2013-11-03 13:58:19 +0000 | [diff] [blame] | 80 | void asm_thumb_bcc_label(asm_thumb_t *as, int cc, int label); // convenience: picks narrow or wide branch |
Damien | 826005c | 2013-10-05 23:17:28 +0100 | [diff] [blame] | 81 | void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp); // convenience ? |
| 82 | |