Unified · Split
| @@ -179,7 +179,7 @@ i386-win32_FILES = $(i386_FILES) tccpe.c · 178 unmodified lines | |||
| 179 | x86_64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-link.c i386-asm.c x86_64-asm.h | 179 | x86_64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-link.c i386-asm.c x86_64-asm.h |
| 180 | x86_64-win32_FILES = $(x86_64_FILES) tccpe.c | 180 | x86_64-win32_FILES = $(x86_64_FILES) tccpe.c |
| 181 | x86_64-osx_FILES = $(x86_64_FILES) tccmacho.c | 181 | x86_64-osx_FILES = $(x86_64_FILES) tccmacho.c |
| 182 | arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c | 182 | arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c arm-tok.h |
| 183 | arm-wince_FILES = $(arm_FILES) tccpe.c | 183 | arm-wince_FILES = $(arm_FILES) tccpe.c |
| 184 | arm-eabihf_FILES = $(arm_FILES) | 184 | arm-eabihf_FILES = $(arm_FILES) |
| 185 | arm-fpa_FILES = $(arm_FILES) | 185 | arm-fpa_FILES = $(arm_FILES) |
| @@ -81,13 +81,42 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, · 80 unmodified lines | |||
| 81 | 81 | ||
| 82 | ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str) | 82 | ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str) |
| 83 | { | 83 | { |
| 84 | asm_error(); | 84 | int reg; |
| 85 | TokenSym *ts; | ||
| 86 | |||
| 87 | if (!strcmp(str, "memory") || | ||
| 88 | !strcmp(str, "cc") || | ||
| 89 | !strcmp(str, "flags")) | ||
| 90 | return; | ||
| 91 | ts = tok_alloc(str, strlen(str)); | ||
| 92 | reg = asm_parse_regvar(ts->tok); | ||
| 93 | if (reg == -1) { | ||
| 94 | tcc_error("invalid clobber register '%s'", str); | ||
| 95 | } | ||
| 96 | clobber_regs[reg] = 1; | ||
| 85 | } | 97 | } |
| 86 | 98 | ||
| 99 | /* If T refers to a register then return the register number and type. | ||
| 100 | Otherwise return -1. */ | ||
| 87 | ST_FUNC int asm_parse_regvar (int t) | 101 | ST_FUNC int asm_parse_regvar (int t) |
| 88 | { | 102 | { |
| 89 | asm_error(); | 103 | if (t >= TOK_ASM_r0 && t <= TOK_ASM_pc) { /* register name */ |
| 90 | return -1; | 104 | switch (t) { |
| 105 | case TOK_ASM_fp: | ||
| 106 | return TOK_ASM_r11 - TOK_ASM_r0; | ||
| 107 | case TOK_ASM_ip: | ||
| 108 | return TOK_ASM_r12 - TOK_ASM_r0; | ||
| 109 | case TOK_ASM_sp: | ||
| 110 | return TOK_ASM_r13 - TOK_ASM_r0; | ||
| 111 | case TOK_ASM_lr: | ||
| 112 | return TOK_ASM_r14 - TOK_ASM_r0; | ||
| 113 | case TOK_ASM_pc: | ||
| 114 | return TOK_ASM_r15 - TOK_ASM_r0; | ||
| 115 | default: | ||
| 116 | return t - TOK_ASM_r0; | ||
| 117 | } | ||
| 118 | } else | ||
| 119 | return -1; | ||
| 91 | } | 120 | } |
| 92 | 121 | ||
| 93 | /*************************************************************/ | 122 | /*************************************************************/ |
| @@ -0,0 +1,29 @@ | |||
| 1 | /* ------------------------------------------------------------------ */ | ||
| 2 | /* WARNING: relative order of tokens is important. */ | ||
| 3 | |||
| 4 | /* register */ | ||
| 5 | |||
| 6 | DEF_ASM(r0) | ||
| 7 | DEF_ASM(r1) | ||
| 8 | DEF_ASM(r2) | ||
| 9 | DEF_ASM(r3) | ||
| 10 | DEF_ASM(r4) | ||
| 11 | DEF_ASM(r5) | ||
| 12 | DEF_ASM(r6) | ||
| 13 | DEF_ASM(r7) | ||
| 14 | DEF_ASM(r8) | ||
| 15 | DEF_ASM(r9) | ||
| 16 | DEF_ASM(r10) | ||
| 17 | DEF_ASM(r11) /* fp */ | ||
| 18 | DEF_ASM(r12) /* ip[c] */ | ||
| 19 | DEF_ASM(r13) /* sp */ | ||
| 20 | DEF_ASM(r14) /* lr */ | ||
| 21 | DEF_ASM(r15) /* pc */ | ||
| 22 | |||
| 23 | /* register macros */ | ||
| 24 | |||
| 25 | DEF_ASM(fp) /* alias for r11 */ | ||
| 26 | DEF_ASM(ip) /* alias for r12 */ | ||
| 27 | DEF_ASM(sp) /* alias for r13 */ | ||
| 28 | DEF_ASM(lr) /* alias for r14 */ | ||
| 29 | DEF_ASM(pc) /* alias for r15 */ | ||
| @@ -370,3 +370,6 @@ · 369 unmodified lines | |||
| 370 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 | 370 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 |
| 371 | #include "i386-tok.h" | 371 | #include "i386-tok.h" |
| 372 | #endif | 372 | #endif |
| 373 | #if defined TCC_TARGET_ARM | ||
| 374 | #include "arm-tok.h" | ||
| 375 | #endif | ||