This reverts commit 61537d899af7bc163238ac21f666170ad84b6851.
Unified · Split
| @@ -24,9 +24,9 @@ · 23 unmodified lines | |||
| 24 | #define CONFIG_TCC_ASM | 24 | #define CONFIG_TCC_ASM |
| 25 | #define NB_ASM_REGS 16 | 25 | #define NB_ASM_REGS 16 |
| 26 | 26 | ||
| 27 | ST_FUNC void g(TCCState *S, int c); | 27 | ST_FUNC void g(TCCState* S, int c); |
| 28 | ST_FUNC void gen_le16(TCCState *S, int c); | 28 | ST_FUNC void gen_le16(TCCState* S, int c); |
| 29 | ST_FUNC void gen_le32(TCCState *S, int c); | 29 | ST_FUNC void gen_le32(TCCState* S, int c); |
| 30 | 30 | ||
| 31 | /*************************************************************/ | 31 | /*************************************************************/ |
| 32 | #else | 32 | #else |
| @@ -100,10 +100,10 @@ static void parse_operand(TCCState *S, Operand *op) · 67 unmodified lines | |||
| 100 | 100 | ||
| 101 | op->type = 0; | 101 | op->type = 0; |
| 102 | 102 | ||
| 103 | if (S->tok == '{') { // regset literal | 103 | if (S->tccpp_tok == '{') { // regset literal |
| 104 | next(S); // skip '{' | 104 | next(S); // skip '{' |
| 105 | while (S->tok != '}' && S->tok != TOK_EOF) { | 105 | while (S->tccpp_tok != '}' && S->tccpp_tok != TOK_EOF) { |
| 106 | reg = asm_parse_regvar(S, S->tok); | 106 | reg = asm_parse_regvar(S, S->tccpp_tok); |
| 107 | if (reg == -1) { | 107 | if (reg == -1) { |
| 108 | expect(S, "register"); | 108 | expect(S, "register"); |
| 109 | return; | 109 | return; |
| @@ -113,11 +113,11 @@ static void parse_operand(TCCState *S, Operand *op) · 3 unmodified lines | |||
| 113 | if ((1 << reg) < regset) | 113 | if ((1 << reg) < regset) |
| 114 | tcc_warning(S, "registers will be processed in ascending order by hardware--but are not specified in ascending order here"); | 114 | tcc_warning(S, "registers will be processed in ascending order by hardware--but are not specified in ascending order here"); |
| 115 | regset |= 1 << reg; | 115 | regset |= 1 << reg; |
| 116 | if (S->tok != ',') | 116 | if (S->tccpp_tok != ',') |
| 117 | break; | 117 | break; |
| 118 | next(S); // skip ',' | 118 | next(S); // skip ',' |
| 119 | } | 119 | } |
| 120 | if (S->tok != '}') | 120 | if (S->tccpp_tok != '}') |
| 121 | expect(S, "'}'"); | 121 | expect(S, "'}'"); |
| 122 | next(S); // skip '}' | 122 | next(S); // skip '}' |
| 123 | if (regset == 0) { | 123 | if (regset == 0) { |
| @@ -128,22 +128,22 @@ static void parse_operand(TCCState *S, Operand *op) · 4 unmodified lines | |||
| 128 | op->regset = regset; | 128 | op->regset = regset; |
| 129 | } | 129 | } |
| 130 | return; | 130 | return; |
| 131 | } else if ((reg = asm_parse_regvar(S, S->tok)) != -1) { | 131 | } else if ((reg = asm_parse_regvar(S, S->tccpp_tok)) != -1) { |
| 132 | next(S); // skip register name | 132 | next(S); // skip register name |
| 133 | op->type = OP_REG32; | 133 | op->type = OP_REG32; |
| 134 | op->reg = (uint8_t) reg; | 134 | op->reg = (uint8_t) reg; |
| 135 | return; | 135 | return; |
| 136 | } else if ((reg = asm_parse_vfp_regvar(S->tok, 0)) != -1) { | 136 | } else if ((reg = asm_parse_vfp_regvar(S->tccpp_tok, 0)) != -1) { |
| 137 | next(S); // skip register name | 137 | next(S); // skip register name |
| 138 | op->type = OP_VREG32; | 138 | op->type = OP_VREG32; |
| 139 | op->reg = (uint8_t) reg; | 139 | op->reg = (uint8_t) reg; |
| 140 | return; | 140 | return; |
| 141 | } else if ((reg = asm_parse_vfp_regvar(S->tok, 1)) != -1) { | 141 | } else if ((reg = asm_parse_vfp_regvar(S->tccpp_tok, 1)) != -1) { |
| 142 | next(S); // skip register name | 142 | next(S); // skip register name |
| 143 | op->type = OP_VREG64; | 143 | op->type = OP_VREG64; |
| 144 | op->reg = (uint8_t) reg; | 144 | op->reg = (uint8_t) reg; |
| 145 | return; | 145 | return; |
| 146 | } else if (S->tok == '#' || S->tok == '$') { | 146 | } else if (S->tccpp_tok == '#' || S->tccpp_tok == '$') { |
| 147 | /* constant value */ | 147 | /* constant value */ |
| 148 | next(S); // skip '#' or '$' | 148 | next(S); // skip '#' or '$' |
| 149 | } | 149 | } |
| @@ -160,44 +160,44 @@ static void parse_operand(TCCState *S, Operand *op) · 10 unmodified lines | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | /* XXX: make it faster ? */ | 162 | /* XXX: make it faster ? */ |
| 163 | ST_FUNC void g(TCCState *S, int c) | 163 | ST_FUNC void g(TCCState* S, int c) |
| 164 | { | 164 | { |
| 165 | int ind1; | 165 | int ind1; |
| 166 | if (S->nocode_wanted) | 166 | if (S->tccgen_nocode_wanted) |
| 167 | return; | 167 | return; |
| 168 | ind1 = S->ind + 1; | 168 | ind1 = S->tccgen_ind + 1; |
| 169 | if (ind1 > cur_text_section->data_allocated) | 169 | if (ind1 > cur_text_section->data_allocated) |
| 170 | section_realloc(S, cur_text_section, ind1); | 170 | section_realloc(S, cur_text_section, ind1); |
| 171 | cur_text_section->data[S->ind] = c; | 171 | cur_text_section->data[S->tccgen_ind] = c; |
| 172 | S->ind = ind1; | 172 | S->tccgen_ind = ind1; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | ST_FUNC void gen_le16 (TCCState *S, int i) | 175 | ST_FUNC void gen_le16 (TCCState* S, int i) |
| 176 | { | 176 | { |
| 177 | g(S, i); | 177 | g(S, i); |
| 178 | g(S, i>>8); | 178 | g(S, i>>8); |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | ST_FUNC void gen_le32 (TCCState *S, int i) | 181 | ST_FUNC void gen_le32 (TCCState* S, int i) |
| 182 | { | 182 | { |
| 183 | int ind1; | 183 | int ind1; |
| 184 | if (S->nocode_wanted) | 184 | if (S->tccgen_nocode_wanted) |
| 185 | return; | 185 | return; |
| 186 | ind1 = S->ind + 4; | 186 | ind1 = S->tccgen_ind + 4; |
| 187 | if (ind1 > cur_text_section->data_allocated) | 187 | if (ind1 > cur_text_section->data_allocated) |
| 188 | section_realloc(S, cur_text_section, ind1); | 188 | section_realloc(S, cur_text_section, ind1); |
| 189 | cur_text_section->data[S->ind++] = i & 0xFF; | 189 | cur_text_section->data[S->tccgen_ind++] = i & 0xFF; |
| 190 | cur_text_section->data[S->ind++] = (i >> 8) & 0xFF; | 190 | cur_text_section->data[S->tccgen_ind++] = (i >> 8) & 0xFF; |
| 191 | cur_text_section->data[S->ind++] = (i >> 16) & 0xFF; | 191 | cur_text_section->data[S->tccgen_ind++] = (i >> 16) & 0xFF; |
| 192 | cur_text_section->data[S->ind++] = (i >> 24) & 0xFF; | 192 | cur_text_section->data[S->tccgen_ind++] = (i >> 24) & 0xFF; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe) | 195 | ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe) |
| 196 | { | 196 | { |
| 197 | gen_le32(S, pe->v); | 197 | gen_le32(S, pe->v); |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | static uint32_t condition_code_of_token(TCCState *S, int token) { | 200 | static uint32_t condition_code_of_token(TCCState* S, int token) { |
| 201 | if (token < TOK_ASM_nopeq) { | 201 | if (token < TOK_ASM_nopeq) { |
| 202 | expect(S, "condition-enabled instruction"); | 202 | expect(S, "condition-enabled instruction"); |
| 203 | return 0; | 203 | return 0; |
| @@ -205,15 +205,15 @@ static uint32_t condition_code_of_token(TCCState *S, int token) { · 1 unmodified line | |||
| 205 | return (token - TOK_ASM_nopeq) & 15; | 205 | return (token - TOK_ASM_nopeq) & 15; |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | static void asm_emit_opcode(TCCState *S, int token, uint32_t opcode) { | 208 | static void asm_emit_opcode(TCCState* S, int token, uint32_t opcode) { |
| 209 | gen_le32(S, (condition_code_of_token(S, token) << 28) | opcode); | 209 | gen_le32(S, (condition_code_of_token(S, token) << 28) | opcode); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | static void asm_emit_unconditional_opcode(TCCState *S, uint32_t opcode) { | 212 | static void asm_emit_unconditional_opcode(TCCState* S, uint32_t opcode) { |
| 213 | gen_le32(S, opcode); | 213 | gen_le32(S, opcode); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | static void asm_emit_coprocessor_opcode(TCCState *S, uint32_t high_nibble, uint8_t cp_number, uint8_t cp_opcode, uint8_t cp_destination_register, uint8_t cp_n_operand_register, uint8_t cp_m_operand_register, uint8_t cp_opcode2, int inter_processor_transfer) | 216 | static void asm_emit_coprocessor_opcode(TCCState* S, uint32_t high_nibble, uint8_t cp_number, uint8_t cp_opcode, uint8_t cp_destination_register, uint8_t cp_n_operand_register, uint8_t cp_m_operand_register, uint8_t cp_opcode2, int inter_processor_transfer) |
| 217 | { | 217 | { |
| 218 | uint32_t opcode = 0xe000000; | 218 | uint32_t opcode = 0xe000000; |
| 219 | if (inter_processor_transfer) | 219 | if (inter_processor_transfer) |
| @@ -233,7 +233,7 @@ static void asm_emit_coprocessor_opcode(TCCState *S, uint32_t high_nibble, uint8 · 13 unmodified lines | |||
| 233 | asm_emit_unconditional_opcode(S, (high_nibble << 28) | opcode); | 233 | asm_emit_unconditional_opcode(S, (high_nibble << 28) | opcode); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | static void asm_nullary_opcode(TCCState *S, int token) | 236 | static void asm_nullary_opcode(TCCState* S, int token) |
| 237 | { | 237 | { |
| 238 | switch (ARM_INSTRUCTION_GROUP(token)) { | 238 | switch (ARM_INSTRUCTION_GROUP(token)) { |
| 239 | case TOK_ASM_nopeq: | 239 | case TOK_ASM_nopeq: |
| @@ -276,7 +276,7 @@ static void asm_binary_opcode(TCCState *S, int token) · 36 unmodified lines | |||
| 276 | uint32_t encoded_rotation = 0; | 276 | uint32_t encoded_rotation = 0; |
| 277 | uint64_t amount; | 277 | uint64_t amount; |
| 278 | parse_operand(S, &ops[0]); | 278 | parse_operand(S, &ops[0]); |
| 279 | if (S->tok == ',') | 279 | if (S->tccpp_tok == ',') |
| 280 | next(S); | 280 | next(S); |
| 281 | else | 281 | else |
| 282 | expect(S, "','"); | 282 | expect(S, "','"); |
| @@ -328,9 +328,9 @@ static void asm_binary_opcode(TCCState *S, int token) · 45 unmodified lines | |||
| 328 | if (ops[1].reg == 13) | 328 | if (ops[1].reg == 13) |
| 329 | tcc_warning(S, "Using 'sp' as operand with '%s' is deprecated by ARM", get_tok_str(S, token, NULL)); | 329 | tcc_warning(S, "Using 'sp' as operand with '%s' is deprecated by ARM", get_tok_str(S, token, NULL)); |
| 330 | 330 | ||
| 331 | if (S->tok == ',') { | 331 | if (S->tccpp_tok == ',') { |
| 332 | next(S); // skip ',' | 332 | next(S); // skip ',' |
| 333 | if (S->tok == TOK_ASM_ror) { | 333 | if (S->tccpp_tok == TOK_ASM_ror) { |
| 334 | next(S); // skip 'ror' | 334 | next(S); // skip 'ror' |
| 335 | parse_operand(S, &rotation); | 335 | parse_operand(S, &rotation); |
| 336 | if (rotation.type != OP_IM8) { | 336 | if (rotation.type != OP_IM8) { |
| @@ -387,15 +387,15 @@ static void asm_coprocessor_opcode(TCCState *S, int token) { · 50 unmodified lines | |||
| 387 | uint8_t high_nibble; | 387 | uint8_t high_nibble; |
| 388 | uint8_t mrc = 0; | 388 | uint8_t mrc = 0; |
| 389 | 389 | ||
| 390 | if (S->tok >= TOK_ASM_p0 && S->tok <= TOK_ASM_p15) { | 390 | if (S->tccpp_tok >= TOK_ASM_p0 && S->tccpp_tok <= TOK_ASM_p15) { |
| 391 | coprocessor = S->tok - TOK_ASM_p0; | 391 | coprocessor = S->tccpp_tok - TOK_ASM_p0; |
| 392 | next(S); | 392 | next(S); |
| 393 | } else { | 393 | } else { |
| 394 | expect(S, "'p<number>'"); | 394 | expect(S, "'p<number>'"); |
| 395 | return; | 395 | return; |
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | if (S->tok == ',') | 398 | if (S->tccpp_tok == ',') |
| 399 | next(S); | 399 | next(S); |
| 400 | else | 400 | else |
| 401 | expect(S, "','"); | 401 | expect(S, "','"); |
| @@ -407,21 +407,21 @@ static void asm_coprocessor_opcode(TCCState *S, int token) { · 5 unmodified lines | |||
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | for (i = 0; i < 3; ++i) { | 409 | for (i = 0; i < 3; ++i) { |
| 410 | if (S->tok == ',') | 410 | if (S->tccpp_tok == ',') |
| 411 | next(S); | 411 | next(S); |
| 412 | else | 412 | else |
| 413 | expect(S, "','"); | 413 | expect(S, "','"); |
| 414 | if (i == 0 && token != TOK_ASM_cdp2 && (ARM_INSTRUCTION_GROUP(token) == TOK_ASM_mrceq || ARM_INSTRUCTION_GROUP(token) == TOK_ASM_mcreq)) { | 414 | if (i == 0 && token != TOK_ASM_cdp2 && (ARM_INSTRUCTION_GROUP(token) == TOK_ASM_mrceq || ARM_INSTRUCTION_GROUP(token) == TOK_ASM_mcreq)) { |
| 415 | if (S->tok >= TOK_ASM_r0 && S->tok <= TOK_ASM_r15) { | 415 | if (S->tccpp_tok >= TOK_ASM_r0 && S->tccpp_tok <= TOK_ASM_r15) { |
| 416 | registers[i] = S->tok - TOK_ASM_r0; | 416 | registers[i] = S->tccpp_tok - TOK_ASM_r0; |
| 417 | next(S); | 417 | next(S); |
| 418 | } else { | 418 | } else { |
| 419 | expect(S, "'r<number>'"); | 419 | expect(S, "'r<number>'"); |
| 420 | return; | 420 | return; |
| 421 | } | 421 | } |
| 422 | } else { | 422 | } else { |
| 423 | if (S->tok >= TOK_ASM_c0 && S->tok <= TOK_ASM_c15) { | 423 | if (S->tccpp_tok >= TOK_ASM_c0 && S->tccpp_tok <= TOK_ASM_c15) { |
| 424 | registers[i] = S->tok - TOK_ASM_c0; | 424 | registers[i] = S->tccpp_tok - TOK_ASM_c0; |
| 425 | next(S); | 425 | next(S); |
| 426 | } else { | 426 | } else { |
| 427 | expect(S, "'c<number>'"); | 427 | expect(S, "'c<number>'"); |
| @@ -429,7 +429,7 @@ static void asm_coprocessor_opcode(TCCState *S, int token) { · 1 unmodified line | |||
| 429 | } | 429 | } |
| 430 | } | 430 | } |
| 431 | } | 431 | } |
| 432 | if (S->tok == ',') { | 432 | if (S->tccpp_tok == ',') { |
| 433 | next(S); | 433 | next(S); |
| 434 | parse_operand(S, &opcode2); | 434 | parse_operand(S, &opcode2); |
| 435 | } else { | 435 | } else { |
| @@ -493,11 +493,11 @@ static void asm_block_data_transfer_opcode(TCCState *S, int token) · 57 unmodified lines | |||
| 493 | Operand ops[2]; | 493 | Operand ops[2]; |
| 494 | int nb_ops = 1; | 494 | int nb_ops = 1; |
| 495 | parse_operand(S, &ops[0]); | 495 | parse_operand(S, &ops[0]); |
| 496 | if (S->tok == '!') { | 496 | if (S->tccpp_tok == '!') { |
| 497 | op0_exclam = 1; | 497 | op0_exclam = 1; |
| 498 | next(S); // skip '!' | 498 | next(S); // skip '!' |
| 499 | } | 499 | } |
| 500 | if (S->tok == ',') { | 500 | if (S->tccpp_tok == ',') { |
| 501 | next(S); // skip comma | 501 | next(S); // skip comma |
| 502 | parse_operand(S, &ops[1]); | 502 | parse_operand(S, &ops[1]); |
| 503 | ++nb_ops; | 503 | ++nb_ops; |
| @@ -600,17 +600,17 @@ static void asm_block_data_transfer_opcode(TCCState *S, int token) · 96 unmodified lines | |||
| 600 | 600 | ||
| 601 | NB_SHIFT: will be set to 1 iff SHIFT is filled. Note that for rrx, there's no need to fill SHIFT. | 601 | NB_SHIFT: will be set to 1 iff SHIFT is filled. Note that for rrx, there's no need to fill SHIFT. |
| 602 | SHIFT: will be filled in with the shift operand to use, if any. */ | 602 | SHIFT: will be filled in with the shift operand to use, if any. */ |
| 603 | static uint32_t asm_parse_optional_shift(TCCState *S, int* nb_shift, Operand* shift) | 603 | static uint32_t asm_parse_optional_shift(TCCState* S, int* nb_shift, Operand* shift) |
| 604 | { | 604 | { |
| 605 | uint32_t opcode = 0; | 605 | uint32_t opcode = 0; |
| 606 | *nb_shift = 0; | 606 | *nb_shift = 0; |
| 607 | switch (S->tok) { | 607 | switch (S->tccpp_tok) { |
| 608 | case TOK_ASM_asl: | 608 | case TOK_ASM_asl: |
| 609 | case TOK_ASM_lsl: | 609 | case TOK_ASM_lsl: |
| 610 | case TOK_ASM_asr: | 610 | case TOK_ASM_asr: |
| 611 | case TOK_ASM_lsr: | 611 | case TOK_ASM_lsr: |
| 612 | case TOK_ASM_ror: | 612 | case TOK_ASM_ror: |
| 613 | switch (S->tok) { | 613 | switch (S->tccpp_tok) { |
| 614 | case TOK_ASM_asl: | 614 | case TOK_ASM_asl: |
| 615 | /* fallthrough */ | 615 | /* fallthrough */ |
| 616 | case TOK_ASM_lsl: | 616 | case TOK_ASM_lsl: |
| @@ -677,15 +677,15 @@ static void asm_data_processing_opcode(TCCState *S, int token) · 60 unmodified lines | |||
| 677 | uint32_t opcode_nos = opcode_idx >> 1; // without "s"; "OpCode" in ARM docs | 677 | uint32_t opcode_nos = opcode_idx >> 1; // without "s"; "OpCode" in ARM docs |
| 678 | 678 | ||
| 679 | for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ) { | 679 | for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ) { |
| 680 | if (S->tok == TOK_ASM_asl || S->tok == TOK_ASM_lsl || S->tok == TOK_ASM_lsr || S->tok == TOK_ASM_asr || S->tok == TOK_ASM_ror || S->tok == TOK_ASM_rrx) | 680 | if (S->tccpp_tok == TOK_ASM_asl || S->tccpp_tok == TOK_ASM_lsl || S->tccpp_tok == TOK_ASM_lsr || S->tccpp_tok == TOK_ASM_asr || S->tccpp_tok == TOK_ASM_ror || S->tccpp_tok == TOK_ASM_rrx) |
| 681 | break; | 681 | break; |
| 682 | parse_operand(S, &ops[nb_ops]); | 682 | parse_operand(S, &ops[nb_ops]); |
| 683 | ++nb_ops; | 683 | ++nb_ops; |
| 684 | if (S->tok != ',') | 684 | if (S->tccpp_tok != ',') |
| 685 | break; | 685 | break; |
| 686 | next(S); // skip ',' | 686 | next(S); // skip ',' |
| 687 | } | 687 | } |
| 688 | if (S->tok == ',') | 688 | if (S->tccpp_tok == ',') |
| 689 | next(S); | 689 | next(S); |
| 690 | operands |= asm_parse_optional_shift(S, &nb_shift, &shift); | 690 | operands |= asm_parse_optional_shift(S, &nb_shift, &shift); |
| 691 | if (nb_ops < 2) | 691 | if (nb_ops < 2) |
| @@ -852,7 +852,7 @@ static void asm_shift_opcode(TCCState *S, int token) · 160 unmodified lines | |||
| 852 | 852 | ||
| 853 | for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) { | 853 | for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) { |
| 854 | parse_operand(S, &ops[nb_ops]); | 854 | parse_operand(S, &ops[nb_ops]); |
| 855 | if (S->tok != ',') { | 855 | if (S->tccpp_tok != ',') { |
| 856 | ++nb_ops; | 856 | ++nb_ops; |
| 857 | break; | 857 | break; |
| 858 | } | 858 | } |
| @@ -961,7 +961,7 @@ static void asm_multiplication_opcode(TCCState *S, int token) · 102 unmodified lines | |||
| 961 | 961 | ||
| 962 | for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) { | 962 | for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) { |
| 963 | parse_operand(S, &ops[nb_ops]); | 963 | parse_operand(S, &ops[nb_ops]); |
| 964 | if (S->tok != ',') { | 964 | if (S->tccpp_tok != ',') { |
| 965 | ++nb_ops; | 965 | ++nb_ops; |
| 966 | break; | 966 | break; |
| 967 | } | 967 | } |
| @@ -1043,7 +1043,7 @@ static void asm_long_multiplication_opcode(TCCState *S, int token) · 75 unmodified lines | |||
| 1043 | 1043 | ||
| 1044 | for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) { | 1044 | for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) { |
| 1045 | parse_operand(S, &ops[nb_ops]); | 1045 | parse_operand(S, &ops[nb_ops]); |
| 1046 | if (S->tok != ',') { | 1046 | if (S->tccpp_tok != ',') { |
| 1047 | ++nb_ops; | 1047 | ++nb_ops; |
| 1048 | break; | 1048 | break; |
| 1049 | } | 1049 | } |
| @@ -1133,7 +1133,7 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token) · 83 unmodified lines | |||
| 1133 | expect(S, "(destination operand) register"); | 1133 | expect(S, "(destination operand) register"); |
| 1134 | return; | 1134 | return; |
| 1135 | } | 1135 | } |
| 1136 | if (S->tok != ',') | 1136 | if (S->tccpp_tok != ',') |
| 1137 | expect(S, "at least two arguments"); | 1137 | expect(S, "at least two arguments"); |
| 1138 | else | 1138 | else |
| 1139 | next(S); // skip ',' | 1139 | next(S); // skip ',' |
| @@ -1146,14 +1146,14 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token) · 6 unmodified lines | |||
| 1146 | expect(S, "register"); | 1146 | expect(S, "register"); |
| 1147 | return; | 1147 | return; |
| 1148 | } | 1148 | } |
| 1149 | if (S->tok != ',') | 1149 | if (S->tccpp_tok != ',') |
| 1150 | expect(S, "at least three arguments"); | 1150 | expect(S, "at least three arguments"); |
| 1151 | else | 1151 | else |
| 1152 | next(S); // skip ',' | 1152 | next(S); // skip ',' |
| 1153 | break; | 1153 | break; |
| 1154 | } | 1154 | } |
| 1155 | 1155 | ||
| 1156 | if (S->tok != '[') | 1156 | if (S->tccpp_tok != '[') |
| 1157 | expect(S, "'['"); | 1157 | expect(S, "'['"); |
| 1158 | else | 1158 | else |
| 1159 | next(S); // skip '[' | 1159 | next(S); // skip '[' |
| @@ -1165,14 +1165,14 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token) · 5 unmodified lines | |||
| 1165 | expect(S, "(first source operand) register"); | 1165 | expect(S, "(first source operand) register"); |
| 1166 | return; | 1166 | return; |
| 1167 | } | 1167 | } |
| 1168 | if (S->tok == ']') { | 1168 | if (S->tccpp_tok == ']') { |
| 1169 | next(S); | 1169 | next(S); |
| 1170 | closed_bracket = 1; | 1170 | closed_bracket = 1; |
| 1171 | // exclam = 1; // implicit in hardware; don't do it in software | 1171 | // exclam = 1; // implicit in hardware; don't do it in software |
| 1172 | } | 1172 | } |
| 1173 | if (S->tok == ',') { | 1173 | if (S->tccpp_tok == ',') { |
| 1174 | next(S); // skip ',' | 1174 | next(S); // skip ',' |
| 1175 | if (S->tok == '-') { | 1175 | if (S->tccpp_tok == '-') { |
| 1176 | op2_minus = 1; | 1176 | op2_minus = 1; |
| 1177 | next(S); | 1177 | next(S); |
| 1178 | } | 1178 | } |
| @@ -1182,7 +1182,7 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token) · 3 unmodified lines | |||
| 1182 | tcc_error(S, "Using 'pc' for register offset in '%s' is not implemented by ARM", get_tok_str(S, token, NULL)); | 1182 | tcc_error(S, "Using 'pc' for register offset in '%s' is not implemented by ARM", get_tok_str(S, token, NULL)); |
| 1183 | return; | 1183 | return; |
| 1184 | } | 1184 | } |
| 1185 | if (S->tok == ',') { | 1185 | if (S->tccpp_tok == ',') { |
| 1186 | next(S); | 1186 | next(S); |
| 1187 | opcode |= asm_parse_optional_shift(S, &nb_shift, &shift); | 1187 | opcode |= asm_parse_optional_shift(S, &nb_shift, &shift); |
| 1188 | if (opcode == 0) | 1188 | if (opcode == 0) |
| @@ -1196,12 +1196,12 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token) · 7 unmodified lines | |||
| 1196 | opcode |= 1 << 24; // add offset before transfer | 1196 | opcode |= 1 << 24; // add offset before transfer |
| 1197 | } | 1197 | } |
| 1198 | if (!closed_bracket) { | 1198 | if (!closed_bracket) { |
| 1199 | if (S->tok != ']') | 1199 | if (S->tccpp_tok != ']') |
| 1200 | expect(S, "']'"); | 1200 | expect(S, "']'"); |
| 1201 | else | 1201 | else |
| 1202 | next(S); // skip ']' | 1202 | next(S); // skip ']' |
| 1203 | opcode |= 1 << 24; // add offset before transfer | 1203 | opcode |= 1 << 24; // add offset before transfer |
| 1204 | if (S->tok == '!') { | 1204 | if (S->tccpp_tok == '!') { |
| 1205 | exclam = 1; | 1205 | exclam = 1; |
| 1206 | next(S); // skip '!' | 1206 | next(S); // skip '!' |
| 1207 | } | 1207 | } |
| @@ -1389,33 +1389,33 @@ static void asm_coprocessor_data_transfer_opcode(TCCState *S, int token) · 181 unmodified lines | |||
| 1389 | // Note: ldc p2, c0, [r4, #4]! ; pre-indexed: r0 = *(int*)(r4+4); r4 = r4+4 | 1389 | // Note: ldc p2, c0, [r4, #4]! ; pre-indexed: r0 = *(int*)(r4+4); r4 = r4+4 |
| 1390 | // Note: ldc p3, c0, [r4], #4 ; post-indexed: r0 = *(int*)(r4+0); r4 = r4+4 | 1390 | // Note: ldc p3, c0, [r4], #4 ; post-indexed: r0 = *(int*)(r4+0); r4 = r4+4 |
| 1391 | 1391 | ||
| 1392 | if (S->tok >= TOK_ASM_p0 && S->tok <= TOK_ASM_p15) { | 1392 | if (S->tccpp_tok >= TOK_ASM_p0 && S->tccpp_tok <= TOK_ASM_p15) { |
| 1393 | coprocessor = S->tok - TOK_ASM_p0; | 1393 | coprocessor = S->tccpp_tok - TOK_ASM_p0; |
| 1394 | next(S); | 1394 | next(S); |
| 1395 | } else { | 1395 | } else { |
| 1396 | expect(S, "'c<number>'"); | 1396 | expect(S, "'c<number>'"); |
| 1397 | return; | 1397 | return; |
| 1398 | } | 1398 | } |
| 1399 | 1399 | ||
| 1400 | if (S->tok == ',') | 1400 | if (S->tccpp_tok == ',') |
| 1401 | next(S); | 1401 | next(S); |
| 1402 | else | 1402 | else |
| 1403 | expect(S, "','"); | 1403 | expect(S, "','"); |
| 1404 | 1404 | ||
| 1405 | if (S->tok >= TOK_ASM_c0 && S->tok <= TOK_ASM_c15) { | 1405 | if (S->tccpp_tok >= TOK_ASM_c0 && S->tccpp_tok <= TOK_ASM_c15) { |
| 1406 | coprocessor_destination_register = S->tok - TOK_ASM_c0; | 1406 | coprocessor_destination_register = S->tccpp_tok - TOK_ASM_c0; |
| 1407 | next(S); | 1407 | next(S); |
| 1408 | } else { | 1408 | } else { |
| 1409 | expect(S, "'c<number>'"); | 1409 | expect(S, "'c<number>'"); |
| 1410 | return; | 1410 | return; |
| 1411 | } | 1411 | } |
| 1412 | 1412 | ||
| 1413 | if (S->tok == ',') | 1413 | if (S->tccpp_tok == ',') |
| 1414 | next(S); | 1414 | next(S); |
| 1415 | else | 1415 | else |
| 1416 | expect(S, "','"); | 1416 | expect(S, "','"); |
| 1417 | 1417 | ||
| 1418 | if (S->tok != '[') | 1418 | if (S->tccpp_tok != '[') |
| 1419 | expect(S, "'['"); | 1419 | expect(S, "'['"); |
| 1420 | else | 1420 | else |
| 1421 | next(S); // skip '[' | 1421 | next(S); // skip '[' |
| @@ -1425,14 +1425,14 @@ static void asm_coprocessor_data_transfer_opcode(TCCState *S, int token) · 3 unmodified lines | |||
| 1425 | expect(S, "(first source operand) register"); | 1425 | expect(S, "(first source operand) register"); |
| 1426 | return; | 1426 | return; |
| 1427 | } | 1427 | } |
| 1428 | if (S->tok == ']') { | 1428 | if (S->tccpp_tok == ']') { |
| 1429 | next(S); | 1429 | next(S); |
| 1430 | closed_bracket = 1; | 1430 | closed_bracket = 1; |
| 1431 | // exclam = 1; // implicit in hardware; don't do it in software | 1431 | // exclam = 1; // implicit in hardware; don't do it in software |
| 1432 | } | 1432 | } |
| 1433 | if (S->tok == ',') { | 1433 | if (S->tccpp_tok == ',') { |
| 1434 | next(S); // skip ',' | 1434 | next(S); // skip ',' |
| 1435 | if (S->tok == '-') { | 1435 | if (S->tccpp_tok == '-') { |
| 1436 | op2_minus = 1; | 1436 | op2_minus = 1; |
| 1437 | next(S); | 1437 | next(S); |
| 1438 | } | 1438 | } |
| @@ -1453,12 +1453,12 @@ static void asm_coprocessor_data_transfer_opcode(TCCState *S, int token) · 14 unmodified lines | |||
| 1453 | preincrement = 1; // add offset before transfer | 1453 | preincrement = 1; // add offset before transfer |
| 1454 | } | 1454 | } |
| 1455 | if (!closed_bracket) { | 1455 | if (!closed_bracket) { |
| 1456 | if (S->tok != ']') | 1456 | if (S->tccpp_tok != ']') |
| 1457 | expect(S, "']'"); | 1457 | expect(S, "']'"); |
| 1458 | else | 1458 | else |
| 1459 | next(S); // skip ']' | 1459 | next(S); // skip ']' |
| 1460 | preincrement = 1; // add offset before transfer | 1460 | preincrement = 1; // add offset before transfer |
| 1461 | if (S->tok == '!') { | 1461 | if (S->tccpp_tok == '!') { |
| 1462 | exclam = 1; | 1462 | exclam = 1; |
| 1463 | next(S); // skip '!' | 1463 | next(S); // skip '!' |
| 1464 | } | 1464 | } |
| @@ -1528,12 +1528,12 @@ static void asm_floating_point_single_data_transfer_opcode(TCCState *S, int toke · 63 unmodified lines | |||
| 1528 | return; | 1528 | return; |
| 1529 | } | 1529 | } |
| 1530 | 1530 | ||
| 1531 | if (S->tok == ',') | 1531 | if (S->tccpp_tok == ',') |
| 1532 | next(S); | 1532 | next(S); |
| 1533 | else | 1533 | else |
| 1534 | expect(S, "','"); | 1534 | expect(S, "','"); |
| 1535 | 1535 | ||
| 1536 | if (S->tok != '[') | 1536 | if (S->tccpp_tok != '[') |
| 1537 | expect(S, "'['"); | 1537 | expect(S, "'['"); |
| 1538 | else | 1538 | else |
| 1539 | next(S); // skip '[' | 1539 | next(S); // skip '[' |
| @@ -1543,7 +1543,7 @@ static void asm_floating_point_single_data_transfer_opcode(TCCState *S, int toke · 3 unmodified lines | |||
| 1543 | expect(S, "(first source operand) register"); | 1543 | expect(S, "(first source operand) register"); |
| 1544 | return; | 1544 | return; |
| 1545 | } | 1545 | } |
| 1546 | if (S->tok == ',') { | 1546 | if (S->tccpp_tok == ',') { |
| 1547 | next(S); // skip ',' | 1547 | next(S); // skip ',' |
| 1548 | parse_operand(S, &ops[2]); | 1548 | parse_operand(S, &ops[2]); |
| 1549 | if (ops[2].type != OP_IM8 && ops[2].type != OP_IM8N) { | 1549 | if (ops[2].type != OP_IM8 && ops[2].type != OP_IM8N) { |
| @@ -1555,7 +1555,7 @@ static void asm_floating_point_single_data_transfer_opcode(TCCState *S, int toke · 5 unmodified lines | |||
| 1555 | ops[2].type = OP_IM8; | 1555 | ops[2].type = OP_IM8; |
| 1556 | ops[2].e.v = 0; | 1556 | ops[2].e.v = 0; |
| 1557 | } | 1557 | } |
| 1558 | if (S->tok != ']') | 1558 | if (S->tccpp_tok != ']') |
| 1559 | expect(S, "']'"); | 1559 | expect(S, "']'"); |
| 1560 | else | 1560 | else |
| 1561 | next(S); // skip ']' | 1561 | next(S); // skip ']' |
| @@ -1593,11 +1593,11 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token · 31 unmodified lines | |||
| 1593 | break; | 1593 | break; |
| 1594 | default: | 1594 | default: |
| 1595 | parse_operand(S, &ops[0]); | 1595 | parse_operand(S, &ops[0]); |
| 1596 | if (S->tok == '!') { | 1596 | if (S->tccpp_tok == '!') { |
| 1597 | op0_exclam = 1; | 1597 | op0_exclam = 1; |
| 1598 | next(S); // skip '!' | 1598 | next(S); // skip '!' |
| 1599 | } | 1599 | } |
| 1600 | if (S->tok == ',') | 1600 | if (S->tccpp_tok == ',') |
| 1601 | next(S); // skip comma | 1601 | next(S); // skip comma |
| 1602 | else { | 1602 | else { |
| 1603 | expect(S, "','"); | 1603 | expect(S, "','"); |
| @@ -1605,16 +1605,16 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token · 1 unmodified line | |||
| 1605 | } | 1605 | } |
| 1606 | } | 1606 | } |
| 1607 | 1607 | ||
| 1608 | if (S->tok != '{') { | 1608 | if (S->tccpp_tok != '{') { |
| 1609 | expect(S, "'{'"); | 1609 | expect(S, "'{'"); |
| 1610 | return; | 1610 | return; |
| 1611 | } | 1611 | } |
| 1612 | next(S); // skip '{' | 1612 | next(S); // skip '{' |
| 1613 | first_regset_register = asm_parse_vfp_regvar(S->tok, 1); | 1613 | first_regset_register = asm_parse_vfp_regvar(S->tccpp_tok, 1); |
| 1614 | if ((first_regset_register = asm_parse_vfp_regvar(S->tok, 1)) != -1) { | 1614 | if ((first_regset_register = asm_parse_vfp_regvar(S->tccpp_tok, 1)) != -1) { |
| 1615 | coprocessor = CP_DOUBLE_PRECISION_FLOAT; | 1615 | coprocessor = CP_DOUBLE_PRECISION_FLOAT; |
| 1616 | next(S); | 1616 | next(S); |
| 1617 | } else if ((first_regset_register = asm_parse_vfp_regvar(S->tok, 0)) != -1) { | 1617 | } else if ((first_regset_register = asm_parse_vfp_regvar(S->tccpp_tok, 0)) != -1) { |
| 1618 | coprocessor = CP_SINGLE_PRECISION_FLOAT; | 1618 | coprocessor = CP_SINGLE_PRECISION_FLOAT; |
| 1619 | next(S); | 1619 | next(S); |
| 1620 | } else { | 1620 | } else { |
| @@ -1622,9 +1622,9 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token · 1 unmodified line | |||
| 1622 | return; | 1622 | return; |
| 1623 | } | 1623 | } |
| 1624 | 1624 | ||
| 1625 | if (S->tok == '-') { | 1625 | if (S->tccpp_tok == '-') { |
| 1626 | next(S); | 1626 | next(S); |
| 1627 | if ((last_regset_register = asm_parse_vfp_regvar(S->tok, coprocessor == CP_DOUBLE_PRECISION_FLOAT)) != -1) | 1627 | if ((last_regset_register = asm_parse_vfp_regvar(S->tccpp_tok, coprocessor == CP_DOUBLE_PRECISION_FLOAT)) != -1) |
| 1628 | next(S); | 1628 | next(S); |
| 1629 | else { | 1629 | else { |
| 1630 | expect(S, "floating-point register"); | 1630 | expect(S, "floating-point register"); |
| @@ -1637,7 +1637,7 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token · 6 unmodified lines | |||
| 1637 | tcc_error(S, "registers will be processed in ascending order by hardware--but are not specified in ascending order here"); | 1637 | tcc_error(S, "registers will be processed in ascending order by hardware--but are not specified in ascending order here"); |
| 1638 | return; | 1638 | return; |
| 1639 | } | 1639 | } |
| 1640 | if (S->tok != '}') { | 1640 | if (S->tccpp_tok != '}') { |
| 1641 | expect(S, "'}'"); | 1641 | expect(S, "'}'"); |
| 1642 | return; | 1642 | return; |
| 1643 | } | 1643 | } |
| @@ -1688,7 +1688,7 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token · 44 unmodified lines | |||
| 1688 | #define VMOV_FRACTIONAL_DIGITS 7 | 1688 | #define VMOV_FRACTIONAL_DIGITS 7 |
| 1689 | #define VMOV_ONE 10000000 /* pow(10, VMOV_FRACTIONAL_DIGITS) */ | 1689 | #define VMOV_ONE 10000000 /* pow(10, VMOV_FRACTIONAL_DIGITS) */ |
| 1690 | 1690 | ||
| 1691 | static uint32_t vmov_parse_fractional_part(TCCState *S, const char* s) | 1691 | static uint32_t vmov_parse_fractional_part(TCCState* S, const char* s) |
| 1692 | { | 1692 | { |
| 1693 | uint32_t result = 0; | 1693 | uint32_t result = 0; |
| 1694 | int i; | 1694 | int i; |
| @@ -1720,16 +1720,16 @@ static int vmov_linear_approx_index(uint32_t beginning, uint32_t end, uint32_t v · 25 unmodified lines | |||
| 1720 | return -1; | 1720 | return -1; |
| 1721 | } | 1721 | } |
| 1722 | 1722 | ||
| 1723 | static uint32_t vmov_parse_immediate_value(TCCState *S) { | 1723 | static uint32_t vmov_parse_immediate_value(TCCState* S) { |
| 1724 | uint32_t value; | 1724 | uint32_t value; |
| 1725 | unsigned long integral_value; | 1725 | unsigned long integral_value; |
| 1726 | const char *p; | 1726 | const char *p; |
| 1727 | 1727 | ||
| 1728 | if (S->tok != TOK_PPNUM) { | 1728 | if (S->tccpp_tok != TOK_PPNUM) { |
| 1729 | expect(S, "immediate value"); | 1729 | expect(S, "immediate value"); |
| 1730 | return 0; | 1730 | return 0; |
| 1731 | } | 1731 | } |
| 1732 | p = S->tokc.str.data; | 1732 | p = S->tccpp_tokc.str.data; |
| 1733 | errno = 0; | 1733 | errno = 0; |
| 1734 | integral_value = strtoul(p, (char **)&p, 0); | 1734 | integral_value = strtoul(p, (char **)&p, 0); |
| 1735 | 1735 | ||
| @@ -1747,7 +1747,7 @@ static uint32_t vmov_parse_immediate_value(TCCState *S) { · 11 unmodified lines | |||
| 1747 | return value; | 1747 | return value; |
| 1748 | } | 1748 | } |
| 1749 | 1749 | ||
| 1750 | static uint8_t vmov_encode_immediate_value(TCCState *S, uint32_t value) | 1750 | static uint8_t vmov_encode_immediate_value(TCCState* S, uint32_t value) |
| 1751 | { | 1751 | { |
| 1752 | uint32_t limit; | 1752 | uint32_t limit; |
| 1753 | uint32_t end = 0; | 1753 | uint32_t end = 0; |
| @@ -1785,10 +1785,10 @@ static void asm_floating_point_immediate_data_processing_opcode_tail(TCCState *S · 31 unmodified lines | |||
| 1785 | 1785 | ||
| 1786 | operands[0] = CRd; | 1786 | operands[0] = CRd; |
| 1787 | 1787 | ||
| 1788 | if (S->tok == '#' || S->tok == '$') { | 1788 | if (S->tccpp_tok == '#' || S->tccpp_tok == '$') { |
| 1789 | next(S); | 1789 | next(S); |
| 1790 | } | 1790 | } |
| 1791 | if (S->tok == '-') { | 1791 | if (S->tccpp_tok == '-') { |
| 1792 | op_minus = 1; | 1792 | op_minus = 1; |
| 1793 | next(S); | 1793 | next(S); |
| 1794 | } | 1794 | } |
| @@ -1956,7 +1956,7 @@ static void asm_floating_point_vcvt_data_processing_opcode(TCCState *S, int toke · 161 unmodified lines | |||
| 1956 | break; | 1956 | break; |
| 1957 | } | 1957 | } |
| 1958 | 1958 | ||
| 1959 | if (S->tok == ',') | 1959 | if (S->tccpp_tok == ',') |
| 1960 | next(S); | 1960 | next(S); |
| 1961 | else | 1961 | else |
| 1962 | expect(S, "','"); | 1962 | expect(S, "','"); |
| @@ -2078,7 +2078,7 @@ static void asm_floating_point_data_processing_opcode(TCCState *S, int token) { · 115 unmodified lines | |||
| 2078 | 2078 | ||
| 2079 | for (nb_ops = 0; nb_ops < 3; ) { | 2079 | for (nb_ops = 0; nb_ops < 3; ) { |
| 2080 | // Note: Necessary because parse_operand can't parse decimal numerals. | 2080 | // Note: Necessary because parse_operand can't parse decimal numerals. |
| 2081 | if (nb_ops == 1 && (S->tok == '#' || S->tok == '$' || S->tok == TOK_PPNUM || S->tok == '-')) { | 2081 | if (nb_ops == 1 && (S->tccpp_tok == '#' || S->tccpp_tok == '$' || S->tccpp_tok == TOK_PPNUM || S->tccpp_tok == '-')) { |
| 2082 | asm_floating_point_immediate_data_processing_opcode_tail(S, token, coprocessor, ops[0].reg); | 2082 | asm_floating_point_immediate_data_processing_opcode_tail(S, token, coprocessor, ops[0].reg); |
| 2083 | return; | 2083 | return; |
| 2084 | } | 2084 | } |
| @@ -2100,7 +2100,7 @@ static void asm_floating_point_data_processing_opcode(TCCState *S, int token) { · 15 unmodified lines | |||
| 2100 | return; | 2100 | return; |
| 2101 | } | 2101 | } |
| 2102 | ++nb_ops; | 2102 | ++nb_ops; |
| 2103 | if (S->tok == ',') | 2103 | if (S->tccpp_tok == ',') |
| 2104 | next(S); | 2104 | next(S); |
| 2105 | else | 2105 | else |
| 2106 | break; | 2106 | break; |
| @@ -2239,7 +2239,7 @@ static void asm_floating_point_data_processing_opcode(TCCState *S, int token) { · 132 unmodified lines | |||
| 2239 | asm_emit_coprocessor_opcode(S, condition_code_of_token(S, token), coprocessor, opcode1, ops[0].reg, (ops[1].type == OP_IM8) ? ops[1].e.v : ops[1].reg, (ops[2].type == OP_IM8) ? ops[2].e.v : ops[2].reg, opcode2, 0); | 2239 | asm_emit_coprocessor_opcode(S, condition_code_of_token(S, token), coprocessor, opcode1, ops[0].reg, (ops[1].type == OP_IM8) ? ops[1].e.v : ops[1].reg, (ops[2].type == OP_IM8) ? ops[2].e.v : ops[2].reg, opcode2, 0); |
| 2240 | } | 2240 | } |
| 2241 | 2241 | ||
| 2242 | static void asm_floating_point_status_register_opcode(TCCState *S, int token) | 2242 | static void asm_floating_point_status_register_opcode(TCCState* S, int token) |
| 2243 | { | 2243 | { |
| 2244 | uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT; | 2244 | uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT; |
| 2245 | uint8_t opcode; | 2245 | uint8_t opcode; |
| @@ -2248,7 +2248,7 @@ static void asm_floating_point_status_register_opcode(TCCState *S, int token) · 2 unmodified lines | |||
| 2248 | switch (ARM_INSTRUCTION_GROUP(token)) { | 2248 | switch (ARM_INSTRUCTION_GROUP(token)) { |
| 2249 | case TOK_ASM_vmrseq: | 2249 | case TOK_ASM_vmrseq: |
| 2250 | opcode = 0xf; | 2250 | opcode = 0xf; |
| 2251 | if (S->tok == TOK_ASM_apsr_nzcv) { | 2251 | if (S->tccpp_tok == TOK_ASM_apsr_nzcv) { |
| 2252 | arm_operand.type = OP_REG32; | 2252 | arm_operand.type = OP_REG32; |
| 2253 | arm_operand.reg = 15; // not PC | 2253 | arm_operand.reg = 15; // not PC |
| 2254 | next(S); // skip apsr_nzcv | 2254 | next(S); // skip apsr_nzcv |
| @@ -2260,11 +2260,11 @@ static void asm_floating_point_status_register_opcode(TCCState *S, int token) · 5 unmodified lines | |||
| 2260 | } | 2260 | } |
| 2261 | } | 2261 | } |
| 2262 | 2262 | ||
| 2263 | if (S->tok != ',') | 2263 | if (S->tccpp_tok != ',') |
| 2264 | expect(S, "','"); | 2264 | expect(S, "','"); |
| 2265 | else | 2265 | else |
| 2266 | next(S); // skip ',' | 2266 | next(S); // skip ',' |
| 2267 | vfp_sys_reg = asm_parse_vfp_status_regvar(S->tok); | 2267 | vfp_sys_reg = asm_parse_vfp_status_regvar(S->tccpp_tok); |
| 2268 | next(S); // skip vfp sys reg | 2268 | next(S); // skip vfp sys reg |
| 2269 | if (arm_operand.type == OP_REG32 && arm_operand.reg == 15 && vfp_sys_reg != 1) { | 2269 | if (arm_operand.type == OP_REG32 && arm_operand.reg == 15 && vfp_sys_reg != 1) { |
| 2270 | tcc_error(S, "'%s' only supports the variant 'vmrs apsr_nzcv, fpscr' here", get_tok_str(S, token, NULL)); | 2270 | tcc_error(S, "'%s' only supports the variant 'vmrs apsr_nzcv, fpscr' here", get_tok_str(S, token, NULL)); |
| @@ -2273,9 +2273,9 @@ static void asm_floating_point_status_register_opcode(TCCState *S, int token) · 2 unmodified lines | |||
| 2273 | break; | 2273 | break; |
| 2274 | case TOK_ASM_vmsreq: | 2274 | case TOK_ASM_vmsreq: |
| 2275 | opcode = 0xe; | 2275 | opcode = 0xe; |
| 2276 | vfp_sys_reg = asm_parse_vfp_status_regvar(S->tok); | 2276 | vfp_sys_reg = asm_parse_vfp_status_regvar(S->tccpp_tok); |
| 2277 | next(S); // skip vfp sys reg | 2277 | next(S); // skip vfp sys reg |
| 2278 | if (S->tok != ',') | 2278 | if (S->tccpp_tok != ',') |
| 2279 | expect(S, "','"); | 2279 | expect(S, "','"); |
| 2280 | else | 2280 | else |
| 2281 | next(S); // skip ',' | 2281 | next(S); // skip ',' |
| @@ -2329,12 +2329,12 @@ static void asm_misc_single_data_transfer_opcode(TCCState *S, int token) · 47 unmodified lines | |||
| 2329 | expect(S, "(destination operand) register"); | 2329 | expect(S, "(destination operand) register"); |
| 2330 | return; | 2330 | return; |
| 2331 | } | 2331 | } |
| 2332 | if (S->tok != ',') | 2332 | if (S->tccpp_tok != ',') |
| 2333 | expect(S, "at least two arguments"); | 2333 | expect(S, "at least two arguments"); |
| 2334 | else | 2334 | else |
| 2335 | next(S); // skip ',' | 2335 | next(S); // skip ',' |
| 2336 | 2336 | ||
| 2337 | if (S->tok != '[') | 2337 | if (S->tccpp_tok != '[') |
| 2338 | expect(S, "'['"); | 2338 | expect(S, "'['"); |
| 2339 | else | 2339 | else |
| 2340 | next(S); // skip '[' | 2340 | next(S); // skip '[' |
| @@ -2346,14 +2346,14 @@ static void asm_misc_single_data_transfer_opcode(TCCState *S, int token) · 5 unmodified lines | |||
| 2346 | expect(S, "(first source operand) register"); | 2346 | expect(S, "(first source operand) register"); |
| 2347 | return; | 2347 | return; |
| 2348 | } | 2348 | } |
| 2349 | if (S->tok == ']') { | 2349 | if (S->tccpp_tok == ']') { |
| 2350 | next(S); | 2350 | next(S); |
| 2351 | closed_bracket = 1; | 2351 | closed_bracket = 1; |
| 2352 | // exclam = 1; // implicit in hardware; don't do it in software | 2352 | // exclam = 1; // implicit in hardware; don't do it in software |
| 2353 | } | 2353 | } |
| 2354 | if (S->tok == ',') { | 2354 | if (S->tccpp_tok == ',') { |
| 2355 | next(S); // skip ',' | 2355 | next(S); // skip ',' |
| 2356 | if (S->tok == '-') { | 2356 | if (S->tccpp_tok == '-') { |
| 2357 | op2_minus = 1; | 2357 | op2_minus = 1; |
| 2358 | next(S); | 2358 | next(S); |
| 2359 | } | 2359 | } |
| @@ -2365,12 +2365,12 @@ static void asm_misc_single_data_transfer_opcode(TCCState *S, int token) · 5 unmodified lines | |||
| 2365 | opcode |= 1 << 24; // add offset before transfer | 2365 | opcode |= 1 << 24; // add offset before transfer |
| 2366 | } | 2366 | } |
| 2367 | if (!closed_bracket) { | 2367 | if (!closed_bracket) { |
| 2368 | if (S->tok != ']') | 2368 | if (S->tccpp_tok != ']') |
| 2369 | expect(S, "']'"); | 2369 | expect(S, "']'"); |
| 2370 | else | 2370 | else |
| 2371 | next(S); // skip ']' | 2371 | next(S); // skip ']' |
| 2372 | opcode |= 1 << 24; // add offset before transfer | 2372 | opcode |= 1 << 24; // add offset before transfer |
| 2373 | if (S->tok == '!') { | 2373 | if (S->tccpp_tok == '!') { |
| 2374 | exclam = 1; | 2374 | exclam = 1; |
| 2375 | next(S); // skip '!' | 2375 | next(S); // skip '!' |
| 2376 | } | 2376 | } |
| @@ -2439,7 +2439,7 @@ static void asm_misc_single_data_transfer_opcode(TCCState *S, int token) · 62 unmodified lines | |||
| 2439 | } | 2439 | } |
| 2440 | 2440 | ||
| 2441 | /* Note: almost dupe of encbranch in arm-gen.c */ | 2441 | /* Note: almost dupe of encbranch in arm-gen.c */ |
| 2442 | static uint32_t encbranchoffset(TCCState *S, int pos, int addr, int fail) | 2442 | static uint32_t encbranchoffset(TCCState* S, int pos, int addr, int fail) |
| 2443 | { | 2443 | { |
| 2444 | addr-=pos+8; | 2444 | addr-=pos+8; |
| 2445 | addr/=4; | 2445 | addr/=4; |
| @@ -2467,7 +2467,7 @@ static void asm_branch_opcode(TCCState *S, int token) · 21 unmodified lines | |||
| 2467 | tcc_error(S, "invalid branch target"); | 2467 | tcc_error(S, "invalid branch target"); |
| 2468 | return; | 2468 | return; |
| 2469 | } | 2469 | } |
| 2470 | jmp_disp = encbranchoffset(S, S->ind, e.v + esym->st_value, 1); | 2470 | jmp_disp = encbranchoffset(S, S->tccgen_ind, e.v + esym->st_value, 1); |
| 2471 | break; | 2471 | break; |
| 2472 | default: | 2472 | default: |
| 2473 | parse_operand(S, &op); | 2473 | parse_operand(S, &op); |
| @@ -2501,7 +2501,7 @@ ST_FUNC void asm_opcode(TCCState *S, int token) · 27 unmodified lines | |||
| 2501 | { | 2501 | { |
| 2502 | while (token == TOK_LINEFEED) { | 2502 | while (token == TOK_LINEFEED) { |
| 2503 | next(S); | 2503 | next(S); |
| 2504 | token = S->tok; | 2504 | token = S->tccpp_tok; |
| 2505 | } | 2505 | } |
| 2506 | if (token == TOK_EOF) | 2506 | if (token == TOK_EOF) |
| 2507 | return; | 2507 | return; |
| @@ -2737,7 +2737,7 @@ ST_FUNC void asm_opcode(TCCState *S, int token) · 229 unmodified lines | |||
| 2737 | } | 2737 | } |
| 2738 | } | 2738 | } |
| 2739 | 2739 | ||
| 2740 | ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, SValue *sv, int modifier) | 2740 | ST_FUNC void subst_asm_operand(TCCState* S, CString *add_str, SValue *sv, int modifier) |
| 2741 | { | 2741 | { |
| 2742 | int r, reg, size, val; | 2742 | int r, reg, size, val; |
| 2743 | char buf[64]; | 2743 | char buf[64]; |
| @@ -2814,7 +2814,7 @@ ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, SValue *sv, int mo · 70 unmodified lines | |||
| 2814 | } | 2814 | } |
| 2815 | 2815 | ||
| 2816 | /* generate prolog and epilog code for asm statement */ | 2816 | /* generate prolog and epilog code for asm statement */ |
| 2817 | ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands, | 2817 | ST_FUNC void asm_gen_code(TCCState* S, ASMOperand *operands, int nb_operands, |
| 2818 | int nb_outputs, int is_output, | 2818 | int nb_outputs, int is_output, |
| 2819 | uint8_t *clobber_regs, | 2819 | uint8_t *clobber_regs, |
| 2820 | int out_reg) | 2820 | int out_reg) |
| @@ -2900,7 +2900,7 @@ ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands, · 79 unmodified lines | |||
| 2900 | 2900 | ||
| 2901 | /* return the constraint priority (we allocate first the lowest | 2901 | /* return the constraint priority (we allocate first the lowest |
| 2902 | numbered constraints) */ | 2902 | numbered constraints) */ |
| 2903 | static inline int constraint_priority(TCCState *S, const char *str) | 2903 | static inline int constraint_priority(TCCState* S, const char *str) |
| 2904 | { | 2904 | { |
| 2905 | int priority, c, pr; | 2905 | int priority, c, pr; |
| 2906 | 2906 | ||
| @@ -2956,7 +2956,7 @@ static const char *skip_constraint_modifiers(const char *p) · 49 unmodified lines | |||
| 2956 | 2956 | ||
| 2957 | #define is_reg_allocated(reg) (regs_allocated[reg] & reg_mask) | 2957 | #define is_reg_allocated(reg) (regs_allocated[reg] & reg_mask) |
| 2958 | 2958 | ||
| 2959 | ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands, | 2959 | ST_FUNC void asm_compute_constraints(TCCState* S, ASMOperand *operands, |
| 2960 | int nb_operands, int nb_outputs, | 2960 | int nb_operands, int nb_outputs, |
| 2961 | const uint8_t *clobber_regs, | 2961 | const uint8_t *clobber_regs, |
| 2962 | int *pout_reg) | 2962 | int *pout_reg) |
| @@ -3191,7 +3191,7 @@ ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands, · 228 unmodified lines | |||
| 3191 | #endif | 3191 | #endif |
| 3192 | } | 3192 | } |
| 3193 | 3193 | ||
| 3194 | ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str) | 3194 | ST_FUNC void asm_clobber(TCCState* S, uint8_t *clobber_regs, const char *str) |
| 3195 | { | 3195 | { |
| 3196 | int reg; | 3196 | int reg; |
| 3197 | TokenSym *ts; | 3197 | TokenSym *ts; |
| @@ -216,13 +216,13 @@ ST_FUNC void arm_init(struct TCCState *s) · 215 unmodified lines | |||
| 216 | 216 | ||
| 217 | #define CHECK_R(r) ((r) >= TREG_R0 && (r) <= TREG_LR) | 217 | #define CHECK_R(r) ((r) >= TREG_R0 && (r) <= TREG_LR) |
| 218 | 218 | ||
| 219 | static int two2mask(TCCState *S, int a,int b) { | 219 | static int two2mask(TCCState* S, int a,int b) { |
| 220 | if (!CHECK_R(a) || !CHECK_R(b)) | 220 | if (!CHECK_R(a) || !CHECK_R(b)) |
| 221 | tcc_error(S, "compiler error! registers %i,%i is not valid",a,b); | 221 | tcc_error(S, "compiler error! registers %i,%i is not valid",a,b); |
| 222 | return (reg_classes[a]|reg_classes[b])&~(RC_INT|RC_FLOAT); | 222 | return (reg_classes[a]|reg_classes[b])&~(RC_INT|RC_FLOAT); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | static int regmask(TCCState *S, int r) { | 225 | static int regmask(TCCState* S, int r) { |
| 226 | if (!CHECK_R(r)) | 226 | if (!CHECK_R(r)) |
| 227 | tcc_error(S, "compiler error! register %i is not valid",r); | 227 | tcc_error(S, "compiler error! register %i is not valid",r); |
| 228 | return reg_classes[r]&~(RC_INT|RC_FLOAT); | 228 | return reg_classes[r]&~(RC_INT|RC_FLOAT); |
| @@ -240,25 +240,25 @@ const char *default_elfinterp(struct TCCState *s) · 11 unmodified lines | |||
| 240 | } | 240 | } |
| 241 | #endif | 241 | #endif |
| 242 | 242 | ||
| 243 | void o(TCCState *S, uint32_t i) | 243 | void o(TCCState* S, uint32_t i) |
| 244 | { | 244 | { |
| 245 | /* this is a good place to start adding big-endian support*/ | 245 | /* this is a good place to start adding big-endian support*/ |
| 246 | int ind1; | 246 | int ind1; |
| 247 | if (S->nocode_wanted) | 247 | if (S->tccgen_nocode_wanted) |
| 248 | return; | 248 | return; |
| 249 | ind1 = S->ind + 4; | 249 | ind1 = S->tccgen_ind + 4; |
| 250 | if (!cur_text_section) | 250 | if (!cur_text_section) |
| 251 | tcc_error(S, "compiler error! This happens f.ex. if the compiler\n" | 251 | tcc_error(S, "compiler error! This happens f.ex. if the compiler\n" |
| 252 | "can't evaluate constant expressions outside of a function."); | 252 | "can't evaluate constant expressions outside of a function."); |
| 253 | if (ind1 > cur_text_section->data_allocated) | 253 | if (ind1 > cur_text_section->data_allocated) |
| 254 | section_realloc(S, cur_text_section, ind1); | 254 | section_realloc(S, cur_text_section, ind1); |
| 255 | cur_text_section->data[S->ind++] = i&255; | 255 | cur_text_section->data[S->tccgen_ind++] = i&255; |
| 256 | i>>=8; | 256 | i>>=8; |
| 257 | cur_text_section->data[S->ind++] = i&255; | 257 | cur_text_section->data[S->tccgen_ind++] = i&255; |
| 258 | i>>=8; | 258 | i>>=8; |
| 259 | cur_text_section->data[S->ind++] = i&255; | 259 | cur_text_section->data[S->tccgen_ind++] = i&255; |
| 260 | i>>=8; | 260 | i>>=8; |
| 261 | cur_text_section->data[S->ind++] = i; | 261 | cur_text_section->data[S->tccgen_ind++] = i; |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | static uint32_t stuff_const(uint32_t op, uint32_t c) | 264 | static uint32_t stuff_const(uint32_t op, uint32_t c) |
| @@ -315,7 +315,7 @@ static uint32_t stuff_const(uint32_t op, uint32_t c) · 50 unmodified lines | |||
| 315 | 315 | ||
| 316 | 316 | ||
| 317 | //only add,sub | 317 | //only add,sub |
| 318 | void stuff_const_harder(TCCState *S, uint32_t op, uint32_t v) { | 318 | void stuff_const_harder(TCCState* S, uint32_t op, uint32_t v) { |
| 319 | uint32_t x; | 319 | uint32_t x; |
| 320 | x=stuff_const(op,v); | 320 | x=stuff_const(op,v); |
| 321 | if(x) | 321 | if(x) |
| @@ -371,7 +371,7 @@ void stuff_const_harder(TCCState *S, uint32_t op, uint32_t v) { · 49 unmodified lines | |||
| 371 | } | 371 | } |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | uint32_t encbranch(TCCState *S, int pos, int addr, int fail) | 374 | uint32_t encbranch(TCCState* S, int pos, int addr, int fail) |
| 375 | { | 375 | { |
| 376 | addr-=pos+8; | 376 | addr-=pos+8; |
| 377 | addr/=4; | 377 | addr/=4; |
| @@ -383,7 +383,7 @@ uint32_t encbranch(TCCState *S, int pos, int addr, int fail) · 5 unmodified lines | |||
| 383 | return 0x0A000000|(addr&0xffffff); | 383 | return 0x0A000000|(addr&0xffffff); |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | int decbranch(TCCState *S, int pos) | 386 | int decbranch(TCCState* S, int pos) |
| 387 | { | 387 | { |
| 388 | int x; | 388 | int x; |
| 389 | x=*(uint32_t *)(cur_text_section->data + pos); | 389 | x=*(uint32_t *)(cur_text_section->data + pos); |
| @@ -394,7 +394,7 @@ int decbranch(TCCState *S, int pos) · 4 unmodified lines | |||
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | /* output a symbol and patch all calls to it */ | 396 | /* output a symbol and patch all calls to it */ |
| 397 | void gsym_addr(TCCState *S, int t, int a) | 397 | void gsym_addr(TCCState* S, int t, int a) |
| 398 | { | 398 | { |
| 399 | uint32_t *x; | 399 | uint32_t *x; |
| 400 | int lt; | 400 | int lt; |
| @@ -411,14 +411,14 @@ void gsym_addr(TCCState *S, int t, int a) · 10 unmodified lines | |||
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | #ifdef TCC_ARM_VFP | 413 | #ifdef TCC_ARM_VFP |
| 414 | static uint32_t vfpr(TCCState *S, int r) | 414 | static uint32_t vfpr(TCCState* S, int r) |
| 415 | { | 415 | { |
| 416 | if(r<TREG_F0 || r>TREG_F7) | 416 | if(r<TREG_F0 || r>TREG_F7) |
| 417 | tcc_error(S, "compiler error! register %i is no vfp register",r); | 417 | tcc_error(S, "compiler error! register %i is no vfp register",r); |
| 418 | return r - TREG_F0; | 418 | return r - TREG_F0; |
| 419 | } | 419 | } |
| 420 | #else | 420 | #else |
| 421 | static uint32_t fpr(TCCState *S, int r) | 421 | static uint32_t fpr(TCCState* S, int r) |
| 422 | { | 422 | { |
| 423 | if(r<TREG_F0 || r>TREG_F3) | 423 | if(r<TREG_F0 || r>TREG_F3) |
| 424 | tcc_error(S, "compiler error! register %i is no fpa register",r); | 424 | tcc_error(S, "compiler error! register %i is no fpa register",r); |
| @@ -426,7 +426,7 @@ static uint32_t fpr(TCCState *S, int r) · 1 unmodified line | |||
| 426 | } | 426 | } |
| 427 | #endif | 427 | #endif |
| 428 | 428 | ||
| 429 | static uint32_t intr(TCCState *S, int r) | 429 | static uint32_t intr(TCCState* S, int r) |
| 430 | { | 430 | { |
| 431 | if(r == TREG_R12) | 431 | if(r == TREG_R12) |
| 432 | return 12; | 432 | return 12; |
| @@ -437,7 +437,7 @@ static uint32_t intr(TCCState *S, int r) · 4 unmodified lines | |||
| 437 | return r + (13 - TREG_SP); | 437 | return r + (13 - TREG_SP); |
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | static void calcaddr(TCCState *S, uint32_t *base, int *off, int *sgn, int maxoff, unsigned shift) | 440 | static void calcaddr(TCCState* S, uint32_t *base, int *off, int *sgn, int maxoff, unsigned shift) |
| 441 | { | 441 | { |
| 442 | if(*off>maxoff || *off&((1<<shift)-1)) { | 442 | if(*off>maxoff || *off&((1<<shift)-1)) { |
| 443 | uint32_t x, y; | 443 | uint32_t x, y; |
| @@ -464,7 +464,7 @@ static void calcaddr(TCCState *S, uint32_t *base, int *off, int *sgn, int maxoff · 20 unmodified lines | |||
| 464 | } | 464 | } |
| 465 | } | 465 | } |
| 466 | 466 | ||
| 467 | static uint32_t mapcc(TCCState *S, int cc) | 467 | static uint32_t mapcc(TCCState* S, int cc) |
| 468 | { | 468 | { |
| 469 | switch(cc) | 469 | switch(cc) |
| 470 | { | 470 | { |
| @@ -497,7 +497,7 @@ static uint32_t mapcc(TCCState *S, int cc) · 26 unmodified lines | |||
| 497 | return 0xE0000000; /* AL */ | 497 | return 0xE0000000; /* AL */ |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | static int negcc(TCCState *S, int cc) | 500 | static int negcc(TCCState* S, int cc) |
| 501 | { | 501 | { |
| 502 | switch(cc) | 502 | switch(cc) |
| 503 | { | 503 | { |
| @@ -532,13 +532,13 @@ static int negcc(TCCState *S, int cc) · 28 unmodified lines | |||
| 532 | 532 | ||
| 533 | /* Load value into register r. | 533 | /* Load value into register r. |
| 534 | Use relative/got addressing to avoid setting DT_TEXTREL */ | 534 | Use relative/got addressing to avoid setting DT_TEXTREL */ |
| 535 | static void load_value(TCCState *S, SValue *sv, int r) | 535 | static void load_value(TCCState* S, SValue *sv, int r) |
| 536 | { | 536 | { |
| 537 | o(S, 0xE59F0000|(intr(S, r)<<12)); /* ldr r, [pc] */ | 537 | o(S, 0xE59F0000|(intr(S, r)<<12)); /* ldr r, [pc] */ |
| 538 | o(S, 0xEA000000); /* b $+4 */ | 538 | o(S, 0xEA000000); /* b $+4 */ |
| 539 | #ifndef CONFIG_TCC_PIE | 539 | #ifndef CONFIG_TCC_PIE |
| 540 | if(sv->r & VT_SYM) | 540 | if(sv->r & VT_SYM) |
| 541 | greloc(S, cur_text_section, sv->sym, S->ind, R_ARM_ABS32); | 541 | greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_ARM_ABS32); |
| 542 | o(S, sv->c.i); | 542 | o(S, sv->c.i); |
| 543 | #else | 543 | #else |
| 544 | if(sv->r & VT_SYM) { | 544 | if(sv->r & VT_SYM) { |
| @@ -563,7 +563,7 @@ static void load_value(TCCState *S, SValue *sv, int r) · 18 unmodified lines | |||
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | /* load 'r' from value 'sv' */ | 565 | /* load 'r' from value 'sv' */ |
| 566 | void load(TCCState *S, int r, SValue *sv) | 566 | void load(TCCState* S, int r, SValue *sv) |
| 567 | { | 567 | { |
| 568 | int v, ft, fc, fr, sign; | 568 | int v, ft, fc, fr, sign; |
| 569 | uint32_t op; | 569 | uint32_t op; |
| @@ -696,7 +696,7 @@ void load(TCCState *S, int r, SValue *sv) · 126 unmodified lines | |||
| 696 | } | 696 | } |
| 697 | 697 | ||
| 698 | /* store register 'r' in lvalue 'v' */ | 698 | /* store register 'r' in lvalue 'v' */ |
| 699 | void store(TCCState *S, int r, SValue *sv) | 699 | void store(TCCState* S, int r, SValue *sv) |
| 700 | { | 700 | { |
| 701 | SValue v1; | 701 | SValue v1; |
| 702 | int v, ft, fc, fr, sign; | 702 | int v, ft, fc, fr, sign; |
| @@ -777,27 +777,27 @@ void store(TCCState *S, int r, SValue *sv) · 74 unmodified lines | |||
| 777 | tcc_error(S, "store unimplemented"); | 777 | tcc_error(S, "store unimplemented"); |
| 778 | } | 778 | } |
| 779 | 779 | ||
| 780 | static void gadd_sp(TCCState *S, int val) | 780 | static void gadd_sp(TCCState* S, int val) |
| 781 | { | 781 | { |
| 782 | stuff_const_harder(S, 0xE28DD000,val); | 782 | stuff_const_harder(S, 0xE28DD000,val); |
| 783 | } | 783 | } |
| 784 | 784 | ||
| 785 | /* 'is_jmp' is '1' if it is a jump */ | 785 | /* 'is_jmp' is '1' if it is a jump */ |
| 786 | static void gcall_or_jmp(TCCState *S, int is_jmp) | 786 | static void gcall_or_jmp(TCCState* S, int is_jmp) |
| 787 | { | 787 | { |
| 788 | int r; | 788 | int r; |
| 789 | uint32_t x; | 789 | uint32_t x; |
| 790 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { | 790 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| 791 | /* constant case */ | 791 | /* constant case */ |
| 792 | if(S->vtop->r & VT_SYM){ | 792 | if(S->tccgen_vtop->r & VT_SYM){ |
| 793 | x=encbranch(S, S->ind, S->ind+S->vtop->c.i,0); | 793 | x=encbranch(S, S->tccgen_ind, S->tccgen_ind+S->tccgen_vtop->c.i,0); |
| 794 | if(x) { | 794 | if(x) { |
| 795 | /* relocation case */ | 795 | /* relocation case */ |
| 796 | greloc(S, cur_text_section, S->vtop->sym, S->ind, R_ARM_PC24); | 796 | greloc(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind, R_ARM_PC24); |
| 797 | o(S, x|(is_jmp?0xE0000000:0xE1000000)); | 797 | o(S, x|(is_jmp?0xE0000000:0xE1000000)); |
| 798 | } else { | 798 | } else { |
| 799 | r = TREG_LR; | 799 | r = TREG_LR; |
| 800 | load_value(S, S->vtop, r); | 800 | load_value(S, S->tccgen_vtop, r); |
| 801 | if(is_jmp) | 801 | if(is_jmp) |
| 802 | o(S, 0xE1A0F000 | intr(S, r)); // mov pc, r | 802 | o(S, 0xE1A0F000 | intr(S, r)); // mov pc, r |
| 803 | else | 803 | else |
| @@ -807,12 +807,12 @@ static void gcall_or_jmp(TCCState *S, int is_jmp) · 3 unmodified lines | |||
| 807 | if(!is_jmp) | 807 | if(!is_jmp) |
| 808 | o(S, 0xE28FE004); // add lr,pc,#4 | 808 | o(S, 0xE28FE004); // add lr,pc,#4 |
| 809 | o(S, 0xE51FF004); // ldr pc,[pc,#-4] | 809 | o(S, 0xE51FF004); // ldr pc,[pc,#-4] |
| 810 | o(S, S->vtop->c.i); | 810 | o(S, S->tccgen_vtop->c.i); |
| 811 | } | 811 | } |
| 812 | } else { | 812 | } else { |
| 813 | /* otherwise, indirect call */ | 813 | /* otherwise, indirect call */ |
| 814 | #ifdef CONFIG_TCC_BCHECK | 814 | #ifdef CONFIG_TCC_BCHECK |
| 815 | S->vtop->r &= ~VT_MUSTBOUND; | 815 | S->tccgen_vtop->r &= ~VT_MUSTBOUND; |
| 816 | #endif | 816 | #endif |
| 817 | r = gv(S, RC_INT); | 817 | r = gv(S, RC_INT); |
| 818 | if(!is_jmp) | 818 | if(!is_jmp) |
| @@ -823,19 +823,19 @@ static void gcall_or_jmp(TCCState *S, int is_jmp) · 4 unmodified lines | |||
| 823 | 823 | ||
| 824 | #if defined(CONFIG_TCC_BCHECK) | 824 | #if defined(CONFIG_TCC_BCHECK) |
| 825 | 825 | ||
| 826 | static void gen_bounds_call(TCCState *S, int v) | 826 | static void gen_bounds_call(TCCState* S, int v) |
| 827 | { | 827 | { |
| 828 | Sym *sym = external_helper_sym(S, v); | 828 | Sym *sym = external_helper_sym(S, v); |
| 829 | 829 | ||
| 830 | greloc(S, cur_text_section, sym, S->ind, R_ARM_PC24); | 830 | greloc(S, cur_text_section, sym, S->tccgen_ind, R_ARM_PC24); |
| 831 | o(S, 0xebfffffe); | 831 | o(S, 0xebfffffe); |
| 832 | } | 832 | } |
| 833 | 833 | ||
| 834 | static void gen_bounds_prolog(TCCState *S) | 834 | static void gen_bounds_prolog(TCCState* S) |
| 835 | { | 835 | { |
| 836 | /* leave some room for bound checking code */ | 836 | /* leave some room for bound checking code */ |
| 837 | S->func_bound_offset = lbounds_section->data_offset; | 837 | S->func_bound_offset = lbounds_section->data_offset; |
| 838 | S->func_bound_ind = S->ind; | 838 | S->func_bound_ind = S->tccgen_ind; |
| 839 | S->func_bound_add_epilog = 0; | 839 | S->func_bound_add_epilog = 0; |
| 840 | o(S, 0xe1a00000); /* ld r0,lbounds_section->data_offset */ | 840 | o(S, 0xe1a00000); /* ld r0,lbounds_section->data_offset */ |
| 841 | o(S, 0xe1a00000); | 841 | o(S, 0xe1a00000); |
| @@ -844,7 +844,7 @@ static void gen_bounds_prolog(TCCState *S) · 2 unmodified lines | |||
| 844 | o(S, 0xe1a00000); /* call __bound_local_new */ | 844 | o(S, 0xe1a00000); /* call __bound_local_new */ |
| 845 | } | 845 | } |
| 846 | 846 | ||
| 847 | static void gen_bounds_epilog(TCCState *S) | 847 | static void gen_bounds_epilog(TCCState* S) |
| 848 | { | 848 | { |
| 849 | addr_t saved_ind; | 849 | addr_t saved_ind; |
| 850 | addr_t *bounds_ptr; | 850 | addr_t *bounds_ptr; |
| @@ -858,20 +858,20 @@ static void gen_bounds_epilog(TCCState *S) · 7 unmodified lines | |||
| 858 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); | 858 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); |
| 859 | *bounds_ptr = 0; | 859 | *bounds_ptr = 0; |
| 860 | 860 | ||
| 861 | sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section, | 861 | sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section, |
| 862 | S->func_bound_offset, lbounds_section->data_offset); | 862 | S->func_bound_offset, lbounds_section->data_offset); |
| 863 | 863 | ||
| 864 | /* generate bound local allocation */ | 864 | /* generate bound local allocation */ |
| 865 | if (offset_modified) { | 865 | if (offset_modified) { |
| 866 | saved_ind = S->ind; | 866 | saved_ind = S->tccgen_ind; |
| 867 | S->ind = S->func_bound_ind; | 867 | S->tccgen_ind = S->func_bound_ind; |
| 868 | o(S, 0xe59f0000); /* ldr r0, [pc] */ | 868 | o(S, 0xe59f0000); /* ldr r0, [pc] */ |
| 869 | o(S, 0xea000000); /* b $+4 */ | 869 | o(S, 0xea000000); /* b $+4 */ |
| 870 | greloc(S, cur_text_section, sym_data, S->ind, R_ARM_REL32); | 870 | greloc(S, cur_text_section, sym_data, S->tccgen_ind, R_ARM_REL32); |
| 871 | o(S, -12); /* lbounds_section->data_offset */ | 871 | o(S, -12); /* lbounds_section->data_offset */ |
| 872 | o(S, 0xe080000f); /* add r0,r0,pc */ | 872 | o(S, 0xe080000f); /* add r0,r0,pc */ |
| 873 | gen_bounds_call(S, TOK___bound_local_new); | 873 | gen_bounds_call(S, TOK___bound_local_new); |
| 874 | S->ind = saved_ind; | 874 | S->tccgen_ind = saved_ind; |
| 875 | } | 875 | } |
| 876 | 876 | ||
| 877 | /* generate bound check local freeing */ | 877 | /* generate bound check local freeing */ |
| @@ -879,7 +879,7 @@ static void gen_bounds_epilog(TCCState *S) · 1 unmodified line | |||
| 879 | o(S, 0xed2d0b02); /* vpush {d0} */ | 879 | o(S, 0xed2d0b02); /* vpush {d0} */ |
| 880 | o(S, 0xe59f0000); /* ldr r0, [pc] */ | 880 | o(S, 0xe59f0000); /* ldr r0, [pc] */ |
| 881 | o(S, 0xea000000); /* b $+4 */ | 881 | o(S, 0xea000000); /* b $+4 */ |
| 882 | greloc(S, cur_text_section, sym_data, S->ind, R_ARM_REL32); | 882 | greloc(S, cur_text_section, sym_data, S->tccgen_ind, R_ARM_REL32); |
| 883 | o(S, -12); /* lbounds_section->data_offset */ | 883 | o(S, -12); /* lbounds_section->data_offset */ |
| 884 | o(S, 0xe080000f); /* add r0,r0,pc */ | 884 | o(S, 0xe080000f); /* add r0,r0,pc */ |
| 885 | gen_bounds_call(S, TOK___bound_local_delete); | 885 | gen_bounds_call(S, TOK___bound_local_delete); |
| @@ -1081,12 +1081,12 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla · 195 unmodified lines | |||
| 1081 | 1081 | ||
| 1082 | for(i = nb_args; i-- ;) { | 1082 | for(i = nb_args; i-- ;) { |
| 1083 | int j, start_vfpreg = 0; | 1083 | int j, start_vfpreg = 0; |
| 1084 | CType type = S->vtop[-i].type; | 1084 | CType type = S->tccgen_vtop[-i].type; |
| 1085 | type.t &= ~VT_ARRAY; | 1085 | type.t &= ~VT_ARRAY; |
| 1086 | size = type_size(&type, &align); | 1086 | size = type_size(&type, &align); |
| 1087 | size = (size + 3) & ~3; | 1087 | size = (size + 3) & ~3; |
| 1088 | align = (align + 3) & ~3; | 1088 | align = (align + 3) & ~3; |
| 1089 | switch(S->vtop[-i].type.t & VT_BTYPE) { | 1089 | switch(S->tccgen_vtop[-i].type.t & VT_BTYPE) { |
| 1090 | case VT_STRUCT: | 1090 | case VT_STRUCT: |
| 1091 | case VT_FLOAT: | 1091 | case VT_FLOAT: |
| 1092 | case VT_DOUBLE: | 1092 | case VT_DOUBLE: |
| @@ -1094,15 +1094,15 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla · 1 unmodified line | |||
| 1094 | if (float_abi == ARM_HARD_FLOAT) { | 1094 | if (float_abi == ARM_HARD_FLOAT) { |
| 1095 | int is_hfa = 0; /* Homogeneous float aggregate */ | 1095 | int is_hfa = 0; /* Homogeneous float aggregate */ |
| 1096 | 1096 | ||
| 1097 | if (is_float(S->vtop[-i].type.t) | 1097 | if (is_float(S->tccgen_vtop[-i].type.t) |
| 1098 | || (is_hfa = is_hgen_float_aggr(&S->vtop[-i].type))) { | 1098 | || (is_hfa = is_hgen_float_aggr(&S->tccgen_vtop[-i].type))) { |
| 1099 | int end_vfpreg; | 1099 | int end_vfpreg; |
| 1100 | 1100 | ||
| 1101 | start_vfpreg = assign_vfpreg(&avregs, align, size); | 1101 | start_vfpreg = assign_vfpreg(&avregs, align, size); |
| 1102 | end_vfpreg = start_vfpreg + ((size - 1) >> 2); | 1102 | end_vfpreg = start_vfpreg + ((size - 1) >> 2); |
| 1103 | if (start_vfpreg >= 0) { | 1103 | if (start_vfpreg >= 0) { |
| 1104 | add_param_plan(plan, is_hfa ? VFP_STRUCT_CLASS : VFP_CLASS, | 1104 | add_param_plan(plan, is_hfa ? VFP_STRUCT_CLASS : VFP_CLASS, |
| 1105 | start_vfpreg, end_vfpreg, &S->vtop[-i]); | 1105 | start_vfpreg, end_vfpreg, &S->tccgen_vtop[-i]); |
| 1106 | continue; | 1106 | continue; |
| 1107 | } else | 1107 | } else |
| 1108 | break; | 1108 | break; |
| @@ -1115,7 +1115,7 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla · 6 unmodified lines | |||
| 1115 | * CORE_STRUCT_CLASS or the first of STACK_CLASS. */ | 1115 | * CORE_STRUCT_CLASS or the first of STACK_CLASS. */ |
| 1116 | for (j = ncrn; j < 4 && j < ncrn + size / 4; j++) | 1116 | for (j = ncrn; j < 4 && j < ncrn + size / 4; j++) |
| 1117 | *todo|=(1<<j); | 1117 | *todo|=(1<<j); |
| 1118 | add_param_plan(plan, CORE_STRUCT_CLASS, ncrn, j, &S->vtop[-i]); | 1118 | add_param_plan(plan, CORE_STRUCT_CLASS, ncrn, j, &S->tccgen_vtop[-i]); |
| 1119 | ncrn += size/4; | 1119 | ncrn += size/4; |
| 1120 | if (ncrn > 4) | 1120 | if (ncrn > 4) |
| 1121 | nsaa = (ncrn - 4) * 4; | 1121 | nsaa = (ncrn - 4) * 4; |
| @@ -1126,20 +1126,20 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla · 4 unmodified lines | |||
| 1126 | continue; | 1126 | continue; |
| 1127 | default: | 1127 | default: |
| 1128 | if (ncrn < 4) { | 1128 | if (ncrn < 4) { |
| 1129 | int is_long = (S->vtop[-i].type.t & VT_BTYPE) == VT_LLONG; | 1129 | int is_long = (S->tccgen_vtop[-i].type.t & VT_BTYPE) == VT_LLONG; |
| 1130 | 1130 | ||
| 1131 | if (is_long) { | 1131 | if (is_long) { |
| 1132 | ncrn = (ncrn + 1) & -2; | 1132 | ncrn = (ncrn + 1) & -2; |
| 1133 | if (ncrn == 4) | 1133 | if (ncrn == 4) |
| 1134 | break; | 1134 | break; |
| 1135 | } | 1135 | } |
| 1136 | add_param_plan(plan, CORE_CLASS, ncrn, ncrn + is_long, &S->vtop[-i]); | 1136 | add_param_plan(plan, CORE_CLASS, ncrn, ncrn + is_long, &S->tccgen_vtop[-i]); |
| 1137 | ncrn += 1 + is_long; | 1137 | ncrn += 1 + is_long; |
| 1138 | continue; | 1138 | continue; |
| 1139 | } | 1139 | } |
| 1140 | } | 1140 | } |
| 1141 | nsaa = (nsaa + (align - 1)) & ~(align - 1); | 1141 | nsaa = (nsaa + (align - 1)) & ~(align - 1); |
| 1142 | add_param_plan(plan, STACK_CLASS, nsaa, nsaa + size, &S->vtop[-i]); | 1142 | add_param_plan(plan, STACK_CLASS, nsaa, nsaa + size, &S->tccgen_vtop[-i]); |
| 1143 | nsaa += size; /* size already rounded up before */ | 1143 | nsaa += size; /* size already rounded up before */ |
| 1144 | } | 1144 | } |
| 1145 | return nsaa; | 1145 | return nsaa; |
| @@ -1153,7 +1153,7 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla · 7 unmodified lines | |||
| 1153 | todo: a bitmap indicating what core reg will hold a parameter | 1153 | todo: a bitmap indicating what core reg will hold a parameter |
| 1154 | 1154 | ||
| 1155 | Returns the number of SValue added by this function on the value stack */ | 1155 | Returns the number of SValue added by this function on the value stack */ |
| 1156 | static int copy_params(TCCState *S, int nb_args, struct plan *plan, int todo) | 1156 | static int copy_params(TCCState* S, int nb_args, struct plan *plan, int todo) |
| 1157 | { | 1157 | { |
| 1158 | int size, align, r, i, nb_extra_sval = 0; | 1158 | int size, align, r, i, nb_extra_sval = 0; |
| 1159 | struct param_plan *pplan; | 1159 | struct param_plan *pplan; |
| @@ -1201,7 +1201,7 @@ again: · 41 unmodified lines | |||
| 1201 | /* generate structure store */ | 1201 | /* generate structure store */ |
| 1202 | r = get_reg(S, RC_INT); | 1202 | r = get_reg(S, RC_INT); |
| 1203 | o(S, 0xE28D0000|(intr(S, r)<<12)|padding); /* add r, sp, padding */ | 1203 | o(S, 0xE28D0000|(intr(S, r)<<12)|padding); /* add r, sp, padding */ |
| 1204 | vset(S, &S->vtop->type, r | VT_LVAL, 0); | 1204 | vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0); |
| 1205 | vswap(S); | 1205 | vswap(S); |
| 1206 | /* XXX: optimize. Save all register because memcpy can use them */ | 1206 | /* XXX: optimize. Save all register because memcpy can use them */ |
| 1207 | o(S, 0xED2D0A00|(0&1)<<22|(0>>1)<<12|16); /* vpush {s0-s15} */ | 1207 | o(S, 0xED2D0A00|(0&1)<<22|(0>>1)<<12|16); /* vpush {s0-s15} */ |
| @@ -1255,7 +1255,7 @@ again: · 47 unmodified lines | |||
| 1255 | size = 8; | 1255 | size = 8; |
| 1256 | r = gv(S, RC_INT); | 1256 | r = gv(S, RC_INT); |
| 1257 | o(S, 0xE52D0004|(intr(S, r)<<12)); /* push r */ | 1257 | o(S, 0xE52D0004|(intr(S, r)<<12)); /* push r */ |
| 1258 | S->vtop--; | 1258 | S->tccgen_vtop--; |
| 1259 | } | 1259 | } |
| 1260 | r = gv(S, RC_INT); | 1260 | r = gv(S, RC_INT); |
| 1261 | o(S, 0xE52D0004|(intr(S, r)<<12)); /* push r */ | 1261 | o(S, 0xE52D0004|(intr(S, r)<<12)); /* push r */ |
| @@ -1269,7 +1269,7 @@ again: · 7 unmodified lines | |||
| 1269 | gv(S, regmask(S, TREG_F0 + (pplan->start >> 1))); | 1269 | gv(S, regmask(S, TREG_F0 + (pplan->start >> 1))); |
| 1270 | if (pplan->start & 1) { /* Must be in upper part of double register */ | 1270 | if (pplan->start & 1) { /* Must be in upper part of double register */ |
| 1271 | o(S, 0xEEF00A40|((pplan->start>>1)<<12)|(pplan->start>>1)); /* vmov.f32 s(n+1), sn */ | 1271 | o(S, 0xEEF00A40|((pplan->start>>1)<<12)|(pplan->start>>1)); /* vmov.f32 s(n+1), sn */ |
| 1272 | S->vtop->r = VT_CONST; /* avoid being saved on stack by gv for next float */ | 1272 | S->tccgen_vtop->r = VT_CONST; /* avoid being saved on stack by gv for next float */ |
| 1273 | } | 1273 | } |
| 1274 | break; | 1274 | break; |
| 1275 | 1275 | ||
| @@ -1277,16 +1277,16 @@ again: · 1 unmodified line | |||
| 1277 | if ((pplan->sval->type.t & VT_BTYPE) == VT_LLONG) { | 1277 | if ((pplan->sval->type.t & VT_BTYPE) == VT_LLONG) { |
| 1278 | lexpand(S); | 1278 | lexpand(S); |
| 1279 | gv(S, regmask(S, pplan->end)); | 1279 | gv(S, regmask(S, pplan->end)); |
| 1280 | pplan->sval->r2 = S->vtop->r; | 1280 | pplan->sval->r2 = S->tccgen_vtop->r; |
| 1281 | S->vtop--; | 1281 | S->tccgen_vtop--; |
| 1282 | } | 1282 | } |
| 1283 | gv(S, regmask(S, pplan->start)); | 1283 | gv(S, regmask(S, pplan->start)); |
| 1284 | /* Mark register as used so that gcall_or_jmp use another one | 1284 | /* Mark register as used so that gcall_or_jmp use another one |
| 1285 | (regs >=4 are free as never used to pass parameters) */ | 1285 | (regs >=4 are free as never used to pass parameters) */ |
| 1286 | pplan->sval->r = S->vtop->r; | 1286 | pplan->sval->r = S->tccgen_vtop->r; |
| 1287 | break; | 1287 | break; |
| 1288 | } | 1288 | } |
| 1289 | S->vtop--; | 1289 | S->tccgen_vtop--; |
| 1290 | } | 1290 | } |
| 1291 | } | 1291 | } |
| 1292 | 1292 | ||
| @@ -1312,7 +1312,7 @@ again: · 19 unmodified lines | |||
| 1312 | if (todo & (1 << r)) { | 1312 | if (todo & (1 << r)) { |
| 1313 | nb_extra_sval++; | 1313 | nb_extra_sval++; |
| 1314 | vpushi(S, 0); | 1314 | vpushi(S, 0); |
| 1315 | S->vtop->r = r; | 1315 | S->tccgen_vtop->r = r; |
| 1316 | } | 1316 | } |
| 1317 | } | 1317 | } |
| 1318 | } | 1318 | } |
| @@ -1323,7 +1323,7 @@ again: · 4 unmodified lines | |||
| 1323 | /* Generate function call. The function address is pushed first, then | 1323 | /* Generate function call. The function address is pushed first, then |
| 1324 | all the parameters in call order. This functions pops all the | 1324 | all the parameters in call order. This functions pops all the |
| 1325 | parameters and the function address. */ | 1325 | parameters and the function address. */ |
| 1326 | void gfunc_call(TCCState *S, int nb_args) | 1326 | void gfunc_call(TCCState* S, int nb_args) |
| 1327 | { | 1327 | { |
| 1328 | int r, args_size; | 1328 | int r, args_size; |
| 1329 | int def_float_abi = float_abi; | 1329 | int def_float_abi = float_abi; |
| @@ -1340,15 +1340,15 @@ void gfunc_call(TCCState *S, int nb_args) · 10 unmodified lines | |||
| 1340 | 1340 | ||
| 1341 | #ifdef TCC_ARM_EABI | 1341 | #ifdef TCC_ARM_EABI |
| 1342 | if (float_abi == ARM_HARD_FLOAT) { | 1342 | if (float_abi == ARM_HARD_FLOAT) { |
| 1343 | variadic = (S->vtop[-nb_args].type.ref->f.func_type == FUNC_ELLIPSIS); | 1343 | variadic = (S->tccgen_vtop[-nb_args].type.ref->f.func_type == FUNC_ELLIPSIS); |
| 1344 | if (variadic || floats_in_core_regs(&S->vtop[-nb_args])) | 1344 | if (variadic || floats_in_core_regs(&S->tccgen_vtop[-nb_args])) |
| 1345 | float_abi = ARM_SOFTFP_FLOAT; | 1345 | float_abi = ARM_SOFTFP_FLOAT; |
| 1346 | } | 1346 | } |
| 1347 | #endif | 1347 | #endif |
| 1348 | /* cannot let cpu flags if other instruction are generated. Also avoid leaving | 1348 | /* cannot let cpu flags if other instruction are generated. Also avoid leaving |
| 1349 | VT_JMP anywhere except on the top of the stack because it would complicate | 1349 | VT_JMP anywhere except on the top of the stack because it would complicate |
| 1350 | the code generator. */ | 1350 | the code generator. */ |
| 1351 | r = S->vtop->r & VT_VALMASK; | 1351 | r = S->tccgen_vtop->r & VT_VALMASK; |
| 1352 | if (r == VT_CMP || (r & ~1) == VT_JMP) | 1352 | if (r == VT_CMP || (r & ~1) == VT_JMP) |
| 1353 | gv(S, RC_INT); | 1353 | gv(S, RC_INT); |
| 1354 | 1354 | ||
| @@ -1374,8 +1374,8 @@ void gfunc_call(TCCState *S, int nb_args) · 19 unmodified lines | |||
| 1374 | if (args_size) | 1374 | if (args_size) |
| 1375 | gadd_sp(S, args_size); /* pop all parameters passed on the stack */ | 1375 | gadd_sp(S, args_size); /* pop all parameters passed on the stack */ |
| 1376 | #if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP) | 1376 | #if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP) |
| 1377 | if(float_abi == ARM_SOFTFP_FLOAT && is_float(S->vtop->type.ref->type.t)) { | 1377 | if(float_abi == ARM_SOFTFP_FLOAT && is_float(S->tccgen_vtop->type.ref->type.t)) { |
| 1378 | if((S->vtop->type.ref->type.t & VT_BTYPE) == VT_FLOAT) { | 1378 | if((S->tccgen_vtop->type.ref->type.t & VT_BTYPE) == VT_FLOAT) { |
| 1379 | o(S, 0xEE000A10); /*vmov s0, r0 */ | 1379 | o(S, 0xEE000A10); /*vmov s0, r0 */ |
| 1380 | } else { | 1380 | } else { |
| 1381 | o(S, 0xEE000B10); /* vmov.32 d0[0], r0 */ | 1381 | o(S, 0xEE000B10); /* vmov.32 d0[0], r0 */ |
| @@ -1383,13 +1383,13 @@ void gfunc_call(TCCState *S, int nb_args) · 1 unmodified line | |||
| 1383 | } | 1383 | } |
| 1384 | } | 1384 | } |
| 1385 | #endif | 1385 | #endif |
| 1386 | S->vtop -= nb_args + 1; /* Pop all params and fct address from value stack */ | 1386 | S->tccgen_vtop -= nb_args + 1; /* Pop all params and fct address from value stack */ |
| 1387 | leaffunc = 0; /* we are calling a function, so we aren't in a leaf function */ | 1387 | leaffunc = 0; /* we are calling a function, so we aren't in a leaf function */ |
| 1388 | float_abi = def_float_abi; | 1388 | float_abi = def_float_abi; |
| 1389 | } | 1389 | } |
| 1390 | 1390 | ||
| 1391 | /* generate function prolog of type 't' */ | 1391 | /* generate function prolog of type 't' */ |
| 1392 | void gfunc_prolog(TCCState *S, Sym *func_sym) | 1392 | void gfunc_prolog(TCCState* S, Sym *func_sym) |
| 1393 | { | 1393 | { |
| 1394 | CType *func_type = &func_sym->type; | 1394 | CType *func_type = &func_sym->type; |
| 1395 | Sym *sym,*sym2; | 1395 | Sym *sym,*sym2; |
| @@ -1443,7 +1443,7 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 47 unmodified lines | |||
| 1443 | } | 1443 | } |
| 1444 | o(S, 0xE92D5800); /* save fp, ip, lr */ | 1444 | o(S, 0xE92D5800); /* save fp, ip, lr */ |
| 1445 | o(S, 0xE1A0B00D); /* mov fp, sp */ | 1445 | o(S, 0xE1A0B00D); /* mov fp, sp */ |
| 1446 | func_sub_sp_offset = S->ind; | 1446 | func_sub_sp_offset = S->tccgen_ind; |
| 1447 | o(S, 0xE1A00000); /* nop, leave space for stack adjustment in epilog */ | 1447 | o(S, 0xE1A00000); /* nop, leave space for stack adjustment in epilog */ |
| 1448 | 1448 | ||
| 1449 | #ifdef TCC_ARM_EABI | 1449 | #ifdef TCC_ARM_EABI |
| @@ -1490,7 +1490,7 @@ from_stack: · 40 unmodified lines | |||
| 1490 | } | 1490 | } |
| 1491 | last_itod_magic=0; | 1491 | last_itod_magic=0; |
| 1492 | leaffunc = 1; | 1492 | leaffunc = 1; |
| 1493 | S->loc = 0; | 1493 | S->tccgen_loc = 0; |
| 1494 | #ifdef CONFIG_TCC_BCHECK | 1494 | #ifdef CONFIG_TCC_BCHECK |
| 1495 | if (S->do_bounds_check) | 1495 | if (S->do_bounds_check) |
| 1496 | gen_bounds_prolog(S); | 1496 | gen_bounds_prolog(S); |
| @@ -1498,7 +1498,7 @@ from_stack: · 1 unmodified line | |||
| 1498 | } | 1498 | } |
| 1499 | 1499 | ||
| 1500 | /* generate function epilog */ | 1500 | /* generate function epilog */ |
| 1501 | void gfunc_epilog(TCCState *S) | 1501 | void gfunc_epilog(TCCState* S) |
| 1502 | { | 1502 | { |
| 1503 | uint32_t x; | 1503 | uint32_t x; |
| 1504 | int diff; | 1504 | int diff; |
| @@ -1520,7 +1520,7 @@ void gfunc_epilog(TCCState *S) · 15 unmodified lines | |||
| 1520 | } | 1520 | } |
| 1521 | #endif | 1521 | #endif |
| 1522 | o(S, 0xE89BA800); /* restore fp, sp, pc */ | 1522 | o(S, 0xE89BA800); /* restore fp, sp, pc */ |
| 1523 | diff = (-S->loc + 3) & -4; | 1523 | diff = (-S->tccgen_loc + 3) & -4; |
| 1524 | #ifdef TCC_ARM_EABI | 1524 | #ifdef TCC_ARM_EABI |
| 1525 | if(!leaffunc) | 1525 | if(!leaffunc) |
| 1526 | diff = ((diff + 11) & -8) - 4; | 1526 | diff = ((diff + 11) & -8) - 4; |
| @@ -1531,7 +1531,7 @@ void gfunc_epilog(TCCState *S) · 4 unmodified lines | |||
| 1531 | *(uint32_t *)(cur_text_section->data + func_sub_sp_offset) = x; | 1531 | *(uint32_t *)(cur_text_section->data + func_sub_sp_offset) = x; |
| 1532 | else { | 1532 | else { |
| 1533 | int addr; | 1533 | int addr; |
| 1534 | addr=S->ind; | 1534 | addr=S->tccgen_ind; |
| 1535 | o(S, 0xE59FC004); /* ldr ip,[pc+4] */ | 1535 | o(S, 0xE59FC004); /* ldr ip,[pc+4] */ |
| 1536 | o(S, 0xE04BD00C); /* sub sp,fp,ip */ | 1536 | o(S, 0xE04BD00C); /* sub sp,fp,ip */ |
| 1537 | o(S, 0xE1A0F00E); /* mov pc,lr */ | 1537 | o(S, 0xE1A0F00E); /* mov pc,lr */ |
| @@ -1541,7 +1541,7 @@ void gfunc_epilog(TCCState *S) · 3 unmodified lines | |||
| 1541 | } | 1541 | } |
| 1542 | } | 1542 | } |
| 1543 | 1543 | ||
| 1544 | ST_FUNC void gen_fill_nops(TCCState *S, int bytes) | 1544 | ST_FUNC void gen_fill_nops(TCCState* S, int bytes) |
| 1545 | { | 1545 | { |
| 1546 | if ((bytes & 3)) | 1546 | if ((bytes & 3)) |
| 1547 | tcc_error(S, "alignment of code section not multiple of 4"); | 1547 | tcc_error(S, "alignment of code section not multiple of 4"); |
| @@ -1552,35 +1552,35 @@ ST_FUNC void gen_fill_nops(TCCState *S, int bytes) · 4 unmodified lines | |||
| 1552 | } | 1552 | } |
| 1553 | 1553 | ||
| 1554 | /* generate a jump to a label */ | 1554 | /* generate a jump to a label */ |
| 1555 | ST_FUNC int gjmp(TCCState *S, int t) | 1555 | ST_FUNC int gjmp(TCCState* S, int t) |
| 1556 | { | 1556 | { |
| 1557 | int r; | 1557 | int r; |
| 1558 | if (S->nocode_wanted) | 1558 | if (S->tccgen_nocode_wanted) |
| 1559 | return t; | 1559 | return t; |
| 1560 | r=S->ind; | 1560 | r=S->tccgen_ind; |
| 1561 | o(S, 0xE0000000|encbranch(S, r,t,1)); | 1561 | o(S, 0xE0000000|encbranch(S, r,t,1)); |
| 1562 | return r; | 1562 | return r; |
| 1563 | } | 1563 | } |
| 1564 | 1564 | ||
| 1565 | /* generate a jump to a fixed address */ | 1565 | /* generate a jump to a fixed address */ |
| 1566 | ST_FUNC void gjmp_addr(TCCState *S, int a) | 1566 | ST_FUNC void gjmp_addr(TCCState* S, int a) |
| 1567 | { | 1567 | { |
| 1568 | gjmp(S, a); | 1568 | gjmp(S, a); |
| 1569 | } | 1569 | } |
| 1570 | 1570 | ||
| 1571 | ST_FUNC int gjmp_cond(TCCState *S, int op, int t) | 1571 | ST_FUNC int gjmp_cond(TCCState* S, int op, int t) |
| 1572 | { | 1572 | { |
| 1573 | int r; | 1573 | int r; |
| 1574 | if (S->nocode_wanted) | 1574 | if (S->tccgen_nocode_wanted) |
| 1575 | return t; | 1575 | return t; |
| 1576 | r=S->ind; | 1576 | r=S->tccgen_ind; |
| 1577 | op=mapcc(S, op); | 1577 | op=mapcc(S, op); |
| 1578 | op|=encbranch(S, r,t,1); | 1578 | op|=encbranch(S, r,t,1); |
| 1579 | o(S, op); | 1579 | o(S, op); |
| 1580 | return r; | 1580 | return r; |
| 1581 | } | 1581 | } |
| 1582 | 1582 | ||
| 1583 | ST_FUNC int gjmp_append(TCCState *S, int n, int t) | 1583 | ST_FUNC int gjmp_append(TCCState* S, int n, int t) |
| 1584 | { | 1584 | { |
| 1585 | uint32_t *x; | 1585 | uint32_t *x; |
| 1586 | int p,lp; | 1586 | int p,lp; |
| @@ -1598,7 +1598,7 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t) · 11 unmodified lines | |||
| 1598 | } | 1598 | } |
| 1599 | 1599 | ||
| 1600 | /* generate an integer binary operation */ | 1600 | /* generate an integer binary operation */ |
| 1601 | void gen_opi(TCCState *S, int op) | 1601 | void gen_opi(TCCState* S, int op) |
| 1602 | { | 1602 | { |
| 1603 | int c, func = 0; | 1603 | int c, func = 0; |
| 1604 | uint32_t opc = 0, r, fr; | 1604 | uint32_t opc = 0, r, fr; |
| @@ -1644,9 +1644,9 @@ void gen_opi(TCCState *S, int op) · 39 unmodified lines | |||
| 1644 | break; | 1644 | break; |
| 1645 | case '*': | 1645 | case '*': |
| 1646 | gv2(S, RC_INT, RC_INT); | 1646 | gv2(S, RC_INT, RC_INT); |
| 1647 | r = S->vtop[-1].r; | 1647 | r = S->tccgen_vtop[-1].r; |
| 1648 | fr = S->vtop[0].r; | 1648 | fr = S->tccgen_vtop[0].r; |
| 1649 | S->vtop--; | 1649 | S->tccgen_vtop--; |
| 1650 | o(S, 0xE0000090|(intr(S, r)<<16)|(intr(S, r)<<8)|intr(S, fr)); | 1650 | o(S, 0xE0000090|(intr(S, r)<<16)|(intr(S, r)<<8)|intr(S, fr)); |
| 1651 | return; | 1651 | return; |
| 1652 | case TOK_SHL: | 1652 | case TOK_SHL: |
| @@ -1690,11 +1690,11 @@ void gen_opi(TCCState *S, int op) · 37 unmodified lines | |||
| 1690 | break; | 1690 | break; |
| 1691 | case TOK_UMULL: | 1691 | case TOK_UMULL: |
| 1692 | gv2(S, RC_INT, RC_INT); | 1692 | gv2(S, RC_INT, RC_INT); |
| 1693 | r=intr(S, S->vtop[-1].r2=get_reg(S, RC_INT)); | 1693 | r=intr(S, S->tccgen_vtop[-1].r2=get_reg(S, RC_INT)); |
| 1694 | c=S->vtop[-1].r; | 1694 | c=S->tccgen_vtop[-1].r; |
| 1695 | S->vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, c)); | 1695 | S->tccgen_vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, c)); |
| 1696 | S->vtop--; | 1696 | S->tccgen_vtop--; |
| 1697 | o(S, 0xE0800090|(r<<16)|(intr(S, S->vtop->r)<<12)|(intr(S, c)<<8)|intr(S, S->vtop[1].r)); | 1697 | o(S, 0xE0800090|(r<<16)|(intr(S, S->tccgen_vtop->r)<<12)|(intr(S, c)<<8)|intr(S, S->tccgen_vtop[1].r)); |
| 1698 | return; | 1698 | return; |
| 1699 | default: | 1699 | default: |
| 1700 | opc = 0x15; | 1700 | opc = 0x15; |
| @@ -1703,27 +1703,27 @@ void gen_opi(TCCState *S, int op) · 2 unmodified lines | |||
| 1703 | } | 1703 | } |
| 1704 | switch(c) { | 1704 | switch(c) { |
| 1705 | case 1: | 1705 | case 1: |
| 1706 | if((S->vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 1706 | if((S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 1707 | if(opc == 4 || opc == 5 || opc == 0xc) { | 1707 | if(opc == 4 || opc == 5 || opc == 0xc) { |
| 1708 | vswap(S); | 1708 | vswap(S); |
| 1709 | opc|=2; // sub -> rsb | 1709 | opc|=2; // sub -> rsb |
| 1710 | } | 1710 | } |
| 1711 | } | 1711 | } |
| 1712 | if ((S->vtop->r & VT_VALMASK) == VT_CMP || | 1712 | if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP || |
| 1713 | (S->vtop->r & (VT_VALMASK & ~1)) == VT_JMP) | 1713 | (S->tccgen_vtop->r & (VT_VALMASK & ~1)) == VT_JMP) |
| 1714 | gv(S, RC_INT); | 1714 | gv(S, RC_INT); |
| 1715 | vswap(S); | 1715 | vswap(S); |
| 1716 | c=intr(S, gv(S, RC_INT)); | 1716 | c=intr(S, gv(S, RC_INT)); |
| 1717 | vswap(S); | 1717 | vswap(S); |
| 1718 | opc=0xE0000000|(opc<<20); | 1718 | opc=0xE0000000|(opc<<20); |
| 1719 | if((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 1719 | if((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 1720 | uint32_t x; | 1720 | uint32_t x; |
| 1721 | x=stuff_const(opc|0x2000000|(c<<16),S->vtop->c.i); | 1721 | x=stuff_const(opc|0x2000000|(c<<16),S->tccgen_vtop->c.i); |
| 1722 | if(x) { | 1722 | if(x) { |
| 1723 | if ((x & 0xfff00000) == 0xe3500000) // cmp rx,#c | 1723 | if ((x & 0xfff00000) == 0xe3500000) // cmp rx,#c |
| 1724 | o(S, x); | 1724 | o(S, x); |
| 1725 | else { | 1725 | else { |
| 1726 | r=intr(S, S->vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, S->vtop[-1].r))); | 1726 | r=intr(S, S->tccgen_vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, S->tccgen_vtop[-1].r))); |
| 1727 | o(S, x|(r<<12)); | 1727 | o(S, x|(r<<12)); |
| 1728 | } | 1728 | } |
| 1729 | goto done; | 1729 | goto done; |
| @@ -1731,7 +1731,7 @@ void gen_opi(TCCState *S, int op) · 1 unmodified line | |||
| 1731 | } | 1731 | } |
| 1732 | fr=intr(S, gv(S, RC_INT)); | 1732 | fr=intr(S, gv(S, RC_INT)); |
| 1733 | #ifdef CONFIG_TCC_BCHECK | 1733 | #ifdef CONFIG_TCC_BCHECK |
| 1734 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 1734 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 1735 | vswap(S); | 1735 | vswap(S); |
| 1736 | c=intr(S, gv(S, RC_INT)); | 1736 | c=intr(S, gv(S, RC_INT)); |
| 1737 | vswap(S); | 1737 | vswap(S); |
| @@ -1740,46 +1740,46 @@ void gen_opi(TCCState *S, int op) · 2 unmodified lines | |||
| 1740 | if ((opc & 0xfff00000) == 0xe1500000) // cmp rx,ry | 1740 | if ((opc & 0xfff00000) == 0xe1500000) // cmp rx,ry |
| 1741 | o(S, opc|(c<<16)|fr); | 1741 | o(S, opc|(c<<16)|fr); |
| 1742 | else { | 1742 | else { |
| 1743 | r=intr(S, S->vtop[-1].r=get_reg_ex(S, RC_INT,two2mask(S, S->vtop->r,S->vtop[-1].r))); | 1743 | r=intr(S, S->tccgen_vtop[-1].r=get_reg_ex(S, RC_INT,two2mask(S, S->tccgen_vtop->r,S->tccgen_vtop[-1].r))); |
| 1744 | o(S, opc|(c<<16)|(r<<12)|fr); | 1744 | o(S, opc|(c<<16)|(r<<12)|fr); |
| 1745 | } | 1745 | } |
| 1746 | done: | 1746 | done: |
| 1747 | S->vtop--; | 1747 | S->tccgen_vtop--; |
| 1748 | if (op >= TOK_ULT && op <= TOK_GT) | 1748 | if (op >= TOK_ULT && op <= TOK_GT) |
| 1749 | vset_VT_CMP(S, op); | 1749 | vset_VT_CMP(S, op); |
| 1750 | break; | 1750 | break; |
| 1751 | case 2: | 1751 | case 2: |
| 1752 | opc=0xE1A00000|(opc<<5); | 1752 | opc=0xE1A00000|(opc<<5); |
| 1753 | if ((S->vtop->r & VT_VALMASK) == VT_CMP || | 1753 | if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP || |
| 1754 | (S->vtop->r & (VT_VALMASK & ~1)) == VT_JMP) | 1754 | (S->tccgen_vtop->r & (VT_VALMASK & ~1)) == VT_JMP) |
| 1755 | gv(S, RC_INT); | 1755 | gv(S, RC_INT); |
| 1756 | vswap(S); | 1756 | vswap(S); |
| 1757 | r=intr(S, gv(S, RC_INT)); | 1757 | r=intr(S, gv(S, RC_INT)); |
| 1758 | vswap(S); | 1758 | vswap(S); |
| 1759 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 1759 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 1760 | fr=intr(S, S->vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, S->vtop[-1].r))); | 1760 | fr=intr(S, S->tccgen_vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, S->tccgen_vtop[-1].r))); |
| 1761 | c = S->vtop->c.i & 0x1f; | 1761 | c = S->tccgen_vtop->c.i & 0x1f; |
| 1762 | o(S, opc|r|(c<<7)|(fr<<12)); | 1762 | o(S, opc|r|(c<<7)|(fr<<12)); |
| 1763 | } else { | 1763 | } else { |
| 1764 | fr=intr(S, gv(S, RC_INT)); | 1764 | fr=intr(S, gv(S, RC_INT)); |
| 1765 | #ifdef CONFIG_TCC_BCHECK | 1765 | #ifdef CONFIG_TCC_BCHECK |
| 1766 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 1766 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 1767 | vswap(S); | 1767 | vswap(S); |
| 1768 | r=intr(S, gv(S, RC_INT)); | 1768 | r=intr(S, gv(S, RC_INT)); |
| 1769 | vswap(S); | 1769 | vswap(S); |
| 1770 | } | 1770 | } |
| 1771 | #endif | 1771 | #endif |
| 1772 | c=intr(S, S->vtop[-1].r=get_reg_ex(S, RC_INT,two2mask(S, S->vtop->r,S->vtop[-1].r))); | 1772 | c=intr(S, S->tccgen_vtop[-1].r=get_reg_ex(S, RC_INT,two2mask(S, S->tccgen_vtop->r,S->tccgen_vtop[-1].r))); |
| 1773 | o(S, opc|r|(c<<12)|(fr<<8)|0x10); | 1773 | o(S, opc|r|(c<<12)|(fr<<8)|0x10); |
| 1774 | } | 1774 | } |
| 1775 | S->vtop--; | 1775 | S->tccgen_vtop--; |
| 1776 | break; | 1776 | break; |
| 1777 | case 3: | 1777 | case 3: |
| 1778 | vpush_helper_func(S, func); | 1778 | vpush_helper_func(S, func); |
| 1779 | vrott(S, 3); | 1779 | vrott(S, 3); |
| 1780 | gfunc_call(S, 2); | 1780 | gfunc_call(S, 2); |
| 1781 | vpushi(S, 0); | 1781 | vpushi(S, 0); |
| 1782 | S->vtop->r = retreg; | 1782 | S->tccgen_vtop->r = retreg; |
| 1783 | break; | 1783 | break; |
| 1784 | default: | 1784 | default: |
| 1785 | tcc_error(S, "gen_opi %i unimplemented!",op); | 1785 | tcc_error(S, "gen_opi %i unimplemented!",op); |
| @@ -1787,30 +1787,30 @@ done: · 1 unmodified line | |||
| 1787 | } | 1787 | } |
| 1788 | 1788 | ||
| 1789 | #ifdef TCC_ARM_VFP | 1789 | #ifdef TCC_ARM_VFP |
| 1790 | static int is_zero(TCCState *S, int i) | 1790 | static int is_zero(TCCState* S, int i) |
| 1791 | { | 1791 | { |
| 1792 | if((S->vtop[i].r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST) | 1792 | if((S->tccgen_vtop[i].r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST) |
| 1793 | return 0; | 1793 | return 0; |
| 1794 | if (S->vtop[i].type.t == VT_FLOAT) | 1794 | if (S->tccgen_vtop[i].type.t == VT_FLOAT) |
| 1795 | return (S->vtop[i].c.f == 0.f); | 1795 | return (S->tccgen_vtop[i].c.f == 0.f); |
| 1796 | else if (S->vtop[i].type.t == VT_DOUBLE) | 1796 | else if (S->tccgen_vtop[i].type.t == VT_DOUBLE) |
| 1797 | return (S->vtop[i].c.d == 0.0); | 1797 | return (S->tccgen_vtop[i].c.d == 0.0); |
| 1798 | return (S->vtop[i].c.ld == 0.l); | 1798 | return (S->tccgen_vtop[i].c.ld == 0.l); |
| 1799 | } | 1799 | } |
| 1800 | 1800 | ||
| 1801 | /* generate a floating point operation 'v = t1 op t2' instruction. The | 1801 | /* generate a floating point operation 'v = t1 op t2' instruction. The |
| 1802 | * two operands are guaranteed to have the same floating point type */ | 1802 | * two operands are guaranteed to have the same floating point type */ |
| 1803 | void gen_opf(TCCState *S, int op) | 1803 | void gen_opf(TCCState* S, int op) |
| 1804 | { | 1804 | { |
| 1805 | uint32_t x; | 1805 | uint32_t x; |
| 1806 | int fneg=0,r; | 1806 | int fneg=0,r; |
| 1807 | x=0xEE000A00|T2CPR(S->vtop->type.t); | 1807 | x=0xEE000A00|T2CPR(S->tccgen_vtop->type.t); |
| 1808 | switch(op) { | 1808 | switch(op) { |
| 1809 | case '+': | 1809 | case '+': |
| 1810 | if(is_zero(S, -1)) | 1810 | if(is_zero(S, -1)) |
| 1811 | vswap(S); | 1811 | vswap(S); |
| 1812 | if(is_zero(S, 0)) { | 1812 | if(is_zero(S, 0)) { |
| 1813 | S->vtop--; | 1813 | S->tccgen_vtop--; |
| 1814 | return; | 1814 | return; |
| 1815 | } | 1815 | } |
| 1816 | x|=0x300000; | 1816 | x|=0x300000; |
| @@ -1818,13 +1818,13 @@ void gen_opf(TCCState *S, int op) · 1 unmodified line | |||
| 1818 | case '-': | 1818 | case '-': |
| 1819 | x|=0x300040; | 1819 | x|=0x300040; |
| 1820 | if(is_zero(S, 0)) { | 1820 | if(is_zero(S, 0)) { |
| 1821 | S->vtop--; | 1821 | S->tccgen_vtop--; |
| 1822 | return; | 1822 | return; |
| 1823 | } | 1823 | } |
| 1824 | if(is_zero(S, -1)) { | 1824 | if(is_zero(S, -1)) { |
| 1825 | x|=0x810000; /* fsubX -> fnegX */ | 1825 | x|=0x810000; /* fsubX -> fnegX */ |
| 1826 | vswap(S); | 1826 | vswap(S); |
| 1827 | S->vtop--; | 1827 | S->tccgen_vtop--; |
| 1828 | fneg=1; | 1828 | fneg=1; |
| 1829 | } | 1829 | } |
| 1830 | break; | 1830 | break; |
| @@ -1852,13 +1852,13 @@ void gen_opf(TCCState *S, int op) · 21 unmodified lines | |||
| 1852 | if(op!=TOK_EQ && op!=TOK_NE) | 1852 | if(op!=TOK_EQ && op!=TOK_NE) |
| 1853 | x|=0x80; /* fcmpX -> fcmpeX */ | 1853 | x|=0x80; /* fcmpX -> fcmpeX */ |
| 1854 | if(is_zero(S, 0)) { | 1854 | if(is_zero(S, 0)) { |
| 1855 | S->vtop--; | 1855 | S->tccgen_vtop--; |
| 1856 | o(S, x|0x10000|(vfpr(S, gv(S, RC_FLOAT))<<12)); /* fcmp(e)X -> fcmp(e)zX */ | 1856 | o(S, x|0x10000|(vfpr(S, gv(S, RC_FLOAT))<<12)); /* fcmp(e)X -> fcmp(e)zX */ |
| 1857 | } else { | 1857 | } else { |
| 1858 | gv2(S, RC_FLOAT,RC_FLOAT); | 1858 | gv2(S, RC_FLOAT,RC_FLOAT); |
| 1859 | x|=vfpr(S, S->vtop[0].r); | 1859 | x|=vfpr(S, S->tccgen_vtop[0].r); |
| 1860 | o(S, x|(vfpr(S, S->vtop[-1].r) << 12)); | 1860 | o(S, x|(vfpr(S, S->tccgen_vtop[-1].r) << 12)); |
| 1861 | S->vtop--; | 1861 | S->tccgen_vtop--; |
| 1862 | } | 1862 | } |
| 1863 | o(S, 0xEEF1FA10); /* fmstat */ | 1863 | o(S, 0xEEF1FA10); /* fmstat */ |
| 1864 | 1864 | ||
| @@ -1881,7 +1881,7 @@ void gen_opf(TCCState *S, int op) · 16 unmodified lines | |||
| 1881 | x|=vfpr(S, r2)<<16; | 1881 | x|=vfpr(S, r2)<<16; |
| 1882 | r|=regmask(S, r2); | 1882 | r|=regmask(S, r2); |
| 1883 | #ifdef CONFIG_TCC_BCHECK | 1883 | #ifdef CONFIG_TCC_BCHECK |
| 1884 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 1884 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 1885 | vswap(S); | 1885 | vswap(S); |
| 1886 | r=gv(S, RC_FLOAT); | 1886 | r=gv(S, RC_FLOAT); |
| 1887 | vswap(S); | 1887 | vswap(S); |
| @@ -1889,25 +1889,25 @@ void gen_opf(TCCState *S, int op) · 1 unmodified line | |||
| 1889 | } | 1889 | } |
| 1890 | #endif | 1890 | #endif |
| 1891 | } | 1891 | } |
| 1892 | S->vtop->r=get_reg_ex(S, RC_FLOAT,r); | 1892 | S->tccgen_vtop->r=get_reg_ex(S, RC_FLOAT,r); |
| 1893 | if(!fneg) | 1893 | if(!fneg) |
| 1894 | S->vtop--; | 1894 | S->tccgen_vtop--; |
| 1895 | o(S, x|(vfpr(S, S->vtop->r)<<12)); | 1895 | o(S, x|(vfpr(S, S->tccgen_vtop->r)<<12)); |
| 1896 | } | 1896 | } |
| 1897 | 1897 | ||
| 1898 | #else | 1898 | #else |
| 1899 | static uint32_t is_fconst(TCCState *S) | 1899 | static uint32_t is_fconst(TCCState* S) |
| 1900 | { | 1900 | { |
| 1901 | long double f; | 1901 | long double f; |
| 1902 | uint32_t r; | 1902 | uint32_t r; |
| 1903 | if((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST) | 1903 | if((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST) |
| 1904 | return 0; | 1904 | return 0; |
| 1905 | if (S->vtop->type.t == VT_FLOAT) | 1905 | if (S->tccgen_vtop->type.t == VT_FLOAT) |
| 1906 | f = S->vtop->c.f; | 1906 | f = S->tccgen_vtop->c.f; |
| 1907 | else if (S->vtop->type.t == VT_DOUBLE) | 1907 | else if (S->tccgen_vtop->type.t == VT_DOUBLE) |
| 1908 | f = S->vtop->c.d; | 1908 | f = S->tccgen_vtop->c.d; |
| 1909 | else | 1909 | else |
| 1910 | f = S->vtop->c.ld; | 1910 | f = S->tccgen_vtop->c.ld; |
| 1911 | if(!ieee_finite(f)) | 1911 | if(!ieee_finite(f)) |
| 1912 | return 0; | 1912 | return 0; |
| 1913 | r=0x8; | 1913 | r=0x8; |
| @@ -1936,7 +1936,7 @@ static uint32_t is_fconst(TCCState *S) · 22 unmodified lines | |||
| 1936 | 1936 | ||
| 1937 | /* generate a floating point operation 'v = t1 op t2' instruction. The | 1937 | /* generate a floating point operation 'v = t1 op t2' instruction. The |
| 1938 | two operands are guaranteed to have the same floating point type */ | 1938 | two operands are guaranteed to have the same floating point type */ |
| 1939 | void gen_opf(TCCState *S, int op) | 1939 | void gen_opf(TCCState* S, int op) |
| 1940 | { | 1940 | { |
| 1941 | uint32_t x, r, r2, c1, c2; | 1941 | uint32_t x, r, r2, c1, c2; |
| 1942 | //fputs("gen_opf\n",stderr); | 1942 | //fputs("gen_opf\n",stderr); |
| @@ -1946,12 +1946,12 @@ void gen_opf(TCCState *S, int op) · 3 unmodified lines | |||
| 1946 | c2 = is_fconst(S); | 1946 | c2 = is_fconst(S); |
| 1947 | x=0xEE000100; | 1947 | x=0xEE000100; |
| 1948 | #if LDOUBLE_SIZE == 8 | 1948 | #if LDOUBLE_SIZE == 8 |
| 1949 | if ((S->vtop->type.t & VT_BTYPE) != VT_FLOAT) | 1949 | if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FLOAT) |
| 1950 | x|=0x80; | 1950 | x|=0x80; |
| 1951 | #else | 1951 | #else |
| 1952 | if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE) | 1952 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE) |
| 1953 | x|=0x80; | 1953 | x|=0x80; |
| 1954 | else if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) | 1954 | else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) |
| 1955 | x|=0x80000; | 1955 | x|=0x80000; |
| 1956 | #endif | 1956 | #endif |
| 1957 | switch(op) | 1957 | switch(op) |
| @@ -1971,7 +1971,7 @@ void gen_opf(TCCState *S, int op) · 13 unmodified lines | |||
| 1971 | } else { | 1971 | } else { |
| 1972 | r2=fpr(S, gv(S, RC_FLOAT)); | 1972 | r2=fpr(S, gv(S, RC_FLOAT)); |
| 1973 | #ifdef CONFIG_TCC_BCHECK | 1973 | #ifdef CONFIG_TCC_BCHECK |
| 1974 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 1974 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 1975 | vswap(S); | 1975 | vswap(S); |
| 1976 | r=fpr(S, gv(S, RC_FLOAT)); | 1976 | r=fpr(S, gv(S, RC_FLOAT)); |
| 1977 | vswap(S); | 1977 | vswap(S); |
| @@ -1999,7 +1999,7 @@ void gen_opf(TCCState *S, int op) · 21 unmodified lines | |||
| 1999 | vswap(S); | 1999 | vswap(S); |
| 2000 | r2=fpr(S, gv(S, RC_FLOAT)); | 2000 | r2=fpr(S, gv(S, RC_FLOAT)); |
| 2001 | #ifdef CONFIG_TCC_BCHECK | 2001 | #ifdef CONFIG_TCC_BCHECK |
| 2002 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 2002 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 2003 | vswap(S); | 2003 | vswap(S); |
| 2004 | r=fpr(S, gv(S, RC_FLOAT)); | 2004 | r=fpr(S, gv(S, RC_FLOAT)); |
| 2005 | vswap(S); | 2005 | vswap(S); |
| @@ -2020,7 +2020,7 @@ void gen_opf(TCCState *S, int op) · 14 unmodified lines | |||
| 2020 | else { | 2020 | else { |
| 2021 | r2=fpr(S, gv(S, RC_FLOAT)); | 2021 | r2=fpr(S, gv(S, RC_FLOAT)); |
| 2022 | #ifdef CONFIG_TCC_BCHECK | 2022 | #ifdef CONFIG_TCC_BCHECK |
| 2023 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 2023 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 2024 | vswap(S); | 2024 | vswap(S); |
| 2025 | r=fpr(S, gv(S, RC_FLOAT)); | 2025 | r=fpr(S, gv(S, RC_FLOAT)); |
| 2026 | vswap(S); | 2026 | vswap(S); |
| @@ -2048,7 +2048,7 @@ void gen_opf(TCCState *S, int op) · 21 unmodified lines | |||
| 2048 | vswap(S); | 2048 | vswap(S); |
| 2049 | r2=fpr(S, gv(S, RC_FLOAT)); | 2049 | r2=fpr(S, gv(S, RC_FLOAT)); |
| 2050 | #ifdef CONFIG_TCC_BCHECK | 2050 | #ifdef CONFIG_TCC_BCHECK |
| 2051 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 2051 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 2052 | vswap(S); | 2052 | vswap(S); |
| 2053 | r=fpr(S, gv(S, RC_FLOAT)); | 2053 | r=fpr(S, gv(S, RC_FLOAT)); |
| 2054 | vswap(S); | 2054 | vswap(S); |
| @@ -2107,65 +2107,65 @@ void gen_opf(TCCState *S, int op) · 52 unmodified lines | |||
| 2107 | } else { | 2107 | } else { |
| 2108 | r2=fpr(S, gv(S, RC_FLOAT)); | 2108 | r2=fpr(S, gv(S, RC_FLOAT)); |
| 2109 | #ifdef CONFIG_TCC_BCHECK | 2109 | #ifdef CONFIG_TCC_BCHECK |
| 2110 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 2110 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 2111 | vswap(S); | 2111 | vswap(S); |
| 2112 | r=fpr(S, gv(S, RC_FLOAT)); | 2112 | r=fpr(S, gv(S, RC_FLOAT)); |
| 2113 | vswap(S); | 2113 | vswap(S); |
| 2114 | } | 2114 | } |
| 2115 | #endif | 2115 | #endif |
| 2116 | } | 2116 | } |
| 2117 | --S->vtop; | 2117 | --S->tccgen_vtop; |
| 2118 | vset_VT_CMP(S, op); | 2118 | vset_VT_CMP(S, op); |
| 2119 | ++S->vtop; | 2119 | ++S->tccgen_vtop; |
| 2120 | } else { | 2120 | } else { |
| 2121 | tcc_error(S, "unknown fp op %x!",op); | 2121 | tcc_error(S, "unknown fp op %x!",op); |
| 2122 | return; | 2122 | return; |
| 2123 | } | 2123 | } |
| 2124 | } | 2124 | } |
| 2125 | if(S->vtop[-1].r == VT_CMP) | 2125 | if(S->tccgen_vtop[-1].r == VT_CMP) |
| 2126 | c1=15; | 2126 | c1=15; |
| 2127 | else { | 2127 | else { |
| 2128 | c1=S->vtop->r; | 2128 | c1=S->tccgen_vtop->r; |
| 2129 | if(r2&0x8) | 2129 | if(r2&0x8) |
| 2130 | c1=S->vtop[-1].r; | 2130 | c1=S->tccgen_vtop[-1].r; |
| 2131 | S->vtop[-1].r=get_reg_ex(S, RC_FLOAT,two2mask(S, S->vtop[-1].r,c1)); | 2131 | S->tccgen_vtop[-1].r=get_reg_ex(S, RC_FLOAT,two2mask(S, S->tccgen_vtop[-1].r,c1)); |
| 2132 | c1=fpr(S, S->vtop[-1].r); | 2132 | c1=fpr(S, S->tccgen_vtop[-1].r); |
| 2133 | } | 2133 | } |
| 2134 | S->vtop--; | 2134 | S->tccgen_vtop--; |
| 2135 | o(S, x|(r<<16)|(c1<<12)|r2); | 2135 | o(S, x|(r<<16)|(c1<<12)|r2); |
| 2136 | } | 2136 | } |
| 2137 | #endif | 2137 | #endif |
| 2138 | 2138 | ||
| 2139 | /* convert integers to fp 't' type. Must handle 'int', 'unsigned int' | 2139 | /* convert integers to fp 't' type. Must handle 'int', 'unsigned int' |
| 2140 | and 'long long' cases. */ | 2140 | and 'long long' cases. */ |
| 2141 | ST_FUNC void gen_cvt_itof(TCCState *S, int t) | 2141 | ST_FUNC void gen_cvt_itof(TCCState* S, int t) |
| 2142 | { | 2142 | { |
| 2143 | uint32_t r, r2; | 2143 | uint32_t r, r2; |
| 2144 | int bt; | 2144 | int bt; |
| 2145 | bt=S->vtop->type.t & VT_BTYPE; | 2145 | bt=S->tccgen_vtop->type.t & VT_BTYPE; |
| 2146 | if(bt == VT_INT || bt == VT_SHORT || bt == VT_BYTE) { | 2146 | if(bt == VT_INT || bt == VT_SHORT || bt == VT_BYTE) { |
| 2147 | #ifndef TCC_ARM_VFP | 2147 | #ifndef TCC_ARM_VFP |
| 2148 | uint32_t dsize = 0; | 2148 | uint32_t dsize = 0; |
| 2149 | #endif | 2149 | #endif |
| 2150 | r=intr(S, gv(S, RC_INT)); | 2150 | r=intr(S, gv(S, RC_INT)); |
| 2151 | #ifdef TCC_ARM_VFP | 2151 | #ifdef TCC_ARM_VFP |
| 2152 | r2=vfpr(S, S->vtop->r=get_reg(S, RC_FLOAT)); | 2152 | r2=vfpr(S, S->tccgen_vtop->r=get_reg(S, RC_FLOAT)); |
| 2153 | o(S, 0xEE000A10|(r<<12)|(r2<<16)); /* fmsr */ | 2153 | o(S, 0xEE000A10|(r<<12)|(r2<<16)); /* fmsr */ |
| 2154 | r2|=r2<<12; | 2154 | r2|=r2<<12; |
| 2155 | if(!(S->vtop->type.t & VT_UNSIGNED)) | 2155 | if(!(S->tccgen_vtop->type.t & VT_UNSIGNED)) |
| 2156 | r2|=0x80; /* fuitoX -> fsituX */ | 2156 | r2|=0x80; /* fuitoX -> fsituX */ |
| 2157 | o(S, 0xEEB80A40|r2|T2CPR(t)); /* fYitoX*/ | 2157 | o(S, 0xEEB80A40|r2|T2CPR(t)); /* fYitoX*/ |
| 2158 | #else | 2158 | #else |
| 2159 | r2=fpr(S, S->vtop->r=get_reg(S, RC_FLOAT)); | 2159 | r2=fpr(S, S->tccgen_vtop->r=get_reg(S, RC_FLOAT)); |
| 2160 | if((t & VT_BTYPE) != VT_FLOAT) | 2160 | if((t & VT_BTYPE) != VT_FLOAT) |
| 2161 | dsize=0x80; /* flts -> fltd */ | 2161 | dsize=0x80; /* flts -> fltd */ |
| 2162 | o(S, 0xEE000110|dsize|(r2<<16)|(r<<12)); /* flts */ | 2162 | o(S, 0xEE000110|dsize|(r2<<16)|(r<<12)); /* flts */ |
| 2163 | if((S->vtop->type.t & (VT_UNSIGNED|VT_BTYPE)) == (VT_UNSIGNED|VT_INT)) { | 2163 | if((S->tccgen_vtop->type.t & (VT_UNSIGNED|VT_BTYPE)) == (VT_UNSIGNED|VT_INT)) { |
| 2164 | uint32_t off = 0; | 2164 | uint32_t off = 0; |
| 2165 | o(S, 0xE3500000|(r<<12)); /* cmp */ | 2165 | o(S, 0xE3500000|(r<<12)); /* cmp */ |
| 2166 | r=fpr(S, get_reg(S, RC_FLOAT)); | 2166 | r=fpr(S, get_reg(S, RC_FLOAT)); |
| 2167 | if(last_itod_magic) { | 2167 | if(last_itod_magic) { |
| 2168 | off=S->ind+8-last_itod_magic; | 2168 | off=S->tccgen_ind+8-last_itod_magic; |
| 2169 | off/=4; | 2169 | off/=4; |
| 2170 | if(off>255) | 2170 | if(off>255) |
| 2171 | off=0; | 2171 | off=0; |
| @@ -2173,7 +2173,7 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t) · 1 unmodified line | |||
| 2173 | o(S, 0xBD1F0100|(r<<12)|off); /* ldflts */ | 2173 | o(S, 0xBD1F0100|(r<<12)|off); /* ldflts */ |
| 2174 | if(!off) { | 2174 | if(!off) { |
| 2175 | o(S, 0xEA000000); /* b */ | 2175 | o(S, 0xEA000000); /* b */ |
| 2176 | last_itod_magic=S->ind; | 2176 | last_itod_magic=S->tccgen_ind; |
| 2177 | o(S, 0x4F800000); /* 4294967296.0f */ | 2177 | o(S, 0x4F800000); /* 4294967296.0f */ |
| 2178 | } | 2178 | } |
| 2179 | o(S, 0xBE000100|dsize|(r2<<16)|(r2<<12)|r); /* adflt */ | 2179 | o(S, 0xBE000100|dsize|(r2<<16)|(r2<<12)|r); /* adflt */ |
| @@ -2185,14 +2185,14 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t) · 5 unmodified lines | |||
| 2185 | CType *func_type = 0; | 2185 | CType *func_type = 0; |
| 2186 | if((t & VT_BTYPE) == VT_FLOAT) { | 2186 | if((t & VT_BTYPE) == VT_FLOAT) { |
| 2187 | func_type = &S->armgen_func_float_type; | 2187 | func_type = &S->armgen_func_float_type; |
| 2188 | if(S->vtop->type.t & VT_UNSIGNED) | 2188 | if(S->tccgen_vtop->type.t & VT_UNSIGNED) |
| 2189 | func=TOK___floatundisf; | 2189 | func=TOK___floatundisf; |
| 2190 | else | 2190 | else |
| 2191 | func=TOK___floatdisf; | 2191 | func=TOK___floatdisf; |
| 2192 | #if LDOUBLE_SIZE != 8 | 2192 | #if LDOUBLE_SIZE != 8 |
| 2193 | } else if((t & VT_BTYPE) == VT_LDOUBLE) { | 2193 | } else if((t & VT_BTYPE) == VT_LDOUBLE) { |
| 2194 | func_type = &S->armgen_func_ldouble_type; | 2194 | func_type = &S->armgen_func_ldouble_type; |
| 2195 | if(S->vtop->type.t & VT_UNSIGNED) | 2195 | if(S->tccgen_vtop->type.t & VT_UNSIGNED) |
| 2196 | func=TOK___floatundixf; | 2196 | func=TOK___floatundixf; |
| 2197 | else | 2197 | else |
| 2198 | func=TOK___floatdixf; | 2198 | func=TOK___floatdixf; |
| @@ -2201,7 +2201,7 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t) · 2 unmodified lines | |||
| 2201 | } else if((t & VT_BTYPE) == VT_DOUBLE || (t & VT_BTYPE) == VT_LDOUBLE) { | 2201 | } else if((t & VT_BTYPE) == VT_DOUBLE || (t & VT_BTYPE) == VT_LDOUBLE) { |
| 2202 | #endif | 2202 | #endif |
| 2203 | func_type = &S->armgen_func_double_type; | 2203 | func_type = &S->armgen_func_double_type; |
| 2204 | if(S->vtop->type.t & VT_UNSIGNED) | 2204 | if(S->tccgen_vtop->type.t & VT_UNSIGNED) |
| 2205 | func=TOK___floatundidf; | 2205 | func=TOK___floatundidf; |
| 2206 | else | 2206 | else |
| 2207 | func=TOK___floatdidf; | 2207 | func=TOK___floatdidf; |
| @@ -2211,27 +2211,27 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t) · 3 unmodified lines | |||
| 2211 | vswap(S); | 2211 | vswap(S); |
| 2212 | gfunc_call(S, 1); | 2212 | gfunc_call(S, 1); |
| 2213 | vpushi(S, 0); | 2213 | vpushi(S, 0); |
| 2214 | S->vtop->r=TREG_F0; | 2214 | S->tccgen_vtop->r=TREG_F0; |
| 2215 | return; | 2215 | return; |
| 2216 | } | 2216 | } |
| 2217 | } | 2217 | } |
| 2218 | tcc_error(S, "unimplemented gen_cvt_itof %x!",S->vtop->type.t); | 2218 | tcc_error(S, "unimplemented gen_cvt_itof %x!",S->tccgen_vtop->type.t); |
| 2219 | } | 2219 | } |
| 2220 | 2220 | ||
| 2221 | /* convert fp to int 't' type */ | 2221 | /* convert fp to int 't' type */ |
| 2222 | void gen_cvt_ftoi(TCCState *S, int t) | 2222 | void gen_cvt_ftoi(TCCState* S, int t) |
| 2223 | { | 2223 | { |
| 2224 | uint32_t r, r2; | 2224 | uint32_t r, r2; |
| 2225 | int u, func = 0; | 2225 | int u, func = 0; |
| 2226 | u=t&VT_UNSIGNED; | 2226 | u=t&VT_UNSIGNED; |
| 2227 | t&=VT_BTYPE; | 2227 | t&=VT_BTYPE; |
| 2228 | r2=S->vtop->type.t & VT_BTYPE; | 2228 | r2=S->tccgen_vtop->type.t & VT_BTYPE; |
| 2229 | if(t==VT_INT) { | 2229 | if(t==VT_INT) { |
| 2230 | #ifdef TCC_ARM_VFP | 2230 | #ifdef TCC_ARM_VFP |
| 2231 | r=vfpr(S, gv(S, RC_FLOAT)); | 2231 | r=vfpr(S, gv(S, RC_FLOAT)); |
| 2232 | u=u?0:0x10000; | 2232 | u=u?0:0x10000; |
| 2233 | o(S, 0xEEBC0AC0|(r<<12)|r|T2CPR(r2)|u); /* ftoXizY */ | 2233 | o(S, 0xEEBC0AC0|(r<<12)|r|T2CPR(r2)|u); /* ftoXizY */ |
| 2234 | r2=intr(S, S->vtop->r=get_reg(S, RC_INT)); | 2234 | r2=intr(S, S->tccgen_vtop->r=get_reg(S, RC_INT)); |
| 2235 | o(S, 0xEE100A10|(r<<16)|(r2<<12)); | 2235 | o(S, 0xEE100A10|(r<<16)|(r2<<12)); |
| 2236 | return; | 2236 | return; |
| 2237 | #else | 2237 | #else |
| @@ -2248,7 +2248,7 @@ void gen_cvt_ftoi(TCCState *S, int t) · 10 unmodified lines | |||
| 2248 | func=TOK___fixunsdfsi; | 2248 | func=TOK___fixunsdfsi; |
| 2249 | } else { | 2249 | } else { |
| 2250 | r=fpr(S, gv(S, RC_FLOAT)); | 2250 | r=fpr(S, gv(S, RC_FLOAT)); |
| 2251 | r2=intr(S, S->vtop->r=get_reg(S, RC_INT)); | 2251 | r2=intr(S, S->tccgen_vtop->r=get_reg(S, RC_INT)); |
| 2252 | o(S, 0xEE100170|(r2<<12)|r); | 2252 | o(S, 0xEE100170|(r2<<12)|r); |
| 2253 | return; | 2253 | return; |
| 2254 | } | 2254 | } |
| @@ -2271,20 +2271,20 @@ void gen_cvt_ftoi(TCCState *S, int t) · 16 unmodified lines | |||
| 2271 | gfunc_call(S, 1); | 2271 | gfunc_call(S, 1); |
| 2272 | vpushi(S, 0); | 2272 | vpushi(S, 0); |
| 2273 | if(t == VT_LLONG) | 2273 | if(t == VT_LLONG) |
| 2274 | S->vtop->r2 = REG_IRE2; | 2274 | S->tccgen_vtop->r2 = REG_IRE2; |
| 2275 | S->vtop->r = REG_IRET; | 2275 | S->tccgen_vtop->r = REG_IRET; |
| 2276 | return; | 2276 | return; |
| 2277 | } | 2277 | } |
| 2278 | tcc_error(S, "unimplemented gen_cvt_ftoi!"); | 2278 | tcc_error(S, "unimplemented gen_cvt_ftoi!"); |
| 2279 | } | 2279 | } |
| 2280 | 2280 | ||
| 2281 | /* convert from one floating point type to another */ | 2281 | /* convert from one floating point type to another */ |
| 2282 | void gen_cvt_ftof(TCCState *S, int t) | 2282 | void gen_cvt_ftof(TCCState* S, int t) |
| 2283 | { | 2283 | { |
| 2284 | #ifdef TCC_ARM_VFP | 2284 | #ifdef TCC_ARM_VFP |
| 2285 | if(((S->vtop->type.t & VT_BTYPE) == VT_FLOAT) != ((t & VT_BTYPE) == VT_FLOAT)) { | 2285 | if(((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FLOAT) != ((t & VT_BTYPE) == VT_FLOAT)) { |
| 2286 | uint32_t r = vfpr(S, gv(S, RC_FLOAT)); | 2286 | uint32_t r = vfpr(S, gv(S, RC_FLOAT)); |
| 2287 | o(S, 0xEEB70AC0|(r<<12)|r|T2CPR(S->vtop->type.t)); | 2287 | o(S, 0xEEB70AC0|(r<<12)|r|T2CPR(S->tccgen_vtop->type.t)); |
| 2288 | } | 2288 | } |
| 2289 | #else | 2289 | #else |
| 2290 | /* all we have to do on i386 and FPA ARM is to put the float in a register */ | 2290 | /* all we have to do on i386 and FPA ARM is to put the float in a register */ |
| @@ -2293,16 +2293,16 @@ void gen_cvt_ftof(TCCState *S, int t) · 2 unmodified lines | |||
| 2293 | } | 2293 | } |
| 2294 | 2294 | ||
| 2295 | /* increment tcov counter */ | 2295 | /* increment tcov counter */ |
| 2296 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv) | 2296 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv) |
| 2297 | { | 2297 | { |
| 2298 | int r1, r2; | 2298 | int r1, r2; |
| 2299 | 2299 | ||
| 2300 | vpushv(S, sv); | 2300 | vpushv(S, sv); |
| 2301 | S->vtop->r = r1 = get_reg(S, RC_INT); | 2301 | S->tccgen_vtop->r = r1 = get_reg(S, RC_INT); |
| 2302 | r2 = get_reg(S, RC_INT); | 2302 | r2 = get_reg(S, RC_INT); |
| 2303 | o(S, 0xE59F0000 | (intr(S, r1)<<12)); // ldr r1,[pc] | 2303 | o(S, 0xE59F0000 | (intr(S, r1)<<12)); // ldr r1,[pc] |
| 2304 | o(S, 0xEA000000); // b $+4 | 2304 | o(S, 0xEA000000); // b $+4 |
| 2305 | greloc(S, cur_text_section, sv->sym, S->ind, R_ARM_REL32); | 2305 | greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_ARM_REL32); |
| 2306 | o(S, -12); | 2306 | o(S, -12); |
| 2307 | o(S, 0xe080000f | (intr(S, r1)<<16) | (intr(S, r1)<<12)); // add r1,r1,pc | 2307 | o(S, 0xe080000f | (intr(S, r1)<<16) | (intr(S, r1)<<12)); // add r1,r1,pc |
| 2308 | o(S, 0xe5900000 | (intr(S, r1)<<16) | (intr(S, r2)<<12)); // ldr r2, [r1] | 2308 | o(S, 0xe5900000 | (intr(S, r1)<<16) | (intr(S, r2)<<12)); // ldr r2, [r1] |
| @@ -2316,14 +2316,14 @@ ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv) · 7 unmodified lines | |||
| 2316 | } | 2316 | } |
| 2317 | 2317 | ||
| 2318 | /* computed goto support */ | 2318 | /* computed goto support */ |
| 2319 | void ggoto(TCCState *S) | 2319 | void ggoto(TCCState* S) |
| 2320 | { | 2320 | { |
| 2321 | gcall_or_jmp(S, 1); | 2321 | gcall_or_jmp(S, 1); |
| 2322 | S->vtop--; | 2322 | S->tccgen_vtop--; |
| 2323 | } | 2323 | } |
| 2324 | 2324 | ||
| 2325 | /* Save the stack pointer onto the stack and return the location of its address */ | 2325 | /* Save the stack pointer onto the stack and return the location of its address */ |
| 2326 | ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) { | 2326 | ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) { |
| 2327 | SValue v; | 2327 | SValue v; |
| 2328 | v.type.t = VT_PTR; | 2328 | v.type.t = VT_PTR; |
| 2329 | v.r = VT_LOCAL | VT_LVAL; | 2329 | v.r = VT_LOCAL | VT_LVAL; |
| @@ -2332,7 +2332,7 @@ ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) { · 2 unmodified lines | |||
| 2332 | } | 2332 | } |
| 2333 | 2333 | ||
| 2334 | /* Restore the SP from a location on the stack */ | 2334 | /* Restore the SP from a location on the stack */ |
| 2335 | ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) { | 2335 | ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) { |
| 2336 | SValue v; | 2336 | SValue v; |
| 2337 | v.type.t = VT_PTR; | 2337 | v.type.t = VT_PTR; |
| 2338 | v.r = VT_LOCAL | VT_LVAL; | 2338 | v.r = VT_LOCAL | VT_LVAL; |
| @@ -2341,11 +2341,11 @@ ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) { · 2 unmodified lines | |||
| 2341 | } | 2341 | } |
| 2342 | 2342 | ||
| 2343 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ | 2343 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ |
| 2344 | ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) { | 2344 | ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) { |
| 2345 | int r; | 2345 | int r; |
| 2346 | #if defined(CONFIG_TCC_BCHECK) | 2346 | #if defined(CONFIG_TCC_BCHECK) |
| 2347 | if (S->do_bounds_check) | 2347 | if (S->do_bounds_check) |
| 2348 | vpushv(S, S->vtop); | 2348 | vpushv(S, S->tccgen_vtop); |
| 2349 | #endif | 2349 | #endif |
| 2350 | r = intr(S, gv(S, RC_INT)); | 2350 | r = intr(S, gv(S, RC_INT)); |
| 2351 | #if defined(CONFIG_TCC_BCHECK) | 2351 | #if defined(CONFIG_TCC_BCHECK) |
| @@ -2367,8 +2367,8 @@ ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) { · 15 unmodified lines | |||
| 2367 | #if defined(CONFIG_TCC_BCHECK) | 2367 | #if defined(CONFIG_TCC_BCHECK) |
| 2368 | if (S->do_bounds_check) { | 2368 | if (S->do_bounds_check) { |
| 2369 | vpushi(S, 0); | 2369 | vpushi(S, 0); |
| 2370 | S->vtop->r = TREG_R0; | 2370 | S->tccgen_vtop->r = TREG_R0; |
| 2371 | o(S, 0xe1a0000d | (S->vtop->r << 12)); // mov r0,sp | 2371 | o(S, 0xe1a0000d | (S->tccgen_vtop->r << 12)); // mov r0,sp |
| 2372 | vswap(S); | 2372 | vswap(S); |
| 2373 | vpush_helper_func(S, TOK___bound_new_region); | 2373 | vpush_helper_func(S, TOK___bound_new_region); |
| 2374 | vrott(S, 3); | 2374 | vrott(S, 3); |
| @@ -9,9 +9,9 @@ · 8 unmodified lines | |||
| 9 | #define CONFIG_TCC_ASM | 9 | #define CONFIG_TCC_ASM |
| 10 | #define NB_ASM_REGS 16 | 10 | #define NB_ASM_REGS 16 |
| 11 | 11 | ||
| 12 | ST_FUNC void g(TCCState *S, int c); | 12 | ST_FUNC void g(TCCState* S, int c); |
| 13 | ST_FUNC void gen_le16(TCCState *S, int c); | 13 | ST_FUNC void gen_le16(TCCState* S, int c); |
| 14 | ST_FUNC void gen_le32(TCCState *S, int c); | 14 | ST_FUNC void gen_le32(TCCState* S, int c); |
| 15 | 15 | ||
| 16 | /*************************************************************/ | 16 | /*************************************************************/ |
| 17 | #else | 17 | #else |
| @@ -19,74 +19,74 @@ ST_FUNC void gen_le32(TCCState *S, int c); · 1 unmodified line | |||
| 19 | #define USING_GLOBALS | 19 | #define USING_GLOBALS |
| 20 | #include "tcc.h" | 20 | #include "tcc.h" |
| 21 | 21 | ||
| 22 | static void asm_error(TCCState *S) | 22 | static void asm_error(void) |
| 23 | { | 23 | { |
| 24 | tcc_error(S, "ARM asm not implemented."); | 24 | tcc_error("ARM asm not implemented."); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | /* XXX: make it faster ? */ | 27 | /* XXX: make it faster ? */ |
| 28 | ST_FUNC void g(TCCState *S, int c) | 28 | ST_FUNC void g(TCCState* S, int c) |
| 29 | { | 29 | { |
| 30 | int ind1; | 30 | int ind1; |
| 31 | if (S->nocode_wanted) | 31 | if (nocode_wanted) |
| 32 | return; | 32 | return; |
| 33 | ind1 = S->ind + 1; | 33 | ind1 = ind + 1; |
| 34 | if (ind1 > cur_text_section->data_allocated) | 34 | if (ind1 > cur_text_section->data_allocated) |
| 35 | section_realloc(S, cur_text_section, ind1); | 35 | section_realloc(cur_text_section, ind1); |
| 36 | cur_text_section->data[S->ind] = c; | 36 | cur_text_section->data[ind] = c; |
| 37 | S->ind = ind1; | 37 | ind = ind1; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | ST_FUNC void gen_le16 (TCCState *S, int i) | 40 | ST_FUNC void gen_le16 (TCCState* S, int i) |
| 41 | { | 41 | { |
| 42 | g(S, i); | 42 | g(S, i); |
| 43 | g(S, i>>8); | 43 | g(S, i>>8); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | ST_FUNC void gen_le32 (TCCState *S, int i) | 46 | ST_FUNC void gen_le32 (TCCState* S, int i) |
| 47 | { | 47 | { |
| 48 | gen_le16(S, i); | 48 | gen_le16(S, i); |
| 49 | gen_le16(S, i>>16); | 49 | gen_le16(S, i>>16); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe) | 52 | ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe) |
| 53 | { | 53 | { |
| 54 | gen_le32(S, pe->v); | 54 | gen_le32(S, pe->v); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | ST_FUNC void asm_opcode(TCCState *S, int opcode) | 57 | ST_FUNC void asm_opcode(TCCState *S, int opcode) |
| 58 | { | 58 | { |
| 59 | asm_error(S); | 59 | asm_error(); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, SValue *sv, int modifier) | 62 | ST_FUNC void subst_asm_operand(CString *add_str, SValue *sv, int modifier) |
| 63 | { | 63 | { |
| 64 | asm_error(S); | 64 | asm_error(); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | /* generate prolog and epilog code for asm statement */ | 67 | /* generate prolog and epilog code for asm statement */ |
| 68 | ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands, | 68 | ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands, |
| 69 | int nb_outputs, int is_output, | 69 | int nb_outputs, int is_output, |
| 70 | uint8_t *clobber_regs, | 70 | uint8_t *clobber_regs, |
| 71 | int out_reg) | 71 | int out_reg) |
| 72 | { | 72 | { |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands, | 75 | ST_FUNC void asm_compute_constraints(ASMOperand *operands, |
| 76 | int nb_operands, int nb_outputs, | 76 | int nb_operands, int nb_outputs, |
| 77 | const uint8_t *clobber_regs, | 77 | const uint8_t *clobber_regs, |
| 78 | int *pout_reg) | 78 | int *pout_reg) |
| 79 | { | 79 | { |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | ST_FUNC void asm_clobber(TCCState *S, 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(S); | 84 | asm_error(); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | ST_FUNC int asm_parse_regvar (TCCState *S, int t) | 87 | ST_FUNC int asm_parse_regvar (int t) |
| 88 | { | 88 | { |
| 89 | asm_error(S); | 89 | asm_error(); |
| 90 | return -1; | 90 | return -1; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| @@ -107,13 +107,13 @@ static uint32_t fltr(int r) · 106 unmodified lines | |||
| 107 | // Add an instruction to text section: | 107 | // Add an instruction to text section: |
| 108 | ST_FUNC void o(TCCState *S, unsigned int c) | 108 | ST_FUNC void o(TCCState *S, unsigned int c) |
| 109 | { | 109 | { |
| 110 | int ind1 = S->ind + 4; | 110 | int ind1 = S->tccgen_ind + 4; |
| 111 | if (S->nocode_wanted) | 111 | if (S->tccgen_nocode_wanted) |
| 112 | return; | 112 | return; |
| 113 | if (ind1 > cur_text_section->data_allocated) | 113 | if (ind1 > cur_text_section->data_allocated) |
| 114 | section_realloc(S, cur_text_section, ind1); | 114 | section_realloc(S, cur_text_section, ind1); |
| 115 | write32le(cur_text_section->data + S->ind, c); | 115 | write32le(cur_text_section->data + S->tccgen_ind, c); |
| 116 | S->ind = ind1; | 116 | S->tccgen_ind = ind1; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | static int arm64_encode_bimm64(uint64_t x) | 119 | static int arm64_encode_bimm64(uint64_t x) |
| @@ -452,9 +452,9 @@ static void arm64_strv(TCCState *S, int sz_, int dst, int bas, uint64_t off) · 332 unmodified lines | |||
| 452 | 452 | ||
| 453 | static void arm64_sym(TCCState *S, int r, Sym *sym, unsigned long addend) | 453 | static void arm64_sym(TCCState *S, int r, Sym *sym, unsigned long addend) |
| 454 | { | 454 | { |
| 455 | greloca(S, cur_text_section, sym, S->ind, R_AARCH64_ADR_GOT_PAGE, 0); | 455 | greloca(S, cur_text_section, sym, S->tccgen_ind, R_AARCH64_ADR_GOT_PAGE, 0); |
| 456 | o(S, 0x90000000 | r); // adrp xr, #sym | 456 | o(S, 0x90000000 | r); // adrp xr, #sym |
| 457 | greloca(S, cur_text_section, sym, S->ind, R_AARCH64_LD64_GOT_LO12_NC, 0); | 457 | greloca(S, cur_text_section, sym, S->tccgen_ind, R_AARCH64_LD64_GOT_LO12_NC, 0); |
| 458 | o(S, 0xf9400000 | r | (r << 5)); // ld xr,[xr, #sym] | 458 | o(S, 0xf9400000 | r | (r << 5)); // ld xr,[xr, #sym] |
| 459 | if (addend) { | 459 | if (addend) { |
| 460 | // add xr, xr, #addend | 460 | // add xr, xr, #addend |
| @@ -654,14 +654,14 @@ ST_FUNC void store(TCCState *S, int r, SValue *sv) · 193 unmodified lines | |||
| 654 | 654 | ||
| 655 | static void arm64_gen_bl_or_b(TCCState *S, int b) | 655 | static void arm64_gen_bl_or_b(TCCState *S, int b) |
| 656 | { | 656 | { |
| 657 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && (S->vtop->r & VT_SYM)) { | 657 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && (S->tccgen_vtop->r & VT_SYM)) { |
| 658 | greloca(S, cur_text_section, S->vtop->sym, S->ind, | 658 | greloca(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind, |
| 659 | b ? R_AARCH64_JUMP26 : R_AARCH64_CALL26, 0); | 659 | b ? R_AARCH64_JUMP26 : R_AARCH64_CALL26, 0); |
| 660 | o(S, 0x14000000 | (uint32_t)!b << 31); // b/bl . | 660 | o(S, 0x14000000 | (uint32_t)!b << 31); // b/bl . |
| 661 | } | 661 | } |
| 662 | else { | 662 | else { |
| 663 | #ifdef CONFIG_TCC_BCHECK | 663 | #ifdef CONFIG_TCC_BCHECK |
| 664 | S->vtop->r &= ~VT_MUSTBOUND; | 664 | S->tccgen_vtop->r &= ~VT_MUSTBOUND; |
| 665 | #endif | 665 | #endif |
| 666 | o(S, 0xd61f0000 | (uint32_t)!b << 21 | intr(S, gv(S, RC_R30)) << 5); // br/blr | 666 | o(S, 0xd61f0000 | (uint32_t)!b << 21 | intr(S, gv(S, RC_R30)) << 5); // br/blr |
| 667 | } | 667 | } |
| @@ -673,7 +673,7 @@ static void gen_bounds_call(TCCState *S, int v) · 5 unmodified lines | |||
| 673 | { | 673 | { |
| 674 | Sym *sym = external_helper_sym(S, v); | 674 | Sym *sym = external_helper_sym(S, v); |
| 675 | 675 | ||
| 676 | greloca(S, cur_text_section, sym, S->ind, R_AARCH64_CALL26, 0); | 676 | greloca(S, cur_text_section, sym, S->tccgen_ind, R_AARCH64_CALL26, 0); |
| 677 | o(S, 0x94000000); // bl | 677 | o(S, 0x94000000); // bl |
| 678 | } | 678 | } |
| 679 | 679 | ||
| @@ -681,7 +681,7 @@ static void gen_bounds_prolog(TCCState *S) · 1 unmodified line | |||
| 681 | { | 681 | { |
| 682 | /* leave some room for bound checking code */ | 682 | /* leave some room for bound checking code */ |
| 683 | S->func_bound_offset = lbounds_section->data_offset; | 683 | S->func_bound_offset = lbounds_section->data_offset; |
| 684 | S->func_bound_ind = S->ind; | 684 | S->func_bound_ind = S->tccgen_ind; |
| 685 | S->func_bound_add_epilog = 0; | 685 | S->func_bound_add_epilog = 0; |
| 686 | o(S, 0xd503201f); /* nop -> mov x0, lbound section pointer */ | 686 | o(S, 0xd503201f); /* nop -> mov x0, lbound section pointer */ |
| 687 | o(S, 0xd503201f); | 687 | o(S, 0xd503201f); |
| @@ -703,27 +703,27 @@ static void gen_bounds_epilog(TCCState *S) · 15 unmodified lines | |||
| 703 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); | 703 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); |
| 704 | *bounds_ptr = 0; | 704 | *bounds_ptr = 0; |
| 705 | 705 | ||
| 706 | sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section, | 706 | sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section, |
| 707 | S->func_bound_offset, lbounds_section->data_offset); | 707 | S->func_bound_offset, lbounds_section->data_offset); |
| 708 | 708 | ||
| 709 | /* generate bound local allocation */ | 709 | /* generate bound local allocation */ |
| 710 | if (offset_modified) { | 710 | if (offset_modified) { |
| 711 | saved_ind = S->ind; | 711 | saved_ind = S->tccgen_ind; |
| 712 | S->ind = S->func_bound_ind; | 712 | S->tccgen_ind = S->func_bound_ind; |
| 713 | greloca(S, cur_text_section, sym_data, S->ind, R_AARCH64_ADR_GOT_PAGE, 0); | 713 | greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_AARCH64_ADR_GOT_PAGE, 0); |
| 714 | o(S, 0x90000000 | 0); // adrp x0, #sym_data | 714 | o(S, 0x90000000 | 0); // adrp x0, #sym_data |
| 715 | greloca(S, cur_text_section, sym_data, S->ind, R_AARCH64_LD64_GOT_LO12_NC, 0); | 715 | greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_AARCH64_LD64_GOT_LO12_NC, 0); |
| 716 | o(S, 0xf9400000 | 0 | (0 << 5)); // ld x0,[x0, #sym_data] | 716 | o(S, 0xf9400000 | 0 | (0 << 5)); // ld x0,[x0, #sym_data] |
| 717 | gen_bounds_call(S, TOK___bound_local_new); | 717 | gen_bounds_call(S, TOK___bound_local_new); |
| 718 | S->ind = saved_ind; | 718 | S->tccgen_ind = saved_ind; |
| 719 | } | 719 | } |
| 720 | 720 | ||
| 721 | /* generate bound check local freeing */ | 721 | /* generate bound check local freeing */ |
| 722 | o(S, 0xf81f0fe0); /* str x0, [sp, #-16]! */ | 722 | o(S, 0xf81f0fe0); /* str x0, [sp, #-16]! */ |
| 723 | o(S, 0x3c9f0fe0); /* str q0, [sp, #-16]! */ | 723 | o(S, 0x3c9f0fe0); /* str q0, [sp, #-16]! */ |
| 724 | greloca(S, cur_text_section, sym_data, S->ind, R_AARCH64_ADR_GOT_PAGE, 0); | 724 | greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_AARCH64_ADR_GOT_PAGE, 0); |
| 725 | o(S, 0x90000000 | 0); // adrp x0, #sym_data | 725 | o(S, 0x90000000 | 0); // adrp x0, #sym_data |
| 726 | greloca(S, cur_text_section, sym_data, S->ind, R_AARCH64_LD64_GOT_LO12_NC, 0); | 726 | greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_AARCH64_LD64_GOT_LO12_NC, 0); |
| 727 | o(S, 0xf9400000 | 0 | (0 << 5)); // ld x0,[x0, #sym_data] | 727 | o(S, 0xf9400000 | 0 | (0 << 5)); // ld x0,[x0, #sym_data] |
| 728 | gen_bounds_call(S, TOK___bound_local_delete); | 728 | gen_bounds_call(S, TOK___bound_local_delete); |
| 729 | o(S, 0x3cc107e0); /* ldr q0, [sp], #16 */ | 729 | o(S, 0x3cc107e0); /* ldr q0, [sp], #16 */ |
| @@ -977,7 +977,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 247 unmodified lines | |||
| 977 | gbound_args(S, nb_args); | 977 | gbound_args(S, nb_args); |
| 978 | #endif | 978 | #endif |
| 979 | 979 | ||
| 980 | return_type = &S->vtop[-nb_args].type.ref->type; | 980 | return_type = &S->tccgen_vtop[-nb_args].type.ref->type; |
| 981 | if ((return_type->t & VT_BTYPE) == VT_STRUCT) | 981 | if ((return_type->t & VT_BTYPE) == VT_STRUCT) |
| 982 | --nb_args; | 982 | --nb_args; |
| 983 | 983 | ||
| @@ -987,14 +987,14 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 3 unmodified lines | |||
| 987 | 987 | ||
| 988 | t[0] = return_type; | 988 | t[0] = return_type; |
| 989 | for (i = 0; i < nb_args; i++) | 989 | for (i = 0; i < nb_args; i++) |
| 990 | t[nb_args - i] = &S->vtop[-i].type; | 990 | t[nb_args - i] = &S->tccgen_vtop[-i].type; |
| 991 | 991 | ||
| 992 | stack = arm64_pcs(nb_args, t, a); | 992 | stack = arm64_pcs(nb_args, t, a); |
| 993 | 993 | ||
| 994 | // Allocate space for structs replaced by pointer: | 994 | // Allocate space for structs replaced by pointer: |
| 995 | for (i = nb_args; i; i--) | 995 | for (i = nb_args; i; i--) |
| 996 | if (a[i] & 1) { | 996 | if (a[i] & 1) { |
| 997 | SValue *arg = &S->vtop[i - nb_args]; | 997 | SValue *arg = &S->tccgen_vtop[i - nb_args]; |
| 998 | int align, size = type_size(&arg->type, &align); | 998 | int align, size = type_size(&arg->type, &align); |
| 999 | assert((arg->type.t & VT_BTYPE) == VT_STRUCT); | 999 | assert((arg->type.t & VT_BTYPE) == VT_STRUCT); |
| 1000 | stack = (stack + align - 1) & -align; | 1000 | stack = (stack + align - 1) & -align; |
| @@ -1005,7 +1005,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 4 unmodified lines | |||
| 1005 | stack = (stack + 15) >> 4 << 4; | 1005 | stack = (stack + 15) >> 4 << 4; |
| 1006 | 1006 | ||
| 1007 | /* fetch cpu flag before generating any code */ | 1007 | /* fetch cpu flag before generating any code */ |
| 1008 | if ((S->vtop->r & VT_VALMASK) == VT_CMP) | 1008 | if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP) |
| 1009 | gv(S, RC_INT); | 1009 | gv(S, RC_INT); |
| 1010 | 1010 | ||
| 1011 | if (stack >= 0x1000000) // 16Mb | 1011 | if (stack >= 0x1000000) // 16Mb |
| @@ -1017,13 +1017,13 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 5 unmodified lines | |||
| 1017 | 1017 | ||
| 1018 | // First pass: set all values on stack | 1018 | // First pass: set all values on stack |
| 1019 | for (i = nb_args; i; i--) { | 1019 | for (i = nb_args; i; i--) { |
| 1020 | vpushv(S, S->vtop - nb_args + i); | 1020 | vpushv(S, S->tccgen_vtop - nb_args + i); |
| 1021 | 1021 | ||
| 1022 | if (a[i] & 1) { | 1022 | if (a[i] & 1) { |
| 1023 | // struct replaced by pointer | 1023 | // struct replaced by pointer |
| 1024 | int r = get_reg(S, RC_INT); | 1024 | int r = get_reg(S, RC_INT); |
| 1025 | arm64_spoff(S, intr(S, r), a1[i]); | 1025 | arm64_spoff(S, intr(S, r), a1[i]); |
| 1026 | vset(S, &S->vtop->type, r | VT_LVAL, 0); | 1026 | vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0); |
| 1027 | vswap(S); | 1027 | vswap(S); |
| 1028 | vstore(S); | 1028 | vstore(S); |
| 1029 | if (a[i] >= 32) { | 1029 | if (a[i] >= 32) { |
| @@ -1035,36 +1035,36 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 5 unmodified lines | |||
| 1035 | } | 1035 | } |
| 1036 | else if (a[i] >= 32) { | 1036 | else if (a[i] >= 32) { |
| 1037 | // value on stack | 1037 | // value on stack |
| 1038 | if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) { | 1038 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) { |
| 1039 | int r = get_reg(S, RC_INT); | 1039 | int r = get_reg(S, RC_INT); |
| 1040 | arm64_spoff(S, intr(S, r), a[i] - 32); | 1040 | arm64_spoff(S, intr(S, r), a[i] - 32); |
| 1041 | vset(S, &S->vtop->type, r | VT_LVAL, 0); | 1041 | vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0); |
| 1042 | vswap(S); | 1042 | vswap(S); |
| 1043 | vstore(S); | 1043 | vstore(S); |
| 1044 | } | 1044 | } |
| 1045 | else if (is_float(S->vtop->type.t)) { | 1045 | else if (is_float(S->tccgen_vtop->type.t)) { |
| 1046 | gv(S, RC_FLOAT); | 1046 | gv(S, RC_FLOAT); |
| 1047 | arm64_strv(S, arm64_type_size(S->vtop[0].type.t), | 1047 | arm64_strv(S, arm64_type_size(S->tccgen_vtop[0].type.t), |
| 1048 | fltr(S->vtop[0].r), 31, a[i] - 32); | 1048 | fltr(S->tccgen_vtop[0].r), 31, a[i] - 32); |
| 1049 | } | 1049 | } |
| 1050 | else { | 1050 | else { |
| 1051 | gv(S, RC_INT); | 1051 | gv(S, RC_INT); |
| 1052 | arm64_strx(S, arm64_type_size(S->vtop[0].type.t), | 1052 | arm64_strx(S, arm64_type_size(S->tccgen_vtop[0].type.t), |
| 1053 | intr(S, S->vtop[0].r), 31, a[i] - 32); | 1053 | intr(S, S->tccgen_vtop[0].r), 31, a[i] - 32); |
| 1054 | } | 1054 | } |
| 1055 | } | 1055 | } |
| 1056 | 1056 | ||
| 1057 | --S->vtop; | 1057 | --S->tccgen_vtop; |
| 1058 | } | 1058 | } |
| 1059 | 1059 | ||
| 1060 | // Second pass: assign values to registers | 1060 | // Second pass: assign values to registers |
| 1061 | for (i = nb_args; i; i--, S->vtop--) { | 1061 | for (i = nb_args; i; i--, S->tccgen_vtop--) { |
| 1062 | if (a[i] < 16 && !(a[i] & 1)) { | 1062 | if (a[i] < 16 && !(a[i] & 1)) { |
| 1063 | // value in general-purpose registers | 1063 | // value in general-purpose registers |
| 1064 | if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) { | 1064 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) { |
| 1065 | int align, size = type_size(&S->vtop->type, &align); | 1065 | int align, size = type_size(&S->tccgen_vtop->type, &align); |
| 1066 | if (size) { | 1066 | if (size) { |
| 1067 | S->vtop->type.t = VT_PTR; | 1067 | S->tccgen_vtop->type.t = VT_PTR; |
| 1068 | gaddrof(S); | 1068 | gaddrof(S); |
| 1069 | gv(S, RC_R(a[i] / 2)); | 1069 | gv(S, RC_R(a[i] / 2)); |
| 1070 | arm64_ldrs(S, a[i] / 2, size); | 1070 | arm64_ldrs(S, a[i] / 2, size); |
| @@ -1078,9 +1078,9 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 7 unmodified lines | |||
| 1078 | arm64_spoff(S, a[i] / 2, a1[i]); | 1078 | arm64_spoff(S, a[i] / 2, a1[i]); |
| 1079 | else if (a[i] < 32) { | 1079 | else if (a[i] < 32) { |
| 1080 | // value in floating-point registers | 1080 | // value in floating-point registers |
| 1081 | if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) { | 1081 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) { |
| 1082 | uint32_t j, sz, n = arm64_hfa(&S->vtop->type, &sz); | 1082 | uint32_t j, sz, n = arm64_hfa(&S->tccgen_vtop->type, &sz); |
| 1083 | S->vtop->type.t = VT_PTR; | 1083 | S->tccgen_vtop->type.t = VT_PTR; |
| 1084 | gaddrof(S); | 1084 | gaddrof(S); |
| 1085 | gv(S, RC_R30); | 1085 | gv(S, RC_R30); |
| 1086 | for (j = 0; j < n; j++) | 1086 | for (j = 0; j < n; j++) |
| @@ -1098,7 +1098,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 11 unmodified lines | |||
| 1098 | if (a[0] == 1) { | 1098 | if (a[0] == 1) { |
| 1099 | // indirect return: set x8 and discard the stack value | 1099 | // indirect return: set x8 and discard the stack value |
| 1100 | gv(S, RC_R(8)); | 1100 | gv(S, RC_R(8)); |
| 1101 | --S->vtop; | 1101 | --S->tccgen_vtop; |
| 1102 | } | 1102 | } |
| 1103 | else | 1103 | else |
| 1104 | // return in registers: keep the address for after the call | 1104 | // return in registers: keep the address for after the call |
| @@ -1107,7 +1107,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 2 unmodified lines | |||
| 1107 | 1107 | ||
| 1108 | save_regs(S, 0); | 1108 | save_regs(S, 0); |
| 1109 | arm64_gen_bl_or_b(S, 0); | 1109 | arm64_gen_bl_or_b(S, 0); |
| 1110 | --S->vtop; | 1110 | --S->tccgen_vtop; |
| 1111 | if (stack & 0xfff) | 1111 | if (stack & 0xfff) |
| 1112 | o(S, 0x910003ff | (stack & 0xfff) << 10); // add sp,sp,#(n) | 1112 | o(S, 0x910003ff | (stack & 0xfff) << 10); // add sp,sp,#(n) |
| 1113 | if (stack >> 12) | 1113 | if (stack >> 12) |
| @@ -1119,7 +1119,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 5 unmodified lines | |||
| 1119 | if (bt == VT_STRUCT && !(a[0] & 1)) { | 1119 | if (bt == VT_STRUCT && !(a[0] & 1)) { |
| 1120 | // A struct was returned in registers, so write it out: | 1120 | // A struct was returned in registers, so write it out: |
| 1121 | gv(S, RC_R(8)); | 1121 | gv(S, RC_R(8)); |
| 1122 | --S->vtop; | 1122 | --S->tccgen_vtop; |
| 1123 | if (a[0] == 0) { | 1123 | if (a[0] == 0) { |
| 1124 | int align, size = type_size(return_type, &align); | 1124 | int align, size = type_size(return_type, &align); |
| 1125 | assert(size <= 16); | 1125 | assert(size <= 16); |
| @@ -1220,11 +1220,11 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 94 unmodified lines | |||
| 1220 | tcc_free(S, t); | 1220 | tcc_free(S, t); |
| 1221 | 1221 | ||
| 1222 | o(S, 0x910003fd); // mov x29,sp | 1222 | o(S, 0x910003fd); // mov x29,sp |
| 1223 | arm64_func_sub_sp_offset = S->ind; | 1223 | arm64_func_sub_sp_offset = S->tccgen_ind; |
| 1224 | // In gfunc_epilog these will be replaced with code to decrement SP: | 1224 | // In gfunc_epilog these will be replaced with code to decrement SP: |
| 1225 | o(S, 0xd503201f); // nop | 1225 | o(S, 0xd503201f); // nop |
| 1226 | o(S, 0xd503201f); // nop | 1226 | o(S, 0xd503201f); // nop |
| 1227 | S->loc = 0; | 1227 | S->tccgen_loc = 0; |
| 1228 | #ifdef CONFIG_TCC_BCHECK | 1228 | #ifdef CONFIG_TCC_BCHECK |
| 1229 | if (S->do_bounds_check) | 1229 | if (S->do_bounds_check) |
| 1230 | gen_bounds_prolog(S); | 1230 | gen_bounds_prolog(S); |
| @@ -1234,7 +1234,7 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 3 unmodified lines | |||
| 1234 | ST_FUNC void gen_va_start(TCCState *S) | 1234 | ST_FUNC void gen_va_start(TCCState *S) |
| 1235 | { | 1235 | { |
| 1236 | int r; | 1236 | int r; |
| 1237 | --S->vtop; // we don't need the "arg" | 1237 | --S->tccgen_vtop; // we don't need the "arg" |
| 1238 | gaddrof(S); | 1238 | gaddrof(S); |
| 1239 | r = intr(S, gv(S, RC_INT)); | 1239 | r = intr(S, gv(S, RC_INT)); |
| 1240 | 1240 | ||
| @@ -1264,7 +1264,7 @@ ST_FUNC void gen_va_start(TCCState *S) · 23 unmodified lines | |||
| 1264 | arm64_movimm(S, 30, arm64_func_va_list_vr_offs); | 1264 | arm64_movimm(S, 30, arm64_func_va_list_vr_offs); |
| 1265 | o(S, 0xb9001c1e | r << 5); // str w30,[x(r),#28] | 1265 | o(S, 0xb9001c1e | r << 5); // str w30,[x(r),#28] |
| 1266 | 1266 | ||
| 1267 | --S->vtop; | 1267 | --S->tccgen_vtop; |
| 1268 | } | 1268 | } |
| 1269 | 1269 | ||
| 1270 | ST_FUNC void gen_va_arg(TCCState *S, CType *t) | 1270 | ST_FUNC void gen_va_arg(TCCState *S, CType *t) |
| @@ -1281,7 +1281,7 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t) · 10 unmodified lines | |||
| 1281 | gaddrof(S); | 1281 | gaddrof(S); |
| 1282 | r0 = intr(S, gv(S, RC_INT)); | 1282 | r0 = intr(S, gv(S, RC_INT)); |
| 1283 | r1 = get_reg(S, RC_INT); | 1283 | r1 = get_reg(S, RC_INT); |
| 1284 | S->vtop[0].r = r1 | VT_LVAL; | 1284 | S->tccgen_vtop[0].r = r1 | VT_LVAL; |
| 1285 | r1 = intr(S, r1); | 1285 | r1 = intr(S, r1); |
| 1286 | 1286 | ||
| 1287 | if (!hfa) { | 1287 | if (!hfa) { |
| @@ -1310,7 +1310,7 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t) · 22 unmodified lines | |||
| 1310 | uint32_t b1, b2; | 1310 | uint32_t b1, b2; |
| 1311 | o(S, 0xb9401c1e | r0 << 5); // ldr w30,[x(r0),#28] // __vr_offs | 1311 | o(S, 0xb9401c1e | r0 << 5); // ldr w30,[x(r0),#28] // __vr_offs |
| 1312 | o(S, 0x310003c0 | r1 | rsz << 10); // adds w(r1),w30,#(rsz) | 1312 | o(S, 0x310003c0 | r1 | rsz << 10); // adds w(r1),w30,#(rsz) |
| 1313 | b1 = S->ind; o(S, 0x5400000d); // b.le lab1 | 1313 | b1 = S->tccgen_ind; o(S, 0x5400000d); // b.le lab1 |
| 1314 | o(S, 0xf9400000 | r1 | r0 << 5); // ldr x(r1),[x(r0)] // __stack | 1314 | o(S, 0xf9400000 | r1 | r0 << 5); // ldr x(r1),[x(r0)] // __stack |
| 1315 | if (fsize == 16) { | 1315 | if (fsize == 16) { |
| 1316 | o(S, 0x91003c00 | r1 | r1 << 5); // add x(r1),x(r1),#15 | 1316 | o(S, 0x91003c00 | r1 | r1 << 5); // add x(r1),x(r1),#15 |
| @@ -1318,9 +1318,9 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t) · 1 unmodified line | |||
| 1318 | } | 1318 | } |
| 1319 | o(S, 0x9100001e | r1 << 5 | ssz << 10); // add x30,x(r1),#(ssz) | 1319 | o(S, 0x9100001e | r1 << 5 | ssz << 10); // add x30,x(r1),#(ssz) |
| 1320 | o(S, 0xf900001e | r0 << 5); // str x30,[x(r0)] // __stack | 1320 | o(S, 0xf900001e | r0 << 5); // str x30,[x(r0)] // __stack |
| 1321 | b2 = S->ind; o(S, 0x14000000); // b lab2 | 1321 | b2 = S->tccgen_ind; o(S, 0x14000000); // b lab2 |
| 1322 | // lab1: | 1322 | // lab1: |
| 1323 | write32le(cur_text_section->data + b1, 0x5400000d | (S->ind - b1) << 3); | 1323 | write32le(cur_text_section->data + b1, 0x5400000d | (S->tccgen_ind - b1) << 3); |
| 1324 | o(S, 0xb9001c00 | r1 | r0 << 5); // str w(r1),[x(r0),#28] // __vr_offs | 1324 | o(S, 0xb9001c00 | r1 | r0 << 5); // str w(r1),[x(r0),#28] // __vr_offs |
| 1325 | o(S, 0xf9400800 | r1 | r0 << 5); // ldr x(r1),[x(r0),#16] // __vr_top | 1325 | o(S, 0xf9400800 | r1 | r0 << 5); // ldr x(r1),[x(r0),#16] // __vr_top |
| 1326 | if (hfa == 1 || fsize == 16) | 1326 | if (hfa == 1 || fsize == 16) |
| @@ -1328,9 +1328,9 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t) · 1 unmodified line | |||
| 1328 | else { | 1328 | else { |
| 1329 | // We need to change the layout of this HFA. | 1329 | // We need to change the layout of this HFA. |
| 1330 | // Get some space on the stack using global variable "loc": | 1330 | // Get some space on the stack using global variable "loc": |
| 1331 | S->loc = (S->loc - size) & -(uint32_t)align; | 1331 | S->tccgen_loc = (S->tccgen_loc - size) & -(uint32_t)align; |
| 1332 | o(S, 0x8b3ec000 | 30 | r1 << 5); // add x30,x(r1),w30,sxtw | 1332 | o(S, 0x8b3ec000 | 30 | r1 << 5); // add x30,x(r1),w30,sxtw |
| 1333 | arm64_movimm(S, r1, S->loc); | 1333 | arm64_movimm(S, r1, S->tccgen_loc); |
| 1334 | o(S, 0x8b0003a0 | r1 | r1 << 16); // add x(r1),x29,x(r1) | 1334 | o(S, 0x8b0003a0 | r1 | r1 << 16); // add x(r1),x29,x(r1) |
| 1335 | o(S, 0x4c402bdc | (uint32_t)fsize << 7 | | 1335 | o(S, 0x4c402bdc | (uint32_t)fsize << 7 | |
| 1336 | (uint32_t)(hfa == 2) << 15 | | 1336 | (uint32_t)(hfa == 2) << 15 | |
| @@ -1340,7 +1340,7 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t) · 3 unmodified lines | |||
| 1340 | (uint32_t)(hfa != 3) << 21); // st(hfa) {v28.(s|d),...}[0],[x(r1)] | 1340 | (uint32_t)(hfa != 3) << 21); // st(hfa) {v28.(s|d),...}[0],[x(r1)] |
| 1341 | } | 1341 | } |
| 1342 | // lab2: | 1342 | // lab2: |
| 1343 | write32le(cur_text_section->data + b2, 0x14000000 | (S->ind - b2) >> 2); | 1343 | write32le(cur_text_section->data + b2, 0x14000000 | (S->tccgen_ind - b2) >> 2); |
| 1344 | } | 1344 | } |
| 1345 | } | 1345 | } |
| 1346 | 1346 | ||
| @@ -1380,7 +1380,7 @@ ST_FUNC void gfunc_return(TCCState *S, CType *func_type) · 33 unmodified lines | |||
| 1380 | } | 1380 | } |
| 1381 | case 16: | 1381 | case 16: |
| 1382 | if ((func_type->t & VT_BTYPE) == VT_STRUCT) { | 1382 | if ((func_type->t & VT_BTYPE) == VT_STRUCT) { |
| 1383 | uint32_t j, sz, n = arm64_hfa(&S->vtop->type, &sz); | 1383 | uint32_t j, sz, n = arm64_hfa(&S->tccgen_vtop->type, &sz); |
| 1384 | gaddrof(S); | 1384 | gaddrof(S); |
| 1385 | gv(S, RC_R(0)); | 1385 | gv(S, RC_R(0)); |
| 1386 | for (j = 0; j < n; j++) | 1386 | for (j = 0; j < n; j++) |
| @@ -1394,7 +1394,7 @@ ST_FUNC void gfunc_return(TCCState *S, CType *func_type) · 7 unmodified lines | |||
| 1394 | default: | 1394 | default: |
| 1395 | assert(0); | 1395 | assert(0); |
| 1396 | } | 1396 | } |
| 1397 | S->vtop--; | 1397 | S->tccgen_vtop--; |
| 1398 | } | 1398 | } |
| 1399 | 1399 | ||
| 1400 | ST_FUNC void gfunc_epilog(TCCState *S) | 1400 | ST_FUNC void gfunc_epilog(TCCState *S) |
| @@ -1404,10 +1404,10 @@ ST_FUNC void gfunc_epilog(TCCState *S) · 3 unmodified lines | |||
| 1404 | gen_bounds_epilog(S); | 1404 | gen_bounds_epilog(S); |
| 1405 | #endif | 1405 | #endif |
| 1406 | 1406 | ||
| 1407 | if (S->loc) { | 1407 | if (S->tccgen_loc) { |
| 1408 | // Insert instructions to subtract size of stack frame from SP. | 1408 | // Insert instructions to subtract size of stack frame from SP. |
| 1409 | unsigned char *ptr = cur_text_section->data + arm64_func_sub_sp_offset; | 1409 | unsigned char *ptr = cur_text_section->data + arm64_func_sub_sp_offset; |
| 1410 | uint64_t diff = (-S->loc + 15) & ~15; | 1410 | uint64_t diff = (-S->tccgen_loc + 15) & ~15; |
| 1411 | if (!(diff >> 24)) { | 1411 | if (!(diff >> 24)) { |
| 1412 | if (diff & 0xfff) // sub sp,sp,#(diff & 0xfff) | 1412 | if (diff & 0xfff) // sub sp,sp,#(diff & 0xfff) |
| 1413 | write32le(ptr, 0xd10003ff | (diff & 0xfff) << 10); | 1413 | write32le(ptr, 0xd10003ff | (diff & 0xfff) << 10); |
| @@ -1452,8 +1452,8 @@ ST_FUNC void gen_fill_nops(TCCState *S, int bytes) · 38 unmodified lines | |||
| 1452 | // Generate forward branch to label: | 1452 | // Generate forward branch to label: |
| 1453 | ST_FUNC int gjmp(TCCState *S, int t) | 1453 | ST_FUNC int gjmp(TCCState *S, int t) |
| 1454 | { | 1454 | { |
| 1455 | int r = S->ind; | 1455 | int r = S->tccgen_ind; |
| 1456 | if (S->nocode_wanted) | 1456 | if (S->tccgen_nocode_wanted) |
| 1457 | return t; | 1457 | return t; |
| 1458 | o(S, t); | 1458 | o(S, t); |
| 1459 | return r; | 1459 | return r; |
| @@ -1462,8 +1462,8 @@ ST_FUNC int gjmp(TCCState *S, int t) · 2 unmodified lines | |||
| 1462 | // Generate branch to known address: | 1462 | // Generate branch to known address: |
| 1463 | ST_FUNC void gjmp_addr(TCCState *S, int a) | 1463 | ST_FUNC void gjmp_addr(TCCState *S, int a) |
| 1464 | { | 1464 | { |
| 1465 | assert(a - S->ind + 0x8000000 < 0x10000000); | 1465 | assert(a - S->tccgen_ind + 0x8000000 < 0x10000000); |
| 1466 | o(S, 0x14000000 | ((a - S->ind) >> 2 & 0x3ffffff)); | 1466 | o(S, 0x14000000 | ((a - S->tccgen_ind) >> 2 & 0x3ffffff)); |
| 1467 | } | 1467 | } |
| 1468 | 1468 | ||
| 1469 | ST_FUNC int gjmp_append(TCCState *S, int n, int t) | 1469 | ST_FUNC int gjmp_append(TCCState *S, int n, int t) |
| @@ -1483,7 +1483,7 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t) · 13 unmodified lines | |||
| 1483 | void arm64_vset_VT_CMP(TCCState *S, int op) | 1483 | void arm64_vset_VT_CMP(TCCState *S, int op) |
| 1484 | { | 1484 | { |
| 1485 | if (op >= TOK_ULT && op <= TOK_GT) { | 1485 | if (op >= TOK_ULT && op <= TOK_GT) { |
| 1486 | S->vtop->cmp_r = S->vtop->r; | 1486 | S->tccgen_vtop->cmp_r = S->tccgen_vtop->r; |
| 1487 | vset_VT_CMP(S, 0x80); | 1487 | vset_VT_CMP(S, 0x80); |
| 1488 | } | 1488 | } |
| 1489 | } | 1489 | } |
| @@ -1505,16 +1505,16 @@ static void arm64_load_cmp(TCCState *S, int r, SValue *sv) · 15 unmodified lines | |||
| 1505 | 1505 | ||
| 1506 | ST_FUNC int gjmp_cond(TCCState *S, int op, int t) | 1506 | ST_FUNC int gjmp_cond(TCCState *S, int op, int t) |
| 1507 | { | 1507 | { |
| 1508 | int bt = S->vtop->type.t & VT_BTYPE; | 1508 | int bt = S->tccgen_vtop->type.t & VT_BTYPE; |
| 1509 | 1509 | ||
| 1510 | int inv = op & 1; | 1510 | int inv = op & 1; |
| 1511 | S->vtop->r = S->vtop->cmp_r; | 1511 | S->tccgen_vtop->r = S->tccgen_vtop->cmp_r; |
| 1512 | 1512 | ||
| 1513 | if (bt == VT_LDOUBLE) { | 1513 | if (bt == VT_LDOUBLE) { |
| 1514 | uint32_t a, b, f = fltr(gv(S, RC_FLOAT)); | 1514 | uint32_t a, b, f = fltr(gv(S, RC_FLOAT)); |
| 1515 | a = get_reg(S, RC_INT); | 1515 | a = get_reg(S, RC_INT); |
| 1516 | vpushi(S, 0); | 1516 | vpushi(S, 0); |
| 1517 | S->vtop[0].r = a; | 1517 | S->tccgen_vtop[0].r = a; |
| 1518 | b = get_reg(S, RC_INT); | 1518 | b = get_reg(S, RC_INT); |
| 1519 | a = intr(S, a); | 1519 | a = intr(S, a); |
| 1520 | b = intr(S, b); | 1520 | b = intr(S, b); |
| @@ -1522,7 +1522,7 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t) · 1 unmodified line | |||
| 1522 | o(S, 0x4e183c00 | b | f << 5); // mov x(b),v(f).d[1] | 1522 | o(S, 0x4e183c00 | b | f << 5); // mov x(b),v(f).d[1] |
| 1523 | o(S, 0xaa000400 | a | a << 5 | b << 16); // orr x(a),x(a),x(b),lsl #1 | 1523 | o(S, 0xaa000400 | a | a << 5 | b << 16); // orr x(a),x(a),x(b),lsl #1 |
| 1524 | o(S, 0xb4000040 | a | !!inv << 24); // cbz/cbnz x(a),.+8 | 1524 | o(S, 0xb4000040 | a | !!inv << 24); // cbz/cbnz x(a),.+8 |
| 1525 | --S->vtop; | 1525 | --S->tccgen_vtop; |
| 1526 | } | 1526 | } |
| 1527 | else if (bt == VT_FLOAT || bt == VT_DOUBLE) { | 1527 | else if (bt == VT_FLOAT || bt == VT_DOUBLE) { |
| 1528 | uint32_t a = fltr(gv(S, RC_FLOAT)); | 1528 | uint32_t a = fltr(gv(S, RC_FLOAT)); |
| @@ -1639,20 +1639,20 @@ static void arm64_gen_opil(TCCState *S, int op, uint32_t l) · 110 unmodified lines | |||
| 1639 | uint64_t val; | 1639 | uint64_t val; |
| 1640 | int rev = 1; | 1640 | int rev = 1; |
| 1641 | 1641 | ||
| 1642 | if (arm64_iconst(0, &S->vtop[0])) { | 1642 | if (arm64_iconst(0, &S->tccgen_vtop[0])) { |
| 1643 | vswap(S); | 1643 | vswap(S); |
| 1644 | rev = 0; | 1644 | rev = 0; |
| 1645 | } | 1645 | } |
| 1646 | if (arm64_iconst(&val, &S->vtop[-1])) { | 1646 | if (arm64_iconst(&val, &S->tccgen_vtop[-1])) { |
| 1647 | gv(S, RC_INT); | 1647 | gv(S, RC_INT); |
| 1648 | a = intr(S, S->vtop[0].r); | 1648 | a = intr(S, S->tccgen_vtop[0].r); |
| 1649 | --S->vtop; | 1649 | --S->tccgen_vtop; |
| 1650 | x = get_reg(S, RC_INT); | 1650 | x = get_reg(S, RC_INT); |
| 1651 | ++S->vtop; | 1651 | ++S->tccgen_vtop; |
| 1652 | if (arm64_gen_opic(S, op, l, rev, val, intr(S, x), a)) { | 1652 | if (arm64_gen_opic(S, op, l, rev, val, intr(S, x), a)) { |
| 1653 | S->vtop[0].r = x; | 1653 | S->tccgen_vtop[0].r = x; |
| 1654 | vswap(S); | 1654 | vswap(S); |
| 1655 | --S->vtop; | 1655 | --S->tccgen_vtop; |
| 1656 | return; | 1656 | return; |
| 1657 | } | 1657 | } |
| 1658 | } | 1658 | } |
| @@ -1661,13 +1661,13 @@ static void arm64_gen_opil(TCCState *S, int op, uint32_t l) · 2 unmodified lines | |||
| 1661 | } | 1661 | } |
| 1662 | 1662 | ||
| 1663 | gv2(S, RC_INT, RC_INT); | 1663 | gv2(S, RC_INT, RC_INT); |
| 1664 | assert(S->vtop[-1].r < VT_CONST && S->vtop[0].r < VT_CONST); | 1664 | assert(S->tccgen_vtop[-1].r < VT_CONST && S->tccgen_vtop[0].r < VT_CONST); |
| 1665 | a = intr(S, S->vtop[-1].r); | 1665 | a = intr(S, S->tccgen_vtop[-1].r); |
| 1666 | b = intr(S, S->vtop[0].r); | 1666 | b = intr(S, S->tccgen_vtop[0].r); |
| 1667 | S->vtop -= 2; | 1667 | S->tccgen_vtop -= 2; |
| 1668 | x = get_reg(S, RC_INT); | 1668 | x = get_reg(S, RC_INT); |
| 1669 | ++S->vtop; | 1669 | ++S->tccgen_vtop; |
| 1670 | S->vtop[0].r = x; | 1670 | S->tccgen_vtop[0].r = x; |
| 1671 | x = intr(S, x); | 1671 | x = intr(S, x); |
| 1672 | 1672 | ||
| 1673 | switch (op) { | 1673 | switch (op) { |
| @@ -1768,7 +1768,7 @@ ST_FUNC void gen_opi(TCCState *S, int op) · 94 unmodified lines | |||
| 1768 | arm64_vset_VT_CMP(S, op); | 1768 | arm64_vset_VT_CMP(S, op); |
| 1769 | } | 1769 | } |
| 1770 | 1770 | ||
| 1771 | ST_FUNC void gen_opl(TCCState *S, int op) | 1771 | ST_FUNC void gen_opl(TCCState* S, int op) |
| 1772 | { | 1772 | { |
| 1773 | arm64_gen_opil(S, op, 1); | 1773 | arm64_gen_opil(S, op, 1); |
| 1774 | arm64_vset_VT_CMP(S, op); | 1774 | arm64_vset_VT_CMP(S, op); |
| @@ -1778,8 +1778,8 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 3 unmodified lines | |||
| 1778 | { | 1778 | { |
| 1779 | uint32_t x, a, b, dbl; | 1779 | uint32_t x, a, b, dbl; |
| 1780 | 1780 | ||
| 1781 | if (S->vtop[0].type.t == VT_LDOUBLE) { | 1781 | if (S->tccgen_vtop[0].type.t == VT_LDOUBLE) { |
| 1782 | CType type = S->vtop[0].type; | 1782 | CType type = S->tccgen_vtop[0].type; |
| 1783 | int func = 0; | 1783 | int func = 0; |
| 1784 | int cond = -1; | 1784 | int cond = -1; |
| 1785 | switch (op) { | 1785 | switch (op) { |
| @@ -1799,9 +1799,9 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 13 unmodified lines | |||
| 1799 | vrott(S, 3); | 1799 | vrott(S, 3); |
| 1800 | gfunc_call(S, 2); | 1800 | gfunc_call(S, 2); |
| 1801 | vpushi(S, 0); | 1801 | vpushi(S, 0); |
| 1802 | S->vtop->r = cond < 0 ? REG_FRET : REG_IRET; | 1802 | S->tccgen_vtop->r = cond < 0 ? REG_FRET : REG_IRET; |
| 1803 | if (cond < 0) | 1803 | if (cond < 0) |
| 1804 | S->vtop->type = type; | 1804 | S->tccgen_vtop->type = type; |
| 1805 | else { | 1805 | else { |
| 1806 | o(S, 0x7100001f); // cmp w0,#0 | 1806 | o(S, 0x7100001f); // cmp w0,#0 |
| 1807 | o(S, 0x1a9f07e0 | (uint32_t)cond << 12); // cset w0,(cond) | 1807 | o(S, 0x1a9f07e0 | (uint32_t)cond << 12); // cset w0,(cond) |
| @@ -1809,24 +1809,24 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 1 unmodified line | |||
| 1809 | return; | 1809 | return; |
| 1810 | } | 1810 | } |
| 1811 | 1811 | ||
| 1812 | dbl = S->vtop[0].type.t != VT_FLOAT; | 1812 | dbl = S->tccgen_vtop[0].type.t != VT_FLOAT; |
| 1813 | gv2(S, RC_FLOAT, RC_FLOAT); | 1813 | gv2(S, RC_FLOAT, RC_FLOAT); |
| 1814 | assert(S->vtop[-1].r < VT_CONST && S->vtop[0].r < VT_CONST); | 1814 | assert(S->tccgen_vtop[-1].r < VT_CONST && S->tccgen_vtop[0].r < VT_CONST); |
| 1815 | a = fltr(S->vtop[-1].r); | 1815 | a = fltr(S->tccgen_vtop[-1].r); |
| 1816 | b = fltr(S->vtop[0].r); | 1816 | b = fltr(S->tccgen_vtop[0].r); |
| 1817 | S->vtop -= 2; | 1817 | S->tccgen_vtop -= 2; |
| 1818 | switch (op) { | 1818 | switch (op) { |
| 1819 | case TOK_EQ: case TOK_NE: | 1819 | case TOK_EQ: case TOK_NE: |
| 1820 | case TOK_LT: case TOK_GE: case TOK_LE: case TOK_GT: | 1820 | case TOK_LT: case TOK_GE: case TOK_LE: case TOK_GT: |
| 1821 | x = get_reg(S, RC_INT); | 1821 | x = get_reg(S, RC_INT); |
| 1822 | ++S->vtop; | 1822 | ++S->tccgen_vtop; |
| 1823 | S->vtop[0].r = x; | 1823 | S->tccgen_vtop[0].r = x; |
| 1824 | x = intr(S, x); | 1824 | x = intr(S, x); |
| 1825 | break; | 1825 | break; |
| 1826 | default: | 1826 | default: |
| 1827 | x = get_reg(S, RC_FLOAT); | 1827 | x = get_reg(S, RC_FLOAT); |
| 1828 | ++S->vtop; | 1828 | ++S->tccgen_vtop; |
| 1829 | S->vtop[0].r = x; | 1829 | S->tccgen_vtop[0].r = x; |
| 1830 | x = fltr(x); | 1830 | x = fltr(x); |
| 1831 | break; | 1831 | break; |
| 1832 | } | 1832 | } |
| @@ -1894,7 +1894,7 @@ ST_FUNC void gen_cvt_csti(TCCState *S, int t) · 61 unmodified lines | |||
| 1894 | ST_FUNC void gen_cvt_itof(TCCState *S, int t) | 1894 | ST_FUNC void gen_cvt_itof(TCCState *S, int t) |
| 1895 | { | 1895 | { |
| 1896 | if (t == VT_LDOUBLE) { | 1896 | if (t == VT_LDOUBLE) { |
| 1897 | int f = S->vtop->type.t; | 1897 | int f = S->tccgen_vtop->type.t; |
| 1898 | int func = (f & VT_BTYPE) == VT_LLONG ? | 1898 | int func = (f & VT_BTYPE) == VT_LLONG ? |
| 1899 | (f & VT_UNSIGNED ? TOK___floatunditf : TOK___floatditf) : | 1899 | (f & VT_UNSIGNED ? TOK___floatunditf : TOK___floatditf) : |
| 1900 | (f & VT_UNSIGNED ? TOK___floatunsitf : TOK___floatsitf); | 1900 | (f & VT_UNSIGNED ? TOK___floatunsitf : TOK___floatsitf); |
| @@ -1902,18 +1902,18 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t) · 1 unmodified line | |||
| 1902 | vrott(S, 2); | 1902 | vrott(S, 2); |
| 1903 | gfunc_call(S, 1); | 1903 | gfunc_call(S, 1); |
| 1904 | vpushi(S, 0); | 1904 | vpushi(S, 0); |
| 1905 | S->vtop->type.t = t; | 1905 | S->tccgen_vtop->type.t = t; |
| 1906 | S->vtop->r = REG_FRET; | 1906 | S->tccgen_vtop->r = REG_FRET; |
| 1907 | return; | 1907 | return; |
| 1908 | } | 1908 | } |
| 1909 | else { | 1909 | else { |
| 1910 | int d, n = intr(S, gv(S, RC_INT)); | 1910 | int d, n = intr(S, gv(S, RC_INT)); |
| 1911 | int s = !(S->vtop->type.t & VT_UNSIGNED); | 1911 | int s = !(S->tccgen_vtop->type.t & VT_UNSIGNED); |
| 1912 | uint32_t l = ((S->vtop->type.t & VT_BTYPE) == VT_LLONG); | 1912 | uint32_t l = ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG); |
| 1913 | --S->vtop; | 1913 | --S->tccgen_vtop; |
| 1914 | d = get_reg(S, RC_FLOAT); | 1914 | d = get_reg(S, RC_FLOAT); |
| 1915 | ++S->vtop; | 1915 | ++S->tccgen_vtop; |
| 1916 | S->vtop[0].r = d; | 1916 | S->tccgen_vtop[0].r = d; |
| 1917 | o(S, 0x1e220000 | (uint32_t)!s << 16 | | 1917 | o(S, 0x1e220000 | (uint32_t)!s << 16 | |
| 1918 | (uint32_t)(t != VT_FLOAT) << 22 | fltr(d) | | 1918 | (uint32_t)(t != VT_FLOAT) << 22 | fltr(d) | |
| 1919 | l << 31 | n << 5); // [us]cvtf [sd](d),[wx](n) | 1919 | l << 31 | n << 5); // [us]cvtf [sd](d),[wx](n) |
| @@ -1922,7 +1922,7 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t) · 2 unmodified lines | |||
| 1922 | 1922 | ||
| 1923 | ST_FUNC void gen_cvt_ftoi(TCCState *S, int t) | 1923 | ST_FUNC void gen_cvt_ftoi(TCCState *S, int t) |
| 1924 | { | 1924 | { |
| 1925 | if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { | 1925 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { |
| 1926 | int func = (t & VT_BTYPE) == VT_LLONG ? | 1926 | int func = (t & VT_BTYPE) == VT_LLONG ? |
| 1927 | (t & VT_UNSIGNED ? TOK___fixunstfdi : TOK___fixtfdi) : | 1927 | (t & VT_UNSIGNED ? TOK___fixunstfdi : TOK___fixtfdi) : |
| 1928 | (t & VT_UNSIGNED ? TOK___fixunstfsi : TOK___fixtfsi); | 1928 | (t & VT_UNSIGNED ? TOK___fixunstfsi : TOK___fixtfsi); |
| @@ -1930,17 +1930,17 @@ ST_FUNC void gen_cvt_ftoi(TCCState *S, int t) · 1 unmodified line | |||
| 1930 | vrott(S, 2); | 1930 | vrott(S, 2); |
| 1931 | gfunc_call(S, 1); | 1931 | gfunc_call(S, 1); |
| 1932 | vpushi(S, 0); | 1932 | vpushi(S, 0); |
| 1933 | S->vtop->type.t = t; | 1933 | S->tccgen_vtop->type.t = t; |
| 1934 | S->vtop->r = REG_IRET; | 1934 | S->tccgen_vtop->r = REG_IRET; |
| 1935 | return; | 1935 | return; |
| 1936 | } | 1936 | } |
| 1937 | else { | 1937 | else { |
| 1938 | int d, n = fltr(gv(S, RC_FLOAT)); | 1938 | int d, n = fltr(gv(S, RC_FLOAT)); |
| 1939 | uint32_t l = ((S->vtop->type.t & VT_BTYPE) != VT_FLOAT); | 1939 | uint32_t l = ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FLOAT); |
| 1940 | --S->vtop; | 1940 | --S->tccgen_vtop; |
| 1941 | d = get_reg(S, RC_INT); | 1941 | d = get_reg(S, RC_INT); |
| 1942 | ++S->vtop; | 1942 | ++S->tccgen_vtop; |
| 1943 | S->vtop[0].r = d; | 1943 | S->tccgen_vtop[0].r = d; |
| 1944 | o(S, 0x1e380000 | | 1944 | o(S, 0x1e380000 | |
| 1945 | (uint32_t)!!(t & VT_UNSIGNED) << 16 | | 1945 | (uint32_t)!!(t & VT_UNSIGNED) << 16 | |
| 1946 | (uint32_t)((t & VT_BTYPE) == VT_LLONG) << 31 | intr(S, d) | | 1946 | (uint32_t)((t & VT_BTYPE) == VT_LLONG) << 31 | intr(S, d) | |
| @@ -1950,7 +1950,7 @@ ST_FUNC void gen_cvt_ftoi(TCCState *S, int t) · 3 unmodified lines | |||
| 1950 | 1950 | ||
| 1951 | ST_FUNC void gen_cvt_ftof(TCCState *S, int t) | 1951 | ST_FUNC void gen_cvt_ftof(TCCState *S, int t) |
| 1952 | { | 1952 | { |
| 1953 | int f = S->vtop[0].type.t & VT_BTYPE; | 1953 | int f = S->tccgen_vtop[0].type.t & VT_BTYPE; |
| 1954 | assert(t == VT_FLOAT || t == VT_DOUBLE || t == VT_LDOUBLE); | 1954 | assert(t == VT_FLOAT || t == VT_DOUBLE || t == VT_LDOUBLE); |
| 1955 | assert(f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE); | 1955 | assert(f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE); |
| 1956 | if (t == f) | 1956 | if (t == f) |
| @@ -1964,18 +1964,18 @@ ST_FUNC void gen_cvt_ftof(TCCState *S, int t) · 7 unmodified lines | |||
| 1964 | vrott(S, 2); | 1964 | vrott(S, 2); |
| 1965 | gfunc_call(S, 1); | 1965 | gfunc_call(S, 1); |
| 1966 | vpushi(S, 0); | 1966 | vpushi(S, 0); |
| 1967 | S->vtop->type.t = t; | 1967 | S->tccgen_vtop->type.t = t; |
| 1968 | S->vtop->r = REG_FRET; | 1968 | S->tccgen_vtop->r = REG_FRET; |
| 1969 | } | 1969 | } |
| 1970 | else { | 1970 | else { |
| 1971 | int x, a; | 1971 | int x, a; |
| 1972 | gv(S, RC_FLOAT); | 1972 | gv(S, RC_FLOAT); |
| 1973 | assert(S->vtop[0].r < VT_CONST); | 1973 | assert(S->tccgen_vtop[0].r < VT_CONST); |
| 1974 | a = fltr(S->vtop[0].r); | 1974 | a = fltr(S->tccgen_vtop[0].r); |
| 1975 | --S->vtop; | 1975 | --S->tccgen_vtop; |
| 1976 | x = get_reg(S, RC_FLOAT); | 1976 | x = get_reg(S, RC_FLOAT); |
| 1977 | ++S->vtop; | 1977 | ++S->tccgen_vtop; |
| 1978 | S->vtop[0].r = x; | 1978 | S->tccgen_vtop[0].r = x; |
| 1979 | x = fltr(x); | 1979 | x = fltr(x); |
| 1980 | 1980 | ||
| 1981 | if (f == VT_FLOAT) | 1981 | if (f == VT_FLOAT) |
| @@ -1986,16 +1986,16 @@ ST_FUNC void gen_cvt_ftof(TCCState *S, int t) · 4 unmodified lines | |||
| 1986 | } | 1986 | } |
| 1987 | 1987 | ||
| 1988 | /* increment tcov counter */ | 1988 | /* increment tcov counter */ |
| 1989 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv) | 1989 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv) |
| 1990 | { | 1990 | { |
| 1991 | int r1, r2; | 1991 | int r1, r2; |
| 1992 | 1992 | ||
| 1993 | vpushv(S, sv); | 1993 | vpushv(S, sv); |
| 1994 | S->vtop->r = r1 = get_reg(S, RC_INT); | 1994 | S->tccgen_vtop->r = r1 = get_reg(S, RC_INT); |
| 1995 | r2 = get_reg(S, RC_INT); | 1995 | r2 = get_reg(S, RC_INT); |
| 1996 | greloca(S, cur_text_section, sv->sym, S->ind, R_AARCH64_ADR_GOT_PAGE, 0); | 1996 | greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_AARCH64_ADR_GOT_PAGE, 0); |
| 1997 | o(S, 0x90000000 | r1); // adrp r1, #sym | 1997 | o(S, 0x90000000 | r1); // adrp r1, #sym |
| 1998 | greloca(S, cur_text_section, sv->sym, S->ind, R_AARCH64_LD64_GOT_LO12_NC, 0); | 1998 | greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_AARCH64_LD64_GOT_LO12_NC, 0); |
| 1999 | o(S, 0xf9400000 | r1 | (r1 << 5)); // ld xr,[xr, #sym] | 1999 | o(S, 0xf9400000 | r1 | (r1 << 5)); // ld xr,[xr, #sym] |
| 2000 | o(S, 0xf9400000 | (intr(S, r1)<<5) | intr(S, r2)); // ldr r2, [r1] | 2000 | o(S, 0xf9400000 | (intr(S, r1)<<5) | intr(S, r2)); // ldr r2, [r1] |
| 2001 | o(S, 0x91000400 | (intr(S, r2)<<5) | intr(S, r2)); // add r2, r2, #1 | 2001 | o(S, 0x91000400 | (intr(S, r2)<<5) | intr(S, r2)); // add r2, r2, #1 |
| @@ -2006,7 +2006,7 @@ ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv) · 4 unmodified lines | |||
| 2006 | ST_FUNC void ggoto(TCCState *S) | 2006 | ST_FUNC void ggoto(TCCState *S) |
| 2007 | { | 2007 | { |
| 2008 | arm64_gen_bl_or_b(S, 1); | 2008 | arm64_gen_bl_or_b(S, 1); |
| 2009 | --S->vtop; | 2009 | --S->tccgen_vtop; |
| 2010 | } | 2010 | } |
| 2011 | 2011 | ||
| 2012 | ST_FUNC void gen_clear_cache(TCCState *S) | 2012 | ST_FUNC void gen_clear_cache(TCCState *S) |
| @@ -2014,17 +2014,17 @@ ST_FUNC void gen_clear_cache(TCCState *S) · 1 unmodified line | |||
| 2014 | uint32_t beg, end, dsz, isz, p, lab1, b1; | 2014 | uint32_t beg, end, dsz, isz, p, lab1, b1; |
| 2015 | gv2(S, RC_INT, RC_INT); | 2015 | gv2(S, RC_INT, RC_INT); |
| 2016 | vpushi(S, 0); | 2016 | vpushi(S, 0); |
| 2017 | S->vtop->r = get_reg(S, RC_INT); | 2017 | S->tccgen_vtop->r = get_reg(S, RC_INT); |
| 2018 | vpushi(S, 0); | 2018 | vpushi(S, 0); |
| 2019 | S->vtop->r = get_reg(S, RC_INT); | 2019 | S->tccgen_vtop->r = get_reg(S, RC_INT); |
| 2020 | vpushi(S, 0); | 2020 | vpushi(S, 0); |
| 2021 | S->vtop->r = get_reg(S, RC_INT); | 2021 | S->tccgen_vtop->r = get_reg(S, RC_INT); |
| 2022 | beg = intr(S, S->vtop[-4].r); // x0 | 2022 | beg = intr(S, S->tccgen_vtop[-4].r); // x0 |
| 2023 | end = intr(S, S->vtop[-3].r); // x1 | 2023 | end = intr(S, S->tccgen_vtop[-3].r); // x1 |
| 2024 | dsz = intr(S, S->vtop[-2].r); // x2 | 2024 | dsz = intr(S, S->tccgen_vtop[-2].r); // x2 |
| 2025 | isz = intr(S, S->vtop[-1].r); // x3 | 2025 | isz = intr(S, S->tccgen_vtop[-1].r); // x3 |
| 2026 | p = intr(S, S->vtop[0].r); // x4 | 2026 | p = intr(S, S->tccgen_vtop[0].r); // x4 |
| 2027 | S->vtop -= 5; | 2027 | S->tccgen_vtop -= 5; |
| 2028 | 2028 | ||
| 2029 | o(S, 0xd53b0020 | isz); // mrs x(isz),ctr_el0 | 2029 | o(S, 0xd53b0020 | isz); // mrs x(isz),ctr_el0 |
| 2030 | o(S, 0x52800080 | p); // mov w(p),#4 | 2030 | o(S, 0x52800080 | p); // mov w(p),#4 |
| @@ -2034,23 +2034,23 @@ ST_FUNC void gen_clear_cache(TCCState *S) · 3 unmodified lines | |||
| 2034 | o(S, 0x1ac02000 | isz | p << 5 | isz << 16); // lsl w(isz),w(p),w(isz) | 2034 | o(S, 0x1ac02000 | isz | p << 5 | isz << 16); // lsl w(isz),w(p),w(isz) |
| 2035 | o(S, 0x51000400 | p | dsz << 5); // sub w(p),w(dsz),#1 | 2035 | o(S, 0x51000400 | p | dsz << 5); // sub w(p),w(dsz),#1 |
| 2036 | o(S, 0x8a240004 | p | beg << 5 | p << 16); // bic x(p),x(beg),x(p) | 2036 | o(S, 0x8a240004 | p | beg << 5 | p << 16); // bic x(p),x(beg),x(p) |
| 2037 | b1 = S->ind; o(S, 0x14000000); // b | 2037 | b1 = S->tccgen_ind; o(S, 0x14000000); // b |
| 2038 | lab1 = S->ind; | 2038 | lab1 = S->tccgen_ind; |
| 2039 | o(S, 0xd50b7b20 | p); // dc cvau,x(p) | 2039 | o(S, 0xd50b7b20 | p); // dc cvau,x(p) |
| 2040 | o(S, 0x8b000000 | p | p << 5 | dsz << 16); // add x(p),x(p),x(dsz) | 2040 | o(S, 0x8b000000 | p | p << 5 | dsz << 16); // add x(p),x(p),x(dsz) |
| 2041 | write32le(cur_text_section->data + b1, 0x14000000 | (S->ind - b1) >> 2); | 2041 | write32le(cur_text_section->data + b1, 0x14000000 | (S->tccgen_ind - b1) >> 2); |
| 2042 | o(S, 0xeb00001f | p << 5 | end << 16); // cmp x(p),x(end) | 2042 | o(S, 0xeb00001f | p << 5 | end << 16); // cmp x(p),x(end) |
| 2043 | o(S, 0x54ffffa3 | ((lab1 - S->ind) << 3 & 0xffffe0)); // b.cc lab1 | 2043 | o(S, 0x54ffffa3 | ((lab1 - S->tccgen_ind) << 3 & 0xffffe0)); // b.cc lab1 |
| 2044 | o(S, 0xd5033b9f); // dsb ish | 2044 | o(S, 0xd5033b9f); // dsb ish |
| 2045 | o(S, 0x51000400 | p | isz << 5); // sub w(p),w(isz),#1 | 2045 | o(S, 0x51000400 | p | isz << 5); // sub w(p),w(isz),#1 |
| 2046 | o(S, 0x8a240004 | p | beg << 5 | p << 16); // bic x(p),x(beg),x(p) | 2046 | o(S, 0x8a240004 | p | beg << 5 | p << 16); // bic x(p),x(beg),x(p) |
| 2047 | b1 = S->ind; o(S, 0x14000000); // b | 2047 | b1 = S->tccgen_ind; o(S, 0x14000000); // b |
| 2048 | lab1 = S->ind; | 2048 | lab1 = S->tccgen_ind; |
| 2049 | o(S, 0xd50b7520 | p); // ic ivau,x(p) | 2049 | o(S, 0xd50b7520 | p); // ic ivau,x(p) |
| 2050 | o(S, 0x8b000000 | p | p << 5 | isz << 16); // add x(p),x(p),x(isz) | 2050 | o(S, 0x8b000000 | p | p << 5 | isz << 16); // add x(p),x(p),x(isz) |
| 2051 | write32le(cur_text_section->data + b1, 0x14000000 | (S->ind - b1) >> 2); | 2051 | write32le(cur_text_section->data + b1, 0x14000000 | (S->tccgen_ind - b1) >> 2); |
| 2052 | o(S, 0xeb00001f | p << 5 | end << 16); // cmp x(p),x(end) | 2052 | o(S, 0xeb00001f | p << 5 | end << 16); // cmp x(p),x(end) |
| 2053 | o(S, 0x54ffffa3 | ((lab1 - S->ind) << 3 & 0xffffe0)); // b.cc lab1 | 2053 | o(S, 0x54ffffa3 | ((lab1 - S->tccgen_ind) << 3 & 0xffffe0)); // b.cc lab1 |
| 2054 | o(S, 0xd5033b9f); // dsb ish | 2054 | o(S, 0xd5033b9f); // dsb ish |
| 2055 | o(S, 0xd5033fdf); // isb | 2055 | o(S, 0xd5033fdf); // isb |
| 2056 | } | 2056 | } |
| @@ -2074,7 +2074,7 @@ ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) { · 17 unmodified lines | |||
| 2074 | uint32_t r; | 2074 | uint32_t r; |
| 2075 | #if defined(CONFIG_TCC_BCHECK) | 2075 | #if defined(CONFIG_TCC_BCHECK) |
| 2076 | if (S->do_bounds_check) | 2076 | if (S->do_bounds_check) |
| 2077 | vpushv(S, S->vtop); | 2077 | vpushv(S, S->tccgen_vtop); |
| 2078 | #endif | 2078 | #endif |
| 2079 | r = intr(S, gv(S, RC_INT)); | 2079 | r = intr(S, gv(S, RC_INT)); |
| 2080 | #if defined(CONFIG_TCC_BCHECK) | 2080 | #if defined(CONFIG_TCC_BCHECK) |
| @@ -2089,8 +2089,8 @@ ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) { · 8 unmodified lines | |||
| 2089 | #if defined(CONFIG_TCC_BCHECK) | 2089 | #if defined(CONFIG_TCC_BCHECK) |
| 2090 | if (S->do_bounds_check) { | 2090 | if (S->do_bounds_check) { |
| 2091 | vpushi(S, 0); | 2091 | vpushi(S, 0); |
| 2092 | S->vtop->r = TREG_R(0); | 2092 | S->tccgen_vtop->r = TREG_R(0); |
| 2093 | o(S, 0x910003e0 | S->vtop->r); // mov r0,sp | 2093 | o(S, 0x910003e0 | S->tccgen_vtop->r); // mov r0,sp |
| 2094 | vswap(S); | 2094 | vswap(S); |
| 2095 | vpush_helper_func(S, TOK___bound_new_region); | 2095 | vpush_helper_func(S, TOK___bound_new_region); |
| 2096 | vrott(S, 3); | 2096 | vrott(S, 3); |
| @@ -186,27 +186,27 @@ static int C67_compare_reg; · 185 unmodified lines | |||
| 186 | FILE *f = NULL; | 186 | FILE *f = NULL; |
| 187 | #endif | 187 | #endif |
| 188 | 188 | ||
| 189 | void C67_g(TCCState *S, int c) | 189 | void C67_g(TCCState* S, int c) |
| 190 | { | 190 | { |
| 191 | int ind1; | 191 | int ind1; |
| 192 | if (S->nocode_wanted) | 192 | if (S->tccgen_nocode_wanted) |
| 193 | return; | 193 | return; |
| 194 | #ifdef ASSEMBLY_LISTING_C67 | 194 | #ifdef ASSEMBLY_LISTING_C67 |
| 195 | fprintf(f, " %08X", c); | 195 | fprintf(f, " %08X", c); |
| 196 | #endif | 196 | #endif |
| 197 | ind1 = S->ind + 4; | 197 | ind1 = S->tccgen_ind + 4; |
| 198 | if (ind1 > (int) cur_text_section->data_allocated) | 198 | if (ind1 > (int) cur_text_section->data_allocated) |
| 199 | section_realloc(S, cur_text_section, ind1); | 199 | section_realloc(S, cur_text_section, ind1); |
| 200 | cur_text_section->data[S->ind] = c & 0xff; | 200 | cur_text_section->data[S->tccgen_ind] = c & 0xff; |
| 201 | cur_text_section->data[S->ind + 1] = (c >> 8) & 0xff; | 201 | cur_text_section->data[S->tccgen_ind + 1] = (c >> 8) & 0xff; |
| 202 | cur_text_section->data[S->ind + 2] = (c >> 16) & 0xff; | 202 | cur_text_section->data[S->tccgen_ind + 2] = (c >> 16) & 0xff; |
| 203 | cur_text_section->data[S->ind + 3] = (c >> 24) & 0xff; | 203 | cur_text_section->data[S->tccgen_ind + 3] = (c >> 24) & 0xff; |
| 204 | S->ind = ind1; | 204 | S->tccgen_ind = ind1; |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | 207 | ||
| 208 | /* output a symbol and patch all calls to it */ | 208 | /* output a symbol and patch all calls to it */ |
| 209 | void gsym_addr(TCCState *S, int t, int a) | 209 | void gsym_addr(TCCState* S, int t, int a) |
| 210 | { | 210 | { |
| 211 | int n, *ptr; | 211 | int n, *ptr; |
| 212 | while (t) { | 212 | while (t) { |
| @@ -220,7 +220,7 @@ void gsym_addr(TCCState *S, int t, int a) · 7 unmodified lines | |||
| 220 | 220 | ||
| 221 | // define a label that will be relocated | 221 | // define a label that will be relocated |
| 222 | 222 | ||
| 223 | sym = get_sym_ref(S, &S->char_pointer_type, cur_text_section, a, 0); | 223 | sym = get_sym_ref(S, &S->tccgen_char_pointer_type, cur_text_section, a, 0); |
| 224 | greloc(S, cur_text_section, sym, t, R_C60LO16); | 224 | greloc(S, cur_text_section, sym, t, R_C60LO16); |
| 225 | greloc(S, cur_text_section, sym, t + 4, R_C60HI16); | 225 | greloc(S, cur_text_section, sym, t + 4, R_C60HI16); |
| 226 | 226 | ||
| @@ -255,7 +255,7 @@ int ConvertRegToRegClass(int r) · 28 unmodified lines | |||
| 255 | 255 | ||
| 256 | // map TCC reg to C67 reg number | 256 | // map TCC reg to C67 reg number |
| 257 | 257 | ||
| 258 | int C67_map_regn(TCCState *S, int r) | 258 | int C67_map_regn(TCCState* S, int r) |
| 259 | { | 259 | { |
| 260 | if (r == 0) // normal tcc regs | 260 | if (r == 0) // normal tcc regs |
| 261 | return 0x2; // A2 | 261 | return 0x2; // A2 |
| @@ -296,7 +296,7 @@ int C67_map_regn(TCCState *S, int r) · 34 unmodified lines | |||
| 296 | // tcc reg 1 -> A3 -> X | 296 | // tcc reg 1 -> A3 -> X |
| 297 | // tcc reg B2 -> 3 | 297 | // tcc reg B2 -> 3 |
| 298 | 298 | ||
| 299 | int C67_map_regc(TCCState *S, int r) | 299 | int C67_map_regc(TCCState* S, int r) |
| 300 | { | 300 | { |
| 301 | if (r == 0) // normal tcc regs | 301 | if (r == 0) // normal tcc regs |
| 302 | return 0x5; | 302 | return 0x5; |
| @@ -317,7 +317,7 @@ int C67_map_regc(TCCState *S, int r) · 14 unmodified lines | |||
| 317 | 317 | ||
| 318 | // map TCC reg to C67 reg side A or B | 318 | // map TCC reg to C67 reg side A or B |
| 319 | 319 | ||
| 320 | int C67_map_regs(TCCState *S, int r) | 320 | int C67_map_regs(TCCState* S, int r) |
| 321 | { | 321 | { |
| 322 | if (r == 0) // normal tcc regs | 322 | if (r == 0) // normal tcc regs |
| 323 | return 0x0; | 323 | return 0x0; |
| @@ -345,7 +345,7 @@ int C67_map_regs(TCCState *S, int r) · 21 unmodified lines | |||
| 345 | return 0; | 345 | return 0; |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | int C67_map_S12(TCCState *S, char *s) | 348 | int C67_map_S12(TCCState* S, char *s) |
| 349 | { | 349 | { |
| 350 | if (strstr(s, ".S1") != NULL) | 350 | if (strstr(s, ".S1") != NULL) |
| 351 | return 0; | 351 | return 0; |
| @@ -357,7 +357,7 @@ int C67_map_S12(TCCState *S, char *s) · 5 unmodified lines | |||
| 357 | return 0; | 357 | return 0; |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | int C67_map_D12(TCCState *S, char *s) | 360 | int C67_map_D12(TCCState* S, char *s) |
| 361 | { | 361 | { |
| 362 | if (strstr(s, ".D1") != NULL) | 362 | if (strstr(s, ".D1") != NULL) |
| 363 | return 0; | 363 | return 0; |
| @@ -371,7 +371,7 @@ int C67_map_D12(TCCState *S, char *s) · 7 unmodified lines | |||
| 371 | 371 | ||
| 372 | 372 | ||
| 373 | 373 | ||
| 374 | void C67_asm(TCCState *S, const char *s, int a, int b, int c) | 374 | void C67_asm(TCCState* S, const char *s, int a, int b, int c) |
| 375 | { | 375 | { |
| 376 | BOOL xpath; | 376 | BOOL xpath; |
| 377 | 377 | ||
| @@ -1195,189 +1195,189 @@ void C67_asm(TCCState *S, const char *s, int a, int b, int c) · 817 unmodified lines | |||
| 1195 | 1195 | ||
| 1196 | //r=reg to load, fr=from reg, symbol for relocation, constant | 1196 | //r=reg to load, fr=from reg, symbol for relocation, constant |
| 1197 | 1197 | ||
| 1198 | void C67_MVKL(TCCState *S, int r, int fc) | 1198 | void C67_MVKL(TCCState* S, int r, int fc) |
| 1199 | { | 1199 | { |
| 1200 | C67_asm(S, "MVKL.", fc, r, 0); | 1200 | C67_asm(S, "MVKL.", fc, r, 0); |
| 1201 | } | 1201 | } |
| 1202 | 1202 | ||
| 1203 | void C67_MVKH(TCCState *S, int r, int fc) | 1203 | void C67_MVKH(TCCState* S, int r, int fc) |
| 1204 | { | 1204 | { |
| 1205 | C67_asm(S, "MVKH.", fc, r, 0); | 1205 | C67_asm(S, "MVKH.", fc, r, 0); |
| 1206 | } | 1206 | } |
| 1207 | 1207 | ||
| 1208 | void C67_STB_SP_A0(TCCState *S, int r) | 1208 | void C67_STB_SP_A0(TCCState* S, int r) |
| 1209 | { | 1209 | { |
| 1210 | C67_asm(S, "STB.D *+SP[A0]", r, 0, 0); // STB r,*+SP[A0] | 1210 | C67_asm(S, "STB.D *+SP[A0]", r, 0, 0); // STB r,*+SP[A0] |
| 1211 | } | 1211 | } |
| 1212 | 1212 | ||
| 1213 | void C67_STH_SP_A0(TCCState *S, int r) | 1213 | void C67_STH_SP_A0(TCCState* S, int r) |
| 1214 | { | 1214 | { |
| 1215 | C67_asm(S, "STH.D *+SP[A0]", r, 0, 0); // STH r,*+SP[A0] | 1215 | C67_asm(S, "STH.D *+SP[A0]", r, 0, 0); // STH r,*+SP[A0] |
| 1216 | } | 1216 | } |
| 1217 | 1217 | ||
| 1218 | void C67_STW_SP_A0(TCCState *S, int r) | 1218 | void C67_STW_SP_A0(TCCState* S, int r) |
| 1219 | { | 1219 | { |
| 1220 | C67_asm(S, "STW.D *+SP[A0]", r, 0, 0); // STW r,*+SP[A0] | 1220 | C67_asm(S, "STW.D *+SP[A0]", r, 0, 0); // STW r,*+SP[A0] |
| 1221 | } | 1221 | } |
| 1222 | 1222 | ||
| 1223 | void C67_STB_PTR(TCCState *S, int r, int r2) | 1223 | void C67_STB_PTR(TCCState* S, int r, int r2) |
| 1224 | { | 1224 | { |
| 1225 | C67_asm(S, "STB.D *", r, r2, 0); // STB r, *r2 | 1225 | C67_asm(S, "STB.D *", r, r2, 0); // STB r, *r2 |
| 1226 | } | 1226 | } |
| 1227 | 1227 | ||
| 1228 | void C67_STH_PTR(TCCState *S, int r, int r2) | 1228 | void C67_STH_PTR(TCCState* S, int r, int r2) |
| 1229 | { | 1229 | { |
| 1230 | C67_asm(S, "STH.D *", r, r2, 0); // STH r, *r2 | 1230 | C67_asm(S, "STH.D *", r, r2, 0); // STH r, *r2 |
| 1231 | } | 1231 | } |
| 1232 | 1232 | ||
| 1233 | void C67_STW_PTR(TCCState *S, int r, int r2) | 1233 | void C67_STW_PTR(TCCState* S, int r, int r2) |
| 1234 | { | 1234 | { |
| 1235 | C67_asm(S, "STW.D *", r, r2, 0); // STW r, *r2 | 1235 | C67_asm(S, "STW.D *", r, r2, 0); // STW r, *r2 |
| 1236 | } | 1236 | } |
| 1237 | 1237 | ||
| 1238 | void C67_STW_PTR_PRE_INC(TCCState *S, int r, int r2, int n) | 1238 | void C67_STW_PTR_PRE_INC(TCCState* S, int r, int r2, int n) |
| 1239 | { | 1239 | { |
| 1240 | C67_asm(S, "STW.D +*", r, r2, n); // STW r, *+r2 | 1240 | C67_asm(S, "STW.D +*", r, r2, n); // STW r, *+r2 |
| 1241 | } | 1241 | } |
| 1242 | 1242 | ||
| 1243 | void C67_PUSH(TCCState *S, int r) | 1243 | void C67_PUSH(TCCState* S, int r) |
| 1244 | { | 1244 | { |
| 1245 | C67_asm(S, "STW.D SP POST DEC", r, 0, 0); // STW r,*SP-- | 1245 | C67_asm(S, "STW.D SP POST DEC", r, 0, 0); // STW r,*SP-- |
| 1246 | } | 1246 | } |
| 1247 | 1247 | ||
| 1248 | void C67_LDW_SP_A0(TCCState *S, int r) | 1248 | void C67_LDW_SP_A0(TCCState* S, int r) |
| 1249 | { | 1249 | { |
| 1250 | C67_asm(S, "LDW.D *+SP[A0]", r, 0, 0); // LDW *+SP[A0],r | 1250 | C67_asm(S, "LDW.D *+SP[A0]", r, 0, 0); // LDW *+SP[A0],r |
| 1251 | } | 1251 | } |
| 1252 | 1252 | ||
| 1253 | void C67_LDDW_SP_A0(TCCState *S, int r) | 1253 | void C67_LDDW_SP_A0(TCCState* S, int r) |
| 1254 | { | 1254 | { |
| 1255 | C67_asm(S, "LDDW.D *+SP[A0]", r, 0, 0); // LDDW *+SP[A0],r | 1255 | C67_asm(S, "LDDW.D *+SP[A0]", r, 0, 0); // LDDW *+SP[A0],r |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | void C67_LDH_SP_A0(TCCState *S, int r) | 1258 | void C67_LDH_SP_A0(TCCState* S, int r) |
| 1259 | { | 1259 | { |
| 1260 | C67_asm(S, "LDH.D *+SP[A0]", r, 0, 0); // LDH *+SP[A0],r | 1260 | C67_asm(S, "LDH.D *+SP[A0]", r, 0, 0); // LDH *+SP[A0],r |
| 1261 | } | 1261 | } |
| 1262 | 1262 | ||
| 1263 | void C67_LDB_SP_A0(TCCState *S, int r) | 1263 | void C67_LDB_SP_A0(TCCState* S, int r) |
| 1264 | { | 1264 | { |
| 1265 | C67_asm(S, "LDB.D *+SP[A0]", r, 0, 0); // LDB *+SP[A0],r | 1265 | C67_asm(S, "LDB.D *+SP[A0]", r, 0, 0); // LDB *+SP[A0],r |
| 1266 | } | 1266 | } |
| 1267 | 1267 | ||
| 1268 | void C67_LDHU_SP_A0(TCCState *S, int r) | 1268 | void C67_LDHU_SP_A0(TCCState* S, int r) |
| 1269 | { | 1269 | { |
| 1270 | C67_asm(S, "LDHU.D *+SP[A0]", r, 0, 0); // LDHU *+SP[A0],r | 1270 | C67_asm(S, "LDHU.D *+SP[A0]", r, 0, 0); // LDHU *+SP[A0],r |
| 1271 | } | 1271 | } |
| 1272 | 1272 | ||
| 1273 | void C67_LDBU_SP_A0(TCCState *S, int r) | 1273 | void C67_LDBU_SP_A0(TCCState* S, int r) |
| 1274 | { | 1274 | { |
| 1275 | C67_asm(S, "LDBU.D *+SP[A0]", r, 0, 0); // LDBU *+SP[A0],r | 1275 | C67_asm(S, "LDBU.D *+SP[A0]", r, 0, 0); // LDBU *+SP[A0],r |
| 1276 | } | 1276 | } |
| 1277 | 1277 | ||
| 1278 | void C67_LDW_PTR(TCCState *S, int r, int r2) | 1278 | void C67_LDW_PTR(TCCState* S, int r, int r2) |
| 1279 | { | 1279 | { |
| 1280 | C67_asm(S, "LDW.D *", r, r2, 0); // LDW *r,r2 | 1280 | C67_asm(S, "LDW.D *", r, r2, 0); // LDW *r,r2 |
| 1281 | } | 1281 | } |
| 1282 | 1282 | ||
| 1283 | void C67_LDDW_PTR(TCCState *S, int r, int r2) | 1283 | void C67_LDDW_PTR(TCCState* S, int r, int r2) |
| 1284 | { | 1284 | { |
| 1285 | C67_asm(S, "LDDW.D *", r, r2, 0); // LDDW *r,r2 | 1285 | C67_asm(S, "LDDW.D *", r, r2, 0); // LDDW *r,r2 |
| 1286 | } | 1286 | } |
| 1287 | 1287 | ||
| 1288 | void C67_LDH_PTR(TCCState *S, int r, int r2) | 1288 | void C67_LDH_PTR(TCCState* S, int r, int r2) |
| 1289 | { | 1289 | { |
| 1290 | C67_asm(S, "LDH.D *", r, r2, 0); // LDH *r,r2 | 1290 | C67_asm(S, "LDH.D *", r, r2, 0); // LDH *r,r2 |
| 1291 | } | 1291 | } |
| 1292 | 1292 | ||
| 1293 | void C67_LDB_PTR(TCCState *S, int r, int r2) | 1293 | void C67_LDB_PTR(TCCState* S, int r, int r2) |
| 1294 | { | 1294 | { |
| 1295 | C67_asm(S, "LDB.D *", r, r2, 0); // LDB *r,r2 | 1295 | C67_asm(S, "LDB.D *", r, r2, 0); // LDB *r,r2 |
| 1296 | } | 1296 | } |
| 1297 | 1297 | ||
| 1298 | void C67_LDHU_PTR(TCCState *S, int r, int r2) | 1298 | void C67_LDHU_PTR(TCCState* S, int r, int r2) |
| 1299 | { | 1299 | { |
| 1300 | C67_asm(S, "LDHU.D *", r, r2, 0); // LDHU *r,r2 | 1300 | C67_asm(S, "LDHU.D *", r, r2, 0); // LDHU *r,r2 |
| 1301 | } | 1301 | } |
| 1302 | 1302 | ||
| 1303 | void C67_LDBU_PTR(TCCState *S, int r, int r2) | 1303 | void C67_LDBU_PTR(TCCState* S, int r, int r2) |
| 1304 | { | 1304 | { |
| 1305 | C67_asm(S, "LDBU.D *", r, r2, 0); // LDBU *r,r2 | 1305 | C67_asm(S, "LDBU.D *", r, r2, 0); // LDBU *r,r2 |
| 1306 | } | 1306 | } |
| 1307 | 1307 | ||
| 1308 | void C67_LDW_PTR_PRE_INC(TCCState *S, int r, int r2) | 1308 | void C67_LDW_PTR_PRE_INC(TCCState* S, int r, int r2) |
| 1309 | { | 1309 | { |
| 1310 | C67_asm(S, "LDW.D +*", r, r2, 0); // LDW *+r,r2 | 1310 | C67_asm(S, "LDW.D +*", r, r2, 0); // LDW *+r,r2 |
| 1311 | } | 1311 | } |
| 1312 | 1312 | ||
| 1313 | void C67_POP(TCCState *S, int r) | 1313 | void C67_POP(TCCState* S, int r) |
| 1314 | { | 1314 | { |
| 1315 | C67_asm(S, "LDW.D SP PRE INC", r, 0, 0); // LDW *++SP,r | 1315 | C67_asm(S, "LDW.D SP PRE INC", r, 0, 0); // LDW *++SP,r |
| 1316 | } | 1316 | } |
| 1317 | 1317 | ||
| 1318 | void C67_POP_DW(TCCState *S, int r) | 1318 | void C67_POP_DW(TCCState* S, int r) |
| 1319 | { | 1319 | { |
| 1320 | C67_asm(S, "LDDW.D SP PRE INC", r, 0, 0); // LDDW *++SP,r | 1320 | C67_asm(S, "LDDW.D SP PRE INC", r, 0, 0); // LDDW *++SP,r |
| 1321 | } | 1321 | } |
| 1322 | 1322 | ||
| 1323 | void C67_CMPLT(TCCState *S, int s1, int s2, int dst) | 1323 | void C67_CMPLT(TCCState* S, int s1, int s2, int dst) |
| 1324 | { | 1324 | { |
| 1325 | C67_asm(S, "CMPLT.L1", s1, s2, dst); | 1325 | C67_asm(S, "CMPLT.L1", s1, s2, dst); |
| 1326 | } | 1326 | } |
| 1327 | 1327 | ||
| 1328 | void C67_CMPGT(TCCState *S, int s1, int s2, int dst) | 1328 | void C67_CMPGT(TCCState* S, int s1, int s2, int dst) |
| 1329 | { | 1329 | { |
| 1330 | C67_asm(S, "CMPGT.L1", s1, s2, dst); | 1330 | C67_asm(S, "CMPGT.L1", s1, s2, dst); |
| 1331 | } | 1331 | } |
| 1332 | 1332 | ||
| 1333 | void C67_CMPEQ(TCCState *S, int s1, int s2, int dst) | 1333 | void C67_CMPEQ(TCCState* S, int s1, int s2, int dst) |
| 1334 | { | 1334 | { |
| 1335 | C67_asm(S, "CMPEQ.L1", s1, s2, dst); | 1335 | C67_asm(S, "CMPEQ.L1", s1, s2, dst); |
| 1336 | } | 1336 | } |
| 1337 | 1337 | ||
| 1338 | void C67_CMPLTU(TCCState *S, int s1, int s2, int dst) | 1338 | void C67_CMPLTU(TCCState* S, int s1, int s2, int dst) |
| 1339 | { | 1339 | { |
| 1340 | C67_asm(S, "CMPLTU.L1", s1, s2, dst); | 1340 | C67_asm(S, "CMPLTU.L1", s1, s2, dst); |
| 1341 | } | 1341 | } |
| 1342 | 1342 | ||
| 1343 | void C67_CMPGTU(TCCState *S, int s1, int s2, int dst) | 1343 | void C67_CMPGTU(TCCState* S, int s1, int s2, int dst) |
| 1344 | { | 1344 | { |
| 1345 | C67_asm(S, "CMPGTU.L1", s1, s2, dst); | 1345 | C67_asm(S, "CMPGTU.L1", s1, s2, dst); |
| 1346 | } | 1346 | } |
| 1347 | 1347 | ||
| 1348 | 1348 | ||
| 1349 | void C67_CMPLTSP(TCCState *S, int s1, int s2, int dst) | 1349 | void C67_CMPLTSP(TCCState* S, int s1, int s2, int dst) |
| 1350 | { | 1350 | { |
| 1351 | C67_asm(S, "CMPLTSP.S1", s1, s2, dst); | 1351 | C67_asm(S, "CMPLTSP.S1", s1, s2, dst); |
| 1352 | } | 1352 | } |
| 1353 | 1353 | ||
| 1354 | void C67_CMPGTSP(TCCState *S, int s1, int s2, int dst) | 1354 | void C67_CMPGTSP(TCCState* S, int s1, int s2, int dst) |
| 1355 | { | 1355 | { |
| 1356 | C67_asm(S, "CMPGTSP.S1", s1, s2, dst); | 1356 | C67_asm(S, "CMPGTSP.S1", s1, s2, dst); |
| 1357 | } | 1357 | } |
| 1358 | 1358 | ||
| 1359 | void C67_CMPEQSP(TCCState *S, int s1, int s2, int dst) | 1359 | void C67_CMPEQSP(TCCState* S, int s1, int s2, int dst) |
| 1360 | { | 1360 | { |
| 1361 | C67_asm(S, "CMPEQSP.S1", s1, s2, dst); | 1361 | C67_asm(S, "CMPEQSP.S1", s1, s2, dst); |
| 1362 | } | 1362 | } |
| 1363 | 1363 | ||
| 1364 | void C67_CMPLTDP(TCCState *S, int s1, int s2, int dst) | 1364 | void C67_CMPLTDP(TCCState* S, int s1, int s2, int dst) |
| 1365 | { | 1365 | { |
| 1366 | C67_asm(S, "CMPLTDP.S1", s1, s2, dst); | 1366 | C67_asm(S, "CMPLTDP.S1", s1, s2, dst); |
| 1367 | } | 1367 | } |
| 1368 | 1368 | ||
| 1369 | void C67_CMPGTDP(TCCState *S, int s1, int s2, int dst) | 1369 | void C67_CMPGTDP(TCCState* S, int s1, int s2, int dst) |
| 1370 | { | 1370 | { |
| 1371 | C67_asm(S, "CMPGTDP.S1", s1, s2, dst); | 1371 | C67_asm(S, "CMPGTDP.S1", s1, s2, dst); |
| 1372 | } | 1372 | } |
| 1373 | 1373 | ||
| 1374 | void C67_CMPEQDP(TCCState *S, int s1, int s2, int dst) | 1374 | void C67_CMPEQDP(TCCState* S, int s1, int s2, int dst) |
| 1375 | { | 1375 | { |
| 1376 | C67_asm(S, "CMPEQDP.S1", s1, s2, dst); | 1376 | C67_asm(S, "CMPEQDP.S1", s1, s2, dst); |
| 1377 | } | 1377 | } |
| 1378 | 1378 | ||
| 1379 | 1379 | ||
| 1380 | void C67_IREG_B_REG(TCCState *S, int inv, int r1, int r2) // [!R] B r2 | 1380 | void C67_IREG_B_REG(TCCState* S, int inv, int r1, int r2) // [!R] B r2 |
| 1381 | { | 1381 | { |
| 1382 | C67_asm(S, "B.S2", inv, r1, r2); | 1382 | C67_asm(S, "B.S2", inv, r1, r2); |
| 1383 | } | 1383 | } |
| @@ -1386,7 +1386,7 @@ void C67_IREG_B_REG(TCCState *S, int inv, int r1, int r2) // [!R] B r2 · 2 unmodified lines | |||
| 1386 | // call with how many 32 bit words to skip | 1386 | // call with how many 32 bit words to skip |
| 1387 | // (0 would branch to the branch instruction) | 1387 | // (0 would branch to the branch instruction) |
| 1388 | 1388 | ||
| 1389 | void C67_B_DISP(TCCState *S, int disp) // B +2 Branch with constant displacement | 1389 | void C67_B_DISP(TCCState* S, int disp) // B +2 Branch with constant displacement |
| 1390 | { | 1390 | { |
| 1391 | // Branch point is relative to the 8 word fetch packet | 1391 | // Branch point is relative to the 8 word fetch packet |
| 1392 | // | 1392 | // |
| @@ -1395,152 +1395,152 @@ void C67_B_DISP(TCCState *S, int disp) // B +2 Branch with constant displacem · 2 unmodified lines | |||
| 1395 | // so add in how many words into the fetch packet the branch is | 1395 | // so add in how many words into the fetch packet the branch is |
| 1396 | 1396 | ||
| 1397 | 1397 | ||
| 1398 | C67_asm(S, "B DISP", disp + ((S->ind & 31) >> 2), 0, 0); | 1398 | C67_asm(S, "B DISP", disp + ((S->tccgen_ind & 31) >> 2), 0, 0); |
| 1399 | } | 1399 | } |
| 1400 | 1400 | ||
| 1401 | void C67_NOP(TCCState *S, int n) | 1401 | void C67_NOP(TCCState* S, int n) |
| 1402 | { | 1402 | { |
| 1403 | C67_asm(S, "NOP", n, 0, 0); | 1403 | C67_asm(S, "NOP", n, 0, 0); |
| 1404 | } | 1404 | } |
| 1405 | 1405 | ||
| 1406 | void C67_ADDK(TCCState *S, int n, int r) | 1406 | void C67_ADDK(TCCState* S, int n, int r) |
| 1407 | { | 1407 | { |
| 1408 | ALWAYS_ASSERT(abs(n) < 32767); | 1408 | ALWAYS_ASSERT(abs(n) < 32767); |
| 1409 | 1409 | ||
| 1410 | C67_asm(S, "ADDK", n, r, 0); | 1410 | C67_asm(S, "ADDK", n, r, 0); |
| 1411 | } | 1411 | } |
| 1412 | 1412 | ||
| 1413 | void C67_ADDK_PARALLEL(TCCState *S, int n, int r) | 1413 | void C67_ADDK_PARALLEL(TCCState* S, int n, int r) |
| 1414 | { | 1414 | { |
| 1415 | ALWAYS_ASSERT(abs(n) < 32767); | 1415 | ALWAYS_ASSERT(abs(n) < 32767); |
| 1416 | 1416 | ||
| 1417 | C67_asm(S, "||ADDK", n, r, 0); | 1417 | C67_asm(S, "||ADDK", n, r, 0); |
| 1418 | } | 1418 | } |
| 1419 | 1419 | ||
| 1420 | void C67_Adjust_ADDK(TCCState *S, int *inst, int n) | 1420 | void C67_Adjust_ADDK(TCCState* S, int *inst, int n) |
| 1421 | { | 1421 | { |
| 1422 | ALWAYS_ASSERT(abs(n) < 32767); | 1422 | ALWAYS_ASSERT(abs(n) < 32767); |
| 1423 | 1423 | ||
| 1424 | *inst = (*inst & (~(0xffff << 7))) | ((n & 0xffff) << 7); | 1424 | *inst = (*inst & (~(0xffff << 7))) | ((n & 0xffff) << 7); |
| 1425 | } | 1425 | } |
| 1426 | 1426 | ||
| 1427 | void C67_MV(TCCState *S, int r, int v) | 1427 | void C67_MV(TCCState* S, int r, int v) |
| 1428 | { | 1428 | { |
| 1429 | C67_asm(S, "MV.L", 0, r, v); | 1429 | C67_asm(S, "MV.L", 0, r, v); |
| 1430 | } | 1430 | } |
| 1431 | 1431 | ||
| 1432 | 1432 | ||
| 1433 | void C67_DPTRUNC(TCCState *S, int r, int v) | 1433 | void C67_DPTRUNC(TCCState* S, int r, int v) |
| 1434 | { | 1434 | { |
| 1435 | C67_asm(S, "DPTRUNC.L", 0, r, v); | 1435 | C67_asm(S, "DPTRUNC.L", 0, r, v); |
| 1436 | } | 1436 | } |
| 1437 | 1437 | ||
| 1438 | void C67_SPTRUNC(TCCState *S, int r, int v) | 1438 | void C67_SPTRUNC(TCCState* S, int r, int v) |
| 1439 | { | 1439 | { |
| 1440 | C67_asm(S, "SPTRUNC.L", 0, r, v); | 1440 | C67_asm(S, "SPTRUNC.L", 0, r, v); |
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| 1443 | void C67_INTSP(TCCState *S, int r, int v) | 1443 | void C67_INTSP(TCCState* S, int r, int v) |
| 1444 | { | 1444 | { |
| 1445 | C67_asm(S, "INTSP.L", 0, r, v); | 1445 | C67_asm(S, "INTSP.L", 0, r, v); |
| 1446 | } | 1446 | } |
| 1447 | 1447 | ||
| 1448 | void C67_INTDP(TCCState *S, int r, int v) | 1448 | void C67_INTDP(TCCState* S, int r, int v) |
| 1449 | { | 1449 | { |
| 1450 | C67_asm(S, "INTDP.L", 0, r, v); | 1450 | C67_asm(S, "INTDP.L", 0, r, v); |
| 1451 | } | 1451 | } |
| 1452 | 1452 | ||
| 1453 | void C67_INTSPU(TCCState *S, int r, int v) | 1453 | void C67_INTSPU(TCCState* S, int r, int v) |
| 1454 | { | 1454 | { |
| 1455 | C67_asm(S, "INTSPU.L", 0, r, v); | 1455 | C67_asm(S, "INTSPU.L", 0, r, v); |
| 1456 | } | 1456 | } |
| 1457 | 1457 | ||
| 1458 | void C67_INTDPU(TCCState *S, int r, int v) | 1458 | void C67_INTDPU(TCCState* S, int r, int v) |
| 1459 | { | 1459 | { |
| 1460 | C67_asm(S, "INTDPU.L", 0, r, v); | 1460 | C67_asm(S, "INTDPU.L", 0, r, v); |
| 1461 | } | 1461 | } |
| 1462 | 1462 | ||
| 1463 | void C67_SPDP(TCCState *S, int r, int v) | 1463 | void C67_SPDP(TCCState* S, int r, int v) |
| 1464 | { | 1464 | { |
| 1465 | C67_asm(S, "SPDP.L", 0, r, v); | 1465 | C67_asm(S, "SPDP.L", 0, r, v); |
| 1466 | } | 1466 | } |
| 1467 | 1467 | ||
| 1468 | void C67_DPSP(TCCState *S, int r, int v) // note regs must be on the same side | 1468 | void C67_DPSP(TCCState* S, int r, int v) // note regs must be on the same side |
| 1469 | { | 1469 | { |
| 1470 | C67_asm(S, "DPSP.L", 0, r, v); | 1470 | C67_asm(S, "DPSP.L", 0, r, v); |
| 1471 | } | 1471 | } |
| 1472 | 1472 | ||
| 1473 | void C67_ADD(TCCState *S, int r, int v) | 1473 | void C67_ADD(TCCState* S, int r, int v) |
| 1474 | { | 1474 | { |
| 1475 | C67_asm(S, "ADD.L", v, r, v); | 1475 | C67_asm(S, "ADD.L", v, r, v); |
| 1476 | } | 1476 | } |
| 1477 | 1477 | ||
| 1478 | void C67_SUB(TCCState *S, int r, int v) | 1478 | void C67_SUB(TCCState* S, int r, int v) |
| 1479 | { | 1479 | { |
| 1480 | C67_asm(S, "SUB.L", v, r, v); | 1480 | C67_asm(S, "SUB.L", v, r, v); |
| 1481 | } | 1481 | } |
| 1482 | 1482 | ||
| 1483 | void C67_AND(TCCState *S, int r, int v) | 1483 | void C67_AND(TCCState* S, int r, int v) |
| 1484 | { | 1484 | { |
| 1485 | C67_asm(S, "AND.L", v, r, v); | 1485 | C67_asm(S, "AND.L", v, r, v); |
| 1486 | } | 1486 | } |
| 1487 | 1487 | ||
| 1488 | void C67_OR(TCCState *S, int r, int v) | 1488 | void C67_OR(TCCState* S, int r, int v) |
| 1489 | { | 1489 | { |
| 1490 | C67_asm(S, "OR.L", v, r, v); | 1490 | C67_asm(S, "OR.L", v, r, v); |
| 1491 | } | 1491 | } |
| 1492 | 1492 | ||
| 1493 | void C67_XOR(TCCState *S, int r, int v) | 1493 | void C67_XOR(TCCState* S, int r, int v) |
| 1494 | { | 1494 | { |
| 1495 | C67_asm(S, "XOR.L", v, r, v); | 1495 | C67_asm(S, "XOR.L", v, r, v); |
| 1496 | } | 1496 | } |
| 1497 | 1497 | ||
| 1498 | void C67_ADDSP(TCCState *S, int r, int v) | 1498 | void C67_ADDSP(TCCState* S, int r, int v) |
| 1499 | { | 1499 | { |
| 1500 | C67_asm(S, "ADDSP.L", v, r, v); | 1500 | C67_asm(S, "ADDSP.L", v, r, v); |
| 1501 | } | 1501 | } |
| 1502 | 1502 | ||
| 1503 | void C67_SUBSP(TCCState *S, int r, int v) | 1503 | void C67_SUBSP(TCCState* S, int r, int v) |
| 1504 | { | 1504 | { |
| 1505 | C67_asm(S, "SUBSP.L", v, r, v); | 1505 | C67_asm(S, "SUBSP.L", v, r, v); |
| 1506 | } | 1506 | } |
| 1507 | 1507 | ||
| 1508 | void C67_MPYSP(TCCState *S, int r, int v) | 1508 | void C67_MPYSP(TCCState* S, int r, int v) |
| 1509 | { | 1509 | { |
| 1510 | C67_asm(S, "MPYSP.M", v, r, v); | 1510 | C67_asm(S, "MPYSP.M", v, r, v); |
| 1511 | } | 1511 | } |
| 1512 | 1512 | ||
| 1513 | void C67_ADDDP(TCCState *S, int r, int v) | 1513 | void C67_ADDDP(TCCState* S, int r, int v) |
| 1514 | { | 1514 | { |
| 1515 | C67_asm(S, "ADDDP.L", v, r, v); | 1515 | C67_asm(S, "ADDDP.L", v, r, v); |
| 1516 | } | 1516 | } |
| 1517 | 1517 | ||
| 1518 | void C67_SUBDP(TCCState *S, int r, int v) | 1518 | void C67_SUBDP(TCCState* S, int r, int v) |
| 1519 | { | 1519 | { |
| 1520 | C67_asm(S, "SUBDP.L", v, r, v); | 1520 | C67_asm(S, "SUBDP.L", v, r, v); |
| 1521 | } | 1521 | } |
| 1522 | 1522 | ||
| 1523 | void C67_MPYDP(TCCState *S, int r, int v) | 1523 | void C67_MPYDP(TCCState* S, int r, int v) |
| 1524 | { | 1524 | { |
| 1525 | C67_asm(S, "MPYDP.M", v, r, v); | 1525 | C67_asm(S, "MPYDP.M", v, r, v); |
| 1526 | } | 1526 | } |
| 1527 | 1527 | ||
| 1528 | void C67_MPYI(TCCState *S, int r, int v) | 1528 | void C67_MPYI(TCCState* S, int r, int v) |
| 1529 | { | 1529 | { |
| 1530 | C67_asm(S, "MPYI.M", v, r, v); | 1530 | C67_asm(S, "MPYI.M", v, r, v); |
| 1531 | } | 1531 | } |
| 1532 | 1532 | ||
| 1533 | void C67_SHL(TCCState *S, int r, int v) | 1533 | void C67_SHL(TCCState* S, int r, int v) |
| 1534 | { | 1534 | { |
| 1535 | C67_asm(S, "SHL.S", r, v, v); | 1535 | C67_asm(S, "SHL.S", r, v, v); |
| 1536 | } | 1536 | } |
| 1537 | 1537 | ||
| 1538 | void C67_SHRU(TCCState *S, int r, int v) | 1538 | void C67_SHRU(TCCState* S, int r, int v) |
| 1539 | { | 1539 | { |
| 1540 | C67_asm(S, "SHRU.S", r, v, v); | 1540 | C67_asm(S, "SHRU.S", r, v, v); |
| 1541 | } | 1541 | } |
| 1542 | 1542 | ||
| 1543 | void C67_SHR(TCCState *S, int r, int v) | 1543 | void C67_SHR(TCCState* S, int r, int v) |
| 1544 | { | 1544 | { |
| 1545 | C67_asm(S, "SHR.S", r, v, v); | 1545 | C67_asm(S, "SHR.S", r, v, v); |
| 1546 | } | 1546 | } |
| @@ -1548,7 +1548,7 @@ void C67_SHR(TCCState *S, int r, int v) · 1 unmodified line | |||
| 1548 | 1548 | ||
| 1549 | 1549 | ||
| 1550 | /* load 'r' from value 'sv' */ | 1550 | /* load 'r' from value 'sv' */ |
| 1551 | void load(TCCState *S, int r, SValue * sv) | 1551 | void load(TCCState* S, int r, SValue * sv) |
| 1552 | { | 1552 | { |
| 1553 | int v, t, ft, fc, fr, size = 0, element; | 1553 | int v, t, ft, fc, fr, size = 0, element; |
| 1554 | BOOL Unsigned = FALSE; | 1554 | BOOL Unsigned = FALSE; |
| @@ -1625,8 +1625,8 @@ void load(TCCState *S, int r, SValue * sv) · 70 unmodified lines | |||
| 1625 | C67_NOP(S, 4); // NOP 4 | 1625 | C67_NOP(S, 4); // NOP 4 |
| 1626 | return; | 1626 | return; |
| 1627 | } else if (fr & VT_SYM) { | 1627 | } else if (fr & VT_SYM) { |
| 1628 | greloc(S, cur_text_section, sv->sym, S->ind, R_C60LO16); // rem the inst need to be patched | 1628 | greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched |
| 1629 | greloc(S, cur_text_section, sv->sym, S->ind + 4, R_C60HI16); | 1629 | greloc(S, cur_text_section, sv->sym, S->tccgen_ind + 4, R_C60HI16); |
| 1630 | 1630 | ||
| 1631 | 1631 | ||
| 1632 | C67_MVKL(S, C67_A0, fc); //r=reg to load, constant | 1632 | C67_MVKL(S, C67_A0, fc); //r=reg to load, constant |
| @@ -1681,8 +1681,8 @@ void load(TCCState *S, int r, SValue * sv) · 48 unmodified lines | |||
| 1681 | } else { | 1681 | } else { |
| 1682 | if (v == VT_CONST) { | 1682 | if (v == VT_CONST) { |
| 1683 | if (fr & VT_SYM) { | 1683 | if (fr & VT_SYM) { |
| 1684 | greloc(S, cur_text_section, sv->sym, S->ind, R_C60LO16); // rem the inst need to be patched | 1684 | greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched |
| 1685 | greloc(S, cur_text_section, sv->sym, S->ind + 4, R_C60HI16); | 1685 | greloc(S, cur_text_section, sv->sym, S->tccgen_ind + 4, R_C60HI16); |
| 1686 | } | 1686 | } |
| 1687 | C67_MVKL(S, r, fc); //r=reg to load, constant | 1687 | C67_MVKL(S, r, fc); //r=reg to load, constant |
| 1688 | C67_MVKH(S, r, fc); //r=reg to load, constant | 1688 | C67_MVKH(S, r, fc); //r=reg to load, constant |
| @@ -1710,7 +1710,7 @@ void load(TCCState *S, int r, SValue * sv) · 21 unmodified lines | |||
| 1710 | 1710 | ||
| 1711 | 1711 | ||
| 1712 | /* store register 'r' in lvalue 'v' */ | 1712 | /* store register 'r' in lvalue 'v' */ |
| 1713 | void store(TCCState *S, int r, SValue * v) | 1713 | void store(TCCState* S, int r, SValue * v) |
| 1714 | { | 1714 | { |
| 1715 | int fr, bt, ft, fc, size, t, element; | 1715 | int fr, bt, ft, fc, size, t, element; |
| 1716 | 1716 | ||
| @@ -1736,8 +1736,8 @@ void store(TCCState *S, int r, SValue * v) · 19 unmodified lines | |||
| 1736 | /* constant memory reference */ | 1736 | /* constant memory reference */ |
| 1737 | 1737 | ||
| 1738 | if (v->r & VT_SYM) { | 1738 | if (v->r & VT_SYM) { |
| 1739 | greloc(S, cur_text_section, v->sym, S->ind, R_C60LO16); // rem the inst need to be patched | 1739 | greloc(S, cur_text_section, v->sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched |
| 1740 | greloc(S, cur_text_section, v->sym, S->ind + 4, R_C60HI16); | 1740 | greloc(S, cur_text_section, v->sym, S->tccgen_ind + 4, R_C60HI16); |
| 1741 | } | 1741 | } |
| 1742 | C67_MVKL(S, C67_A0, fc); //r=reg to load, constant | 1742 | C67_MVKL(S, C67_A0, fc); //r=reg to load, constant |
| 1743 | C67_MVKH(S, C67_A0, fc); //r=reg to load, constant | 1743 | C67_MVKH(S, C67_A0, fc); //r=reg to load, constant |
| @@ -1813,20 +1813,20 @@ void store(TCCState *S, int r, SValue * v) · 69 unmodified lines | |||
| 1813 | } | 1813 | } |
| 1814 | 1814 | ||
| 1815 | /* 'is_jmp' is '1' if it is a jump */ | 1815 | /* 'is_jmp' is '1' if it is a jump */ |
| 1816 | static void gcall_or_jmp(TCCState *S, int is_jmp) | 1816 | static void gcall_or_jmp(TCCState* S, int is_jmp) |
| 1817 | { | 1817 | { |
| 1818 | int r; | 1818 | int r; |
| 1819 | Sym *sym; | 1819 | Sym *sym; |
| 1820 | 1820 | ||
| 1821 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { | 1821 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| 1822 | /* constant case */ | 1822 | /* constant case */ |
| 1823 | if (S->vtop->r & VT_SYM) { | 1823 | if (S->tccgen_vtop->r & VT_SYM) { |
| 1824 | /* relocation case */ | 1824 | /* relocation case */ |
| 1825 | 1825 | ||
| 1826 | // get add into A0, then start the jump B3 | 1826 | // get add into A0, then start the jump B3 |
| 1827 | 1827 | ||
| 1828 | greloc(S, cur_text_section, S->vtop->sym, S->ind, R_C60LO16); // rem the inst need to be patched | 1828 | greloc(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched |
| 1829 | greloc(S, cur_text_section, S->vtop->sym, S->ind + 4, R_C60HI16); | 1829 | greloc(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind + 4, R_C60HI16); |
| 1830 | 1830 | ||
| 1831 | C67_MVKL(S, C67_A0, 0); //r=reg to load, constant | 1831 | C67_MVKL(S, C67_A0, 0); //r=reg to load, constant |
| 1832 | C67_MVKH(S, C67_A0, 0); //r=reg to load, constant | 1832 | C67_MVKH(S, C67_A0, 0); //r=reg to load, constant |
| @@ -1837,9 +1837,9 @@ static void gcall_or_jmp(TCCState *S, int is_jmp) · 4 unmodified lines | |||
| 1837 | } else { | 1837 | } else { |
| 1838 | // Call, must load return address into B3 during delay slots | 1838 | // Call, must load return address into B3 during delay slots |
| 1839 | 1839 | ||
| 1840 | sym = get_sym_ref(S, &S->char_pointer_type, cur_text_section, S->ind + 12, 0); // symbol for return address | 1840 | sym = get_sym_ref(S, &S->tccgen_char_pointer_type, cur_text_section, S->tccgen_ind + 12, 0); // symbol for return address |
| 1841 | greloc(S, cur_text_section, sym, S->ind, R_C60LO16); // rem the inst need to be patched | 1841 | greloc(S, cur_text_section, sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched |
| 1842 | greloc(S, cur_text_section, sym, S->ind + 4, R_C60HI16); | 1842 | greloc(S, cur_text_section, sym, S->tccgen_ind + 4, R_C60HI16); |
| 1843 | C67_MVKL(S, C67_B3, 0); //r=reg to load, constant | 1843 | C67_MVKL(S, C67_B3, 0); //r=reg to load, constant |
| 1844 | C67_MVKH(S, C67_B3, 0); //r=reg to load, constant | 1844 | C67_MVKH(S, C67_B3, 0); //r=reg to load, constant |
| 1845 | C67_NOP(S, 3); // put remaining NOPs | 1845 | C67_NOP(S, 3); // put remaining NOPs |
| @@ -1858,9 +1858,9 @@ static void gcall_or_jmp(TCCState *S, int is_jmp) · 12 unmodified lines | |||
| 1858 | } else { | 1858 | } else { |
| 1859 | // Call, must load return address into B3 during delay slots | 1859 | // Call, must load return address into B3 during delay slots |
| 1860 | 1860 | ||
| 1861 | sym = get_sym_ref(S, &S->char_pointer_type, cur_text_section, S->ind + 12, 0); // symbol for return address | 1861 | sym = get_sym_ref(S, &S->tccgen_char_pointer_type, cur_text_section, S->tccgen_ind + 12, 0); // symbol for return address |
| 1862 | greloc(S, cur_text_section, sym, S->ind, R_C60LO16); // rem the inst need to be patched | 1862 | greloc(S, cur_text_section, sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched |
| 1863 | greloc(S, cur_text_section, sym, S->ind + 4, R_C60HI16); | 1863 | greloc(S, cur_text_section, sym, S->tccgen_ind + 4, R_C60HI16); |
| 1864 | C67_MVKL(S, C67_B3, 0); //r=reg to load, constant | 1864 | C67_MVKL(S, C67_B3, 0); //r=reg to load, constant |
| 1865 | C67_MVKH(S, C67_B3, 0); //r=reg to load, constant | 1865 | C67_MVKH(S, C67_B3, 0); //r=reg to load, constant |
| 1866 | C67_NOP(S, 3); // put remaining NOPs | 1866 | C67_NOP(S, 3); // put remaining NOPs |
| @@ -1877,7 +1877,7 @@ ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align, int · 10 unmodified lines | |||
| 1877 | 1877 | ||
| 1878 | /* generate function call with address in (vtop->t, vtop->c) and free function | 1878 | /* generate function call with address in (vtop->t, vtop->c) and free function |
| 1879 | context. Stack entry is popped */ | 1879 | context. Stack entry is popped */ |
| 1880 | void gfunc_call(TCCState *S, int nb_args) | 1880 | void gfunc_call(TCCState* S, int nb_args) |
| 1881 | { | 1881 | { |
| 1882 | int i, r, size = 0; | 1882 | int i, r, size = 0; |
| 1883 | int args_sizes[NoCallArgsPassedOnStack]; | 1883 | int args_sizes[NoCallArgsPassedOnStack]; |
| @@ -1888,18 +1888,18 @@ void gfunc_call(TCCState *S, int nb_args) · 4 unmodified lines | |||
| 1888 | } | 1888 | } |
| 1889 | 1889 | ||
| 1890 | for (i = 0; i < nb_args; i++) { | 1890 | for (i = 0; i < nb_args; i++) { |
| 1891 | if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) { | 1891 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) { |
| 1892 | ALWAYS_ASSERT(FALSE); | 1892 | ALWAYS_ASSERT(FALSE); |
| 1893 | } else { | 1893 | } else { |
| 1894 | /* simple type (currently always same size) */ | 1894 | /* simple type (currently always same size) */ |
| 1895 | /* XXX: implicit cast ? */ | 1895 | /* XXX: implicit cast ? */ |
| 1896 | 1896 | ||
| 1897 | 1897 | ||
| 1898 | if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) { | 1898 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) { |
| 1899 | tcc_error(S, "long long not supported"); | 1899 | tcc_error(S, "long long not supported"); |
| 1900 | } else if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { | 1900 | } else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { |
| 1901 | tcc_error(S, "long double not supported"); | 1901 | tcc_error(S, "long double not supported"); |
| 1902 | } else if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE) { | 1902 | } else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE) { |
| 1903 | size = 8; | 1903 | size = 8; |
| 1904 | } else { | 1904 | } else { |
| 1905 | size = 4; | 1905 | size = 4; |
| @@ -1919,7 +1919,7 @@ void gfunc_call(TCCState *S, int nb_args) · 13 unmodified lines | |||
| 1919 | } | 1919 | } |
| 1920 | args_sizes[i] = size; | 1920 | args_sizes[i] = size; |
| 1921 | } | 1921 | } |
| 1922 | S->vtop--; | 1922 | S->tccgen_vtop--; |
| 1923 | } | 1923 | } |
| 1924 | // POP all the params on the stack into registers for the | 1924 | // POP all the params on the stack into registers for the |
| 1925 | // immediate call (in reverse order) | 1925 | // immediate call (in reverse order) |
| @@ -1932,7 +1932,7 @@ void gfunc_call(TCCState *S, int nb_args) · 6 unmodified lines | |||
| 1932 | C67_POP(S, TREG_C67_A4 + i * 2); | 1932 | C67_POP(S, TREG_C67_A4 + i * 2); |
| 1933 | } | 1933 | } |
| 1934 | gcall_or_jmp(S, 0); | 1934 | gcall_or_jmp(S, 0); |
| 1935 | S->vtop--; | 1935 | S->tccgen_vtop--; |
| 1936 | } | 1936 | } |
| 1937 | 1937 | ||
| 1938 | 1938 | ||
| @@ -1946,7 +1946,7 @@ void gfunc_call(TCCState *S, int nb_args) · 7 unmodified lines | |||
| 1946 | // parameters are loaded and restored upon return (or if/when needed). | 1946 | // parameters are loaded and restored upon return (or if/when needed). |
| 1947 | 1947 | ||
| 1948 | /* generate function prolog of type 't' */ | 1948 | /* generate function prolog of type 't' */ |
| 1949 | void gfunc_prolog(TCCState *S, Sym *func_sym) | 1949 | void gfunc_prolog(TCCState* S, Sym *func_sym) |
| 1950 | { | 1950 | { |
| 1951 | CType *func_type = &func_sym->type; | 1951 | CType *func_type = &func_sym->type; |
| 1952 | int addr, align, size, func_call, i; | 1952 | int addr, align, size, func_call, i; |
| @@ -1997,11 +1997,11 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 44 unmodified lines | |||
| 1997 | 1997 | ||
| 1998 | // place all the args passed in regs onto the stack | 1998 | // place all the args passed in regs onto the stack |
| 1999 | 1999 | ||
| 2000 | S->loc = 0; | 2000 | S->tccgen_loc = 0; |
| 2001 | for (i = 0; i < NoOfCurFuncArgs; i++) { | 2001 | for (i = 0; i < NoOfCurFuncArgs; i++) { |
| 2002 | 2002 | ||
| 2003 | ParamLocOnStack[i] = S->loc; // remember where the param is | 2003 | ParamLocOnStack[i] = S->tccgen_loc; // remember where the param is |
| 2004 | S->loc += -8; | 2004 | S->tccgen_loc += -8; |
| 2005 | 2005 | ||
| 2006 | C67_PUSH(S, TREG_C67_A4 + i * 2); | 2006 | C67_PUSH(S, TREG_C67_A4 + i * 2); |
| 2007 | 2007 | ||
| @@ -2010,9 +2010,9 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 2 unmodified lines | |||
| 2010 | } | 2010 | } |
| 2011 | } | 2011 | } |
| 2012 | 2012 | ||
| 2013 | TotalBytesPushedOnStack = -S->loc; | 2013 | TotalBytesPushedOnStack = -S->tccgen_loc; |
| 2014 | 2014 | ||
| 2015 | func_sub_sp_offset = S->ind; // remember where we put the stack instruction | 2015 | func_sub_sp_offset = S->tccgen_ind; // remember where we put the stack instruction |
| 2016 | C67_ADDK(S, 0, C67_SP); // ADDK.L2 loc,SP (just put zero temporarily) | 2016 | C67_ADDK(S, 0, C67_SP); // ADDK.L2 loc,SP (just put zero temporarily) |
| 2017 | 2017 | ||
| 2018 | C67_PUSH(S, C67_A0); | 2018 | C67_PUSH(S, C67_A0); |
| @@ -2020,10 +2020,10 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 1 unmodified line | |||
| 2020 | } | 2020 | } |
| 2021 | 2021 | ||
| 2022 | /* generate function epilog */ | 2022 | /* generate function epilog */ |
| 2023 | void gfunc_epilog(TCCState *S) | 2023 | void gfunc_epilog(TCCState* S) |
| 2024 | { | 2024 | { |
| 2025 | { | 2025 | { |
| 2026 | int local = (-S->loc + 7) & -8; // stack must stay aligned to 8 bytes for LDDW instr | 2026 | int local = (-S->tccgen_loc + 7) & -8; // stack must stay aligned to 8 bytes for LDDW instr |
| 2027 | C67_POP(S, C67_B3); | 2027 | C67_POP(S, C67_B3); |
| 2028 | C67_NOP(S, 4); // NOP wait for load | 2028 | C67_NOP(S, 4); // NOP wait for load |
| 2029 | C67_IREG_B_REG(S, 0, C67_CREG_ZERO, C67_B3); // B.S2 B3 | 2029 | C67_IREG_B_REG(S, 0, C67_CREG_ZERO, C67_B3); // B.S2 B3 |
| @@ -2036,7 +2036,7 @@ void gfunc_epilog(TCCState *S) · 6 unmodified lines | |||
| 2036 | } | 2036 | } |
| 2037 | } | 2037 | } |
| 2038 | 2038 | ||
| 2039 | ST_FUNC void gen_fill_nops(TCCState *S, int bytes) | 2039 | ST_FUNC void gen_fill_nops(TCCState* S, int bytes) |
| 2040 | { | 2040 | { |
| 2041 | if ((bytes & 3)) | 2041 | if ((bytes & 3)) |
| 2042 | tcc_error(S, "alignment of code section not multiple of 4"); | 2042 | tcc_error(S, "alignment of code section not multiple of 4"); |
| @@ -2047,10 +2047,10 @@ ST_FUNC void gen_fill_nops(TCCState *S, int bytes) · 4 unmodified lines | |||
| 2047 | } | 2047 | } |
| 2048 | 2048 | ||
| 2049 | /* generate a jump to a label */ | 2049 | /* generate a jump to a label */ |
| 2050 | int gjmp(TCCState *S, int t) | 2050 | int gjmp(TCCState* S, int t) |
| 2051 | { | 2051 | { |
| 2052 | int ind1 = S->ind; | 2052 | int ind1 = S->tccgen_ind; |
| 2053 | if (S->nocode_wanted) | 2053 | if (S->tccgen_nocode_wanted) |
| 2054 | return t; | 2054 | return t; |
| 2055 | 2055 | ||
| 2056 | C67_MVKL(S, C67_A0, t); //r=reg to load, constant | 2056 | C67_MVKL(S, C67_A0, t); //r=reg to load, constant |
| @@ -2061,7 +2061,7 @@ int gjmp(TCCState *S, int t) · 4 unmodified lines | |||
| 2061 | } | 2061 | } |
| 2062 | 2062 | ||
| 2063 | /* generate a jump to a fixed address */ | 2063 | /* generate a jump to a fixed address */ |
| 2064 | void gjmp_addr(TCCState *S, int a) | 2064 | void gjmp_addr(TCCState* S, int a) |
| 2065 | { | 2065 | { |
| 2066 | Sym *sym; | 2066 | Sym *sym; |
| 2067 | // I guess this routine is used for relative short | 2067 | // I guess this routine is used for relative short |
| @@ -2070,24 +2070,24 @@ void gjmp_addr(TCCState *S, int a) · 2 unmodified lines | |||
| 2070 | 2070 | ||
| 2071 | // define a label that will be relocated | 2071 | // define a label that will be relocated |
| 2072 | 2072 | ||
| 2073 | sym = get_sym_ref(S, &S->char_pointer_type, cur_text_section, a, 0); | 2073 | sym = get_sym_ref(S, &S->tccgen_char_pointer_type, cur_text_section, a, 0); |
| 2074 | greloc(S, cur_text_section, sym, S->ind, R_C60LO16); | 2074 | greloc(S, cur_text_section, sym, S->tccgen_ind, R_C60LO16); |
| 2075 | greloc(S, cur_text_section, sym, S->ind + 4, R_C60HI16); | 2075 | greloc(S, cur_text_section, sym, S->tccgen_ind + 4, R_C60HI16); |
| 2076 | 2076 | ||
| 2077 | gjmp(S, 0); // place a zero there later the symbol will be added to it | 2077 | gjmp(S, 0); // place a zero there later the symbol will be added to it |
| 2078 | } | 2078 | } |
| 2079 | 2079 | ||
| 2080 | /* generate a test. set 'inv' to invert test. Stack entry is popped */ | 2080 | /* generate a test. set 'inv' to invert test. Stack entry is popped */ |
| 2081 | ST_FUNC int gjmp_cond(TCCState *S, int op, int t) | 2081 | ST_FUNC int gjmp_cond(TCCState* S, int op, int t) |
| 2082 | { | 2082 | { |
| 2083 | int ind1; | 2083 | int ind1; |
| 2084 | int inv = op & 1; | 2084 | int inv = op & 1; |
| 2085 | if (S->nocode_wanted) | 2085 | if (S->tccgen_nocode_wanted) |
| 2086 | return t; | 2086 | return t; |
| 2087 | 2087 | ||
| 2088 | /* fast case : can jump directly since flags are set */ | 2088 | /* fast case : can jump directly since flags are set */ |
| 2089 | // C67 uses B2 sort of as flags register | 2089 | // C67 uses B2 sort of as flags register |
| 2090 | ind1 = S->ind; | 2090 | ind1 = S->tccgen_ind; |
| 2091 | C67_MVKL(S, C67_A0, t); //r=reg to load, constant | 2091 | C67_MVKL(S, C67_A0, t); //r=reg to load, constant |
| 2092 | C67_MVKH(S, C67_A0, t); //r=reg to load, constant | 2092 | C67_MVKH(S, C67_A0, t); //r=reg to load, constant |
| 2093 | 2093 | ||
| @@ -2105,7 +2105,7 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t) · 11 unmodified lines | |||
| 2105 | return t; | 2105 | return t; |
| 2106 | } | 2106 | } |
| 2107 | 2107 | ||
| 2108 | ST_FUNC int gjmp_append(TCCState *S, int n0, int t) | 2108 | ST_FUNC int gjmp_append(TCCState* S, int n0, int t) |
| 2109 | { | 2109 | { |
| 2110 | if (n0) { | 2110 | if (n0) { |
| 2111 | int n = n0, *p; | 2111 | int n = n0, *p; |
| @@ -2129,7 +2129,7 @@ ST_FUNC int gjmp_append(TCCState *S, int n0, int t) · 17 unmodified lines | |||
| 2129 | } | 2129 | } |
| 2130 | 2130 | ||
| 2131 | /* generate an integer binary operation */ | 2131 | /* generate an integer binary operation */ |
| 2132 | void gen_opi(TCCState *S, int op) | 2132 | void gen_opi(TCCState* S, int op) |
| 2133 | { | 2133 | { |
| 2134 | int r, fr, opc, t; | 2134 | int r, fr, opc, t; |
| 2135 | 2135 | ||
| @@ -2150,8 +2150,8 @@ void gen_opi(TCCState *S, int op) · 14 unmodified lines | |||
| 2150 | else | 2150 | else |
| 2151 | gv2(S, RC_INT, RC_INT); | 2151 | gv2(S, RC_INT, RC_INT); |
| 2152 | 2152 | ||
| 2153 | r = S->vtop[-1].r; | 2153 | r = S->tccgen_vtop[-1].r; |
| 2154 | fr = S->vtop[0].r; | 2154 | fr = S->tccgen_vtop[0].r; |
| 2155 | 2155 | ||
| 2156 | C67_compare_reg = C67_B2; | 2156 | C67_compare_reg = C67_B2; |
| 2157 | 2157 | ||
| @@ -2199,7 +2199,7 @@ void gen_opi(TCCState *S, int op) · 41 unmodified lines | |||
| 2199 | else | 2199 | else |
| 2200 | ALWAYS_ASSERT(FALSE); | 2200 | ALWAYS_ASSERT(FALSE); |
| 2201 | 2201 | ||
| 2202 | S->vtop--; | 2202 | S->tccgen_vtop--; |
| 2203 | if (op >= TOK_ULT && op <= TOK_GT) | 2203 | if (op >= TOK_ULT && op <= TOK_GT) |
| 2204 | vset_VT_CMP(S, 0x80); | 2204 | vset_VT_CMP(S, 0x80); |
| 2205 | break; | 2205 | break; |
| @@ -2225,33 +2225,33 @@ void gen_opi(TCCState *S, int op) · 19 unmodified lines | |||
| 2225 | case '*': | 2225 | case '*': |
| 2226 | case TOK_UMULL: | 2226 | case TOK_UMULL: |
| 2227 | gv2(S, RC_INT, RC_INT); | 2227 | gv2(S, RC_INT, RC_INT); |
| 2228 | r = S->vtop[-1].r; | 2228 | r = S->tccgen_vtop[-1].r; |
| 2229 | fr = S->vtop[0].r; | 2229 | fr = S->tccgen_vtop[0].r; |
| 2230 | S->vtop--; | 2230 | S->tccgen_vtop--; |
| 2231 | C67_MPYI(S, fr, r); // 32 bit multiply fr,r,fr | 2231 | C67_MPYI(S, fr, r); // 32 bit multiply fr,r,fr |
| 2232 | C67_NOP(S, 8); // NOP 8 for worst case | 2232 | C67_NOP(S, 8); // NOP 8 for worst case |
| 2233 | break; | 2233 | break; |
| 2234 | case TOK_SHL: | 2234 | case TOK_SHL: |
| 2235 | gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst | 2235 | gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst |
| 2236 | r = S->vtop[-1].r; | 2236 | r = S->tccgen_vtop[-1].r; |
| 2237 | fr = S->vtop[0].r; | 2237 | fr = S->tccgen_vtop[0].r; |
| 2238 | S->vtop--; | 2238 | S->tccgen_vtop--; |
| 2239 | C67_SHL(S, fr, r); // arithmetic/logical shift | 2239 | C67_SHL(S, fr, r); // arithmetic/logical shift |
| 2240 | break; | 2240 | break; |
| 2241 | 2241 | ||
| 2242 | case TOK_SHR: | 2242 | case TOK_SHR: |
| 2243 | gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst | 2243 | gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst |
| 2244 | r = S->vtop[-1].r; | 2244 | r = S->tccgen_vtop[-1].r; |
| 2245 | fr = S->vtop[0].r; | 2245 | fr = S->tccgen_vtop[0].r; |
| 2246 | S->vtop--; | 2246 | S->tccgen_vtop--; |
| 2247 | C67_SHRU(S, fr, r); // logical shift | 2247 | C67_SHRU(S, fr, r); // logical shift |
| 2248 | break; | 2248 | break; |
| 2249 | 2249 | ||
| 2250 | case TOK_SAR: | 2250 | case TOK_SAR: |
| 2251 | gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst | 2251 | gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst |
| 2252 | r = S->vtop[-1].r; | 2252 | r = S->tccgen_vtop[-1].r; |
| 2253 | fr = S->vtop[0].r; | 2253 | fr = S->tccgen_vtop[0].r; |
| 2254 | S->vtop--; | 2254 | S->tccgen_vtop--; |
| 2255 | C67_SHR(S, fr, r); // arithmetic shift | 2255 | C67_SHR(S, fr, r); // arithmetic shift |
| 2256 | break; | 2256 | break; |
| 2257 | 2257 | ||
| @@ -2264,8 +2264,8 @@ void gen_opi(TCCState *S, int op) · 6 unmodified lines | |||
| 2264 | vrott(S, 3); | 2264 | vrott(S, 3); |
| 2265 | gfunc_call(S, 2); | 2265 | gfunc_call(S, 2); |
| 2266 | vpushi(S, 0); | 2266 | vpushi(S, 0); |
| 2267 | S->vtop->r = REG_IRET; | 2267 | S->tccgen_vtop->r = REG_IRET; |
| 2268 | S->vtop->r2 = VT_CONST; | 2268 | S->tccgen_vtop->r2 = VT_CONST; |
| 2269 | break; | 2269 | break; |
| 2270 | case TOK_UDIV: | 2270 | case TOK_UDIV: |
| 2271 | case TOK_PDIV: | 2271 | case TOK_PDIV: |
| @@ -2287,7 +2287,7 @@ void gen_opi(TCCState *S, int op) · 15 unmodified lines | |||
| 2287 | /* generate a floating point operation 'v = t1 op t2' instruction. The | 2287 | /* generate a floating point operation 'v = t1 op t2' instruction. The |
| 2288 | two operands are guaranteed to have the same floating point type */ | 2288 | two operands are guaranteed to have the same floating point type */ |
| 2289 | /* XXX: need to use ST1 too */ | 2289 | /* XXX: need to use ST1 too */ |
| 2290 | void gen_opf(TCCState *S, int op) | 2290 | void gen_opf(TCCState* S, int op) |
| 2291 | { | 2291 | { |
| 2292 | int ft, fc, fr, r; | 2292 | int ft, fc, fr, r; |
| 2293 | 2293 | ||
| @@ -2296,10 +2296,10 @@ void gen_opf(TCCState *S, int op) · 2 unmodified lines | |||
| 2296 | else | 2296 | else |
| 2297 | gv2(S, RC_FLOAT, RC_FLOAT); // make sure src2 is on b side | 2297 | gv2(S, RC_FLOAT, RC_FLOAT); // make sure src2 is on b side |
| 2298 | 2298 | ||
| 2299 | ft = S->vtop->type.t; | 2299 | ft = S->tccgen_vtop->type.t; |
| 2300 | fc = S->vtop->c.i; | 2300 | fc = S->tccgen_vtop->c.i; |
| 2301 | r = S->vtop->r; | 2301 | r = S->tccgen_vtop->r; |
| 2302 | fr = S->vtop[-1].r; | 2302 | fr = S->tccgen_vtop[-1].r; |
| 2303 | 2303 | ||
| 2304 | 2304 | ||
| 2305 | if ((ft & VT_BTYPE) == VT_LDOUBLE) | 2305 | if ((ft & VT_BTYPE) == VT_LDOUBLE) |
| @@ -2307,8 +2307,8 @@ void gen_opf(TCCState *S, int op) · 1 unmodified line | |||
| 2307 | 2307 | ||
| 2308 | if (op >= TOK_ULT && op <= TOK_GT) { | 2308 | if (op >= TOK_ULT && op <= TOK_GT) { |
| 2309 | 2309 | ||
| 2310 | r = S->vtop[-1].r; | 2310 | r = S->tccgen_vtop[-1].r; |
| 2311 | fr = S->vtop[0].r; | 2311 | fr = S->tccgen_vtop[0].r; |
| 2312 | 2312 | ||
| 2313 | C67_compare_reg = C67_B2; | 2313 | C67_compare_reg = C67_B2; |
| 2314 | 2314 | ||
| @@ -2367,7 +2367,7 @@ void gen_opf(TCCState *S, int op) · 52 unmodified lines | |||
| 2367 | C67_ADDSP(S, r, fr); // ADD fr,r,fr | 2367 | C67_ADDSP(S, r, fr); // ADD fr,r,fr |
| 2368 | C67_NOP(S, 3); | 2368 | C67_NOP(S, 3); |
| 2369 | } | 2369 | } |
| 2370 | S->vtop--; | 2370 | S->tccgen_vtop--; |
| 2371 | } else if (op == '-') { | 2371 | } else if (op == '-') { |
| 2372 | if ((ft & VT_BTYPE) == VT_DOUBLE) { | 2372 | if ((ft & VT_BTYPE) == VT_DOUBLE) { |
| 2373 | C67_SUBDP(S, r, fr); // SUB fr,r,fr | 2373 | C67_SUBDP(S, r, fr); // SUB fr,r,fr |
| @@ -2376,7 +2376,7 @@ void gen_opf(TCCState *S, int op) · 2 unmodified lines | |||
| 2376 | C67_SUBSP(S, r, fr); // SUB fr,r,fr | 2376 | C67_SUBSP(S, r, fr); // SUB fr,r,fr |
| 2377 | C67_NOP(S, 3); | 2377 | C67_NOP(S, 3); |
| 2378 | } | 2378 | } |
| 2379 | S->vtop--; | 2379 | S->tccgen_vtop--; |
| 2380 | } else if (op == '*') { | 2380 | } else if (op == '*') { |
| 2381 | if ((ft & VT_BTYPE) == VT_DOUBLE) { | 2381 | if ((ft & VT_BTYPE) == VT_DOUBLE) { |
| 2382 | C67_MPYDP(S, r, fr); // MPY fr,r,fr | 2382 | C67_MPYDP(S, r, fr); // MPY fr,r,fr |
| @@ -2385,7 +2385,7 @@ void gen_opf(TCCState *S, int op) · 2 unmodified lines | |||
| 2385 | C67_MPYSP(S, r, fr); // MPY fr,r,fr | 2385 | C67_MPYSP(S, r, fr); // MPY fr,r,fr |
| 2386 | C67_NOP(S, 3); | 2386 | C67_NOP(S, 3); |
| 2387 | } | 2387 | } |
| 2388 | S->vtop--; | 2388 | S->tccgen_vtop--; |
| 2389 | } else if (op == '/') { | 2389 | } else if (op == '/') { |
| 2390 | if ((ft & VT_BTYPE) == VT_DOUBLE) { | 2390 | if ((ft & VT_BTYPE) == VT_DOUBLE) { |
| 2391 | // must call intrinsic DP floating point divide | 2391 | // must call intrinsic DP floating point divide |
| @@ -2395,8 +2395,8 @@ void gen_opf(TCCState *S, int op) · 3 unmodified lines | |||
| 2395 | vrott(S, 3); | 2395 | vrott(S, 3); |
| 2396 | gfunc_call(S, 2); | 2396 | gfunc_call(S, 2); |
| 2397 | vpushi(S, 0); | 2397 | vpushi(S, 0); |
| 2398 | S->vtop->r = REG_FRET; | 2398 | S->tccgen_vtop->r = REG_FRET; |
| 2399 | S->vtop->r2 = REG_IRE2; | 2399 | S->tccgen_vtop->r2 = REG_IRE2; |
| 2400 | 2400 | ||
| 2401 | } else { | 2401 | } else { |
| 2402 | // must call intrinsic SP floating point divide | 2402 | // must call intrinsic SP floating point divide |
| @@ -2406,8 +2406,8 @@ void gen_opf(TCCState *S, int op) · 3 unmodified lines | |||
| 2406 | vrott(S, 3); | 2406 | vrott(S, 3); |
| 2407 | gfunc_call(S, 2); | 2407 | gfunc_call(S, 2); |
| 2408 | vpushi(S, 0); | 2408 | vpushi(S, 0); |
| 2409 | S->vtop->r = REG_FRET; | 2409 | S->tccgen_vtop->r = REG_FRET; |
| 2410 | S->vtop->r2 = VT_CONST; | 2410 | S->tccgen_vtop->r2 = VT_CONST; |
| 2411 | } | 2411 | } |
| 2412 | } else | 2412 | } else |
| 2413 | ALWAYS_ASSERT(FALSE); | 2413 | ALWAYS_ASSERT(FALSE); |
| @@ -2419,12 +2419,12 @@ void gen_opf(TCCState *S, int op) · 5 unmodified lines | |||
| 2419 | 2419 | ||
| 2420 | /* convert integers to fp 't' type. Must handle 'int', 'unsigned int' | 2420 | /* convert integers to fp 't' type. Must handle 'int', 'unsigned int' |
| 2421 | and 'long long' cases. */ | 2421 | and 'long long' cases. */ |
| 2422 | void gen_cvt_itof(TCCState *S, int t) | 2422 | void gen_cvt_itof(TCCState* S, int t) |
| 2423 | { | 2423 | { |
| 2424 | int r; | 2424 | int r; |
| 2425 | 2425 | ||
| 2426 | gv(S, RC_INT); | 2426 | gv(S, RC_INT); |
| 2427 | r = S->vtop->r; | 2427 | r = S->tccgen_vtop->r; |
| 2428 | 2428 | ||
| 2429 | if ((t & VT_BTYPE) == VT_DOUBLE) { | 2429 | if ((t & VT_BTYPE) == VT_DOUBLE) { |
| 2430 | if (t & VT_UNSIGNED) | 2430 | if (t & VT_UNSIGNED) |
| @@ -2433,31 +2433,31 @@ void gen_cvt_itof(TCCState *S, int t) · 2 unmodified lines | |||
| 2433 | C67_INTDP(S, r, r); | 2433 | C67_INTDP(S, r, r); |
| 2434 | 2434 | ||
| 2435 | C67_NOP(S, 4); | 2435 | C67_NOP(S, 4); |
| 2436 | S->vtop->type.t = VT_DOUBLE; | 2436 | S->tccgen_vtop->type.t = VT_DOUBLE; |
| 2437 | } else { | 2437 | } else { |
| 2438 | if (t & VT_UNSIGNED) | 2438 | if (t & VT_UNSIGNED) |
| 2439 | C67_INTSPU(S, r, r); | 2439 | C67_INTSPU(S, r, r); |
| 2440 | else | 2440 | else |
| 2441 | C67_INTSP(S, r, r); | 2441 | C67_INTSP(S, r, r); |
| 2442 | C67_NOP(S, 3); | 2442 | C67_NOP(S, 3); |
| 2443 | S->vtop->type.t = VT_FLOAT; | 2443 | S->tccgen_vtop->type.t = VT_FLOAT; |
| 2444 | } | 2444 | } |
| 2445 | 2445 | ||
| 2446 | } | 2446 | } |
| 2447 | 2447 | ||
| 2448 | /* convert fp to int 't' type */ | 2448 | /* convert fp to int 't' type */ |
| 2449 | /* XXX: handle long long case */ | 2449 | /* XXX: handle long long case */ |
| 2450 | void gen_cvt_ftoi(TCCState *S, int t) | 2450 | void gen_cvt_ftoi(TCCState* S, int t) |
| 2451 | { | 2451 | { |
| 2452 | int r; | 2452 | int r; |
| 2453 | 2453 | ||
| 2454 | gv(S, RC_FLOAT); | 2454 | gv(S, RC_FLOAT); |
| 2455 | r = S->vtop->r; | 2455 | r = S->tccgen_vtop->r; |
| 2456 | 2456 | ||
| 2457 | if (t != VT_INT) | 2457 | if (t != VT_INT) |
| 2458 | tcc_error(S, "long long not supported"); | 2458 | tcc_error(S, "long long not supported"); |
| 2459 | else { | 2459 | else { |
| 2460 | if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE) { | 2460 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE) { |
| 2461 | C67_DPTRUNC(S, r, r); | 2461 | C67_DPTRUNC(S, r, r); |
| 2462 | C67_NOP(S, 3); | 2462 | C67_NOP(S, 3); |
| 2463 | } else { | 2463 | } else { |
| @@ -2465,36 +2465,36 @@ void gen_cvt_ftoi(TCCState *S, int t) · 1 unmodified line | |||
| 2465 | C67_NOP(S, 3); | 2465 | C67_NOP(S, 3); |
| 2466 | } | 2466 | } |
| 2467 | 2467 | ||
| 2468 | S->vtop->type.t = VT_INT; | 2468 | S->tccgen_vtop->type.t = VT_INT; |
| 2469 | 2469 | ||
| 2470 | } | 2470 | } |
| 2471 | } | 2471 | } |
| 2472 | 2472 | ||
| 2473 | /* convert from one floating point type to another */ | 2473 | /* convert from one floating point type to another */ |
| 2474 | void gen_cvt_ftof(TCCState *S, int t) | 2474 | void gen_cvt_ftof(TCCState* S, int t) |
| 2475 | { | 2475 | { |
| 2476 | int r, r2; | 2476 | int r, r2; |
| 2477 | 2477 | ||
| 2478 | if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE && | 2478 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE && |
| 2479 | (t & VT_BTYPE) == VT_FLOAT) { | 2479 | (t & VT_BTYPE) == VT_FLOAT) { |
| 2480 | // convert double to float | 2480 | // convert double to float |
| 2481 | 2481 | ||
| 2482 | gv(S, RC_FLOAT); // get it in a register pair | 2482 | gv(S, RC_FLOAT); // get it in a register pair |
| 2483 | 2483 | ||
| 2484 | r = S->vtop->r; | 2484 | r = S->tccgen_vtop->r; |
| 2485 | 2485 | ||
| 2486 | C67_DPSP(S, r, r); // convert it to SP same register | 2486 | C67_DPSP(S, r, r); // convert it to SP same register |
| 2487 | C67_NOP(S, 3); | 2487 | C67_NOP(S, 3); |
| 2488 | 2488 | ||
| 2489 | S->vtop->type.t = VT_FLOAT; | 2489 | S->tccgen_vtop->type.t = VT_FLOAT; |
| 2490 | S->vtop->r2 = VT_CONST; // set this as unused | 2490 | S->tccgen_vtop->r2 = VT_CONST; // set this as unused |
| 2491 | } else if ((S->vtop->type.t & VT_BTYPE) == VT_FLOAT && | 2491 | } else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FLOAT && |
| 2492 | (t & VT_BTYPE) == VT_DOUBLE) { | 2492 | (t & VT_BTYPE) == VT_DOUBLE) { |
| 2493 | // convert float to double | 2493 | // convert float to double |
| 2494 | 2494 | ||
| 2495 | gv(S, RC_FLOAT); // get it in a register | 2495 | gv(S, RC_FLOAT); // get it in a register |
| 2496 | 2496 | ||
| 2497 | r = S->vtop->r; | 2497 | r = S->tccgen_vtop->r; |
| 2498 | 2498 | ||
| 2499 | if (r == TREG_EAX) { // make sure the paired reg is avail | 2499 | if (r == TREG_EAX) { // make sure the paired reg is avail |
| 2500 | r2 = get_reg(S, RC_ECX); | 2500 | r2 = get_reg(S, RC_ECX); |
| @@ -2508,32 +2508,32 @@ void gen_cvt_ftof(TCCState *S, int t) · 7 unmodified lines | |||
| 2508 | C67_SPDP(S, r, r); // convert it to DP same register | 2508 | C67_SPDP(S, r, r); // convert it to DP same register |
| 2509 | C67_NOP(S, 1); | 2509 | C67_NOP(S, 1); |
| 2510 | 2510 | ||
| 2511 | S->vtop->type.t = VT_DOUBLE; | 2511 | S->tccgen_vtop->type.t = VT_DOUBLE; |
| 2512 | S->vtop->r2 = r2; // set this as unused | 2512 | S->tccgen_vtop->r2 = r2; // set this as unused |
| 2513 | } else { | 2513 | } else { |
| 2514 | ALWAYS_ASSERT(FALSE); | 2514 | ALWAYS_ASSERT(FALSE); |
| 2515 | } | 2515 | } |
| 2516 | } | 2516 | } |
| 2517 | 2517 | ||
| 2518 | /* computed goto support */ | 2518 | /* computed goto support */ |
| 2519 | void ggoto(TCCState *S) | 2519 | void ggoto(TCCState* S) |
| 2520 | { | 2520 | { |
| 2521 | gcall_or_jmp(S, 1); | 2521 | gcall_or_jmp(S, 1); |
| 2522 | S->vtop--; | 2522 | S->tccgen_vtop--; |
| 2523 | } | 2523 | } |
| 2524 | 2524 | ||
| 2525 | /* Save the stack pointer onto the stack and return the location of its address */ | 2525 | /* Save the stack pointer onto the stack and return the location of its address */ |
| 2526 | ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) { | 2526 | ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) { |
| 2527 | tcc_error(S, "variable length arrays unsupported for this target"); | 2527 | tcc_error(S, "variable length arrays unsupported for this target"); |
| 2528 | } | 2528 | } |
| 2529 | 2529 | ||
| 2530 | /* Restore the SP from a location on the stack */ | 2530 | /* Restore the SP from a location on the stack */ |
| 2531 | ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) { | 2531 | ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) { |
| 2532 | tcc_error(S, "variable length arrays unsupported for this target"); | 2532 | tcc_error(S, "variable length arrays unsupported for this target"); |
| 2533 | } | 2533 | } |
| 2534 | 2534 | ||
| 2535 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ | 2535 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ |
| 2536 | ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) { | 2536 | ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) { |
| 2537 | tcc_error(S, "variable length arrays unsupported for this target"); | 2537 | tcc_error(S, "variable length arrays unsupported for this target"); |
| 2538 | } | 2538 | } |
| 2539 | 2539 | ||
| @@ -282,7 +282,7 @@ static inline int get_reg_shift(TCCState *S) · 281 unmodified lines | |||
| 282 | static int asm_parse_numeric_reg(TCCState *S, int t, unsigned int *type) | 282 | static int asm_parse_numeric_reg(TCCState *S, int t, unsigned int *type) |
| 283 | { | 283 | { |
| 284 | int reg = -1; | 284 | int reg = -1; |
| 285 | if (t >= TOK_IDENT && t < S->tok_ident) { | 285 | if (t >= TOK_IDENT && t < S->tccpp_tok_ident) { |
| 286 | const char *s = S->tccpp_table_ident[t - TOK_IDENT]->str; | 286 | const char *s = S->tccpp_table_ident[t - TOK_IDENT]->str; |
| 287 | char c; | 287 | char c; |
| 288 | *type = OP_REG64; | 288 | *type = OP_REG64; |
| @@ -318,24 +318,24 @@ static int asm_parse_numeric_reg(TCCState *S, int t, unsigned int *type) · 29 unmodified lines | |||
| 318 | } | 318 | } |
| 319 | #endif | 319 | #endif |
| 320 | 320 | ||
| 321 | static int asm_parse_reg(TCCState *S, unsigned int *type) | 321 | static int asm_parse_reg(TCCState* S, unsigned int *type) |
| 322 | { | 322 | { |
| 323 | int reg = 0; | 323 | int reg = 0; |
| 324 | *type = 0; | 324 | *type = 0; |
| 325 | if (S->tok != '%') | 325 | if (S->tccpp_tok != '%') |
| 326 | goto error_32; | 326 | goto error_32; |
| 327 | next(S); | 327 | next(S); |
| 328 | if (S->tok >= TOK_ASM_eax && S->tok <= TOK_ASM_edi) { | 328 | if (S->tccpp_tok >= TOK_ASM_eax && S->tccpp_tok <= TOK_ASM_edi) { |
| 329 | reg = S->tok - TOK_ASM_eax; | 329 | reg = S->tccpp_tok - TOK_ASM_eax; |
| 330 | *type = OP_REG32; | 330 | *type = OP_REG32; |
| 331 | #ifdef TCC_TARGET_X86_64 | 331 | #ifdef TCC_TARGET_X86_64 |
| 332 | } else if (S->tok >= TOK_ASM_rax && S->tok <= TOK_ASM_rdi) { | 332 | } else if (S->tccpp_tok >= TOK_ASM_rax && S->tccpp_tok <= TOK_ASM_rdi) { |
| 333 | reg = S->tok - TOK_ASM_rax; | 333 | reg = S->tccpp_tok - TOK_ASM_rax; |
| 334 | *type = OP_REG64; | 334 | *type = OP_REG64; |
| 335 | } else if (S->tok == TOK_ASM_rip) { | 335 | } else if (S->tccpp_tok == TOK_ASM_rip) { |
| 336 | reg = -2; /* Probably should use different escape code. */ | 336 | reg = -2; /* Probably should use different escape code. */ |
| 337 | *type = OP_REG64; | 337 | *type = OP_REG64; |
| 338 | } else if ((reg = asm_parse_numeric_reg(S, S->tok, type)) >= 0 | 338 | } else if ((reg = asm_parse_numeric_reg(S, S->tccpp_tok, type)) >= 0 |
| 339 | && (*type == OP_REG32 || *type == OP_REG64)) { | 339 | && (*type == OP_REG32 || *type == OP_REG64)) { |
| 340 | ; | 340 | ; |
| 341 | #endif | 341 | #endif |
| @@ -354,15 +354,15 @@ static void parse_operand(TCCState *S, Operand *op) · 12 unmodified lines | |||
| 354 | const char *p; | 354 | const char *p; |
| 355 | 355 | ||
| 356 | indir = 0; | 356 | indir = 0; |
| 357 | if (S->tok == '*') { | 357 | if (S->tccpp_tok == '*') { |
| 358 | next(S); | 358 | next(S); |
| 359 | indir = OP_INDIR; | 359 | indir = OP_INDIR; |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | if (S->tok == '%') { | 362 | if (S->tccpp_tok == '%') { |
| 363 | next(S); | 363 | next(S); |
| 364 | if (S->tok >= TOK_ASM_al && S->tok <= TOK_ASM_db7) { | 364 | if (S->tccpp_tok >= TOK_ASM_al && S->tccpp_tok <= TOK_ASM_db7) { |
| 365 | reg = S->tok - TOK_ASM_al; | 365 | reg = S->tccpp_tok - TOK_ASM_al; |
| 366 | op->type = 1 << (reg >> 3); /* WARNING: do not change constant order */ | 366 | op->type = 1 << (reg >> 3); /* WARNING: do not change constant order */ |
| 367 | op->reg = reg & 7; | 367 | op->reg = reg & 7; |
| 368 | if ((op->type & OP_REG) && op->reg == TREG_XAX) | 368 | if ((op->type & OP_REG) && op->reg == TREG_XAX) |
| @@ -371,21 +371,21 @@ static void parse_operand(TCCState *S, Operand *op) · 2 unmodified lines | |||
| 371 | op->type |= OP_CL; | 371 | op->type |= OP_CL; |
| 372 | else if (op->type == OP_REG16 && op->reg == TREG_XDX) | 372 | else if (op->type == OP_REG16 && op->reg == TREG_XDX) |
| 373 | op->type |= OP_DX; | 373 | op->type |= OP_DX; |
| 374 | } else if (S->tok >= TOK_ASM_dr0 && S->tok <= TOK_ASM_dr7) { | 374 | } else if (S->tccpp_tok >= TOK_ASM_dr0 && S->tccpp_tok <= TOK_ASM_dr7) { |
| 375 | op->type = OP_DB; | 375 | op->type = OP_DB; |
| 376 | op->reg = S->tok - TOK_ASM_dr0; | 376 | op->reg = S->tccpp_tok - TOK_ASM_dr0; |
| 377 | } else if (S->tok >= TOK_ASM_es && S->tok <= TOK_ASM_gs) { | 377 | } else if (S->tccpp_tok >= TOK_ASM_es && S->tccpp_tok <= TOK_ASM_gs) { |
| 378 | op->type = OP_SEG; | 378 | op->type = OP_SEG; |
| 379 | op->reg = S->tok - TOK_ASM_es; | 379 | op->reg = S->tccpp_tok - TOK_ASM_es; |
| 380 | } else if (S->tok == TOK_ASM_st) { | 380 | } else if (S->tccpp_tok == TOK_ASM_st) { |
| 381 | op->type = OP_ST; | 381 | op->type = OP_ST; |
| 382 | op->reg = 0; | 382 | op->reg = 0; |
| 383 | next(S); | 383 | next(S); |
| 384 | if (S->tok == '(') { | 384 | if (S->tccpp_tok == '(') { |
| 385 | next(S); | 385 | next(S); |
| 386 | if (S->tok != TOK_PPNUM) | 386 | if (S->tccpp_tok != TOK_PPNUM) |
| 387 | goto reg_error; | 387 | goto reg_error; |
| 388 | p = S->tokc.str.data; | 388 | p = S->tccpp_tokc.str.data; |
| 389 | reg = p[0] - '0'; | 389 | reg = p[0] - '0'; |
| 390 | if ((unsigned)reg >= 8 || p[1] != '\0') | 390 | if ((unsigned)reg >= 8 || p[1] != '\0') |
| 391 | goto reg_error; | 391 | goto reg_error; |
| @@ -397,19 +397,19 @@ static void parse_operand(TCCState *S, Operand *op) · 5 unmodified lines | |||
| 397 | op->type |= OP_ST0; | 397 | op->type |= OP_ST0; |
| 398 | goto no_skip; | 398 | goto no_skip; |
| 399 | #ifdef TCC_TARGET_X86_64 | 399 | #ifdef TCC_TARGET_X86_64 |
| 400 | } else if (S->tok >= TOK_ASM_spl && S->tok <= TOK_ASM_dil) { | 400 | } else if (S->tccpp_tok >= TOK_ASM_spl && S->tccpp_tok <= TOK_ASM_dil) { |
| 401 | op->type = OP_REG8 | OP_REG8_LOW; | 401 | op->type = OP_REG8 | OP_REG8_LOW; |
| 402 | op->reg = 4 + S->tok - TOK_ASM_spl; | 402 | op->reg = 4 + S->tccpp_tok - TOK_ASM_spl; |
| 403 | } else if ((op->reg = asm_parse_numeric_reg(S, S->tok, &op->type)) >= 0) { | 403 | } else if ((op->reg = asm_parse_numeric_reg(S, S->tccpp_tok, &op->type)) >= 0) { |
| 404 | ; | 404 | ; |
| 405 | #endif | 405 | #endif |
| 406 | } else { | 406 | } else { |
| 407 | reg_error: | 407 | reg_error: |
| 408 | tcc_error(S, "unknown register %%%s", get_tok_str(S, S->tok, &S->tokc)); | 408 | tcc_error(S, "unknown register %%%s", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 409 | } | 409 | } |
| 410 | next(S); | 410 | next(S); |
| 411 | no_skip: ; | 411 | no_skip: ; |
| 412 | } else if (S->tok == '$') { | 412 | } else if (S->tccpp_tok == '$') { |
| 413 | /* constant value */ | 413 | /* constant value */ |
| 414 | next(S); | 414 | next(S); |
| 415 | asm_expr(S, &e); | 415 | asm_expr(S, &e); |
| @@ -433,19 +433,19 @@ static void parse_operand(TCCState *S, Operand *op) · 17 unmodified lines | |||
| 433 | op->reg = -1; | 433 | op->reg = -1; |
| 434 | op->reg2 = -1; | 434 | op->reg2 = -1; |
| 435 | op->shift = 0; | 435 | op->shift = 0; |
| 436 | if (S->tok != '(') { | 436 | if (S->tccpp_tok != '(') { |
| 437 | asm_expr(S, &e); | 437 | asm_expr(S, &e); |
| 438 | op->e = e; | 438 | op->e = e; |
| 439 | } else { | 439 | } else { |
| 440 | next(S); | 440 | next(S); |
| 441 | if (S->tok == '%') { | 441 | if (S->tccpp_tok == '%') { |
| 442 | unget_tok(S, '('); | 442 | unget_tok(S, '('); |
| 443 | op->e.v = 0; | 443 | op->e.v = 0; |
| 444 | op->e.sym = NULL; | 444 | op->e.sym = NULL; |
| 445 | } else { | 445 | } else { |
| 446 | /* bracketed offset expression */ | 446 | /* bracketed offset expression */ |
| 447 | asm_expr(S, &e); | 447 | asm_expr(S, &e); |
| 448 | if (S->tok != ')') | 448 | if (S->tccpp_tok != ')') |
| 449 | expect(S, ")"); | 449 | expect(S, ")"); |
| 450 | next(S); | 450 | next(S); |
| 451 | op->e.v = e.v; | 451 | op->e.v = e.v; |
| @@ -453,18 +453,18 @@ static void parse_operand(TCCState *S, Operand *op) · 1 unmodified line | |||
| 453 | } | 453 | } |
| 454 | op->e.pcrel = 0; | 454 | op->e.pcrel = 0; |
| 455 | } | 455 | } |
| 456 | if (S->tok == '(') { | 456 | if (S->tccpp_tok == '(') { |
| 457 | unsigned int type = 0; | 457 | unsigned int type = 0; |
| 458 | next(S); | 458 | next(S); |
| 459 | if (S->tok != ',') { | 459 | if (S->tccpp_tok != ',') { |
| 460 | op->reg = asm_parse_reg(S, &type); | 460 | op->reg = asm_parse_reg(S, &type); |
| 461 | } | 461 | } |
| 462 | if (S->tok == ',') { | 462 | if (S->tccpp_tok == ',') { |
| 463 | next(S); | 463 | next(S); |
| 464 | if (S->tok != ',') { | 464 | if (S->tccpp_tok != ',') { |
| 465 | op->reg2 = asm_parse_reg(S, &type); | 465 | op->reg2 = asm_parse_reg(S, &type); |
| 466 | } | 466 | } |
| 467 | if (S->tok == ',') { | 467 | if (S->tccpp_tok == ',') { |
| 468 | next(S); | 468 | next(S); |
| 469 | op->shift = get_reg_shift(S); | 469 | op->shift = get_reg_shift(S); |
| 470 | } | 470 | } |
| @@ -480,7 +480,7 @@ static void parse_operand(TCCState *S, Operand *op) · 9 unmodified lines | |||
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | /* XXX: unify with C code output ? */ | 482 | /* XXX: unify with C code output ? */ |
| 483 | ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe) | 483 | ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe) |
| 484 | { | 484 | { |
| 485 | if (pe->pcrel) | 485 | if (pe->pcrel) |
| 486 | /* If PC-relative, always set VT_SYM, even without symbol, | 486 | /* If PC-relative, always set VT_SYM, even without symbol, |
| @@ -491,14 +491,14 @@ ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe) · 4 unmodified lines | |||
| 491 | } | 491 | } |
| 492 | 492 | ||
| 493 | #ifdef TCC_TARGET_X86_64 | 493 | #ifdef TCC_TARGET_X86_64 |
| 494 | ST_FUNC void gen_expr64(TCCState *S, ExprValue *pe) | 494 | ST_FUNC void gen_expr64(TCCState* S, ExprValue *pe) |
| 495 | { | 495 | { |
| 496 | gen_addr64(S, pe->sym ? VT_SYM : 0, pe->sym, pe->v); | 496 | gen_addr64(S, pe->sym ? VT_SYM : 0, pe->sym, pe->v); |
| 497 | } | 497 | } |
| 498 | #endif | 498 | #endif |
| 499 | 499 | ||
| 500 | /* XXX: unify with C code output ? */ | 500 | /* XXX: unify with C code output ? */ |
| 501 | static void gen_disp32(TCCState *S, ExprValue *pe) | 501 | static void gen_disp32(TCCState* S, ExprValue *pe) |
| 502 | { | 502 | { |
| 503 | Sym *sym = pe->sym; | 503 | Sym *sym = pe->sym; |
| 504 | ElfSym *esym = elfsym(S, sym); | 504 | ElfSym *esym = elfsym(S, sym); |
| @@ -507,7 +507,7 @@ static void gen_disp32(TCCState *S, ExprValue *pe) · 2 unmodified lines | |||
| 507 | that the TCC compiler behaves differently here because | 507 | that the TCC compiler behaves differently here because |
| 508 | it always outputs a relocation to ease (future) code | 508 | it always outputs a relocation to ease (future) code |
| 509 | elimination in the linker */ | 509 | elimination in the linker */ |
| 510 | gen_le32(S, pe->v + esym->st_value - S->ind - 4); | 510 | gen_le32(S, pe->v + esym->st_value - S->tccgen_ind - 4); |
| 511 | } else { | 511 | } else { |
| 512 | if (sym && sym->type.t == VT_VOID) { | 512 | if (sym && sym->type.t == VT_VOID) { |
| 513 | sym->type.t = VT_FUNC; | 513 | sym->type.t = VT_FUNC; |
| @@ -518,7 +518,7 @@ static void gen_disp32(TCCState *S, ExprValue *pe) · 4 unmodified lines | |||
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | /* generate the modrm operand */ | 520 | /* generate the modrm operand */ |
| 521 | static inline int asm_modrm(TCCState *S, int reg, Operand *op) | 521 | static inline int asm_modrm(TCCState* S, int reg, Operand *op) |
| 522 | { | 522 | { |
| 523 | int mod, reg1, reg2, sib_reg1; | 523 | int mod, reg1, reg2, sib_reg1; |
| 524 | 524 | ||
| @@ -538,7 +538,7 @@ static inline int asm_modrm(TCCState *S, int reg, Operand *op) · 13 unmodified lines | |||
| 538 | ExprValue *pe = &op->e; | 538 | ExprValue *pe = &op->e; |
| 539 | g(S, 0x05 + (reg << 3)); | 539 | g(S, 0x05 + (reg << 3)); |
| 540 | gen_addrpc32(S, pe->sym ? VT_SYM : 0, pe->sym, pe->v); | 540 | gen_addrpc32(S, pe->sym ? VT_SYM : 0, pe->sym, pe->v); |
| 541 | return S->ind; | 541 | return S->tccgen_ind; |
| 542 | #endif | 542 | #endif |
| 543 | } else { | 543 | } else { |
| 544 | sib_reg1 = op->reg; | 544 | sib_reg1 = op->reg; |
| @@ -581,7 +581,7 @@ static inline int asm_modrm(TCCState *S, int reg, Operand *op) · 36 unmodified lines | |||
| 581 | #define REX_X 0x42 | 581 | #define REX_X 0x42 |
| 582 | #define REX_B 0x41 | 582 | #define REX_B 0x41 |
| 583 | 583 | ||
| 584 | static void asm_rex(TCCState *S, int width64, Operand *ops, int nb_ops, int *op_type, | 584 | static void asm_rex(TCCState* S, int width64, Operand *ops, int nb_ops, int *op_type, |
| 585 | int regi, int rmi) | 585 | int regi, int rmi) |
| 586 | { | 586 | { |
| 587 | unsigned char rex = width64 ? 0x48 : 0; | 587 | unsigned char rex = width64 ? 0x48 : 0; |
| @@ -705,13 +705,13 @@ ST_FUNC void asm_opcode(TCCState *S, int opcode) · 117 unmodified lines | |||
| 705 | seg_prefix = 0; | 705 | seg_prefix = 0; |
| 706 | alltypes = 0; | 706 | alltypes = 0; |
| 707 | for(;;) { | 707 | for(;;) { |
| 708 | if (S->tok == ';' || S->tok == TOK_LINEFEED) | 708 | if (S->tccpp_tok == ';' || S->tccpp_tok == TOK_LINEFEED) |
| 709 | break; | 709 | break; |
| 710 | if (nb_ops >= MAX_OPERANDS) { | 710 | if (nb_ops >= MAX_OPERANDS) { |
| 711 | tcc_error(S, "incorrect number of operands"); | 711 | tcc_error(S, "incorrect number of operands"); |
| 712 | } | 712 | } |
| 713 | parse_operand(S, pop); | 713 | parse_operand(S, pop); |
| 714 | if (S->tok == ':') { | 714 | if (S->tccpp_tok == ':') { |
| 715 | if (pop->type != OP_SEG || seg_prefix) | 715 | if (pop->type != OP_SEG || seg_prefix) |
| 716 | tcc_error(S, "incorrect prefix"); | 716 | tcc_error(S, "incorrect prefix"); |
| 717 | seg_prefix = segment_prefixes[pop->reg]; | 717 | seg_prefix = segment_prefixes[pop->reg]; |
| @@ -723,7 +723,7 @@ ST_FUNC void asm_opcode(TCCState *S, int opcode) · 5 unmodified lines | |||
| 723 | } | 723 | } |
| 724 | pop++; | 724 | pop++; |
| 725 | nb_ops++; | 725 | nb_ops++; |
| 726 | if (S->tok != ',') | 726 | if (S->tccpp_tok != ',') |
| 727 | break; | 727 | break; |
| 728 | next(S); | 728 | next(S); |
| 729 | } | 729 | } |
| @@ -1038,7 +1038,7 @@ again: · 308 unmodified lines | |||
| 1038 | esym = elfsym(S, ops[0].e.sym); | 1038 | esym = elfsym(S, ops[0].e.sym); |
| 1039 | if (!esym || esym->st_shndx != cur_text_section->sh_num) | 1039 | if (!esym || esym->st_shndx != cur_text_section->sh_num) |
| 1040 | goto no_short_jump; | 1040 | goto no_short_jump; |
| 1041 | jmp_disp = ops[0].e.v + esym->st_value - S->ind - 2 - (v >= 0xff); | 1041 | jmp_disp = ops[0].e.v + esym->st_value - S->tccgen_ind - 2 - (v >= 0xff); |
| 1042 | if (jmp_disp == (int8_t)jmp_disp) { | 1042 | if (jmp_disp == (int8_t)jmp_disp) { |
| 1043 | /* OK to generate jump */ | 1043 | /* OK to generate jump */ |
| 1044 | ops[0].e.sym = 0; | 1044 | ops[0].e.sym = 0; |
| @@ -1136,12 +1136,12 @@ again: · 91 unmodified lines | |||
| 1136 | 1136 | ||
| 1137 | /* after immediate operands, adjust pc-relative address */ | 1137 | /* after immediate operands, adjust pc-relative address */ |
| 1138 | if (pc) | 1138 | if (pc) |
| 1139 | add32le(cur_text_section->data + pc - 4, pc - S->ind); | 1139 | add32le(cur_text_section->data + pc - 4, pc - S->tccgen_ind); |
| 1140 | } | 1140 | } |
| 1141 | 1141 | ||
| 1142 | /* return the constraint priority (we allocate first the lowest | 1142 | /* return the constraint priority (we allocate first the lowest |
| 1143 | numbered constraints) */ | 1143 | numbered constraints) */ |
| 1144 | static inline int constraint_priority(TCCState *S, const char *str) | 1144 | static inline int constraint_priority(TCCState* S, const char *str) |
| 1145 | { | 1145 | { |
| 1146 | int priority, c, pr; | 1146 | int priority, c, pr; |
| 1147 | 1147 | ||
| @@ -1200,7 +1200,7 @@ static const char *skip_constraint_modifiers(const char *p) · 52 unmodified lines | |||
| 1200 | 1200 | ||
| 1201 | /* If T (a token) is of the form "%reg" returns the register | 1201 | /* If T (a token) is of the form "%reg" returns the register |
| 1202 | number and type, otherwise return -1. */ | 1202 | number and type, otherwise return -1. */ |
| 1203 | ST_FUNC int asm_parse_regvar (TCCState *S, int t) | 1203 | ST_FUNC int asm_parse_regvar (TCCState* S, int t) |
| 1204 | { | 1204 | { |
| 1205 | const char *s; | 1205 | const char *s; |
| 1206 | Operand op; | 1206 | Operand op; |
| @@ -1225,7 +1225,7 @@ ST_FUNC int asm_parse_regvar (TCCState *S, int t) · 18 unmodified lines | |||
| 1225 | 1225 | ||
| 1226 | #define is_reg_allocated(reg) (regs_allocated[reg] & reg_mask) | 1226 | #define is_reg_allocated(reg) (regs_allocated[reg] & reg_mask) |
| 1227 | 1227 | ||
| 1228 | ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands, | 1228 | ST_FUNC void asm_compute_constraints(TCCState* S, ASMOperand *operands, |
| 1229 | int nb_operands, int nb_outputs, | 1229 | int nb_operands, int nb_outputs, |
| 1230 | const uint8_t *clobber_regs, | 1230 | const uint8_t *clobber_regs, |
| 1231 | int *pout_reg) | 1231 | int *pout_reg) |
| @@ -1471,7 +1471,7 @@ ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands, · 239 unmodified lines | |||
| 1471 | #endif | 1471 | #endif |
| 1472 | } | 1472 | } |
| 1473 | 1473 | ||
| 1474 | ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, | 1474 | ST_FUNC void subst_asm_operand(TCCState* S, CString *add_str, |
| 1475 | SValue *sv, int modifier) | 1475 | SValue *sv, int modifier) |
| 1476 | { | 1476 | { |
| 1477 | int r, reg, size, val; | 1477 | int r, reg, size, val; |
| @@ -1593,7 +1593,7 @@ ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, · 115 unmodified lines | |||
| 1593 | } | 1593 | } |
| 1594 | 1594 | ||
| 1595 | /* generate prolog and epilog code for asm statement */ | 1595 | /* generate prolog and epilog code for asm statement */ |
| 1596 | ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands, | 1596 | ST_FUNC void asm_gen_code(TCCState* S, ASMOperand *operands, int nb_operands, |
| 1597 | int nb_outputs, int is_output, | 1597 | int nb_outputs, int is_output, |
| 1598 | uint8_t *clobber_regs, | 1598 | uint8_t *clobber_regs, |
| 1599 | int out_reg) | 1599 | int out_reg) |
| @@ -1697,7 +1697,7 @@ ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands, · 97 unmodified lines | |||
| 1697 | } | 1697 | } |
| 1698 | } | 1698 | } |
| 1699 | 1699 | ||
| 1700 | ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str) | 1700 | ST_FUNC void asm_clobber(TCCState* S, uint8_t *clobber_regs, const char *str) |
| 1701 | { | 1701 | { |
| 1702 | int reg; | 1702 | int reg; |
| 1703 | #ifdef TCC_TARGET_X86_64 | 1703 | #ifdef TCC_TARGET_X86_64 |
| @@ -100,24 +100,24 @@ ST_DATA const int reg_classes[NB_REGS] = { · 99 unmodified lines | |||
| 100 | static unsigned long func_sub_sp_offset; | 100 | static unsigned long func_sub_sp_offset; |
| 101 | static int func_ret_sub; | 101 | static int func_ret_sub; |
| 102 | #ifdef CONFIG_TCC_BCHECK | 102 | #ifdef CONFIG_TCC_BCHECK |
| 103 | static void gen_bounds_prolog(TCCState *S); | 103 | static void gen_bounds_prolog(TCCState* S); |
| 104 | static void gen_bounds_epilog(TCCState *S); | 104 | static void gen_bounds_epilog(TCCState* S); |
| 105 | #endif | 105 | #endif |
| 106 | 106 | ||
| 107 | /* XXX: make it faster ? */ | 107 | /* XXX: make it faster ? */ |
| 108 | ST_FUNC void g(TCCState *S, int c) | 108 | ST_FUNC void g(TCCState* S, int c) |
| 109 | { | 109 | { |
| 110 | int ind1; | 110 | int ind1; |
| 111 | if (S->nocode_wanted) | 111 | if (S->tccgen_nocode_wanted) |
| 112 | return; | 112 | return; |
| 113 | ind1 = S->ind + 1; | 113 | ind1 = S->tccgen_ind + 1; |
| 114 | if (ind1 > cur_text_section->data_allocated) | 114 | if (ind1 > cur_text_section->data_allocated) |
| 115 | section_realloc(S, cur_text_section, ind1); | 115 | section_realloc(S, cur_text_section, ind1); |
| 116 | cur_text_section->data[S->ind] = c; | 116 | cur_text_section->data[S->tccgen_ind] = c; |
| 117 | S->ind = ind1; | 117 | S->tccgen_ind = ind1; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | ST_FUNC void o(TCCState *S, unsigned int c) | 120 | ST_FUNC void o(TCCState* S, unsigned int c) |
| 121 | { | 121 | { |
| 122 | while (c) { | 122 | while (c) { |
| 123 | g(S, c); | 123 | g(S, c); |
| @@ -125,13 +125,13 @@ ST_FUNC void o(TCCState *S, unsigned int c) · 1 unmodified line | |||
| 125 | } | 125 | } |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | ST_FUNC void gen_le16(TCCState *S, int v) | 128 | ST_FUNC void gen_le16(TCCState* S, int v) |
| 129 | { | 129 | { |
| 130 | g(S, v); | 130 | g(S, v); |
| 131 | g(S, v >> 8); | 131 | g(S, v >> 8); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | ST_FUNC void gen_le32(TCCState *S, int c) | 134 | ST_FUNC void gen_le32(TCCState* S, int c) |
| 135 | { | 135 | { |
| 136 | g(S, c); | 136 | g(S, c); |
| 137 | g(S, c >> 8); | 137 | g(S, c >> 8); |
| @@ -140,7 +140,7 @@ ST_FUNC void gen_le32(TCCState *S, int c) · 2 unmodified lines | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /* output a symbol and patch all calls to it */ | 142 | /* output a symbol and patch all calls to it */ |
| 143 | ST_FUNC void gsym_addr(TCCState *S, int t, int a) | 143 | ST_FUNC void gsym_addr(TCCState* S, int t, int a) |
| 144 | { | 144 | { |
| 145 | while (t) { | 145 | while (t) { |
| 146 | unsigned char *ptr = cur_text_section->data + t; | 146 | unsigned char *ptr = cur_text_section->data + t; |
| @@ -151,18 +151,18 @@ ST_FUNC void gsym_addr(TCCState *S, int t, int a) · 4 unmodified lines | |||
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | /* instruction + 4 bytes data. Return the address of the data */ | 153 | /* instruction + 4 bytes data. Return the address of the data */ |
| 154 | static int oad(TCCState *S, int c, int s) | 154 | static int oad(TCCState* S, int c, int s) |
| 155 | { | 155 | { |
| 156 | int t; | 156 | int t; |
| 157 | if (S->nocode_wanted) | 157 | if (S->tccgen_nocode_wanted) |
| 158 | return s; | 158 | return s; |
| 159 | o(S, c); | 159 | o(S, c); |
| 160 | t = S->ind; | 160 | t = S->tccgen_ind; |
| 161 | gen_le32(S, s); | 161 | gen_le32(S, s); |
| 162 | return t; | 162 | return t; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | ST_FUNC void gen_fill_nops(TCCState *S, int bytes) | 165 | ST_FUNC void gen_fill_nops(TCCState* S, int bytes) |
| 166 | { | 166 | { |
| 167 | while (bytes--) | 167 | while (bytes--) |
| 168 | g(S, 0x90); | 168 | g(S, 0x90); |
| @@ -172,23 +172,23 @@ ST_FUNC void gen_fill_nops(TCCState *S, int bytes) · 3 unmodified lines | |||
| 172 | #define gjmp2(s, instr,lbl) oad(s, instr,lbl) | 172 | #define gjmp2(s, instr,lbl) oad(s, instr,lbl) |
| 173 | 173 | ||
| 174 | /* output constant with relocation if 'r & VT_SYM' is true */ | 174 | /* output constant with relocation if 'r & VT_SYM' is true */ |
| 175 | ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c) | 175 | ST_FUNC void gen_addr32(TCCState* S, int r, Sym *sym, int c) |
| 176 | { | 176 | { |
| 177 | if (r & VT_SYM) | 177 | if (r & VT_SYM) |
| 178 | greloc(S, cur_text_section, sym, S->ind, R_386_32); | 178 | greloc(S, cur_text_section, sym, S->tccgen_ind, R_386_32); |
| 179 | gen_le32(S, c); | 179 | gen_le32(S, c); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | ST_FUNC void gen_addrpc32(TCCState *S, int r, Sym *sym, int c) | 182 | ST_FUNC void gen_addrpc32(TCCState* S, int r, Sym *sym, int c) |
| 183 | { | 183 | { |
| 184 | if (r & VT_SYM) | 184 | if (r & VT_SYM) |
| 185 | greloc(S, cur_text_section, sym, S->ind, R_386_PC32); | 185 | greloc(S, cur_text_section, sym, S->tccgen_ind, R_386_PC32); |
| 186 | gen_le32(S, c - 4); | 186 | gen_le32(S, c - 4); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | /* generate a modrm reference. 'op_reg' contains the additional 3 | 189 | /* generate a modrm reference. 'op_reg' contains the additional 3 |
| 190 | opcode bits */ | 190 | opcode bits */ |
| 191 | static void gen_modrm(TCCState *S, int op_reg, int r, Sym *sym, int c) | 191 | static void gen_modrm(TCCState* S, int op_reg, int r, Sym *sym, int c) |
| 192 | { | 192 | { |
| 193 | op_reg = op_reg << 3; | 193 | op_reg = op_reg << 3; |
| 194 | if ((r & VT_VALMASK) == VT_CONST) { | 194 | if ((r & VT_VALMASK) == VT_CONST) { |
| @@ -210,7 +210,7 @@ static void gen_modrm(TCCState *S, int op_reg, int r, Sym *sym, int c) · 15 unmodified lines | |||
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | /* load 'r' from value 'sv' */ | 212 | /* load 'r' from value 'sv' */ |
| 213 | ST_FUNC void load(TCCState *S, int r, SValue *sv) | 213 | ST_FUNC void load(TCCState* S, int r, SValue *sv) |
| 214 | { | 214 | { |
| 215 | int v, t, ft, fc, fr; | 215 | int v, t, ft, fc, fr; |
| 216 | SValue v1; | 216 | SValue v1; |
| @@ -290,7 +290,7 @@ ST_FUNC void load(TCCState *S, int r, SValue *sv) · 73 unmodified lines | |||
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | /* store register 'r' in lvalue 'v' */ | 292 | /* store register 'r' in lvalue 'v' */ |
| 293 | ST_FUNC void store(TCCState *S, int r, SValue *v) | 293 | ST_FUNC void store(TCCState* S, int r, SValue *v) |
| 294 | { | 294 | { |
| 295 | int fr, bt, ft, fc; | 295 | int fr, bt, ft, fc; |
| 296 | 296 | ||
| @@ -332,7 +332,7 @@ ST_FUNC void store(TCCState *S, int r, SValue *v) · 35 unmodified lines | |||
| 332 | } | 332 | } |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | static void gadd_sp(TCCState *S, int val) | 335 | static void gadd_sp(TCCState* S, int val) |
| 336 | { | 336 | { |
| 337 | if (val == (char)val) { | 337 | if (val == (char)val) { |
| 338 | o(S, 0xc483); | 338 | o(S, 0xc483); |
| @@ -343,24 +343,24 @@ static void gadd_sp(TCCState *S, int val) · 4 unmodified lines | |||
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | #if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_PE | 345 | #if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_PE |
| 346 | static void gen_static_call(TCCState *S, int v) | 346 | static void gen_static_call(TCCState* S, int v) |
| 347 | { | 347 | { |
| 348 | Sym *sym; | 348 | Sym *sym; |
| 349 | 349 | ||
| 350 | sym = external_helper_sym(S, v); | 350 | sym = external_helper_sym(S, v); |
| 351 | oad(S, 0xe8, -4); | 351 | oad(S, 0xe8, -4); |
| 352 | greloc(S, cur_text_section, sym, S->ind-4, R_386_PC32); | 352 | greloc(S, cur_text_section, sym, S->tccgen_ind-4, R_386_PC32); |
| 353 | } | 353 | } |
| 354 | #endif | 354 | #endif |
| 355 | 355 | ||
| 356 | /* 'is_jmp' is '1' if it is a jump */ | 356 | /* 'is_jmp' is '1' if it is a jump */ |
| 357 | static void gcall_or_jmp(TCCState *S, int is_jmp) | 357 | static void gcall_or_jmp(TCCState* S, int is_jmp) |
| 358 | { | 358 | { |
| 359 | int r; | 359 | int r; |
| 360 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && (S->vtop->r & VT_SYM)) { | 360 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && (S->tccgen_vtop->r & VT_SYM)) { |
| 361 | /* constant and relocation case */ | 361 | /* constant and relocation case */ |
| 362 | greloc(S, cur_text_section, S->vtop->sym, S->ind + 1, R_386_PC32); | 362 | greloc(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind + 1, R_386_PC32); |
| 363 | oad(S, 0xe8 + is_jmp, S->vtop->c.i - 4); /* call/jmp im */ | 363 | oad(S, 0xe8 + is_jmp, S->tccgen_vtop->c.i - 4); /* call/jmp im */ |
| 364 | } else { | 364 | } else { |
| 365 | /* otherwise, indirect call */ | 365 | /* otherwise, indirect call */ |
| 366 | r = gv(S, RC_INT); | 366 | r = gv(S, RC_INT); |
| @@ -402,7 +402,7 @@ ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align, int · 35 unmodified lines | |||
| 402 | /* Generate function call. The function address is pushed first, then | 402 | /* Generate function call. The function address is pushed first, then |
| 403 | all the parameters in call order. This functions pops all the | 403 | all the parameters in call order. This functions pops all the |
| 404 | parameters and the function address. */ | 404 | parameters and the function address. */ |
| 405 | ST_FUNC void gfunc_call(TCCState *S, int nb_args) | 405 | ST_FUNC void gfunc_call(TCCState* S, int nb_args) |
| 406 | { | 406 | { |
| 407 | int size, align, r, args_size, i, func_call; | 407 | int size, align, r, args_size, i, func_call; |
| 408 | Sym *func_sym; | 408 | Sym *func_sym; |
| @@ -414,8 +414,8 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 5 unmodified lines | |||
| 414 | 414 | ||
| 415 | args_size = 0; | 415 | args_size = 0; |
| 416 | for(i = 0;i < nb_args; i++) { | 416 | for(i = 0;i < nb_args; i++) { |
| 417 | if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) { | 417 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) { |
| 418 | size = type_size(&S->vtop->type, &align); | 418 | size = type_size(&S->tccgen_vtop->type, &align); |
| 419 | /* align to stack align size */ | 419 | /* align to stack align size */ |
| 420 | size = (size + 3) & ~3; | 420 | size = (size + 3) & ~3; |
| 421 | /* allocate the necessary size on stack */ | 421 | /* allocate the necessary size on stack */ |
| @@ -434,15 +434,15 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 12 unmodified lines | |||
| 434 | r = get_reg(S, RC_INT); | 434 | r = get_reg(S, RC_INT); |
| 435 | o(S, 0xe089 + (r << 8)); /* mov %esp, r */ | 435 | o(S, 0xe089 + (r << 8)); /* mov %esp, r */ |
| 436 | } | 436 | } |
| 437 | vset(S, &S->vtop->type, r | VT_LVAL, 0); | 437 | vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0); |
| 438 | vswap(S); | 438 | vswap(S); |
| 439 | vstore(S); | 439 | vstore(S); |
| 440 | args_size += size; | 440 | args_size += size; |
| 441 | } else if (is_float(S->vtop->type.t)) { | 441 | } else if (is_float(S->tccgen_vtop->type.t)) { |
| 442 | gv(S, RC_FLOAT); /* only one float register */ | 442 | gv(S, RC_FLOAT); /* only one float register */ |
| 443 | if ((S->vtop->type.t & VT_BTYPE) == VT_FLOAT) | 443 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FLOAT) |
| 444 | size = 4; | 444 | size = 4; |
| 445 | else if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE) | 445 | else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE) |
| 446 | size = 8; | 446 | size = 8; |
| 447 | else | 447 | else |
| 448 | size = 12; | 448 | size = 12; |
| @@ -458,19 +458,19 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 9 unmodified lines | |||
| 458 | /* simple type (currently always same size) */ | 458 | /* simple type (currently always same size) */ |
| 459 | /* XXX: implicit cast ? */ | 459 | /* XXX: implicit cast ? */ |
| 460 | r = gv(S, RC_INT); | 460 | r = gv(S, RC_INT); |
| 461 | if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) { | 461 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) { |
| 462 | size = 8; | 462 | size = 8; |
| 463 | o(S, 0x50 + S->vtop->r2); /* push r */ | 463 | o(S, 0x50 + S->tccgen_vtop->r2); /* push r */ |
| 464 | } else { | 464 | } else { |
| 465 | size = 4; | 465 | size = 4; |
| 466 | } | 466 | } |
| 467 | o(S, 0x50 + r); /* push r */ | 467 | o(S, 0x50 + r); /* push r */ |
| 468 | args_size += size; | 468 | args_size += size; |
| 469 | } | 469 | } |
| 470 | S->vtop--; | 470 | S->tccgen_vtop--; |
| 471 | } | 471 | } |
| 472 | save_regs(S, 0); /* save used temporary registers */ | 472 | save_regs(S, 0); /* save used temporary registers */ |
| 473 | func_sym = S->vtop->type.ref; | 473 | func_sym = S->tccgen_vtop->type.ref; |
| 474 | func_call = func_sym->f.func_call; | 474 | func_call = func_sym->f.func_call; |
| 475 | /* fast call case */ | 475 | /* fast call case */ |
| 476 | if ((func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) || | 476 | if ((func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) || |
| @@ -493,7 +493,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 16 unmodified lines | |||
| 493 | } | 493 | } |
| 494 | } | 494 | } |
| 495 | #if !defined(TCC_TARGET_PE) && !TARGETOS_FreeBSD || TARGETOS_OpenBSD | 495 | #if !defined(TCC_TARGET_PE) && !TARGETOS_FreeBSD || TARGETOS_OpenBSD |
| 496 | else if ((S->vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT) | 496 | else if ((S->tccgen_vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT) |
| 497 | args_size -= 4; | 497 | args_size -= 4; |
| 498 | #endif | 498 | #endif |
| 499 | 499 | ||
| @@ -501,7 +501,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 1 unmodified line | |||
| 501 | 501 | ||
| 502 | if (args_size && func_call != FUNC_STDCALL && func_call != FUNC_FASTCALLW) | 502 | if (args_size && func_call != FUNC_STDCALL && func_call != FUNC_FASTCALLW) |
| 503 | gadd_sp(S, args_size); | 503 | gadd_sp(S, args_size); |
| 504 | S->vtop--; | 504 | S->tccgen_vtop--; |
| 505 | } | 505 | } |
| 506 | 506 | ||
| 507 | #ifdef TCC_TARGET_PE | 507 | #ifdef TCC_TARGET_PE |
| @@ -511,7 +511,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 3 unmodified lines | |||
| 511 | #endif | 511 | #endif |
| 512 | 512 | ||
| 513 | /* generate function prolog of type 't' */ | 513 | /* generate function prolog of type 't' */ |
| 514 | ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) | 514 | ST_FUNC void gfunc_prolog(TCCState* S, Sym *func_sym) |
| 515 | { | 515 | { |
| 516 | CType *func_type = &func_sym->type; | 516 | CType *func_type = &func_sym->type; |
| 517 | int addr, align, size, func_call, fastcall_nb_regs; | 517 | int addr, align, size, func_call, fastcall_nb_regs; |
| @@ -523,7 +523,7 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 5 unmodified lines | |||
| 523 | sym = func_type->ref; | 523 | sym = func_type->ref; |
| 524 | func_call = sym->f.func_call; | 524 | func_call = sym->f.func_call; |
| 525 | addr = 8; | 525 | addr = 8; |
| 526 | S->loc = 0; | 526 | S->tccgen_loc = 0; |
| 527 | S->tccgen_func_vc = 0; | 527 | S->tccgen_func_vc = 0; |
| 528 | 528 | ||
| 529 | if (func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) { | 529 | if (func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) { |
| @@ -538,8 +538,8 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 8 unmodified lines | |||
| 538 | } | 538 | } |
| 539 | param_index = 0; | 539 | param_index = 0; |
| 540 | 540 | ||
| 541 | S->ind += FUNC_PROLOG_SIZE; | 541 | S->tccgen_ind += FUNC_PROLOG_SIZE; |
| 542 | func_sub_sp_offset = S->ind; | 542 | func_sub_sp_offset = S->tccgen_ind; |
| 543 | /* if the function returns a structure, then add an | 543 | /* if the function returns a structure, then add an |
| 544 | implicit pointer parameter */ | 544 | implicit pointer parameter */ |
| 545 | #if defined(TCC_TARGET_PE) || TARGETOS_FreeBSD || TARGETOS_OpenBSD | 545 | #if defined(TCC_TARGET_PE) || TARGETOS_FreeBSD || TARGETOS_OpenBSD |
| @@ -567,10 +567,10 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 21 unmodified lines | |||
| 567 | #endif | 567 | #endif |
| 568 | if (param_index < fastcall_nb_regs) { | 568 | if (param_index < fastcall_nb_regs) { |
| 569 | /* save FASTCALL register */ | 569 | /* save FASTCALL register */ |
| 570 | S->loc -= 4; | 570 | S->tccgen_loc -= 4; |
| 571 | o(S, 0x89); /* movl */ | 571 | o(S, 0x89); /* movl */ |
| 572 | gen_modrm(S, fastcall_regs_ptr[param_index], VT_LOCAL, NULL, S->loc); | 572 | gen_modrm(S, fastcall_regs_ptr[param_index], VT_LOCAL, NULL, S->tccgen_loc); |
| 573 | param_addr = S->loc; | 573 | param_addr = S->tccgen_loc; |
| 574 | } else { | 574 | } else { |
| 575 | param_addr = addr; | 575 | param_addr = addr; |
| 576 | addr += size; | 576 | addr += size; |
| @@ -595,7 +595,7 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 18 unmodified lines | |||
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | /* generate function epilog */ | 597 | /* generate function epilog */ |
| 598 | ST_FUNC void gfunc_epilog(TCCState *S) | 598 | ST_FUNC void gfunc_epilog(TCCState* S) |
| 599 | { | 599 | { |
| 600 | addr_t v, saved_ind; | 600 | addr_t v, saved_ind; |
| 601 | 601 | ||
| @@ -605,7 +605,7 @@ ST_FUNC void gfunc_epilog(TCCState *S) · 3 unmodified lines | |||
| 605 | #endif | 605 | #endif |
| 606 | 606 | ||
| 607 | /* align local size to word & save local variables */ | 607 | /* align local size to word & save local variables */ |
| 608 | v = (-S->loc + 3) & -4; | 608 | v = (-S->tccgen_loc + 3) & -4; |
| 609 | 609 | ||
| 610 | #if USE_EBX | 610 | #if USE_EBX |
| 611 | o(S, 0x8b); | 611 | o(S, 0x8b); |
| @@ -620,8 +620,8 @@ ST_FUNC void gfunc_epilog(TCCState *S) · 8 unmodified lines | |||
| 620 | g(S, func_ret_sub); | 620 | g(S, func_ret_sub); |
| 621 | g(S, func_ret_sub >> 8); | 621 | g(S, func_ret_sub >> 8); |
| 622 | } | 622 | } |
| 623 | saved_ind = S->ind; | 623 | saved_ind = S->tccgen_ind; |
| 624 | S->ind = func_sub_sp_offset - FUNC_PROLOG_SIZE; | 624 | S->tccgen_ind = func_sub_sp_offset - FUNC_PROLOG_SIZE; |
| 625 | #ifdef TCC_TARGET_PE | 625 | #ifdef TCC_TARGET_PE |
| 626 | if (v >= 4096) { | 626 | if (v >= 4096) { |
| 627 | oad(S, 0xb8, v); /* mov stacksize, %eax */ | 627 | oad(S, 0xb8, v); /* mov stacksize, %eax */ |
| @@ -637,33 +637,33 @@ ST_FUNC void gfunc_epilog(TCCState *S) · 9 unmodified lines | |||
| 637 | #endif | 637 | #endif |
| 638 | } | 638 | } |
| 639 | o(S, 0x53 * USE_EBX); /* push ebx */ | 639 | o(S, 0x53 * USE_EBX); /* push ebx */ |
| 640 | S->ind = saved_ind; | 640 | S->tccgen_ind = saved_ind; |
| 641 | } | 641 | } |
| 642 | 642 | ||
| 643 | /* generate a jump to a label */ | 643 | /* generate a jump to a label */ |
| 644 | ST_FUNC int gjmp(TCCState *S, int t) | 644 | ST_FUNC int gjmp(TCCState* S, int t) |
| 645 | { | 645 | { |
| 646 | return gjmp2(S, 0xe9, t); | 646 | return gjmp2(S, 0xe9, t); |
| 647 | } | 647 | } |
| 648 | 648 | ||
| 649 | /* generate a jump to a fixed address */ | 649 | /* generate a jump to a fixed address */ |
| 650 | ST_FUNC void gjmp_addr(TCCState *S, int a) | 650 | ST_FUNC void gjmp_addr(TCCState* S, int a) |
| 651 | { | 651 | { |
| 652 | int r; | 652 | int r; |
| 653 | r = a - S->ind - 2; | 653 | r = a - S->tccgen_ind - 2; |
| 654 | if (r == (char)r) { | 654 | if (r == (char)r) { |
| 655 | g(S, 0xeb); | 655 | g(S, 0xeb); |
| 656 | g(S, r); | 656 | g(S, r); |
| 657 | } else { | 657 | } else { |
| 658 | oad(S, 0xe9, a - S->ind - 5); | 658 | oad(S, 0xe9, a - S->tccgen_ind - 5); |
| 659 | } | 659 | } |
| 660 | } | 660 | } |
| 661 | 661 | ||
| 662 | #if 0 | 662 | #if 0 |
| 663 | /* generate a jump to a fixed address */ | 663 | /* generate a jump to a fixed address */ |
| 664 | ST_FUNC void gjmp_cond_addr(TCCState *S, int a, int op) | 664 | ST_FUNC void gjmp_cond_addr(TCCState* S, int a, int op) |
| 665 | { | 665 | { |
| 666 | int r = a - S->ind - 2; | 666 | int r = a - S->tccgen_ind - 2; |
| 667 | if (r == (char)r) | 667 | if (r == (char)r) |
| 668 | g(S, op - 32), g(r); | 668 | g(S, op - 32), g(r); |
| 669 | else | 669 | else |
| @@ -671,7 +671,7 @@ ST_FUNC void gjmp_cond_addr(TCCState *S, int a, int op) · 1 unmodified line | |||
| 671 | } | 671 | } |
| 672 | #endif | 672 | #endif |
| 673 | 673 | ||
| 674 | ST_FUNC int gjmp_append(TCCState *S, int n, int t) | 674 | ST_FUNC int gjmp_append(TCCState* S, int n, int t) |
| 675 | { | 675 | { |
| 676 | void *p; | 676 | void *p; |
| 677 | /* insert vtop->c jump list in t */ | 677 | /* insert vtop->c jump list in t */ |
| @@ -685,14 +685,14 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t) · 7 unmodified lines | |||
| 685 | return t; | 685 | return t; |
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | ST_FUNC int gjmp_cond(TCCState *S, int op, int t) | 688 | ST_FUNC int gjmp_cond(TCCState* S, int op, int t) |
| 689 | { | 689 | { |
| 690 | g(S, 0x0f); | 690 | g(S, 0x0f); |
| 691 | t = gjmp2(S, op - 16, t); | 691 | t = gjmp2(S, op - 16, t); |
| 692 | return t; | 692 | return t; |
| 693 | } | 693 | } |
| 694 | 694 | ||
| 695 | ST_FUNC void gen_opi(TCCState *S, int op) | 695 | ST_FUNC void gen_opi(TCCState* S, int op) |
| 696 | { | 696 | { |
| 697 | int r, fr, opc, c; | 697 | int r, fr, opc, c; |
| 698 | 698 | ||
| @@ -701,12 +701,12 @@ ST_FUNC void gen_opi(TCCState *S, int op) · 2 unmodified lines | |||
| 701 | case TOK_ADDC1: /* add with carry generation */ | 701 | case TOK_ADDC1: /* add with carry generation */ |
| 702 | opc = 0; | 702 | opc = 0; |
| 703 | gen_op8: | 703 | gen_op8: |
| 704 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 704 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 705 | /* constant case */ | 705 | /* constant case */ |
| 706 | vswap(S); | 706 | vswap(S); |
| 707 | r = gv(S, RC_INT); | 707 | r = gv(S, RC_INT); |
| 708 | vswap(S); | 708 | vswap(S); |
| 709 | c = S->vtop->c.i; | 709 | c = S->tccgen_vtop->c.i; |
| 710 | if (c == (char)c) { | 710 | if (c == (char)c) { |
| 711 | /* generate inc and dec for smaller code */ | 711 | /* generate inc and dec for smaller code */ |
| 712 | if ((c == 1 || c == -1) && (op == '+' || op == '-')) { | 712 | if ((c == 1 || c == -1) && (op == '+' || op == '-')) { |
| @@ -723,12 +723,12 @@ ST_FUNC void gen_opi(TCCState *S, int op) · 10 unmodified lines | |||
| 723 | } | 723 | } |
| 724 | } else { | 724 | } else { |
| 725 | gv2(S, RC_INT, RC_INT); | 725 | gv2(S, RC_INT, RC_INT); |
| 726 | r = S->vtop[-1].r; | 726 | r = S->tccgen_vtop[-1].r; |
| 727 | fr = S->vtop[0].r; | 727 | fr = S->tccgen_vtop[0].r; |
| 728 | o(S, (opc << 3) | 0x01); | 728 | o(S, (opc << 3) | 0x01); |
| 729 | o(S, 0xc0 + r + fr * 8); | 729 | o(S, 0xc0 + r + fr * 8); |
| 730 | } | 730 | } |
| 731 | S->vtop--; | 731 | S->tccgen_vtop--; |
| 732 | if (op >= TOK_ULT && op <= TOK_GT) | 732 | if (op >= TOK_ULT && op <= TOK_GT) |
| 733 | vset_VT_CMP(S, op); | 733 | vset_VT_CMP(S, op); |
| 734 | break; | 734 | break; |
| @@ -753,9 +753,9 @@ ST_FUNC void gen_opi(TCCState *S, int op) · 18 unmodified lines | |||
| 753 | goto gen_op8; | 753 | goto gen_op8; |
| 754 | case '*': | 754 | case '*': |
| 755 | gv2(S, RC_INT, RC_INT); | 755 | gv2(S, RC_INT, RC_INT); |
| 756 | r = S->vtop[-1].r; | 756 | r = S->tccgen_vtop[-1].r; |
| 757 | fr = S->vtop[0].r; | 757 | fr = S->tccgen_vtop[0].r; |
| 758 | S->vtop--; | 758 | S->tccgen_vtop--; |
| 759 | o(S, 0xaf0f); /* imul fr, r */ | 759 | o(S, 0xaf0f); /* imul fr, r */ |
| 760 | o(S, 0xc0 + fr + r * 8); | 760 | o(S, 0xc0 + fr + r * 8); |
| 761 | break; | 761 | break; |
| @@ -769,23 +769,23 @@ ST_FUNC void gen_opi(TCCState *S, int op) · 7 unmodified lines | |||
| 769 | opc = 7; | 769 | opc = 7; |
| 770 | gen_shift: | 770 | gen_shift: |
| 771 | opc = 0xc0 | (opc << 3); | 771 | opc = 0xc0 | (opc << 3); |
| 772 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 772 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 773 | /* constant case */ | 773 | /* constant case */ |
| 774 | vswap(S); | 774 | vswap(S); |
| 775 | r = gv(S, RC_INT); | 775 | r = gv(S, RC_INT); |
| 776 | vswap(S); | 776 | vswap(S); |
| 777 | c = S->vtop->c.i & 0x1f; | 777 | c = S->tccgen_vtop->c.i & 0x1f; |
| 778 | o(S, 0xc1); /* shl/shr/sar $xxx, r */ | 778 | o(S, 0xc1); /* shl/shr/sar $xxx, r */ |
| 779 | o(S, opc | r); | 779 | o(S, opc | r); |
| 780 | g(S, c); | 780 | g(S, c); |
| 781 | } else { | 781 | } else { |
| 782 | /* we generate the shift in ecx */ | 782 | /* we generate the shift in ecx */ |
| 783 | gv2(S, RC_INT, RC_ECX); | 783 | gv2(S, RC_INT, RC_ECX); |
| 784 | r = S->vtop[-1].r; | 784 | r = S->tccgen_vtop[-1].r; |
| 785 | o(S, 0xd3); /* shl/shr/sar %cl, r */ | 785 | o(S, 0xd3); /* shl/shr/sar %cl, r */ |
| 786 | o(S, opc | r); | 786 | o(S, opc | r); |
| 787 | } | 787 | } |
| 788 | S->vtop--; | 788 | S->tccgen_vtop--; |
| 789 | break; | 789 | break; |
| 790 | case '/': | 790 | case '/': |
| 791 | case TOK_UDIV: | 791 | case TOK_UDIV: |
| @@ -796,16 +796,16 @@ ST_FUNC void gen_opi(TCCState *S, int op) · 4 unmodified lines | |||
| 796 | /* first operand must be in eax */ | 796 | /* first operand must be in eax */ |
| 797 | /* XXX: need better constraint for second operand */ | 797 | /* XXX: need better constraint for second operand */ |
| 798 | gv2(S, RC_EAX, RC_ECX); | 798 | gv2(S, RC_EAX, RC_ECX); |
| 799 | r = S->vtop[-1].r; | 799 | r = S->tccgen_vtop[-1].r; |
| 800 | fr = S->vtop[0].r; | 800 | fr = S->tccgen_vtop[0].r; |
| 801 | S->vtop--; | 801 | S->tccgen_vtop--; |
| 802 | save_reg(S, TREG_EDX); | 802 | save_reg(S, TREG_EDX); |
| 803 | /* save EAX too if used otherwise */ | 803 | /* save EAX too if used otherwise */ |
| 804 | save_reg_upstack(S, TREG_EAX, 1); | 804 | save_reg_upstack(S, TREG_EAX, 1); |
| 805 | if (op == TOK_UMULL) { | 805 | if (op == TOK_UMULL) { |
| 806 | o(S, 0xf7); /* mul fr */ | 806 | o(S, 0xf7); /* mul fr */ |
| 807 | o(S, 0xe0 + fr); | 807 | o(S, 0xe0 + fr); |
| 808 | S->vtop->r2 = TREG_EDX; | 808 | S->tccgen_vtop->r2 = TREG_EDX; |
| 809 | r = TREG_EAX; | 809 | r = TREG_EAX; |
| 810 | } else { | 810 | } else { |
| 811 | if (op == TOK_UDIV || op == TOK_UMOD) { | 811 | if (op == TOK_UDIV || op == TOK_UMOD) { |
| @@ -820,7 +820,7 @@ ST_FUNC void gen_opi(TCCState *S, int op) · 8 unmodified lines | |||
| 820 | else | 820 | else |
| 821 | r = TREG_EAX; | 821 | r = TREG_EAX; |
| 822 | } | 822 | } |
| 823 | S->vtop->r = r; | 823 | S->tccgen_vtop->r = r; |
| 824 | break; | 824 | break; |
| 825 | default: | 825 | default: |
| 826 | opc = 7; | 826 | opc = 7; |
| @@ -831,7 +831,7 @@ ST_FUNC void gen_opi(TCCState *S, int op) · 4 unmodified lines | |||
| 831 | /* generate a floating point operation 'v = t1 op t2' instruction. The | 831 | /* generate a floating point operation 'v = t1 op t2' instruction. The |
| 832 | two operands are guaranteed to have the same floating point type */ | 832 | two operands are guaranteed to have the same floating point type */ |
| 833 | /* XXX: need to use ST1 too */ | 833 | /* XXX: need to use ST1 too */ |
| 834 | ST_FUNC void gen_opf(TCCState *S, int op) | 834 | ST_FUNC void gen_opf(TCCState* S, int op) |
| 835 | { | 835 | { |
| 836 | int a, ft, fc, swapped, r; | 836 | int a, ft, fc, swapped, r; |
| 837 | 837 | ||
| @@ -842,17 +842,17 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 4 unmodified lines | |||
| 842 | } | 842 | } |
| 843 | 843 | ||
| 844 | /* convert constants to memory references */ | 844 | /* convert constants to memory references */ |
| 845 | if ((S->vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { | 845 | if ((S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| 846 | vswap(S); | 846 | vswap(S); |
| 847 | gv(S, RC_FLOAT); | 847 | gv(S, RC_FLOAT); |
| 848 | vswap(S); | 848 | vswap(S); |
| 849 | } | 849 | } |
| 850 | if ((S->vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) | 850 | if ((S->tccgen_vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) |
| 851 | gv(S, RC_FLOAT); | 851 | gv(S, RC_FLOAT); |
| 852 | 852 | ||
| 853 | /* must put at least one value in the floating point register */ | 853 | /* must put at least one value in the floating point register */ |
| 854 | if ((S->vtop[-1].r & VT_LVAL) && | 854 | if ((S->tccgen_vtop[-1].r & VT_LVAL) && |
| 855 | (S->vtop[0].r & VT_LVAL)) { | 855 | (S->tccgen_vtop[0].r & VT_LVAL)) { |
| 856 | vswap(S); | 856 | vswap(S); |
| 857 | gv(S, RC_FLOAT); | 857 | gv(S, RC_FLOAT); |
| 858 | vswap(S); | 858 | vswap(S); |
| @@ -860,13 +860,13 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 1 unmodified line | |||
| 860 | swapped = 0; | 860 | swapped = 0; |
| 861 | /* swap the stack if needed so that t1 is the register and t2 is | 861 | /* swap the stack if needed so that t1 is the register and t2 is |
| 862 | the memory reference */ | 862 | the memory reference */ |
| 863 | if (S->vtop[-1].r & VT_LVAL) { | 863 | if (S->tccgen_vtop[-1].r & VT_LVAL) { |
| 864 | vswap(S); | 864 | vswap(S); |
| 865 | swapped = 1; | 865 | swapped = 1; |
| 866 | } | 866 | } |
| 867 | if (op >= TOK_ULT && op <= TOK_GT) { | 867 | if (op >= TOK_ULT && op <= TOK_GT) { |
| 868 | /* load on stack second operand */ | 868 | /* load on stack second operand */ |
| 869 | load(S, TREG_ST0, S->vtop); | 869 | load(S, TREG_ST0, S->tccgen_vtop); |
| 870 | save_reg(S, TREG_EAX); /* eax is used by FP comparison code */ | 870 | save_reg(S, TREG_EAX); /* eax is used by FP comparison code */ |
| 871 | if (op == TOK_GE || op == TOK_GT) | 871 | if (op == TOK_GE || op == TOK_GT) |
| 872 | swapped = !swapped; | 872 | swapped = !swapped; |
| @@ -893,12 +893,12 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 20 unmodified lines | |||
| 893 | o(S, 0x45c4f6); /* test $0x45, %ah */ | 893 | o(S, 0x45c4f6); /* test $0x45, %ah */ |
| 894 | op = TOK_EQ; | 894 | op = TOK_EQ; |
| 895 | } | 895 | } |
| 896 | S->vtop--; | 896 | S->tccgen_vtop--; |
| 897 | vset_VT_CMP(S, op); | 897 | vset_VT_CMP(S, op); |
| 898 | } else { | 898 | } else { |
| 899 | /* no memory reference possible for long double operations */ | 899 | /* no memory reference possible for long double operations */ |
| 900 | if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { | 900 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { |
| 901 | load(S, TREG_ST0, S->vtop); | 901 | load(S, TREG_ST0, S->tccgen_vtop); |
| 902 | swapped = !swapped; | 902 | swapped = !swapped; |
| 903 | } | 903 | } |
| 904 | 904 | ||
| @@ -921,14 +921,14 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 16 unmodified lines | |||
| 921 | a++; | 921 | a++; |
| 922 | break; | 922 | break; |
| 923 | } | 923 | } |
| 924 | ft = S->vtop->type.t; | 924 | ft = S->tccgen_vtop->type.t; |
| 925 | fc = S->vtop->c.i; | 925 | fc = S->tccgen_vtop->c.i; |
| 926 | if ((ft & VT_BTYPE) == VT_LDOUBLE) { | 926 | if ((ft & VT_BTYPE) == VT_LDOUBLE) { |
| 927 | o(S, 0xde); /* fxxxp %st, %st(1) */ | 927 | o(S, 0xde); /* fxxxp %st, %st(1) */ |
| 928 | o(S, 0xc1 + (a << 3)); | 928 | o(S, 0xc1 + (a << 3)); |
| 929 | } else { | 929 | } else { |
| 930 | /* if saved lvalue, then we must reload it */ | 930 | /* if saved lvalue, then we must reload it */ |
| 931 | r = S->vtop->r; | 931 | r = S->tccgen_vtop->r; |
| 932 | if ((r & VT_VALMASK) == VT_LLOCAL) { | 932 | if ((r & VT_VALMASK) == VT_LLOCAL) { |
| 933 | SValue v1; | 933 | SValue v1; |
| 934 | r = get_reg(S, RC_INT); | 934 | r = get_reg(S, RC_INT); |
| @@ -944,48 +944,48 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 9 unmodified lines | |||
| 944 | o(S, 0xdc); | 944 | o(S, 0xdc); |
| 945 | else | 945 | else |
| 946 | o(S, 0xd8); | 946 | o(S, 0xd8); |
| 947 | gen_modrm(S, a, r, S->vtop->sym, fc); | 947 | gen_modrm(S, a, r, S->tccgen_vtop->sym, fc); |
| 948 | } | 948 | } |
| 949 | S->vtop--; | 949 | S->tccgen_vtop--; |
| 950 | } | 950 | } |
| 951 | } | 951 | } |
| 952 | 952 | ||
| 953 | /* convert integers to fp 't' type. Must handle 'int', 'unsigned int' | 953 | /* convert integers to fp 't' type. Must handle 'int', 'unsigned int' |
| 954 | and 'long long' cases. */ | 954 | and 'long long' cases. */ |
| 955 | ST_FUNC void gen_cvt_itof(TCCState *S, int t) | 955 | ST_FUNC void gen_cvt_itof(TCCState* S, int t) |
| 956 | { | 956 | { |
| 957 | save_reg(S, TREG_ST0); | 957 | save_reg(S, TREG_ST0); |
| 958 | gv(S, RC_INT); | 958 | gv(S, RC_INT); |
| 959 | if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) { | 959 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) { |
| 960 | /* signed long long to float/double/long double (unsigned case | 960 | /* signed long long to float/double/long double (unsigned case |
| 961 | is handled generically) */ | 961 | is handled generically) */ |
| 962 | o(S, 0x50 + S->vtop->r2); /* push r2 */ | 962 | o(S, 0x50 + S->tccgen_vtop->r2); /* push r2 */ |
| 963 | o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */ | 963 | o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */ |
| 964 | o(S, 0x242cdf); /* fildll (%esp) */ | 964 | o(S, 0x242cdf); /* fildll (%esp) */ |
| 965 | o(S, 0x08c483); /* add $8, %esp */ | 965 | o(S, 0x08c483); /* add $8, %esp */ |
| 966 | S->vtop->r2 = VT_CONST; | 966 | S->tccgen_vtop->r2 = VT_CONST; |
| 967 | } else if ((S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == | 967 | } else if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == |
| 968 | (VT_INT | VT_UNSIGNED)) { | 968 | (VT_INT | VT_UNSIGNED)) { |
| 969 | /* unsigned int to float/double/long double */ | 969 | /* unsigned int to float/double/long double */ |
| 970 | o(S, 0x6a); /* push $0 */ | 970 | o(S, 0x6a); /* push $0 */ |
| 971 | g(S, 0x00); | 971 | g(S, 0x00); |
| 972 | o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */ | 972 | o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */ |
| 973 | o(S, 0x242cdf); /* fildll (%esp) */ | 973 | o(S, 0x242cdf); /* fildll (%esp) */ |
| 974 | o(S, 0x08c483); /* add $8, %esp */ | 974 | o(S, 0x08c483); /* add $8, %esp */ |
| 975 | } else { | 975 | } else { |
| 976 | /* int to float/double/long double */ | 976 | /* int to float/double/long double */ |
| 977 | o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */ | 977 | o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */ |
| 978 | o(S, 0x2404db); /* fildl (%esp) */ | 978 | o(S, 0x2404db); /* fildl (%esp) */ |
| 979 | o(S, 0x04c483); /* add $4, %esp */ | 979 | o(S, 0x04c483); /* add $4, %esp */ |
| 980 | } | 980 | } |
| 981 | S->vtop->r2 = VT_CONST; | 981 | S->tccgen_vtop->r2 = VT_CONST; |
| 982 | S->vtop->r = TREG_ST0; | 982 | S->tccgen_vtop->r = TREG_ST0; |
| 983 | } | 983 | } |
| 984 | 984 | ||
| 985 | /* convert fp to int 't' type */ | 985 | /* convert fp to int 't' type */ |
| 986 | ST_FUNC void gen_cvt_ftoi(TCCState *S, int t) | 986 | ST_FUNC void gen_cvt_ftoi(TCCState* S, int t) |
| 987 | { | 987 | { |
| 988 | int bt = S->vtop->type.t & VT_BTYPE; | 988 | int bt = S->tccgen_vtop->type.t & VT_BTYPE; |
| 989 | if (bt == VT_FLOAT) | 989 | if (bt == VT_FLOAT) |
| 990 | vpush_helper_func(S, TOK___fixsfdi); | 990 | vpush_helper_func(S, TOK___fixsfdi); |
| 991 | else if (bt == VT_LDOUBLE) | 991 | else if (bt == VT_LDOUBLE) |
| @@ -995,20 +995,20 @@ ST_FUNC void gen_cvt_ftoi(TCCState *S, int t) · 3 unmodified lines | |||
| 995 | vswap(S); | 995 | vswap(S); |
| 996 | gfunc_call(S, 1); | 996 | gfunc_call(S, 1); |
| 997 | vpushi(S, 0); | 997 | vpushi(S, 0); |
| 998 | S->vtop->r = REG_IRET; | 998 | S->tccgen_vtop->r = REG_IRET; |
| 999 | if ((t & VT_BTYPE) == VT_LLONG) | 999 | if ((t & VT_BTYPE) == VT_LLONG) |
| 1000 | S->vtop->r2 = REG_IRE2; | 1000 | S->tccgen_vtop->r2 = REG_IRE2; |
| 1001 | } | 1001 | } |
| 1002 | 1002 | ||
| 1003 | /* convert from one floating point type to another */ | 1003 | /* convert from one floating point type to another */ |
| 1004 | ST_FUNC void gen_cvt_ftof(TCCState *S, int t) | 1004 | ST_FUNC void gen_cvt_ftof(TCCState* S, int t) |
| 1005 | { | 1005 | { |
| 1006 | /* all we have to do on i386 is to put the float in a register */ | 1006 | /* all we have to do on i386 is to put the float in a register */ |
| 1007 | gv(S, RC_FLOAT); | 1007 | gv(S, RC_FLOAT); |
| 1008 | } | 1008 | } |
| 1009 | 1009 | ||
| 1010 | /* char/short to int conversion */ | 1010 | /* char/short to int conversion */ |
| 1011 | ST_FUNC void gen_cvt_csti(TCCState *S, int t) | 1011 | ST_FUNC void gen_cvt_csti(TCCState* S, int t) |
| 1012 | { | 1012 | { |
| 1013 | int r, sz, xl; | 1013 | int r, sz, xl; |
| 1014 | r = gv(S, RC_INT); | 1014 | r = gv(S, RC_INT); |
| @@ -1021,39 +1021,39 @@ ST_FUNC void gen_cvt_csti(TCCState *S, int t) · 6 unmodified lines | |||
| 1021 | } | 1021 | } |
| 1022 | 1022 | ||
| 1023 | /* increment tcov counter */ | 1023 | /* increment tcov counter */ |
| 1024 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv) | 1024 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv) |
| 1025 | { | 1025 | { |
| 1026 | o(S, 0x0583); /* addl $1, xxx */ | 1026 | o(S, 0x0583); /* addl $1, xxx */ |
| 1027 | greloc(S, cur_text_section, sv->sym, S->ind, R_386_32); | 1027 | greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_386_32); |
| 1028 | gen_le32(S, 0); | 1028 | gen_le32(S, 0); |
| 1029 | o(S, 1); | 1029 | o(S, 1); |
| 1030 | o(S, 0x1583); /* addcl $0, xxx */ | 1030 | o(S, 0x1583); /* addcl $0, xxx */ |
| 1031 | greloc(S, cur_text_section, sv->sym, S->ind, R_386_32); | 1031 | greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_386_32); |
| 1032 | gen_le32(S, 4); | 1032 | gen_le32(S, 4); |
| 1033 | g(S, 0); | 1033 | g(S, 0); |
| 1034 | } | 1034 | } |
| 1035 | 1035 | ||
| 1036 | /* computed goto support */ | 1036 | /* computed goto support */ |
| 1037 | ST_FUNC void ggoto(TCCState *S) | 1037 | ST_FUNC void ggoto(TCCState* S) |
| 1038 | { | 1038 | { |
| 1039 | gcall_or_jmp(S, 1); | 1039 | gcall_or_jmp(S, 1); |
| 1040 | S->vtop--; | 1040 | S->tccgen_vtop--; |
| 1041 | } | 1041 | } |
| 1042 | 1042 | ||
| 1043 | /* bound check support functions */ | 1043 | /* bound check support functions */ |
| 1044 | #ifdef CONFIG_TCC_BCHECK | 1044 | #ifdef CONFIG_TCC_BCHECK |
| 1045 | 1045 | ||
| 1046 | static void gen_bounds_prolog(TCCState *S) | 1046 | static void gen_bounds_prolog(TCCState* S) |
| 1047 | { | 1047 | { |
| 1048 | /* leave some room for bound checking code */ | 1048 | /* leave some room for bound checking code */ |
| 1049 | S->func_bound_offset = lbounds_section->data_offset; | 1049 | S->func_bound_offset = lbounds_section->data_offset; |
| 1050 | S->func_bound_ind = S->ind; | 1050 | S->func_bound_ind = S->tccgen_ind; |
| 1051 | S->func_bound_add_epilog = 0; | 1051 | S->func_bound_add_epilog = 0; |
| 1052 | oad(S, 0xb8, 0); /* lbound section pointer */ | 1052 | oad(S, 0xb8, 0); /* lbound section pointer */ |
| 1053 | oad(S, 0xb8, 0); /* call to function */ | 1053 | oad(S, 0xb8, 0); /* call to function */ |
| 1054 | } | 1054 | } |
| 1055 | 1055 | ||
| 1056 | static void gen_bounds_epilog(TCCState *S) | 1056 | static void gen_bounds_epilog(TCCState* S) |
| 1057 | { | 1057 | { |
| 1058 | addr_t saved_ind; | 1058 | addr_t saved_ind; |
| 1059 | addr_t *bounds_ptr; | 1059 | addr_t *bounds_ptr; |
| @@ -1067,22 +1067,22 @@ static void gen_bounds_epilog(TCCState *S) · 7 unmodified lines | |||
| 1067 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); | 1067 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); |
| 1068 | *bounds_ptr = 0; | 1068 | *bounds_ptr = 0; |
| 1069 | 1069 | ||
| 1070 | sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section, | 1070 | sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section, |
| 1071 | S->func_bound_offset, lbounds_section->data_offset); | 1071 | S->func_bound_offset, lbounds_section->data_offset); |
| 1072 | 1072 | ||
| 1073 | /* generate bound local allocation */ | 1073 | /* generate bound local allocation */ |
| 1074 | if (offset_modified) { | 1074 | if (offset_modified) { |
| 1075 | saved_ind = S->ind; | 1075 | saved_ind = S->tccgen_ind; |
| 1076 | S->ind = S->func_bound_ind; | 1076 | S->tccgen_ind = S->func_bound_ind; |
| 1077 | greloc(S, cur_text_section, sym_data, S->ind + 1, R_386_32); | 1077 | greloc(S, cur_text_section, sym_data, S->tccgen_ind + 1, R_386_32); |
| 1078 | S->ind = S->ind + 5; | 1078 | S->tccgen_ind = S->tccgen_ind + 5; |
| 1079 | gen_static_call(S, TOK___bound_local_new); | 1079 | gen_static_call(S, TOK___bound_local_new); |
| 1080 | S->ind = saved_ind; | 1080 | S->tccgen_ind = saved_ind; |
| 1081 | } | 1081 | } |
| 1082 | 1082 | ||
| 1083 | /* generate bound check local freeing */ | 1083 | /* generate bound check local freeing */ |
| 1084 | o(S, 0x5250); /* save returned value, if any */ | 1084 | o(S, 0x5250); /* save returned value, if any */ |
| 1085 | greloc(S, cur_text_section, sym_data, S->ind + 1, R_386_32); | 1085 | greloc(S, cur_text_section, sym_data, S->tccgen_ind + 1, R_386_32); |
| 1086 | oad(S, 0xb8, 0); /* mov %eax, xxx */ | 1086 | oad(S, 0xb8, 0); /* mov %eax, xxx */ |
| 1087 | gen_static_call(S, TOK___bound_local_delete); | 1087 | gen_static_call(S, TOK___bound_local_delete); |
| 1088 | o(S, 0x585a); /* restore returned value, if any */ | 1088 | o(S, 0x585a); /* restore returned value, if any */ |
| @@ -1090,20 +1090,20 @@ static void gen_bounds_epilog(TCCState *S) · 1 unmodified line | |||
| 1090 | #endif | 1090 | #endif |
| 1091 | 1091 | ||
| 1092 | /* Save the stack pointer onto the stack */ | 1092 | /* Save the stack pointer onto the stack */ |
| 1093 | ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) { | 1093 | ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) { |
| 1094 | /* mov %esp,addr(%ebp)*/ | 1094 | /* mov %esp,addr(%ebp)*/ |
| 1095 | o(S, 0x89); | 1095 | o(S, 0x89); |
| 1096 | gen_modrm(S, TREG_ESP, VT_LOCAL, NULL, addr); | 1096 | gen_modrm(S, TREG_ESP, VT_LOCAL, NULL, addr); |
| 1097 | } | 1097 | } |
| 1098 | 1098 | ||
| 1099 | /* Restore the SP from a location on the stack */ | 1099 | /* Restore the SP from a location on the stack */ |
| 1100 | ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) { | 1100 | ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) { |
| 1101 | o(S, 0x8b); | 1101 | o(S, 0x8b); |
| 1102 | gen_modrm(S, TREG_ESP, VT_LOCAL, NULL, addr); | 1102 | gen_modrm(S, TREG_ESP, VT_LOCAL, NULL, addr); |
| 1103 | } | 1103 | } |
| 1104 | 1104 | ||
| 1105 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ | 1105 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ |
| 1106 | ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) { | 1106 | ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) { |
| 1107 | int use_call = 0; | 1107 | int use_call = 0; |
| 1108 | 1108 | ||
| 1109 | #if defined(CONFIG_TCC_BCHECK) | 1109 | #if defined(CONFIG_TCC_BCHECK) |
| @@ -233,7 +233,7 @@ PUB_FUNC char *tcc_fileextension (const char *name) · 232 unmodified lines | |||
| 233 | return e ? e : strchr(b, 0); | 233 | return e ? e : strchr(b, 0); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | ST_FUNC char *tcc_load_text(TCCState *S, int fd) | 236 | ST_FUNC char *tcc_load_text(TCCState* S, int fd) |
| 237 | { | 237 | { |
| 238 | int len = lseek(fd, 0, SEEK_END); | 238 | int len = lseek(fd, 0, SEEK_END); |
| 239 | char *buf = load_data(S, fd, 0, len + 1); | 239 | char *buf = load_data(S, fd, 0, len + 1); |
| @@ -275,12 +275,12 @@ PUB_FUNC void *tcc_mallocz_base(unsigned long size) · 35 unmodified lines | |||
| 275 | 275 | ||
| 276 | #ifndef MEM_DEBUG | 276 | #ifndef MEM_DEBUG |
| 277 | 277 | ||
| 278 | PUB_FUNC void tcc_free(TCCState *S, void *ptr) | 278 | PUB_FUNC void tcc_free(TCCState* S, void *ptr) |
| 279 | { | 279 | { |
| 280 | free(ptr); | 280 | free(ptr); |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | PUB_FUNC void *tcc_malloc(TCCState *S, unsigned long size) | 283 | PUB_FUNC void *tcc_malloc(TCCState* S, unsigned long size) |
| 284 | { | 284 | { |
| 285 | void *ptr; | 285 | void *ptr; |
| 286 | ptr = malloc(size); | 286 | ptr = malloc(size); |
| @@ -289,7 +289,7 @@ PUB_FUNC void *tcc_malloc(TCCState *S, unsigned long size) · 2 unmodified lines | |||
| 289 | return ptr; | 289 | return ptr; |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | PUB_FUNC void *tcc_mallocz(TCCState *S, unsigned long size) | 292 | PUB_FUNC void *tcc_mallocz(TCCState* S, unsigned long size) |
| 293 | { | 293 | { |
| 294 | void *ptr; | 294 | void *ptr; |
| 295 | ptr = tcc_malloc(S, size); | 295 | ptr = tcc_malloc(S, size); |
| @@ -298,7 +298,7 @@ PUB_FUNC void *tcc_mallocz(TCCState *S, unsigned long size) · 2 unmodified lines | |||
| 298 | return ptr; | 298 | return ptr; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | PUB_FUNC void *tcc_realloc(TCCState *S, void *ptr, unsigned long size) | 301 | PUB_FUNC void *tcc_realloc(TCCState* S, void *ptr, unsigned long size) |
| 302 | { | 302 | { |
| 303 | void *ptr1; | 303 | void *ptr1; |
| 304 | ptr1 = realloc(ptr, size); | 304 | ptr1 = realloc(ptr, size); |
| @@ -307,7 +307,7 @@ PUB_FUNC void *tcc_realloc(TCCState *S, void *ptr, unsigned long size) · 2 unmodified lines | |||
| 307 | return ptr1; | 307 | return ptr1; |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | PUB_FUNC char *tcc_strdup(TCCState *S, const char *str) | 310 | PUB_FUNC char *tcc_strdup(TCCState* S, const char *str) |
| 311 | { | 311 | { |
| 312 | char *ptr; | 312 | char *ptr; |
| 313 | ptr = tcc_malloc(S, strlen(str) + 1); | 313 | ptr = tcc_malloc(S, strlen(str) + 1); |
| @@ -361,7 +361,7 @@ static mem_debug_header_t *malloc_check(void *ptr, const char *msg) · 47 unmodified lines | |||
| 361 | return header; | 361 | return header; |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | PUB_FUNC void *tcc_malloc_debug(TCCState *S, unsigned long size, const char *file, int line) | 364 | PUB_FUNC void *tcc_malloc_debug(TCCState* S, unsigned long size, const char *file, int line) |
| 365 | { | 365 | { |
| 366 | int ofs; | 366 | int ofs; |
| 367 | mem_debug_header_t *header; | 367 | mem_debug_header_t *header; |
| @@ -392,7 +392,7 @@ PUB_FUNC void *tcc_malloc_debug(TCCState *S, unsigned long size, const char *fil · 24 unmodified lines | |||
| 392 | return MEM_USER_PTR(header); | 392 | return MEM_USER_PTR(header); |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | PUB_FUNC void tcc_free_debug(TCCState *S, void *ptr) | 395 | PUB_FUNC void tcc_free_debug(TCCState* S, void *ptr) |
| 396 | { | 396 | { |
| 397 | mem_debug_header_t *header; | 397 | mem_debug_header_t *header; |
| 398 | if (!ptr) | 398 | if (!ptr) |
| @@ -409,7 +409,7 @@ PUB_FUNC void tcc_free_debug(TCCState *S, void *ptr) · 10 unmodified lines | |||
| 409 | free(header); | 409 | free(header); |
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | PUB_FUNC void *tcc_mallocz_debug(TCCState *S, unsigned long size, const char *file, int line) | 412 | PUB_FUNC void *tcc_mallocz_debug(TCCState* S, unsigned long size, const char *file, int line) |
| 413 | { | 413 | { |
| 414 | void *ptr; | 414 | void *ptr; |
| 415 | ptr = tcc_malloc_debug(S, size,file,line); | 415 | ptr = tcc_malloc_debug(S, size,file,line); |
| @@ -417,7 +417,7 @@ PUB_FUNC void *tcc_mallocz_debug(TCCState *S, unsigned long size, const char *fi · 1 unmodified line | |||
| 417 | return ptr; | 417 | return ptr; |
| 418 | } | 418 | } |
| 419 | 419 | ||
| 420 | PUB_FUNC void *tcc_realloc_debug(TCCState *S, void *ptr, unsigned long size, const char *file, int line) | 420 | PUB_FUNC void *tcc_realloc_debug(TCCState* S, void *ptr, unsigned long size, const char *file, int line) |
| 421 | { | 421 | { |
| 422 | mem_debug_header_t *header; | 422 | mem_debug_header_t *header; |
| 423 | int mem_debug_chain_update = 0; | 423 | int mem_debug_chain_update = 0; |
| @@ -443,7 +443,7 @@ PUB_FUNC void *tcc_realloc_debug(TCCState *S, void *ptr, unsigned long size, con · 19 unmodified lines | |||
| 443 | return MEM_USER_PTR(header); | 443 | return MEM_USER_PTR(header); |
| 444 | } | 444 | } |
| 445 | 445 | ||
| 446 | PUB_FUNC char *tcc_strdup_debug(TCCState *S, const char *str, const char *file, int line) | 446 | PUB_FUNC char *tcc_strdup_debug(TCCState* S, const char *str, const char *file, int line) |
| 447 | { | 447 | { |
| 448 | char *ptr; | 448 | char *ptr; |
| 449 | ptr = tcc_malloc_debug(S, strlen(str) + 1, file, line); | 449 | ptr = tcc_malloc_debug(S, strlen(str) + 1, file, line); |
| @@ -532,7 +532,7 @@ int vio_close(vio_fd *fd) { · 82 unmodified lines | |||
| 532 | /********************************************************/ | 532 | /********************************************************/ |
| 533 | /* dynarrays */ | 533 | /* dynarrays */ |
| 534 | 534 | ||
| 535 | ST_FUNC void dynarray_add(TCCState *S, void *ptab, int *nb_ptr, void *data) | 535 | ST_FUNC void dynarray_add(TCCState* S, void *ptab, int *nb_ptr, void *data) |
| 536 | { | 536 | { |
| 537 | int nb, nb_alloc; | 537 | int nb, nb_alloc; |
| 538 | void **pp; | 538 | void **pp; |
| @@ -552,7 +552,7 @@ ST_FUNC void dynarray_add(TCCState *S, void *ptab, int *nb_ptr, void *data) · 13 unmodified lines | |||
| 552 | *nb_ptr = nb; | 552 | *nb_ptr = nb; |
| 553 | } | 553 | } |
| 554 | 554 | ||
| 555 | ST_FUNC void dynarray_reset(TCCState *S, void *pp, int *n) | 555 | ST_FUNC void dynarray_reset(TCCState* S, void *pp, int *n) |
| 556 | { | 556 | { |
| 557 | void **p; | 557 | void **p; |
| 558 | for (p = *(void***)pp; *n; ++p, --*n) | 558 | for (p = *(void***)pp; *n; ++p, --*n) |
| @@ -608,7 +608,7 @@ static void tcc_split_path(TCCState *S, void *p_ary, int *p_nb_ary, const char * · 49 unmodified lines | |||
| 608 | /* error1() modes */ | 608 | /* error1() modes */ |
| 609 | enum { ERROR_WARN, ERROR_NOABORT, ERROR_ERROR }; | 609 | enum { ERROR_WARN, ERROR_NOABORT, ERROR_ERROR }; |
| 610 | 610 | ||
| 611 | static void error1(TCCState *S, int mode, const char *fmt, va_list ap) | 611 | static void error1(TCCState* S, int mode, const char *fmt, va_list ap) |
| 612 | { | 612 | { |
| 613 | BufferedFile **pf, *f; | 613 | BufferedFile **pf, *f; |
| 614 | CString cs; | 614 | CString cs; |
| @@ -650,7 +650,7 @@ static void error1(TCCState *S, int mode, const char *fmt, va_list ap) · 35 unmodified lines | |||
| 650 | cstr_printf(S, &cs, "In file included from %s:%d:\n", | 650 | cstr_printf(S, &cs, "In file included from %s:%d:\n", |
| 651 | (*pf)->filename, (*pf)->line_num); | 651 | (*pf)->filename, (*pf)->line_num); |
| 652 | cstr_printf(S, &cs, "%s:%d: ", | 652 | cstr_printf(S, &cs, "%s:%d: ", |
| 653 | f->filename, (*pf)->line_num - !!(S->tok_flags & TOK_FLAG_BOL)); | 653 | f->filename, (*pf)->line_num - !!(S->tccpp_tok_flags & TOK_FLAG_BOL)); |
| 654 | } else if (S->current_filename) { | 654 | } else if (S->current_filename) { |
| 655 | cstr_printf(S, &cs, "%s: ", S->current_filename); | 655 | cstr_printf(S, &cs, "%s: ", S->current_filename); |
| 656 | } | 656 | } |
| @@ -699,7 +699,7 @@ LIBTCCAPI void *tcc_get_error_opaque(TCCState *S) · 42 unmodified lines | |||
| 699 | } | 699 | } |
| 700 | 700 | ||
| 701 | /* error without aborting current compilation */ | 701 | /* error without aborting current compilation */ |
| 702 | PUB_FUNC void _tcc_error_noabort(TCCState *S, const char *fmt, ...) | 702 | PUB_FUNC void _tcc_error_noabort(TCCState* S, const char *fmt, ...) |
| 703 | { | 703 | { |
| 704 | va_list ap; | 704 | va_list ap; |
| 705 | va_start(ap, fmt); | 705 | va_start(ap, fmt); |
| @@ -707,14 +707,14 @@ PUB_FUNC void _tcc_error_noabort(TCCState *S, const char *fmt, ...) · 1 unmodified line | |||
| 707 | va_end(ap); | 707 | va_end(ap); |
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | PUB_FUNC void _tcc_error(TCCState *S, const char *fmt, ...) | 710 | PUB_FUNC void _tcc_error(TCCState* S, const char *fmt, ...) |
| 711 | { | 711 | { |
| 712 | va_list ap; | 712 | va_list ap; |
| 713 | va_start(ap, fmt); | 713 | va_start(ap, fmt); |
| 714 | for (;;) error1(S, ERROR_ERROR, fmt, ap); | 714 | for (;;) error1(S, ERROR_ERROR, fmt, ap); |
| 715 | } | 715 | } |
| 716 | 716 | ||
| 717 | PUB_FUNC void _tcc_warning(TCCState *S, const char *fmt, ...) | 717 | PUB_FUNC void _tcc_warning(TCCState* S, const char *fmt, ...) |
| 718 | { | 718 | { |
| 719 | va_list ap; | 719 | va_list ap; |
| 720 | va_start(ap, fmt); | 720 | va_start(ap, fmt); |
| @@ -744,10 +744,10 @@ ST_FUNC void tcc_open_bf(TCCState *S, const char *filename, int initlen) · 23 unmodified lines | |||
| 744 | bf->fd = -1; | 744 | bf->fd = -1; |
| 745 | bf->prev = S->tccpp_file; | 745 | bf->prev = S->tccpp_file; |
| 746 | S->tccpp_file = bf; | 746 | S->tccpp_file = bf; |
| 747 | S->tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF; | 747 | S->tccpp_tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF; |
| 748 | } | 748 | } |
| 749 | 749 | ||
| 750 | ST_FUNC void tcc_close(TCCState *S) | 750 | ST_FUNC void tcc_close(TCCState* S) |
| 751 | { | 751 | { |
| 752 | BufferedFile *bf = S->tccpp_file; | 752 | BufferedFile *bf = S->tccpp_file; |
| 753 | if (bf->fd > 0) { | 753 | if (bf->fd > 0) { |
| @@ -1388,7 +1388,7 @@ static const char *skip_linker_arg(const char **str) · 634 unmodified lines | |||
| 1388 | return s2; | 1388 | return s2; |
| 1389 | } | 1389 | } |
| 1390 | 1390 | ||
| 1391 | static void copy_linker_arg(TCCState *S, char **pp, const char *s, int sep) | 1391 | static void copy_linker_arg(TCCState* S, char **pp, const char *s, int sep) |
| 1392 | { | 1392 | { |
| 1393 | const char *q = s; | 1393 | const char *q = s; |
| 1394 | char *p = *pp; | 1394 | char *p = *pp; |
| @@ -1723,7 +1723,7 @@ static void args_parser_add_file(TCCState *S, const char* filename, int filetype · 328 unmodified lines | |||
| 1723 | dynarray_add(S, &S->files, &S->nb_files, f); | 1723 | dynarray_add(S, &S->files, &S->nb_files, f); |
| 1724 | } | 1724 | } |
| 1725 | 1725 | ||
| 1726 | static int args_parser_make_argv(TCCState *S, const char *r, int *argc, char ***argv) | 1726 | static int args_parser_make_argv(TCCState* S, const char *r, int *argc, char ***argv) |
| 1727 | { | 1727 | { |
| 1728 | int ret = 0, q, c; | 1728 | int ret = 0, q, c; |
| 1729 | CString str; | 1729 | CString str; |
| @@ -9,9 +9,9 @@ · 8 unmodified lines | |||
| 9 | #define CONFIG_TCC_ASM | 9 | #define CONFIG_TCC_ASM |
| 10 | #define NB_ASM_REGS 32 | 10 | #define NB_ASM_REGS 32 |
| 11 | 11 | ||
| 12 | ST_FUNC void g(TCCState *S, int c); | 12 | ST_FUNC void g(TCCState* S, int c); |
| 13 | ST_FUNC void gen_le16(TCCState *S, int c); | 13 | ST_FUNC void gen_le16(TCCState* S, int c); |
| 14 | ST_FUNC void gen_le32(TCCState *S, int c); | 14 | ST_FUNC void gen_le32(TCCState* S, int c); |
| 15 | 15 | ||
| 16 | /*************************************************************/ | 16 | /*************************************************************/ |
| 17 | #else | 17 | #else |
| @@ -20,44 +20,44 @@ ST_FUNC void gen_le32(TCCState *S, int c); · 2 unmodified lines | |||
| 20 | #include "tcc.h" | 20 | #include "tcc.h" |
| 21 | 21 | ||
| 22 | /* XXX: make it faster ? */ | 22 | /* XXX: make it faster ? */ |
| 23 | ST_FUNC void g(TCCState *S, int c) | 23 | ST_FUNC void g(TCCState* S, int c) |
| 24 | { | 24 | { |
| 25 | int ind1; | 25 | int ind1; |
| 26 | if (S->nocode_wanted) | 26 | if (S->tccgen_nocode_wanted) |
| 27 | return; | 27 | return; |
| 28 | ind1 = S->ind + 1; | 28 | ind1 = S->tccgen_ind + 1; |
| 29 | if (ind1 > cur_text_section->data_allocated) | 29 | if (ind1 > cur_text_section->data_allocated) |
| 30 | section_realloc(S, cur_text_section, ind1); | 30 | section_realloc(S, cur_text_section, ind1); |
| 31 | cur_text_section->data[S->ind] = c; | 31 | cur_text_section->data[S->tccgen_ind] = c; |
| 32 | S->ind = ind1; | 32 | S->tccgen_ind = ind1; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | ST_FUNC void gen_le16 (TCCState *S, int i) | 35 | ST_FUNC void gen_le16 (TCCState* S, int i) |
| 36 | { | 36 | { |
| 37 | g(S, i); | 37 | g(S, i); |
| 38 | g(S, i>>8); | 38 | g(S, i>>8); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | ST_FUNC void gen_le32 (TCCState *S, int i) | 41 | ST_FUNC void gen_le32 (TCCState* S, int i) |
| 42 | { | 42 | { |
| 43 | int ind1; | 43 | int ind1; |
| 44 | if (S->nocode_wanted) | 44 | if (S->tccgen_nocode_wanted) |
| 45 | return; | 45 | return; |
| 46 | ind1 = S->ind + 4; | 46 | ind1 = S->tccgen_ind + 4; |
| 47 | if (ind1 > cur_text_section->data_allocated) | 47 | if (ind1 > cur_text_section->data_allocated) |
| 48 | section_realloc(S, cur_text_section, ind1); | 48 | section_realloc(S, cur_text_section, ind1); |
| 49 | cur_text_section->data[S->ind++] = i & 0xFF; | 49 | cur_text_section->data[S->tccgen_ind++] = i & 0xFF; |
| 50 | cur_text_section->data[S->ind++] = (i >> 8) & 0xFF; | 50 | cur_text_section->data[S->tccgen_ind++] = (i >> 8) & 0xFF; |
| 51 | cur_text_section->data[S->ind++] = (i >> 16) & 0xFF; | 51 | cur_text_section->data[S->tccgen_ind++] = (i >> 16) & 0xFF; |
| 52 | cur_text_section->data[S->ind++] = (i >> 24) & 0xFF; | 52 | cur_text_section->data[S->tccgen_ind++] = (i >> 24) & 0xFF; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe) | 55 | ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe) |
| 56 | { | 56 | { |
| 57 | gen_le32(S, pe->v); | 57 | gen_le32(S, pe->v); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | static void asm_emit_opcode(TCCState *S, uint32_t opcode) { | 60 | static void asm_emit_opcode(TCCState* S, uint32_t opcode) { |
| 61 | gen_le32(S, opcode); | 61 | gen_le32(S, opcode); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| @@ -128,12 +128,12 @@ static void parse_operand(TCCState *S, Operand *op) · 64 unmodified lines | |||
| 128 | 128 | ||
| 129 | op->type = 0; | 129 | op->type = 0; |
| 130 | 130 | ||
| 131 | if ((reg = asm_parse_regvar(S, S->tok)) != -1) { | 131 | if ((reg = asm_parse_regvar(S, S->tccpp_tok)) != -1) { |
| 132 | next(S); // skip register name | 132 | next(S); // skip register name |
| 133 | op->type = OP_REG; | 133 | op->type = OP_REG; |
| 134 | op->reg = (uint8_t) reg; | 134 | op->reg = (uint8_t) reg; |
| 135 | return; | 135 | return; |
| 136 | } else if (S->tok == '$') { | 136 | } else if (S->tccpp_tok == '$') { |
| 137 | /* constant value */ | 137 | /* constant value */ |
| 138 | next(S); // skip '#' or '$' | 138 | next(S); // skip '#' or '$' |
| 139 | } | 139 | } |
| @@ -207,11 +207,11 @@ static void asm_emit_u(TCCState *S, int token, uint32_t opcode, const Operand* r · 67 unmodified lines | |||
| 207 | gen_le32(S, opcode | ENCODE_RD(rd->reg) | (rs2->e.v << 12)); | 207 | gen_le32(S, opcode | ENCODE_RD(rd->reg) | (rs2->e.v << 12)); |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | static void asm_binary_opcode(TCCState *S, int token) | 210 | static void asm_binary_opcode(TCCState* S, int token) |
| 211 | { | 211 | { |
| 212 | Operand ops[2]; | 212 | Operand ops[2]; |
| 213 | parse_operand(S, &ops[0]); | 213 | parse_operand(S, &ops[0]); |
| 214 | if (S->tok == ',') | 214 | if (S->tccpp_tok == ',') |
| 215 | next(S); | 215 | next(S); |
| 216 | else | 216 | else |
| 217 | expect(S, "','"); | 217 | expect(S, "','"); |
| @@ -230,7 +230,7 @@ static void asm_binary_opcode(TCCState *S, int token) · 12 unmodified lines | |||
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | /* caller: Add funct3, funct7 into opcode */ | 232 | /* caller: Add funct3, funct7 into opcode */ |
| 233 | static void asm_emit_r(TCCState *S, int token, uint32_t opcode, const Operand* rd, const Operand* rs1, const Operand* rs2) | 233 | static void asm_emit_r(TCCState* S, int token, uint32_t opcode, const Operand* rd, const Operand* rs1, const Operand* rs2) |
| 234 | { | 234 | { |
| 235 | if (rd->type != OP_REG) { | 235 | if (rd->type != OP_REG) { |
| 236 | tcc_error(S, "'%s': Expected destination operand that is a register", get_tok_str(S, token, NULL)); | 236 | tcc_error(S, "'%s': Expected destination operand that is a register", get_tok_str(S, token, NULL)); |
| @@ -255,7 +255,7 @@ static void asm_emit_r(TCCState *S, int token, uint32_t opcode, const Operand* r · 18 unmodified lines | |||
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | /* caller: Add funct3 into opcode */ | 257 | /* caller: Add funct3 into opcode */ |
| 258 | static void asm_emit_i(TCCState *S, int token, uint32_t opcode, const Operand* rd, const Operand* rs1, const Operand* rs2) | 258 | static void asm_emit_i(TCCState* S, int token, uint32_t opcode, const Operand* rd, const Operand* rs1, const Operand* rs2) |
| 259 | { | 259 | { |
| 260 | if (rd->type != OP_REG) { | 260 | if (rd->type != OP_REG) { |
| 261 | tcc_error(S, "'%s': Expected destination operand that is a register", get_tok_str(S, token, NULL)); | 261 | tcc_error(S, "'%s': Expected destination operand that is a register", get_tok_str(S, token, NULL)); |
| @@ -283,12 +283,12 @@ static void asm_shift_opcode(TCCState *S, int token) · 21 unmodified lines | |||
| 283 | { | 283 | { |
| 284 | Operand ops[3]; | 284 | Operand ops[3]; |
| 285 | parse_operand(S, &ops[0]); | 285 | parse_operand(S, &ops[0]); |
| 286 | if (S->tok == ',') | 286 | if (S->tccpp_tok == ',') |
| 287 | next(S); | 287 | next(S); |
| 288 | else | 288 | else |
| 289 | expect(S, "','"); | 289 | expect(S, "','"); |
| 290 | parse_operand(S, &ops[1]); | 290 | parse_operand(S, &ops[1]); |
| 291 | if (S->tok == ',') | 291 | if (S->tccpp_tok == ',') |
| 292 | next(S); | 292 | next(S); |
| 293 | else | 293 | else |
| 294 | expect(S, "','"); | 294 | expect(S, "','"); |
| @@ -336,16 +336,16 @@ static void asm_shift_opcode(TCCState *S, int token) · 41 unmodified lines | |||
| 336 | } | 336 | } |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | static void asm_data_processing_opcode(TCCState *S, int token) | 339 | static void asm_data_processing_opcode(TCCState* S, int token) |
| 340 | { | 340 | { |
| 341 | Operand ops[3]; | 341 | Operand ops[3]; |
| 342 | parse_operand(S, &ops[0]); | 342 | parse_operand(S, &ops[0]); |
| 343 | if (S->tok == ',') | 343 | if (S->tccpp_tok == ',') |
| 344 | next(S); | 344 | next(S); |
| 345 | else | 345 | else |
| 346 | expect(S, "','"); | 346 | expect(S, "','"); |
| 347 | parse_operand(S, &ops[1]); | 347 | parse_operand(S, &ops[1]); |
| 348 | if (S->tok == ',') | 348 | if (S->tccpp_tok == ',') |
| 349 | next(S); | 349 | next(S); |
| 350 | else | 350 | else |
| 351 | expect(S, "','"); | 351 | expect(S, "','"); |
| @@ -414,7 +414,7 @@ static void asm_data_processing_opcode(TCCState *S, int token) · 62 unmodified lines | |||
| 414 | } | 414 | } |
| 415 | 415 | ||
| 416 | /* caller: Add funct3 to opcode */ | 416 | /* caller: Add funct3 to opcode */ |
| 417 | static void asm_emit_s(TCCState *S, int token, uint32_t opcode, const Operand* rs1, const Operand* rs2, const Operand* imm) | 417 | static void asm_emit_s(TCCState* S, int token, uint32_t opcode, const Operand* rs1, const Operand* rs2, const Operand* imm) |
| 418 | { | 418 | { |
| 419 | if (rs1->type != OP_REG) { | 419 | if (rs1->type != OP_REG) { |
| 420 | tcc_error(S, "'%s': Expected first source operand that is a register", get_tok_str(S, token, NULL)); | 420 | tcc_error(S, "'%s': Expected first source operand that is a register", get_tok_str(S, token, NULL)); |
| @@ -442,7 +442,7 @@ static void asm_emit_s(TCCState *S, int token, uint32_t opcode, const Operand* r · 21 unmodified lines | |||
| 442 | } | 442 | } |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | static void asm_data_transfer_opcode(TCCState *S, int token) | 445 | static void asm_data_transfer_opcode(TCCState* S, int token) |
| 446 | { | 446 | { |
| 447 | Operand ops[3]; | 447 | Operand ops[3]; |
| 448 | parse_operand(S, &ops[0]); | 448 | parse_operand(S, &ops[0]); |
| @@ -450,7 +450,7 @@ static void asm_data_transfer_opcode(TCCState *S, int token) · 1 unmodified line | |||
| 450 | expect(S, "register"); | 450 | expect(S, "register"); |
| 451 | return; | 451 | return; |
| 452 | } | 452 | } |
| 453 | if (S->tok == ',') | 453 | if (S->tccpp_tok == ',') |
| 454 | next(S); | 454 | next(S); |
| 455 | else | 455 | else |
| 456 | expect(S, "','"); | 456 | expect(S, "','"); |
| @@ -459,7 +459,7 @@ static void asm_data_transfer_opcode(TCCState *S, int token) · 2 unmodified lines | |||
| 459 | expect(S, "register"); | 459 | expect(S, "register"); |
| 460 | return; | 460 | return; |
| 461 | } | 461 | } |
| 462 | if (S->tok == ',') | 462 | if (S->tccpp_tok == ',') |
| 463 | next(S); | 463 | next(S); |
| 464 | else | 464 | else |
| 465 | expect(S, "','"); | 465 | expect(S, "','"); |
| @@ -511,7 +511,7 @@ static void asm_data_transfer_opcode(TCCState *S, int token) · 45 unmodified lines | |||
| 511 | } | 511 | } |
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | static void asm_branch_opcode(TCCState *S, int token) | 514 | static void asm_branch_opcode(TCCState* S, int token) |
| 515 | { | 515 | { |
| 516 | // Branch (RS1,RS2,IMM); SB-format | 516 | // Branch (RS1,RS2,IMM); SB-format |
| 517 | uint32_t opcode = (0x18 << 2) | 3; | 517 | uint32_t opcode = (0x18 << 2) | 3; |
| @@ -522,7 +522,7 @@ static void asm_branch_opcode(TCCState *S, int token) · 4 unmodified lines | |||
| 522 | expect(S, "register"); | 522 | expect(S, "register"); |
| 523 | return; | 523 | return; |
| 524 | } | 524 | } |
| 525 | if (S->tok == ',') | 525 | if (S->tccpp_tok == ',') |
| 526 | next(S); | 526 | next(S); |
| 527 | else | 527 | else |
| 528 | expect(S, "','"); | 528 | expect(S, "','"); |
| @@ -531,7 +531,7 @@ static void asm_branch_opcode(TCCState *S, int token) · 2 unmodified lines | |||
| 531 | expect(S, "register"); | 531 | expect(S, "register"); |
| 532 | return; | 532 | return; |
| 533 | } | 533 | } |
| 534 | if (S->tok == ',') | 534 | if (S->tccpp_tok == ',') |
| 535 | next(S); | 535 | next(S); |
| 536 | else | 536 | else |
| 537 | expect(S, "','"); | 537 | expect(S, "','"); |
| @@ -709,7 +709,7 @@ ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str) · 171 unmodified lines | |||
| 709 | clobber_regs[reg] = 1; | 709 | clobber_regs[reg] = 1; |
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | ST_FUNC int asm_parse_regvar (TCCState *S, int t) | 712 | ST_FUNC int asm_parse_regvar (TCCState* S, int t) |
| 713 | { | 713 | { |
| 714 | if (t >= TOK_ASM_x0 && t <= TOK_ASM_pc) { /* register name */ | 714 | if (t >= TOK_ASM_x0 && t <= TOK_ASM_pc) { /* register name */ |
| 715 | switch (t) { | 715 | switch (t) { |
| @@ -100,37 +100,37 @@ static int is_freg(int r) · 99 unmodified lines | |||
| 100 | return r >= 8 && r < 16; | 100 | return r >= 8 && r < 16; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | ST_FUNC void o(TCCState *S, unsigned int c) | 103 | ST_FUNC void o(TCCState* S, unsigned int c) |
| 104 | { | 104 | { |
| 105 | int ind1 = S->ind + 4; | 105 | int ind1 = S->tccgen_ind + 4; |
| 106 | if (S->nocode_wanted) | 106 | if (S->tccgen_nocode_wanted) |
| 107 | return; | 107 | return; |
| 108 | if (ind1 > cur_text_section->data_allocated) | 108 | if (ind1 > cur_text_section->data_allocated) |
| 109 | section_realloc(S, cur_text_section, ind1); | 109 | section_realloc(S, cur_text_section, ind1); |
| 110 | write32le(cur_text_section->data + S->ind, c); | 110 | write32le(cur_text_section->data + S->tccgen_ind, c); |
| 111 | S->ind = ind1; | 111 | S->tccgen_ind = ind1; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | static void EIu(TCCState *S, uint32_t opcode, uint32_t func3, | 114 | static void EIu(TCCState* S, uint32_t opcode, uint32_t func3, |
| 115 | uint32_t rd, uint32_t rs1, uint32_t imm) | 115 | uint32_t rd, uint32_t rs1, uint32_t imm) |
| 116 | { | 116 | { |
| 117 | o(S, opcode | (func3 << 12) | (rd << 7) | (rs1 << 15) | (imm << 20)); | 117 | o(S, opcode | (func3 << 12) | (rd << 7) | (rs1 << 15) | (imm << 20)); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | static void ER(TCCState *S, uint32_t opcode, uint32_t func3, | 120 | static void ER(TCCState* S, uint32_t opcode, uint32_t func3, |
| 121 | uint32_t rd, uint32_t rs1, uint32_t rs2, uint32_t func7) | 121 | uint32_t rd, uint32_t rs1, uint32_t rs2, uint32_t func7) |
| 122 | { | 122 | { |
| 123 | o(S, opcode | func3 << 12 | rd << 7 | rs1 << 15 | rs2 << 20 | func7 << 25); | 123 | o(S, opcode | func3 << 12 | rd << 7 | rs1 << 15 | rs2 << 20 | func7 << 25); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | static void EI(TCCState *S, uint32_t opcode, uint32_t func3, | 126 | static void EI(TCCState* S, uint32_t opcode, uint32_t func3, |
| 127 | uint32_t rd, uint32_t rs1, uint32_t imm) | 127 | uint32_t rd, uint32_t rs1, uint32_t imm) |
| 128 | { | 128 | { |
| 129 | assert(! ((imm + (1 << 11)) >> 12)); | 129 | assert(! ((imm + (1 << 11)) >> 12)); |
| 130 | EIu(S, opcode, func3, rd, rs1, imm); | 130 | EIu(S, opcode, func3, rd, rs1, imm); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static void ES(TCCState *S, uint32_t opcode, uint32_t func3, | 133 | static void ES(TCCState* S, uint32_t opcode, uint32_t func3, |
| 134 | uint32_t rs1, uint32_t rs2, uint32_t imm) | 134 | uint32_t rs1, uint32_t rs2, uint32_t imm) |
| 135 | { | 135 | { |
| 136 | assert(! ((imm + (1 << 11)) >> 12)); | 136 | assert(! ((imm + (1 << 11)) >> 12)); |
| @@ -139,7 +139,7 @@ static void ES(TCCState *S, uint32_t opcode, uint32_t func3, · 2 unmodified lines | |||
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | // Patch all branches in list pointed to by t to branch to a: | 141 | // Patch all branches in list pointed to by t to branch to a: |
| 142 | ST_FUNC void gsym_addr(TCCState *S, int t_, int a_) | 142 | ST_FUNC void gsym_addr(TCCState* S, int t_, int a_) |
| 143 | { | 143 | { |
| 144 | uint32_t t = t_; | 144 | uint32_t t = t_; |
| 145 | uint32_t a = a_; | 145 | uint32_t a = a_; |
| @@ -158,7 +158,7 @@ ST_FUNC void gsym_addr(TCCState *S, int t_, int a_) · 12 unmodified lines | |||
| 158 | } | 158 | } |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | static int load_symofs(TCCState *S, int r, SValue *sv, int forstore) | 161 | static int load_symofs(TCCState* S, int r, SValue *sv, int forstore) |
| 162 | { | 162 | { |
| 163 | int rr, doload = 0; | 163 | int rr, doload = 0; |
| 164 | int fc = sv->c.i, v = sv->r & VT_VALMASK; | 164 | int fc = sv->c.i, v = sv->r & VT_VALMASK; |
| @@ -166,21 +166,21 @@ static int load_symofs(TCCState *S, int r, SValue *sv, int forstore) · 1 unmodified line | |||
| 166 | Sym label = {0}; | 166 | Sym label = {0}; |
| 167 | assert(v == VT_CONST); | 167 | assert(v == VT_CONST); |
| 168 | if (sv->sym->type.t & VT_STATIC) { // XXX do this per linker relax | 168 | if (sv->sym->type.t & VT_STATIC) { // XXX do this per linker relax |
| 169 | greloca(S, cur_text_section, sv->sym, S->ind, | 169 | greloca(S, cur_text_section, sv->sym, S->tccgen_ind, |
| 170 | R_RISCV_PCREL_HI20, sv->c.i); | 170 | R_RISCV_PCREL_HI20, sv->c.i); |
| 171 | sv->c.i = 0; | 171 | sv->c.i = 0; |
| 172 | } else { | 172 | } else { |
| 173 | if (((unsigned)fc + (1 << 11)) >> 12) | 173 | if (((unsigned)fc + (1 << 11)) >> 12) |
| 174 | tcc_error(S, "unimp: large addend for global address (0x%lx)", (long)sv->c.i); | 174 | tcc_error(S, "unimp: large addend for global address (0x%lx)", (long)sv->c.i); |
| 175 | greloca(S, cur_text_section, sv->sym, S->ind, | 175 | greloca(S, cur_text_section, sv->sym, S->tccgen_ind, |
| 176 | R_RISCV_GOT_HI20, 0); | 176 | R_RISCV_GOT_HI20, 0); |
| 177 | doload = 1; | 177 | doload = 1; |
| 178 | } | 178 | } |
| 179 | label.type.t = VT_VOID | VT_STATIC; | 179 | label.type.t = VT_VOID | VT_STATIC; |
| 180 | put_extern_sym(S, &label, cur_text_section, S->ind, 0); | 180 | put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0); |
| 181 | rr = is_ireg(r) ? ireg(r) : 5; | 181 | rr = is_ireg(r) ? ireg(r) : 5; |
| 182 | o(S, 0x17 | (rr << 7)); // auipc RR, 0 %pcrel_hi(sym)+addend | 182 | o(S, 0x17 | (rr << 7)); // auipc RR, 0 %pcrel_hi(sym)+addend |
| 183 | greloca(S, cur_text_section, &label, S->ind, | 183 | greloca(S, cur_text_section, &label, S->tccgen_ind, |
| 184 | doload || !forstore | 184 | doload || !forstore |
| 185 | ? R_RISCV_PCREL_LO12_I : R_RISCV_PCREL_LO12_S, 0); | 185 | ? R_RISCV_PCREL_LO12_I : R_RISCV_PCREL_LO12_S, 0); |
| 186 | if (doload) { | 186 | if (doload) { |
| @@ -201,7 +201,7 @@ static int load_symofs(TCCState *S, int r, SValue *sv, int forstore) · 14 unmodified lines | |||
| 201 | return rr; | 201 | return rr; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | static void load_large_constant(TCCState *S, int rr, int fc, uint32_t pi) | 204 | static void load_large_constant(TCCState* S, int rr, int fc, uint32_t pi) |
| 205 | { | 205 | { |
| 206 | if (fc < 0) | 206 | if (fc < 0) |
| 207 | pi++; | 207 | pi++; |
| @@ -215,7 +215,7 @@ static void load_large_constant(TCCState *S, int rr, int fc, uint32_t pi) · 7 unmodified lines | |||
| 215 | EI(S, 0x13, 1, rr, rr, 8); // slli RR, RR, 8 | 215 | EI(S, 0x13, 1, rr, rr, 8); // slli RR, RR, 8 |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | ST_FUNC void load(TCCState *S, int r, SValue *sv) | 218 | ST_FUNC void load(TCCState* S, int r, SValue *sv) |
| 219 | { | 219 | { |
| 220 | int fr = sv->r; | 220 | int fr = sv->r; |
| 221 | int v = fr & VT_VALMASK; | 221 | int v = fr & VT_VALMASK; |
| @@ -314,9 +314,9 @@ ST_FUNC void load(TCCState *S, int r, SValue *sv) · 92 unmodified lines | |||
| 314 | | (func7 << 25)); // fmv.{w.x, x.w, d.x, x.d} RR, VR | 314 | | (func7 << 25)); // fmv.{w.x, x.w, d.x, x.d} RR, VR |
| 315 | } | 315 | } |
| 316 | } else if (v == VT_CMP) { | 316 | } else if (v == VT_CMP) { |
| 317 | int op = S->vtop->cmp_op; | 317 | int op = S->tccgen_vtop->cmp_op; |
| 318 | int a = S->vtop->cmp_r & 0xff; | 318 | int a = S->tccgen_vtop->cmp_r & 0xff; |
| 319 | int b = (S->vtop->cmp_r >> 8) & 0xff; | 319 | int b = (S->tccgen_vtop->cmp_r >> 8) & 0xff; |
| 320 | int inv = 0; | 320 | int inv = 0; |
| 321 | switch (op) { | 321 | switch (op) { |
| 322 | case TOK_ULT: | 322 | case TOK_ULT: |
| @@ -353,14 +353,14 @@ ST_FUNC void load(TCCState *S, int r, SValue *sv) · 30 unmodified lines | |||
| 353 | int t = v & 1; | 353 | int t = v & 1; |
| 354 | assert(is_ireg(r)); | 354 | assert(is_ireg(r)); |
| 355 | EI(S, 0x13, 0, rr, 0, t); // addi RR, x0, t | 355 | EI(S, 0x13, 0, rr, 0, t); // addi RR, x0, t |
| 356 | gjmp_addr(S, S->ind + 8); | 356 | gjmp_addr(S, S->tccgen_ind + 8); |
| 357 | gsym(S, fc); | 357 | gsym(S, fc); |
| 358 | EI(S, 0x13, 0, rr, 0, t ^ 1); // addi RR, x0, !t | 358 | EI(S, 0x13, 0, rr, 0, t ^ 1); // addi RR, x0, !t |
| 359 | } else | 359 | } else |
| 360 | tcc_error(S, "unimp: load(non-const)"); | 360 | tcc_error(S, "unimp: load(non-const)"); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | ST_FUNC void store(TCCState *S, int r, SValue *sv) | 363 | ST_FUNC void store(TCCState* S, int r, SValue *sv) |
| 364 | { | 364 | { |
| 365 | int fr = sv->r & VT_VALMASK; | 365 | int fr = sv->r & VT_VALMASK; |
| 366 | int rr = is_ireg(r) ? ireg(r) : freg(r), ptrreg; | 366 | int rr = is_ireg(r) ? ireg(r) : freg(r), ptrreg; |
| @@ -403,22 +403,22 @@ ST_FUNC void store(TCCState *S, int r, SValue *sv) · 36 unmodified lines | |||
| 403 | ptrreg, rr, fc); // RR, fc(base) | 403 | ptrreg, rr, fc); // RR, fc(base) |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | static void gcall_or_jmp(TCCState *S, int docall) | 406 | static void gcall_or_jmp(TCCState* S, int docall) |
| 407 | { | 407 | { |
| 408 | int tr = docall ? 1 : 5; // ra or t0 | 408 | int tr = docall ? 1 : 5; // ra or t0 |
| 409 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && | 409 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && |
| 410 | ((S->vtop->r & VT_SYM) && S->vtop->c.i == (int)S->vtop->c.i)) { | 410 | ((S->tccgen_vtop->r & VT_SYM) && S->tccgen_vtop->c.i == (int)S->tccgen_vtop->c.i)) { |
| 411 | /* constant symbolic case -> simple relocation */ | 411 | /* constant symbolic case -> simple relocation */ |
| 412 | greloca(S, cur_text_section, S->vtop->sym, S->ind, | 412 | greloca(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind, |
| 413 | R_RISCV_CALL_PLT, (int)S->vtop->c.i); | 413 | R_RISCV_CALL_PLT, (int)S->tccgen_vtop->c.i); |
| 414 | o(S, 0x17 | (tr << 7)); // auipc TR, 0 %call(func) | 414 | o(S, 0x17 | (tr << 7)); // auipc TR, 0 %call(func) |
| 415 | EI(S, 0x67, 0, tr, tr, 0);// jalr TR, r(TR) | 415 | EI(S, 0x67, 0, tr, tr, 0);// jalr TR, r(TR) |
| 416 | } else if (S->vtop->r < VT_CONST) { | 416 | } else if (S->tccgen_vtop->r < VT_CONST) { |
| 417 | int r = ireg(S->vtop->r); | 417 | int r = ireg(S->tccgen_vtop->r); |
| 418 | EI(S, 0x67, 0, tr, r, 0); // jalr TR, 0(R) | 418 | EI(S, 0x67, 0, tr, r, 0); // jalr TR, 0(R) |
| 419 | } else { | 419 | } else { |
| 420 | int r = TREG_RA; | 420 | int r = TREG_RA; |
| 421 | load(S, r, S->vtop); | 421 | load(S, r, S->tccgen_vtop); |
| 422 | r = ireg(r); | 422 | r = ireg(r); |
| 423 | EI(S, 0x67, 0, tr, r, 0); // jalr TR, 0(R) | 423 | EI(S, 0x67, 0, tr, r, 0); // jalr TR, 0(R) |
| 424 | } | 424 | } |
| @@ -426,20 +426,20 @@ static void gcall_or_jmp(TCCState *S, int docall) · 1 unmodified line | |||
| 426 | 426 | ||
| 427 | #if defined(CONFIG_TCC_BCHECK) | 427 | #if defined(CONFIG_TCC_BCHECK) |
| 428 | 428 | ||
| 429 | static void gen_bounds_call(TCCState *S, int v) | 429 | static void gen_bounds_call(TCCState* S, int v) |
| 430 | { | 430 | { |
| 431 | Sym *sym = external_helper_sym(S, v); | 431 | Sym *sym = external_helper_sym(S, v); |
| 432 | 432 | ||
| 433 | greloca(S, cur_text_section, sym, S->ind, R_RISCV_CALL_PLT, 0); | 433 | greloca(S, cur_text_section, sym, S->tccgen_ind, R_RISCV_CALL_PLT, 0); |
| 434 | o(S, 0x17 | (1 << 7)); // auipc TR, 0 %call(func) | 434 | o(S, 0x17 | (1 << 7)); // auipc TR, 0 %call(func) |
| 435 | EI(S, 0x67, 0, 1, 1, 0); // jalr TR, r(TR) | 435 | EI(S, 0x67, 0, 1, 1, 0); // jalr TR, r(TR) |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | static void gen_bounds_prolog(TCCState *S) | 438 | static void gen_bounds_prolog(TCCState* S) |
| 439 | { | 439 | { |
| 440 | /* leave some room for bound checking code */ | 440 | /* leave some room for bound checking code */ |
| 441 | S->func_bound_offset = lbounds_section->data_offset; | 441 | S->func_bound_offset = lbounds_section->data_offset; |
| 442 | S->func_bound_ind = S->ind; | 442 | S->func_bound_ind = S->tccgen_ind; |
| 443 | S->func_bound_add_epilog = 0; | 443 | S->func_bound_add_epilog = 0; |
| 444 | o(S, 0x00000013); /* ld a0,#lbound section pointer */ | 444 | o(S, 0x00000013); /* ld a0,#lbound section pointer */ |
| 445 | o(S, 0x00000013); | 445 | o(S, 0x00000013); |
| @@ -447,7 +447,7 @@ static void gen_bounds_prolog(TCCState *S) · 1 unmodified line | |||
| 447 | o(S, 0x00000013); | 447 | o(S, 0x00000013); |
| 448 | } | 448 | } |
| 449 | 449 | ||
| 450 | static void gen_bounds_epilog(TCCState *S) | 450 | static void gen_bounds_epilog(TCCState* S) |
| 451 | { | 451 | { |
| 452 | addr_t saved_ind; | 452 | addr_t saved_ind; |
| 453 | addr_t *bounds_ptr; | 453 | addr_t *bounds_ptr; |
| @@ -463,31 +463,31 @@ static void gen_bounds_epilog(TCCState *S) · 9 unmodified lines | |||
| 463 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); | 463 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); |
| 464 | *bounds_ptr = 0; | 464 | *bounds_ptr = 0; |
| 465 | 465 | ||
| 466 | sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section, | 466 | sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section, |
| 467 | S->func_bound_offset, lbounds_section->data_offset); | 467 | S->func_bound_offset, lbounds_section->data_offset); |
| 468 | 468 | ||
| 469 | label.type.t = VT_VOID | VT_STATIC; | 469 | label.type.t = VT_VOID | VT_STATIC; |
| 470 | /* generate bound local allocation */ | 470 | /* generate bound local allocation */ |
| 471 | if (offset_modified) { | 471 | if (offset_modified) { |
| 472 | saved_ind = S->ind; | 472 | saved_ind = S->tccgen_ind; |
| 473 | S->ind = S->func_bound_ind; | 473 | S->tccgen_ind = S->func_bound_ind; |
| 474 | put_extern_sym(S, &label, cur_text_section, S->ind, 0); | 474 | put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0); |
| 475 | greloca(S, cur_text_section, sym_data, S->ind, R_RISCV_GOT_HI20, 0); | 475 | greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_RISCV_GOT_HI20, 0); |
| 476 | o(S, 0x17 | (10 << 7)); // auipc a0, 0 %pcrel_hi(sym)+addend | 476 | o(S, 0x17 | (10 << 7)); // auipc a0, 0 %pcrel_hi(sym)+addend |
| 477 | greloca(S, cur_text_section, &label, S->ind, R_RISCV_PCREL_LO12_I, 0); | 477 | greloca(S, cur_text_section, &label, S->tccgen_ind, R_RISCV_PCREL_LO12_I, 0); |
| 478 | EI(S, 0x03, 3, 10, 10, 0); // ld a0, 0(a0) | 478 | EI(S, 0x03, 3, 10, 10, 0); // ld a0, 0(a0) |
| 479 | gen_bounds_call(S, TOK___bound_local_new); | 479 | gen_bounds_call(S, TOK___bound_local_new); |
| 480 | S->ind = saved_ind; | 480 | S->tccgen_ind = saved_ind; |
| 481 | label.c = 0; /* force new local ELF symbol */ | 481 | label.c = 0; /* force new local ELF symbol */ |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | /* generate bound check local freeing */ | 484 | /* generate bound check local freeing */ |
| 485 | o(S, 0xe02a1101); /* addi sp,sp,-32 sd a0,0(sp) */ | 485 | o(S, 0xe02a1101); /* addi sp,sp,-32 sd a0,0(sp) */ |
| 486 | o(S, 0xa82ae42e); /* sd a1,8(sp) fsd fa0,16(sp) */ | 486 | o(S, 0xa82ae42e); /* sd a1,8(sp) fsd fa0,16(sp) */ |
| 487 | put_extern_sym(S, &label, cur_text_section, S->ind, 0); | 487 | put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0); |
| 488 | greloca(S, cur_text_section, sym_data, S->ind, R_RISCV_GOT_HI20, 0); | 488 | greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_RISCV_GOT_HI20, 0); |
| 489 | o(S, 0x17 | (10 << 7)); // auipc a0, 0 %pcrel_hi(sym)+addend | 489 | o(S, 0x17 | (10 << 7)); // auipc a0, 0 %pcrel_hi(sym)+addend |
| 490 | greloca(S, cur_text_section, &label, S->ind, R_RISCV_PCREL_LO12_I, 0); | 490 | greloca(S, cur_text_section, &label, S->tccgen_ind, R_RISCV_PCREL_LO12_I, 0); |
| 491 | EI(S, 0x03, 3, 10, 10, 0); // ld a0, 0(a0) | 491 | EI(S, 0x03, 3, 10, 10, 0); // ld a0, 0(a0) |
| 492 | gen_bounds_call(S, TOK___bound_local_delete); | 492 | gen_bounds_call(S, TOK___bound_local_delete); |
| 493 | o(S, 0x65a26502); /* ld a0,0(sp) ld a1,8(sp) */ | 493 | o(S, 0x65a26502); /* ld a0,0(sp) ld a1,8(sp) */ |
| @@ -540,7 +540,7 @@ static void reg_pass(CType *type, int *prc, int *fieldofs, int named) · 46 unmodified lines | |||
| 540 | } | 540 | } |
| 541 | } | 541 | } |
| 542 | 542 | ||
| 543 | ST_FUNC void gfunc_call(TCCState *S, int nb_args) | 543 | ST_FUNC void gfunc_call(TCCState* S, int nb_args) |
| 544 | { | 544 | { |
| 545 | int i, align, size, areg[2]; | 545 | int i, align, size, areg[2]; |
| 546 | int *info = tcc_malloc(S, (nb_args + 1) * sizeof (int)); | 546 | int *info = tcc_malloc(S, (nb_args + 1) * sizeof (int)); |
| @@ -556,11 +556,11 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 9 unmodified lines | |||
| 556 | 556 | ||
| 557 | areg[0] = 0; /* int arg regs */ | 557 | areg[0] = 0; /* int arg regs */ |
| 558 | areg[1] = 8; /* float arg regs */ | 558 | areg[1] = 8; /* float arg regs */ |
| 559 | sa = S->vtop[-nb_args].type.ref->next; | 559 | sa = S->tccgen_vtop[-nb_args].type.ref->next; |
| 560 | for (i = 0; i < nb_args; i++) { | 560 | for (i = 0; i < nb_args; i++) { |
| 561 | int nregs, byref = 0, tempofs; | 561 | int nregs, byref = 0, tempofs; |
| 562 | int prc[3], fieldofs[3]; | 562 | int prc[3], fieldofs[3]; |
| 563 | sv = &S->vtop[1 + i - nb_args]; | 563 | sv = &S->tccgen_vtop[1 + i - nb_args]; |
| 564 | sv->type.t &= ~VT_ARRAY; // XXX this should be done in tccgen.c | 564 | sv->type.t &= ~VT_ARRAY; // XXX this should be done in tccgen.c |
| 565 | size = type_size(&sv->type, &align); | 565 | size = type_size(&sv->type, &align); |
| 566 | if (size > 16) { | 566 | if (size > 16) { |
| @@ -617,7 +617,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 50 unmodified lines | |||
| 617 | stack_add = stack_adj + tempspace; | 617 | stack_add = stack_adj + tempspace; |
| 618 | 618 | ||
| 619 | /* fetch cpu flag before generating any code */ | 619 | /* fetch cpu flag before generating any code */ |
| 620 | if ((S->vtop->r & VT_VALMASK) == VT_CMP) | 620 | if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP) |
| 621 | gv(S, RC_INT); | 621 | gv(S, RC_INT); |
| 622 | 622 | ||
| 623 | if (stack_add) { | 623 | if (stack_add) { |
| @@ -631,15 +631,15 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 7 unmodified lines | |||
| 631 | for (i = ofs = 0; i < nb_args; i++) { | 631 | for (i = ofs = 0; i < nb_args; i++) { |
| 632 | if (info[i] & (64 | 32)) { | 632 | if (info[i] & (64 | 32)) { |
| 633 | vrotb(S, nb_args - i); | 633 | vrotb(S, nb_args - i); |
| 634 | size = type_size(&S->vtop->type, &align); | 634 | size = type_size(&S->tccgen_vtop->type, &align); |
| 635 | if (info[i] & 64) { | 635 | if (info[i] & 64) { |
| 636 | vset(S, &S->char_pointer_type, TREG_SP, 0); | 636 | vset(S, &S->tccgen_char_pointer_type, TREG_SP, 0); |
| 637 | vpushi(S, stack_adj + (info[i] >> 7)); | 637 | vpushi(S, stack_adj + (info[i] >> 7)); |
| 638 | gen_op(S, '+'); | 638 | gen_op(S, '+'); |
| 639 | vpushv(S, S->vtop); // this replaces the old argument | 639 | vpushv(S, S->tccgen_vtop); // this replaces the old argument |
| 640 | vrott(S, 3); | 640 | vrott(S, 3); |
| 641 | indir(S); | 641 | indir(S); |
| 642 | S->vtop->type = S->vtop[-1].type; | 642 | S->tccgen_vtop->type = S->tccgen_vtop[-1].type; |
| 643 | vswap(S); | 643 | vswap(S); |
| 644 | vstore(S); | 644 | vstore(S); |
| 645 | vpop(S); | 645 | vpop(S); |
| @@ -649,18 +649,18 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 3 unmodified lines | |||
| 649 | if (align < XLEN) | 649 | if (align < XLEN) |
| 650 | align = XLEN; | 650 | align = XLEN; |
| 651 | /* Once we support offseted regs we can do this: | 651 | /* Once we support offseted regs we can do this: |
| 652 | vset(S, &S->vtop->type, TREG_SP | VT_LVAL, ofs); | 652 | vset(S, &S->tccgen_vtop->type, TREG_SP | VT_LVAL, ofs); |
| 653 | to construct the lvalue for the outgoing stack slot, | 653 | to construct the lvalue for the outgoing stack slot, |
| 654 | until then we have to jump through hoops. */ | 654 | until then we have to jump through hoops. */ |
| 655 | vset(S, &S->char_pointer_type, TREG_SP, 0); | 655 | vset(S, &S->tccgen_char_pointer_type, TREG_SP, 0); |
| 656 | ofs = (ofs + align - 1) & -align; | 656 | ofs = (ofs + align - 1) & -align; |
| 657 | vpushi(S, ofs); | 657 | vpushi(S, ofs); |
| 658 | gen_op(S, '+'); | 658 | gen_op(S, '+'); |
| 659 | indir(S); | 659 | indir(S); |
| 660 | S->vtop->type = S->vtop[-1].type; | 660 | S->tccgen_vtop->type = S->tccgen_vtop[-1].type; |
| 661 | vswap(S); | 661 | vswap(S); |
| 662 | vstore(S); | 662 | vstore(S); |
| 663 | S->vtop->r = S->vtop->r2 = VT_CONST; // this arg is done | 663 | S->tccgen_vtop->r = S->tccgen_vtop->r2 = VT_CONST; // this arg is done |
| 664 | ofs += size; | 664 | ofs += size; |
| 665 | } | 665 | } |
| 666 | vrott(S, nb_args - i); | 666 | vrott(S, nb_args - i); |
| @@ -680,11 +680,11 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 13 unmodified lines | |||
| 680 | r2 = r2 & 64 ? 0 : (r2 >> 7) & 31; | 680 | r2 = r2 & 64 ? 0 : (r2 >> 7) & 31; |
| 681 | assert(r2 <= 16); | 681 | assert(r2 <= 16); |
| 682 | vrotb(S, i+1); | 682 | vrotb(S, i+1); |
| 683 | origtype = S->vtop->type; | 683 | origtype = S->tccgen_vtop->type; |
| 684 | size = type_size(&S->vtop->type, &align); | 684 | size = type_size(&S->tccgen_vtop->type, &align); |
| 685 | if (size == 0) | 685 | if (size == 0) |
| 686 | goto done; | 686 | goto done; |
| 687 | loadt = S->vtop->type.t & VT_BTYPE; | 687 | loadt = S->tccgen_vtop->type.t & VT_BTYPE; |
| 688 | if (loadt == VT_STRUCT) { | 688 | if (loadt == VT_STRUCT) { |
| 689 | loadt = (ii >> 12) & VT_BTYPE; | 689 | loadt = (ii >> 12) & VT_BTYPE; |
| 690 | } | 690 | } |
| @@ -697,18 +697,18 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 6 unmodified lines | |||
| 697 | r2--; | 697 | r2--; |
| 698 | } else if (r2) { | 698 | } else if (r2) { |
| 699 | test_lvalue(S); | 699 | test_lvalue(S); |
| 700 | vpushv(S, S->vtop); | 700 | vpushv(S, S->tccgen_vtop); |
| 701 | } | 701 | } |
| 702 | S->vtop->type.t = loadt | (S->vtop->type.t & VT_UNSIGNED); | 702 | S->tccgen_vtop->type.t = loadt | (S->tccgen_vtop->type.t & VT_UNSIGNED); |
| 703 | gv(S, r < 8 ? RC_R(r) : RC_F(r - 8)); | 703 | gv(S, r < 8 ? RC_R(r) : RC_F(r - 8)); |
| 704 | S->vtop->type = origtype; | 704 | S->tccgen_vtop->type = origtype; |
| 705 | 705 | ||
| 706 | if (r2 && loadt != VT_LDOUBLE) { | 706 | if (r2 && loadt != VT_LDOUBLE) { |
| 707 | r2--; | 707 | r2--; |
| 708 | assert(r2 < 16 || r2 == TREG_RA); | 708 | assert(r2 < 16 || r2 == TREG_RA); |
| 709 | vswap(S); | 709 | vswap(S); |
| 710 | gaddrof(S); | 710 | gaddrof(S); |
| 711 | S->vtop->type = S->char_pointer_type; | 711 | S->tccgen_vtop->type = S->tccgen_char_pointer_type; |
| 712 | vpushi(S, ii >> 20); | 712 | vpushi(S, ii >> 20); |
| 713 | #ifdef CONFIG_TCC_BCHECK | 713 | #ifdef CONFIG_TCC_BCHECK |
| 714 | if ((origtype.t & VT_BTYPE) == VT_STRUCT) | 714 | if ((origtype.t & VT_BTYPE) == VT_STRUCT) |
| @@ -719,27 +719,27 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args) · 4 unmodified lines | |||
| 719 | S->do_bounds_check = bc_save; | 719 | S->do_bounds_check = bc_save; |
| 720 | #endif | 720 | #endif |
| 721 | indir(S); | 721 | indir(S); |
| 722 | S->vtop->type = origtype; | 722 | S->tccgen_vtop->type = origtype; |
| 723 | loadt = S->vtop->type.t & VT_BTYPE; | 723 | loadt = S->tccgen_vtop->type.t & VT_BTYPE; |
| 724 | if (loadt == VT_STRUCT) { | 724 | if (loadt == VT_STRUCT) { |
| 725 | loadt = (ii >> 16) & VT_BTYPE; | 725 | loadt = (ii >> 16) & VT_BTYPE; |
| 726 | } | 726 | } |
| 727 | save_reg_upstack(S, r2, 1); | 727 | save_reg_upstack(S, r2, 1); |
| 728 | S->vtop->type.t = loadt | (S->vtop->type.t & VT_UNSIGNED); | 728 | S->tccgen_vtop->type.t = loadt | (S->tccgen_vtop->type.t & VT_UNSIGNED); |
| 729 | load(S, r2, S->vtop); | 729 | load(S, r2, S->tccgen_vtop); |
| 730 | assert(r2 < VT_CONST); | 730 | assert(r2 < VT_CONST); |
| 731 | S->vtop--; | 731 | S->tccgen_vtop--; |
| 732 | S->vtop->r2 = r2; | 732 | S->tccgen_vtop->r2 = r2; |
| 733 | } | 733 | } |
| 734 | if (info[nb_args - 1 - i] & 16) { | 734 | if (info[nb_args - 1 - i] & 16) { |
| 735 | ES(S, 0x23, 3, 2, ireg(S->vtop->r2), splitofs); // sd t0, ofs(sp) | 735 | ES(S, 0x23, 3, 2, ireg(S->tccgen_vtop->r2), splitofs); // sd t0, ofs(sp) |
| 736 | S->vtop->r2 = VT_CONST; | 736 | S->tccgen_vtop->r2 = VT_CONST; |
| 737 | } else if (loadt == VT_LDOUBLE && S->vtop->r2 != r2) { | 737 | } else if (loadt == VT_LDOUBLE && S->tccgen_vtop->r2 != r2) { |
| 738 | assert(S->vtop->r2 <= 7 && r2 <= 7); | 738 | assert(S->tccgen_vtop->r2 <= 7 && r2 <= 7); |
| 739 | /* XXX we'd like to have 'gv' move directly into | 739 | /* XXX we'd like to have 'gv' move directly into |
| 740 | the right class instead of us fixing it up. */ | 740 | the right class instead of us fixing it up. */ |
| 741 | EI(S, 0x13, 0, ireg(r2), ireg(S->vtop->r2), 0); // mv Ra+1, RR2 | 741 | EI(S, 0x13, 0, ireg(r2), ireg(S->tccgen_vtop->r2), 0); // mv Ra+1, RR2 |
| 742 | S->vtop->r2 = r2; | 742 | S->tccgen_vtop->r2 = r2; |
| 743 | } | 743 | } |
| 744 | done: | 744 | done: |
| 745 | vrott(S, i+1); | 745 | vrott(S, i+1); |
| @@ -748,7 +748,7 @@ done: · 2 unmodified lines | |||
| 748 | vrotb(S, nb_args + 1); | 748 | vrotb(S, nb_args + 1); |
| 749 | save_regs(S, nb_args + 1); | 749 | save_regs(S, nb_args + 1); |
| 750 | gcall_or_jmp(S, 1); | 750 | gcall_or_jmp(S, 1); |
| 751 | S->vtop -= nb_args + 1; | 751 | S->tccgen_vtop -= nb_args + 1; |
| 752 | if (stack_add) { | 752 | if (stack_add) { |
| 753 | if (stack_add >= 0x1000) { | 753 | if (stack_add >= 0x1000) { |
| 754 | o(S, 0x37 | (5 << 7) | (stack_add & 0xfffff000)); //lui t0, upper(v) | 754 | o(S, 0x37 | (5 << 7) | (stack_add & 0xfffff000)); //lui t0, upper(v) |
| @@ -763,7 +763,7 @@ done: · 8 unmodified lines | |||
| 763 | 763 | ||
| 764 | static int func_sub_sp_offset, num_va_regs, func_va_list_ofs; | 764 | static int func_sub_sp_offset, num_va_regs, func_va_list_ofs; |
| 765 | 765 | ||
| 766 | ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) | 766 | ST_FUNC void gfunc_prolog(TCCState* S, Sym *func_sym) |
| 767 | { | 767 | { |
| 768 | CType *func_type = &func_sym->type; | 768 | CType *func_type = &func_sym->type; |
| 769 | int i, addr, align, size; | 769 | int i, addr, align, size; |
| @@ -773,9 +773,9 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 3 unmodified lines | |||
| 773 | CType *type; | 773 | CType *type; |
| 774 | 774 | ||
| 775 | sym = func_type->ref; | 775 | sym = func_type->ref; |
| 776 | S->loc = -16; // for ra and s0 | 776 | S->tccgen_loc = -16; // for ra and s0 |
| 777 | func_sub_sp_offset = S->ind; | 777 | func_sub_sp_offset = S->tccgen_ind; |
| 778 | S->ind += 5 * 4; | 778 | S->tccgen_ind += 5 * 4; |
| 779 | 779 | ||
| 780 | areg[0] = 0, areg[1] = 0; | 780 | areg[0] = 0, areg[1] = 0; |
| 781 | addr = 0; | 781 | addr = 0; |
| @@ -783,9 +783,9 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 1 unmodified line | |||
| 783 | implicit pointer parameter */ | 783 | implicit pointer parameter */ |
| 784 | size = type_size(&S->tccgen_func_vt, &align); | 784 | size = type_size(&S->tccgen_func_vt, &align); |
| 785 | if (size > 2 * XLEN) { | 785 | if (size > 2 * XLEN) { |
| 786 | S->loc -= 8; | 786 | S->tccgen_loc -= 8; |
| 787 | S->tccgen_func_vc = S->loc; | 787 | S->tccgen_func_vc = S->tccgen_loc; |
| 788 | ES(S, 0x23, 3, 8, 10 + areg[0]++, S->loc); // sd a0, loc(s0) | 788 | ES(S, 0x23, 3, 8, 10 + areg[0]++, S->tccgen_loc); // sd a0, loc(s0) |
| 789 | } | 789 | } |
| 790 | /* define parameters */ | 790 | /* define parameters */ |
| 791 | while ((sym = sym->next) != NULL) { | 791 | while ((sym = sym->next) != NULL) { |
| @@ -795,7 +795,7 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 3 unmodified lines | |||
| 795 | type = &sym->type; | 795 | type = &sym->type; |
| 796 | size = type_size(type, &align); | 796 | size = type_size(type, &align); |
| 797 | if (size > 2 * XLEN) { | 797 | if (size > 2 * XLEN) { |
| 798 | type = &S->char_pointer_type; | 798 | type = &S->tccgen_char_pointer_type; |
| 799 | size = align = byref = 8; | 799 | size = align = byref = 8; |
| 800 | } | 800 | } |
| 801 | reg_pass(type, prc, fieldofs, 1); | 801 | reg_pass(type, prc, fieldofs, 1); |
| @@ -810,18 +810,18 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym) · 8 unmodified lines | |||
| 810 | param_addr = addr; | 810 | param_addr = addr; |
| 811 | addr += size; | 811 | addr += size; |
| 812 | } else { | 812 | } else { |
| 813 | S->loc -= regcount * 8; // XXX could reserve only 'size' bytes | 813 | S->tccgen_loc -= regcount * 8; // XXX could reserve only 'size' bytes |
| 814 | param_addr = S->loc; | 814 | param_addr = S->tccgen_loc; |
| 815 | for (i = 0; i < regcount; i++) { | 815 | for (i = 0; i < regcount; i++) { |
| 816 | if (areg[prc[1+i] - 1] >= 8) { | 816 | if (areg[prc[1+i] - 1] >= 8) { |
| 817 | assert(i == 1 && regcount == 2 && !(addr & 7)); | 817 | assert(i == 1 && regcount == 2 && !(addr & 7)); |
| 818 | EI(S, 0x03, 3, 5, 8, addr); // ld t0, addr(s0) | 818 | EI(S, 0x03, 3, 5, 8, addr); // ld t0, addr(s0) |
| 819 | addr += 8; | 819 | addr += 8; |
| 820 | ES(S, 0x23, 3, 8, 5, S->loc + i*8); // sd t0, loc(s0) | 820 | ES(S, 0x23, 3, 8, 5, S->tccgen_loc + i*8); // sd t0, loc(s0) |
| 821 | } else if (prc[1+i] == RC_FLOAT) { | 821 | } else if (prc[1+i] == RC_FLOAT) { |
| 822 | ES(S, 0x27, (size / regcount) == 4 ? 2 : 3, 8, 10 + areg[1]++, S->loc + (fieldofs[i+1] >> 4)); // fs[wd] FAi, loc(s0) | 822 | ES(S, 0x27, (size / regcount) == 4 ? 2 : 3, 8, 10 + areg[1]++, S->tccgen_loc + (fieldofs[i+1] >> 4)); // fs[wd] FAi, loc(s0) |
| 823 | } else { | 823 | } else { |
| 824 | ES(S, 0x23, 3, 8, 10 + areg[0]++, S->loc + i*8); // sd aX, loc(s0) // XXX | 824 | ES(S, 0x23, 3, 8, 10 + areg[0]++, S->tccgen_loc + i*8); // sd aX, loc(s0) // XXX |
| 825 | } | 825 | } |
| 826 | } | 826 | } |
| 827 | } | 827 | } |
| @@ -864,22 +864,22 @@ ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, · 36 unmodified lines | |||
| 864 | return nregs; | 864 | return nregs; |
| 865 | } | 865 | } |
| 866 | 866 | ||
| 867 | ST_FUNC void arch_transfer_ret_regs(TCCState *S, int aftercall) | 867 | ST_FUNC void arch_transfer_ret_regs(TCCState* S, int aftercall) |
| 868 | { | 868 | { |
| 869 | int prc[3], fieldofs[3]; | 869 | int prc[3], fieldofs[3]; |
| 870 | reg_pass(&S->vtop->type, prc, fieldofs, 1); | 870 | reg_pass(&S->tccgen_vtop->type, prc, fieldofs, 1); |
| 871 | assert(prc[0] == 2 && prc[1] != prc[2] && !(fieldofs[1] >> 4)); | 871 | assert(prc[0] == 2 && prc[1] != prc[2] && !(fieldofs[1] >> 4)); |
| 872 | assert(S->vtop->r == (VT_LOCAL | VT_LVAL)); | 872 | assert(S->tccgen_vtop->r == (VT_LOCAL | VT_LVAL)); |
| 873 | vpushv(S, S->vtop); | 873 | vpushv(S, S->tccgen_vtop); |
| 874 | S->vtop->type.t = fieldofs[1] & VT_BTYPE; | 874 | S->tccgen_vtop->type.t = fieldofs[1] & VT_BTYPE; |
| 875 | (aftercall ? store : load)(S, prc[1] == RC_INT ? REG_IRET : REG_FRET, S->vtop); | 875 | (aftercall ? store : load)(S, prc[1] == RC_INT ? REG_IRET : REG_FRET, S->tccgen_vtop); |
| 876 | S->vtop->c.i += fieldofs[2] >> 4; | 876 | S->tccgen_vtop->c.i += fieldofs[2] >> 4; |
| 877 | S->vtop->type.t = fieldofs[2] & VT_BTYPE; | 877 | S->tccgen_vtop->type.t = fieldofs[2] & VT_BTYPE; |
| 878 | (aftercall ? store : load)(S, prc[2] == RC_INT ? REG_IRET : REG_FRET, S->vtop); | 878 | (aftercall ? store : load)(S, prc[2] == RC_INT ? REG_IRET : REG_FRET, S->tccgen_vtop); |
| 879 | S->vtop--; | 879 | S->tccgen_vtop--; |
| 880 | } | 880 | } |
| 881 | 881 | ||
| 882 | ST_FUNC void gfunc_epilog(TCCState *S) | 882 | ST_FUNC void gfunc_epilog(TCCState* S) |
| 883 | { | 883 | { |
| 884 | int v, saved_ind, d, large_ofs_ind; | 884 | int v, saved_ind, d, large_ofs_ind; |
| 885 | 885 | ||
| @@ -888,8 +888,8 @@ ST_FUNC void gfunc_epilog(TCCState *S) · 2 unmodified lines | |||
| 888 | gen_bounds_epilog(S); | 888 | gen_bounds_epilog(S); |
| 889 | #endif | 889 | #endif |
| 890 | 890 | ||
| 891 | S->loc = (S->loc - num_va_regs * 8); | 891 | S->tccgen_loc = (S->tccgen_loc - num_va_regs * 8); |
| 892 | d = v = (-S->loc + 15) & -16; | 892 | d = v = (-S->tccgen_loc + 15) & -16; |
| 893 | 893 | ||
| 894 | if (v >= (1 << 11)) { | 894 | if (v >= (1 << 11)) { |
| 895 | d = 16; | 895 | d = 16; |
| @@ -901,7 +901,7 @@ ST_FUNC void gfunc_epilog(TCCState *S) · 5 unmodified lines | |||
| 901 | EI(S, 0x03, 3, 8, 2, d - 16 - num_va_regs * 8); // ld s0, v-16(sp) | 901 | EI(S, 0x03, 3, 8, 2, d - 16 - num_va_regs * 8); // ld s0, v-16(sp) |
| 902 | EI(S, 0x13, 0, 2, 2, d); // addi sp, sp, v | 902 | EI(S, 0x13, 0, 2, 2, d); // addi sp, sp, v |
| 903 | EI(S, 0x67, 0, 0, 1, 0); // jalr x0, 0(x1), aka ret | 903 | EI(S, 0x67, 0, 0, 1, 0); // jalr x0, 0(x1), aka ret |
| 904 | large_ofs_ind = S->ind; | 904 | large_ofs_ind = S->tccgen_ind; |
| 905 | if (v >= (1 << 11)) { | 905 | if (v >= (1 << 11)) { |
| 906 | EI(S, 0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d | 906 | EI(S, 0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d |
| 907 | o(S, 0x37 | (5 << 7) | ((0x800 + (v-16)) & 0xfffff000)); //lui t0, upper(v) | 907 | o(S, 0x37 | (5 << 7) | ((0x800 + (v-16)) & 0xfffff000)); //lui t0, upper(v) |
| @@ -909,9 +909,9 @@ ST_FUNC void gfunc_epilog(TCCState *S) · 1 unmodified line | |||
| 909 | ER(S, 0x33, 0, 2, 2, 5, 0x20); // sub sp, sp, t0 | 909 | ER(S, 0x33, 0, 2, 2, 5, 0x20); // sub sp, sp, t0 |
| 910 | gjmp_addr(S, func_sub_sp_offset + 5*4); | 910 | gjmp_addr(S, func_sub_sp_offset + 5*4); |
| 911 | } | 911 | } |
| 912 | saved_ind = S->ind; | 912 | saved_ind = S->tccgen_ind; |
| 913 | 913 | ||
| 914 | S->ind = func_sub_sp_offset; | 914 | S->tccgen_ind = func_sub_sp_offset; |
| 915 | EI(S, 0x13, 0, 2, 2, -d); // addi sp, sp, -d | 915 | EI(S, 0x13, 0, 2, 2, -d); // addi sp, sp, -d |
| 916 | ES(S, 0x23, 3, 2, 1, d - 8 - num_va_regs * 8); // sd ra, d-8(sp) | 916 | ES(S, 0x23, 3, 2, 1, d - 8 - num_va_regs * 8); // sd ra, d-8(sp) |
| 917 | ES(S, 0x23, 3, 2, 8, d - 16 - num_va_regs * 8); // sd s0, d-16(sp) | 917 | ES(S, 0x23, 3, 2, 8, d - 16 - num_va_regs * 8); // sd s0, d-16(sp) |
| @@ -919,18 +919,18 @@ ST_FUNC void gfunc_epilog(TCCState *S) · 1 unmodified line | |||
| 919 | EI(S, 0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d | 919 | EI(S, 0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d |
| 920 | else | 920 | else |
| 921 | gjmp_addr(S, large_ofs_ind); | 921 | gjmp_addr(S, large_ofs_ind); |
| 922 | if ((S->ind - func_sub_sp_offset) != 5*4) | 922 | if ((S->tccgen_ind - func_sub_sp_offset) != 5*4) |
| 923 | EI(S, 0x13, 0, 0, 0, 0); // addi x0, x0, 0 == nop | 923 | EI(S, 0x13, 0, 0, 0, 0); // addi x0, x0, 0 == nop |
| 924 | S->ind = saved_ind; | 924 | S->tccgen_ind = saved_ind; |
| 925 | } | 925 | } |
| 926 | 926 | ||
| 927 | ST_FUNC void gen_va_start(TCCState *S) | 927 | ST_FUNC void gen_va_start(TCCState *S) |
| 928 | { | 928 | { |
| 929 | S->vtop--; | 929 | S->tccgen_vtop--; |
| 930 | vset(S, &S->char_pointer_type, VT_LOCAL, func_va_list_ofs); | 930 | vset(S, &S->tccgen_char_pointer_type, VT_LOCAL, func_va_list_ofs); |
| 931 | } | 931 | } |
| 932 | 932 | ||
| 933 | ST_FUNC void gen_fill_nops(TCCState *S, int bytes) | 933 | ST_FUNC void gen_fill_nops(TCCState* S, int bytes) |
| 934 | { | 934 | { |
| 935 | if ((bytes & 3)) | 935 | if ((bytes & 3)) |
| 936 | tcc_error(S, "alignment of code section not multiple of 4"); | 936 | tcc_error(S, "alignment of code section not multiple of 4"); |
| @@ -941,18 +941,18 @@ ST_FUNC void gen_fill_nops(TCCState *S, int bytes) · 4 unmodified lines | |||
| 941 | } | 941 | } |
| 942 | 942 | ||
| 943 | // Generate forward branch to label: | 943 | // Generate forward branch to label: |
| 944 | ST_FUNC int gjmp(TCCState *S, int t) | 944 | ST_FUNC int gjmp(TCCState* S, int t) |
| 945 | { | 945 | { |
| 946 | if (S->nocode_wanted) | 946 | if (S->tccgen_nocode_wanted) |
| 947 | return t; | 947 | return t; |
| 948 | o(S, t); | 948 | o(S, t); |
| 949 | return S->ind - 4; | 949 | return S->tccgen_ind - 4; |
| 950 | } | 950 | } |
| 951 | 951 | ||
| 952 | // Generate branch to known address: | 952 | // Generate branch to known address: |
| 953 | ST_FUNC void gjmp_addr(TCCState *S, int a) | 953 | ST_FUNC void gjmp_addr(TCCState* S, int a) |
| 954 | { | 954 | { |
| 955 | uint32_t r = a - S->ind, imm; | 955 | uint32_t r = a - S->tccgen_ind, imm; |
| 956 | if ((r + (1 << 21)) & ~((1U << 22) - 2)) { | 956 | if ((r + (1 << 21)) & ~((1U << 22) - 2)) { |
| 957 | o(S, 0x17 | (5 << 7) | (((r + 0x800) & 0xfffff000))); // lui RR, up(r) | 957 | o(S, 0x17 | (5 << 7) | (((r + 0x800) & 0xfffff000))); // lui RR, up(r) |
| 958 | r = (int)r << 20 >> 20; | 958 | r = (int)r << 20 >> 20; |
| @@ -966,11 +966,11 @@ ST_FUNC void gjmp_addr(TCCState *S, int a) · 7 unmodified lines | |||
| 966 | } | 966 | } |
| 967 | } | 967 | } |
| 968 | 968 | ||
| 969 | ST_FUNC int gjmp_cond(TCCState *S, int op, int t) | 969 | ST_FUNC int gjmp_cond(TCCState* S, int op, int t) |
| 970 | { | 970 | { |
| 971 | int tmp; | 971 | int tmp; |
| 972 | int a = S->vtop->cmp_r & 0xff; | 972 | int a = S->tccgen_vtop->cmp_r & 0xff; |
| 973 | int b = (S->vtop->cmp_r >> 8) & 0xff; | 973 | int b = (S->tccgen_vtop->cmp_r >> 8) & 0xff; |
| 974 | switch (op) { | 974 | switch (op) { |
| 975 | case TOK_ULT: op = 6; break; | 975 | case TOK_ULT: op = 6; break; |
| 976 | case TOK_UGE: op = 7; break; | 976 | case TOK_UGE: op = 7; break; |
| @@ -987,7 +987,7 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t) · 10 unmodified lines | |||
| 987 | return gjmp(S, t); | 987 | return gjmp(S, t); |
| 988 | } | 988 | } |
| 989 | 989 | ||
| 990 | ST_FUNC int gjmp_append(TCCState *S, int n, int t) | 990 | ST_FUNC int gjmp_append(TCCState* S, int n, int t) |
| 991 | { | 991 | { |
| 992 | void *p; | 992 | void *p; |
| 993 | /* insert jump list n into t */ | 993 | /* insert jump list n into t */ |
| @@ -1001,22 +1001,22 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t) · 7 unmodified lines | |||
| 1001 | return t; | 1001 | return t; |
| 1002 | } | 1002 | } |
| 1003 | 1003 | ||
| 1004 | static void gen_opil(TCCState *S, int op, int ll) | 1004 | static void gen_opil(TCCState* S, int op, int ll) |
| 1005 | { | 1005 | { |
| 1006 | int a, b, d; | 1006 | int a, b, d; |
| 1007 | int func3 = 0; | 1007 | int func3 = 0; |
| 1008 | ll = ll ? 0 : 8; | 1008 | ll = ll ? 0 : 8; |
| 1009 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 1009 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 1010 | int fc = S->vtop->c.i; | 1010 | int fc = S->tccgen_vtop->c.i; |
| 1011 | if (fc == S->vtop->c.i && !(((unsigned)fc + (1 << 11)) >> 12)) { | 1011 | if (fc == S->tccgen_vtop->c.i && !(((unsigned)fc + (1 << 11)) >> 12)) { |
| 1012 | int cll = 0; | 1012 | int cll = 0; |
| 1013 | int m = ll ? 31 : 63; | 1013 | int m = ll ? 31 : 63; |
| 1014 | vswap(S); | 1014 | vswap(S); |
| 1015 | gv(S, RC_INT); | 1015 | gv(S, RC_INT); |
| 1016 | a = ireg(S->vtop[0].r); | 1016 | a = ireg(S->tccgen_vtop[0].r); |
| 1017 | --S->vtop; | 1017 | --S->tccgen_vtop; |
| 1018 | d = get_reg(S, RC_INT); | 1018 | d = get_reg(S, RC_INT); |
| 1019 | ++S->vtop; | 1019 | ++S->tccgen_vtop; |
| 1020 | vswap(S); | 1020 | vswap(S); |
| 1021 | switch (op) { | 1021 | switch (op) { |
| 1022 | case '-': | 1022 | case '-': |
| @@ -1028,12 +1028,12 @@ static void gen_opil(TCCState *S, int op, int ll) · 5 unmodified lines | |||
| 1028 | cll = ll; | 1028 | cll = ll; |
| 1029 | do_cop: | 1029 | do_cop: |
| 1030 | EI(S, 0x13 | cll, func3, ireg(d), a, fc); | 1030 | EI(S, 0x13 | cll, func3, ireg(d), a, fc); |
| 1031 | --S->vtop; | 1031 | --S->tccgen_vtop; |
| 1032 | if (op >= TOK_ULT && op <= TOK_GT) { | 1032 | if (op >= TOK_ULT && op <= TOK_GT) { |
| 1033 | vset_VT_CMP(S, TOK_NE); | 1033 | vset_VT_CMP(S, TOK_NE); |
| 1034 | S->vtop->cmp_r = ireg(d) | 0 << 8; | 1034 | S->tccgen_vtop->cmp_r = ireg(d) | 0 << 8; |
| 1035 | } else | 1035 | } else |
| 1036 | S->vtop[0].r = d; | 1036 | S->tccgen_vtop[0].r = d; |
| 1037 | return; | 1037 | return; |
| 1038 | case TOK_LE: | 1038 | case TOK_LE: |
| 1039 | if (fc >= (1 << 11) - 1) | 1039 | if (fc >= (1 << 11) - 1) |
| @@ -1057,33 +1057,33 @@ static void gen_opil(TCCState *S, int op, int ll) · 17 unmodified lines | |||
| 1057 | case TOK_GE: /* -> TOK_LT */ | 1057 | case TOK_GE: /* -> TOK_LT */ |
| 1058 | case TOK_GT: /* -> TOK_LE */ | 1058 | case TOK_GT: /* -> TOK_LE */ |
| 1059 | gen_opil(S, op - 1, !ll); | 1059 | gen_opil(S, op - 1, !ll); |
| 1060 | S->vtop->cmp_op ^= 1; | 1060 | S->tccgen_vtop->cmp_op ^= 1; |
| 1061 | return; | 1061 | return; |
| 1062 | 1062 | ||
| 1063 | case TOK_NE: | 1063 | case TOK_NE: |
| 1064 | case TOK_EQ: | 1064 | case TOK_EQ: |
| 1065 | if (fc) | 1065 | if (fc) |
| 1066 | gen_opil(S, '-', !ll), a = ireg(S->vtop++->r); | 1066 | gen_opil(S, '-', !ll), a = ireg(S->tccgen_vtop++->r); |
| 1067 | --S->vtop; | 1067 | --S->tccgen_vtop; |
| 1068 | vset_VT_CMP(S, op); | 1068 | vset_VT_CMP(S, op); |
| 1069 | S->vtop->cmp_r = a | 0 << 8; | 1069 | S->tccgen_vtop->cmp_r = a | 0 << 8; |
| 1070 | return; | 1070 | return; |
| 1071 | } | 1071 | } |
| 1072 | } | 1072 | } |
| 1073 | } | 1073 | } |
| 1074 | gv2(S, RC_INT, RC_INT); | 1074 | gv2(S, RC_INT, RC_INT); |
| 1075 | a = ireg(S->vtop[-1].r); | 1075 | a = ireg(S->tccgen_vtop[-1].r); |
| 1076 | b = ireg(S->vtop[0].r); | 1076 | b = ireg(S->tccgen_vtop[0].r); |
| 1077 | S->vtop -= 2; | 1077 | S->tccgen_vtop -= 2; |
| 1078 | d = get_reg(S, RC_INT); | 1078 | d = get_reg(S, RC_INT); |
| 1079 | S->vtop++; | 1079 | S->tccgen_vtop++; |
| 1080 | S->vtop[0].r = d; | 1080 | S->tccgen_vtop[0].r = d; |
| 1081 | d = ireg(d); | 1081 | d = ireg(d); |
| 1082 | switch (op) { | 1082 | switch (op) { |
| 1083 | default: | 1083 | default: |
| 1084 | if (op >= TOK_ULT && op <= TOK_GT) { | 1084 | if (op >= TOK_ULT && op <= TOK_GT) { |
| 1085 | vset_VT_CMP(S, op); | 1085 | vset_VT_CMP(S, op); |
| 1086 | S->vtop->cmp_r = a | b << 8; | 1086 | S->tccgen_vtop->cmp_r = a | b << 8; |
| 1087 | break; | 1087 | break; |
| 1088 | } | 1088 | } |
| 1089 | tcc_error(S, "implement me: %s(%s)", __FUNCTION__, get_tok_str(S, op, NULL)); | 1089 | tcc_error(S, "implement me: %s(%s)", __FUNCTION__, get_tok_str(S, op, NULL)); |
| @@ -1132,21 +1132,21 @@ static void gen_opil(TCCState *S, int op, int ll) · 42 unmodified lines | |||
| 1132 | } | 1132 | } |
| 1133 | } | 1133 | } |
| 1134 | 1134 | ||
| 1135 | ST_FUNC void gen_opi(TCCState *S, int op) | 1135 | ST_FUNC void gen_opi(TCCState* S, int op) |
| 1136 | { | 1136 | { |
| 1137 | gen_opil(S, op, 0); | 1137 | gen_opil(S, op, 0); |
| 1138 | } | 1138 | } |
| 1139 | 1139 | ||
| 1140 | ST_FUNC void gen_opl(TCCState *S, int op) | 1140 | ST_FUNC void gen_opl(TCCState* S, int op) |
| 1141 | { | 1141 | { |
| 1142 | gen_opil(S, op, 1); | 1142 | gen_opil(S, op, 1); |
| 1143 | } | 1143 | } |
| 1144 | 1144 | ||
| 1145 | ST_FUNC void gen_opf(TCCState *S, int op) | 1145 | ST_FUNC void gen_opf(TCCState* S, int op) |
| 1146 | { | 1146 | { |
| 1147 | int rs1, rs2, rd, dbl, invert; | 1147 | int rs1, rs2, rd, dbl, invert; |
| 1148 | if (S->vtop[0].type.t == VT_LDOUBLE) { | 1148 | if (S->tccgen_vtop[0].type.t == VT_LDOUBLE) { |
| 1149 | CType type = S->vtop[0].type; | 1149 | CType type = S->tccgen_vtop[0].type; |
| 1150 | int func = 0; | 1150 | int func = 0; |
| 1151 | int cond = -1; | 1151 | int cond = -1; |
| 1152 | switch (op) { | 1152 | switch (op) { |
| @@ -1166,10 +1166,10 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 13 unmodified lines | |||
| 1166 | vrott(S, 3); | 1166 | vrott(S, 3); |
| 1167 | gfunc_call(S, 2); | 1167 | gfunc_call(S, 2); |
| 1168 | vpushi(S, 0); | 1168 | vpushi(S, 0); |
| 1169 | S->vtop->r = REG_IRET; | 1169 | S->tccgen_vtop->r = REG_IRET; |
| 1170 | S->vtop->r2 = cond < 0 ? TREG_R(1) : VT_CONST; | 1170 | S->tccgen_vtop->r2 = cond < 0 ? TREG_R(1) : VT_CONST; |
| 1171 | if (cond < 0) | 1171 | if (cond < 0) |
| 1172 | S->vtop->type = type; | 1172 | S->tccgen_vtop->type = type; |
| 1173 | else { | 1173 | else { |
| 1174 | vpushi(S, 0); | 1174 | vpushi(S, 0); |
| 1175 | gen_opil(S, op, 1); | 1175 | gen_opil(S, op, 1); |
| @@ -1178,11 +1178,11 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 2 unmodified lines | |||
| 1178 | } | 1178 | } |
| 1179 | 1179 | ||
| 1180 | gv2(S, RC_FLOAT, RC_FLOAT); | 1180 | gv2(S, RC_FLOAT, RC_FLOAT); |
| 1181 | assert(S->vtop->type.t == VT_DOUBLE || S->vtop->type.t == VT_FLOAT); | 1181 | assert(S->tccgen_vtop->type.t == VT_DOUBLE || S->tccgen_vtop->type.t == VT_FLOAT); |
| 1182 | dbl = S->vtop->type.t == VT_DOUBLE; | 1182 | dbl = S->tccgen_vtop->type.t == VT_DOUBLE; |
| 1183 | rs1 = freg(S->vtop[-1].r); | 1183 | rs1 = freg(S->tccgen_vtop[-1].r); |
| 1184 | rs2 = freg(S->vtop->r); | 1184 | rs2 = freg(S->tccgen_vtop->r); |
| 1185 | S->vtop--; | 1185 | S->tccgen_vtop--; |
| 1186 | invert = 0; | 1186 | invert = 0; |
| 1187 | switch(op) { | 1187 | switch(op) { |
| 1188 | default: | 1188 | default: |
| @@ -1191,7 +1191,7 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 2 unmodified lines | |||
| 1191 | op = 0; // fadd | 1191 | op = 0; // fadd |
| 1192 | arithop: | 1192 | arithop: |
| 1193 | rd = get_reg(S, RC_FLOAT); | 1193 | rd = get_reg(S, RC_FLOAT); |
| 1194 | S->vtop->r = rd; | 1194 | S->tccgen_vtop->r = rd; |
| 1195 | rd = freg(rd); | 1195 | rd = freg(rd); |
| 1196 | ER(S, 0x53, 7, rd, rs1, rs2, dbl | (op << 2)); // fop.[sd] RD, RS1, RS2 (dyn rm) | 1196 | ER(S, 0x53, 7, rd, rs1, rs2, dbl | (op << 2)); // fop.[sd] RD, RS1, RS2 (dyn rm) |
| 1197 | break; | 1197 | break; |
| @@ -1208,7 +1208,7 @@ ST_FUNC void gen_opf(TCCState *S, int op) · 10 unmodified lines | |||
| 1208 | op = 2; // EQ | 1208 | op = 2; // EQ |
| 1209 | cmpop: | 1209 | cmpop: |
| 1210 | rd = get_reg(S, RC_INT); | 1210 | rd = get_reg(S, RC_INT); |
| 1211 | S->vtop->r = rd; | 1211 | S->tccgen_vtop->r = rd; |
| 1212 | rd = ireg(rd); | 1212 | rd = ireg(rd); |
| 1213 | ER(S, 0x53, op, rd, rs1, rs2, dbl | 0x50); // fcmp.[sd] RD, RS1, RS2 (op == eq/lt/le) | 1213 | ER(S, 0x53, op, rd, rs1, rs2, dbl | 0x50); // fcmp.[sd] RD, RS1, RS2 (op == eq/lt/le) |
| 1214 | if (invert) | 1214 | if (invert) |
| @@ -1241,11 +1241,11 @@ ST_FUNC void gen_cvt_sxtw(TCCState *S) · 26 unmodified lines | |||
| 1241 | Let's try to not do anything here. */ | 1241 | Let's try to not do anything here. */ |
| 1242 | } | 1242 | } |
| 1243 | 1243 | ||
| 1244 | ST_FUNC void gen_cvt_itof(TCCState *S, int t) | 1244 | ST_FUNC void gen_cvt_itof(TCCState* S, int t) |
| 1245 | { | 1245 | { |
| 1246 | int rr = ireg(gv(S, RC_INT)), dr; | 1246 | int rr = ireg(gv(S, RC_INT)), dr; |
| 1247 | int u = S->vtop->type.t & VT_UNSIGNED; | 1247 | int u = S->tccgen_vtop->type.t & VT_UNSIGNED; |
| 1248 | int l = (S->vtop->type.t & VT_BTYPE) == VT_LLONG; | 1248 | int l = (S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG; |
| 1249 | if (t == VT_LDOUBLE) { | 1249 | if (t == VT_LDOUBLE) { |
| 1250 | int func = l ? | 1250 | int func = l ? |
| 1251 | (u ? TOK___floatunditf : TOK___floatditf) : | 1251 | (u ? TOK___floatunditf : TOK___floatditf) : |
| @@ -1254,22 +1254,22 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t) · 2 unmodified lines | |||
| 1254 | vrott(S, 2); | 1254 | vrott(S, 2); |
| 1255 | gfunc_call(S, 1); | 1255 | gfunc_call(S, 1); |
| 1256 | vpushi(S, 0); | 1256 | vpushi(S, 0); |
| 1257 | S->vtop->type.t = t; | 1257 | S->tccgen_vtop->type.t = t; |
| 1258 | S->vtop->r = REG_IRET; | 1258 | S->tccgen_vtop->r = REG_IRET; |
| 1259 | S->vtop->r2 = TREG_R(1); | 1259 | S->tccgen_vtop->r2 = TREG_R(1); |
| 1260 | } else { | 1260 | } else { |
| 1261 | S->vtop--; | 1261 | S->tccgen_vtop--; |
| 1262 | dr = get_reg(S, RC_FLOAT); | 1262 | dr = get_reg(S, RC_FLOAT); |
| 1263 | S->vtop++; | 1263 | S->tccgen_vtop++; |
| 1264 | S->vtop->r = dr; | 1264 | S->tccgen_vtop->r = dr; |
| 1265 | dr = freg(dr); | 1265 | dr = freg(dr); |
| 1266 | EIu(S, 0x53, 7, dr, rr, ((0x68 | (t == VT_DOUBLE ? 1 : 0)) << 5) | (u ? 1 : 0) | (l ? 2 : 0)); // fcvt.[sd].[wl][u] | 1266 | EIu(S, 0x53, 7, dr, rr, ((0x68 | (t == VT_DOUBLE ? 1 : 0)) << 5) | (u ? 1 : 0) | (l ? 2 : 0)); // fcvt.[sd].[wl][u] |
| 1267 | } | 1267 | } |
| 1268 | } | 1268 | } |
| 1269 | 1269 | ||
| 1270 | ST_FUNC void gen_cvt_ftoi(TCCState *S, int t) | 1270 | ST_FUNC void gen_cvt_ftoi(TCCState* S, int t) |
| 1271 | { | 1271 | { |
| 1272 | int ft = S->vtop->type.t & VT_BTYPE; | 1272 | int ft = S->tccgen_vtop->type.t & VT_BTYPE; |
| 1273 | int l = (t & VT_BTYPE) == VT_LLONG; | 1273 | int l = (t & VT_BTYPE) == VT_LLONG; |
| 1274 | int u = t & VT_UNSIGNED; | 1274 | int u = t & VT_UNSIGNED; |
| 1275 | if (ft == VT_LDOUBLE) { | 1275 | if (ft == VT_LDOUBLE) { |
| @@ -1280,22 +1280,22 @@ ST_FUNC void gen_cvt_ftoi(TCCState *S, int t) · 4 unmodified lines | |||
| 1280 | vrott(S, 2); | 1280 | vrott(S, 2); |
| 1281 | gfunc_call(S, 1); | 1281 | gfunc_call(S, 1); |
| 1282 | vpushi(S, 0); | 1282 | vpushi(S, 0); |
| 1283 | S->vtop->type.t = t; | 1283 | S->tccgen_vtop->type.t = t; |
| 1284 | S->vtop->r = REG_IRET; | 1284 | S->tccgen_vtop->r = REG_IRET; |
| 1285 | } else { | 1285 | } else { |
| 1286 | int rr = freg(gv(S, RC_FLOAT)), dr; | 1286 | int rr = freg(gv(S, RC_FLOAT)), dr; |
| 1287 | S->vtop--; | 1287 | S->tccgen_vtop--; |
| 1288 | dr = get_reg(S, RC_INT); | 1288 | dr = get_reg(S, RC_INT); |
| 1289 | S->vtop++; | 1289 | S->tccgen_vtop++; |
| 1290 | S->vtop->r = dr; | 1290 | S->tccgen_vtop->r = dr; |
| 1291 | dr = ireg(dr); | 1291 | dr = ireg(dr); |
| 1292 | EIu(S, 0x53, 1, dr, rr, ((0x60 | (ft == VT_DOUBLE ? 1 : 0)) << 5) | (u ? 1 : 0) | (l ? 2 : 0)); // fcvt.[wl][u].[sd] rtz | 1292 | EIu(S, 0x53, 1, dr, rr, ((0x60 | (ft == VT_DOUBLE ? 1 : 0)) << 5) | (u ? 1 : 0) | (l ? 2 : 0)); // fcvt.[wl][u].[sd] rtz |
| 1293 | } | 1293 | } |
| 1294 | } | 1294 | } |
| 1295 | 1295 | ||
| 1296 | ST_FUNC void gen_cvt_ftof(TCCState *S, int dt) | 1296 | ST_FUNC void gen_cvt_ftof(TCCState* S, int dt) |
| 1297 | { | 1297 | { |
| 1298 | int st = S->vtop->type.t & VT_BTYPE, rs, rd; | 1298 | int st = S->tccgen_vtop->type.t & VT_BTYPE, rs, rd; |
| 1299 | dt &= VT_BTYPE; | 1299 | dt &= VT_BTYPE; |
| 1300 | if (st == dt) | 1300 | if (st == dt) |
| 1301 | return; | 1301 | return; |
| @@ -1312,21 +1312,21 @@ ST_FUNC void gen_cvt_ftof(TCCState *S, int dt) · 10 unmodified lines | |||
| 1312 | gv(S, RC_F(0)); | 1312 | gv(S, RC_F(0)); |
| 1313 | else { | 1313 | else { |
| 1314 | gv(S, RC_R(0)); | 1314 | gv(S, RC_R(0)); |
| 1315 | assert(S->vtop->r2 < 7); | 1315 | assert(S->tccgen_vtop->r2 < 7); |
| 1316 | if (S->vtop->r2 != 1 + S->vtop->r) { | 1316 | if (S->tccgen_vtop->r2 != 1 + S->tccgen_vtop->r) { |
| 1317 | EI(S, 0x13, 0, ireg(S->vtop->r) + 1, ireg(S->vtop->r2), 0); // mv Ra+1, RR2 | 1317 | EI(S, 0x13, 0, ireg(S->tccgen_vtop->r) + 1, ireg(S->tccgen_vtop->r2), 0); // mv Ra+1, RR2 |
| 1318 | S->vtop->r2 = 1 + S->vtop->r; | 1318 | S->tccgen_vtop->r2 = 1 + S->tccgen_vtop->r; |
| 1319 | } | 1319 | } |
| 1320 | } | 1320 | } |
| 1321 | vpush_helper_func(S, func); | 1321 | vpush_helper_func(S, func); |
| 1322 | gcall_or_jmp(S, 1); | 1322 | gcall_or_jmp(S, 1); |
| 1323 | S->vtop -= 2; | 1323 | S->tccgen_vtop -= 2; |
| 1324 | vpushi(S, 0); | 1324 | vpushi(S, 0); |
| 1325 | S->vtop->type.t = dt; | 1325 | S->tccgen_vtop->type.t = dt; |
| 1326 | if (dt == VT_LDOUBLE) | 1326 | if (dt == VT_LDOUBLE) |
| 1327 | S->vtop->r = REG_IRET, S->vtop->r2 = REG_IRET+1; | 1327 | S->tccgen_vtop->r = REG_IRET, S->tccgen_vtop->r2 = REG_IRET+1; |
| 1328 | else | 1328 | else |
| 1329 | S->vtop->r = REG_FRET; | 1329 | S->tccgen_vtop->r = REG_FRET; |
| 1330 | } else { | 1330 | } else { |
| 1331 | assert (dt == VT_FLOAT || dt == VT_DOUBLE); | 1331 | assert (dt == VT_FLOAT || dt == VT_DOUBLE); |
| 1332 | assert (st == VT_FLOAT || st == VT_DOUBLE); | 1332 | assert (st == VT_FLOAT || st == VT_DOUBLE); |
| @@ -1336,59 +1336,59 @@ ST_FUNC void gen_cvt_ftof(TCCState *S, int dt) · 3 unmodified lines | |||
| 1336 | EI(S, 0x53, 0, freg(rd), freg(rs), 0x21 << 5); // fcvt.d.s RD, RS (no rm) | 1336 | EI(S, 0x53, 0, freg(rd), freg(rs), 0x21 << 5); // fcvt.d.s RD, RS (no rm) |
| 1337 | else | 1337 | else |
| 1338 | EI(S, 0x53, 7, freg(rd), freg(rs), (0x20 << 5) | 1); // fcvt.s.d RD, RS (dyn rm) | 1338 | EI(S, 0x53, 7, freg(rd), freg(rs), (0x20 << 5) | 1); // fcvt.s.d RD, RS (dyn rm) |
| 1339 | S->vtop->r = rd; | 1339 | S->tccgen_vtop->r = rd; |
| 1340 | } | 1340 | } |
| 1341 | } | 1341 | } |
| 1342 | 1342 | ||
| 1343 | /* increment tcov counter */ | 1343 | /* increment tcov counter */ |
| 1344 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv) | 1344 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv) |
| 1345 | { | 1345 | { |
| 1346 | int r1, r2; | 1346 | int r1, r2; |
| 1347 | Sym label = {0}; | 1347 | Sym label = {0}; |
| 1348 | label.type.t = VT_VOID | VT_STATIC; | 1348 | label.type.t = VT_VOID | VT_STATIC; |
| 1349 | 1349 | ||
| 1350 | vpushv(S, sv); | 1350 | vpushv(S, sv); |
| 1351 | S->vtop->r = r1 = get_reg(S, RC_INT); | 1351 | S->tccgen_vtop->r = r1 = get_reg(S, RC_INT); |
| 1352 | r2 = get_reg(S, RC_INT); | 1352 | r2 = get_reg(S, RC_INT); |
| 1353 | r1 = ireg(r1); | 1353 | r1 = ireg(r1); |
| 1354 | r2 = ireg(r2); | 1354 | r2 = ireg(r2); |
| 1355 | greloca(S, cur_text_section, sv->sym, S->ind, R_RISCV_PCREL_HI20, 0); | 1355 | greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_RISCV_PCREL_HI20, 0); |
| 1356 | put_extern_sym(S, &label, cur_text_section, S->ind, 0); | 1356 | put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0); |
| 1357 | o(S, 0x17 | (r1 << 7)); // auipc RR, 0 %pcrel_hi(sym) | 1357 | o(S, 0x17 | (r1 << 7)); // auipc RR, 0 %pcrel_hi(sym) |
| 1358 | greloca(S, cur_text_section, &label, S->ind, R_RISCV_PCREL_LO12_I, 0); | 1358 | greloca(S, cur_text_section, &label, S->tccgen_ind, R_RISCV_PCREL_LO12_I, 0); |
| 1359 | EI(S, 0x03, 3, r2, r1, 0); // ld r2, x[r1] | 1359 | EI(S, 0x03, 3, r2, r1, 0); // ld r2, x[r1] |
| 1360 | EI(S, 0x13, 0, r2, r2, 1); // addi r2, r2, #1 | 1360 | EI(S, 0x13, 0, r2, r2, 1); // addi r2, r2, #1 |
| 1361 | greloca(S, cur_text_section, sv->sym, S->ind, R_RISCV_PCREL_HI20, 0); | 1361 | greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_RISCV_PCREL_HI20, 0); |
| 1362 | label.c = 0; /* force new local ELF symbol */ | 1362 | label.c = 0; /* force new local ELF symbol */ |
| 1363 | put_extern_sym(S, &label, cur_text_section, S->ind, 0); | 1363 | put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0); |
| 1364 | o(S, 0x17 | (r1 << 7)); // auipc RR, 0 %pcrel_hi(sym) | 1364 | o(S, 0x17 | (r1 << 7)); // auipc RR, 0 %pcrel_hi(sym) |
| 1365 | greloca(S, cur_text_section, &label, S->ind, R_RISCV_PCREL_LO12_S, 0); | 1365 | greloca(S, cur_text_section, &label, S->tccgen_ind, R_RISCV_PCREL_LO12_S, 0); |
| 1366 | ES(S, 0x23, 3, r1, r2, 0); // sd r2, [r1] | 1366 | ES(S, 0x23, 3, r1, r2, 0); // sd r2, [r1] |
| 1367 | vpop(S); | 1367 | vpop(S); |
| 1368 | } | 1368 | } |
| 1369 | 1369 | ||
| 1370 | ST_FUNC void ggoto(TCCState *S) | 1370 | ST_FUNC void ggoto(TCCState* S) |
| 1371 | { | 1371 | { |
| 1372 | gcall_or_jmp(S, 0); | 1372 | gcall_or_jmp(S, 0); |
| 1373 | S->vtop--; | 1373 | S->tccgen_vtop--; |
| 1374 | } | 1374 | } |
| 1375 | 1375 | ||
| 1376 | ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) | 1376 | ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) |
| 1377 | { | 1377 | { |
| 1378 | ES(S, 0x23, 3, 8, 2, addr); // sd sp, fc(s0) | 1378 | ES(S, 0x23, 3, 8, 2, addr); // sd sp, fc(s0) |
| 1379 | } | 1379 | } |
| 1380 | 1380 | ||
| 1381 | ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) | 1381 | ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) |
| 1382 | { | 1382 | { |
| 1383 | EI(S, 0x03, 3, 2, 8, addr); // ld sp, fc(s0) | 1383 | EI(S, 0x03, 3, 2, 8, addr); // ld sp, fc(s0) |
| 1384 | } | 1384 | } |
| 1385 | 1385 | ||
| 1386 | ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) | 1386 | ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) |
| 1387 | { | 1387 | { |
| 1388 | int rr; | 1388 | int rr; |
| 1389 | #if defined(CONFIG_TCC_BCHECK) | 1389 | #if defined(CONFIG_TCC_BCHECK) |
| 1390 | if (S->do_bounds_check) | 1390 | if (S->do_bounds_check) |
| 1391 | vpushv(S, S->vtop); | 1391 | vpushv(S, S->tccgen_vtop); |
| 1392 | #endif | 1392 | #endif |
| 1393 | rr = ireg(gv(S, RC_INT)); | 1393 | rr = ireg(gv(S, RC_INT)); |
| 1394 | #if defined(CONFIG_TCC_BCHECK) | 1394 | #if defined(CONFIG_TCC_BCHECK) |
| @@ -1403,7 +1403,7 @@ ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) · 8 unmodified lines | |||
| 1403 | #if defined(CONFIG_TCC_BCHECK) | 1403 | #if defined(CONFIG_TCC_BCHECK) |
| 1404 | if (S->do_bounds_check) { | 1404 | if (S->do_bounds_check) { |
| 1405 | vpushi(S, 0); | 1405 | vpushi(S, 0); |
| 1406 | S->vtop->r = TREG_R(0); | 1406 | S->tccgen_vtop->r = TREG_R(0); |
| 1407 | o(S, 0x00010513); /* mv a0,sp */ | 1407 | o(S, 0x00010513); /* mv a0,sp */ |
| 1408 | vswap(S); | 1408 | vswap(S); |
| 1409 | vpush_helper_func(S, TOK___bound_new_region); | 1409 | vpush_helper_func(S, TOK___bound_new_region); |
| @@ -1074,21 +1074,21 @@ struct TCCState { · 1073 unmodified lines | |||
| 1074 | /* ------------ tccpp.c ------------ */ | 1074 | /* ------------ tccpp.c ------------ */ |
| 1075 | 1075 | ||
| 1076 | struct BufferedFile *tccpp_file; | 1076 | struct BufferedFile *tccpp_file; |
| 1077 | int tccpp_ch, tok; | 1077 | int tccpp_ch, tccpp_tok; |
| 1078 | CValue tokc; | 1078 | CValue tccpp_tokc; |
| 1079 | const int *tccpp_macro_ptr; | 1079 | const int *tccpp_macro_ptr; |
| 1080 | int tccpp_parse_flags; | 1080 | int tccpp_parse_flags; |
| 1081 | int tok_flags; | 1081 | int tccpp_tok_flags; |
| 1082 | CString tokcstr; /* current parsed string, if any */ | 1082 | CString tccpp_tokcstr; /* current parsed string, if any */ |
| 1083 | CString tccpp_cstr_buf; | 1083 | CString tccpp_cstr_buf; |
| 1084 | CString tccpp_macro_equal_buf; | 1084 | CString tccpp_macro_equal_buf; |
| 1085 | TokenString tokstr_buf; | 1085 | TokenString tccpp_tokstr_buf; |
| 1086 | TokenString *tccpp_macro_stack; | 1086 | TokenString *tccpp_macro_stack; |
| 1087 | 1087 | ||
| 1088 | /* display benchmark infos */ | 1088 | /* display benchmark infos */ |
| 1089 | int tccpp_total_lines; | 1089 | int tccpp_total_lines; |
| 1090 | int tccpp_total_bytes; | 1090 | int tccpp_total_bytes; |
| 1091 | int tok_ident; | 1091 | int tccpp_tok_ident; |
| 1092 | TokenSym **tccpp_table_ident; | 1092 | TokenSym **tccpp_table_ident; |
| 1093 | 1093 | ||
| 1094 | int *tccpp_macro_ptr_allocated; | 1094 | int *tccpp_macro_ptr_allocated; |
| @@ -1096,7 +1096,7 @@ struct TCCState { · 1 unmodified line | |||
| 1096 | int tccpp_unget_saved_buffer[TOK_MAX_SIZE + 1]; | 1096 | int tccpp_unget_saved_buffer[TOK_MAX_SIZE + 1]; |
| 1097 | int tccpp_unget_buffer_enabled; | 1097 | int tccpp_unget_buffer_enabled; |
| 1098 | TokenSym *tccpp_hash_ident[TOK_HASH_SIZE]; | 1098 | TokenSym *tccpp_hash_ident[TOK_HASH_SIZE]; |
| 1099 | char token_buf[STRING_MAX_SIZE + 1]; | 1099 | char tccpp_token_buf[STRING_MAX_SIZE + 1]; |
| 1100 | /* true if isid(c) || isnum(c) */ | 1100 | /* true if isid(c) || isnum(c) */ |
| 1101 | unsigned char tccpp_isidnum_table[256-CH_EOF]; | 1101 | unsigned char tccpp_isidnum_table[256-CH_EOF]; |
| 1102 | 1102 | ||
| @@ -1105,8 +1105,8 @@ struct TCCState { · 2 unmodified lines | |||
| 1105 | int tccpp_pp_expr; | 1105 | int tccpp_pp_expr; |
| 1106 | int tccpp_pp_counter; | 1106 | int tccpp_pp_counter; |
| 1107 | 1107 | ||
| 1108 | TinyAlloc *toksym_alloc; | 1108 | TinyAlloc *tccpp_toksym_alloc; |
| 1109 | TinyAlloc *tokstr_alloc; | 1109 | TinyAlloc *tccpp_tokstr_alloc; |
| 1110 | 1110 | ||
| 1111 | /*----------- tccasm.c --------*/ | 1111 | /*----------- tccasm.c --------*/ |
| 1112 | Section *tccasm_last_text_section; /* to handle .previous asm directive */ | 1112 | Section *tccasm_last_text_section; /* to handle .previous asm directive */ |
| @@ -1114,18 +1114,18 @@ struct TCCState { · 1 unmodified line | |||
| 1114 | /* ------------ tccgen.c ------------ */ | 1114 | /* ------------ tccgen.c ------------ */ |
| 1115 | 1115 | ||
| 1116 | Sym *tccgen_global_stack; | 1116 | Sym *tccgen_global_stack; |
| 1117 | Sym *local_stack; | 1117 | Sym *tccgen_local_stack; |
| 1118 | Sym *local_label_stack; | 1118 | Sym *tccgen_local_label_stack; |
| 1119 | Sym *tccgen_global_label_stack; | 1119 | Sym *tccgen_global_label_stack; |
| 1120 | Sym *tccgen_define_stack; | 1120 | Sym *tccgen_define_stack; |
| 1121 | CType tccgen_int_type, tccgen_func_old_type, tccgen_char_type, char_pointer_type; | 1121 | CType tccgen_int_type, tccgen_func_old_type, tccgen_char_type, tccgen_char_pointer_type; |
| 1122 | SValue *vtop; | 1122 | SValue *tccgen_vtop; |
| 1123 | SValue tccgen__vstack[1 + VSTACK_SIZE]; | 1123 | SValue tccgen__vstack[1 + VSTACK_SIZE]; |
| 1124 | int tccgen_rsym, tccgen_anon_sym, ind, loc; | 1124 | int tccgen_rsym, tccgen_anon_sym, tccgen_ind, tccgen_loc; |
| 1125 | char tccgen_debug_modes; | 1125 | char tccgen_debug_modes; |
| 1126 | 1126 | ||
| 1127 | int tccgen_const_wanted; /* true if constant wanted */ | 1127 | int tccgen_const_wanted; /* true if constant wanted */ |
| 1128 | int nocode_wanted; /* true if no code generation wanted for an expression */ | 1128 | int tccgen_nocode_wanted; /* true if no code generation wanted for an expression */ |
| 1129 | int tccgen_global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */ | 1129 | int tccgen_global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */ |
| 1130 | CType tccgen_func_vt; /* current function return type (used by return instruction) */ | 1130 | CType tccgen_func_vt; /* current function return type (used by return instruction) */ |
| 1131 | int tccgen_func_var; /* true if current function is variadic */ | 1131 | int tccgen_func_var; /* true if current function is variadic */ |
| @@ -1136,7 +1136,7 @@ struct TCCState { · 4 unmodified lines | |||
| 1136 | void **tccgen_sym_pools; | 1136 | void **tccgen_sym_pools; |
| 1137 | int tccgen_nb_sym_pools; | 1137 | int tccgen_nb_sym_pools; |
| 1138 | Sym *tccgen_all_cleanups, *tccgen_pending_gotos; | 1138 | Sym *tccgen_all_cleanups, *tccgen_pending_gotos; |
| 1139 | int local_scope; | 1139 | int tccgen_local_scope; |
| 1140 | int tccgen_in_sizeof; | 1140 | int tccgen_in_sizeof; |
| 1141 | int tccgen_in_generic; | 1141 | int tccgen_in_generic; |
| 1142 | int tccgen_section_sym; | 1142 | int tccgen_section_sym; |
| @@ -1155,7 +1155,7 @@ struct TCCState { · 12 unmodified lines | |||
| 1155 | int tccgen_debug_next_type; | 1155 | int tccgen_debug_next_type; |
| 1156 | debug_hash_t *tccgen_debug_hash; | 1156 | debug_hash_t *tccgen_debug_hash; |
| 1157 | int tccgen_n_debug_hash; | 1157 | int tccgen_n_debug_hash; |
| 1158 | debug_info_t *debug_info, *debug_info_root; | 1158 | debug_info_t *tccgen_debug_info, *tccgen_debug_info_root; |
| 1159 | 1159 | ||
| 1160 | unsigned char tccgen_prec[256]; | 1160 | unsigned char tccgen_prec[256]; |
| 1161 | 1161 | ||
| @@ -1374,22 +1374,22 @@ PUB_FUNC void tcc_free_base(void *ptr); · 212 unmodified lines | |||
| 1374 | PUB_FUNC void *tcc_malloc_base(unsigned long size); | 1374 | PUB_FUNC void *tcc_malloc_base(unsigned long size); |
| 1375 | PUB_FUNC void *tcc_mallocz_base(unsigned long size); | 1375 | PUB_FUNC void *tcc_mallocz_base(unsigned long size); |
| 1376 | #ifndef MEM_DEBUG | 1376 | #ifndef MEM_DEBUG |
| 1377 | PUB_FUNC void tcc_free(TCCState *S, void *ptr); | 1377 | PUB_FUNC void tcc_free(TCCState* S, void *ptr); |
| 1378 | PUB_FUNC void *tcc_malloc(TCCState *S, unsigned long size); | 1378 | PUB_FUNC void *tcc_malloc(TCCState* S, unsigned long size); |
| 1379 | PUB_FUNC void *tcc_mallocz(TCCState *S, unsigned long size); | 1379 | PUB_FUNC void *tcc_mallocz(TCCState* S, unsigned long size); |
| 1380 | PUB_FUNC void *tcc_realloc(TCCState *S, void *ptr, unsigned long size); | 1380 | PUB_FUNC void *tcc_realloc(TCCState* S, void *ptr, unsigned long size); |
| 1381 | PUB_FUNC char *tcc_strdup(TCCState *S, const char *str); | 1381 | PUB_FUNC char *tcc_strdup(TCCState* S, const char *str); |
| 1382 | #else | 1382 | #else |
| 1383 | #define tcc_free(s, ptr) tcc_free_debug(s, ptr) | 1383 | #define tcc_free(s, ptr) tcc_free_debug(s, ptr) |
| 1384 | #define tcc_malloc(s, size) tcc_malloc_debug(s, size, __FILE__, __LINE__) | 1384 | #define tcc_malloc(s, size) tcc_malloc_debug(s, size, __FILE__, __LINE__) |
| 1385 | #define tcc_mallocz(s, size) tcc_mallocz_debug(s, size, __FILE__, __LINE__) | 1385 | #define tcc_mallocz(s, size) tcc_mallocz_debug(s, size, __FILE__, __LINE__) |
| 1386 | #define tcc_realloc(s, ptr, size) tcc_realloc_debug(s, ptr, size, __FILE__, __LINE__) | 1386 | #define tcc_realloc(s, ptr, size) tcc_realloc_debug(s, ptr, size, __FILE__, __LINE__) |
| 1387 | #define tcc_strdup(s, str) tcc_strdup_debug(s, str, __FILE__, __LINE__) | 1387 | #define tcc_strdup(s, str) tcc_strdup_debug(s, str, __FILE__, __LINE__) |
| 1388 | PUB_FUNC void tcc_free_debug(TCCState *S, void *ptr); | 1388 | PUB_FUNC void tcc_free_debug(TCCState* S, void *ptr); |
| 1389 | PUB_FUNC void *tcc_malloc_debug(TCCState *S, unsigned long size, const char *file, int line); | 1389 | PUB_FUNC void *tcc_malloc_debug(TCCState* S, unsigned long size, const char *file, int line); |
| 1390 | PUB_FUNC void *tcc_mallocz_debug(TCCState *S, unsigned long size, const char *file, int line); | 1390 | PUB_FUNC void *tcc_mallocz_debug(TCCState* S, unsigned long size, const char *file, int line); |
| 1391 | PUB_FUNC void *tcc_realloc_debug(TCCState *S, void *ptr, unsigned long size, const char *file, int line); | 1391 | PUB_FUNC void *tcc_realloc_debug(TCCState* S, void *ptr, unsigned long size, const char *file, int line); |
| 1392 | PUB_FUNC char *tcc_strdup_debug(TCCState *S, const char *str, const char *file, int line); | 1392 | PUB_FUNC char *tcc_strdup_debug(TCCState* S, const char *str, const char *file, int line); |
| 1393 | #endif | 1393 | #endif |
| 1394 | 1394 | ||
| 1395 | #define free(p) use_tcc_free(S, p) | 1395 | #define free(p) use_tcc_free(S, p) |
| @@ -1397,22 +1397,22 @@ PUB_FUNC char *tcc_strdup_debug(TCCState *S, const char *str, const char *file, · 1 unmodified line | |||
| 1397 | #define realloc(p, s) use_tcc_realloc(S, p, s) | 1397 | #define realloc(p, s) use_tcc_realloc(S, p, s) |
| 1398 | #undef strdup | 1398 | #undef strdup |
| 1399 | #define strdup(s) use_tcc_strdup(S, s) | 1399 | #define strdup(s) use_tcc_strdup(S, s) |
| 1400 | PUB_FUNC void _tcc_error_noabort(TCCState *S, const char *fmt, ...) PRINTF_LIKE(2,3); | 1400 | PUB_FUNC void _tcc_error_noabort(TCCState* S, const char *fmt, ...) PRINTF_LIKE(2,3); |
| 1401 | PUB_FUNC NORETURN void _tcc_error(TCCState *S, const char *fmt, ...) PRINTF_LIKE(2,3); | 1401 | PUB_FUNC NORETURN void _tcc_error(TCCState* S, const char *fmt, ...) PRINTF_LIKE(2,3); |
| 1402 | PUB_FUNC void _tcc_warning(TCCState *S, const char *fmt, ...) PRINTF_LIKE(2,3); | 1402 | PUB_FUNC void _tcc_warning(TCCState* S, const char *fmt, ...) PRINTF_LIKE(2,3); |
| 1403 | #define tcc_internal_error(S, msg) tcc_error(S, "internal compiler error\n"\ | 1403 | #define tcc_internal_error(S, msg) tcc_error(S, "internal compiler error\n"\ |
| 1404 | "%s:%d: in %s(): " msg, __FILE__,__LINE__,__FUNCTION__) | 1404 | "%s:%d: in %s(): " msg, __FILE__,__LINE__,__FUNCTION__) |
| 1405 | 1405 | ||
| 1406 | /* other utilities */ | 1406 | /* other utilities */ |
| 1407 | ST_FUNC void dynarray_add(TCCState *S, void *ptab, int *nb_ptr, void *data); | 1407 | ST_FUNC void dynarray_add(TCCState* S, void *ptab, int *nb_ptr, void *data); |
| 1408 | ST_FUNC void dynarray_reset(TCCState *S, void *pp, int *n); | 1408 | ST_FUNC void dynarray_reset(TCCState* S, void *pp, int *n); |
| 1409 | ST_INLN void cstr_ccat(TCCState *S, CString *cstr, int ch); | 1409 | ST_INLN void cstr_ccat(TCCState* S, CString *cstr, int ch); |
| 1410 | ST_FUNC void cstr_cat(TCCState *S, CString *cstr, const char *str, int len); | 1410 | ST_FUNC void cstr_cat(TCCState* S, CString *cstr, const char *str, int len); |
| 1411 | ST_FUNC void cstr_wccat(TCCState *S, CString *cstr, int ch); | 1411 | ST_FUNC void cstr_wccat(TCCState* S, CString *cstr, int ch); |
| 1412 | ST_FUNC void cstr_new(TCCState *S, CString *cstr); | 1412 | ST_FUNC void cstr_new(TCCState* S, CString *cstr); |
| 1413 | ST_FUNC void cstr_free(TCCState *S, CString *cstr); | 1413 | ST_FUNC void cstr_free(TCCState* S, CString *cstr); |
| 1414 | ST_FUNC int cstr_printf(TCCState *S, CString *cs, const char *fmt, ...) PRINTF_LIKE(3,4); | 1414 | ST_FUNC int cstr_printf(TCCState* S, CString *cs, const char *fmt, ...) PRINTF_LIKE(3,4); |
| 1415 | ST_FUNC int cstr_vprintf(TCCState *S, CString *cstr, const char *fmt, va_list ap); | 1415 | ST_FUNC int cstr_vprintf(TCCState* S, CString *cstr, const char *fmt, va_list ap); |
| 1416 | ST_FUNC void cstr_reset(CString *cstr); | 1416 | ST_FUNC void cstr_reset(CString *cstr); |
| 1417 | 1417 | ||
| 1418 | ST_FUNC void tcc_open_bf(TCCState *S, const char *filename, int initlen); | 1418 | ST_FUNC void tcc_open_bf(TCCState *S, const char *filename, int initlen); |
| @@ -1499,36 +1499,36 @@ enum line_macro_output_format { · 80 unmodified lines | |||
| 1499 | LINE_MACRO_OUTPUT_FORMAT_P10 = 11 | 1499 | LINE_MACRO_OUTPUT_FORMAT_P10 = 11 |
| 1500 | }; | 1500 | }; |
| 1501 | 1501 | ||
| 1502 | ST_FUNC TokenSym *tok_alloc(TCCState *S, const char *str, int len); | 1502 | ST_FUNC TokenSym *tok_alloc(TCCState* S, const char *str, int len); |
| 1503 | ST_FUNC int tok_alloc_const(TCCState *S, const char *str); | 1503 | ST_FUNC int tok_alloc_const(TCCState* S, const char *str); |
| 1504 | ST_FUNC const char *get_tok_str(TCCState *S, int v, CValue *cv); | 1504 | ST_FUNC const char *get_tok_str(TCCState* S, int v, CValue *cv); |
| 1505 | ST_FUNC void begin_macro(TCCState *S, TokenString *str, int alloc); | 1505 | ST_FUNC void begin_macro(TCCState* S, TokenString *str, int alloc); |
| 1506 | ST_FUNC void end_macro(TCCState *S); | 1506 | ST_FUNC void end_macro(TCCState* S); |
| 1507 | ST_FUNC int set_idnum(TCCState *S, int c, int val); | 1507 | ST_FUNC int set_idnum(TCCState* S, int c, int val); |
| 1508 | ST_INLN void tok_str_new(TokenString *s); | 1508 | ST_INLN void tok_str_new(TokenString *s); |
| 1509 | ST_FUNC TokenString *tok_str_alloc(TCCState *S); | 1509 | ST_FUNC TokenString *tok_str_alloc(TCCState* S); |
| 1510 | ST_FUNC void tok_str_free(TCCState *S, TokenString *s); | 1510 | ST_FUNC void tok_str_free(TCCState* S, TokenString *s); |
| 1511 | ST_FUNC void tok_str_free_str(TCCState *S, int *str); | 1511 | ST_FUNC void tok_str_free_str(TCCState* S, int *str); |
| 1512 | ST_FUNC void tok_str_add(TCCState *S, TokenString *s, int t); | 1512 | ST_FUNC void tok_str_add(TCCState* S, TokenString *s, int t); |
| 1513 | ST_FUNC void tok_str_add_tok(TCCState *S, TokenString *s); | 1513 | ST_FUNC void tok_str_add_tok(TCCState* S, TokenString *s); |
| 1514 | ST_INLN void define_push(TCCState *S, int v, int macro_type, int *str, Sym *first_arg); | 1514 | ST_INLN void define_push(TCCState* S, int v, int macro_type, int *str, Sym *first_arg); |
| 1515 | ST_FUNC void define_undef(TCCState *S, Sym *s); | 1515 | ST_FUNC void define_undef(TCCState* S, Sym *s); |
| 1516 | ST_INLN Sym *define_find(TCCState *S, int v); | 1516 | ST_INLN Sym *define_find(TCCState* S, int v); |
| 1517 | ST_FUNC void free_defines(TCCState *S, Sym *b); | 1517 | ST_FUNC void free_defines(TCCState* S, Sym *b); |
| 1518 | ST_FUNC Sym *label_find(TCCState *S, int v); | 1518 | ST_FUNC Sym *label_find(TCCState* S, int v); |
| 1519 | ST_FUNC Sym *label_push(TCCState *S, Sym **ptop, int v, int flags); | 1519 | ST_FUNC Sym *label_push(TCCState* S, Sym **ptop, int v, int flags); |
| 1520 | ST_FUNC void label_pop(TCCState *S, Sym **ptop, Sym *slast, int keep); | 1520 | ST_FUNC void label_pop(TCCState* S, Sym **ptop, Sym *slast, int keep); |
| 1521 | ST_FUNC void parse_define(TCCState *S); | 1521 | ST_FUNC void parse_define(TCCState* S); |
| 1522 | ST_FUNC void preprocess(TCCState *S, int is_bof); | 1522 | ST_FUNC void preprocess(TCCState* S, int is_bof); |
| 1523 | ST_FUNC void next(TCCState *S); | 1523 | ST_FUNC void next(TCCState* S); |
| 1524 | ST_INLN void unget_tok(TCCState *S, int last_tok); | 1524 | ST_INLN void unget_tok(TCCState* S, int last_tok); |
| 1525 | ST_FUNC void preprocess_start(TCCState *S, int filetype); | 1525 | ST_FUNC void preprocess_start(TCCState *S, int filetype); |
| 1526 | ST_FUNC void preprocess_end(TCCState *S); | 1526 | ST_FUNC void preprocess_end(TCCState *S); |
| 1527 | ST_FUNC void tccpp_new(TCCState *S); | 1527 | ST_FUNC void tccpp_new(TCCState *S); |
| 1528 | ST_FUNC void tccpp_delete(TCCState *S); | 1528 | ST_FUNC void tccpp_delete(TCCState *S); |
| 1529 | ST_FUNC int tcc_preprocess(TCCState *S); | 1529 | ST_FUNC int tcc_preprocess(TCCState *S); |
| 1530 | ST_FUNC void skip(TCCState *S, int c); | 1530 | ST_FUNC void skip(TCCState* S, int c); |
| 1531 | ST_FUNC NORETURN void expect(TCCState *S, const char *msg); | 1531 | ST_FUNC NORETURN void expect(TCCState* S, const char *msg); |
| 1532 | 1532 | ||
| 1533 | /* space excluding newline */ | 1533 | /* space excluding newline */ |
| 1534 | static inline int is_space(int ch) { | 1534 | static inline int is_space(int ch) { |
| @@ -1559,76 +1559,77 @@ ST_FUNC void tcc_debug_putfile(TCCState *S, const char *filename); · 24 unmodified lines | |||
| 1559 | ST_FUNC void tccgen_init(TCCState *S); | 1559 | ST_FUNC void tccgen_init(TCCState *S); |
| 1560 | ST_FUNC int tccgen_compile(TCCState *S); | 1560 | ST_FUNC int tccgen_compile(TCCState *S); |
| 1561 | ST_FUNC void tccgen_finish(TCCState *S); | 1561 | ST_FUNC void tccgen_finish(TCCState *S); |
| 1562 | ST_FUNC void check_vstack(TCCState *S); | 1562 | ST_FUNC void check_vstack(TCCState* S); |
| 1563 | 1563 | ||
| 1564 | ST_INLN int is_float(int t); | 1564 | ST_INLN int is_float(int t); |
| 1565 | ST_FUNC int ieee_finite(double d); | 1565 | ST_FUNC int ieee_finite(double d); |
| 1566 | ST_FUNC int exact_log2p1(int i); | 1566 | ST_FUNC int exact_log2p1(int i); |
| 1567 | ST_FUNC void test_lvalue(TCCState *S); | 1567 | ST_FUNC void test_lvalue(TCCState* S); |
| 1568 | 1568 | ||
| 1569 | ST_FUNC ElfSym *elfsym(TCCState *S, Sym *); | 1569 | ST_FUNC ElfSym *elfsym(TCCState* S, Sym *); |
| 1570 | ST_FUNC void update_storage(TCCState *S, Sym *sym); | 1570 | ST_FUNC void update_storage(TCCState* S, Sym *sym); |
| 1571 | ST_FUNC void put_extern_sym2(TCCState *S, Sym *sym, int sh_num, addr_t value, unsigned long size, int can_add_underscore); | 1571 | ST_FUNC void put_extern_sym2(TCCState* S, Sym *sym, int sh_num, addr_t value, unsigned long size, int can_add_underscore); |
| 1572 | ST_FUNC void put_extern_sym(TCCState *S, Sym *sym, Section *section, addr_t value, unsigned long size); | 1572 | ST_FUNC void put_extern_sym(TCCState* S, Sym *sym, Section *section, addr_t value, unsigned long size); |
| 1573 | #if PTR_SIZE == 4 | 1573 | #if PTR_SIZE == 4 |
| 1574 | ST_FUNC void greloc(TCCState *S, Section *s, Sym *sym, unsigned long offset, int type); | 1574 | ST_FUNC void greloc(TCCState* S, Section *s, Sym *sym, unsigned long offset, int type); |
| 1575 | #endif | 1575 | #endif |
| 1576 | ST_FUNC void greloca(TCCState *S, Section *s, Sym *sym, unsigned long offset, int type, addr_t addend); | 1576 | ST_FUNC void greloca(TCCState* S, Section *s, Sym *sym, unsigned long offset, int type, addr_t addend); |
| 1577 | 1577 | ||
| 1578 | ST_INLN void sym_free(TCCState *S, Sym *sym); | 1578 | ST_INLN void sym_free(TCCState* S, Sym *sym); |
| 1579 | ST_FUNC Sym *sym_push(TCCState *S, int v, CType *type, int r, int c); | 1579 | ST_FUNC Sym *sym_push(TCCState* S, int v, CType *type, int r, int c); |
| 1580 | ST_FUNC void sym_pop(TCCState *S, Sym **ptop, Sym *b, int keep); | 1580 | ST_FUNC void sym_pop(TCCState* S, Sym **ptop, Sym *b, int keep); |
| 1581 | ST_FUNC Sym *sym_push2(TCCState *S, Sym **ps, int v, int t, int c); | 1581 | ST_FUNC Sym *sym_push2(TCCState* S, Sym **ps, int v, int t, int c); |
| 1582 | ST_FUNC Sym *sym_find2(Sym *s, int v); | 1582 | ST_FUNC Sym *sym_find2(Sym *s, int v); |
| 1583 | ST_INLN Sym *sym_find(TCCState *S, int v); | 1583 | ST_INLN Sym *sym_find(TCCState* S, int v); |
| 1584 | ST_INLN Sym *struct_find(TCCState *S, int v); | 1584 | ST_INLN Sym *struct_find(TCCState* S, int v); |
| 1585 | 1585 | ||
| 1586 | ST_FUNC Sym *global_identifier_push(TCCState *S, int v, int t, int c); | 1586 | ST_FUNC Sym *global_identifier_push(TCCState* S, int v, int t, int c); |
| 1587 | ST_FUNC Sym *external_global_sym(TCCState *S, int v, CType *type); | 1587 | ST_FUNC Sym *external_global_sym(TCCState* S, int v, CType *type); |
| 1588 | ST_FUNC Sym *external_helper_sym(TCCState *S, int v); | 1588 | ST_FUNC Sym *external_helper_sym(TCCState* S, int v); |
| 1589 | ST_FUNC void vpush_helper_func(TCCState *S, int v); | 1589 | ST_FUNC void vpush_helper_func(TCCState* S, int v); |
| 1590 | ST_FUNC void vset(TCCState *S, CType *type, int r, int v); | 1590 | ST_FUNC void vset(TCCState* S, CType *type, int r, int v); |
| 1591 | ST_FUNC void vset_VT_CMP(TCCState *S, int op); | 1591 | ST_FUNC void vset_VT_CMP(TCCState* S, int op); |
| 1592 | ST_FUNC void vpushi(TCCState *S, int v); | 1592 | ST_FUNC void vpushi(TCCState* S, int v); |
| 1593 | ST_FUNC void vpushv(TCCState *S, SValue *v); | 1593 | ST_FUNC void vpushv(TCCState* S, SValue *v); |
| 1594 | ST_FUNC void vpushsym(TCCState *S, CType *type, Sym *sym); | 1594 | ST_FUNC void vpushsym(TCCState* S, CType *type, Sym *sym); |
| 1595 | ST_FUNC void vswap(TCCState *S); | 1595 | ST_FUNC void vswap(TCCState* S); |
| 1596 | ST_FUNC void vrote(TCCState *S, SValue *e, int n); | 1596 | ST_FUNC void vrote(TCCState* S, SValue *e, int n); |
| 1597 | ST_FUNC void vrott(TCCState *S, int n); | 1597 | ST_FUNC void vrott(TCCState* S, int n); |
| 1598 | ST_FUNC void vrotb(TCCState *S, int n); | 1598 | ST_FUNC void vrotb(TCCState* S, int n); |
| 1599 | ST_FUNC void vpop(TCCState *S); | 1599 | ST_FUNC void vpop(TCCState* S); |
| 1600 | #if PTR_SIZE == 4 | 1600 | #if PTR_SIZE == 4 |
| 1601 | ST_FUNC void lexpand(TCCState *S); | 1601 | ST_FUNC void lexpand(TCCState* S); |
| 1602 | #endif | 1602 | #endif |
| 1603 | #ifdef TCC_TARGET_ARM | 1603 | #ifdef TCC_TARGET_ARM |
| 1604 | ST_FUNC int get_reg_ex(TCCState *S, int rc, int rc2); | 1604 | ST_FUNC int get_reg_ex(TCCState* S, int rc, int rc2); |
| 1605 | #endif | 1605 | #endif |
| 1606 | ST_FUNC void save_reg(TCCState *S, int r); | 1606 | ST_FUNC void save_reg(TCCState* S, int r); |
| 1607 | ST_FUNC void save_reg_upstack(TCCState *S, int r, int n); | 1607 | ST_FUNC void save_reg_upstack(TCCState* S, int r, int n); |
| 1608 | ST_FUNC int get_reg(TCCState *S, int rc); | 1608 | ST_FUNC int get_reg(TCCState* S, int rc); |
| 1609 | ST_FUNC void save_regs(TCCState *S, int n); | 1609 | ST_FUNC void save_regs(TCCState* S, int n); |
| 1610 | ST_FUNC void gaddrof(TCCState *S); | 1610 | ST_FUNC void gaddrof(TCCState* S); |
| 1611 | ST_FUNC int gv(TCCState *S, int rc); | 1611 | ST_FUNC int gv(TCCState* S, int rc); |
| 1612 | ST_FUNC void gv2(TCCState *S, int rc1, int rc2); | 1612 | ST_FUNC void gv2(TCCState* S, int rc1, int rc2); |
| 1613 | ST_FUNC void gen_op(TCCState *S, int op); | 1613 | ST_FUNC void gen_op(TCCState* S, int op); |
| 1614 | ST_FUNC int type_size(CType *type, int *a); | 1614 | ST_FUNC int type_size(CType *type, int *a); |
| 1615 | ST_FUNC void mk_pointer(TCCState *S, CType *type); | 1615 | ST_FUNC void mk_pointer(TCCState* S, CType *type); |
| 1616 | ST_FUNC void vstore(TCCState *S); | 1616 | ST_FUNC void vstore(TCCState* S); |
| 1617 | ST_FUNC void inc(TCCState *S, int post, int c); | 1617 | ST_FUNC void inc(TCCState* S, int post, int c); |
| 1618 | ST_FUNC void parse_mult_str (TCCState *S, CString *astr, const char *msg); | 1618 | ST_FUNC void parse_mult_str (TCCState* S, CString *astr, const char *msg); |
| 1619 | ST_FUNC void parse_asm_str(TCCState *S, CString *astr); | 1619 | ST_FUNC void parse_asm_str(TCCState* S, CString *astr); |
| 1620 | ST_FUNC void indir(TCCState *S); | 1620 | ST_FUNC void indir(TCCState* S); |
| 1621 | ST_FUNC void unary(TCCState *S); | 1621 | ST_FUNC void unary(TCCState* S); |
| 1622 | ST_FUNC void gexpr(TCCState *S); | 1622 | ST_FUNC void gexpr(TCCState* S); |
| 1623 | ST_FUNC int expr_const(TCCState *S); | 1623 | ST_FUNC int expr_const(TCCState* S); |
| 1624 | #if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_C67 | 1624 | #if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_C67 |
| 1625 | ST_FUNC Sym *get_sym_ref(TCCState *S, CType *type, Section *sec, unsigned long offset, unsigned long size); | 1625 | ST_FUNC Sym *get_sym_ref(TCCState* S, CType *type, Section *sec, unsigned long offset, unsigned long size); |
| 1626 | #endif | 1626 | #endif |
| 1627 | #if defined TCC_TARGET_X86_64 && !defined TCC_TARGET_PE | 1627 | #if defined TCC_TARGET_X86_64 && !defined TCC_TARGET_PE |
| 1628 | ST_FUNC int classify_x86_64_va_arg(CType *ty); | 1628 | ST_FUNC int classify_x86_64_va_arg(CType *ty); |
| 1629 | #endif | 1629 | #endif |
| 1630 | #ifdef CONFIG_TCC_BCHECK | 1630 | #ifdef CONFIG_TCC_BCHECK |
| 1631 | ST_FUNC void gbound_args(TCCState *S, int nb_args); | 1631 | ST_FUNC void gbound_args(TCCState* S, int nb_args); |
| 1632 | ST_DATA int func_bound_add_epilog; | ||
| 1632 | #endif | 1633 | #endif |
| 1633 | 1634 | ||
| 1634 | /* ------------ tccelf.c ------------ */ | 1635 | /* ------------ tccelf.c ------------ */ |
| @@ -1656,14 +1657,14 @@ ST_FUNC void tccelf_end_file(TCCState *S); · 21 unmodified lines | |||
| 1656 | ST_FUNC void tccelf_bounds_new(TCCState *S); | 1657 | ST_FUNC void tccelf_bounds_new(TCCState *S); |
| 1657 | #endif | 1658 | #endif |
| 1658 | ST_FUNC Section *new_section(TCCState *S, const char *name, int sh_type, int sh_flags); | 1659 | ST_FUNC Section *new_section(TCCState *S, const char *name, int sh_type, int sh_flags); |
| 1659 | ST_FUNC void section_realloc(TCCState *S, Section *sec, unsigned long new_size); | 1660 | ST_FUNC void section_realloc(TCCState* S, Section *sec, unsigned long new_size); |
| 1660 | ST_FUNC size_t section_add(TCCState *S, Section *sec, addr_t size, int align); | 1661 | ST_FUNC size_t section_add(TCCState* S, Section *sec, addr_t size, int align); |
| 1661 | ST_FUNC void *section_ptr_add(TCCState *S, Section *sec, addr_t size); | 1662 | ST_FUNC void *section_ptr_add(TCCState* S, Section *sec, addr_t size); |
| 1662 | ST_FUNC Section *find_section(TCCState *S, const char *name); | 1663 | ST_FUNC Section *find_section(TCCState *S, const char *name); |
| 1663 | ST_FUNC Section *new_symtab(TCCState *S, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags); | 1664 | ST_FUNC Section *new_symtab(TCCState *S, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags); |
| 1664 | 1665 | ||
| 1665 | ST_FUNC int put_elf_str(TCCState *S, Section *s, const char *sym); | 1666 | ST_FUNC int put_elf_str(TCCState* S, Section *s, const char *sym); |
| 1666 | ST_FUNC int put_elf_sym(TCCState *S, Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name); | 1667 | ST_FUNC int put_elf_sym(TCCState* S, Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name); |
| 1667 | ST_FUNC int set_elf_sym(Section *S, addr_t value, unsigned long size, int info, int other, int shndx, const char *name); | 1668 | ST_FUNC int set_elf_sym(Section *S, addr_t value, unsigned long size, int info, int other, int shndx, const char *name); |
| 1668 | ST_FUNC int find_elf_sym(Section *S, const char *name); | 1669 | ST_FUNC int find_elf_sym(Section *S, const char *name); |
| 1669 | ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol); | 1670 | ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol); |
| @@ -1678,7 +1679,7 @@ ST_FUNC void relocate_syms(TCCState *S, Section *symtab, int do_resolve); · 8 unmodified lines | |||
| 1678 | ST_FUNC void relocate_sections(TCCState *S); | 1679 | ST_FUNC void relocate_sections(TCCState *S); |
| 1679 | 1680 | ||
| 1680 | ST_FUNC ssize_t full_read(int fd, void *buf, size_t count); | 1681 | ST_FUNC ssize_t full_read(int fd, void *buf, size_t count); |
| 1681 | ST_FUNC void *load_data(TCCState *S, int fd, unsigned long file_offset, unsigned long size); | 1682 | ST_FUNC void *load_data(TCCState* S, int fd, unsigned long file_offset, unsigned long size); |
| 1682 | ST_FUNC int tcc_object_type(int fd, ElfW(Ehdr) *h); | 1683 | ST_FUNC int tcc_object_type(int fd, ElfW(Ehdr) *h); |
| 1683 | ST_FUNC int tcc_load_object_file(TCCState *S, int fd, unsigned long file_offset); | 1684 | ST_FUNC int tcc_load_object_file(TCCState *S, int fd, unsigned long file_offset); |
| 1684 | ST_FUNC int tcc_load_archive(TCCState *S, int fd, int alacarte); | 1685 | ST_FUNC int tcc_load_archive(TCCState *S, int fd, int alacarte); |
| @@ -1732,31 +1733,31 @@ ST_FUNC void relocate(TCCState *S, ElfW_Rel *rel, int type, unsigned char *ptr, · 47 unmodified lines | |||
| 1732 | ST_DATA const char * const target_machine_defs; | 1733 | ST_DATA const char * const target_machine_defs; |
| 1733 | ST_DATA const int reg_classes[NB_REGS]; | 1734 | ST_DATA const int reg_classes[NB_REGS]; |
| 1734 | 1735 | ||
| 1735 | ST_FUNC void gsym_addr(TCCState *S, int t, int a); | 1736 | ST_FUNC void gsym_addr(TCCState* S, int t, int a); |
| 1736 | ST_FUNC void gsym(TCCState *S, int t); | 1737 | ST_FUNC void gsym(TCCState* S, int t); |
| 1737 | ST_FUNC void load(TCCState *S, int r, SValue *sv); | 1738 | ST_FUNC void load(TCCState *S, int r, SValue *sv); |
| 1738 | ST_FUNC void store(TCCState *S, int r, SValue *v); | 1739 | ST_FUNC void store(TCCState *S, int r, SValue *v); |
| 1739 | ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *align, int *regsize); | 1740 | ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *align, int *regsize); |
| 1740 | ST_FUNC void gfunc_call(TCCState *S, int nb_args); | 1741 | ST_FUNC void gfunc_call(TCCState *S, int nb_args); |
| 1741 | ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym); | 1742 | ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym); |
| 1742 | ST_FUNC void gfunc_epilog(TCCState *S); | 1743 | ST_FUNC void gfunc_epilog(TCCState *S); |
| 1743 | ST_FUNC void gen_fill_nops(TCCState *S, int); | 1744 | ST_FUNC void gen_fill_nops(TCCState* S, int); |
| 1744 | ST_FUNC int gjmp(TCCState *S, int t); | 1745 | ST_FUNC int gjmp(TCCState* S, int t); |
| 1745 | ST_FUNC void gjmp_addr(TCCState *S, int a); | 1746 | ST_FUNC void gjmp_addr(TCCState* S, int a); |
| 1746 | ST_FUNC int gjmp_cond(TCCState *S, int op, int t); | 1747 | ST_FUNC int gjmp_cond(TCCState* S, int op, int t); |
| 1747 | ST_FUNC int gjmp_append(TCCState *S, int n, int t); | 1748 | ST_FUNC int gjmp_append(TCCState *S, int n, int t); |
| 1748 | ST_FUNC void gen_opi(TCCState *S, int op); | 1749 | ST_FUNC void gen_opi(TCCState* S, int op); |
| 1749 | ST_FUNC void gen_opf(TCCState *S, int op); | 1750 | ST_FUNC void gen_opf(TCCState* S, int op); |
| 1750 | ST_FUNC void gen_cvt_ftoi(TCCState *S, int t); | 1751 | ST_FUNC void gen_cvt_ftoi(TCCState *S, int t); |
| 1751 | ST_FUNC void gen_cvt_itof(TCCState *S, int t); | 1752 | ST_FUNC void gen_cvt_itof(TCCState *S, int t); |
| 1752 | ST_FUNC void gen_cvt_ftof(TCCState *S, int t); | 1753 | ST_FUNC void gen_cvt_ftof(TCCState *S, int t); |
| 1753 | ST_FUNC void ggoto(TCCState *S); | 1754 | ST_FUNC void ggoto(TCCState *S); |
| 1754 | #ifndef TCC_TARGET_C67 | 1755 | #ifndef TCC_TARGET_C67 |
| 1755 | ST_FUNC void o(TCCState *S, unsigned int c); | 1756 | ST_FUNC void o(TCCState* S, unsigned int c); |
| 1756 | #endif | 1757 | #endif |
| 1757 | ST_FUNC void gen_vla_sp_save(TCCState *S, int addr); | 1758 | ST_FUNC void gen_vla_sp_save(TCCState* S, int addr); |
| 1758 | ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr); | 1759 | ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr); |
| 1759 | ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align); | 1760 | ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align); |
| 1760 | 1761 | ||
| 1761 | static inline uint16_t read16le(unsigned char *p) { | 1762 | static inline uint16_t read16le(unsigned char *p) { |
| 1762 | return p[0] | (uint16_t)p[1] << 8; | 1763 | return p[0] | (uint16_t)p[1] << 8; |
| @@ -1785,26 +1786,26 @@ static inline void add64le(unsigned char *p, int64_t x) { · 22 unmodified lines | |||
| 1785 | 1786 | ||
| 1786 | /* ------------ i386-gen.c ------------ */ | 1787 | /* ------------ i386-gen.c ------------ */ |
| 1787 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 || defined TCC_TARGET_ARM | 1788 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 || defined TCC_TARGET_ARM |
| 1788 | ST_FUNC void g(TCCState *S, int c); | 1789 | ST_FUNC void g(TCCState* S, int c); |
| 1789 | ST_FUNC void gen_le16(TCCState *S, int c); | 1790 | ST_FUNC void gen_le16(TCCState* S, int c); |
| 1790 | ST_FUNC void gen_le32(TCCState *S, int c); | 1791 | ST_FUNC void gen_le32(TCCState* S, int c); |
| 1791 | #endif | 1792 | #endif |
| 1792 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 | 1793 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 |
| 1793 | ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c); | 1794 | ST_FUNC void gen_addr32(TCCState* S, int r, Sym *sym, int c); |
| 1794 | ST_FUNC void gen_addrpc32(TCCState *S, int r, Sym *sym, int c); | 1795 | ST_FUNC void gen_addrpc32(TCCState* S, int r, Sym *sym, int c); |
| 1795 | ST_FUNC void gen_cvt_csti(TCCState *S, int t); | 1796 | ST_FUNC void gen_cvt_csti(TCCState* S, int t); |
| 1796 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv); | 1797 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv); |
| 1797 | #endif | 1798 | #endif |
| 1798 | 1799 | ||
| 1799 | /* ------------ x86_64-gen.c ------------ */ | 1800 | /* ------------ x86_64-gen.c ------------ */ |
| 1800 | #ifdef TCC_TARGET_X86_64 | 1801 | #ifdef TCC_TARGET_X86_64 |
| 1801 | ST_FUNC void gen_addr64(TCCState *S, int r, Sym *sym, int64_t c); | 1802 | ST_FUNC void gen_addr64(TCCState* S, int r, Sym *sym, int64_t c); |
| 1802 | ST_FUNC void gen_opl(TCCState *S, int op); | 1803 | ST_FUNC void gen_opl(TCCState* S, int op); |
| 1803 | #ifdef TCC_TARGET_PE | 1804 | #ifdef TCC_TARGET_PE |
| 1804 | ST_FUNC void gen_vla_result(TCCState *S, int addr); | 1805 | ST_FUNC void gen_vla_result(TCCState* S, int addr); |
| 1805 | #endif | 1806 | #endif |
| 1806 | ST_FUNC void gen_cvt_sxtw(TCCState *S); | 1807 | ST_FUNC void gen_cvt_sxtw(TCCState *S); |
| 1807 | ST_FUNC void gen_cvt_csti(TCCState *S, int t); | 1808 | ST_FUNC void gen_cvt_csti(TCCState* S, int t); |
| 1808 | #endif | 1809 | #endif |
| 1809 | 1810 | ||
| 1810 | /* ------------ arm-gen.c ------------ */ | 1811 | /* ------------ arm-gen.c ------------ */ |
| @@ -1813,29 +1814,29 @@ ST_FUNC void gen_cvt_csti(TCCState *S, int t); · 2 unmodified lines | |||
| 1813 | PUB_FUNC const char *default_elfinterp(TCCState *S); | 1814 | PUB_FUNC const char *default_elfinterp(TCCState *S); |
| 1814 | #endif | 1815 | #endif |
| 1815 | ST_FUNC void arm_init(TCCState *S); | 1816 | ST_FUNC void arm_init(TCCState *S); |
| 1816 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv); | 1817 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv); |
| 1817 | #endif | 1818 | #endif |
| 1818 | 1819 | ||
| 1819 | /* ------------ arm64-gen.c ------------ */ | 1820 | /* ------------ arm64-gen.c ------------ */ |
| 1820 | #ifdef TCC_TARGET_ARM64 | 1821 | #ifdef TCC_TARGET_ARM64 |
| 1821 | ST_FUNC void gen_opl(TCCState *S, int op); | 1822 | ST_FUNC void gen_opl(TCCState* S, int op); |
| 1822 | ST_FUNC void gfunc_return(TCCState *S, CType *func_type); | 1823 | ST_FUNC void gfunc_return(TCCState *S, CType *func_type); |
| 1823 | ST_FUNC void gen_va_start(TCCState *S); | 1824 | ST_FUNC void gen_va_start(TCCState *S); |
| 1824 | ST_FUNC void gen_va_arg(TCCState *S, CType *t); | 1825 | ST_FUNC void gen_va_arg(TCCState *S, CType *t); |
| 1825 | ST_FUNC void gen_clear_cache(TCCState *S); | 1826 | ST_FUNC void gen_clear_cache(TCCState *S); |
| 1826 | ST_FUNC void gen_cvt_sxtw(TCCState *S); | 1827 | ST_FUNC void gen_cvt_sxtw(TCCState *S); |
| 1827 | ST_FUNC void gen_cvt_csti(TCCState *S, int t); | 1828 | ST_FUNC void gen_cvt_csti(TCCState *S, int t); |
| 1828 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv); | 1829 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv); |
| 1829 | #endif | 1830 | #endif |
| 1830 | 1831 | ||
| 1831 | /* ------------ riscv64-gen.c ------------ */ | 1832 | /* ------------ riscv64-gen.c ------------ */ |
| 1832 | #ifdef TCC_TARGET_RISCV64 | 1833 | #ifdef TCC_TARGET_RISCV64 |
| 1833 | ST_FUNC void gen_opl(TCCState *S, int op); | 1834 | ST_FUNC void gen_opl(TCCState* S, int op); |
| 1834 | //ST_FUNC void gfunc_return(TCCState *S, CType *func_type); | 1835 | //ST_FUNC void gfunc_return(TCCState *S, CType *func_type); |
| 1835 | ST_FUNC void gen_va_start(TCCState *S); | 1836 | ST_FUNC void gen_va_start(TCCState *S); |
| 1836 | ST_FUNC void arch_transfer_ret_regs(TCCState *S, int); | 1837 | ST_FUNC void arch_transfer_ret_regs(TCCState* S, int); |
| 1837 | ST_FUNC void gen_cvt_sxtw(TCCState *S); | 1838 | ST_FUNC void gen_cvt_sxtw(TCCState *S); |
| 1838 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv); | 1839 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv); |
| 1839 | #endif | 1840 | #endif |
| 1840 | 1841 | ||
| 1841 | /* ------------ c67-gen.c ------------ */ | 1842 | /* ------------ c67-gen.c ------------ */ |
| @@ -1850,25 +1851,25 @@ ST_FUNC int tcc_load_coff(TCCState *S, int fd); · 8 unmodified lines | |||
| 1850 | #endif | 1851 | #endif |
| 1851 | 1852 | ||
| 1852 | /* ------------ tccasm.c ------------ */ | 1853 | /* ------------ tccasm.c ------------ */ |
| 1853 | ST_FUNC void asm_instr(TCCState *S); | 1854 | ST_FUNC void asm_instr(TCCState* S); |
| 1854 | ST_FUNC void asm_global_instr(TCCState *S); | 1855 | ST_FUNC void asm_global_instr(TCCState* S); |
| 1855 | ST_FUNC int tcc_assemble(TCCState *S, int do_preprocess); | 1856 | ST_FUNC int tcc_assemble(TCCState *S, int do_preprocess); |
| 1856 | #ifdef CONFIG_TCC_ASM | 1857 | #ifdef CONFIG_TCC_ASM |
| 1857 | ST_FUNC int find_constraint(TCCState *S, ASMOperand *operands, int nb_operands, const char *name, const char **pp); | 1858 | ST_FUNC int find_constraint(TCCState* S, ASMOperand *operands, int nb_operands, const char *name, const char **pp); |
| 1858 | ST_FUNC Sym* get_asm_sym(TCCState *S, int name, Sym *csym); | 1859 | ST_FUNC Sym* get_asm_sym(TCCState* S, int name, Sym *csym); |
| 1859 | ST_FUNC void asm_expr(TCCState *S, ExprValue *pe); | 1860 | ST_FUNC void asm_expr(TCCState *S, ExprValue *pe); |
| 1860 | ST_FUNC int asm_int_expr(TCCState *S); | 1861 | ST_FUNC int asm_int_expr(TCCState *S); |
| 1861 | /* ------------ i386-asm.c ------------ */ | 1862 | /* ------------ i386-asm.c ------------ */ |
| 1862 | ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe); | 1863 | ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe); |
| 1863 | #ifdef TCC_TARGET_X86_64 | 1864 | #ifdef TCC_TARGET_X86_64 |
| 1864 | ST_FUNC void gen_expr64(TCCState *S, ExprValue *pe); | 1865 | ST_FUNC void gen_expr64(TCCState* S, ExprValue *pe); |
| 1865 | #endif | 1866 | #endif |
| 1866 | ST_FUNC void asm_opcode(TCCState *S, int opcode); | 1867 | ST_FUNC void asm_opcode(TCCState *S, int opcode); |
| 1867 | ST_FUNC int asm_parse_regvar(TCCState *S, int t); | 1868 | ST_FUNC int asm_parse_regvar(TCCState* S, int t); |
| 1868 | ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands, int nb_operands, int nb_outputs, const uint8_t *clobber_regs, int *pout_reg); | 1869 | ST_FUNC void asm_compute_constraints(TCCState* S, ASMOperand *operands, int nb_operands, int nb_outputs, const uint8_t *clobber_regs, int *pout_reg); |
| 1869 | ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, SValue *sv, int modifier); | 1870 | ST_FUNC void subst_asm_operand(TCCState* S, CString *add_str, SValue *sv, int modifier); |
| 1870 | ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands, int nb_outputs, int is_output, uint8_t *clobber_regs, int out_reg); | 1871 | ST_FUNC void asm_gen_code(TCCState* S, ASMOperand *operands, int nb_operands, int nb_outputs, int is_output, uint8_t *clobber_regs, int out_reg); |
| 1871 | ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str); | 1872 | ST_FUNC void asm_clobber(TCCState* S, uint8_t *clobber_regs, const char *str); |
| 1872 | #endif | 1873 | #endif |
| 1873 | 1874 | ||
| 1874 | /* ------------ tccpe.c -------------- */ | 1875 | /* ------------ tccpe.c -------------- */ |
| @@ -1880,9 +1881,9 @@ ST_FUNC int pe_putimport(TCCState *S, int dllindex, const char *name, addr_t val · 5 unmodified lines | |||
| 1880 | ST_FUNC SValue *pe_getimport(TCCState * S, SValue *sv, SValue *v2); | 1881 | ST_FUNC SValue *pe_getimport(TCCState * S, SValue *sv, SValue *v2); |
| 1881 | #endif | 1882 | #endif |
| 1882 | #ifdef TCC_TARGET_X86_64 | 1883 | #ifdef TCC_TARGET_X86_64 |
| 1883 | ST_FUNC void pe_add_unwind_data(TCCState *S, unsigned start, unsigned end, unsigned stack); | 1884 | ST_FUNC void pe_add_unwind_data(TCCState* S, unsigned start, unsigned end, unsigned stack); |
| 1884 | #endif | 1885 | #endif |
| 1885 | PUB_FUNC int tcc_get_dllexports(TCCState *S, const char *filename, char **pp); | 1886 | PUB_FUNC int tcc_get_dllexports(TCCState* S, const char *filename, char **pp); |
| 1886 | /* symbol properties stored in Elf32_Sym->st_other */ | 1887 | /* symbol properties stored in Elf32_Sym->st_other */ |
| 1887 | # define ST_PE_EXPORT 0x10 | 1888 | # define ST_PE_EXPORT 0x10 |
| 1888 | # define ST_PE_IMPORT 0x20 | 1889 | # define ST_PE_IMPORT 0x20 |
| @@ -1896,7 +1897,7 @@ ST_FUNC int macho_output_file(TCCState * S, const char *filename); · 7 unmodified lines | |||
| 1896 | ST_FUNC int macho_load_dll(TCCState *S, int fd, const char *filename, int lev); | 1897 | ST_FUNC int macho_load_dll(TCCState *S, int fd, const char *filename, int lev); |
| 1897 | ST_FUNC int macho_load_tbd(TCCState *S, int fd, const char *filename, int lev); | 1898 | ST_FUNC int macho_load_tbd(TCCState *S, int fd, const char *filename, int lev); |
| 1898 | #ifdef TCC_IS_NATIVE | 1899 | #ifdef TCC_IS_NATIVE |
| 1899 | ST_FUNC void tcc_add_macos_sdkpath(TCCState *S); | 1900 | ST_FUNC void tcc_add_macos_sdkpath(TCCState* S); |
| 1900 | ST_FUNC const char* macho_tbd_soname(const char* filename); | 1901 | ST_FUNC const char* macho_tbd_soname(const char* filename); |
| 1901 | #endif | 1902 | #endif |
| 1902 | #endif | 1903 | #endif |
| @@ -39,7 +39,7 @@ static Sym* asm_new_label1(TCCState *S, int label, int is_local, int sh_num, int · 38 unmodified lines | |||
| 39 | the global C symbol table to track ASM names as well, so we need to | 39 | the global C symbol table to track ASM names as well, so we need to |
| 40 | transform those into ones that don't conflict with a C name, | 40 | transform those into ones that don't conflict with a C name, |
| 41 | so prepend a '.' for them, but force the ELF asm name to be set. */ | 41 | so prepend a '.' for them, but force the ELF asm name to be set. */ |
| 42 | static int asm2cname(TCCState *S, int v, int *addeddot) | 42 | static int asm2cname(TCCState* S, int v, int *addeddot) |
| 43 | { | 43 | { |
| 44 | const char *name; | 44 | const char *name; |
| 45 | *addeddot = 0; | 45 | *addeddot = 0; |
| @@ -59,7 +59,7 @@ static int asm2cname(TCCState *S, int v, int *addeddot) · 13 unmodified lines | |||
| 59 | return v; | 59 | return v; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static Sym *asm_label_find(TCCState *S, int v) | 62 | static Sym *asm_label_find(TCCState* S, int v) |
| 63 | { | 63 | { |
| 64 | Sym *sym; | 64 | Sym *sym; |
| 65 | int addeddot; | 65 | int addeddot; |
| @@ -70,7 +70,7 @@ static Sym *asm_label_find(TCCState *S, int v) · 4 unmodified lines | |||
| 70 | return sym; | 70 | return sym; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static Sym *asm_label_push(TCCState *S, int v) | 73 | static Sym *asm_label_push(TCCState* S, int v) |
| 74 | { | 74 | { |
| 75 | int addeddot, v2 = asm2cname(S, v, &addeddot); | 75 | int addeddot, v2 = asm2cname(S, v, &addeddot); |
| 76 | /* We always add VT_EXTERN, for sym definition that's tentative | 76 | /* We always add VT_EXTERN, for sym definition that's tentative |
| @@ -92,7 +92,7 @@ static Sym *asm_label_push(TCCState *S, int v) · 15 unmodified lines | |||
| 92 | are anonymous in C, in this case CSYM can be used to transfer | 92 | are anonymous in C, in this case CSYM can be used to transfer |
| 93 | all information from that symbol to the (possibly newly created) | 93 | all information from that symbol to the (possibly newly created) |
| 94 | asm symbol. */ | 94 | asm symbol. */ |
| 95 | ST_FUNC Sym* get_asm_sym(TCCState *S, int name, Sym *csym) | 95 | ST_FUNC Sym* get_asm_sym(TCCState* S, int name, Sym *csym) |
| 96 | { | 96 | { |
| 97 | Sym *sym = asm_label_find(S, name); | 97 | Sym *sym = asm_label_find(S, name); |
| 98 | if (!sym) { | 98 | if (!sym) { |
| @@ -122,9 +122,9 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe) · 23 unmodified lines | |||
| 122 | uint64_t n; | 122 | uint64_t n; |
| 123 | const char *p; | 123 | const char *p; |
| 124 | 124 | ||
| 125 | switch(S->tok) { | 125 | switch(S->tccpp_tok) { |
| 126 | case TOK_PPNUM: | 126 | case TOK_PPNUM: |
| 127 | p = S->tokc.str.data; | 127 | p = S->tccpp_tokc.str.data; |
| 128 | n = strtoull(p, (char **)&p, 0); | 128 | n = strtoull(p, (char **)&p, 0); |
| 129 | if (*p == 'b' || *p == 'f') { | 129 | if (*p == 'b' || *p == 'f') { |
| 130 | /* backward or forward label */ | 130 | /* backward or forward label */ |
| @@ -161,7 +161,7 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe) · 30 unmodified lines | |||
| 161 | break; | 161 | break; |
| 162 | case '-': | 162 | case '-': |
| 163 | case '~': | 163 | case '~': |
| 164 | op = S->tok; | 164 | op = S->tccpp_tok; |
| 165 | next(S); | 165 | next(S); |
| 166 | asm_expr_unary(S, pe); | 166 | asm_expr_unary(S, pe); |
| 167 | if (pe->sym) | 167 | if (pe->sym) |
| @@ -173,7 +173,7 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe) · 5 unmodified lines | |||
| 173 | break; | 173 | break; |
| 174 | case TOK_CCHAR: | 174 | case TOK_CCHAR: |
| 175 | case TOK_LCHAR: | 175 | case TOK_LCHAR: |
| 176 | pe->v = S->tokc.i; | 176 | pe->v = S->tccpp_tokc.i; |
| 177 | pe->sym = NULL; | 177 | pe->sym = NULL; |
| 178 | pe->pcrel = 0; | 178 | pe->pcrel = 0; |
| 179 | next(S); | 179 | next(S); |
| @@ -184,16 +184,16 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe) · 4 unmodified lines | |||
| 184 | skip(S, ')'); | 184 | skip(S, ')'); |
| 185 | break; | 185 | break; |
| 186 | case '.': | 186 | case '.': |
| 187 | pe->v = S->ind; | 187 | pe->v = S->tccgen_ind; |
| 188 | pe->sym = asm_section_sym(S, cur_text_section); | 188 | pe->sym = asm_section_sym(S, cur_text_section); |
| 189 | pe->pcrel = 0; | 189 | pe->pcrel = 0; |
| 190 | next(S); | 190 | next(S); |
| 191 | break; | 191 | break; |
| 192 | default: | 192 | default: |
| 193 | if (S->tok >= TOK_IDENT) { | 193 | if (S->tccpp_tok >= TOK_IDENT) { |
| 194 | ElfSym *esym; | 194 | ElfSym *esym; |
| 195 | /* label case : if the label was not found, add one */ | 195 | /* label case : if the label was not found, add one */ |
| 196 | sym = get_asm_sym(S, S->tok, NULL); | 196 | sym = get_asm_sym(S, S->tccpp_tok, NULL); |
| 197 | esym = elfsym(S, sym); | 197 | esym = elfsym(S, sym); |
| 198 | if (esym && esym->st_shndx == SHN_ABS) { | 198 | if (esym && esym->st_shndx == SHN_ABS) { |
| 199 | /* if absolute symbol, no need to put a symbol value */ | 199 | /* if absolute symbol, no need to put a symbol value */ |
| @@ -207,7 +207,7 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe) · 7 unmodified lines | |||
| 207 | } | 207 | } |
| 208 | next(S); | 208 | next(S); |
| 209 | } else { | 209 | } else { |
| 210 | tcc_error(S, "bad expression syntax [%s]", get_tok_str(S, S->tok, &S->tokc)); | 210 | tcc_error(S, "bad expression syntax [%s]", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 211 | } | 211 | } |
| 212 | break; | 212 | break; |
| 213 | } | 213 | } |
| @@ -220,7 +220,7 @@ static void asm_expr_prod(TCCState *S, ExprValue *pe) · 6 unmodified lines | |||
| 220 | 220 | ||
| 221 | asm_expr_unary(S, pe); | 221 | asm_expr_unary(S, pe); |
| 222 | for(;;) { | 222 | for(;;) { |
| 223 | op = S->tok; | 223 | op = S->tccpp_tok; |
| 224 | if (op != '*' && op != '/' && op != '%' && | 224 | if (op != '*' && op != '/' && op != '%' && |
| 225 | op != TOK_SHL && op != TOK_SAR) | 225 | op != TOK_SHL && op != TOK_SAR) |
| 226 | break; | 226 | break; |
| @@ -262,7 +262,7 @@ static void asm_expr_logic(TCCState *S, ExprValue *pe) · 35 unmodified lines | |||
| 262 | 262 | ||
| 263 | asm_expr_prod(S, pe); | 263 | asm_expr_prod(S, pe); |
| 264 | for(;;) { | 264 | for(;;) { |
| 265 | op = S->tok; | 265 | op = S->tccpp_tok; |
| 266 | if (op != '&' && op != '|' && op != '^') | 266 | if (op != '&' && op != '|' && op != '^') |
| 267 | break; | 267 | break; |
| 268 | next(S); | 268 | next(S); |
| @@ -291,7 +291,7 @@ static inline void asm_expr_sum(TCCState *S, ExprValue *pe) · 22 unmodified lines | |||
| 291 | 291 | ||
| 292 | asm_expr_logic(S, pe); | 292 | asm_expr_logic(S, pe); |
| 293 | for(;;) { | 293 | for(;;) { |
| 294 | op = S->tok; | 294 | op = S->tccpp_tok; |
| 295 | if (op != '+' && op != '-') | 295 | if (op != '+' && op != '-') |
| 296 | break; | 296 | break; |
| 297 | next(S); | 297 | next(S); |
| @@ -323,7 +323,7 @@ static inline void asm_expr_sum(TCCState *S, ExprValue *pe) · 25 unmodified lines | |||
| 323 | } else if (esym2->st_shndx == cur_text_section->sh_num) { | 323 | } else if (esym2->st_shndx == cur_text_section->sh_num) { |
| 324 | /* When subtracting a defined symbol in current section | 324 | /* When subtracting a defined symbol in current section |
| 325 | this actually makes the value PC-relative. */ | 325 | this actually makes the value PC-relative. */ |
| 326 | pe->v -= esym2->st_value - S->ind - 4; | 326 | pe->v -= esym2->st_value - S->tccgen_ind - 4; |
| 327 | pe->pcrel = 1; | 327 | pe->pcrel = 1; |
| 328 | e2.sym = NULL; | 328 | e2.sym = NULL; |
| 329 | } else { | 329 | } else { |
| @@ -342,7 +342,7 @@ static inline void asm_expr_cmp(TCCState *S, ExprValue *pe) · 12 unmodified lines | |||
| 342 | 342 | ||
| 343 | asm_expr_sum(S, pe); | 343 | asm_expr_sum(S, pe); |
| 344 | for(;;) { | 344 | for(;;) { |
| 345 | op = S->tok; | 345 | op = S->tccpp_tok; |
| 346 | if (op != TOK_EQ && op != TOK_NE | 346 | if (op != TOK_EQ && op != TOK_NE |
| 347 | && (op > TOK_GT || op < TOK_ULE)) | 347 | && (op > TOK_GT || op < TOK_ULE)) |
| 348 | break; | 348 | break; |
| @@ -428,7 +428,7 @@ static Sym* asm_new_label1(TCCState *S, int label, int is_local, · 79 unmodified lines | |||
| 428 | 428 | ||
| 429 | static Sym* asm_new_label(TCCState *S, int label, int is_local) | 429 | static Sym* asm_new_label(TCCState *S, int label, int is_local) |
| 430 | { | 430 | { |
| 431 | return asm_new_label1(S, label, is_local, cur_text_section->sh_num, S->ind); | 431 | return asm_new_label1(S, label, is_local, cur_text_section->sh_num, S->tccgen_ind); |
| 432 | } | 432 | } |
| 433 | 433 | ||
| 434 | /* Set the value of LABEL to that of some expression (possibly | 434 | /* Set the value of LABEL to that of some expression (possibly |
| @@ -452,9 +452,9 @@ static Sym* set_symbol(TCCState *S, int label) · 17 unmodified lines | |||
| 452 | 452 | ||
| 453 | static void use_section1(TCCState *S, Section *sec) | 453 | static void use_section1(TCCState *S, Section *sec) |
| 454 | { | 454 | { |
| 455 | cur_text_section->data_offset = S->ind; | 455 | cur_text_section->data_offset = S->tccgen_ind; |
| 456 | cur_text_section = sec; | 456 | cur_text_section = sec; |
| 457 | S->ind = cur_text_section->data_offset; | 457 | S->tccgen_ind = cur_text_section->data_offset; |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | static void use_section(TCCState *S, const char *name) | 460 | static void use_section(TCCState *S, const char *name) |
| @@ -488,13 +488,13 @@ static void asm_parse_directive(TCCState *S, int global) · 27 unmodified lines | |||
| 488 | 488 | ||
| 489 | /* assembler directive */ | 489 | /* assembler directive */ |
| 490 | sec = cur_text_section; | 490 | sec = cur_text_section; |
| 491 | switch(S->tok) { | 491 | switch(S->tccpp_tok) { |
| 492 | case TOK_ASMDIR_align: | 492 | case TOK_ASMDIR_align: |
| 493 | case TOK_ASMDIR_balign: | 493 | case TOK_ASMDIR_balign: |
| 494 | case TOK_ASMDIR_p2align: | 494 | case TOK_ASMDIR_p2align: |
| 495 | case TOK_ASMDIR_skip: | 495 | case TOK_ASMDIR_skip: |
| 496 | case TOK_ASMDIR_space: | 496 | case TOK_ASMDIR_space: |
| 497 | tok1 = S->tok; | 497 | tok1 = S->tccpp_tok; |
| 498 | next(S); | 498 | next(S); |
| 499 | n = asm_int_expr(S); | 499 | n = asm_int_expr(S); |
| 500 | if (tok1 == TOK_ASMDIR_p2align) | 500 | if (tok1 == TOK_ASMDIR_p2align) |
| @@ -507,8 +507,8 @@ static void asm_parse_directive(TCCState *S, int global) · 6 unmodified lines | |||
| 507 | if (tok1 == TOK_ASMDIR_align || tok1 == TOK_ASMDIR_balign) { | 507 | if (tok1 == TOK_ASMDIR_align || tok1 == TOK_ASMDIR_balign) { |
| 508 | if (n < 0 || (n & (n-1)) != 0) | 508 | if (n < 0 || (n & (n-1)) != 0) |
| 509 | tcc_error(S, "alignment must be a positive power of two"); | 509 | tcc_error(S, "alignment must be a positive power of two"); |
| 510 | offset = (S->ind + n - 1) & -n; | 510 | offset = (S->tccgen_ind + n - 1) & -n; |
| 511 | size = offset - S->ind; | 511 | size = offset - S->tccgen_ind; |
| 512 | /* the section must have a compatible alignment */ | 512 | /* the section must have a compatible alignment */ |
| 513 | if (sec->sh_addralign < n) | 513 | if (sec->sh_addralign < n) |
| 514 | sec->sh_addralign = n; | 514 | sec->sh_addralign = n; |
| @@ -518,17 +518,17 @@ static void asm_parse_directive(TCCState *S, int global) · 3 unmodified lines | |||
| 518 | size = n; | 518 | size = n; |
| 519 | } | 519 | } |
| 520 | v = 0; | 520 | v = 0; |
| 521 | if (S->tok == ',') { | 521 | if (S->tccpp_tok == ',') { |
| 522 | next(S); | 522 | next(S); |
| 523 | v = asm_int_expr(S); | 523 | v = asm_int_expr(S); |
| 524 | } | 524 | } |
| 525 | zero_pad: | 525 | zero_pad: |
| 526 | if (sec->sh_type != SHT_NOBITS) { | 526 | if (sec->sh_type != SHT_NOBITS) { |
| 527 | sec->data_offset = S->ind; | 527 | sec->data_offset = S->tccgen_ind; |
| 528 | ptr = section_ptr_add(S, sec, size); | 528 | ptr = section_ptr_add(S, sec, size); |
| 529 | memset(ptr, v, size); | 529 | memset(ptr, v, size); |
| 530 | } | 530 | } |
| 531 | S->ind += size; | 531 | S->tccgen_ind += size; |
| 532 | break; | 532 | break; |
| 533 | case TOK_ASMDIR_quad: | 533 | case TOK_ASMDIR_quad: |
| 534 | #ifdef TCC_TARGET_X86_64 | 534 | #ifdef TCC_TARGET_X86_64 |
| @@ -540,8 +540,8 @@ static void asm_parse_directive(TCCState *S, int global) · 5 unmodified lines | |||
| 540 | uint64_t vl; | 540 | uint64_t vl; |
| 541 | const char *p; | 541 | const char *p; |
| 542 | 542 | ||
| 543 | p = S->tokc.str.data; | 543 | p = S->tccpp_tokc.str.data; |
| 544 | if (S->tok != TOK_PPNUM) { | 544 | if (S->tccpp_tok != TOK_PPNUM) { |
| 545 | error_constant: | 545 | error_constant: |
| 546 | tcc_error(S, "64 bit constant"); | 546 | tcc_error(S, "64 bit constant"); |
| 547 | } | 547 | } |
| @@ -554,9 +554,9 @@ static void asm_parse_directive(TCCState *S, int global) · 6 unmodified lines | |||
| 554 | gen_le32(S, vl); | 554 | gen_le32(S, vl); |
| 555 | gen_le32(S, vl >> 32); | 555 | gen_le32(S, vl >> 32); |
| 556 | } else { | 556 | } else { |
| 557 | S->ind += 8; | 557 | S->tccgen_ind += 8; |
| 558 | } | 558 | } |
| 559 | if (S->tok != ',') | 559 | if (S->tccpp_tok != ',') |
| 560 | break; | 560 | break; |
| 561 | next(S); | 561 | next(S); |
| 562 | } | 562 | } |
| @@ -593,9 +593,9 @@ static void asm_parse_directive(TCCState *S, int global) · 30 unmodified lines | |||
| 593 | gen_le16(S, e.v); | 593 | gen_le16(S, e.v); |
| 594 | } | 594 | } |
| 595 | } else { | 595 | } else { |
| 596 | S->ind += size; | 596 | S->tccgen_ind += size; |
| 597 | } | 597 | } |
| 598 | if (S->tok != ',') | 598 | if (S->tccpp_tok != ',') |
| 599 | break; | 599 | break; |
| 600 | next(S); | 600 | next(S); |
| 601 | } | 601 | } |
| @@ -612,7 +612,7 @@ static void asm_parse_directive(TCCState *S, int global) · 10 unmodified lines | |||
| 612 | } | 612 | } |
| 613 | size = 1; | 613 | size = 1; |
| 614 | val = 0; | 614 | val = 0; |
| 615 | if (S->tok == ',') { | 615 | if (S->tccpp_tok == ',') { |
| 616 | next(S); | 616 | next(S); |
| 617 | size = asm_int_expr(S); | 617 | size = asm_int_expr(S); |
| 618 | if (size < 0) { | 618 | if (size < 0) { |
| @@ -621,7 +621,7 @@ static void asm_parse_directive(TCCState *S, int global) · 2 unmodified lines | |||
| 621 | } | 621 | } |
| 622 | if (size > 8) | 622 | if (size > 8) |
| 623 | size = 8; | 623 | size = 8; |
| 624 | if (S->tok == ',') { | 624 | if (S->tccpp_tok == ',') { |
| 625 | next(S); | 625 | next(S); |
| 626 | val = asm_int_expr(S); | 626 | val = asm_int_expr(S); |
| 627 | } | 627 | } |
| @@ -649,8 +649,8 @@ static void asm_parse_directive(TCCState *S, int global) · 21 unmodified lines | |||
| 649 | next(S); | 649 | next(S); |
| 650 | repeat = asm_int_expr(S); | 650 | repeat = asm_int_expr(S); |
| 651 | init_str = tok_str_alloc(S); | 651 | init_str = tok_str_alloc(S); |
| 652 | while (next(S), S->tok != TOK_ASMDIR_endr) { | 652 | while (next(S), S->tccpp_tok != TOK_ASMDIR_endr) { |
| 653 | if (S->tok == CH_EOF) | 653 | if (S->tccpp_tok == CH_EOF) |
| 654 | tcc_error(S, "we at end of file, .endr not found"); | 654 | tcc_error(S, "we at end of file, .endr not found"); |
| 655 | tok_str_add_tok(S, init_str); | 655 | tok_str_add_tok(S, init_str); |
| 656 | } | 656 | } |
| @@ -680,31 +680,31 @@ static void asm_parse_directive(TCCState *S, int global) · 23 unmodified lines | |||
| 680 | expect(S, "constant or same-section symbol"); | 680 | expect(S, "constant or same-section symbol"); |
| 681 | n += esym->st_value; | 681 | n += esym->st_value; |
| 682 | } | 682 | } |
| 683 | if (n < S->ind) | 683 | if (n < S->tccgen_ind) |
| 684 | tcc_error(S, "attempt to .org backwards"); | 684 | tcc_error(S, "attempt to .org backwards"); |
| 685 | v = 0; | 685 | v = 0; |
| 686 | size = n - S->ind; | 686 | size = n - S->tccgen_ind; |
| 687 | goto zero_pad; | 687 | goto zero_pad; |
| 688 | } | 688 | } |
| 689 | break; | 689 | break; |
| 690 | case TOK_ASMDIR_set: | 690 | case TOK_ASMDIR_set: |
| 691 | next(S); | 691 | next(S); |
| 692 | tok1 = S->tok; | 692 | tok1 = S->tccpp_tok; |
| 693 | next(S); | 693 | next(S); |
| 694 | /* Also accept '.set stuff', but don't do anything with this. | 694 | /* Also accept '.set stuff', but don't do anything with this. |
| 695 | It's used in GAS to set various features like '.set mips16'. */ | 695 | It's used in GAS to set various features like '.set mips16'. */ |
| 696 | if (S->tok == ',') | 696 | if (S->tccpp_tok == ',') |
| 697 | set_symbol(S, tok1); | 697 | set_symbol(S, tok1); |
| 698 | break; | 698 | break; |
| 699 | case TOK_ASMDIR_globl: | 699 | case TOK_ASMDIR_globl: |
| 700 | case TOK_ASMDIR_global: | 700 | case TOK_ASMDIR_global: |
| 701 | case TOK_ASMDIR_weak: | 701 | case TOK_ASMDIR_weak: |
| 702 | case TOK_ASMDIR_hidden: | 702 | case TOK_ASMDIR_hidden: |
| 703 | tok1 = S->tok; | 703 | tok1 = S->tccpp_tok; |
| 704 | do { | 704 | do { |
| 705 | Sym *sym; | 705 | Sym *sym; |
| 706 | next(S); | 706 | next(S); |
| 707 | sym = get_asm_sym(S, S->tok, NULL); | 707 | sym = get_asm_sym(S, S->tccpp_tok, NULL); |
| 708 | if (tok1 != TOK_ASMDIR_hidden) | 708 | if (tok1 != TOK_ASMDIR_hidden) |
| 709 | sym->type.t &= ~VT_STATIC; | 709 | sym->type.t &= ~VT_STATIC; |
| 710 | if (tok1 == TOK_ASMDIR_weak) | 710 | if (tok1 == TOK_ASMDIR_weak) |
| @@ -713,7 +713,7 @@ static void asm_parse_directive(TCCState *S, int global) · 2 unmodified lines | |||
| 713 | sym->a.visibility = STV_HIDDEN; | 713 | sym->a.visibility = STV_HIDDEN; |
| 714 | update_storage(S, sym); | 714 | update_storage(S, sym); |
| 715 | next(S); | 715 | next(S); |
| 716 | } while (S->tok == ','); | 716 | } while (S->tccpp_tok == ','); |
| 717 | break; | 717 | break; |
| 718 | case TOK_ASMDIR_string: | 718 | case TOK_ASMDIR_string: |
| 719 | case TOK_ASMDIR_ascii: | 719 | case TOK_ASMDIR_ascii: |
| @@ -722,21 +722,21 @@ static void asm_parse_directive(TCCState *S, int global) · 2 unmodified lines | |||
| 722 | const uint8_t *p; | 722 | const uint8_t *p; |
| 723 | int i, size, t; | 723 | int i, size, t; |
| 724 | 724 | ||
| 725 | t = S->tok; | 725 | t = S->tccpp_tok; |
| 726 | next(S); | 726 | next(S); |
| 727 | for(;;) { | 727 | for(;;) { |
| 728 | if (S->tok != TOK_STR) | 728 | if (S->tccpp_tok != TOK_STR) |
| 729 | expect(S, "string constant"); | 729 | expect(S, "string constant"); |
| 730 | p = S->tokc.str.data; | 730 | p = S->tccpp_tokc.str.data; |
| 731 | size = S->tokc.str.size; | 731 | size = S->tccpp_tokc.str.size; |
| 732 | if (t == TOK_ASMDIR_ascii && size > 0) | 732 | if (t == TOK_ASMDIR_ascii && size > 0) |
| 733 | size--; | 733 | size--; |
| 734 | for(i = 0; i < size; i++) | 734 | for(i = 0; i < size; i++) |
| 735 | g(S, p[i]); | 735 | g(S, p[i]); |
| 736 | next(S); | 736 | next(S); |
| 737 | if (S->tok == ',') { | 737 | if (S->tccpp_tok == ',') { |
| 738 | next(S); | 738 | next(S); |
| 739 | } else if (S->tok != TOK_STR) { | 739 | } else if (S->tccpp_tok != TOK_STR) { |
| 740 | break; | 740 | break; |
| 741 | } | 741 | } |
| 742 | } | 742 | } |
| @@ -747,10 +747,10 @@ static void asm_parse_directive(TCCState *S, int global) · 4 unmodified lines | |||
| 747 | case TOK_ASMDIR_bss: | 747 | case TOK_ASMDIR_bss: |
| 748 | { | 748 | { |
| 749 | char sname[64]; | 749 | char sname[64]; |
| 750 | tok1 = S->tok; | 750 | tok1 = S->tccpp_tok; |
| 751 | n = 0; | 751 | n = 0; |
| 752 | next(S); | 752 | next(S); |
| 753 | if (S->tok != ';' && S->tok != TOK_LINEFEED) { | 753 | if (S->tccpp_tok != ';' && S->tccpp_tok != TOK_LINEFEED) { |
| 754 | n = asm_int_expr(S); | 754 | n = asm_int_expr(S); |
| 755 | next(S); | 755 | next(S); |
| 756 | } | 756 | } |
| @@ -767,10 +767,10 @@ static void asm_parse_directive(TCCState *S, int global) · 10 unmodified lines | |||
| 767 | 767 | ||
| 768 | filename[0] = '\0'; | 768 | filename[0] = '\0'; |
| 769 | next(S); | 769 | next(S); |
| 770 | if (S->tok == TOK_STR) | 770 | if (S->tccpp_tok == TOK_STR) |
| 771 | pstrcat(filename, sizeof(filename), S->tokc.str.data); | 771 | pstrcat(filename, sizeof(filename), S->tccpp_tokc.str.data); |
| 772 | else | 772 | else |
| 773 | pstrcat(filename, sizeof(filename), get_tok_str(S, S->tok, NULL)); | 773 | pstrcat(filename, sizeof(filename), get_tok_str(S, S->tccpp_tok, NULL)); |
| 774 | tcc_warning_c(warn_unsupported)(S, "ignoring .file %s", filename); | 774 | tcc_warning_c(warn_unsupported)(S, "ignoring .file %s", filename); |
| 775 | next(S); | 775 | next(S); |
| 776 | } | 776 | } |
| @@ -781,10 +781,10 @@ static void asm_parse_directive(TCCState *S, int global) · 4 unmodified lines | |||
| 781 | 781 | ||
| 782 | ident[0] = '\0'; | 782 | ident[0] = '\0'; |
| 783 | next(S); | 783 | next(S); |
| 784 | if (S->tok == TOK_STR) | 784 | if (S->tccpp_tok == TOK_STR) |
| 785 | pstrcat(ident, sizeof(ident), S->tokc.str.data); | 785 | pstrcat(ident, sizeof(ident), S->tccpp_tokc.str.data); |
| 786 | else | 786 | else |
| 787 | pstrcat(ident, sizeof(ident), get_tok_str(S, S->tok, NULL)); | 787 | pstrcat(ident, sizeof(ident), get_tok_str(S, S->tccpp_tok, NULL)); |
| 788 | tcc_warning_c(warn_unsupported)(S, "ignoring .ident %s", ident); | 788 | tcc_warning_c(warn_unsupported)(S, "ignoring .ident %s", ident); |
| 789 | next(S); | 789 | next(S); |
| 790 | } | 790 | } |
| @@ -794,15 +794,15 @@ static void asm_parse_directive(TCCState *S, int global) · 3 unmodified lines | |||
| 794 | Sym *sym; | 794 | Sym *sym; |
| 795 | 795 | ||
| 796 | next(S); | 796 | next(S); |
| 797 | sym = asm_label_find(S, S->tok); | 797 | sym = asm_label_find(S, S->tccpp_tok); |
| 798 | if (!sym) { | 798 | if (!sym) { |
| 799 | tcc_error(S, "label not found: %s", get_tok_str(S, S->tok, NULL)); | 799 | tcc_error(S, "label not found: %s", get_tok_str(S, S->tccpp_tok, NULL)); |
| 800 | } | 800 | } |
| 801 | /* XXX .size name,label2-label1 */ | 801 | /* XXX .size name,label2-label1 */ |
| 802 | tcc_warning_c(warn_unsupported)(S, "ignoring .size %s,*", get_tok_str(S, S->tok, NULL)); | 802 | tcc_warning_c(warn_unsupported)(S, "ignoring .size %s,*", get_tok_str(S, S->tccpp_tok, NULL)); |
| 803 | next(S); | 803 | next(S); |
| 804 | skip(S, ','); | 804 | skip(S, ','); |
| 805 | while (S->tok != TOK_LINEFEED && S->tok != ';' && S->tok != CH_EOF) { | 805 | while (S->tccpp_tok != TOK_LINEFEED && S->tccpp_tok != ';' && S->tccpp_tok != CH_EOF) { |
| 806 | next(S); | 806 | next(S); |
| 807 | } | 807 | } |
| 808 | } | 808 | } |
| @@ -813,15 +813,15 @@ static void asm_parse_directive(TCCState *S, int global) · 4 unmodified lines | |||
| 813 | const char *newtype; | 813 | const char *newtype; |
| 814 | 814 | ||
| 815 | next(S); | 815 | next(S); |
| 816 | sym = get_asm_sym(S, S->tok, NULL); | 816 | sym = get_asm_sym(S, S->tccpp_tok, NULL); |
| 817 | next(S); | 817 | next(S); |
| 818 | skip(S, ','); | 818 | skip(S, ','); |
| 819 | if (S->tok == TOK_STR) { | 819 | if (S->tccpp_tok == TOK_STR) { |
| 820 | newtype = S->tokc.str.data; | 820 | newtype = S->tccpp_tokc.str.data; |
| 821 | } else { | 821 | } else { |
| 822 | if (S->tok == '@' || S->tok == '%') | 822 | if (S->tccpp_tok == '@' || S->tccpp_tok == '%') |
| 823 | next(S); | 823 | next(S); |
| 824 | newtype = get_tok_str(S, S->tok, NULL); | 824 | newtype = get_tok_str(S, S->tccpp_tok, NULL); |
| 825 | } | 825 | } |
| 826 | 826 | ||
| 827 | if (!strcmp(newtype, "function") || !strcmp(newtype, "STT_FUNC")) { | 827 | if (!strcmp(newtype, "function") || !strcmp(newtype, "STT_FUNC")) { |
| @@ -839,26 +839,26 @@ static void asm_parse_directive(TCCState *S, int global) · 11 unmodified lines | |||
| 839 | char sname[256]; | 839 | char sname[256]; |
| 840 | int old_nb_section = S->nb_sections; | 840 | int old_nb_section = S->nb_sections; |
| 841 | 841 | ||
| 842 | tok1 = S->tok; | 842 | tok1 = S->tccpp_tok; |
| 843 | /* XXX: support more options */ | 843 | /* XXX: support more options */ |
| 844 | next(S); | 844 | next(S); |
| 845 | sname[0] = '\0'; | 845 | sname[0] = '\0'; |
| 846 | while (S->tok != ';' && S->tok != TOK_LINEFEED && S->tok != ',') { | 846 | while (S->tccpp_tok != ';' && S->tccpp_tok != TOK_LINEFEED && S->tccpp_tok != ',') { |
| 847 | if (S->tok == TOK_STR) | 847 | if (S->tccpp_tok == TOK_STR) |
| 848 | pstrcat(sname, sizeof(sname), S->tokc.str.data); | 848 | pstrcat(sname, sizeof(sname), S->tccpp_tokc.str.data); |
| 849 | else | 849 | else |
| 850 | pstrcat(sname, sizeof(sname), get_tok_str(S, S->tok, NULL)); | 850 | pstrcat(sname, sizeof(sname), get_tok_str(S, S->tccpp_tok, NULL)); |
| 851 | next(S); | 851 | next(S); |
| 852 | } | 852 | } |
| 853 | if (S->tok == ',') { | 853 | if (S->tccpp_tok == ',') { |
| 854 | /* skip section options */ | 854 | /* skip section options */ |
| 855 | next(S); | 855 | next(S); |
| 856 | if (S->tok != TOK_STR) | 856 | if (S->tccpp_tok != TOK_STR) |
| 857 | expect(S, "string constant"); | 857 | expect(S, "string constant"); |
| 858 | next(S); | 858 | next(S); |
| 859 | if (S->tok == ',') { | 859 | if (S->tccpp_tok == ',') { |
| 860 | next(S); | 860 | next(S); |
| 861 | if (S->tok == '@' || S->tok == '%') | 861 | if (S->tccpp_tok == '@' || S->tccpp_tok == '%') |
| 862 | next(S); | 862 | next(S); |
| 863 | next(S); | 863 | next(S); |
| 864 | } | 864 | } |
| @@ -911,7 +911,7 @@ static void asm_parse_directive(TCCState *S, int global) · 46 unmodified lines | |||
| 911 | break; | 911 | break; |
| 912 | #endif | 912 | #endif |
| 913 | default: | 913 | default: |
| 914 | tcc_error(S, "unknown assembler directive '.%s'", get_tok_str(S, S->tok, NULL)); | 914 | tcc_error(S, "unknown assembler directive '.%s'", get_tok_str(S, S->tccpp_tok, NULL)); |
| 915 | break; | 915 | break; |
| 916 | } | 916 | } |
| 917 | } | 917 | } |
| @@ -928,20 +928,20 @@ static int tcc_assemble_internal(TCCState *S, int do_preprocess, int global) · 10 unmodified lines | |||
| 928 | S->tccpp_parse_flags |= PARSE_FLAG_PREPROCESS; | 928 | S->tccpp_parse_flags |= PARSE_FLAG_PREPROCESS; |
| 929 | for(;;) { | 929 | for(;;) { |
| 930 | next(S); | 930 | next(S); |
| 931 | if (S->tok == TOK_EOF) | 931 | if (S->tccpp_tok == TOK_EOF) |
| 932 | break; | 932 | break; |
| 933 | S->tccpp_parse_flags |= PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */ | 933 | S->tccpp_parse_flags |= PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */ |
| 934 | redo: | 934 | redo: |
| 935 | if (S->tok == '#') { | 935 | if (S->tccpp_tok == '#') { |
| 936 | /* horrible gas comment */ | 936 | /* horrible gas comment */ |
| 937 | while (S->tok != TOK_LINEFEED) | 937 | while (S->tccpp_tok != TOK_LINEFEED) |
| 938 | next(S); | 938 | next(S); |
| 939 | } else if (S->tok >= TOK_ASMDIR_FIRST && S->tok <= TOK_ASMDIR_LAST) { | 939 | } else if (S->tccpp_tok >= TOK_ASMDIR_FIRST && S->tccpp_tok <= TOK_ASMDIR_LAST) { |
| 940 | asm_parse_directive(S, global); | 940 | asm_parse_directive(S, global); |
| 941 | } else if (S->tok == TOK_PPNUM) { | 941 | } else if (S->tccpp_tok == TOK_PPNUM) { |
| 942 | const char *p; | 942 | const char *p; |
| 943 | int n; | 943 | int n; |
| 944 | p = S->tokc.str.data; | 944 | p = S->tccpp_tokc.str.data; |
| 945 | n = strtoul(p, (char **)&p, 10); | 945 | n = strtoul(p, (char **)&p, 10); |
| 946 | if (*p != '\0') | 946 | if (*p != '\0') |
| 947 | expect(S, "':'"); | 947 | expect(S, "':'"); |
| @@ -950,16 +950,16 @@ static int tcc_assemble_internal(TCCState *S, int do_preprocess, int global) · 2 unmodified lines | |||
| 950 | next(S); | 950 | next(S); |
| 951 | skip(S, ':'); | 951 | skip(S, ':'); |
| 952 | goto redo; | 952 | goto redo; |
| 953 | } else if (S->tok >= TOK_IDENT) { | 953 | } else if (S->tccpp_tok >= TOK_IDENT) { |
| 954 | /* instruction or label */ | 954 | /* instruction or label */ |
| 955 | opcode = S->tok; | 955 | opcode = S->tccpp_tok; |
| 956 | next(S); | 956 | next(S); |
| 957 | if (S->tok == ':') { | 957 | if (S->tccpp_tok == ':') { |
| 958 | /* new label */ | 958 | /* new label */ |
| 959 | asm_new_label(S, opcode, 0); | 959 | asm_new_label(S, opcode, 0); |
| 960 | next(S); | 960 | next(S); |
| 961 | goto redo; | 961 | goto redo; |
| 962 | } else if (S->tok == '=') { | 962 | } else if (S->tccpp_tok == '=') { |
| 963 | set_symbol(S, opcode); | 963 | set_symbol(S, opcode); |
| 964 | goto redo; | 964 | goto redo; |
| 965 | } else { | 965 | } else { |
| @@ -967,7 +967,7 @@ static int tcc_assemble_internal(TCCState *S, int do_preprocess, int global) · 1 unmodified line | |||
| 967 | } | 967 | } |
| 968 | } | 968 | } |
| 969 | /* end of line */ | 969 | /* end of line */ |
| 970 | if (S->tok != ';' && S->tok != TOK_LINEFEED) | 970 | if (S->tccpp_tok != ';' && S->tccpp_tok != TOK_LINEFEED) |
| 971 | expect(S, "end of line"); | 971 | expect(S, "end of line"); |
| 972 | S->tccpp_parse_flags &= ~PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */ | 972 | S->tccpp_parse_flags &= ~PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */ |
| 973 | } | 973 | } |
| @@ -983,10 +983,10 @@ ST_FUNC int tcc_assemble(TCCState *S, int do_preprocess) · 9 unmodified lines | |||
| 983 | tcc_debug_start(S); | 983 | tcc_debug_start(S); |
| 984 | /* default section is text */ | 984 | /* default section is text */ |
| 985 | cur_text_section = text_section; | 985 | cur_text_section = text_section; |
| 986 | S->ind = cur_text_section->data_offset; | 986 | S->tccgen_ind = cur_text_section->data_offset; |
| 987 | S->nocode_wanted = 0; | 987 | S->tccgen_nocode_wanted = 0; |
| 988 | ret = tcc_assemble_internal(S, do_preprocess, 1); | 988 | ret = tcc_assemble_internal(S, do_preprocess, 1); |
| 989 | cur_text_section->data_offset = S->ind; | 989 | cur_text_section->data_offset = S->tccgen_ind; |
| 990 | tcc_debug_end(S); | 990 | tcc_debug_end(S); |
| 991 | return ret; | 991 | return ret; |
| 992 | } | 992 | } |
| @@ -1017,7 +1017,7 @@ static void tcc_assemble_inline(TCCState *S, char *str, int len, int global) · 24 unmodified lines | |||
| 1017 | /* find a constraint by its number or id (gcc 3 extended | 1017 | /* find a constraint by its number or id (gcc 3 extended |
| 1018 | syntax). return -1 if not found. Return in *pp in char after the | 1018 | syntax). return -1 if not found. Return in *pp in char after the |
| 1019 | constraint */ | 1019 | constraint */ |
| 1020 | ST_FUNC int find_constraint(TCCState *S, ASMOperand *operands, int nb_operands, | 1020 | ST_FUNC int find_constraint(TCCState* S, ASMOperand *operands, int nb_operands, |
| 1021 | const char *name, const char **pp) | 1021 | const char *name, const char **pp) |
| 1022 | { | 1022 | { |
| 1023 | int index; | 1023 | int index; |
| @@ -1055,7 +1055,7 @@ ST_FUNC int find_constraint(TCCState *S, ASMOperand *operands, int nb_operands, · 31 unmodified lines | |||
| 1055 | return index; | 1055 | return index; |
| 1056 | } | 1056 | } |
| 1057 | 1057 | ||
| 1058 | static void subst_asm_operands(TCCState *S, ASMOperand *operands, int nb_operands, | 1058 | static void subst_asm_operands(TCCState* S, ASMOperand *operands, int nb_operands, |
| 1059 | CString *out_str, CString *in_str) | 1059 | CString *out_str, CString *in_str) |
| 1060 | { | 1060 | { |
| 1061 | int c, index, modifier; | 1061 | int c, index, modifier; |
| @@ -1101,13 +1101,13 @@ static void subst_asm_operands(TCCState *S, ASMOperand *operands, int nb_operand · 39 unmodified lines | |||
| 1101 | } | 1101 | } |
| 1102 | 1102 | ||
| 1103 | 1103 | ||
| 1104 | static void parse_asm_operands(TCCState *S, ASMOperand *operands, int *nb_operands_ptr, | 1104 | static void parse_asm_operands(TCCState* S, ASMOperand *operands, int *nb_operands_ptr, |
| 1105 | int is_output) | 1105 | int is_output) |
| 1106 | { | 1106 | { |
| 1107 | ASMOperand *op; | 1107 | ASMOperand *op; |
| 1108 | int nb_operands; | 1108 | int nb_operands; |
| 1109 | 1109 | ||
| 1110 | if (S->tok != ':') { | 1110 | if (S->tccpp_tok != ':') { |
| 1111 | nb_operands = *nb_operands_ptr; | 1111 | nb_operands = *nb_operands_ptr; |
| 1112 | for(;;) { | 1112 | for(;;) { |
| 1113 | CString astr; | 1113 | CString astr; |
| @@ -1115,11 +1115,11 @@ static void parse_asm_operands(TCCState *S, ASMOperand *operands, int *nb_operan · 1 unmodified line | |||
| 1115 | tcc_error(S, "too many asm operands"); | 1115 | tcc_error(S, "too many asm operands"); |
| 1116 | op = &operands[nb_operands++]; | 1116 | op = &operands[nb_operands++]; |
| 1117 | op->id = 0; | 1117 | op->id = 0; |
| 1118 | if (S->tok == '[') { | 1118 | if (S->tccpp_tok == '[') { |
| 1119 | next(S); | 1119 | next(S); |
| 1120 | if (S->tok < TOK_IDENT) | 1120 | if (S->tccpp_tok < TOK_IDENT) |
| 1121 | expect(S, "identifier"); | 1121 | expect(S, "identifier"); |
| 1122 | op->id = S->tok; | 1122 | op->id = S->tccpp_tok; |
| 1123 | next(S); | 1123 | next(S); |
| 1124 | skip(S, ']'); | 1124 | skip(S, ']'); |
| 1125 | } | 1125 | } |
| @@ -1130,23 +1130,23 @@ static void parse_asm_operands(TCCState *S, ASMOperand *operands, int *nb_operan · 4 unmodified lines | |||
| 1130 | skip(S, '('); | 1130 | skip(S, '('); |
| 1131 | gexpr(S); | 1131 | gexpr(S); |
| 1132 | if (is_output) { | 1132 | if (is_output) { |
| 1133 | if (!(S->vtop->type.t & VT_ARRAY)) | 1133 | if (!(S->tccgen_vtop->type.t & VT_ARRAY)) |
| 1134 | test_lvalue(S); | 1134 | test_lvalue(S); |
| 1135 | } else { | 1135 | } else { |
| 1136 | /* we want to avoid LLOCAL case, except when the 'm' | 1136 | /* we want to avoid LLOCAL case, except when the 'm' |
| 1137 | constraint is used. Note that it may come from | 1137 | constraint is used. Note that it may come from |
| 1138 | register storage, so we need to convert (reg) | 1138 | register storage, so we need to convert (reg) |
| 1139 | case */ | 1139 | case */ |
| 1140 | if ((S->vtop->r & VT_LVAL) && | 1140 | if ((S->tccgen_vtop->r & VT_LVAL) && |
| 1141 | ((S->vtop->r & VT_VALMASK) == VT_LLOCAL || | 1141 | ((S->tccgen_vtop->r & VT_VALMASK) == VT_LLOCAL || |
| 1142 | (S->vtop->r & VT_VALMASK) < VT_CONST) && | 1142 | (S->tccgen_vtop->r & VT_VALMASK) < VT_CONST) && |
| 1143 | !strchr(op->constraint, 'm')) { | 1143 | !strchr(op->constraint, 'm')) { |
| 1144 | gv(S, RC_INT); | 1144 | gv(S, RC_INT); |
| 1145 | } | 1145 | } |
| 1146 | } | 1146 | } |
| 1147 | op->vt = S->vtop; | 1147 | op->vt = S->tccgen_vtop; |
| 1148 | skip(S, ')'); | 1148 | skip(S, ')'); |
| 1149 | if (S->tok == ',') { | 1149 | if (S->tccpp_tok == ',') { |
| 1150 | next(S); | 1150 | next(S); |
| 1151 | } else { | 1151 | } else { |
| 1152 | break; | 1152 | break; |
| @@ -1157,7 +1157,7 @@ static void parse_asm_operands(TCCState *S, ASMOperand *operands, int *nb_operan · 4 unmodified lines | |||
| 1157 | } | 1157 | } |
| 1158 | 1158 | ||
| 1159 | /* parse the GCC asm() instruction */ | 1159 | /* parse the GCC asm() instruction */ |
| 1160 | ST_FUNC void asm_instr(TCCState *S) | 1160 | ST_FUNC void asm_instr(TCCState* S) |
| 1161 | { | 1161 | { |
| 1162 | CString astr, astr1; | 1162 | CString astr, astr1; |
| 1163 | ASMOperand operands[MAX_ASM_OPERANDS]; | 1163 | ASMOperand operands[MAX_ASM_OPERANDS]; |
| @@ -1167,7 +1167,7 @@ ST_FUNC void asm_instr(TCCState *S) · 3 unmodified lines | |||
| 1167 | 1167 | ||
| 1168 | /* since we always generate the asm() instruction, we can ignore | 1168 | /* since we always generate the asm() instruction, we can ignore |
| 1169 | volatile */ | 1169 | volatile */ |
| 1170 | if (S->tok == TOK_VOLATILE1 || S->tok == TOK_VOLATILE2 || S->tok == TOK_VOLATILE3) { | 1170 | if (S->tccpp_tok == TOK_VOLATILE1 || S->tccpp_tok == TOK_VOLATILE2 || S->tccpp_tok == TOK_VOLATILE3) { |
| 1171 | next(S); | 1171 | next(S); |
| 1172 | } | 1172 | } |
| 1173 | parse_asm_str(S, &astr); | 1173 | parse_asm_str(S, &astr); |
| @@ -1175,27 +1175,27 @@ ST_FUNC void asm_instr(TCCState *S) · 1 unmodified line | |||
| 1175 | nb_outputs = 0; | 1175 | nb_outputs = 0; |
| 1176 | must_subst = 0; | 1176 | must_subst = 0; |
| 1177 | memset(clobber_regs, 0, sizeof(clobber_regs)); | 1177 | memset(clobber_regs, 0, sizeof(clobber_regs)); |
| 1178 | if (S->tok == ':') { | 1178 | if (S->tccpp_tok == ':') { |
| 1179 | next(S); | 1179 | next(S); |
| 1180 | must_subst = 1; | 1180 | must_subst = 1; |
| 1181 | /* output args */ | 1181 | /* output args */ |
| 1182 | parse_asm_operands(S, operands, &nb_operands, 1); | 1182 | parse_asm_operands(S, operands, &nb_operands, 1); |
| 1183 | nb_outputs = nb_operands; | 1183 | nb_outputs = nb_operands; |
| 1184 | if (S->tok == ':') { | 1184 | if (S->tccpp_tok == ':') { |
| 1185 | next(S); | 1185 | next(S); |
| 1186 | if (S->tok != ')') { | 1186 | if (S->tccpp_tok != ')') { |
| 1187 | /* input args */ | 1187 | /* input args */ |
| 1188 | parse_asm_operands(S, operands, &nb_operands, 0); | 1188 | parse_asm_operands(S, operands, &nb_operands, 0); |
| 1189 | if (S->tok == ':') { | 1189 | if (S->tccpp_tok == ':') { |
| 1190 | /* clobber list */ | 1190 | /* clobber list */ |
| 1191 | /* XXX: handle registers */ | 1191 | /* XXX: handle registers */ |
| 1192 | next(S); | 1192 | next(S); |
| 1193 | for(;;) { | 1193 | for(;;) { |
| 1194 | if (S->tok != TOK_STR) | 1194 | if (S->tccpp_tok != TOK_STR) |
| 1195 | expect(S, "string constant"); | 1195 | expect(S, "string constant"); |
| 1196 | asm_clobber(S, clobber_regs, S->tokc.str.data); | 1196 | asm_clobber(S, clobber_regs, S->tccpp_tokc.str.data); |
| 1197 | next(S); | 1197 | next(S); |
| 1198 | if (S->tok == ',') { | 1198 | if (S->tccpp_tok == ',') { |
| 1199 | next(S); | 1199 | next(S); |
| 1200 | } else { | 1200 | } else { |
| 1201 | break; | 1201 | break; |
| @@ -1208,7 +1208,7 @@ ST_FUNC void asm_instr(TCCState *S) · 6 unmodified lines | |||
| 1208 | skip(S, ')'); | 1208 | skip(S, ')'); |
| 1209 | /* NOTE: we do not eat the ';' so that we can restore the current | 1209 | /* NOTE: we do not eat the ';' so that we can restore the current |
| 1210 | token after the assembler parsing */ | 1210 | token after the assembler parsing */ |
| 1211 | if (S->tok != ';') | 1211 | if (S->tccpp_tok != ';') |
| 1212 | expect(S, "';'"); | 1212 | expect(S, "';'"); |
| 1213 | 1213 | ||
| 1214 | /* save all values in the memory */ | 1214 | /* save all values in the memory */ |
| @@ -1264,37 +1264,37 @@ ST_FUNC void asm_instr(TCCState *S) · 49 unmodified lines | |||
| 1264 | cstr_free(S, &astr1); | 1264 | cstr_free(S, &astr1); |
| 1265 | } | 1265 | } |
| 1266 | 1266 | ||
| 1267 | ST_FUNC void asm_global_instr(TCCState *S) | 1267 | ST_FUNC void asm_global_instr(TCCState* S) |
| 1268 | { | 1268 | { |
| 1269 | CString astr; | 1269 | CString astr; |
| 1270 | int saved_nocode_wanted = S->nocode_wanted; | 1270 | int saved_nocode_wanted = S->tccgen_nocode_wanted; |
| 1271 | 1271 | ||
| 1272 | /* Global asm blocks are always emitted. */ | 1272 | /* Global asm blocks are always emitted. */ |
| 1273 | S->nocode_wanted = 0; | 1273 | S->tccgen_nocode_wanted = 0; |
| 1274 | next(S); | 1274 | next(S); |
| 1275 | parse_asm_str(S, &astr); | 1275 | parse_asm_str(S, &astr); |
| 1276 | skip(S, ')'); | 1276 | skip(S, ')'); |
| 1277 | /* NOTE: we do not eat the ';' so that we can restore the current | 1277 | /* NOTE: we do not eat the ';' so that we can restore the current |
| 1278 | token after the assembler parsing */ | 1278 | token after the assembler parsing */ |
| 1279 | if (S->tok != ';') | 1279 | if (S->tccpp_tok != ';') |
| 1280 | expect(S, "';'"); | 1280 | expect(S, "';'"); |
| 1281 | 1281 | ||
| 1282 | #ifdef ASM_DEBUG | 1282 | #ifdef ASM_DEBUG |
| 1283 | printf("asm_global: \"%s\"\n", (char *)astr.data); | 1283 | printf("asm_global: \"%s\"\n", (char *)astr.data); |
| 1284 | #endif | 1284 | #endif |
| 1285 | cur_text_section = text_section; | 1285 | cur_text_section = text_section; |
| 1286 | S->ind = cur_text_section->data_offset; | 1286 | S->tccgen_ind = cur_text_section->data_offset; |
| 1287 | 1287 | ||
| 1288 | /* assemble the string with tcc internal assembler */ | 1288 | /* assemble the string with tcc internal assembler */ |
| 1289 | tcc_assemble_inline(S, astr.data, astr.size - 1, 1); | 1289 | tcc_assemble_inline(S, astr.data, astr.size - 1, 1); |
| 1290 | 1290 | ||
| 1291 | cur_text_section->data_offset = S->ind; | 1291 | cur_text_section->data_offset = S->tccgen_ind; |
| 1292 | 1292 | ||
| 1293 | /* restore the current C token */ | 1293 | /* restore the current C token */ |
| 1294 | next(S); | 1294 | next(S); |
| 1295 | 1295 | ||
| 1296 | cstr_free(S, &astr); | 1296 | cstr_free(S, &astr); |
| 1297 | S->nocode_wanted = saved_nocode_wanted; | 1297 | S->tccgen_nocode_wanted = saved_nocode_wanted; |
| 1298 | } | 1298 | } |
| 1299 | 1299 | ||
| 1300 | /********************************************************/ | 1300 | /********************************************************/ |
| @@ -1304,12 +1304,12 @@ ST_FUNC int tcc_assemble(TCCState *S, int do_preprocess) · 3 unmodified lines | |||
| 1304 | tcc_error(S, "asm not supported"); | 1304 | tcc_error(S, "asm not supported"); |
| 1305 | } | 1305 | } |
| 1306 | 1306 | ||
| 1307 | ST_FUNC void asm_instr(TCCState *S) | 1307 | ST_FUNC void asm_instr(S) |
| 1308 | { | 1308 | { |
| 1309 | tcc_error(S, "inline asm() not supported"); | 1309 | tcc_error(S, "inline asm() not supported"); |
| 1310 | } | 1310 | } |
| 1311 | 1311 | ||
| 1312 | ST_FUNC void asm_global_instr(TCCState *S) | 1312 | ST_FUNC void asm_global_instr(S) |
| 1313 | { | 1313 | { |
| 1314 | tcc_error(S, "inline asm() not supported"); | 1314 | tcc_error(S, "inline asm() not supported"); |
| 1315 | } | 1315 | } |
| @@ -107,7 +107,7 @@ ST_FUNC void tccelf_stab_new(TCCState *S) · 106 unmodified lines | |||
| 107 | put_stabs(S, "", 0, 0, 0, 0); | 107 | put_stabs(S, "", 0, 0, 0, 0); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | static void free_section(TCCState *S, Section *s) | 110 | static void free_section(TCCState* S, Section *s) |
| 111 | { | 111 | { |
| 112 | tcc_free(S, s->data); | 112 | tcc_free(S, s->data); |
| 113 | } | 113 | } |
| @@ -284,7 +284,7 @@ ST_FUNC Section *new_symtab(TCCState *S, · 170 unmodified lines | |||
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | /* realloc section and set its content to zero */ | 286 | /* realloc section and set its content to zero */ |
| 287 | ST_FUNC void section_realloc(TCCState *S, Section *sec, unsigned long new_size) | 287 | ST_FUNC void section_realloc(TCCState* S, Section *sec, unsigned long new_size) |
| 288 | { | 288 | { |
| 289 | unsigned long size; | 289 | unsigned long size; |
| 290 | unsigned char *data; | 290 | unsigned char *data; |
| @@ -302,7 +302,7 @@ ST_FUNC void section_realloc(TCCState *S, Section *sec, unsigned long new_size) · 11 unmodified lines | |||
| 302 | 302 | ||
| 303 | /* reserve at least 'size' bytes aligned per 'align' in section | 303 | /* reserve at least 'size' bytes aligned per 'align' in section |
| 304 | 'sec' from current offset, and return the aligned offset */ | 304 | 'sec' from current offset, and return the aligned offset */ |
| 305 | ST_FUNC size_t section_add(TCCState *S, Section *sec, addr_t size, int align) | 305 | ST_FUNC size_t section_add(TCCState* S, Section *sec, addr_t size, int align) |
| 306 | { | 306 | { |
| 307 | size_t offset, offset1; | 307 | size_t offset, offset1; |
| 308 | 308 | ||
| @@ -318,7 +318,7 @@ ST_FUNC size_t section_add(TCCState *S, Section *sec, addr_t size, int align) · 9 unmodified lines | |||
| 318 | 318 | ||
| 319 | /* reserve at least 'size' bytes in section 'sec' from | 319 | /* reserve at least 'size' bytes in section 'sec' from |
| 320 | sec->data_offset. */ | 320 | sec->data_offset. */ |
| 321 | ST_FUNC void *section_ptr_add(TCCState *S, Section *sec, addr_t size) | 321 | ST_FUNC void *section_ptr_add(TCCState* S, Section *sec, addr_t size) |
| 322 | { | 322 | { |
| 323 | size_t offset = section_add(S, sec, size, 1); | 323 | size_t offset = section_add(S, sec, size, 1); |
| 324 | return sec->data + offset; | 324 | return sec->data + offset; |
| @@ -326,7 +326,7 @@ ST_FUNC void *section_ptr_add(TCCState *S, Section *sec, addr_t size) · 1 unmodified line | |||
| 326 | 326 | ||
| 327 | #ifndef ELF_OBJ_ONLY | 327 | #ifndef ELF_OBJ_ONLY |
| 328 | /* reserve at least 'size' bytes from section start */ | 328 | /* reserve at least 'size' bytes from section start */ |
| 329 | static void section_reserve(TCCState *S, Section *sec, unsigned long size) | 329 | static void section_reserve(TCCState* S, Section *sec, unsigned long size) |
| 330 | { | 330 | { |
| 331 | if (size > sec->data_allocated) | 331 | if (size > sec->data_allocated) |
| 332 | section_realloc(S, sec, size); | 332 | section_realloc(S, sec, size); |
| @@ -357,7 +357,7 @@ ST_FUNC Section *find_section(TCCState *S, const char *name) · 24 unmodified lines | |||
| 357 | 357 | ||
| 358 | /* ------------------------------------------------------------------------- */ | 358 | /* ------------------------------------------------------------------------- */ |
| 359 | 359 | ||
| 360 | ST_FUNC int put_elf_str(TCCState *S, Section *s, const char *sym) | 360 | ST_FUNC int put_elf_str(TCCState* S, Section *s, const char *sym) |
| 361 | { | 361 | { |
| 362 | int offset, len; | 362 | int offset, len; |
| 363 | char *ptr; | 363 | char *ptr; |
| @@ -386,7 +386,7 @@ static unsigned long elf_hash(const unsigned char *name) · 22 unmodified lines | |||
| 386 | 386 | ||
| 387 | /* rebuild hash table of section s */ | 387 | /* rebuild hash table of section s */ |
| 388 | /* NOTE: we do factorize the hash table code to go faster */ | 388 | /* NOTE: we do factorize the hash table code to go faster */ |
| 389 | static void rebuild_hash(TCCState *S, Section *s, unsigned int nb_buckets) | 389 | static void rebuild_hash(TCCState* S, Section *s, unsigned int nb_buckets) |
| 390 | { | 390 | { |
| 391 | ElfW(Sym) *sym; | 391 | ElfW(Sym) *sym; |
| 392 | int *ptr, *hash, nb_syms, sym_index, h; | 392 | int *ptr, *hash, nb_syms, sym_index, h; |
| @@ -422,7 +422,7 @@ static void rebuild_hash(TCCState *S, Section *s, unsigned int nb_buckets) · 29 unmodified lines | |||
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | /* return the symbol number */ | 424 | /* return the symbol number */ |
| 425 | ST_FUNC int put_elf_sym(TCCState *S, Section *s, addr_t value, unsigned long size, | 425 | ST_FUNC int put_elf_sym(TCCState* S, Section *s, addr_t value, unsigned long size, |
| 426 | int info, int other, int shndx, const char *name) | 426 | int info, int other, int shndx, const char *name) |
| 427 | { | 427 | { |
| 428 | int name_offset, sym_index; | 428 | int name_offset, sym_index; |
| @@ -2082,7 +2082,7 @@ static int layout_sections(TCCState *S, ElfW(Phdr) *phdr, · 1653 unmodified lines | |||
| 2082 | } | 2082 | } |
| 2083 | 2083 | ||
| 2084 | /* put dynamic tag */ | 2084 | /* put dynamic tag */ |
| 2085 | static void put_dt(TCCState *S, Section *dynamic, int dt, addr_t val) | 2085 | static void put_dt(TCCState* S, Section *dynamic, int dt, addr_t val) |
| 2086 | { | 2086 | { |
| 2087 | ElfW(Dyn) *dyn; | 2087 | ElfW(Dyn) *dyn; |
| 2088 | dyn = section_ptr_add(S, dynamic, sizeof(ElfW(Dyn))); | 2088 | dyn = section_ptr_add(S, dynamic, sizeof(ElfW(Dyn))); |
| @@ -2827,7 +2827,7 @@ ST_FUNC ssize_t full_read(int fd, void *buf, size_t count) { · 738 unmodified lines | |||
| 2827 | } | 2827 | } |
| 2828 | } | 2828 | } |
| 2829 | 2829 | ||
| 2830 | ST_FUNC void *load_data(TCCState *S, int fd, unsigned long file_offset, unsigned long size) | 2830 | ST_FUNC void *load_data(TCCState* S, int fd, unsigned long file_offset, unsigned long size) |
| 2831 | { | 2831 | { |
| 2832 | void *data; | 2832 | void *data; |
| 2833 | 2833 | ||
| @@ -33,22 +33,22 @@ · 32 unmodified lines | |||
| 33 | #define vstack (S->tccgen__vstack + 1) | 33 | #define vstack (S->tccgen__vstack + 1) |
| 34 | 34 | ||
| 35 | #define unevalmask 0xffff /* unevaluated subexpression */ | 35 | #define unevalmask 0xffff /* unevaluated subexpression */ |
| 36 | #define NODATA_WANTED (S->nocode_wanted > 0) /* no static data output wanted either */ | 36 | #define NODATA_WANTED (S->tccgen_nocode_wanted > 0) /* no static data output wanted either */ |
| 37 | #define STATIC_DATA_WANTED (S->nocode_wanted & 0xC0000000) /* only static data output */ | 37 | #define STATIC_DATA_WANTED (S->tccgen_nocode_wanted & 0xC0000000) /* only static data output */ |
| 38 | 38 | ||
| 39 | /* Automagical code suppression ----> */ | 39 | /* Automagical code suppression ----> */ |
| 40 | #define CODE_OFF() (S->nocode_wanted |= 0x20000000) | 40 | #define CODE_OFF() (S->tccgen_nocode_wanted |= 0x20000000) |
| 41 | #define CODE_ON() (S->nocode_wanted &= ~0x20000000) | 41 | #define CODE_ON() (S->tccgen_nocode_wanted &= ~0x20000000) |
| 42 | 42 | ||
| 43 | static void tcc_tcov_block_begin(TCCState *S); | 43 | static void tcc_tcov_block_begin(TCCState* S); |
| 44 | 44 | ||
| 45 | /* Clear 'nocode_wanted' at label if it was used */ | 45 | /* Clear 'nocode_wanted' at label if it was used */ |
| 46 | ST_FUNC void gsym(TCCState *S, int t) { if (t) { gsym_addr(S, t, S->ind); CODE_ON(); }} | 46 | ST_FUNC void gsym(TCCState* S, int t) { if (t) { gsym_addr(S, t, S->tccgen_ind); CODE_ON(); }} |
| 47 | static int gind(TCCState *S) { int t = S->ind; CODE_ON(); if (S->tccgen_debug_modes) tcc_tcov_block_begin(S); return t; } | 47 | static int gind(TCCState* S) { int t = S->tccgen_ind; CODE_ON(); if (S->tccgen_debug_modes) tcc_tcov_block_begin(S); return t; } |
| 48 | 48 | ||
| 49 | /* Set 'nocode_wanted' after unconditional jumps */ | 49 | /* Set 'nocode_wanted' after unconditional jumps */ |
| 50 | static void gjmp_addr_acs(TCCState *S, int t) { gjmp_addr(S, t); CODE_OFF(); } | 50 | static void gjmp_addr_acs(TCCState* S, int t) { gjmp_addr(S, t); CODE_OFF(); } |
| 51 | static int gjmp_acs(TCCState *S, int t) { t = gjmp(S, t); CODE_OFF(); return t; } | 51 | static int gjmp_acs(TCCState* S, int t) { t = gjmp(S, t); CODE_OFF(); return t; } |
| 52 | 52 | ||
| 53 | /* These are #undef'd at the end of this file */ | 53 | /* These are #undef'd at the end of this file */ |
| 54 | #define gjmp_addr gjmp_addr_acs | 54 | #define gjmp_addr gjmp_addr_acs |
| @@ -74,7 +74,7 @@ typedef struct { · 19 unmodified lines | |||
| 74 | 74 | ||
| 75 | #if 1 | 75 | #if 1 |
| 76 | #define precedence_parser | 76 | #define precedence_parser |
| 77 | static void init_prec(TCCState *S); | 77 | static void init_prec(TCCState* S); |
| 78 | #endif | 78 | #endif |
| 79 | 79 | ||
| 80 | /********************************************************/ | 80 | /********************************************************/ |
| @@ -129,33 +129,33 @@ static const struct { · 48 unmodified lines | |||
| 129 | }; | 129 | }; |
| 130 | 130 | ||
| 131 | /********************************************************/ | 131 | /********************************************************/ |
| 132 | static void gen_cast(TCCState *S, CType *type); | 132 | static void gen_cast(TCCState* S, CType *type); |
| 133 | static void gen_cast_s(TCCState *S, int t); | 133 | static void gen_cast_s(TCCState* S, int t); |
| 134 | static inline CType *pointed_type(CType *type); | 134 | static inline CType *pointed_type(CType *type); |
| 135 | static int is_compatible_types(CType *type1, CType *type2); | 135 | static int is_compatible_types(CType *type1, CType *type2); |
| 136 | static int parse_btype(TCCState *S, CType *type, AttributeDef *ad); | 136 | static int parse_btype(TCCState* S, CType *type, AttributeDef *ad); |
| 137 | static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int td); | 137 | static CType *type_decl(TCCState* S, CType *type, AttributeDef *ad, int *v, int td); |
| 138 | static void parse_expr_type(TCCState *S, CType *type); | 138 | static void parse_expr_type(TCCState* S, CType *type); |
| 139 | static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c); | 139 | static void init_putv(TCCState* S, init_params *p, CType *type, unsigned long c); |
| 140 | static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned long c, int flags); | 140 | static void decl_initializer(TCCState* S, init_params *p, CType *type, unsigned long c, int flags); |
| 141 | static void block(TCCState *S, int is_expr); | 141 | static void block(TCCState* S, int is_expr); |
| 142 | static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, int r, int has_init, int v, int scope); | 142 | static void decl_initializer_alloc(TCCState* S, CType *type, AttributeDef *ad, int r, int has_init, int v, int scope); |
| 143 | static void decl(TCCState *S, int l); | 143 | static void decl(TCCState* S, int l); |
| 144 | static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *); | 144 | static int decl0(TCCState* S, int l, int is_for_loop_init, Sym *); |
| 145 | static void expr_eq(TCCState *S); | 145 | static void expr_eq(TCCState* S); |
| 146 | static void vla_runtime_type_size(TCCState *S, CType *type, int *a); | 146 | static void vla_runtime_type_size(TCCState* S, CType *type, int *a); |
| 147 | static int is_compatible_unqualified_types(CType *type1, CType *type2); | 147 | static int is_compatible_unqualified_types(CType *type1, CType *type2); |
| 148 | static inline int64_t expr_const64(TCCState *S); | 148 | static inline int64_t expr_const64(TCCState* S); |
| 149 | static void vpush64(TCCState *S, int ty, unsigned long long v); | 149 | static void vpush64(TCCState* S, int ty, unsigned long long v); |
| 150 | static void vpush(TCCState *S, CType *type); | 150 | static void vpush(TCCState* S, CType *type); |
| 151 | static int gvtst(TCCState *S, int inv, int t); | 151 | static int gvtst(TCCState* S, int inv, int t); |
| 152 | static void gen_inline_functions(TCCState *S); | 152 | static void gen_inline_functions(TCCState *S); |
| 153 | static void free_inline_functions(TCCState *S); | 153 | static void free_inline_functions(TCCState *S); |
| 154 | static void skip_or_save_block(TCCState *S, TokenString **str); | 154 | static void skip_or_save_block(TCCState* S, TokenString **str); |
| 155 | static void gv_dup(TCCState *S); | 155 | static void gv_dup(TCCState* S); |
| 156 | static int get_temp_local_var(TCCState *S, int size,int align); | 156 | static int get_temp_local_var(TCCState* S, int size,int align); |
| 157 | static void clear_temp_local_var_list(); | 157 | static void clear_temp_local_var_list(); |
| 158 | static void cast_error(TCCState *S, CType *st, CType *dt); | 158 | static void cast_error(TCCState* S, CType *st, CType *dt); |
| 159 | 159 | ||
| 160 | ST_INLN int is_float(int t) | 160 | ST_INLN int is_float(int t) |
| 161 | { | 161 | { |
| @@ -284,17 +284,17 @@ ST_FUNC int ieee_finite(double d) · 122 unmodified lines | |||
| 284 | # define TCC_IS_NATIVE_387 | 284 | # define TCC_IS_NATIVE_387 |
| 285 | #endif | 285 | #endif |
| 286 | 286 | ||
| 287 | ST_FUNC void test_lvalue(TCCState *S) | 287 | ST_FUNC void test_lvalue(TCCState* S) |
| 288 | { | 288 | { |
| 289 | if (!(S->vtop->r & VT_LVAL)) | 289 | if (!(S->tccgen_vtop->r & VT_LVAL)) |
| 290 | expect(S, "lvalue"); | 290 | expect(S, "lvalue"); |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | ST_FUNC void check_vstack(TCCState *S) | 293 | ST_FUNC void check_vstack(TCCState* S) |
| 294 | { | 294 | { |
| 295 | if (S->vtop != vstack - 1) | 295 | if (S->tccgen_vtop != vstack - 1) |
| 296 | tcc_error(S, "internal compiler error: vstack leak (%d)", | 296 | tcc_error(S, "internal compiler error: vstack leak (%d)", |
| 297 | (int)(S->vtop - vstack + 1)); | 297 | (int)(S->tccgen_vtop - vstack + 1)); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | /* ------------------------------------------------------------------------- */ | 300 | /* ------------------------------------------------------------------------- */ |
| @@ -305,7 +305,7 @@ void pv (const char *lbl, int a, int b) · 4 unmodified lines | |||
| 305 | { | 305 | { |
| 306 | int i; | 306 | int i; |
| 307 | for (i = a; i < a + b; ++i) { | 307 | for (i = a; i < a + b; ++i) { |
| 308 | SValue *p = &S->vtop[-i]; | 308 | SValue *p = &S->tccgen_vtop[-i]; |
| 309 | printf("%s vtop[-%d] : type.t:%04x r:%04x r2:%04x c.i:%d\n", | 309 | printf("%s vtop[-%d] : type.t:%04x r:%04x r2:%04x c.i:%d\n", |
| 310 | lbl, i, p->type.t, p->r, p->r2, (int)p->c.i); | 310 | lbl, i, p->type.t, p->r, p->r2, (int)p->c.i); |
| 311 | } | 311 | } |
| @@ -371,7 +371,7 @@ static BufferedFile* put_new_file(TCCState *S) · 59 unmodified lines | |||
| 371 | if (f->filename[0] == ':') | 371 | if (f->filename[0] == ':') |
| 372 | f = f->prev; | 372 | f = f->prev; |
| 373 | if (f && S->tccgen_new_file) { | 373 | if (f && S->tccgen_new_file) { |
| 374 | put_stabs_r(S, f->filename, N_SOL, 0, 0, S->ind, text_section, S->tccgen_section_sym); | 374 | put_stabs_r(S, f->filename, N_SOL, 0, 0, S->tccgen_ind, text_section, S->tccgen_section_sym); |
| 375 | S->tccgen_new_file = S->tccgen_last_line_num = 0; | 375 | S->tccgen_new_file = S->tccgen_last_line_num = 0; |
| 376 | } | 376 | } |
| 377 | return f; | 377 | return f; |
| @@ -414,10 +414,10 @@ static void tcc_debug_line(TCCState *S) · 36 unmodified lines | |||
| 414 | || S->tccgen_last_line_num == f->line_num) | 414 | || S->tccgen_last_line_num == f->line_num) |
| 415 | return; | 415 | return; |
| 416 | if (S->tccgen_func_ind != -1) { | 416 | if (S->tccgen_func_ind != -1) { |
| 417 | put_stabn(S, N_SLINE, 0, f->line_num, S->ind - S->tccgen_func_ind); | 417 | put_stabn(S, N_SLINE, 0, f->line_num, S->tccgen_ind - S->tccgen_func_ind); |
| 418 | } else { | 418 | } else { |
| 419 | /* from tcc_assemble */ | 419 | /* from tcc_assemble */ |
| 420 | put_stabs_r(S, NULL, N_SLINE, 0, f->line_num, S->ind, text_section, S->tccgen_section_sym); | 420 | put_stabs_r(S, NULL, N_SLINE, 0, f->line_num, S->tccgen_ind, text_section, S->tccgen_section_sym); |
| 421 | } | 421 | } |
| 422 | S->tccgen_last_line_num = f->line_num; | 422 | S->tccgen_last_line_num = f->line_num; |
| 423 | } | 423 | } |
| @@ -427,12 +427,12 @@ static void tcc_debug_stabs (TCCState *S, const char *str, int type, unsigned lo · 3 unmodified lines | |||
| 427 | { | 427 | { |
| 428 | struct debug_sym *s; | 428 | struct debug_sym *s; |
| 429 | 429 | ||
| 430 | if (S->debug_info) { | 430 | if (S->tccgen_debug_info) { |
| 431 | S->debug_info->sym = | 431 | S->tccgen_debug_info->sym = |
| 432 | (struct debug_sym *)tcc_realloc (S, S->debug_info->sym, | 432 | (struct debug_sym *)tcc_realloc (S, S->tccgen_debug_info->sym, |
| 433 | sizeof(struct debug_sym) * | 433 | sizeof(struct debug_sym) * |
| 434 | (S->debug_info->n_sym + 1)); | 434 | (S->tccgen_debug_info->n_sym + 1)); |
| 435 | s = S->debug_info->sym + S->debug_info->n_sym++; | 435 | s = S->tccgen_debug_info->sym + S->tccgen_debug_info->n_sym++; |
| 436 | s->type = type; | 436 | s->type = type; |
| 437 | s->value = value; | 437 | s->value = value; |
| 438 | s->str = tcc_strdup(S, str); | 438 | s->str = tcc_strdup(S, str); |
| @@ -454,25 +454,25 @@ static void tcc_debug_stabn(TCCState *S, int type, int value) · 15 unmodified lines | |||
| 454 | (debug_info_t *) tcc_mallocz(S, sizeof (*info)); | 454 | (debug_info_t *) tcc_mallocz(S, sizeof (*info)); |
| 455 | 455 | ||
| 456 | info->start = value; | 456 | info->start = value; |
| 457 | info->parent = S->debug_info; | 457 | info->parent = S->tccgen_debug_info; |
| 458 | if (S->debug_info) { | 458 | if (S->tccgen_debug_info) { |
| 459 | if (S->debug_info->child) { | 459 | if (S->tccgen_debug_info->child) { |
| 460 | if (S->debug_info->child->last) | 460 | if (S->tccgen_debug_info->child->last) |
| 461 | S->debug_info->child->last->next = info; | 461 | S->tccgen_debug_info->child->last->next = info; |
| 462 | else | 462 | else |
| 463 | S->debug_info->child->next = info; | 463 | S->tccgen_debug_info->child->next = info; |
| 464 | S->debug_info->child->last = info; | 464 | S->tccgen_debug_info->child->last = info; |
| 465 | } | 465 | } |
| 466 | else | 466 | else |
| 467 | S->debug_info->child = info; | 467 | S->tccgen_debug_info->child = info; |
| 468 | } | 468 | } |
| 469 | else | 469 | else |
| 470 | S->debug_info_root = info; | 470 | S->tccgen_debug_info_root = info; |
| 471 | S->debug_info = info; | 471 | S->tccgen_debug_info = info; |
| 472 | } | 472 | } |
| 473 | else { | 473 | else { |
| 474 | S->debug_info->end = value; | 474 | S->tccgen_debug_info->end = value; |
| 475 | S->debug_info = S->debug_info->parent; | 475 | S->tccgen_debug_info = S->tccgen_debug_info->parent; |
| 476 | } | 476 | } |
| 477 | } | 477 | } |
| 478 | 478 | ||
| @@ -644,9 +644,9 @@ static void tcc_debug_funcstart(TCCState *S, Sym *sym) · 165 unmodified lines | |||
| 644 | BufferedFile *f; | 644 | BufferedFile *f; |
| 645 | if (!S->do_debug) | 645 | if (!S->do_debug) |
| 646 | return; | 646 | return; |
| 647 | S->debug_info_root = NULL; | 647 | S->tccgen_debug_info_root = NULL; |
| 648 | S->debug_info = NULL; | 648 | S->tccgen_debug_info = NULL; |
| 649 | tcc_debug_stabn(S, N_LBRAC, S->ind - S->tccgen_func_ind); | 649 | tcc_debug_stabn(S, N_LBRAC, S->tccgen_ind - S->tccgen_func_ind); |
| 650 | if (!(f = put_new_file(S))) | 650 | if (!(f = put_new_file(S))) |
| 651 | return; | 651 | return; |
| 652 | cstr_new (S, &debug_str); | 652 | cstr_new (S, &debug_str); |
| @@ -664,7 +664,7 @@ static void tcc_debug_funcend(TCCState *S, int size) · 11 unmodified lines | |||
| 664 | if (!S->do_debug) | 664 | if (!S->do_debug) |
| 665 | return; | 665 | return; |
| 666 | tcc_debug_stabn(S, N_RBRAC, size); | 666 | tcc_debug_stabn(S, N_RBRAC, size); |
| 667 | tcc_debug_finish (S, S->debug_info_root); | 667 | tcc_debug_finish (S, S->tccgen_debug_info_root); |
| 668 | } | 668 | } |
| 669 | 669 | ||
| 670 | 670 | ||
| @@ -682,7 +682,7 @@ static void tcc_debug_extern_sym(TCCState *S, Sym *sym, int sh_num, int sym_bind · 11 unmodified lines | |||
| 682 | cstr_new (S, &str); | 682 | cstr_new (S, &str); |
| 683 | cstr_printf (S, &str, "%s:%c", | 683 | cstr_printf (S, &str, "%s:%c", |
| 684 | get_tok_str(S, sym->v, NULL), | 684 | get_tok_str(S, sym->v, NULL), |
| 685 | sym_bind == STB_GLOBAL ? 'G' : S->local_scope ? 'V' : 'S' | 685 | sym_bind == STB_GLOBAL ? 'G' : S->tccgen_local_scope ? 'V' : 'S' |
| 686 | ); | 686 | ); |
| 687 | tcc_get_debug_info(S, sym, &str); | 687 | tcc_get_debug_info(S, sym, &str); |
| 688 | if (sym_bind == STB_GLOBAL) | 688 | if (sym_bind == STB_GLOBAL) |
| @@ -712,16 +712,16 @@ static void tcc_debug_typedef(TCCState *S, Sym *sym) · 23 unmodified lines | |||
| 712 | /* ------------------------------------------------------------------------- */ | 712 | /* ------------------------------------------------------------------------- */ |
| 713 | /* for section layout see lib/tcov.c */ | 713 | /* for section layout see lib/tcov.c */ |
| 714 | 714 | ||
| 715 | static void tcc_tcov_block_end(TCCState *S, int line); | 715 | static void tcc_tcov_block_end(TCCState* S, int line); |
| 716 | 716 | ||
| 717 | static void tcc_tcov_block_begin(TCCState *S) | 717 | static void tcc_tcov_block_begin(TCCState* S) |
| 718 | { | 718 | { |
| 719 | SValue sv; | 719 | SValue sv; |
| 720 | void *ptr; | 720 | void *ptr; |
| 721 | unsigned long last_offset = S->tccgen_tcov_data.offset; | 721 | unsigned long last_offset = S->tccgen_tcov_data.offset; |
| 722 | 722 | ||
| 723 | tcc_tcov_block_end (S, 0); | 723 | tcc_tcov_block_end (S, 0); |
| 724 | if (S->test_coverage == 0 || S->nocode_wanted) | 724 | if (S->test_coverage == 0 || S->tccgen_nocode_wanted) |
| 725 | return; | 725 | return; |
| 726 | 726 | ||
| 727 | if (S->tccgen_tcov_data.last_file_name == 0 || | 727 | if (S->tccgen_tcov_data.last_file_name == 0 || |
| @@ -767,7 +767,7 @@ static void tcc_tcov_block_begin(TCCState *S) · 39 unmodified lines | |||
| 767 | ptr = section_ptr_add(S, tcov_section, 8); | 767 | ptr = section_ptr_add(S, tcov_section, 8); |
| 768 | write64le (ptr, S->tccpp_file->line_num); | 768 | write64le (ptr, S->tccpp_file->line_num); |
| 769 | } | 769 | } |
| 770 | if (S->ind == S->tccgen_tcov_data.ind && S->tccgen_tcov_data.line == S->tccpp_file->line_num) | 770 | if (S->tccgen_ind == S->tccgen_tcov_data.ind && S->tccgen_tcov_data.line == S->tccpp_file->line_num) |
| 771 | S->tccgen_tcov_data.offset = last_offset; | 771 | S->tccgen_tcov_data.offset = last_offset; |
| 772 | else { | 772 | else { |
| 773 | Sym label = {0}; | 773 | Sym label = {0}; |
| @@ -793,11 +793,11 @@ static void tcc_tcov_block_begin(TCCState *S) · 19 unmodified lines | |||
| 793 | vpop(S); | 793 | vpop(S); |
| 794 | #endif | 794 | #endif |
| 795 | S->tccgen_tcov_data.offset = (unsigned char *)ptr - tcov_section->data; | 795 | S->tccgen_tcov_data.offset = (unsigned char *)ptr - tcov_section->data; |
| 796 | S->tccgen_tcov_data.ind = S->ind; | 796 | S->tccgen_tcov_data.ind = S->tccgen_ind; |
| 797 | } | 797 | } |
| 798 | } | 798 | } |
| 799 | 799 | ||
| 800 | static void tcc_tcov_block_end(TCCState *S, int line) | 800 | static void tcc_tcov_block_end(TCCState* S, int line) |
| 801 | { | 801 | { |
| 802 | if (S->test_coverage == 0) | 802 | if (S->test_coverage == 0) |
| 803 | return; | 803 | return; |
| @@ -810,7 +810,7 @@ static void tcc_tcov_block_end(TCCState *S, int line) · 6 unmodified lines | |||
| 810 | } | 810 | } |
| 811 | } | 811 | } |
| 812 | 812 | ||
| 813 | static void tcc_tcov_check_line(TCCState *S, int start) | 813 | static void tcc_tcov_check_line(TCCState* S, int start) |
| 814 | { | 814 | { |
| 815 | if (S->test_coverage == 0) | 815 | if (S->test_coverage == 0) |
| 816 | return; | 816 | return; |
| @@ -825,7 +825,7 @@ static void tcc_tcov_check_line(TCCState *S, int start) · 8 unmodified lines | |||
| 825 | } | 825 | } |
| 826 | } | 826 | } |
| 827 | 827 | ||
| 828 | static void tcc_tcov_start(TCCState *S) | 828 | static void tcc_tcov_start(TCCState* S) |
| 829 | { | 829 | { |
| 830 | if (S->test_coverage == 0) | 830 | if (S->test_coverage == 0) |
| 831 | return; | 831 | return; |
| @@ -837,7 +837,7 @@ static void tcc_tcov_start(TCCState *S) · 5 unmodified lines | |||
| 837 | } | 837 | } |
| 838 | } | 838 | } |
| 839 | 839 | ||
| 840 | static void tcc_tcov_end(TCCState *S) | 840 | static void tcc_tcov_end(TCCState* S) |
| 841 | { | 841 | { |
| 842 | if (S->test_coverage == 0) | 842 | if (S->test_coverage == 0) |
| 843 | return; | 843 | return; |
| @@ -851,8 +851,8 @@ static void tcc_tcov_end(TCCState *S) · 7 unmodified lines | |||
| 851 | /* initialize vstack and types. This must be done also for tcc -E */ | 851 | /* initialize vstack and types. This must be done also for tcc -E */ |
| 852 | ST_FUNC void tccgen_init(TCCState *S) | 852 | ST_FUNC void tccgen_init(TCCState *S) |
| 853 | { | 853 | { |
| 854 | S->vtop = vstack - 1; | 854 | S->tccgen_vtop = vstack - 1; |
| 855 | memset(S->vtop, 0, sizeof *S->vtop); | 855 | memset(S->tccgen_vtop, 0, sizeof *S->tccgen_vtop); |
| 856 | 856 | ||
| 857 | /* define some often used types */ | 857 | /* define some often used types */ |
| 858 | S->tccgen_int_type.t = VT_INT; | 858 | S->tccgen_int_type.t = VT_INT; |
| @@ -860,8 +860,8 @@ ST_FUNC void tccgen_init(TCCState *S) · 1 unmodified line | |||
| 860 | S->tccgen_char_type.t = VT_BYTE; | 860 | S->tccgen_char_type.t = VT_BYTE; |
| 861 | if (S->char_is_unsigned) | 861 | if (S->char_is_unsigned) |
| 862 | S->tccgen_char_type.t |= VT_UNSIGNED; | 862 | S->tccgen_char_type.t |= VT_UNSIGNED; |
| 863 | S->char_pointer_type = S->tccgen_char_type; | 863 | S->tccgen_char_pointer_type = S->tccgen_char_type; |
| 864 | mk_pointer(S, &S->char_pointer_type); | 864 | mk_pointer(S, &S->tccgen_char_pointer_type); |
| 865 | 865 | ||
| 866 | S->tccgen_func_old_type.t = VT_FUNC; | 866 | S->tccgen_func_old_type.t = VT_FUNC; |
| 867 | S->tccgen_func_old_type.ref = sym_push(S, SYM_FIELD, &S->tccgen_int_type, 0, 0); | 867 | S->tccgen_func_old_type.ref = sym_push(S, SYM_FIELD, &S->tccgen_int_type, 0, 0); |
| @@ -880,8 +880,8 @@ ST_FUNC int tccgen_compile(TCCState *S) · 12 unmodified lines | |||
| 880 | S->tccgen_anon_sym = SYM_FIRST_ANOM; | 880 | S->tccgen_anon_sym = SYM_FIRST_ANOM; |
| 881 | S->tccgen_section_sym = 0; | 881 | S->tccgen_section_sym = 0; |
| 882 | S->tccgen_const_wanted = 0; | 882 | S->tccgen_const_wanted = 0; |
| 883 | S->nocode_wanted = 0x80000000; | 883 | S->tccgen_nocode_wanted = 0x80000000; |
| 884 | S->local_scope = 0; | 884 | S->tccgen_local_scope = 0; |
| 885 | S->tccgen_debug_modes = S->do_debug | S->test_coverage << 1; | 885 | S->tccgen_debug_modes = S->do_debug | S->test_coverage << 1; |
| 886 | 886 | ||
| 887 | tcc_debug_start(S); | 887 | tcc_debug_start(S); |
| @@ -908,7 +908,7 @@ ST_FUNC void tccgen_finish(TCCState *S) · 20 unmodified lines | |||
| 908 | cstr_free(S, &S->tccgen_initstr); | 908 | cstr_free(S, &S->tccgen_initstr); |
| 909 | free_inline_functions(S); | 909 | free_inline_functions(S); |
| 910 | sym_pop(S, &S->tccgen_global_stack, NULL, 0); | 910 | sym_pop(S, &S->tccgen_global_stack, NULL, 0); |
| 911 | sym_pop(S, &S->local_stack, NULL, 0); | 911 | sym_pop(S, &S->tccgen_local_stack, NULL, 0); |
| 912 | /* free preprocessor macros */ | 912 | /* free preprocessor macros */ |
| 913 | free_defines(S, NULL); | 913 | free_defines(S, NULL); |
| 914 | /* free sym_pools */ | 914 | /* free sym_pools */ |
| @@ -917,7 +917,7 @@ ST_FUNC void tccgen_finish(TCCState *S) · 2 unmodified lines | |||
| 917 | } | 917 | } |
| 918 | 918 | ||
| 919 | /* ------------------------------------------------------------------------- */ | 919 | /* ------------------------------------------------------------------------- */ |
| 920 | ST_FUNC ElfSym *elfsym(TCCState *S, Sym *s) | 920 | ST_FUNC ElfSym *elfsym(TCCState* S, Sym *s) |
| 921 | { | 921 | { |
| 922 | if (!s || !s->c) | 922 | if (!s || !s->c) |
| 923 | return NULL; | 923 | return NULL; |
| @@ -925,7 +925,7 @@ ST_FUNC ElfSym *elfsym(TCCState *S, Sym *s) · 1 unmodified line | |||
| 925 | } | 925 | } |
| 926 | 926 | ||
| 927 | /* apply storage attributes to Elf symbol */ | 927 | /* apply storage attributes to Elf symbol */ |
| 928 | ST_FUNC void update_storage(TCCState *S, Sym *sym) | 928 | ST_FUNC void update_storage(TCCState* S, Sym *sym) |
| 929 | { | 929 | { |
| 930 | ElfSym *esym; | 930 | ElfSym *esym; |
| 931 | int sym_bind, old_sym_bind; | 931 | int sym_bind, old_sym_bind; |
| @@ -971,7 +971,7 @@ ST_FUNC void update_storage(TCCState *S, Sym *sym) · 39 unmodified lines | |||
| 971 | /* update sym->c so that it points to an external symbol in section | 971 | /* update sym->c so that it points to an external symbol in section |
| 972 | 'section' with value 'value' */ | 972 | 'section' with value 'value' */ |
| 973 | 973 | ||
| 974 | ST_FUNC void put_extern_sym2(TCCState *S, Sym *sym, int sh_num, | 974 | ST_FUNC void put_extern_sym2(TCCState* S, Sym *sym, int sh_num, |
| 975 | addr_t value, unsigned long size, | 975 | addr_t value, unsigned long size, |
| 976 | int can_add_underscore) | 976 | int can_add_underscore) |
| 977 | { | 977 | { |
| @@ -1039,7 +1039,7 @@ ST_FUNC void put_extern_sym2(TCCState *S, Sym *sym, int sh_num, · 61 unmodified lines | |||
| 1039 | update_storage(S, sym); | 1039 | update_storage(S, sym); |
| 1040 | } | 1040 | } |
| 1041 | 1041 | ||
| 1042 | ST_FUNC void put_extern_sym(TCCState *S, Sym *sym, Section *section, | 1042 | ST_FUNC void put_extern_sym(TCCState* S, Sym *sym, Section *section, |
| 1043 | addr_t value, unsigned long size) | 1043 | addr_t value, unsigned long size) |
| 1044 | { | 1044 | { |
| 1045 | int sh_num = section ? section->sh_num : SHN_UNDEF; | 1045 | int sh_num = section ? section->sh_num : SHN_UNDEF; |
| @@ -1047,12 +1047,12 @@ ST_FUNC void put_extern_sym(TCCState *S, Sym *sym, Section *section, · 1 unmodified line | |||
| 1047 | } | 1047 | } |
| 1048 | 1048 | ||
| 1049 | /* add a new relocation entry to symbol 'sym' in section 's' */ | 1049 | /* add a new relocation entry to symbol 'sym' in section 's' */ |
| 1050 | ST_FUNC void greloca(TCCState *S, Section *s, Sym *sym, unsigned long offset, int type, | 1050 | ST_FUNC void greloca(TCCState* S, Section *s, Sym *sym, unsigned long offset, int type, |
| 1051 | addr_t addend) | 1051 | addr_t addend) |
| 1052 | { | 1052 | { |
| 1053 | int c = 0; | 1053 | int c = 0; |
| 1054 | 1054 | ||
| 1055 | if (S->nocode_wanted && s == cur_text_section) | 1055 | if (S->tccgen_nocode_wanted && s == cur_text_section) |
| 1056 | return; | 1056 | return; |
| 1057 | 1057 | ||
| 1058 | if (sym) { | 1058 | if (sym) { |
| @@ -1066,7 +1066,7 @@ ST_FUNC void greloca(TCCState *S, Section *s, Sym *sym, unsigned long offset, in · 7 unmodified lines | |||
| 1066 | } | 1066 | } |
| 1067 | 1067 | ||
| 1068 | #if PTR_SIZE == 4 | 1068 | #if PTR_SIZE == 4 |
| 1069 | ST_FUNC void greloc(TCCState *S, Section *s, Sym *sym, unsigned long offset, int type) | 1069 | ST_FUNC void greloc(TCCState* S, Section *s, Sym *sym, unsigned long offset, int type) |
| 1070 | { | 1070 | { |
| 1071 | greloca(S, s, sym, offset, type, 0); | 1071 | greloca(S, s, sym, offset, type, 0); |
| 1072 | } | 1072 | } |
| @@ -1074,7 +1074,7 @@ ST_FUNC void greloc(TCCState *S, Section *s, Sym *sym, unsigned long offset, int · 1 unmodified line | |||
| 1074 | 1074 | ||
| 1075 | /* ------------------------------------------------------------------------- */ | 1075 | /* ------------------------------------------------------------------------- */ |
| 1076 | /* symbol allocator */ | 1076 | /* symbol allocator */ |
| 1077 | static Sym *__sym_malloc(TCCState *S) | 1077 | static Sym *__sym_malloc(TCCState* S) |
| 1078 | { | 1078 | { |
| 1079 | Sym *sym_pool, *sym, *last_sym; | 1079 | Sym *sym_pool, *sym, *last_sym; |
| 1080 | int i; | 1080 | int i; |
| @@ -1093,7 +1093,7 @@ static Sym *__sym_malloc(TCCState *S) · 12 unmodified lines | |||
| 1093 | return last_sym; | 1093 | return last_sym; |
| 1094 | } | 1094 | } |
| 1095 | 1095 | ||
| 1096 | static inline Sym *sym_malloc(TCCState *S) | 1096 | static inline Sym *sym_malloc(TCCState* S) |
| 1097 | { | 1097 | { |
| 1098 | Sym *sym; | 1098 | Sym *sym; |
| 1099 | #ifndef SYM_DEBUG | 1099 | #ifndef SYM_DEBUG |
| @@ -1108,7 +1108,7 @@ static inline Sym *sym_malloc(TCCState *S) · 8 unmodified lines | |||
| 1108 | #endif | 1108 | #endif |
| 1109 | } | 1109 | } |
| 1110 | 1110 | ||
| 1111 | ST_INLN void sym_free(TCCState *S, Sym *sym) | 1111 | ST_INLN void sym_free(TCCState* S, Sym *sym) |
| 1112 | { | 1112 | { |
| 1113 | #ifndef SYM_DEBUG | 1113 | #ifndef SYM_DEBUG |
| 1114 | sym->next = S->tccgen_sym_free_first; | 1114 | sym->next = S->tccgen_sym_free_first; |
| @@ -1119,7 +1119,7 @@ ST_INLN void sym_free(TCCState *S, Sym *sym) · 4 unmodified lines | |||
| 1119 | } | 1119 | } |
| 1120 | 1120 | ||
| 1121 | /* push, without hashing */ | 1121 | /* push, without hashing */ |
| 1122 | ST_FUNC Sym *sym_push2(TCCState *S, Sym **ps, int v, int t, int c) | 1122 | ST_FUNC Sym *sym_push2(TCCState* S, Sym **ps, int v, int t, int c) |
| 1123 | { | 1123 | { |
| 1124 | Sym *s; | 1124 | Sym *s; |
| 1125 | 1125 | ||
| @@ -1149,19 +1149,19 @@ ST_FUNC Sym *sym_find2(Sym *s, int v) · 23 unmodified lines | |||
| 1149 | } | 1149 | } |
| 1150 | 1150 | ||
| 1151 | /* structure lookup */ | 1151 | /* structure lookup */ |
| 1152 | ST_INLN Sym *struct_find(TCCState *S, int v) | 1152 | ST_INLN Sym *struct_find(TCCState* S, int v) |
| 1153 | { | 1153 | { |
| 1154 | v -= TOK_IDENT; | 1154 | v -= TOK_IDENT; |
| 1155 | if ((unsigned)v >= (unsigned)(S->tok_ident - TOK_IDENT)) | 1155 | if ((unsigned)v >= (unsigned)(S->tccpp_tok_ident - TOK_IDENT)) |
| 1156 | return NULL; | 1156 | return NULL; |
| 1157 | return S->tccpp_table_ident[v]->sym_struct; | 1157 | return S->tccpp_table_ident[v]->sym_struct; |
| 1158 | } | 1158 | } |
| 1159 | 1159 | ||
| 1160 | /* find an identifier */ | 1160 | /* find an identifier */ |
| 1161 | ST_INLN Sym *sym_find(TCCState *S, int v) | 1161 | ST_INLN Sym *sym_find(TCCState* S, int v) |
| 1162 | { | 1162 | { |
| 1163 | v -= TOK_IDENT; | 1163 | v -= TOK_IDENT; |
| 1164 | if ((unsigned)v >= (unsigned)(S->tok_ident - TOK_IDENT)) | 1164 | if ((unsigned)v >= (unsigned)(S->tccpp_tok_ident - TOK_IDENT)) |
| 1165 | return NULL; | 1165 | return NULL; |
| 1166 | return S->tccpp_table_ident[v]->sym_identifier; | 1166 | return S->tccpp_table_ident[v]->sym_identifier; |
| 1167 | } | 1167 | } |
| @@ -1175,13 +1175,13 @@ static int sym_scope(Sym *s) · 7 unmodified lines | |||
| 1175 | } | 1175 | } |
| 1176 | 1176 | ||
| 1177 | /* push a given symbol on the symbol stack */ | 1177 | /* push a given symbol on the symbol stack */ |
| 1178 | ST_FUNC Sym *sym_push(TCCState *S, int v, CType *type, int r, int c) | 1178 | ST_FUNC Sym *sym_push(TCCState* S, int v, CType *type, int r, int c) |
| 1179 | { | 1179 | { |
| 1180 | Sym *s, **ps; | 1180 | Sym *s, **ps; |
| 1181 | TokenSym *ts; | 1181 | TokenSym *ts; |
| 1182 | 1182 | ||
| 1183 | if (S->local_stack) | 1183 | if (S->tccgen_local_stack) |
| 1184 | ps = &S->local_stack; | 1184 | ps = &S->tccgen_local_stack; |
| 1185 | else | 1185 | else |
| 1186 | ps = &S->tccgen_global_stack; | 1186 | ps = &S->tccgen_global_stack; |
| 1187 | s = sym_push2(S, ps, v, type->t, c); | 1187 | s = sym_push2(S, ps, v, type->t, c); |
| @@ -1198,7 +1198,7 @@ ST_FUNC Sym *sym_push(TCCState *S, int v, CType *type, int r, int c) · 10 unmodified lines | |||
| 1198 | ps = &ts->sym_identifier; | 1198 | ps = &ts->sym_identifier; |
| 1199 | s->prev_tok = *ps; | 1199 | s->prev_tok = *ps; |
| 1200 | *ps = s; | 1200 | *ps = s; |
| 1201 | s->sym_scope = S->local_scope; | 1201 | s->sym_scope = S->tccgen_local_scope; |
| 1202 | if (s->prev_tok && sym_scope(s->prev_tok) == s->sym_scope) | 1202 | if (s->prev_tok && sym_scope(s->prev_tok) == s->sym_scope) |
| 1203 | tcc_error(S, "redeclaration of '%s'", | 1203 | tcc_error(S, "redeclaration of '%s'", |
| 1204 | get_tok_str(S, v & ~SYM_STRUCT, NULL)); | 1204 | get_tok_str(S, v & ~SYM_STRUCT, NULL)); |
| @@ -1207,7 +1207,7 @@ ST_FUNC Sym *sym_push(TCCState *S, int v, CType *type, int r, int c) · 2 unmodified lines | |||
| 1207 | } | 1207 | } |
| 1208 | 1208 | ||
| 1209 | /* push a global identifier */ | 1209 | /* push a global identifier */ |
| 1210 | ST_FUNC Sym *global_identifier_push(TCCState *S, int v, int t, int c) | 1210 | ST_FUNC Sym *global_identifier_push(TCCState* S, int v, int t, int c) |
| 1211 | { | 1211 | { |
| 1212 | Sym *s, **ps; | 1212 | Sym *s, **ps; |
| 1213 | s = sym_push2(S, &S->tccgen_global_stack, v, t, c); | 1213 | s = sym_push2(S, &S->tccgen_global_stack, v, t, c); |
| @@ -1227,7 +1227,7 @@ ST_FUNC Sym *global_identifier_push(TCCState *S, int v, int t, int c) · 13 unmodified lines | |||
| 1227 | 1227 | ||
| 1228 | /* pop symbols until top reaches 'b'. If KEEP is non-zero don't really | 1228 | /* pop symbols until top reaches 'b'. If KEEP is non-zero don't really |
| 1229 | pop them yet from the list, but do remove them from the token array. */ | 1229 | pop them yet from the list, but do remove them from the token array. */ |
| 1230 | ST_FUNC void sym_pop(TCCState *S, Sym **ptop, Sym *b, int keep) | 1230 | ST_FUNC void sym_pop(TCCState* S, Sym **ptop, Sym *b, int keep) |
| 1231 | { | 1231 | { |
| 1232 | Sym *s, *ss, **ps; | 1232 | Sym *s, *ss, **ps; |
| 1233 | TokenSym *ts; | 1233 | TokenSym *ts; |
| @@ -1256,7 +1256,7 @@ ST_FUNC void sym_pop(TCCState *S, Sym **ptop, Sym *b, int keep) · 22 unmodified lines | |||
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | /* ------------------------------------------------------------------------- */ | 1258 | /* ------------------------------------------------------------------------- */ |
| 1259 | static void vcheck_cmp(TCCState *S) | 1259 | static void vcheck_cmp(TCCState* S) |
| 1260 | { | 1260 | { |
| 1261 | /* cannot let cpu flags if other instruction are generated. Also | 1261 | /* cannot let cpu flags if other instruction are generated. Also |
| 1262 | avoid leaving VT_JMP anywhere except on the top of the stack | 1262 | avoid leaving VT_JMP anywhere except on the top of the stack |
| @@ -1270,38 +1270,38 @@ static void vcheck_cmp(TCCState *S) · 7 unmodified lines | |||
| 1270 | again, so that the VT_CMP/VT_JMP value will be in vtop | 1270 | again, so that the VT_CMP/VT_JMP value will be in vtop |
| 1271 | when code is unsuppressed again. */ | 1271 | when code is unsuppressed again. */ |
| 1272 | 1272 | ||
| 1273 | if (S->vtop->r == VT_CMP && !S->nocode_wanted) | 1273 | if (S->tccgen_vtop->r == VT_CMP && !S->tccgen_nocode_wanted) |
| 1274 | gv(S, RC_INT); | 1274 | gv(S, RC_INT); |
| 1275 | } | 1275 | } |
| 1276 | 1276 | ||
| 1277 | static void vsetc(TCCState *S, CType *type, int r, CValue *vc) | 1277 | static void vsetc(TCCState* S, CType *type, int r, CValue *vc) |
| 1278 | { | 1278 | { |
| 1279 | if (S->vtop >= vstack + (VSTACK_SIZE - 1)) | 1279 | if (S->tccgen_vtop >= vstack + (VSTACK_SIZE - 1)) |
| 1280 | tcc_error(S, "memory full (vstack)"); | 1280 | tcc_error(S, "memory full (vstack)"); |
| 1281 | vcheck_cmp(S); | 1281 | vcheck_cmp(S); |
| 1282 | S->vtop++; | 1282 | S->tccgen_vtop++; |
| 1283 | S->vtop->type = *type; | 1283 | S->tccgen_vtop->type = *type; |
| 1284 | S->vtop->r = r; | 1284 | S->tccgen_vtop->r = r; |
| 1285 | S->vtop->r2 = VT_CONST; | 1285 | S->tccgen_vtop->r2 = VT_CONST; |
| 1286 | S->vtop->c = *vc; | 1286 | S->tccgen_vtop->c = *vc; |
| 1287 | S->vtop->sym = NULL; | 1287 | S->tccgen_vtop->sym = NULL; |
| 1288 | } | 1288 | } |
| 1289 | 1289 | ||
| 1290 | ST_FUNC void vswap(TCCState *S) | 1290 | ST_FUNC void vswap(TCCState* S) |
| 1291 | { | 1291 | { |
| 1292 | SValue tmp; | 1292 | SValue tmp; |
| 1293 | 1293 | ||
| 1294 | vcheck_cmp(S); | 1294 | vcheck_cmp(S); |
| 1295 | tmp = S->vtop[0]; | 1295 | tmp = S->tccgen_vtop[0]; |
| 1296 | S->vtop[0] = S->vtop[-1]; | 1296 | S->tccgen_vtop[0] = S->tccgen_vtop[-1]; |
| 1297 | S->vtop[-1] = tmp; | 1297 | S->tccgen_vtop[-1] = tmp; |
| 1298 | } | 1298 | } |
| 1299 | 1299 | ||
| 1300 | /* pop stack value */ | 1300 | /* pop stack value */ |
| 1301 | ST_FUNC void vpop(TCCState *S) | 1301 | ST_FUNC void vpop(TCCState* S) |
| 1302 | { | 1302 | { |
| 1303 | int v; | 1303 | int v; |
| 1304 | v = S->vtop->r & VT_VALMASK; | 1304 | v = S->tccgen_vtop->r & VT_VALMASK; |
| 1305 | #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) | 1305 | #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) |
| 1306 | /* for x86, we need to pop the FP stack */ | 1306 | /* for x86, we need to pop the FP stack */ |
| 1307 | if (v == TREG_ST0) { | 1307 | if (v == TREG_ST0) { |
| @@ -1310,20 +1310,20 @@ ST_FUNC void vpop(TCCState *S) · 2 unmodified lines | |||
| 1310 | #endif | 1310 | #endif |
| 1311 | if (v == VT_CMP) { | 1311 | if (v == VT_CMP) { |
| 1312 | /* need to put correct jump if && or || without test */ | 1312 | /* need to put correct jump if && or || without test */ |
| 1313 | gsym(S, S->vtop->jtrue); | 1313 | gsym(S, S->tccgen_vtop->jtrue); |
| 1314 | gsym(S, S->vtop->jfalse); | 1314 | gsym(S, S->tccgen_vtop->jfalse); |
| 1315 | } | 1315 | } |
| 1316 | S->vtop--; | 1316 | S->tccgen_vtop--; |
| 1317 | } | 1317 | } |
| 1318 | 1318 | ||
| 1319 | /* push constant of type "type" with useless value */ | 1319 | /* push constant of type "type" with useless value */ |
| 1320 | static void vpush(TCCState *S, CType *type) | 1320 | static void vpush(TCCState* S, CType *type) |
| 1321 | { | 1321 | { |
| 1322 | vset(S, type, VT_CONST, 0); | 1322 | vset(S, type, VT_CONST, 0); |
| 1323 | } | 1323 | } |
| 1324 | 1324 | ||
| 1325 | /* push arbitrary 64bit constant */ | 1325 | /* push arbitrary 64bit constant */ |
| 1326 | static void vpush64(TCCState *S, int ty, unsigned long long v) | 1326 | static void vpush64(TCCState* S, int ty, unsigned long long v) |
| 1327 | { | 1327 | { |
| 1328 | CValue cval; | 1328 | CValue cval; |
| 1329 | CType ctype; | 1329 | CType ctype; |
| @@ -1334,31 +1334,31 @@ static void vpush64(TCCState *S, int ty, unsigned long long v) · 4 unmodified lines | |||
| 1334 | } | 1334 | } |
| 1335 | 1335 | ||
| 1336 | /* push integer constant */ | 1336 | /* push integer constant */ |
| 1337 | ST_FUNC void vpushi(TCCState *S, int v) | 1337 | ST_FUNC void vpushi(TCCState* S, int v) |
| 1338 | { | 1338 | { |
| 1339 | vpush64(S, VT_INT, v); | 1339 | vpush64(S, VT_INT, v); |
| 1340 | } | 1340 | } |
| 1341 | 1341 | ||
| 1342 | /* push a pointer sized constant */ | 1342 | /* push a pointer sized constant */ |
| 1343 | static void vpushs(TCCState *S, addr_t v) | 1343 | static void vpushs(TCCState* S, addr_t v) |
| 1344 | { | 1344 | { |
| 1345 | vpush64(S, VT_SIZE_T, v); | 1345 | vpush64(S, VT_SIZE_T, v); |
| 1346 | } | 1346 | } |
| 1347 | 1347 | ||
| 1348 | /* push long long constant */ | 1348 | /* push long long constant */ |
| 1349 | static inline void vpushll(TCCState *S, long long v) | 1349 | static inline void vpushll(TCCState* S, long long v) |
| 1350 | { | 1350 | { |
| 1351 | vpush64(S, VT_LLONG, v); | 1351 | vpush64(S, VT_LLONG, v); |
| 1352 | } | 1352 | } |
| 1353 | 1353 | ||
| 1354 | ST_FUNC void vset(TCCState *S, CType *type, int r, int v) | 1354 | ST_FUNC void vset(TCCState* S, CType *type, int r, int v) |
| 1355 | { | 1355 | { |
| 1356 | CValue cval; | 1356 | CValue cval; |
| 1357 | cval.i = v; | 1357 | cval.i = v; |
| 1358 | vsetc(S, type, r, &cval); | 1358 | vsetc(S, type, r, &cval); |
| 1359 | } | 1359 | } |
| 1360 | 1360 | ||
| 1361 | static void vseti(TCCState *S, int r, int v) | 1361 | static void vseti(TCCState* S, int r, int v) |
| 1362 | { | 1362 | { |
| 1363 | CType type; | 1363 | CType type; |
| 1364 | type.t = VT_INT; | 1364 | type.t = VT_INT; |
| @@ -1366,38 +1366,38 @@ static void vseti(TCCState *S, int r, int v) · 1 unmodified line | |||
| 1366 | vset(S, &type, r, v); | 1366 | vset(S, &type, r, v); |
| 1367 | } | 1367 | } |
| 1368 | 1368 | ||
| 1369 | ST_FUNC void vpushv(TCCState *S, SValue *v) | 1369 | ST_FUNC void vpushv(TCCState* S, SValue *v) |
| 1370 | { | 1370 | { |
| 1371 | if (S->vtop >= vstack + (VSTACK_SIZE - 1)) | 1371 | if (S->tccgen_vtop >= vstack + (VSTACK_SIZE - 1)) |
| 1372 | tcc_error(S, "memory full (vstack)"); | 1372 | tcc_error(S, "memory full (vstack)"); |
| 1373 | S->vtop++; | 1373 | S->tccgen_vtop++; |
| 1374 | *S->vtop = *v; | 1374 | *S->tccgen_vtop = *v; |
| 1375 | } | 1375 | } |
| 1376 | 1376 | ||
| 1377 | static void vdup(TCCState *S) | 1377 | static void vdup(TCCState* S) |
| 1378 | { | 1378 | { |
| 1379 | vpushv(S, S->vtop); | 1379 | vpushv(S, S->tccgen_vtop); |
| 1380 | } | 1380 | } |
| 1381 | 1381 | ||
| 1382 | /* rotate n first stack elements to the bottom | 1382 | /* rotate n first stack elements to the bottom |
| 1383 | I1 ... In -> I2 ... In I1 [top is right] | 1383 | I1 ... In -> I2 ... In I1 [top is right] |
| 1384 | */ | 1384 | */ |
| 1385 | ST_FUNC void vrotb(TCCState *S, int n) | 1385 | ST_FUNC void vrotb(TCCState* S, int n) |
| 1386 | { | 1386 | { |
| 1387 | int i; | 1387 | int i; |
| 1388 | SValue tmp; | 1388 | SValue tmp; |
| 1389 | 1389 | ||
| 1390 | vcheck_cmp(S); | 1390 | vcheck_cmp(S); |
| 1391 | tmp = S->vtop[-n + 1]; | 1391 | tmp = S->tccgen_vtop[-n + 1]; |
| 1392 | for(i=-n+1;i!=0;i++) | 1392 | for(i=-n+1;i!=0;i++) |
| 1393 | S->vtop[i] = S->vtop[i+1]; | 1393 | S->tccgen_vtop[i] = S->tccgen_vtop[i+1]; |
| 1394 | S->vtop[0] = tmp; | 1394 | S->tccgen_vtop[0] = tmp; |
| 1395 | } | 1395 | } |
| 1396 | 1396 | ||
| 1397 | /* rotate the n elements before entry e towards the top | 1397 | /* rotate the n elements before entry e towards the top |
| 1398 | I1 ... In ... -> In I1 ... I(n-1) ... [top is right] | 1398 | I1 ... In ... -> In I1 ... I(n-1) ... [top is right] |
| 1399 | */ | 1399 | */ |
| 1400 | ST_FUNC void vrote(TCCState *S, SValue *e, int n) | 1400 | ST_FUNC void vrote(TCCState* S, SValue *e, int n) |
| 1401 | { | 1401 | { |
| 1402 | int i; | 1402 | int i; |
| 1403 | SValue tmp; | 1403 | SValue tmp; |
| @@ -1412,68 +1412,68 @@ ST_FUNC void vrote(TCCState *S, SValue *e, int n) · 8 unmodified lines | |||
| 1412 | /* rotate n first stack elements to the top | 1412 | /* rotate n first stack elements to the top |
| 1413 | I1 ... In -> In I1 ... I(n-1) [top is right] | 1413 | I1 ... In -> In I1 ... I(n-1) [top is right] |
| 1414 | */ | 1414 | */ |
| 1415 | ST_FUNC void vrott(TCCState *S, int n) | 1415 | ST_FUNC void vrott(TCCState* S, int n) |
| 1416 | { | 1416 | { |
| 1417 | vrote(S, S->vtop, n); | 1417 | vrote(S, S->tccgen_vtop, n); |
| 1418 | } | 1418 | } |
| 1419 | 1419 | ||
| 1420 | /* ------------------------------------------------------------------------- */ | 1420 | /* ------------------------------------------------------------------------- */ |
| 1421 | /* vtop->r = VT_CMP means CPU-flags have been set from comparison or test. */ | 1421 | /* vtop->r = VT_CMP means CPU-flags have been set from comparison or test. */ |
| 1422 | 1422 | ||
| 1423 | /* called from generators to set the result from relational ops */ | 1423 | /* called from generators to set the result from relational ops */ |
| 1424 | ST_FUNC void vset_VT_CMP(TCCState *S, int op) | 1424 | ST_FUNC void vset_VT_CMP(TCCState* S, int op) |
| 1425 | { | 1425 | { |
| 1426 | S->vtop->r = VT_CMP; | 1426 | S->tccgen_vtop->r = VT_CMP; |
| 1427 | S->vtop->cmp_op = op; | 1427 | S->tccgen_vtop->cmp_op = op; |
| 1428 | S->vtop->jfalse = 0; | 1428 | S->tccgen_vtop->jfalse = 0; |
| 1429 | S->vtop->jtrue = 0; | 1429 | S->tccgen_vtop->jtrue = 0; |
| 1430 | } | 1430 | } |
| 1431 | 1431 | ||
| 1432 | /* called once before asking generators to load VT_CMP to a register */ | 1432 | /* called once before asking generators to load VT_CMP to a register */ |
| 1433 | static void vset_VT_JMP(TCCState *S) | 1433 | static void vset_VT_JMP(TCCState* S) |
| 1434 | { | 1434 | { |
| 1435 | int op = S->vtop->cmp_op; | 1435 | int op = S->tccgen_vtop->cmp_op; |
| 1436 | 1436 | ||
| 1437 | if (S->vtop->jtrue || S->vtop->jfalse) { | 1437 | if (S->tccgen_vtop->jtrue || S->tccgen_vtop->jfalse) { |
| 1438 | /* we need to jump to 'mov $0,%R' or 'mov $1,%R' */ | 1438 | /* we need to jump to 'mov $0,%R' or 'mov $1,%R' */ |
| 1439 | int inv = op & (op < 2); /* small optimization */ | 1439 | int inv = op & (op < 2); /* small optimization */ |
| 1440 | vseti(S, VT_JMP+inv, gvtst(S, inv, 0)); | 1440 | vseti(S, VT_JMP+inv, gvtst(S, inv, 0)); |
| 1441 | } else { | 1441 | } else { |
| 1442 | /* otherwise convert flags (rsp. 0/1) to register */ | 1442 | /* otherwise convert flags (rsp. 0/1) to register */ |
| 1443 | S->vtop->c.i = op; | 1443 | S->tccgen_vtop->c.i = op; |
| 1444 | if (op < 2) /* doesn't seem to happen */ | 1444 | if (op < 2) /* doesn't seem to happen */ |
| 1445 | S->vtop->r = VT_CONST; | 1445 | S->tccgen_vtop->r = VT_CONST; |
| 1446 | } | 1446 | } |
| 1447 | } | 1447 | } |
| 1448 | 1448 | ||
| 1449 | /* Set CPU Flags, doesn't yet jump */ | 1449 | /* Set CPU Flags, doesn't yet jump */ |
| 1450 | static void gvtst_set(TCCState *S, int inv, int t) | 1450 | static void gvtst_set(TCCState* S, int inv, int t) |
| 1451 | { | 1451 | { |
| 1452 | int *p; | 1452 | int *p; |
| 1453 | 1453 | ||
| 1454 | if (S->vtop->r != VT_CMP) { | 1454 | if (S->tccgen_vtop->r != VT_CMP) { |
| 1455 | vpushi(S, 0); | 1455 | vpushi(S, 0); |
| 1456 | gen_op(S, TOK_NE); | 1456 | gen_op(S, TOK_NE); |
| 1457 | if (S->vtop->r != VT_CMP) /* must be VT_CONST then */ | 1457 | if (S->tccgen_vtop->r != VT_CMP) /* must be VT_CONST then */ |
| 1458 | vset_VT_CMP(S, S->vtop->c.i != 0); | 1458 | vset_VT_CMP(S, S->tccgen_vtop->c.i != 0); |
| 1459 | } | 1459 | } |
| 1460 | 1460 | ||
| 1461 | p = inv ? &S->vtop->jfalse : &S->vtop->jtrue; | 1461 | p = inv ? &S->tccgen_vtop->jfalse : &S->tccgen_vtop->jtrue; |
| 1462 | *p = gjmp_append(S, *p, t); | 1462 | *p = gjmp_append(S, *p, t); |
| 1463 | } | 1463 | } |
| 1464 | 1464 | ||
| 1465 | /* Generate value test | 1465 | /* Generate value test |
| 1466 | * | 1466 | * |
| 1467 | * Generate a test for any value (jump, comparison and integers) */ | 1467 | * Generate a test for any value (jump, comparison and integers) */ |
| 1468 | static int gvtst(TCCState *S, int inv, int t) | 1468 | static int gvtst(TCCState* S, int inv, int t) |
| 1469 | { | 1469 | { |
| 1470 | int op, x, u; | 1470 | int op, x, u; |
| 1471 | 1471 | ||
| 1472 | gvtst_set(S, inv, t); | 1472 | gvtst_set(S, inv, t); |
| 1473 | t = S->vtop->jtrue, u = S->vtop->jfalse; | 1473 | t = S->tccgen_vtop->jtrue, u = S->tccgen_vtop->jfalse; |
| 1474 | if (inv) | 1474 | if (inv) |
| 1475 | x = u, u = t, t = x; | 1475 | x = u, u = t, t = x; |
| 1476 | op = S->vtop->cmp_op; | 1476 | op = S->tccgen_vtop->cmp_op; |
| 1477 | 1477 | ||
| 1478 | /* jump to the wanted target */ | 1478 | /* jump to the wanted target */ |
| 1479 | if (op > 1) | 1479 | if (op > 1) |
| @@ -1483,20 +1483,20 @@ static int gvtst(TCCState *S, int inv, int t) · 3 unmodified lines | |||
| 1483 | /* resolve complementary jumps to here */ | 1483 | /* resolve complementary jumps to here */ |
| 1484 | gsym(S, u); | 1484 | gsym(S, u); |
| 1485 | 1485 | ||
| 1486 | S->vtop--; | 1486 | S->tccgen_vtop--; |
| 1487 | return t; | 1487 | return t; |
| 1488 | } | 1488 | } |
| 1489 | 1489 | ||
| 1490 | /* generate a zero or nozero test */ | 1490 | /* generate a zero or nozero test */ |
| 1491 | static void gen_test_zero(TCCState *S, int op) | 1491 | static void gen_test_zero(TCCState* S, int op) |
| 1492 | { | 1492 | { |
| 1493 | if (S->vtop->r == VT_CMP) { | 1493 | if (S->tccgen_vtop->r == VT_CMP) { |
| 1494 | int j; | 1494 | int j; |
| 1495 | if (op == TOK_EQ) { | 1495 | if (op == TOK_EQ) { |
| 1496 | j = S->vtop->jfalse; | 1496 | j = S->tccgen_vtop->jfalse; |
| 1497 | S->vtop->jfalse = S->vtop->jtrue; | 1497 | S->tccgen_vtop->jfalse = S->tccgen_vtop->jtrue; |
| 1498 | S->vtop->jtrue = j; | 1498 | S->tccgen_vtop->jtrue = j; |
| 1499 | S->vtop->cmp_op ^= 1; | 1499 | S->tccgen_vtop->cmp_op ^= 1; |
| 1500 | } | 1500 | } |
| 1501 | } else { | 1501 | } else { |
| 1502 | vpushi(S, 0); | 1502 | vpushi(S, 0); |
| @@ -1506,16 +1506,16 @@ static void gen_test_zero(TCCState *S, int op) · 3 unmodified lines | |||
| 1506 | 1506 | ||
| 1507 | /* ------------------------------------------------------------------------- */ | 1507 | /* ------------------------------------------------------------------------- */ |
| 1508 | /* push a symbol value of TYPE */ | 1508 | /* push a symbol value of TYPE */ |
| 1509 | ST_FUNC void vpushsym(TCCState *S, CType *type, Sym *sym) | 1509 | ST_FUNC void vpushsym(TCCState* S, CType *type, Sym *sym) |
| 1510 | { | 1510 | { |
| 1511 | CValue cval; | 1511 | CValue cval; |
| 1512 | cval.i = 0; | 1512 | cval.i = 0; |
| 1513 | vsetc(S, type, VT_CONST | VT_SYM, &cval); | 1513 | vsetc(S, type, VT_CONST | VT_SYM, &cval); |
| 1514 | S->vtop->sym = sym; | 1514 | S->tccgen_vtop->sym = sym; |
| 1515 | } | 1515 | } |
| 1516 | 1516 | ||
| 1517 | /* Return a static symbol pointing to a section */ | 1517 | /* Return a static symbol pointing to a section */ |
| 1518 | ST_FUNC Sym *get_sym_ref(TCCState *S, CType *type, Section *sec, unsigned long offset, unsigned long size) | 1518 | ST_FUNC Sym *get_sym_ref(TCCState* S, CType *type, Section *sec, unsigned long offset, unsigned long size) |
| 1519 | { | 1519 | { |
| 1520 | int v; | 1520 | int v; |
| 1521 | Sym *sym; | 1521 | Sym *sym; |
| @@ -1528,13 +1528,13 @@ ST_FUNC Sym *get_sym_ref(TCCState *S, CType *type, Section *sec, unsigned long o · 6 unmodified lines | |||
| 1528 | } | 1528 | } |
| 1529 | 1529 | ||
| 1530 | /* push a reference to a section offset by adding a dummy symbol */ | 1530 | /* push a reference to a section offset by adding a dummy symbol */ |
| 1531 | static void vpush_ref(TCCState *S, CType *type, Section *sec, unsigned long offset, unsigned long size) | 1531 | static void vpush_ref(TCCState* S, CType *type, Section *sec, unsigned long offset, unsigned long size) |
| 1532 | { | 1532 | { |
| 1533 | vpushsym(S, type, get_sym_ref(S, type, sec, offset, size)); | 1533 | vpushsym(S, type, get_sym_ref(S, type, sec, offset, size)); |
| 1534 | } | 1534 | } |
| 1535 | 1535 | ||
| 1536 | /* define a new external reference to a symbol 'v' of type 'u' */ | 1536 | /* define a new external reference to a symbol 'v' of type 'u' */ |
| 1537 | ST_FUNC Sym *external_global_sym(TCCState *S, int v, CType *type) | 1537 | ST_FUNC Sym *external_global_sym(TCCState* S, int v, CType *type) |
| 1538 | { | 1538 | { |
| 1539 | Sym *s; | 1539 | Sym *s; |
| 1540 | 1540 | ||
| @@ -1553,14 +1553,14 @@ ST_FUNC Sym *external_global_sym(TCCState *S, int v, CType *type) · 12 unmodified lines | |||
| 1553 | 1553 | ||
| 1554 | /* create an external reference with no specific type similar to asm labels. | 1554 | /* create an external reference with no specific type similar to asm labels. |
| 1555 | This avoids type conflicts if the symbol is used from C too */ | 1555 | This avoids type conflicts if the symbol is used from C too */ |
| 1556 | ST_FUNC Sym *external_helper_sym(TCCState *S, int v) | 1556 | ST_FUNC Sym *external_helper_sym(TCCState* S, int v) |
| 1557 | { | 1557 | { |
| 1558 | CType ct = { VT_ASM_FUNC, NULL }; | 1558 | CType ct = { VT_ASM_FUNC, NULL }; |
| 1559 | return external_global_sym(S, v, &ct); | 1559 | return external_global_sym(S, v, &ct); |
| 1560 | } | 1560 | } |
| 1561 | 1561 | ||
| 1562 | /* push a reference to an helper function (such as memmove) */ | 1562 | /* push a reference to an helper function (such as memmove) */ |
| 1563 | ST_FUNC void vpush_helper_func(TCCState *S, int v) | 1563 | ST_FUNC void vpush_helper_func(TCCState* S, int v) |
| 1564 | { | 1564 | { |
| 1565 | vpushsym(S, &S->tccgen_func_old_type, external_helper_sym(S, v)); | 1565 | vpushsym(S, &S->tccgen_func_old_type, external_helper_sym(S, v)); |
| 1566 | } | 1566 | } |
| @@ -1618,7 +1618,7 @@ static void merge_attr(AttributeDef *ad, AttributeDef *ad1) · 51 unmodified lines | |||
| 1618 | } | 1618 | } |
| 1619 | 1619 | ||
| 1620 | /* Merge some type attributes. */ | 1620 | /* Merge some type attributes. */ |
| 1621 | static void patch_type(TCCState *S, Sym *sym, CType *type) | 1621 | static void patch_type(TCCState* S, Sym *sym, CType *type) |
| 1622 | { | 1622 | { |
| 1623 | if (!(type->t & VT_EXTERN) || IS_ENUM_VAL(sym->type.t)) { | 1623 | if (!(type->t & VT_EXTERN) || IS_ENUM_VAL(sym->type.t)) { |
| 1624 | if (!(sym->type.t & VT_EXTERN)) | 1624 | if (!(sym->type.t & VT_EXTERN)) |
| @@ -1681,7 +1681,7 @@ static void patch_type(TCCState *S, Sym *sym, CType *type) · 56 unmodified lines | |||
| 1681 | } | 1681 | } |
| 1682 | 1682 | ||
| 1683 | /* Merge some storage attributes. */ | 1683 | /* Merge some storage attributes. */ |
| 1684 | static void patch_storage(TCCState *S, Sym *sym, AttributeDef *ad, CType *type) | 1684 | static void patch_storage(TCCState* S, Sym *sym, AttributeDef *ad, CType *type) |
| 1685 | { | 1685 | { |
| 1686 | if (type) | 1686 | if (type) |
| 1687 | patch_type(S, sym, type); | 1687 | patch_type(S, sym, type); |
| @@ -1698,7 +1698,7 @@ static void patch_storage(TCCState *S, Sym *sym, AttributeDef *ad, CType *type) · 10 unmodified lines | |||
| 1698 | } | 1698 | } |
| 1699 | 1699 | ||
| 1700 | /* copy sym to other stack */ | 1700 | /* copy sym to other stack */ |
| 1701 | static Sym *sym_copy(TCCState *S, Sym *s0, Sym **ps) | 1701 | static Sym *sym_copy(TCCState* S, Sym *s0, Sym **ps) |
| 1702 | { | 1702 | { |
| 1703 | Sym *s; | 1703 | Sym *s; |
| 1704 | s = sym_malloc(S), *s = *s0; | 1704 | s = sym_malloc(S), *s = *s0; |
| @@ -1711,7 +1711,7 @@ static Sym *sym_copy(TCCState *S, Sym *s0, Sym **ps) · 6 unmodified lines | |||
| 1711 | } | 1711 | } |
| 1712 | 1712 | ||
| 1713 | /* copy s->type.ref to stack 'ps' for VT_FUNC and VT_PTR */ | 1713 | /* copy s->type.ref to stack 'ps' for VT_FUNC and VT_PTR */ |
| 1714 | static void sym_copy_ref(TCCState *S, Sym *s, Sym **ps) | 1714 | static void sym_copy_ref(TCCState* S, Sym *s, Sym **ps) |
| 1715 | { | 1715 | { |
| 1716 | int bt = s->type.t & VT_BTYPE; | 1716 | int bt = s->type.t & VT_BTYPE; |
| 1717 | if (bt == VT_FUNC || bt == VT_PTR || (bt == VT_STRUCT && s->sym_scope)) { | 1717 | if (bt == VT_FUNC || bt == VT_PTR || (bt == VT_STRUCT && s->sym_scope)) { |
| @@ -1725,7 +1725,7 @@ static void sym_copy_ref(TCCState *S, Sym *s, Sym **ps) · 7 unmodified lines | |||
| 1725 | } | 1725 | } |
| 1726 | 1726 | ||
| 1727 | /* define a new external reference to a symbol 'v' */ | 1727 | /* define a new external reference to a symbol 'v' */ |
| 1728 | static Sym *external_sym(TCCState *S, int v, CType *type, int r, AttributeDef *ad) | 1728 | static Sym *external_sym(TCCState* S, int v, CType *type, int r, AttributeDef *ad) |
| 1729 | { | 1729 | { |
| 1730 | Sym *s; | 1730 | Sym *s; |
| 1731 | 1731 | ||
| @@ -1742,44 +1742,44 @@ static Sym *external_sym(TCCState *S, int v, CType *type, int r, AttributeDef *a · 10 unmodified lines | |||
| 1742 | s->asm_label = ad->asm_label; | 1742 | s->asm_label = ad->asm_label; |
| 1743 | s->type.ref = type->ref; | 1743 | s->type.ref = type->ref; |
| 1744 | /* copy type to the global stack */ | 1744 | /* copy type to the global stack */ |
| 1745 | if (S->local_stack) | 1745 | if (S->tccgen_local_stack) |
| 1746 | sym_copy_ref(S, s, &S->tccgen_global_stack); | 1746 | sym_copy_ref(S, s, &S->tccgen_global_stack); |
| 1747 | } else { | 1747 | } else { |
| 1748 | patch_storage(S, s, ad, type); | 1748 | patch_storage(S, s, ad, type); |
| 1749 | } | 1749 | } |
| 1750 | /* push variables on local_stack if any */ | 1750 | /* push variables on local_stack if any */ |
| 1751 | if (S->local_stack && (s->type.t & VT_BTYPE) != VT_FUNC) | 1751 | if (S->tccgen_local_stack && (s->type.t & VT_BTYPE) != VT_FUNC) |
| 1752 | s = sym_copy(S, s, &S->local_stack); | 1752 | s = sym_copy(S, s, &S->tccgen_local_stack); |
| 1753 | return s; | 1753 | return s; |
| 1754 | } | 1754 | } |
| 1755 | 1755 | ||
| 1756 | /* save registers up to (vtop - n) stack entry */ | 1756 | /* save registers up to (vtop - n) stack entry */ |
| 1757 | ST_FUNC void save_regs(TCCState *S, int n) | 1757 | ST_FUNC void save_regs(TCCState* S, int n) |
| 1758 | { | 1758 | { |
| 1759 | SValue *p, *p1; | 1759 | SValue *p, *p1; |
| 1760 | for(p = vstack, p1 = S->vtop - n; p <= p1; p++) | 1760 | for(p = vstack, p1 = S->tccgen_vtop - n; p <= p1; p++) |
| 1761 | save_reg(S, p->r); | 1761 | save_reg(S, p->r); |
| 1762 | } | 1762 | } |
| 1763 | 1763 | ||
| 1764 | /* save r to the memory stack, and mark it as being free */ | 1764 | /* save r to the memory stack, and mark it as being free */ |
| 1765 | ST_FUNC void save_reg(TCCState *S, int r) | 1765 | ST_FUNC void save_reg(TCCState* S, int r) |
| 1766 | { | 1766 | { |
| 1767 | save_reg_upstack(S, r, 0); | 1767 | save_reg_upstack(S, r, 0); |
| 1768 | } | 1768 | } |
| 1769 | 1769 | ||
| 1770 | /* save r to the memory stack, and mark it as being free, | 1770 | /* save r to the memory stack, and mark it as being free, |
| 1771 | if seen up to (vtop - n) stack entry */ | 1771 | if seen up to (vtop - n) stack entry */ |
| 1772 | ST_FUNC void save_reg_upstack(TCCState *S, int r, int n) | 1772 | ST_FUNC void save_reg_upstack(TCCState* S, int r, int n) |
| 1773 | { | 1773 | { |
| 1774 | int l, size, align, bt; | 1774 | int l, size, align, bt; |
| 1775 | SValue *p, *p1, sv; | 1775 | SValue *p, *p1, sv; |
| 1776 | 1776 | ||
| 1777 | if ((r &= VT_VALMASK) >= VT_CONST) | 1777 | if ((r &= VT_VALMASK) >= VT_CONST) |
| 1778 | return; | 1778 | return; |
| 1779 | if (S->nocode_wanted) | 1779 | if (S->tccgen_nocode_wanted) |
| 1780 | return; | 1780 | return; |
| 1781 | l = 0; | 1781 | l = 0; |
| 1782 | for(p = vstack, p1 = S->vtop - n; p <= p1; p++) { | 1782 | for(p = vstack, p1 = S->tccgen_vtop - n; p <= p1; p++) { |
| 1783 | if ((p->r & VT_VALMASK) == r || p->r2 == r) { | 1783 | if ((p->r & VT_VALMASK) == r || p->r2 == r) { |
| 1784 | /* must save value on stack if not already done */ | 1784 | /* must save value on stack if not already done */ |
| 1785 | if (!l) { | 1785 | if (!l) { |
| @@ -1825,7 +1825,7 @@ ST_FUNC void save_reg_upstack(TCCState *S, int r, int n) · 39 unmodified lines | |||
| 1825 | #ifdef TCC_TARGET_ARM | 1825 | #ifdef TCC_TARGET_ARM |
| 1826 | /* find a register of class 'rc2' with at most one reference on stack. | 1826 | /* find a register of class 'rc2' with at most one reference on stack. |
| 1827 | * If none, call get_reg(rc) */ | 1827 | * If none, call get_reg(rc) */ |
| 1828 | ST_FUNC int get_reg_ex(TCCState *S, int rc, int rc2) | 1828 | ST_FUNC int get_reg_ex(TCCState* S, int rc, int rc2) |
| 1829 | { | 1829 | { |
| 1830 | int r; | 1830 | int r; |
| 1831 | SValue *p; | 1831 | SValue *p; |
| @@ -1834,7 +1834,7 @@ ST_FUNC int get_reg_ex(TCCState *S, int rc, int rc2) · 2 unmodified lines | |||
| 1834 | if (reg_classes[r] & rc2) { | 1834 | if (reg_classes[r] & rc2) { |
| 1835 | int n; | 1835 | int n; |
| 1836 | n=0; | 1836 | n=0; |
| 1837 | for(p = vstack; p <= S->vtop; p++) { | 1837 | for(p = vstack; p <= S->tccgen_vtop; p++) { |
| 1838 | if ((p->r & VT_VALMASK) == r || | 1838 | if ((p->r & VT_VALMASK) == r || |
| 1839 | p->r2 == r) | 1839 | p->r2 == r) |
| 1840 | n++; | 1840 | n++; |
| @@ -1848,7 +1848,7 @@ ST_FUNC int get_reg_ex(TCCState *S, int rc, int rc2) · 7 unmodified lines | |||
| 1848 | #endif | 1848 | #endif |
| 1849 | 1849 | ||
| 1850 | /* find a free register of class 'rc'. If none, save one register */ | 1850 | /* find a free register of class 'rc'. If none, save one register */ |
| 1851 | ST_FUNC int get_reg(TCCState *S, int rc) | 1851 | ST_FUNC int get_reg(TCCState* S, int rc) |
| 1852 | { | 1852 | { |
| 1853 | int r; | 1853 | int r; |
| 1854 | SValue *p; | 1854 | SValue *p; |
| @@ -1856,9 +1856,9 @@ ST_FUNC int get_reg(TCCState *S, int rc) · 1 unmodified line | |||
| 1856 | /* find a free register */ | 1856 | /* find a free register */ |
| 1857 | for(r=0;r<NB_REGS;r++) { | 1857 | for(r=0;r<NB_REGS;r++) { |
| 1858 | if (reg_classes[r] & rc) { | 1858 | if (reg_classes[r] & rc) { |
| 1859 | if (S->nocode_wanted) | 1859 | if (S->tccgen_nocode_wanted) |
| 1860 | return r; | 1860 | return r; |
| 1861 | for(p=vstack;p<=S->vtop;p++) { | 1861 | for(p=vstack;p<=S->tccgen_vtop;p++) { |
| 1862 | if ((p->r & VT_VALMASK) == r || | 1862 | if ((p->r & VT_VALMASK) == r || |
| 1863 | p->r2 == r) | 1863 | p->r2 == r) |
| 1864 | goto notfound; | 1864 | goto notfound; |
| @@ -1871,7 +1871,7 @@ ST_FUNC int get_reg(TCCState *S, int rc) · 6 unmodified lines | |||
| 1871 | /* no register left : free the first one on the stack (VERY | 1871 | /* no register left : free the first one on the stack (VERY |
| 1872 | IMPORTANT to start from the bottom to ensure that we don't | 1872 | IMPORTANT to start from the bottom to ensure that we don't |
| 1873 | spill registers used in gen_opi()) */ | 1873 | spill registers used in gen_opi()) */ |
| 1874 | for(p=vstack;p<=S->vtop;p++) { | 1874 | for(p=vstack;p<=S->tccgen_vtop;p++) { |
| 1875 | /* look at second register (if long long) */ | 1875 | /* look at second register (if long long) */ |
| 1876 | r = p->r2; | 1876 | r = p->r2; |
| 1877 | if (r < VT_CONST && (reg_classes[r] & rc)) | 1877 | if (r < VT_CONST && (reg_classes[r] & rc)) |
| @@ -1888,7 +1888,7 @@ ST_FUNC int get_reg(TCCState *S, int rc) · 10 unmodified lines | |||
| 1888 | } | 1888 | } |
| 1889 | 1889 | ||
| 1890 | /* find a free temporary local variable (return the offset on stack) match the size and align. If none, add new temporary stack variable*/ | 1890 | /* find a free temporary local variable (return the offset on stack) match the size and align. If none, add new temporary stack variable*/ |
| 1891 | static int get_temp_local_var(TCCState *S, int size,int align){ | 1891 | static int get_temp_local_var(TCCState* S, int size,int align){ |
| 1892 | int i; | 1892 | int i; |
| 1893 | temp_local_variable_t *temp_var; | 1893 | temp_local_variable_t *temp_var; |
| 1894 | int found_var; | 1894 | int found_var; |
| @@ -1904,7 +1904,7 @@ static int get_temp_local_var(TCCState *S, int size,int align){ · 9 unmodified lines | |||
| 1904 | } | 1904 | } |
| 1905 | /*check if temp_var is free*/ | 1905 | /*check if temp_var is free*/ |
| 1906 | free=1; | 1906 | free=1; |
| 1907 | for(p=vstack;p<=S->vtop;p++) { | 1907 | for(p=vstack;p<=S->tccgen_vtop;p++) { |
| 1908 | r=p->r&VT_VALMASK; | 1908 | r=p->r&VT_VALMASK; |
| 1909 | if(r==VT_LOCAL||r==VT_LLOCAL){ | 1909 | if(r==VT_LOCAL||r==VT_LLOCAL){ |
| 1910 | if(p->c.i==temp_var->location){ | 1910 | if(p->c.i==temp_var->location){ |
| @@ -1920,26 +1920,26 @@ static int get_temp_local_var(TCCState *S, int size,int align){ · 9 unmodified lines | |||
| 1920 | } | 1920 | } |
| 1921 | } | 1921 | } |
| 1922 | if(!found){ | 1922 | if(!found){ |
| 1923 | S->loc = (S->loc - size) & -align; | 1923 | S->tccgen_loc = (S->tccgen_loc - size) & -align; |
| 1924 | if(S->tccgen_nb_temp_local_vars<MAX_TEMP_LOCAL_VARIABLE_NUMBER){ | 1924 | if(S->tccgen_nb_temp_local_vars<MAX_TEMP_LOCAL_VARIABLE_NUMBER){ |
| 1925 | temp_var=&S->tccgen_arr_temp_local_vars[i]; | 1925 | temp_var=&S->tccgen_arr_temp_local_vars[i]; |
| 1926 | temp_var->location=S->loc; | 1926 | temp_var->location=S->tccgen_loc; |
| 1927 | temp_var->size=size; | 1927 | temp_var->size=size; |
| 1928 | temp_var->align=align; | 1928 | temp_var->align=align; |
| 1929 | S->tccgen_nb_temp_local_vars++; | 1929 | S->tccgen_nb_temp_local_vars++; |
| 1930 | } | 1930 | } |
| 1931 | found_var=S->loc; | 1931 | found_var=S->tccgen_loc; |
| 1932 | } | 1932 | } |
| 1933 | return found_var; | 1933 | return found_var; |
| 1934 | } | 1934 | } |
| 1935 | 1935 | ||
| 1936 | static void clear_temp_local_var_list(TCCState *S){ | 1936 | static void clear_temp_local_var_list(TCCState* S){ |
| 1937 | S->tccgen_nb_temp_local_vars=0; | 1937 | S->tccgen_nb_temp_local_vars=0; |
| 1938 | } | 1938 | } |
| 1939 | 1939 | ||
| 1940 | /* move register 's' (of type 't') to 'r', and flush previous value of r to memory | 1940 | /* move register 's' (of type 't') to 'r', and flush previous value of r to memory |
| 1941 | if needed */ | 1941 | if needed */ |
| 1942 | static void move_reg(TCCState *S, int r, int s, int t) | 1942 | static void move_reg(TCCState* S, int r, int s, int t) |
| 1943 | { | 1943 | { |
| 1944 | SValue sv; | 1944 | SValue sv; |
| 1945 | 1945 | ||
| @@ -1954,49 +1954,49 @@ static void move_reg(TCCState *S, int r, int s, int t) · 8 unmodified lines | |||
| 1954 | } | 1954 | } |
| 1955 | 1955 | ||
| 1956 | /* get address of vtop (vtop MUST BE an lvalue) */ | 1956 | /* get address of vtop (vtop MUST BE an lvalue) */ |
| 1957 | ST_FUNC void gaddrof(TCCState *S) | 1957 | ST_FUNC void gaddrof(TCCState* S) |
| 1958 | { | 1958 | { |
| 1959 | S->vtop->r &= ~VT_LVAL; | 1959 | S->tccgen_vtop->r &= ~VT_LVAL; |
| 1960 | /* tricky: if saved lvalue, then we can go back to lvalue */ | 1960 | /* tricky: if saved lvalue, then we can go back to lvalue */ |
| 1961 | if ((S->vtop->r & VT_VALMASK) == VT_LLOCAL) | 1961 | if ((S->tccgen_vtop->r & VT_VALMASK) == VT_LLOCAL) |
| 1962 | S->vtop->r = (S->vtop->r & ~VT_VALMASK) | VT_LOCAL | VT_LVAL; | 1962 | S->tccgen_vtop->r = (S->tccgen_vtop->r & ~VT_VALMASK) | VT_LOCAL | VT_LVAL; |
| 1963 | } | 1963 | } |
| 1964 | 1964 | ||
| 1965 | #ifdef CONFIG_TCC_BCHECK | 1965 | #ifdef CONFIG_TCC_BCHECK |
| 1966 | /* generate a bounded pointer addition */ | 1966 | /* generate a bounded pointer addition */ |
| 1967 | static void gen_bounded_ptr_add(TCCState *S) | 1967 | static void gen_bounded_ptr_add(TCCState* S) |
| 1968 | { | 1968 | { |
| 1969 | int save = (S->vtop[-1].r & VT_VALMASK) == VT_LOCAL; | 1969 | int save = (S->tccgen_vtop[-1].r & VT_VALMASK) == VT_LOCAL; |
| 1970 | if (save) { | 1970 | if (save) { |
| 1971 | vpushv(S, &S->vtop[-1]); | 1971 | vpushv(S, &S->tccgen_vtop[-1]); |
| 1972 | vrott(S, 3); | 1972 | vrott(S, 3); |
| 1973 | } | 1973 | } |
| 1974 | vpush_helper_func(S, TOK___bound_ptr_add); | 1974 | vpush_helper_func(S, TOK___bound_ptr_add); |
| 1975 | vrott(S, 3); | 1975 | vrott(S, 3); |
| 1976 | gfunc_call(S, 2); | 1976 | gfunc_call(S, 2); |
| 1977 | S->vtop -= save; | 1977 | S->tccgen_vtop -= save; |
| 1978 | vpushi(S, 0); | 1978 | vpushi(S, 0); |
| 1979 | /* returned pointer is in REG_IRET */ | 1979 | /* returned pointer is in REG_IRET */ |
| 1980 | S->vtop->r = REG_IRET | VT_BOUNDED; | 1980 | S->tccgen_vtop->r = REG_IRET | VT_BOUNDED; |
| 1981 | if (S->nocode_wanted) | 1981 | if (S->tccgen_nocode_wanted) |
| 1982 | return; | 1982 | return; |
| 1983 | /* relocation offset of the bounding function call point */ | 1983 | /* relocation offset of the bounding function call point */ |
| 1984 | S->vtop->c.i = (cur_text_section->reloc->data_offset - sizeof(ElfW_Rel)); | 1984 | S->tccgen_vtop->c.i = (cur_text_section->reloc->data_offset - sizeof(ElfW_Rel)); |
| 1985 | } | 1985 | } |
| 1986 | 1986 | ||
| 1987 | /* patch pointer addition in vtop so that pointer dereferencing is | 1987 | /* patch pointer addition in vtop so that pointer dereferencing is |
| 1988 | also tested */ | 1988 | also tested */ |
| 1989 | static void gen_bounded_ptr_deref(TCCState *S) | 1989 | static void gen_bounded_ptr_deref(TCCState* S) |
| 1990 | { | 1990 | { |
| 1991 | addr_t func; | 1991 | addr_t func; |
| 1992 | int size, align; | 1992 | int size, align; |
| 1993 | ElfW_Rel *rel; | 1993 | ElfW_Rel *rel; |
| 1994 | Sym *sym; | 1994 | Sym *sym; |
| 1995 | 1995 | ||
| 1996 | if (S->nocode_wanted) | 1996 | if (S->tccgen_nocode_wanted) |
| 1997 | return; | 1997 | return; |
| 1998 | 1998 | ||
| 1999 | size = type_size(&S->vtop->type, &align); | 1999 | size = type_size(&S->tccgen_vtop->type, &align); |
| 2000 | switch(size) { | 2000 | switch(size) { |
| 2001 | case 1: func = TOK___bound_ptr_indir1; break; | 2001 | case 1: func = TOK___bound_ptr_indir1; break; |
| 2002 | case 2: func = TOK___bound_ptr_indir2; break; | 2002 | case 2: func = TOK___bound_ptr_indir2; break; |
| @@ -2013,28 +2013,28 @@ static void gen_bounded_ptr_deref(TCCState *S) · 10 unmodified lines | |||
| 2013 | put_extern_sym(S, sym, NULL, 0, 0); | 2013 | put_extern_sym(S, sym, NULL, 0, 0); |
| 2014 | /* patch relocation */ | 2014 | /* patch relocation */ |
| 2015 | /* XXX: find a better solution ? */ | 2015 | /* XXX: find a better solution ? */ |
| 2016 | rel = (ElfW_Rel *)(cur_text_section->reloc->data + S->vtop->c.i); | 2016 | rel = (ElfW_Rel *)(cur_text_section->reloc->data + S->tccgen_vtop->c.i); |
| 2017 | rel->r_info = ELFW(R_INFO)(sym->c, ELFW(R_TYPE)(rel->r_info)); | 2017 | rel->r_info = ELFW(R_INFO)(sym->c, ELFW(R_TYPE)(rel->r_info)); |
| 2018 | } | 2018 | } |
| 2019 | 2019 | ||
| 2020 | /* generate lvalue bound code */ | 2020 | /* generate lvalue bound code */ |
| 2021 | static void gbound(TCCState *S) | 2021 | static void gbound(TCCState* S) |
| 2022 | { | 2022 | { |
| 2023 | CType type1; | 2023 | CType type1; |
| 2024 | 2024 | ||
| 2025 | S->vtop->r &= ~VT_MUSTBOUND; | 2025 | S->tccgen_vtop->r &= ~VT_MUSTBOUND; |
| 2026 | /* if lvalue, then use checking code before dereferencing */ | 2026 | /* if lvalue, then use checking code before dereferencing */ |
| 2027 | if (S->vtop->r & VT_LVAL) { | 2027 | if (S->tccgen_vtop->r & VT_LVAL) { |
| 2028 | /* if not VT_BOUNDED value, then make one */ | 2028 | /* if not VT_BOUNDED value, then make one */ |
| 2029 | if (!(S->vtop->r & VT_BOUNDED)) { | 2029 | if (!(S->tccgen_vtop->r & VT_BOUNDED)) { |
| 2030 | /* must save type because we must set it to int to get pointer */ | 2030 | /* must save type because we must set it to int to get pointer */ |
| 2031 | type1 = S->vtop->type; | 2031 | type1 = S->tccgen_vtop->type; |
| 2032 | S->vtop->type.t = VT_PTR; | 2032 | S->tccgen_vtop->type.t = VT_PTR; |
| 2033 | gaddrof(S); | 2033 | gaddrof(S); |
| 2034 | vpushi(S, 0); | 2034 | vpushi(S, 0); |
| 2035 | gen_bounded_ptr_add(S); | 2035 | gen_bounded_ptr_add(S); |
| 2036 | S->vtop->r |= VT_LVAL; | 2036 | S->tccgen_vtop->r |= VT_LVAL; |
| 2037 | S->vtop->type = type1; | 2037 | S->tccgen_vtop->type = type1; |
| 2038 | } | 2038 | } |
| 2039 | /* then check for dereferencing */ | 2039 | /* then check for dereferencing */ |
| 2040 | gen_bounded_ptr_deref(S); | 2040 | gen_bounded_ptr_deref(S); |
| @@ -2043,19 +2043,19 @@ static void gbound(TCCState *S) · 2 unmodified lines | |||
| 2043 | 2043 | ||
| 2044 | /* we need to call __bound_ptr_add before we start to load function | 2044 | /* we need to call __bound_ptr_add before we start to load function |
| 2045 | args into registers */ | 2045 | args into registers */ |
| 2046 | ST_FUNC void gbound_args(TCCState *S, int nb_args) | 2046 | ST_FUNC void gbound_args(TCCState* S, int nb_args) |
| 2047 | { | 2047 | { |
| 2048 | int i, v; | 2048 | int i, v; |
| 2049 | SValue *sv; | 2049 | SValue *sv; |
| 2050 | 2050 | ||
| 2051 | for (i = 1; i <= nb_args; ++i) | 2051 | for (i = 1; i <= nb_args; ++i) |
| 2052 | if (S->vtop[1 - i].r & VT_MUSTBOUND) { | 2052 | if (S->tccgen_vtop[1 - i].r & VT_MUSTBOUND) { |
| 2053 | vrotb(S, i); | 2053 | vrotb(S, i); |
| 2054 | gbound(S); | 2054 | gbound(S); |
| 2055 | vrott(S, i); | 2055 | vrott(S, i); |
| 2056 | } | 2056 | } |
| 2057 | 2057 | ||
| 2058 | sv = S->vtop - nb_args; | 2058 | sv = S->tccgen_vtop - nb_args; |
| 2059 | if (sv->r & VT_SYM) { | 2059 | if (sv->r & VT_SYM) { |
| 2060 | v = sv->sym->v; | 2060 | v = sv->sym->v; |
| 2061 | if (v == TOK_setjmp | 2061 | if (v == TOK_setjmp |
| @@ -2082,7 +2082,7 @@ ST_FUNC void gbound_args(TCCState *S, int nb_args) · 20 unmodified lines | |||
| 2082 | } | 2082 | } |
| 2083 | 2083 | ||
| 2084 | /* Add bounds for local symbols from S to E (via ->prev) */ | 2084 | /* Add bounds for local symbols from S to E (via ->prev) */ |
| 2085 | static void add_local_bounds(TCCState *S, Sym *s, Sym *e) | 2085 | static void add_local_bounds(TCCState* S, Sym *s, Sym *e) |
| 2086 | { | 2086 | { |
| 2087 | for (; s != e; s = s->prev) { | 2087 | for (; s != e; s = s->prev) { |
| 2088 | if (!s->v || (s->r & VT_VALMASK) != VT_LOCAL) | 2088 | if (!s->v || (s->r & VT_VALMASK) != VT_LOCAL) |
| @@ -2103,32 +2103,32 @@ static void add_local_bounds(TCCState *S, Sym *s, Sym *e) · 14 unmodified lines | |||
| 2103 | #endif | 2103 | #endif |
| 2104 | 2104 | ||
| 2105 | /* Wrapper around sym_pop, that potentially also registers local bounds. */ | 2105 | /* Wrapper around sym_pop, that potentially also registers local bounds. */ |
| 2106 | static void pop_local_syms(TCCState *S, Sym *b, int keep) | 2106 | static void pop_local_syms(TCCState* S, Sym *b, int keep) |
| 2107 | { | 2107 | { |
| 2108 | #ifdef CONFIG_TCC_BCHECK | 2108 | #ifdef CONFIG_TCC_BCHECK |
| 2109 | if (S->do_bounds_check && !keep && (S->local_scope || !S->tccgen_func_var)) | 2109 | if (S->do_bounds_check && !keep && (S->tccgen_local_scope || !S->tccgen_func_var)) |
| 2110 | add_local_bounds(S, S->local_stack, b); | 2110 | add_local_bounds(S, S->tccgen_local_stack, b); |
| 2111 | #endif | 2111 | #endif |
| 2112 | if (S->tccgen_debug_modes) | 2112 | if (S->tccgen_debug_modes) |
| 2113 | tcc_add_debug_info (S, !S->local_scope, S->local_stack, b); | 2113 | tcc_add_debug_info (S, !S->tccgen_local_scope, S->tccgen_local_stack, b); |
| 2114 | sym_pop(S, &S->local_stack, b, keep); | 2114 | sym_pop(S, &S->tccgen_local_stack, b, keep); |
| 2115 | } | 2115 | } |
| 2116 | 2116 | ||
| 2117 | static void incr_bf_adr(TCCState *S, int o) | 2117 | static void incr_bf_adr(TCCState* S, int o) |
| 2118 | { | 2118 | { |
| 2119 | S->vtop->type = S->char_pointer_type; | 2119 | S->tccgen_vtop->type = S->tccgen_char_pointer_type; |
| 2120 | gaddrof(S); | 2120 | gaddrof(S); |
| 2121 | vpushs(S, o); | 2121 | vpushs(S, o); |
| 2122 | gen_op(S, '+'); | 2122 | gen_op(S, '+'); |
| 2123 | S->vtop->type.t = VT_BYTE | VT_UNSIGNED; | 2123 | S->tccgen_vtop->type.t = VT_BYTE | VT_UNSIGNED; |
| 2124 | S->vtop->r |= VT_LVAL; | 2124 | S->tccgen_vtop->r |= VT_LVAL; |
| 2125 | } | 2125 | } |
| 2126 | 2126 | ||
| 2127 | /* single-byte load mode for packed or otherwise unaligned bitfields */ | 2127 | /* single-byte load mode for packed or otherwise unaligned bitfields */ |
| 2128 | static void load_packed_bf(TCCState *S, CType *type, int bit_pos, int bit_size) | 2128 | static void load_packed_bf(TCCState* S, CType *type, int bit_pos, int bit_size) |
| 2129 | { | 2129 | { |
| 2130 | int n, o, bits; | 2130 | int n, o, bits; |
| 2131 | save_reg_upstack(S, S->vtop->r, 1); | 2131 | save_reg_upstack(S, S->tccgen_vtop->r, 1); |
| 2132 | vpush64(S, type->t & VT_BTYPE, 0); // B X | 2132 | vpush64(S, type->t & VT_BTYPE, 0); // B X |
| 2133 | bits = 0, o = bit_pos >> 3, bit_pos &= 7; | 2133 | bits = 0, o = bit_pos >> 3, bit_pos &= 7; |
| 2134 | do { | 2134 | do { |
| @@ -2158,12 +2158,12 @@ static void load_packed_bf(TCCState *S, CType *type, int bit_pos, int bit_size) · 23 unmodified lines | |||
| 2158 | } | 2158 | } |
| 2159 | 2159 | ||
| 2160 | /* single-byte store mode for packed or otherwise unaligned bitfields */ | 2160 | /* single-byte store mode for packed or otherwise unaligned bitfields */ |
| 2161 | static void store_packed_bf(TCCState *S, int bit_pos, int bit_size) | 2161 | static void store_packed_bf(TCCState* S, int bit_pos, int bit_size) |
| 2162 | { | 2162 | { |
| 2163 | int bits, n, o, m, c; | 2163 | int bits, n, o, m, c; |
| 2164 | c = (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST; | 2164 | c = (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST; |
| 2165 | vswap(S); // X B | 2165 | vswap(S); // X B |
| 2166 | save_reg_upstack(S, S->vtop->r, 1); | 2166 | save_reg_upstack(S, S->tccgen_vtop->r, 1); |
| 2167 | bits = 0, o = bit_pos >> 3, bit_pos &= 7; | 2167 | bits = 0, o = bit_pos >> 3, bit_pos &= 7; |
| 2168 | do { | 2168 | do { |
| 2169 | incr_bf_adr(S, o); // X B | 2169 | incr_bf_adr(S, o); // X B |
| @@ -2180,12 +2180,12 @@ static void store_packed_bf(TCCState *S, int bit_pos, int bit_size) · 10 unmodified lines | |||
| 2180 | if (n < 8) { | 2180 | if (n < 8) { |
| 2181 | m = ((1 << n) - 1) << bit_pos; | 2181 | m = ((1 << n) - 1) << bit_pos; |
| 2182 | vpushi(S, m), gen_op(S, '&'); // X B V1 | 2182 | vpushi(S, m), gen_op(S, '&'); // X B V1 |
| 2183 | vpushv(S, S->vtop-1); // X B V1 B | 2183 | vpushv(S, S->tccgen_vtop-1); // X B V1 B |
| 2184 | vpushi(S, m & 0x80 ? ~m & 0x7f : ~m); | 2184 | vpushi(S, m & 0x80 ? ~m & 0x7f : ~m); |
| 2185 | gen_op(S, '&'); // X B V1 B1 | 2185 | gen_op(S, '&'); // X B V1 B1 |
| 2186 | gen_op(S, '|'); // X B V2 | 2186 | gen_op(S, '|'); // X B V2 |
| 2187 | } | 2187 | } |
| 2188 | vdup(S), S->vtop[-1] = S->vtop[-2]; // X B B V2 | 2188 | vdup(S), S->tccgen_vtop[-1] = S->tccgen_vtop[-2]; // X B B V2 |
| 2189 | vstore(S), vpop(S); // X B | 2189 | vstore(S), vpop(S); // X B |
| 2190 | bits += n, bit_size -= n, bit_pos = 0, o = 1; | 2190 | bits += n, bit_size -= n, bit_pos = 0, o = 1; |
| 2191 | } while (bit_size); | 2191 | } while (bit_size); |
| @@ -2208,28 +2208,28 @@ static int adjust_bf(SValue *sv, int bit_pos, int bit_size) · 16 unmodified lines | |||
| 2208 | /* store vtop a register belonging to class 'rc'. lvalues are | 2208 | /* store vtop a register belonging to class 'rc'. lvalues are |
| 2209 | converted to values. Cannot be used if cannot be converted to | 2209 | converted to values. Cannot be used if cannot be converted to |
| 2210 | register value (such as structures). */ | 2210 | register value (such as structures). */ |
| 2211 | ST_FUNC int gv(TCCState *S, int rc) | 2211 | ST_FUNC int gv(TCCState* S, int rc) |
| 2212 | { | 2212 | { |
| 2213 | int r, r2, r_ok, r2_ok, rc2, bt; | 2213 | int r, r2, r_ok, r2_ok, rc2, bt; |
| 2214 | int bit_pos, bit_size, size, align; | 2214 | int bit_pos, bit_size, size, align; |
| 2215 | 2215 | ||
| 2216 | /* NOTE: get_reg can modify vstack[] */ | 2216 | /* NOTE: get_reg can modify vstack[] */ |
| 2217 | if (S->vtop->type.t & VT_BITFIELD) { | 2217 | if (S->tccgen_vtop->type.t & VT_BITFIELD) { |
| 2218 | CType type; | 2218 | CType type; |
| 2219 | 2219 | ||
| 2220 | bit_pos = BIT_POS(S->vtop->type.t); | 2220 | bit_pos = BIT_POS(S->tccgen_vtop->type.t); |
| 2221 | bit_size = BIT_SIZE(S->vtop->type.t); | 2221 | bit_size = BIT_SIZE(S->tccgen_vtop->type.t); |
| 2222 | /* remove bit field info to avoid loops */ | 2222 | /* remove bit field info to avoid loops */ |
| 2223 | S->vtop->type.t &= ~VT_STRUCT_MASK; | 2223 | S->tccgen_vtop->type.t &= ~VT_STRUCT_MASK; |
| 2224 | 2224 | ||
| 2225 | type.ref = NULL; | 2225 | type.ref = NULL; |
| 2226 | type.t = S->vtop->type.t & VT_UNSIGNED; | 2226 | type.t = S->tccgen_vtop->type.t & VT_UNSIGNED; |
| 2227 | if ((S->vtop->type.t & VT_BTYPE) == VT_BOOL) | 2227 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_BOOL) |
| 2228 | type.t |= VT_UNSIGNED; | 2228 | type.t |= VT_UNSIGNED; |
| 2229 | 2229 | ||
| 2230 | r = adjust_bf(S->vtop, bit_pos, bit_size); | 2230 | r = adjust_bf(S->tccgen_vtop, bit_pos, bit_size); |
| 2231 | 2231 | ||
| 2232 | if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) | 2232 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) |
| 2233 | type.t |= VT_LLONG; | 2233 | type.t |= VT_LLONG; |
| 2234 | else | 2234 | else |
| 2235 | type.t |= VT_INT; | 2235 | type.t |= VT_INT; |
| @@ -2249,27 +2249,27 @@ ST_FUNC int gv(TCCState *S, int rc) · 13 unmodified lines | |||
| 2249 | } | 2249 | } |
| 2250 | r = gv(S, rc); | 2250 | r = gv(S, rc); |
| 2251 | } else { | 2251 | } else { |
| 2252 | if (is_float(S->vtop->type.t) && | 2252 | if (is_float(S->tccgen_vtop->type.t) && |
| 2253 | (S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { | 2253 | (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| 2254 | /* CPUs usually cannot use float constants, so we store them | 2254 | /* CPUs usually cannot use float constants, so we store them |
| 2255 | generically in data segment */ | 2255 | generically in data segment */ |
| 2256 | init_params p = { rodata_section }; | 2256 | init_params p = { rodata_section }; |
| 2257 | unsigned long offset; | 2257 | unsigned long offset; |
| 2258 | size = type_size(&S->vtop->type, &align); | 2258 | size = type_size(&S->tccgen_vtop->type, &align); |
| 2259 | if (NODATA_WANTED) | 2259 | if (NODATA_WANTED) |
| 2260 | size = 0, align = 1; | 2260 | size = 0, align = 1; |
| 2261 | offset = section_add(S, p.sec, size, align); | 2261 | offset = section_add(S, p.sec, size, align); |
| 2262 | vpush_ref(S, &S->vtop->type, p.sec, offset, size); | 2262 | vpush_ref(S, &S->tccgen_vtop->type, p.sec, offset, size); |
| 2263 | vswap(S); | 2263 | vswap(S); |
| 2264 | init_putv(S, &p, &S->vtop->type, offset); | 2264 | init_putv(S, &p, &S->tccgen_vtop->type, offset); |
| 2265 | S->vtop->r |= VT_LVAL; | 2265 | S->tccgen_vtop->r |= VT_LVAL; |
| 2266 | } | 2266 | } |
| 2267 | #ifdef CONFIG_TCC_BCHECK | 2267 | #ifdef CONFIG_TCC_BCHECK |
| 2268 | if (S->vtop->r & VT_MUSTBOUND) | 2268 | if (S->tccgen_vtop->r & VT_MUSTBOUND) |
| 2269 | gbound(S); | 2269 | gbound(S); |
| 2270 | #endif | 2270 | #endif |
| 2271 | 2271 | ||
| 2272 | bt = S->vtop->type.t & VT_BTYPE; | 2272 | bt = S->tccgen_vtop->type.t & VT_BTYPE; |
| 2273 | 2273 | ||
| 2274 | #ifdef TCC_TARGET_RISCV64 | 2274 | #ifdef TCC_TARGET_RISCV64 |
| 2275 | /* XXX mega hack */ | 2275 | /* XXX mega hack */ |
| @@ -2282,91 +2282,91 @@ ST_FUNC int gv(TCCState *S, int rc) · 6 unmodified lines | |||
| 2282 | - constant | 2282 | - constant |
| 2283 | - lvalue (need to dereference pointer) | 2283 | - lvalue (need to dereference pointer) |
| 2284 | - already a register, but not in the right class */ | 2284 | - already a register, but not in the right class */ |
| 2285 | r = S->vtop->r & VT_VALMASK; | 2285 | r = S->tccgen_vtop->r & VT_VALMASK; |
| 2286 | r_ok = !(S->vtop->r & VT_LVAL) && (r < VT_CONST) && (reg_classes[r] & rc); | 2286 | r_ok = !(S->tccgen_vtop->r & VT_LVAL) && (r < VT_CONST) && (reg_classes[r] & rc); |
| 2287 | r2_ok = !rc2 || ((S->vtop->r2 < VT_CONST) && (reg_classes[S->vtop->r2] & rc2)); | 2287 | r2_ok = !rc2 || ((S->tccgen_vtop->r2 < VT_CONST) && (reg_classes[S->tccgen_vtop->r2] & rc2)); |
| 2288 | 2288 | ||
| 2289 | if (!r_ok || !r2_ok) { | 2289 | if (!r_ok || !r2_ok) { |
| 2290 | if (!r_ok) | 2290 | if (!r_ok) |
| 2291 | r = get_reg(S, rc); | 2291 | r = get_reg(S, rc); |
| 2292 | if (rc2) { | 2292 | if (rc2) { |
| 2293 | int load_type = (bt == VT_QFLOAT) ? VT_DOUBLE : VT_PTRDIFF_T; | 2293 | int load_type = (bt == VT_QFLOAT) ? VT_DOUBLE : VT_PTRDIFF_T; |
| 2294 | int original_type = S->vtop->type.t; | 2294 | int original_type = S->tccgen_vtop->type.t; |
| 2295 | 2295 | ||
| 2296 | /* two register type load : | 2296 | /* two register type load : |
| 2297 | expand to two words temporarily */ | 2297 | expand to two words temporarily */ |
| 2298 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { | 2298 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| 2299 | /* load constant */ | 2299 | /* load constant */ |
| 2300 | unsigned long long ll = S->vtop->c.i; | 2300 | unsigned long long ll = S->tccgen_vtop->c.i; |
| 2301 | S->vtop->c.i = ll; /* first word */ | 2301 | S->tccgen_vtop->c.i = ll; /* first word */ |
| 2302 | load(S, r, S->vtop); | 2302 | load(S, r, S->tccgen_vtop); |
| 2303 | S->vtop->r = r; /* save register value */ | 2303 | S->tccgen_vtop->r = r; /* save register value */ |
| 2304 | vpushi(S, ll >> 32); /* second word */ | 2304 | vpushi(S, ll >> 32); /* second word */ |
| 2305 | } else if (S->vtop->r & VT_LVAL) { | 2305 | } else if (S->tccgen_vtop->r & VT_LVAL) { |
| 2306 | /* We do not want to modifier the long long pointer here. | 2306 | /* We do not want to modifier the long long pointer here. |
| 2307 | So we save any other instances down the stack */ | 2307 | So we save any other instances down the stack */ |
| 2308 | save_reg_upstack(S, S->vtop->r, 1); | 2308 | save_reg_upstack(S, S->tccgen_vtop->r, 1); |
| 2309 | /* load from memory */ | 2309 | /* load from memory */ |
| 2310 | S->vtop->type.t = load_type; | 2310 | S->tccgen_vtop->type.t = load_type; |
| 2311 | load(S, r, S->vtop); | 2311 | load(S, r, S->tccgen_vtop); |
| 2312 | vdup(S); | 2312 | vdup(S); |
| 2313 | S->vtop[-1].r = r; /* save register value */ | 2313 | S->tccgen_vtop[-1].r = r; /* save register value */ |
| 2314 | /* increment pointer to get second word */ | 2314 | /* increment pointer to get second word */ |
| 2315 | S->vtop->type.t = VT_PTRDIFF_T; | 2315 | S->tccgen_vtop->type.t = VT_PTRDIFF_T; |
| 2316 | gaddrof(S); | 2316 | gaddrof(S); |
| 2317 | vpushs(S, PTR_SIZE); | 2317 | vpushs(S, PTR_SIZE); |
| 2318 | gen_op(S, '+'); | 2318 | gen_op(S, '+'); |
| 2319 | S->vtop->r |= VT_LVAL; | 2319 | S->tccgen_vtop->r |= VT_LVAL; |
| 2320 | S->vtop->type.t = load_type; | 2320 | S->tccgen_vtop->type.t = load_type; |
| 2321 | } else { | 2321 | } else { |
| 2322 | /* move registers */ | 2322 | /* move registers */ |
| 2323 | if (!r_ok) | 2323 | if (!r_ok) |
| 2324 | load(S, r, S->vtop); | 2324 | load(S, r, S->tccgen_vtop); |
| 2325 | if (r2_ok && S->vtop->r2 < VT_CONST) | 2325 | if (r2_ok && S->tccgen_vtop->r2 < VT_CONST) |
| 2326 | goto done; | 2326 | goto done; |
| 2327 | vdup(S); | 2327 | vdup(S); |
| 2328 | S->vtop[-1].r = r; /* save register value */ | 2328 | S->tccgen_vtop[-1].r = r; /* save register value */ |
| 2329 | S->vtop->r = S->vtop[-1].r2; | 2329 | S->tccgen_vtop->r = S->tccgen_vtop[-1].r2; |
| 2330 | } | 2330 | } |
| 2331 | /* Allocate second register. Here we rely on the fact that | 2331 | /* Allocate second register. Here we rely on the fact that |
| 2332 | get_reg() tries first to free r2 of an SValue. */ | 2332 | get_reg() tries first to free r2 of an SValue. */ |
| 2333 | r2 = get_reg(S, rc2); | 2333 | r2 = get_reg(S, rc2); |
| 2334 | load(S, r2, S->vtop); | 2334 | load(S, r2, S->tccgen_vtop); |
| 2335 | vpop(S); | 2335 | vpop(S); |
| 2336 | /* write second register */ | 2336 | /* write second register */ |
| 2337 | S->vtop->r2 = r2; | 2337 | S->tccgen_vtop->r2 = r2; |
| 2338 | done: | 2338 | done: |
| 2339 | S->vtop->type.t = original_type; | 2339 | S->tccgen_vtop->type.t = original_type; |
| 2340 | } else { | 2340 | } else { |
| 2341 | if (S->vtop->r == VT_CMP) | 2341 | if (S->tccgen_vtop->r == VT_CMP) |
| 2342 | vset_VT_JMP(S); | 2342 | vset_VT_JMP(S); |
| 2343 | /* one register type load */ | 2343 | /* one register type load */ |
| 2344 | load(S, r, S->vtop); | 2344 | load(S, r, S->tccgen_vtop); |
| 2345 | } | 2345 | } |
| 2346 | } | 2346 | } |
| 2347 | S->vtop->r = r; | 2347 | S->tccgen_vtop->r = r; |
| 2348 | #ifdef TCC_TARGET_C67 | 2348 | #ifdef TCC_TARGET_C67 |
| 2349 | /* uses register pairs for doubles */ | 2349 | /* uses register pairs for doubles */ |
| 2350 | if (bt == VT_DOUBLE) | 2350 | if (bt == VT_DOUBLE) |
| 2351 | S->vtop->r2 = r+1; | 2351 | S->tccgen_vtop->r2 = r+1; |
| 2352 | #endif | 2352 | #endif |
| 2353 | } | 2353 | } |
| 2354 | return r; | 2354 | return r; |
| 2355 | } | 2355 | } |
| 2356 | 2356 | ||
| 2357 | /* generate vtop[-1] and vtop[0] in resp. classes rc1 and rc2 */ | 2357 | /* generate vtop[-1] and vtop[0] in resp. classes rc1 and rc2 */ |
| 2358 | ST_FUNC void gv2(TCCState *S, int rc1, int rc2) | 2358 | ST_FUNC void gv2(TCCState* S, int rc1, int rc2) |
| 2359 | { | 2359 | { |
| 2360 | /* generate more generic register first. But VT_JMP or VT_CMP | 2360 | /* generate more generic register first. But VT_JMP or VT_CMP |
| 2361 | values must be generated first in all cases to avoid possible | 2361 | values must be generated first in all cases to avoid possible |
| 2362 | reload errors */ | 2362 | reload errors */ |
| 2363 | if (S->vtop->r != VT_CMP && rc1 <= rc2) { | 2363 | if (S->tccgen_vtop->r != VT_CMP && rc1 <= rc2) { |
| 2364 | vswap(S); | 2364 | vswap(S); |
| 2365 | gv(S, rc1); | 2365 | gv(S, rc1); |
| 2366 | vswap(S); | 2366 | vswap(S); |
| 2367 | gv(S, rc2); | 2367 | gv(S, rc2); |
| 2368 | /* test if reload is needed for first register */ | 2368 | /* test if reload is needed for first register */ |
| 2369 | if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) { | 2369 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) { |
| 2370 | vswap(S); | 2370 | vswap(S); |
| 2371 | gv(S, rc1); | 2371 | gv(S, rc1); |
| 2372 | vswap(S); | 2372 | vswap(S); |
| @@ -2377,7 +2377,7 @@ ST_FUNC void gv2(TCCState *S, int rc1, int rc2) · 4 unmodified lines | |||
| 2377 | gv(S, rc1); | 2377 | gv(S, rc1); |
| 2378 | vswap(S); | 2378 | vswap(S); |
| 2379 | /* test if reload is needed for first register */ | 2379 | /* test if reload is needed for first register */ |
| 2380 | if ((S->vtop[0].r & VT_VALMASK) >= VT_CONST) { | 2380 | if ((S->tccgen_vtop[0].r & VT_VALMASK) >= VT_CONST) { |
| 2381 | gv(S, rc2); | 2381 | gv(S, rc2); |
| 2382 | } | 2382 | } |
| 2383 | } | 2383 | } |
| @@ -2385,50 +2385,50 @@ ST_FUNC void gv2(TCCState *S, int rc1, int rc2) · 1 unmodified line | |||
| 2385 | 2385 | ||
| 2386 | #if PTR_SIZE == 4 | 2386 | #if PTR_SIZE == 4 |
| 2387 | /* expand 64bit on stack in two ints */ | 2387 | /* expand 64bit on stack in two ints */ |
| 2388 | ST_FUNC void lexpand(TCCState *S) | 2388 | ST_FUNC void lexpand(TCCState* S) |
| 2389 | { | 2389 | { |
| 2390 | int u, v; | 2390 | int u, v; |
| 2391 | u = S->vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED); | 2391 | u = S->tccgen_vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED); |
| 2392 | v = S->vtop->r & (VT_VALMASK | VT_LVAL); | 2392 | v = S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL); |
| 2393 | if (v == VT_CONST) { | 2393 | if (v == VT_CONST) { |
| 2394 | vdup(S); | 2394 | vdup(S); |
| 2395 | S->vtop[0].c.i >>= 32; | 2395 | S->tccgen_vtop[0].c.i >>= 32; |
| 2396 | } else if (v == (VT_LVAL|VT_CONST) || v == (VT_LVAL|VT_LOCAL)) { | 2396 | } else if (v == (VT_LVAL|VT_CONST) || v == (VT_LVAL|VT_LOCAL)) { |
| 2397 | vdup(S); | 2397 | vdup(S); |
| 2398 | S->vtop[0].c.i += 4; | 2398 | S->tccgen_vtop[0].c.i += 4; |
| 2399 | } else { | 2399 | } else { |
| 2400 | gv(S, RC_INT); | 2400 | gv(S, RC_INT); |
| 2401 | vdup(S); | 2401 | vdup(S); |
| 2402 | S->vtop[0].r = S->vtop[-1].r2; | 2402 | S->tccgen_vtop[0].r = S->tccgen_vtop[-1].r2; |
| 2403 | S->vtop[0].r2 = S->vtop[-1].r2 = VT_CONST; | 2403 | S->tccgen_vtop[0].r2 = S->tccgen_vtop[-1].r2 = VT_CONST; |
| 2404 | } | 2404 | } |
| 2405 | S->vtop[0].type.t = S->vtop[-1].type.t = VT_INT | u; | 2405 | S->tccgen_vtop[0].type.t = S->tccgen_vtop[-1].type.t = VT_INT | u; |
| 2406 | } | 2406 | } |
| 2407 | #endif | 2407 | #endif |
| 2408 | 2408 | ||
| 2409 | #if PTR_SIZE == 4 | 2409 | #if PTR_SIZE == 4 |
| 2410 | /* build a long long from two ints */ | 2410 | /* build a long long from two ints */ |
| 2411 | static void lbuild(TCCState *S, int t) | 2411 | static void lbuild(TCCState* S, int t) |
| 2412 | { | 2412 | { |
| 2413 | gv2(S, RC_INT, RC_INT); | 2413 | gv2(S, RC_INT, RC_INT); |
| 2414 | S->vtop[-1].r2 = S->vtop[0].r; | 2414 | S->tccgen_vtop[-1].r2 = S->tccgen_vtop[0].r; |
| 2415 | S->vtop[-1].type.t = t; | 2415 | S->tccgen_vtop[-1].type.t = t; |
| 2416 | vpop(S); | 2416 | vpop(S); |
| 2417 | } | 2417 | } |
| 2418 | #endif | 2418 | #endif |
| 2419 | 2419 | ||
| 2420 | /* convert stack entry to register and duplicate its value in another | 2420 | /* convert stack entry to register and duplicate its value in another |
| 2421 | register */ | 2421 | register */ |
| 2422 | static void gv_dup(TCCState *S) | 2422 | static void gv_dup(TCCState* S) |
| 2423 | { | 2423 | { |
| 2424 | int t, rc, r; | 2424 | int t, rc, r; |
| 2425 | 2425 | ||
| 2426 | t = S->vtop->type.t; | 2426 | t = S->tccgen_vtop->type.t; |
| 2427 | #if PTR_SIZE == 4 | 2427 | #if PTR_SIZE == 4 |
| 2428 | if ((t & VT_BTYPE) == VT_LLONG) { | 2428 | if ((t & VT_BTYPE) == VT_LLONG) { |
| 2429 | if (t & VT_BITFIELD) { | 2429 | if (t & VT_BITFIELD) { |
| 2430 | gv(S, RC_INT); | 2430 | gv(S, RC_INT); |
| 2431 | t = S->vtop->type.t; | 2431 | t = S->tccgen_vtop->type.t; |
| 2432 | } | 2432 | } |
| 2433 | lexpand(S); | 2433 | lexpand(S); |
| 2434 | gv_dup(S); | 2434 | gv_dup(S); |
| @@ -2451,13 +2451,13 @@ static void gv_dup(TCCState *S) · 16 unmodified lines | |||
| 2451 | gv(S, rc); | 2451 | gv(S, rc); |
| 2452 | r = get_reg(S, rc); | 2452 | r = get_reg(S, rc); |
| 2453 | vdup(S); | 2453 | vdup(S); |
| 2454 | load(S, r, S->vtop); | 2454 | load(S, r, S->tccgen_vtop); |
| 2455 | S->vtop->r = r; | 2455 | S->tccgen_vtop->r = r; |
| 2456 | } | 2456 | } |
| 2457 | 2457 | ||
| 2458 | #if PTR_SIZE == 4 | 2458 | #if PTR_SIZE == 4 |
| 2459 | /* generate CPU independent (unsigned) long long operations */ | 2459 | /* generate CPU independent (unsigned) long long operations */ |
| 2460 | static void gen_opl(TCCState *S, int op) | 2460 | static void gen_opl(TCCState* S, int op) |
| 2461 | { | 2461 | { |
| 2462 | int t, a, b, op1, c, i; | 2462 | int t, a, b, op1, c, i; |
| 2463 | int func; | 2463 | int func; |
| @@ -2489,8 +2489,8 @@ static void gen_opl(TCCState *S, int op) · 25 unmodified lines | |||
| 2489 | vrott(S, 3); | 2489 | vrott(S, 3); |
| 2490 | gfunc_call(S, 2); | 2490 | gfunc_call(S, 2); |
| 2491 | vpushi(S, 0); | 2491 | vpushi(S, 0); |
| 2492 | S->vtop->r = reg_iret; | 2492 | S->tccgen_vtop->r = reg_iret; |
| 2493 | S->vtop->r2 = reg_lret; | 2493 | S->tccgen_vtop->r2 = reg_lret; |
| 2494 | break; | 2494 | break; |
| 2495 | case '^': | 2495 | case '^': |
| 2496 | case '&': | 2496 | case '&': |
| @@ -2499,33 +2499,33 @@ static void gen_opl(TCCState *S, int op) · 2 unmodified lines | |||
| 2499 | case '+': | 2499 | case '+': |
| 2500 | case '-': | 2500 | case '-': |
| 2501 | //pv("gen_opl A",0,2); | 2501 | //pv("gen_opl A",0,2); |
| 2502 | t = S->vtop->type.t; | 2502 | t = S->tccgen_vtop->type.t; |
| 2503 | vswap(S); | 2503 | vswap(S); |
| 2504 | lexpand(S); | 2504 | lexpand(S); |
| 2505 | vrotb(S, 3); | 2505 | vrotb(S, 3); |
| 2506 | lexpand(S); | 2506 | lexpand(S); |
| 2507 | /* stack: L1 H1 L2 H2 */ | 2507 | /* stack: L1 H1 L2 H2 */ |
| 2508 | tmp = S->vtop[0]; | 2508 | tmp = S->tccgen_vtop[0]; |
| 2509 | S->vtop[0] = S->vtop[-3]; | 2509 | S->tccgen_vtop[0] = S->tccgen_vtop[-3]; |
| 2510 | S->vtop[-3] = tmp; | 2510 | S->tccgen_vtop[-3] = tmp; |
| 2511 | tmp = S->vtop[-2]; | 2511 | tmp = S->tccgen_vtop[-2]; |
| 2512 | S->vtop[-2] = S->vtop[-3]; | 2512 | S->tccgen_vtop[-2] = S->tccgen_vtop[-3]; |
| 2513 | S->vtop[-3] = tmp; | 2513 | S->tccgen_vtop[-3] = tmp; |
| 2514 | vswap(S); | 2514 | vswap(S); |
| 2515 | /* stack: H1 H2 L1 L2 */ | 2515 | /* stack: H1 H2 L1 L2 */ |
| 2516 | //pv("gen_opl B",0,4); | 2516 | //pv("gen_opl B",0,4); |
| 2517 | if (op == '*') { | 2517 | if (op == '*') { |
| 2518 | vpushv(S, S->vtop - 1); | 2518 | vpushv(S, S->tccgen_vtop - 1); |
| 2519 | vpushv(S, S->vtop - 1); | 2519 | vpushv(S, S->tccgen_vtop - 1); |
| 2520 | gen_op(S, TOK_UMULL); | 2520 | gen_op(S, TOK_UMULL); |
| 2521 | lexpand(S); | 2521 | lexpand(S); |
| 2522 | /* stack: H1 H2 L1 L2 ML MH */ | 2522 | /* stack: H1 H2 L1 L2 ML MH */ |
| 2523 | for(i=0;i<4;i++) | 2523 | for(i=0;i<4;i++) |
| 2524 | vrotb(S, 6); | 2524 | vrotb(S, 6); |
| 2525 | /* stack: ML MH H1 H2 L1 L2 */ | 2525 | /* stack: ML MH H1 H2 L1 L2 */ |
| 2526 | tmp = S->vtop[0]; | 2526 | tmp = S->tccgen_vtop[0]; |
| 2527 | S->vtop[0] = S->vtop[-2]; | 2527 | S->tccgen_vtop[0] = S->tccgen_vtop[-2]; |
| 2528 | S->vtop[-2] = tmp; | 2528 | S->tccgen_vtop[-2] = tmp; |
| 2529 | /* stack: ML MH H1 L2 H2 L1 */ | 2529 | /* stack: ML MH H1 L2 H2 L1 */ |
| 2530 | gen_op(S, '*'); | 2530 | gen_op(S, '*'); |
| 2531 | vrotb(S, 3); | 2531 | vrotb(S, 3); |
| @@ -2560,13 +2560,13 @@ static void gen_opl(TCCState *S, int op) · 28 unmodified lines | |||
| 2560 | case TOK_SAR: | 2560 | case TOK_SAR: |
| 2561 | case TOK_SHR: | 2561 | case TOK_SHR: |
| 2562 | case TOK_SHL: | 2562 | case TOK_SHL: |
| 2563 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 2563 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 2564 | t = S->vtop[-1].type.t; | 2564 | t = S->tccgen_vtop[-1].type.t; |
| 2565 | vswap(S); | 2565 | vswap(S); |
| 2566 | lexpand(S); | 2566 | lexpand(S); |
| 2567 | vrotb(S, 3); | 2567 | vrotb(S, 3); |
| 2568 | /* stack: L H shift */ | 2568 | /* stack: L H shift */ |
| 2569 | c = (int)S->vtop->c.i; | 2569 | c = (int)S->tccgen_vtop->c.i; |
| 2570 | /* constant: simpler */ | 2570 | /* constant: simpler */ |
| 2571 | /* NOTE: all comments are for SHL. the other cases are | 2571 | /* NOTE: all comments are for SHL. the other cases are |
| 2572 | done by swapping words */ | 2572 | done by swapping words */ |
| @@ -2629,15 +2629,15 @@ static void gen_opl(TCCState *S, int op) · 56 unmodified lines | |||
| 2629 | break; | 2629 | break; |
| 2630 | default: | 2630 | default: |
| 2631 | /* compare operations */ | 2631 | /* compare operations */ |
| 2632 | t = S->vtop->type.t; | 2632 | t = S->tccgen_vtop->type.t; |
| 2633 | vswap(S); | 2633 | vswap(S); |
| 2634 | lexpand(S); | 2634 | lexpand(S); |
| 2635 | vrotb(S, 3); | 2635 | vrotb(S, 3); |
| 2636 | lexpand(S); | 2636 | lexpand(S); |
| 2637 | /* stack: L1 H1 L2 H2 */ | 2637 | /* stack: L1 H1 L2 H2 */ |
| 2638 | tmp = S->vtop[-1]; | 2638 | tmp = S->tccgen_vtop[-1]; |
| 2639 | S->vtop[-1] = S->vtop[-2]; | 2639 | S->tccgen_vtop[-1] = S->tccgen_vtop[-2]; |
| 2640 | S->vtop[-2] = tmp; | 2640 | S->tccgen_vtop[-2] = tmp; |
| 2641 | /* stack: L1 L2 H1 H2 */ | 2641 | /* stack: L1 L2 H1 H2 */ |
| 2642 | save_regs(S, 4); | 2642 | save_regs(S, 4); |
| 2643 | /* compare high */ | 2643 | /* compare high */ |
| @@ -2701,10 +2701,10 @@ static int gen_opic_lt(uint64_t a, uint64_t b) · 57 unmodified lines | |||
| 2701 | 2701 | ||
| 2702 | /* handle integer constant optimizations and various machine | 2702 | /* handle integer constant optimizations and various machine |
| 2703 | independent opt */ | 2703 | independent opt */ |
| 2704 | static void gen_opic(TCCState *S, int op) | 2704 | static void gen_opic(TCCState* S, int op) |
| 2705 | { | 2705 | { |
| 2706 | SValue *v1 = S->vtop - 1; | 2706 | SValue *v1 = S->tccgen_vtop - 1; |
| 2707 | SValue *v2 = S->vtop; | 2707 | SValue *v2 = S->tccgen_vtop; |
| 2708 | int t1 = v1->type.t & VT_BTYPE; | 2708 | int t1 = v1->type.t & VT_BTYPE; |
| 2709 | int t2 = v2->type.t & VT_BTYPE; | 2709 | int t2 = v2->type.t & VT_BTYPE; |
| 2710 | int c1 = (v1->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST; | 2710 | int c1 = (v1->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST; |
| @@ -2736,7 +2736,7 @@ static void gen_opic(TCCState *S, int op) · 25 unmodified lines | |||
| 2736 | case TOK_UMOD: | 2736 | case TOK_UMOD: |
| 2737 | /* if division by zero, generate explicit division */ | 2737 | /* if division by zero, generate explicit division */ |
| 2738 | if (l2 == 0) { | 2738 | if (l2 == 0) { |
| 2739 | if (S->tccgen_const_wanted && !(S->nocode_wanted & unevalmask)) | 2739 | if (S->tccgen_const_wanted && !(S->tccgen_nocode_wanted & unevalmask)) |
| 2740 | tcc_error(S, "division by zero in constant"); | 2740 | tcc_error(S, "division by zero in constant"); |
| 2741 | goto general_case; | 2741 | goto general_case; |
| 2742 | } | 2742 | } |
| @@ -2773,7 +2773,7 @@ static void gen_opic(TCCState *S, int op) · 30 unmodified lines | |||
| 2773 | l1 = ((uint32_t)l1 | | 2773 | l1 = ((uint32_t)l1 | |
| 2774 | (v1->type.t & VT_UNSIGNED ? 0 : -(l1 & 0x80000000))); | 2774 | (v1->type.t & VT_UNSIGNED ? 0 : -(l1 & 0x80000000))); |
| 2775 | v1->c.i = l1; | 2775 | v1->c.i = l1; |
| 2776 | S->vtop--; | 2776 | S->tccgen_vtop--; |
| 2777 | } else { | 2777 | } else { |
| 2778 | /* if commutative ops, put c2 as constant */ | 2778 | /* if commutative ops, put c2 as constant */ |
| 2779 | if (c1 && (op == '+' || op == '&' || op == '^' || | 2779 | if (c1 && (op == '+' || op == '&' || op == '^' || |
| @@ -2787,7 +2787,7 @@ static void gen_opic(TCCState *S, int op) · 7 unmodified lines | |||
| 2787 | (op == TOK_SHL || op == TOK_SHR || op == TOK_SAR)) || | 2787 | (op == TOK_SHL || op == TOK_SHR || op == TOK_SAR)) || |
| 2788 | (l1 == -1 && op == TOK_SAR))) { | 2788 | (l1 == -1 && op == TOK_SAR))) { |
| 2789 | /* treat (0 << x), (0 >> x) and (-1 >> x) as constant */ | 2789 | /* treat (0 << x), (0 >> x) and (-1 >> x) as constant */ |
| 2790 | S->vtop--; | 2790 | S->tccgen_vtop--; |
| 2791 | } else if (!S->tccgen_const_wanted && | 2791 | } else if (!S->tccgen_const_wanted && |
| 2792 | c2 && ((l2 == 0 && (op == '&' || op == '*')) || | 2792 | c2 && ((l2 == 0 && (op == '&' || op == '*')) || |
| 2793 | (op == '|' && | 2793 | (op == '|' && |
| @@ -2795,9 +2795,9 @@ static void gen_opic(TCCState *S, int op) · 1 unmodified line | |||
| 2795 | (l2 == 1 && (op == '%' || op == TOK_UMOD)))) { | 2795 | (l2 == 1 && (op == '%' || op == TOK_UMOD)))) { |
| 2796 | /* treat (x & 0), (x * 0), (x | -1) and (x % 1) as constant */ | 2796 | /* treat (x & 0), (x * 0), (x | -1) and (x % 1) as constant */ |
| 2797 | if (l2 == 1) | 2797 | if (l2 == 1) |
| 2798 | S->vtop->c.i = 0; | 2798 | S->tccgen_vtop->c.i = 0; |
| 2799 | vswap(S); | 2799 | vswap(S); |
| 2800 | S->vtop--; | 2800 | S->tccgen_vtop--; |
| 2801 | } else if (c2 && (((op == '*' || op == '/' || op == TOK_UDIV || | 2801 | } else if (c2 && (((op == '*' || op == '/' || op == TOK_UDIV || |
| 2802 | op == TOK_PDIV) && | 2802 | op == TOK_PDIV) && |
| 2803 | l2 == 1) || | 2803 | l2 == 1) || |
| @@ -2807,7 +2807,7 @@ static void gen_opic(TCCState *S, int op) · 3 unmodified lines | |||
| 2807 | (op == '&' && | 2807 | (op == '&' && |
| 2808 | (l2 == -1 || (l2 == 0xFFFFFFFF && t2 != VT_LLONG))))) { | 2808 | (l2 == -1 || (l2 == 0xFFFFFFFF && t2 != VT_LLONG))))) { |
| 2809 | /* filter out NOP operations like x*1, x-0, x&-1... */ | 2809 | /* filter out NOP operations like x*1, x-0, x&-1... */ |
| 2810 | S->vtop--; | 2810 | S->tccgen_vtop--; |
| 2811 | } else if (c2 && (op == '*' || op == TOK_PDIV || op == TOK_UDIV)) { | 2811 | } else if (c2 && (op == '*' || op == TOK_PDIV || op == TOK_UDIV)) { |
| 2812 | /* try to use shifts instead of muls or divs */ | 2812 | /* try to use shifts instead of muls or divs */ |
| 2813 | if (l2 > 0 && (l2 & (l2 - 1)) == 0) { | 2813 | if (l2 > 0 && (l2 & (l2 - 1)) == 0) { |
| @@ -2816,7 +2816,7 @@ static void gen_opic(TCCState *S, int op) · 2 unmodified lines | |||
| 2816 | l2 >>= 1; | 2816 | l2 >>= 1; |
| 2817 | n++; | 2817 | n++; |
| 2818 | } | 2818 | } |
| 2819 | S->vtop->c.i = n; | 2819 | S->tccgen_vtop->c.i = n; |
| 2820 | if (op == '*') | 2820 | if (op == '*') |
| 2821 | op = TOK_SHL; | 2821 | op = TOK_SHL; |
| 2822 | else if (op == TOK_PDIV) | 2822 | else if (op == TOK_PDIV) |
| @@ -2826,18 +2826,18 @@ static void gen_opic(TCCState *S, int op) · 3 unmodified lines | |||
| 2826 | } | 2826 | } |
| 2827 | goto general_case; | 2827 | goto general_case; |
| 2828 | } else if (c2 && (op == '+' || op == '-') && | 2828 | } else if (c2 && (op == '+' || op == '-') && |
| 2829 | (((S->vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == (VT_CONST | VT_SYM)) | 2829 | (((S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == (VT_CONST | VT_SYM)) |
| 2830 | || (S->vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_LOCAL)) { | 2830 | || (S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_LOCAL)) { |
| 2831 | /* symbol + constant case */ | 2831 | /* symbol + constant case */ |
| 2832 | if (op == '-') | 2832 | if (op == '-') |
| 2833 | l2 = -l2; | 2833 | l2 = -l2; |
| 2834 | l2 += S->vtop[-1].c.i; | 2834 | l2 += S->tccgen_vtop[-1].c.i; |
| 2835 | /* The backends can't always deal with addends to symbols | 2835 | /* The backends can't always deal with addends to symbols |
| 2836 | larger than +-1<<31. Don't construct such. */ | 2836 | larger than +-1<<31. Don't construct such. */ |
| 2837 | if ((int)l2 != l2) | 2837 | if ((int)l2 != l2) |
| 2838 | goto general_case; | 2838 | goto general_case; |
| 2839 | S->vtop--; | 2839 | S->tccgen_vtop--; |
| 2840 | S->vtop->c.i = l2; | 2840 | S->tccgen_vtop->c.i = l2; |
| 2841 | } else { | 2841 | } else { |
| 2842 | general_case: | 2842 | general_case: |
| 2843 | /* call low level op generator */ | 2843 | /* call low level op generator */ |
| @@ -2853,14 +2853,14 @@ static void gen_opic(TCCState *S, int op) · 9 unmodified lines | |||
| 2853 | #if defined TCC_TARGET_X86_64 || defined TCC_TARGET_I386 | 2853 | #if defined TCC_TARGET_X86_64 || defined TCC_TARGET_I386 |
| 2854 | # define gen_negf gen_opf | 2854 | # define gen_negf gen_opf |
| 2855 | #elif defined TCC_TARGET_ARM | 2855 | #elif defined TCC_TARGET_ARM |
| 2856 | void gen_negf(TCCState *S, int op) | 2856 | void gen_negf(TCCState* S, int op) |
| 2857 | { | 2857 | { |
| 2858 | /* arm will detect 0-x and replace by vneg */ | 2858 | /* arm will detect 0-x and replace by vneg */ |
| 2859 | vpushi(S, 0), vswap(S), gen_op(S, '-'); | 2859 | vpushi(S, 0), vswap(S), gen_op(S, '-'); |
| 2860 | } | 2860 | } |
| 2861 | #else | 2861 | #else |
| 2862 | /* XXX: implement in gen_opf() for other backends too */ | 2862 | /* XXX: implement in gen_opf() for other backends too */ |
| 2863 | void gen_negf(TCCState *S, int op) | 2863 | void gen_negf(TCCState* S, int op) |
| 2864 | { | 2864 | { |
| 2865 | /* In IEEE negate(x) isn't subtract(0,x). Without NaNs it's | 2865 | /* In IEEE negate(x) isn't subtract(0,x). Without NaNs it's |
| 2866 | subtract(-0, x), but with them it's really a sign flip | 2866 | subtract(-0, x), but with them it's really a sign flip |
| @@ -2870,8 +2870,8 @@ void gen_negf(TCCState *S, int op) · 3 unmodified lines | |||
| 2870 | 2870 | ||
| 2871 | int align, size, bt; | 2871 | int align, size, bt; |
| 2872 | 2872 | ||
| 2873 | size = type_size(&S->vtop->type, &align); | 2873 | size = type_size(&S->tccgen_vtop->type, &align); |
| 2874 | bt = S->vtop->type.t & VT_BTYPE; | 2874 | bt = S->tccgen_vtop->type.t & VT_BTYPE; |
| 2875 | save_reg(S, gv(S, RC_TYPE(bt))); | 2875 | save_reg(S, gv(S, RC_TYPE(bt))); |
| 2876 | vdup(S); | 2876 | vdup(S); |
| 2877 | incr_bf_adr(S, size - 1); | 2877 | incr_bf_adr(S, size - 1); |
| @@ -2884,7 +2884,7 @@ void gen_negf(TCCState *S, int op) · 6 unmodified lines | |||
| 2884 | #endif | 2884 | #endif |
| 2885 | 2885 | ||
| 2886 | /* generate a floating point operation with constant propagation */ | 2886 | /* generate a floating point operation with constant propagation */ |
| 2887 | static void gen_opif(TCCState *S, int op) | 2887 | static void gen_opif(TCCState* S, int op) |
| 2888 | { | 2888 | { |
| 2889 | int c1, c2; | 2889 | int c1, c2; |
| 2890 | SValue *v1, *v2; | 2890 | SValue *v1, *v2; |
| @@ -2894,8 +2894,8 @@ static void gen_opif(TCCState *S, int op) · 3 unmodified lines | |||
| 2894 | #endif | 2894 | #endif |
| 2895 | long double f1, f2; | 2895 | long double f1, f2; |
| 2896 | 2896 | ||
| 2897 | v1 = S->vtop - 1; | 2897 | v1 = S->tccgen_vtop - 1; |
| 2898 | v2 = S->vtop; | 2898 | v2 = S->tccgen_vtop; |
| 2899 | if (op == TOK_NEG) | 2899 | if (op == TOK_NEG) |
| 2900 | v1 = v2; | 2900 | v1 = v2; |
| 2901 | 2901 | ||
| @@ -2948,7 +2948,7 @@ static void gen_opif(TCCState *S, int op) · 46 unmodified lines | |||
| 2948 | default: | 2948 | default: |
| 2949 | goto general_case; | 2949 | goto general_case; |
| 2950 | } | 2950 | } |
| 2951 | S->vtop--; | 2951 | S->tccgen_vtop--; |
| 2952 | unary_result: | 2952 | unary_result: |
| 2953 | /* XXX: overflow test ? */ | 2953 | /* XXX: overflow test ? */ |
| 2954 | if (v1->type.t == VT_FLOAT) { | 2954 | if (v1->type.t == VT_FLOAT) { |
| @@ -2972,7 +2972,7 @@ static void gen_opif(TCCState *S, int op) · 17 unmodified lines | |||
| 2972 | printed in the type */ | 2972 | printed in the type */ |
| 2973 | /* XXX: union */ | 2973 | /* XXX: union */ |
| 2974 | /* XXX: add array and function pointers */ | 2974 | /* XXX: add array and function pointers */ |
| 2975 | static void type_to_str(TCCState *S, char *buf, int buf_size, | 2975 | static void type_to_str(TCCState* S, char *buf, int buf_size, |
| 2976 | CType *type, const char *varstr) | 2976 | CType *type, const char *varstr) |
| 2977 | { | 2977 | { |
| 2978 | int bt, v, t; | 2978 | int bt, v, t; |
| @@ -3107,7 +3107,7 @@ static void type_to_str(TCCState *S, char *buf, int buf_size, · 128 unmodified lines | |||
| 3107 | no_var: ; | 3107 | no_var: ; |
| 3108 | } | 3108 | } |
| 3109 | 3109 | ||
| 3110 | static void type_incompatibility_error(TCCState *S, CType* st, CType* dt, const char* fmt) | 3110 | static void type_incompatibility_error(TCCState* S, CType* st, CType* dt, const char* fmt) |
| 3111 | { | 3111 | { |
| 3112 | char buf1[256], buf2[256]; | 3112 | char buf1[256], buf2[256]; |
| 3113 | type_to_str(S, buf1, sizeof(buf1), st, NULL); | 3113 | type_to_str(S, buf1, sizeof(buf1), st, NULL); |
| @@ -3115,7 +3115,7 @@ static void type_incompatibility_error(TCCState *S, CType* st, CType* dt, const · 1 unmodified line | |||
| 3115 | tcc_error(S, fmt, buf1, buf2); | 3115 | tcc_error(S, fmt, buf1, buf2); |
| 3116 | } | 3116 | } |
| 3117 | 3117 | ||
| 3118 | static void type_incompatibility_warning(TCCState *S, CType* st, CType* dt, const char* fmt) | 3118 | static void type_incompatibility_warning(TCCState* S, CType* st, CType* dt, const char* fmt) |
| 3119 | { | 3119 | { |
| 3120 | char buf1[256], buf2[256]; | 3120 | char buf1[256], buf2[256]; |
| 3121 | type_to_str(S, buf1, sizeof(buf1), st, NULL); | 3121 | type_to_str(S, buf1, sizeof(buf1), st, NULL); |
| @@ -3129,7 +3129,7 @@ static int pointed_size(CType *type) · 7 unmodified lines | |||
| 3129 | return type_size(pointed_type(type), &align); | 3129 | return type_size(pointed_type(type), &align); |
| 3130 | } | 3130 | } |
| 3131 | 3131 | ||
| 3132 | static void vla_runtime_pointed_size(TCCState *S, CType *type) | 3132 | static void vla_runtime_pointed_size(TCCState* S, CType *type) |
| 3133 | { | 3133 | { |
| 3134 | int align; | 3134 | int align; |
| 3135 | vla_runtime_type_size(S, pointed_type(type), &align); | 3135 | vla_runtime_type_size(S, pointed_type(type), &align); |
| @@ -3226,7 +3226,7 @@ static int compare_types(CType *type1, CType *type2, int unqualified) · 90 unmodified lines | |||
| 3226 | 3226 | ||
| 3227 | /* Check if OP1 and OP2 can be "combined" with operation OP, the combined | 3227 | /* Check if OP1 and OP2 can be "combined" with operation OP, the combined |
| 3228 | type is stored in DEST if non-null (except for pointer plus/minus) . */ | 3228 | type is stored in DEST if non-null (except for pointer plus/minus) . */ |
| 3229 | static int combine_types(TCCState *S, CType *dest, SValue *op1, SValue *op2, int op) | 3229 | static int combine_types(TCCState* S, CType *dest, SValue *op1, SValue *op2, int op) |
| 3230 | { | 3230 | { |
| 3231 | CType *type1 = &op1->type, *type2 = &op2->type, type; | 3231 | CType *type1 = &op1->type, *type2 = &op2->type, type; |
| 3232 | int t1 = type1->t, t2 = type2->t, bt1 = t1 & VT_BTYPE, bt2 = t2 & VT_BTYPE; | 3232 | int t1 = type1->t, t2 = type2->t, bt1 = t1 & VT_BTYPE, bt2 = t2 & VT_BTYPE; |
| @@ -3343,30 +3343,30 @@ static int combine_types(TCCState *S, CType *dest, SValue *op1, SValue *op2, int · 110 unmodified lines | |||
| 3343 | } | 3343 | } |
| 3344 | 3344 | ||
| 3345 | /* generic gen_op: handles types problems */ | 3345 | /* generic gen_op: handles types problems */ |
| 3346 | ST_FUNC void gen_op(TCCState *S, int op) | 3346 | ST_FUNC void gen_op(TCCState* S, int op) |
| 3347 | { | 3347 | { |
| 3348 | int u, t1, t2, bt1, bt2, t; | 3348 | int u, t1, t2, bt1, bt2, t; |
| 3349 | CType type1, combtype; | 3349 | CType type1, combtype; |
| 3350 | 3350 | ||
| 3351 | redo: | 3351 | redo: |
| 3352 | t1 = S->vtop[-1].type.t; | 3352 | t1 = S->tccgen_vtop[-1].type.t; |
| 3353 | t2 = S->vtop[0].type.t; | 3353 | t2 = S->tccgen_vtop[0].type.t; |
| 3354 | bt1 = t1 & VT_BTYPE; | 3354 | bt1 = t1 & VT_BTYPE; |
| 3355 | bt2 = t2 & VT_BTYPE; | 3355 | bt2 = t2 & VT_BTYPE; |
| 3356 | 3356 | ||
| 3357 | if (bt1 == VT_FUNC || bt2 == VT_FUNC) { | 3357 | if (bt1 == VT_FUNC || bt2 == VT_FUNC) { |
| 3358 | if (bt2 == VT_FUNC) { | 3358 | if (bt2 == VT_FUNC) { |
| 3359 | mk_pointer(S, &S->vtop->type); | 3359 | mk_pointer(S, &S->tccgen_vtop->type); |
| 3360 | gaddrof(S); | 3360 | gaddrof(S); |
| 3361 | } | 3361 | } |
| 3362 | if (bt1 == VT_FUNC) { | 3362 | if (bt1 == VT_FUNC) { |
| 3363 | vswap(S); | 3363 | vswap(S); |
| 3364 | mk_pointer(S, &S->vtop->type); | 3364 | mk_pointer(S, &S->tccgen_vtop->type); |
| 3365 | gaddrof(S); | 3365 | gaddrof(S); |
| 3366 | vswap(S); | 3366 | vswap(S); |
| 3367 | } | 3367 | } |
| 3368 | goto redo; | 3368 | goto redo; |
| 3369 | } else if (!combine_types(S, &combtype, S->vtop - 1, S->vtop, op)) { | 3369 | } else if (!combine_types(S, &combtype, S->tccgen_vtop - 1, S->tccgen_vtop, op)) { |
| 3370 | tcc_error_noabort(S, "invalid operand types for binary operation"); | 3370 | tcc_error_noabort(S, "invalid operand types for binary operation"); |
| 3371 | vpop(S); | 3371 | vpop(S); |
| 3372 | } else if (bt1 == VT_PTR || bt2 == VT_PTR) { | 3372 | } else if (bt1 == VT_PTR || bt2 == VT_PTR) { |
| @@ -3378,14 +3378,14 @@ redo: · 5 unmodified lines | |||
| 3378 | if (bt1 == VT_PTR && bt2 == VT_PTR) { | 3378 | if (bt1 == VT_PTR && bt2 == VT_PTR) { |
| 3379 | if (op != '-') | 3379 | if (op != '-') |
| 3380 | tcc_error(S, "cannot use pointers here"); | 3380 | tcc_error(S, "cannot use pointers here"); |
| 3381 | if (S->vtop[-1].type.t & VT_VLA) { | 3381 | if (S->tccgen_vtop[-1].type.t & VT_VLA) { |
| 3382 | vla_runtime_pointed_size(S, &S->vtop[-1].type); | 3382 | vla_runtime_pointed_size(S, &S->tccgen_vtop[-1].type); |
| 3383 | } else { | 3383 | } else { |
| 3384 | vpushi(S, pointed_size(&S->vtop[-1].type)); | 3384 | vpushi(S, pointed_size(&S->tccgen_vtop[-1].type)); |
| 3385 | } | 3385 | } |
| 3386 | vrott(S, 3); | 3386 | vrott(S, 3); |
| 3387 | gen_opic(S, op); | 3387 | gen_opic(S, op); |
| 3388 | S->vtop->type.t = VT_PTRDIFF_T; | 3388 | S->tccgen_vtop->type.t = VT_PTRDIFF_T; |
| 3389 | vswap(S); | 3389 | vswap(S); |
| 3390 | gen_op(S, TOK_PDIV); | 3390 | gen_op(S, TOK_PDIV); |
| 3391 | } else { | 3391 | } else { |
| @@ -3398,15 +3398,15 @@ redo: · 6 unmodified lines | |||
| 3398 | t = t1, t1 = t2, t2 = t; | 3398 | t = t1, t1 = t2, t2 = t; |
| 3399 | } | 3399 | } |
| 3400 | #if PTR_SIZE == 4 | 3400 | #if PTR_SIZE == 4 |
| 3401 | if ((S->vtop[0].type.t & VT_BTYPE) == VT_LLONG) | 3401 | if ((S->tccgen_vtop[0].type.t & VT_BTYPE) == VT_LLONG) |
| 3402 | /* XXX: truncate here because gen_opl can't handle ptr + long long */ | 3402 | /* XXX: truncate here because gen_opl can't handle ptr + long long */ |
| 3403 | gen_cast_s(S, VT_INT); | 3403 | gen_cast_s(S, VT_INT); |
| 3404 | #endif | 3404 | #endif |
| 3405 | type1 = S->vtop[-1].type; | 3405 | type1 = S->tccgen_vtop[-1].type; |
| 3406 | if (S->vtop[-1].type.t & VT_VLA) | 3406 | if (S->tccgen_vtop[-1].type.t & VT_VLA) |
| 3407 | vla_runtime_pointed_size(S, &S->vtop[-1].type); | 3407 | vla_runtime_pointed_size(S, &S->tccgen_vtop[-1].type); |
| 3408 | else { | 3408 | else { |
| 3409 | u = pointed_size(&S->vtop[-1].type); | 3409 | u = pointed_size(&S->tccgen_vtop[-1].type); |
| 3410 | if (u < 0) | 3410 | if (u < 0) |
| 3411 | tcc_error(S, "unknown array element size"); | 3411 | tcc_error(S, "unknown array element size"); |
| 3412 | #if PTR_SIZE == 8 | 3412 | #if PTR_SIZE == 8 |
| @@ -3434,7 +3434,7 @@ redo: · 21 unmodified lines | |||
| 3434 | } | 3434 | } |
| 3435 | type1.t &= ~VT_ARRAY; | 3435 | type1.t &= ~VT_ARRAY; |
| 3436 | /* put again type if gen_opic() swaped operands */ | 3436 | /* put again type if gen_opic() swaped operands */ |
| 3437 | S->vtop->type = type1; | 3437 | S->tccgen_vtop->type = type1; |
| 3438 | } | 3438 | } |
| 3439 | } else { | 3439 | } else { |
| 3440 | /* floats can only be used for a few operations */ | 3440 | /* floats can only be used for a few operations */ |
| @@ -3483,23 +3483,23 @@ redo: · 42 unmodified lines | |||
| 3483 | gen_opic(S, op); | 3483 | gen_opic(S, op); |
| 3484 | if (TOK_ISCOND(op)) { | 3484 | if (TOK_ISCOND(op)) { |
| 3485 | /* relational op: the result is an int */ | 3485 | /* relational op: the result is an int */ |
| 3486 | S->vtop->type.t = VT_INT; | 3486 | S->tccgen_vtop->type.t = VT_INT; |
| 3487 | } else { | 3487 | } else { |
| 3488 | S->vtop->type.t = t; | 3488 | S->tccgen_vtop->type.t = t; |
| 3489 | } | 3489 | } |
| 3490 | } | 3490 | } |
| 3491 | // Make sure that we have converted to an rvalue: | 3491 | // Make sure that we have converted to an rvalue: |
| 3492 | if (S->vtop->r & VT_LVAL) | 3492 | if (S->tccgen_vtop->r & VT_LVAL) |
| 3493 | gv(S, is_float(S->vtop->type.t & VT_BTYPE) ? RC_FLOAT : RC_INT); | 3493 | gv(S, is_float(S->tccgen_vtop->type.t & VT_BTYPE) ? RC_FLOAT : RC_INT); |
| 3494 | } | 3494 | } |
| 3495 | 3495 | ||
| 3496 | #if defined TCC_TARGET_ARM64 || defined TCC_TARGET_RISCV64 || defined TCC_TARGET_ARM | 3496 | #if defined TCC_TARGET_ARM64 || defined TCC_TARGET_RISCV64 || defined TCC_TARGET_ARM |
| 3497 | #define gen_cvt_itof1 gen_cvt_itof | 3497 | #define gen_cvt_itof1 gen_cvt_itof |
| 3498 | #else | 3498 | #else |
| 3499 | /* generic itof for unsigned long long case */ | 3499 | /* generic itof for unsigned long long case */ |
| 3500 | static void gen_cvt_itof1(TCCState *S, int t) | 3500 | static void gen_cvt_itof1(TCCState* S, int t) |
| 3501 | { | 3501 | { |
| 3502 | if ((S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == | 3502 | if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == |
| 3503 | (VT_LLONG | VT_UNSIGNED)) { | 3503 | (VT_LLONG | VT_UNSIGNED)) { |
| 3504 | 3504 | ||
| 3505 | if (t == VT_FLOAT) | 3505 | if (t == VT_FLOAT) |
| @@ -3513,7 +3513,7 @@ static void gen_cvt_itof1(TCCState *S, int t) · 7 unmodified lines | |||
| 3513 | vrott(S, 2); | 3513 | vrott(S, 2); |
| 3514 | gfunc_call(S, 1); | 3514 | gfunc_call(S, 1); |
| 3515 | vpushi(S, 0); | 3515 | vpushi(S, 0); |
| 3516 | PUT_R_RET(S->vtop, t); | 3516 | PUT_R_RET(S->tccgen_vtop, t); |
| 3517 | } else { | 3517 | } else { |
| 3518 | gen_cvt_itof(S, t); | 3518 | gen_cvt_itof(S, t); |
| 3519 | } | 3519 | } |
| @@ -3524,12 +3524,12 @@ static void gen_cvt_itof1(TCCState *S, int t) · 4 unmodified lines | |||
| 3524 | #define gen_cvt_ftoi1 gen_cvt_ftoi | 3524 | #define gen_cvt_ftoi1 gen_cvt_ftoi |
| 3525 | #else | 3525 | #else |
| 3526 | /* generic ftoi for unsigned long long case */ | 3526 | /* generic ftoi for unsigned long long case */ |
| 3527 | static void gen_cvt_ftoi1(TCCState *S, int t) | 3527 | static void gen_cvt_ftoi1(TCCState* S, int t) |
| 3528 | { | 3528 | { |
| 3529 | int st; | 3529 | int st; |
| 3530 | if (t == (VT_LLONG | VT_UNSIGNED)) { | 3530 | if (t == (VT_LLONG | VT_UNSIGNED)) { |
| 3531 | /* not handled natively */ | 3531 | /* not handled natively */ |
| 3532 | st = S->vtop->type.t & VT_BTYPE; | 3532 | st = S->tccgen_vtop->type.t & VT_BTYPE; |
| 3533 | if (st == VT_FLOAT) | 3533 | if (st == VT_FLOAT) |
| 3534 | vpush_helper_func(S, TOK___fixunssfdi); | 3534 | vpush_helper_func(S, TOK___fixunssfdi); |
| 3535 | #if LDOUBLE_SIZE != 8 | 3535 | #if LDOUBLE_SIZE != 8 |
| @@ -3541,7 +3541,7 @@ static void gen_cvt_ftoi1(TCCState *S, int t) · 5 unmodified lines | |||
| 3541 | vrott(S, 2); | 3541 | vrott(S, 2); |
| 3542 | gfunc_call(S, 1); | 3542 | gfunc_call(S, 1); |
| 3543 | vpushi(S, 0); | 3543 | vpushi(S, 0); |
| 3544 | PUT_R_RET(S->vtop, t); | 3544 | PUT_R_RET(S->tccgen_vtop, t); |
| 3545 | } else { | 3545 | } else { |
| 3546 | gen_cvt_ftoi(S, t); | 3546 | gen_cvt_ftoi(S, t); |
| 3547 | } | 3547 | } |
| @@ -3549,17 +3549,17 @@ static void gen_cvt_ftoi1(TCCState *S, int t) · 1 unmodified line | |||
| 3549 | #endif | 3549 | #endif |
| 3550 | 3550 | ||
| 3551 | /* special delayed cast for char/short */ | 3551 | /* special delayed cast for char/short */ |
| 3552 | static void force_charshort_cast(TCCState *S) | 3552 | static void force_charshort_cast(TCCState* S) |
| 3553 | { | 3553 | { |
| 3554 | int sbt = BFGET(S->vtop->r, VT_MUSTCAST) == 2 ? VT_LLONG : VT_INT; | 3554 | int sbt = BFGET(S->tccgen_vtop->r, VT_MUSTCAST) == 2 ? VT_LLONG : VT_INT; |
| 3555 | int dbt = S->vtop->type.t; | 3555 | int dbt = S->tccgen_vtop->type.t; |
| 3556 | S->vtop->r &= ~VT_MUSTCAST; | 3556 | S->tccgen_vtop->r &= ~VT_MUSTCAST; |
| 3557 | S->vtop->type.t = sbt; | 3557 | S->tccgen_vtop->type.t = sbt; |
| 3558 | gen_cast_s(S, dbt == VT_BOOL ? VT_BYTE|VT_UNSIGNED : dbt); | 3558 | gen_cast_s(S, dbt == VT_BOOL ? VT_BYTE|VT_UNSIGNED : dbt); |
| 3559 | S->vtop->type.t = dbt; | 3559 | S->tccgen_vtop->type.t = dbt; |
| 3560 | } | 3560 | } |
| 3561 | 3561 | ||
| 3562 | static void gen_cast_s(TCCState *S, int t) | 3562 | static void gen_cast_s(TCCState* S, int t) |
| 3563 | { | 3563 | { |
| 3564 | CType type; | 3564 | CType type; |
| 3565 | type.t = t; | 3565 | type.t = t; |
| @@ -3568,21 +3568,21 @@ static void gen_cast_s(TCCState *S, int t) · 2 unmodified lines | |||
| 3568 | } | 3568 | } |
| 3569 | 3569 | ||
| 3570 | /* cast 'vtop' to 'type'. Casting to bitfields is forbidden. */ | 3570 | /* cast 'vtop' to 'type'. Casting to bitfields is forbidden. */ |
| 3571 | static void gen_cast(TCCState *S, CType *type) | 3571 | static void gen_cast(TCCState* S, CType *type) |
| 3572 | { | 3572 | { |
| 3573 | int sbt, dbt, sf, df, c; | 3573 | int sbt, dbt, sf, df, c; |
| 3574 | int dbt_bt, sbt_bt, ds, ss, bits, trunc; | 3574 | int dbt_bt, sbt_bt, ds, ss, bits, trunc; |
| 3575 | 3575 | ||
| 3576 | /* special delayed cast for char/short */ | 3576 | /* special delayed cast for char/short */ |
| 3577 | if (S->vtop->r & VT_MUSTCAST) | 3577 | if (S->tccgen_vtop->r & VT_MUSTCAST) |
| 3578 | force_charshort_cast(S); | 3578 | force_charshort_cast(S); |
| 3579 | 3579 | ||
| 3580 | /* bitfields first get cast to ints */ | 3580 | /* bitfields first get cast to ints */ |
| 3581 | if (S->vtop->type.t & VT_BITFIELD) | 3581 | if (S->tccgen_vtop->type.t & VT_BITFIELD) |
| 3582 | gv(S, RC_INT); | 3582 | gv(S, RC_INT); |
| 3583 | 3583 | ||
| 3584 | dbt = type->t & (VT_BTYPE | VT_UNSIGNED); | 3584 | dbt = type->t & (VT_BTYPE | VT_UNSIGNED); |
| 3585 | sbt = S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED); | 3585 | sbt = S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED); |
| 3586 | if (sbt == VT_FUNC) | 3586 | if (sbt == VT_FUNC) |
| 3587 | sbt = VT_PTR; | 3587 | sbt = VT_PTR; |
| 3588 | 3588 | ||
| @@ -3596,71 +3596,71 @@ again: · 7 unmodified lines | |||
| 3596 | goto done; | 3596 | goto done; |
| 3597 | if (sbt_bt == VT_VOID) { | 3597 | if (sbt_bt == VT_VOID) { |
| 3598 | error: | 3598 | error: |
| 3599 | cast_error(S, &S->vtop->type, type); | 3599 | cast_error(S, &S->tccgen_vtop->type, type); |
| 3600 | } | 3600 | } |
| 3601 | 3601 | ||
| 3602 | c = (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST; | 3602 | c = (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST; |
| 3603 | #if !defined TCC_IS_NATIVE && !defined TCC_IS_NATIVE_387 | 3603 | #if !defined TCC_IS_NATIVE && !defined TCC_IS_NATIVE_387 |
| 3604 | c &= (dbt != VT_LDOUBLE) | !!S->nocode_wanted; | 3604 | c &= (dbt != VT_LDOUBLE) | !!S->tccgen_nocode_wanted; |
| 3605 | #endif | 3605 | #endif |
| 3606 | if (c) { | 3606 | if (c) { |
| 3607 | /* constant case: we can do it now */ | 3607 | /* constant case: we can do it now */ |
| 3608 | /* XXX: in ISOC, cannot do it if error in convert */ | 3608 | /* XXX: in ISOC, cannot do it if error in convert */ |
| 3609 | if (sbt == VT_FLOAT) | 3609 | if (sbt == VT_FLOAT) |
| 3610 | S->vtop->c.ld = S->vtop->c.f; | 3610 | S->tccgen_vtop->c.ld = S->tccgen_vtop->c.f; |
| 3611 | else if (sbt == VT_DOUBLE) | 3611 | else if (sbt == VT_DOUBLE) |
| 3612 | S->vtop->c.ld = S->vtop->c.d; | 3612 | S->tccgen_vtop->c.ld = S->tccgen_vtop->c.d; |
| 3613 | 3613 | ||
| 3614 | if (df) { | 3614 | if (df) { |
| 3615 | if (sbt_bt == VT_LLONG) { | 3615 | if (sbt_bt == VT_LLONG) { |
| 3616 | if ((sbt & VT_UNSIGNED) || !(S->vtop->c.i >> 63)) | 3616 | if ((sbt & VT_UNSIGNED) || !(S->tccgen_vtop->c.i >> 63)) |
| 3617 | S->vtop->c.ld = S->vtop->c.i; | 3617 | S->tccgen_vtop->c.ld = S->tccgen_vtop->c.i; |
| 3618 | else | 3618 | else |
| 3619 | S->vtop->c.ld = -(long double)-S->vtop->c.i; | 3619 | S->tccgen_vtop->c.ld = -(long double)-S->tccgen_vtop->c.i; |
| 3620 | } else if(!sf) { | 3620 | } else if(!sf) { |
| 3621 | if ((sbt & VT_UNSIGNED) || !(S->vtop->c.i >> 31)) | 3621 | if ((sbt & VT_UNSIGNED) || !(S->tccgen_vtop->c.i >> 31)) |
| 3622 | S->vtop->c.ld = (uint32_t)S->vtop->c.i; | 3622 | S->tccgen_vtop->c.ld = (uint32_t)S->tccgen_vtop->c.i; |
| 3623 | else | 3623 | else |
| 3624 | S->vtop->c.ld = -(long double)-(uint32_t)S->vtop->c.i; | 3624 | S->tccgen_vtop->c.ld = -(long double)-(uint32_t)S->tccgen_vtop->c.i; |
| 3625 | } | 3625 | } |
| 3626 | 3626 | ||
| 3627 | if (dbt == VT_FLOAT) | 3627 | if (dbt == VT_FLOAT) |
| 3628 | S->vtop->c.f = (float)S->vtop->c.ld; | 3628 | S->tccgen_vtop->c.f = (float)S->tccgen_vtop->c.ld; |
| 3629 | else if (dbt == VT_DOUBLE) | 3629 | else if (dbt == VT_DOUBLE) |
| 3630 | S->vtop->c.d = (double)S->vtop->c.ld; | 3630 | S->tccgen_vtop->c.d = (double)S->tccgen_vtop->c.ld; |
| 3631 | } else if (sf && dbt == VT_BOOL) { | 3631 | } else if (sf && dbt == VT_BOOL) { |
| 3632 | S->vtop->c.i = (S->vtop->c.ld != 0); | 3632 | S->tccgen_vtop->c.i = (S->tccgen_vtop->c.ld != 0); |
| 3633 | } else { | 3633 | } else { |
| 3634 | if(sf) | 3634 | if(sf) |
| 3635 | S->vtop->c.i = S->vtop->c.ld; | 3635 | S->tccgen_vtop->c.i = S->tccgen_vtop->c.ld; |
| 3636 | else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR)) | 3636 | else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR)) |
| 3637 | ; | 3637 | ; |
| 3638 | else if (sbt & VT_UNSIGNED) | 3638 | else if (sbt & VT_UNSIGNED) |
| 3639 | S->vtop->c.i = (uint32_t)S->vtop->c.i; | 3639 | S->tccgen_vtop->c.i = (uint32_t)S->tccgen_vtop->c.i; |
| 3640 | else | 3640 | else |
| 3641 | S->vtop->c.i = ((uint32_t)S->vtop->c.i | -(S->vtop->c.i & 0x80000000)); | 3641 | S->tccgen_vtop->c.i = ((uint32_t)S->tccgen_vtop->c.i | -(S->tccgen_vtop->c.i & 0x80000000)); |
| 3642 | 3642 | ||
| 3643 | if (dbt_bt == VT_LLONG || (PTR_SIZE == 8 && dbt == VT_PTR)) | 3643 | if (dbt_bt == VT_LLONG || (PTR_SIZE == 8 && dbt == VT_PTR)) |
| 3644 | ; | 3644 | ; |
| 3645 | else if (dbt == VT_BOOL) | 3645 | else if (dbt == VT_BOOL) |
| 3646 | S->vtop->c.i = (S->vtop->c.i != 0); | 3646 | S->tccgen_vtop->c.i = (S->tccgen_vtop->c.i != 0); |
| 3647 | else { | 3647 | else { |
| 3648 | uint32_t m = dbt_bt == VT_BYTE ? 0xff : | 3648 | uint32_t m = dbt_bt == VT_BYTE ? 0xff : |
| 3649 | dbt_bt == VT_SHORT ? 0xffff : | 3649 | dbt_bt == VT_SHORT ? 0xffff : |
| 3650 | 0xffffffff; | 3650 | 0xffffffff; |
| 3651 | S->vtop->c.i &= m; | 3651 | S->tccgen_vtop->c.i &= m; |
| 3652 | if (!(dbt & VT_UNSIGNED)) | 3652 | if (!(dbt & VT_UNSIGNED)) |
| 3653 | S->vtop->c.i |= -(S->vtop->c.i & ((m >> 1) + 1)); | 3653 | S->tccgen_vtop->c.i |= -(S->tccgen_vtop->c.i & ((m >> 1) + 1)); |
| 3654 | } | 3654 | } |
| 3655 | } | 3655 | } |
| 3656 | goto done; | 3656 | goto done; |
| 3657 | 3657 | ||
| 3658 | } else if (dbt == VT_BOOL | 3658 | } else if (dbt == VT_BOOL |
| 3659 | && (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) | 3659 | && (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) |
| 3660 | == (VT_CONST | VT_SYM)) { | 3660 | == (VT_CONST | VT_SYM)) { |
| 3661 | /* addresses are considered non-zero (see tcctest.c:sinit23) */ | 3661 | /* addresses are considered non-zero (see tcctest.c:sinit23) */ |
| 3662 | S->vtop->r = VT_CONST; | 3662 | S->tccgen_vtop->r = VT_CONST; |
| 3663 | S->vtop->c.i = 1; | 3663 | S->tccgen_vtop->c.i = 1; |
| 3664 | goto done; | 3664 | goto done; |
| 3665 | } | 3665 | } |
| 3666 | 3666 | ||
| @@ -3707,7 +3707,7 @@ error: · 40 unmodified lines | |||
| 3707 | tcc_warning(S, "cast between pointer and integer of different size"); | 3707 | tcc_warning(S, "cast between pointer and integer of different size"); |
| 3708 | if (sbt_bt == VT_PTR) { | 3708 | if (sbt_bt == VT_PTR) { |
| 3709 | /* put integer type to allow logical operations below */ | 3709 | /* put integer type to allow logical operations below */ |
| 3710 | S->vtop->type.t = (PTR_SIZE == 8 ? VT_LLONG : VT_INT); | 3710 | S->tccgen_vtop->type.t = (PTR_SIZE == 8 ? VT_LLONG : VT_INT); |
| 3711 | } | 3711 | } |
| 3712 | } | 3712 | } |
| 3713 | 3713 | ||
| @@ -3716,7 +3716,7 @@ error: · 2 unmodified lines | |||
| 3716 | change the type and read it still later. */ | 3716 | change the type and read it still later. */ |
| 3717 | #define ALLOW_SUBTYPE_ACCESS 1 | 3717 | #define ALLOW_SUBTYPE_ACCESS 1 |
| 3718 | 3718 | ||
| 3719 | if (ALLOW_SUBTYPE_ACCESS && (S->vtop->r & VT_LVAL)) { | 3719 | if (ALLOW_SUBTYPE_ACCESS && (S->tccgen_vtop->r & VT_LVAL)) { |
| 3720 | /* value still in memory */ | 3720 | /* value still in memory */ |
| 3721 | if (ds <= ss) | 3721 | if (ds <= ss) |
| 3722 | goto done; | 3722 | goto done; |
| @@ -3786,7 +3786,7 @@ error: · 63 unmodified lines | |||
| 3786 | #endif | 3786 | #endif |
| 3787 | bits = (ss - ds) * 8; | 3787 | bits = (ss - ds) * 8; |
| 3788 | /* for unsigned, gen_op will convert SAR to SHR */ | 3788 | /* for unsigned, gen_op will convert SAR to SHR */ |
| 3789 | S->vtop->type.t = (ss == 8 ? VT_LLONG : VT_INT) | (dbt & VT_UNSIGNED); | 3789 | S->tccgen_vtop->type.t = (ss == 8 ? VT_LLONG : VT_INT) | (dbt & VT_UNSIGNED); |
| 3790 | vpushi(S, bits); | 3790 | vpushi(S, bits); |
| 3791 | gen_op(S, TOK_SHL); | 3791 | gen_op(S, TOK_SHL); |
| 3792 | vpushi(S, bits - trunc); | 3792 | vpushi(S, bits - trunc); |
| @@ -3795,8 +3795,8 @@ error: · 2 unmodified lines | |||
| 3795 | gen_op(S, TOK_SHR); | 3795 | gen_op(S, TOK_SHR); |
| 3796 | } | 3796 | } |
| 3797 | done: | 3797 | done: |
| 3798 | S->vtop->type = *type; | 3798 | S->tccgen_vtop->type = *type; |
| 3799 | S->vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY ); | 3799 | S->tccgen_vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY ); |
| 3800 | } | 3800 | } |
| 3801 | 3801 | ||
| 3802 | /* return type size as known at compile time. Put alignment at 'a' */ | 3802 | /* return type size as known at compile time. Put alignment at 'a' */ |
| @@ -3866,7 +3866,7 @@ ST_FUNC int type_size(CType *type, int *a) · 63 unmodified lines | |||
| 3866 | 3866 | ||
| 3867 | /* push type size as known at runtime time on top of value stack. Put | 3867 | /* push type size as known at runtime time on top of value stack. Put |
| 3868 | alignment at 'a' */ | 3868 | alignment at 'a' */ |
| 3869 | ST_FUNC void vla_runtime_type_size(TCCState *S, CType *type, int *a) | 3869 | ST_FUNC void vla_runtime_type_size(TCCState* S, CType *type, int *a) |
| 3870 | { | 3870 | { |
| 3871 | if (type->t & VT_VLA) { | 3871 | if (type->t & VT_VLA) { |
| 3872 | type_size(&type->ref->type, a); | 3872 | type_size(&type->ref->type, a); |
| @@ -3883,7 +3883,7 @@ static inline CType *pointed_type(CType *type) · 10 unmodified lines | |||
| 3883 | } | 3883 | } |
| 3884 | 3884 | ||
| 3885 | /* modify type so that its it is a pointer to type. */ | 3885 | /* modify type so that its it is a pointer to type. */ |
| 3886 | ST_FUNC void mk_pointer(TCCState *S, CType *type) | 3886 | ST_FUNC void mk_pointer(TCCState* S, CType *type) |
| 3887 | { | 3887 | { |
| 3888 | Sym *s; | 3888 | Sym *s; |
| 3889 | s = sym_push(S, SYM_FIELD, type, 0, -1); | 3889 | s = sym_push(S, SYM_FIELD, type, 0, -1); |
| @@ -3906,18 +3906,18 @@ static int is_compatible_unqualified_types(CType *type1, CType *type2) · 16 unmodified lines | |||
| 3906 | return compare_types(type1,type2,1); | 3906 | return compare_types(type1,type2,1); |
| 3907 | } | 3907 | } |
| 3908 | 3908 | ||
| 3909 | static void cast_error(TCCState *S, CType *st, CType *dt) | 3909 | static void cast_error(TCCState* S, CType *st, CType *dt) |
| 3910 | { | 3910 | { |
| 3911 | type_incompatibility_error(S, st, dt, "cannot convert '%s' to '%s'"); | 3911 | type_incompatibility_error(S, st, dt, "cannot convert '%s' to '%s'"); |
| 3912 | } | 3912 | } |
| 3913 | 3913 | ||
| 3914 | /* verify type compatibility to store vtop in 'dt' type */ | 3914 | /* verify type compatibility to store vtop in 'dt' type */ |
| 3915 | static void verify_assign_cast(TCCState *S, CType *dt) | 3915 | static void verify_assign_cast(TCCState* S, CType *dt) |
| 3916 | { | 3916 | { |
| 3917 | CType *st, *type1, *type2; | 3917 | CType *st, *type1, *type2; |
| 3918 | int dbt, sbt, qualwarn, lvl; | 3918 | int dbt, sbt, qualwarn, lvl; |
| 3919 | 3919 | ||
| 3920 | st = &S->vtop->type; /* source type */ | 3920 | st = &S->tccgen_vtop->type; /* source type */ |
| 3921 | dbt = dt->t & VT_BTYPE; | 3921 | dbt = dt->t & VT_BTYPE; |
| 3922 | sbt = st->t & VT_BTYPE; | 3922 | sbt = st->t & VT_BTYPE; |
| 3923 | if (dt->t & VT_CONSTANT) | 3923 | if (dt->t & VT_CONSTANT) |
| @@ -3930,7 +3930,7 @@ static void verify_assign_cast(TCCState *S, CType *dt) · 6 unmodified lines | |||
| 3930 | case VT_PTR: | 3930 | case VT_PTR: |
| 3931 | /* special cases for pointers */ | 3931 | /* special cases for pointers */ |
| 3932 | /* '0' can also be a pointer */ | 3932 | /* '0' can also be a pointer */ |
| 3933 | if (is_null_pointer(S->vtop)) | 3933 | if (is_null_pointer(S->tccgen_vtop)) |
| 3934 | break; | 3934 | break; |
| 3935 | /* accept implicit pointer to integer cast with warning */ | 3935 | /* accept implicit pointer to integer cast with warning */ |
| 3936 | if (is_integer_btype(sbt)) { | 3936 | if (is_integer_btype(sbt)) { |
| @@ -3997,36 +3997,36 @@ static void verify_assign_cast(TCCState *S, CType *dt) · 60 unmodified lines | |||
| 3997 | } | 3997 | } |
| 3998 | } | 3998 | } |
| 3999 | 3999 | ||
| 4000 | static void gen_assign_cast(TCCState *S, CType *dt) | 4000 | static void gen_assign_cast(TCCState* S, CType *dt) |
| 4001 | { | 4001 | { |
| 4002 | verify_assign_cast(S, dt); | 4002 | verify_assign_cast(S, dt); |
| 4003 | gen_cast(S, dt); | 4003 | gen_cast(S, dt); |
| 4004 | } | 4004 | } |
| 4005 | 4005 | ||
| 4006 | /* store vtop in lvalue pushed on stack */ | 4006 | /* store vtop in lvalue pushed on stack */ |
| 4007 | ST_FUNC void vstore(TCCState *S) | 4007 | ST_FUNC void vstore(TCCState* S) |
| 4008 | { | 4008 | { |
| 4009 | int sbt, dbt, ft, r, size, align, bit_size, bit_pos, delayed_cast; | 4009 | int sbt, dbt, ft, r, size, align, bit_size, bit_pos, delayed_cast; |
| 4010 | 4010 | ||
| 4011 | ft = S->vtop[-1].type.t; | 4011 | ft = S->tccgen_vtop[-1].type.t; |
| 4012 | sbt = S->vtop->type.t & VT_BTYPE; | 4012 | sbt = S->tccgen_vtop->type.t & VT_BTYPE; |
| 4013 | dbt = ft & VT_BTYPE; | 4013 | dbt = ft & VT_BTYPE; |
| 4014 | 4014 | ||
| 4015 | verify_assign_cast(S, &S->vtop[-1].type); | 4015 | verify_assign_cast(S, &S->tccgen_vtop[-1].type); |
| 4016 | 4016 | ||
| 4017 | if (sbt == VT_STRUCT) { | 4017 | if (sbt == VT_STRUCT) { |
| 4018 | /* if structure, only generate pointer */ | 4018 | /* if structure, only generate pointer */ |
| 4019 | /* structure assignment : generate memcpy */ | 4019 | /* structure assignment : generate memcpy */ |
| 4020 | /* XXX: optimize if small size */ | 4020 | /* XXX: optimize if small size */ |
| 4021 | size = type_size(&S->vtop->type, &align); | 4021 | size = type_size(&S->tccgen_vtop->type, &align); |
| 4022 | 4022 | ||
| 4023 | /* destination */ | 4023 | /* destination */ |
| 4024 | vswap(S); | 4024 | vswap(S); |
| 4025 | #ifdef CONFIG_TCC_BCHECK | 4025 | #ifdef CONFIG_TCC_BCHECK |
| 4026 | if (S->vtop->r & VT_MUSTBOUND) | 4026 | if (S->tccgen_vtop->r & VT_MUSTBOUND) |
| 4027 | gbound(S); /* check would be wrong after gaddrof() */ | 4027 | gbound(S); /* check would be wrong after gaddrof() */ |
| 4028 | #endif | 4028 | #endif |
| 4029 | S->vtop->type.t = VT_PTR; | 4029 | S->tccgen_vtop->type.t = VT_PTR; |
| 4030 | gaddrof(S); | 4030 | gaddrof(S); |
| 4031 | 4031 | ||
| 4032 | /* address of memcpy() */ | 4032 | /* address of memcpy() */ |
| @@ -4042,12 +4042,12 @@ ST_FUNC void vstore(TCCState *S) · 9 unmodified lines | |||
| 4042 | 4042 | ||
| 4043 | vswap(S); | 4043 | vswap(S); |
| 4044 | /* source */ | 4044 | /* source */ |
| 4045 | vpushv(S, S->vtop - 2); | 4045 | vpushv(S, S->tccgen_vtop - 2); |
| 4046 | #ifdef CONFIG_TCC_BCHECK | 4046 | #ifdef CONFIG_TCC_BCHECK |
| 4047 | if (S->vtop->r & VT_MUSTBOUND) | 4047 | if (S->tccgen_vtop->r & VT_MUSTBOUND) |
| 4048 | gbound(S); | 4048 | gbound(S); |
| 4049 | #endif | 4049 | #endif |
| 4050 | S->vtop->type.t = VT_PTR; | 4050 | S->tccgen_vtop->type.t = VT_PTR; |
| 4051 | gaddrof(S); | 4051 | gaddrof(S); |
| 4052 | /* type size */ | 4052 | /* type size */ |
| 4053 | vpushi(S, size); | 4053 | vpushi(S, size); |
| @@ -4058,21 +4058,21 @@ ST_FUNC void vstore(TCCState *S) · 4 unmodified lines | |||
| 4058 | /* bitfield store handling */ | 4058 | /* bitfield store handling */ |
| 4059 | 4059 | ||
| 4060 | /* save lvalue as expression result (example: s.b = s.a = n;) */ | 4060 | /* save lvalue as expression result (example: s.b = s.a = n;) */ |
| 4061 | vdup(S), S->vtop[-1] = S->vtop[-2]; | 4061 | vdup(S), S->tccgen_vtop[-1] = S->tccgen_vtop[-2]; |
| 4062 | 4062 | ||
| 4063 | bit_pos = BIT_POS(ft); | 4063 | bit_pos = BIT_POS(ft); |
| 4064 | bit_size = BIT_SIZE(ft); | 4064 | bit_size = BIT_SIZE(ft); |
| 4065 | /* remove bit field info to avoid loops */ | 4065 | /* remove bit field info to avoid loops */ |
| 4066 | S->vtop[-1].type.t = ft & ~VT_STRUCT_MASK; | 4066 | S->tccgen_vtop[-1].type.t = ft & ~VT_STRUCT_MASK; |
| 4067 | 4067 | ||
| 4068 | if (dbt == VT_BOOL) { | 4068 | if (dbt == VT_BOOL) { |
| 4069 | gen_cast(S, &S->vtop[-1].type); | 4069 | gen_cast(S, &S->tccgen_vtop[-1].type); |
| 4070 | S->vtop[-1].type.t = (S->vtop[-1].type.t & ~VT_BTYPE) | (VT_BYTE | VT_UNSIGNED); | 4070 | S->tccgen_vtop[-1].type.t = (S->tccgen_vtop[-1].type.t & ~VT_BTYPE) | (VT_BYTE | VT_UNSIGNED); |
| 4071 | } | 4071 | } |
| 4072 | r = adjust_bf(S->vtop - 1, bit_pos, bit_size); | 4072 | r = adjust_bf(S->tccgen_vtop - 1, bit_pos, bit_size); |
| 4073 | if (dbt != VT_BOOL) { | 4073 | if (dbt != VT_BOOL) { |
| 4074 | gen_cast(S, &S->vtop[-1].type); | 4074 | gen_cast(S, &S->tccgen_vtop[-1].type); |
| 4075 | dbt = S->vtop[-1].type.t & VT_BTYPE; | 4075 | dbt = S->tccgen_vtop[-1].type.t & VT_BTYPE; |
| 4076 | } | 4076 | } |
| 4077 | if (r == VT_STRUCT) { | 4077 | if (r == VT_STRUCT) { |
| 4078 | store_packed_bf(S, bit_pos, bit_size); | 4078 | store_packed_bf(S, bit_pos, bit_size); |
| @@ -4106,25 +4106,25 @@ ST_FUNC void vstore(TCCState *S) · 27 unmodified lines | |||
| 4106 | vpop(S); | 4106 | vpop(S); |
| 4107 | } | 4107 | } |
| 4108 | } else if (dbt == VT_VOID) { | 4108 | } else if (dbt == VT_VOID) { |
| 4109 | --S->vtop; | 4109 | --S->tccgen_vtop; |
| 4110 | } else { | 4110 | } else { |
| 4111 | /* optimize char/short casts */ | 4111 | /* optimize char/short casts */ |
| 4112 | delayed_cast = 0; | 4112 | delayed_cast = 0; |
| 4113 | if ((dbt == VT_BYTE || dbt == VT_SHORT) | 4113 | if ((dbt == VT_BYTE || dbt == VT_SHORT) |
| 4114 | && is_integer_btype(sbt) | 4114 | && is_integer_btype(sbt) |
| 4115 | ) { | 4115 | ) { |
| 4116 | if ((S->vtop->r & VT_MUSTCAST) | 4116 | if ((S->tccgen_vtop->r & VT_MUSTCAST) |
| 4117 | && btype_size(dbt) > btype_size(sbt) | 4117 | && btype_size(dbt) > btype_size(sbt) |
| 4118 | ) | 4118 | ) |
| 4119 | force_charshort_cast(S); | 4119 | force_charshort_cast(S); |
| 4120 | delayed_cast = 1; | 4120 | delayed_cast = 1; |
| 4121 | } else { | 4121 | } else { |
| 4122 | gen_cast(S, &S->vtop[-1].type); | 4122 | gen_cast(S, &S->tccgen_vtop[-1].type); |
| 4123 | } | 4123 | } |
| 4124 | 4124 | ||
| 4125 | #ifdef CONFIG_TCC_BCHECK | 4125 | #ifdef CONFIG_TCC_BCHECK |
| 4126 | /* bound check case */ | 4126 | /* bound check case */ |
| 4127 | if (S->vtop[-1].r & VT_MUSTBOUND) { | 4127 | if (S->tccgen_vtop[-1].r & VT_MUSTBOUND) { |
| 4128 | vswap(S); | 4128 | vswap(S); |
| 4129 | gbound(S); | 4129 | gbound(S); |
| 4130 | vswap(S); | 4130 | vswap(S); |
| @@ -4133,51 +4133,51 @@ ST_FUNC void vstore(TCCState *S) · 2 unmodified lines | |||
| 4133 | gv(S, RC_TYPE(dbt)); /* generate value */ | 4133 | gv(S, RC_TYPE(dbt)); /* generate value */ |
| 4134 | 4134 | ||
| 4135 | if (delayed_cast) { | 4135 | if (delayed_cast) { |
| 4136 | S->vtop->r |= BFVAL(VT_MUSTCAST, (sbt == VT_LLONG) + 1); | 4136 | S->tccgen_vtop->r |= BFVAL(VT_MUSTCAST, (sbt == VT_LLONG) + 1); |
| 4137 | //tcc_warning(S, "deley cast %x -> %x", sbt, dbt); | 4137 | //tcc_warning(S, "deley cast %x -> %x", sbt, dbt); |
| 4138 | S->vtop->type.t = ft & VT_TYPE; | 4138 | S->tccgen_vtop->type.t = ft & VT_TYPE; |
| 4139 | } | 4139 | } |
| 4140 | 4140 | ||
| 4141 | /* if lvalue was saved on stack, must read it */ | 4141 | /* if lvalue was saved on stack, must read it */ |
| 4142 | if ((S->vtop[-1].r & VT_VALMASK) == VT_LLOCAL) { | 4142 | if ((S->tccgen_vtop[-1].r & VT_VALMASK) == VT_LLOCAL) { |
| 4143 | SValue sv; | 4143 | SValue sv; |
| 4144 | r = get_reg(S, RC_INT); | 4144 | r = get_reg(S, RC_INT); |
| 4145 | sv.type.t = VT_PTRDIFF_T; | 4145 | sv.type.t = VT_PTRDIFF_T; |
| 4146 | sv.r = VT_LOCAL | VT_LVAL; | 4146 | sv.r = VT_LOCAL | VT_LVAL; |
| 4147 | sv.c.i = S->vtop[-1].c.i; | 4147 | sv.c.i = S->tccgen_vtop[-1].c.i; |
| 4148 | load(S, r, &sv); | 4148 | load(S, r, &sv); |
| 4149 | S->vtop[-1].r = r | VT_LVAL; | 4149 | S->tccgen_vtop[-1].r = r | VT_LVAL; |
| 4150 | } | 4150 | } |
| 4151 | 4151 | ||
| 4152 | r = S->vtop->r & VT_VALMASK; | 4152 | r = S->tccgen_vtop->r & VT_VALMASK; |
| 4153 | /* two word case handling : | 4153 | /* two word case handling : |
| 4154 | store second register at word + 4 (or +8 for x86-64) */ | 4154 | store second register at word + 4 (or +8 for x86-64) */ |
| 4155 | if (USING_TWO_WORDS(dbt)) { | 4155 | if (USING_TWO_WORDS(dbt)) { |
| 4156 | int load_type = (dbt == VT_QFLOAT) ? VT_DOUBLE : VT_PTRDIFF_T; | 4156 | int load_type = (dbt == VT_QFLOAT) ? VT_DOUBLE : VT_PTRDIFF_T; |
| 4157 | S->vtop[-1].type.t = load_type; | 4157 | S->tccgen_vtop[-1].type.t = load_type; |
| 4158 | store(S, r, S->vtop - 1); | 4158 | store(S, r, S->tccgen_vtop - 1); |
| 4159 | vswap(S); | 4159 | vswap(S); |
| 4160 | /* convert to int to increment easily */ | 4160 | /* convert to int to increment easily */ |
| 4161 | S->vtop->type.t = VT_PTRDIFF_T; | 4161 | S->tccgen_vtop->type.t = VT_PTRDIFF_T; |
| 4162 | gaddrof(S); | 4162 | gaddrof(S); |
| 4163 | vpushs(S, PTR_SIZE); | 4163 | vpushs(S, PTR_SIZE); |
| 4164 | gen_op(S, '+'); | 4164 | gen_op(S, '+'); |
| 4165 | S->vtop->r |= VT_LVAL; | 4165 | S->tccgen_vtop->r |= VT_LVAL; |
| 4166 | vswap(S); | 4166 | vswap(S); |
| 4167 | S->vtop[-1].type.t = load_type; | 4167 | S->tccgen_vtop[-1].type.t = load_type; |
| 4168 | /* XXX: it works because r2 is spilled last ! */ | 4168 | /* XXX: it works because r2 is spilled last ! */ |
| 4169 | store(S, S->vtop->r2, S->vtop - 1); | 4169 | store(S, S->tccgen_vtop->r2, S->tccgen_vtop - 1); |
| 4170 | } else { | 4170 | } else { |
| 4171 | /* single word */ | 4171 | /* single word */ |
| 4172 | store(S, r, S->vtop - 1); | 4172 | store(S, r, S->tccgen_vtop - 1); |
| 4173 | } | 4173 | } |
| 4174 | vswap(S); | 4174 | vswap(S); |
| 4175 | S->vtop--; /* NOT vpop() because on x86 it would flush the fp stack */ | 4175 | S->tccgen_vtop--; /* NOT vpop() because on x86 it would flush the fp stack */ |
| 4176 | } | 4176 | } |
| 4177 | } | 4177 | } |
| 4178 | 4178 | ||
| 4179 | /* post defines POST/PRE add. c is the token ++ or -- */ | 4179 | /* post defines POST/PRE add. c is the token ++ or -- */ |
| 4180 | ST_FUNC void inc(TCCState *S, int post, int c) | 4180 | ST_FUNC void inc(TCCState* S, int post, int c) |
| 4181 | { | 4181 | { |
| 4182 | test_lvalue(S); | 4182 | test_lvalue(S); |
| 4183 | vdup(S); /* save lvalue */ | 4183 | vdup(S); /* save lvalue */ |
| @@ -4194,15 +4194,15 @@ ST_FUNC void inc(TCCState *S, int post, int c) · 10 unmodified lines | |||
| 4194 | vpop(S); /* if post op, return saved value */ | 4194 | vpop(S); /* if post op, return saved value */ |
| 4195 | } | 4195 | } |
| 4196 | 4196 | ||
| 4197 | ST_FUNC void parse_mult_str (TCCState *S, CString *astr, const char *msg) | 4197 | ST_FUNC void parse_mult_str (TCCState* S, CString *astr, const char *msg) |
| 4198 | { | 4198 | { |
| 4199 | /* read the string */ | 4199 | /* read the string */ |
| 4200 | if (S->tok != TOK_STR) | 4200 | if (S->tccpp_tok != TOK_STR) |
| 4201 | expect(S, msg); | 4201 | expect(S, msg); |
| 4202 | cstr_new(S, astr); | 4202 | cstr_new(S, astr); |
| 4203 | while (S->tok == TOK_STR) { | 4203 | while (S->tccpp_tok == TOK_STR) { |
| 4204 | /* XXX: add \0 handling too ? */ | 4204 | /* XXX: add \0 handling too ? */ |
| 4205 | cstr_cat(S, astr, S->tokc.str.data, -1); | 4205 | cstr_cat(S, astr, S->tccpp_tokc.str.data, -1); |
| 4206 | next(S); | 4206 | next(S); |
| 4207 | } | 4207 | } |
| 4208 | cstr_ccat(S, astr, '\0'); | 4208 | cstr_ccat(S, astr, '\0'); |
| @@ -4227,21 +4227,21 @@ ST_FUNC int exact_log2p1(int i) · 18 unmodified lines | |||
| 4227 | } | 4227 | } |
| 4228 | 4228 | ||
| 4229 | /* Parse __attribute__((...)) GNUC extension. */ | 4229 | /* Parse __attribute__((...)) GNUC extension. */ |
| 4230 | static void parse_attribute(TCCState *S, AttributeDef *ad) | 4230 | static void parse_attribute(TCCState* S, AttributeDef *ad) |
| 4231 | { | 4231 | { |
| 4232 | int t, n; | 4232 | int t, n; |
| 4233 | CString astr; | 4233 | CString astr; |
| 4234 | 4234 | ||
| 4235 | redo: | 4235 | redo: |
| 4236 | if (S->tok != TOK_ATTRIBUTE1 && S->tok != TOK_ATTRIBUTE2) | 4236 | if (S->tccpp_tok != TOK_ATTRIBUTE1 && S->tccpp_tok != TOK_ATTRIBUTE2) |
| 4237 | return; | 4237 | return; |
| 4238 | next(S); | 4238 | next(S); |
| 4239 | skip(S, '('); | 4239 | skip(S, '('); |
| 4240 | skip(S, '('); | 4240 | skip(S, '('); |
| 4241 | while (S->tok != ')') { | 4241 | while (S->tccpp_tok != ')') { |
| 4242 | if (S->tok < TOK_IDENT) | 4242 | if (S->tccpp_tok < TOK_IDENT) |
| 4243 | expect(S, "attribute name"); | 4243 | expect(S, "attribute name"); |
| 4244 | t = S->tok; | 4244 | t = S->tccpp_tok; |
| 4245 | next(S); | 4245 | next(S); |
| 4246 | switch(t) { | 4246 | switch(t) { |
| 4247 | case TOK_CLEANUP1: | 4247 | case TOK_CLEANUP1: |
| @@ -4250,13 +4250,13 @@ redo: · 2 unmodified lines | |||
| 4250 | Sym *s; | 4250 | Sym *s; |
| 4251 | 4251 | ||
| 4252 | skip(S, '('); | 4252 | skip(S, '('); |
| 4253 | s = sym_find(S, S->tok); | 4253 | s = sym_find(S, S->tccpp_tok); |
| 4254 | if (!s) { | 4254 | if (!s) { |
| 4255 | tcc_warning_c(warn_implicit_function_declaration)(S, | 4255 | tcc_warning_c(warn_implicit_function_declaration)(S, |
| 4256 | "implicit declaration of function '%s'", get_tok_str(S, S->tok, &S->tokc)); | 4256 | "implicit declaration of function '%s'", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 4257 | s = external_global_sym(S, S->tok, &S->tccgen_func_old_type); | 4257 | s = external_global_sym(S, S->tccpp_tok, &S->tccgen_func_old_type); |
| 4258 | } else if ((s->type.t & VT_BTYPE) != VT_FUNC) | 4258 | } else if ((s->type.t & VT_BTYPE) != VT_FUNC) |
| 4259 | tcc_error(S, "'%s' is not declared as function", get_tok_str(S, S->tok, &S->tokc)); | 4259 | tcc_error(S, "'%s' is not declared as function", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 4260 | ad->cleanup_func = s; | 4260 | ad->cleanup_func = s; |
| 4261 | next(S); | 4261 | next(S); |
| 4262 | skip(S, ')'); | 4262 | skip(S, ')'); |
| @@ -4311,7 +4311,7 @@ redo: · 48 unmodified lines | |||
| 4311 | break; | 4311 | break; |
| 4312 | case TOK_ALIGNED1: | 4312 | case TOK_ALIGNED1: |
| 4313 | case TOK_ALIGNED2: | 4313 | case TOK_ALIGNED2: |
| 4314 | if (S->tok == '(') { | 4314 | if (S->tccpp_tok == '(') { |
| 4315 | next(S); | 4315 | next(S); |
| 4316 | n = expr_const(S); | 4316 | n = expr_const(S); |
| 4317 | if (n <= 0 || (n & (n - 1)) != 0) | 4317 | if (n <= 0 || (n & (n - 1)) != 0) |
| @@ -4372,7 +4372,7 @@ redo: · 54 unmodified lines | |||
| 4372 | #endif | 4372 | #endif |
| 4373 | case TOK_MODE: | 4373 | case TOK_MODE: |
| 4374 | skip(S, '('); | 4374 | skip(S, '('); |
| 4375 | switch(S->tok) { | 4375 | switch(S->tccpp_tok) { |
| 4376 | case TOK_MODE_DI: | 4376 | case TOK_MODE_DI: |
| 4377 | ad->attr_mode = VT_LLONG + 1; | 4377 | ad->attr_mode = VT_LLONG + 1; |
| 4378 | break; | 4378 | break; |
| @@ -4387,7 +4387,7 @@ redo: · 8 unmodified lines | |||
| 4387 | ad->attr_mode = VT_INT + 1; | 4387 | ad->attr_mode = VT_INT + 1; |
| 4388 | break; | 4388 | break; |
| 4389 | default: | 4389 | default: |
| 4390 | tcc_warning(S, "__mode__(%s) not supported\n", get_tok_str(S, S->tok, NULL)); | 4390 | tcc_warning(S, "__mode__(%s) not supported\n", get_tok_str(S, S->tccpp_tok, NULL)); |
| 4391 | break; | 4391 | break; |
| 4392 | } | 4392 | } |
| 4393 | next(S); | 4393 | next(S); |
| @@ -4405,19 +4405,19 @@ redo: · 11 unmodified lines | |||
| 4405 | default: | 4405 | default: |
| 4406 | tcc_warning_c(warn_unsupported)(S, "'%s' attribute ignored", get_tok_str(S, t, NULL)); | 4406 | tcc_warning_c(warn_unsupported)(S, "'%s' attribute ignored", get_tok_str(S, t, NULL)); |
| 4407 | /* skip parameters */ | 4407 | /* skip parameters */ |
| 4408 | if (S->tok == '(') { | 4408 | if (S->tccpp_tok == '(') { |
| 4409 | int parenthesis = 0; | 4409 | int parenthesis = 0; |
| 4410 | do { | 4410 | do { |
| 4411 | if (S->tok == '(') | 4411 | if (S->tccpp_tok == '(') |
| 4412 | parenthesis++; | 4412 | parenthesis++; |
| 4413 | else if (S->tok == ')') | 4413 | else if (S->tccpp_tok == ')') |
| 4414 | parenthesis--; | 4414 | parenthesis--; |
| 4415 | next(S); | 4415 | next(S); |
| 4416 | } while (parenthesis && S->tok != -1); | 4416 | } while (parenthesis && S->tccpp_tok != -1); |
| 4417 | } | 4417 | } |
| 4418 | break; | 4418 | break; |
| 4419 | } | 4419 | } |
| 4420 | if (S->tok != ',') | 4420 | if (S->tccpp_tok != ',') |
| 4421 | break; | 4421 | break; |
| 4422 | next(S); | 4422 | next(S); |
| 4423 | } | 4423 | } |
| @@ -4446,7 +4446,7 @@ static Sym * find_field (CType *type, int v, int *cumofs) · 22 unmodified lines | |||
| 4446 | return s; | 4446 | return s; |
| 4447 | } | 4447 | } |
| 4448 | 4448 | ||
| 4449 | static void check_fields (TCCState *S, CType *type, int check) | 4449 | static void check_fields (TCCState* S, CType *type, int check) |
| 4450 | { | 4450 | { |
| 4451 | Sym *s = type->ref; | 4451 | Sym *s = type->ref; |
| 4452 | 4452 | ||
| @@ -4462,7 +4462,7 @@ static void check_fields (TCCState *S, CType *type, int check) · 9 unmodified lines | |||
| 4462 | } | 4462 | } |
| 4463 | } | 4463 | } |
| 4464 | 4464 | ||
| 4465 | static void struct_layout(TCCState *S, CType *type, AttributeDef *ad) | 4465 | static void struct_layout(TCCState* S, CType *type, AttributeDef *ad) |
| 4466 | { | 4466 | { |
| 4467 | int size, align, maxalign, offset, c, bit_pos, bit_size; | 4467 | int size, align, maxalign, offset, c, bit_pos, bit_size; |
| 4468 | int packed, a, bt, prevbt, prev_bit_size; | 4468 | int packed, a, bt, prevbt, prev_bit_size; |
| @@ -4712,7 +4712,7 @@ static void struct_layout(TCCState *S, CType *type, AttributeDef *ad) · 243 unmodified lines | |||
| 4712 | } | 4712 | } |
| 4713 | 4713 | ||
| 4714 | /* enum/struct/union declaration. u is VT_ENUM/VT_STRUCT/VT_UNION */ | 4714 | /* enum/struct/union declaration. u is VT_ENUM/VT_STRUCT/VT_UNION */ |
| 4715 | static void struct_decl(TCCState *S, CType *type, int u) | 4715 | static void struct_decl(TCCState* S, CType *type, int u) |
| 4716 | { | 4716 | { |
| 4717 | int v, c, size, align, flexible; | 4717 | int v, c, size, align, flexible; |
| 4718 | int bit_size, bsize, bt; | 4718 | int bit_size, bsize, bt; |
| @@ -4723,14 +4723,14 @@ static void struct_decl(TCCState *S, CType *type, int u) · 4 unmodified lines | |||
| 4723 | memset(&ad, 0, sizeof ad); | 4723 | memset(&ad, 0, sizeof ad); |
| 4724 | next(S); | 4724 | next(S); |
| 4725 | parse_attribute(S, &ad); | 4725 | parse_attribute(S, &ad); |
| 4726 | if (S->tok != '{') { | 4726 | if (S->tccpp_tok != '{') { |
| 4727 | v = S->tok; | 4727 | v = S->tccpp_tok; |
| 4728 | next(S); | 4728 | next(S); |
| 4729 | /* struct already defined ? return it */ | 4729 | /* struct already defined ? return it */ |
| 4730 | if (v < TOK_IDENT) | 4730 | if (v < TOK_IDENT) |
| 4731 | expect(S, "struct/union/enum name"); | 4731 | expect(S, "struct/union/enum name"); |
| 4732 | s = struct_find(S, v); | 4732 | s = struct_find(S, v); |
| 4733 | if (s && (s->sym_scope == S->local_scope || S->tok != '{')) { | 4733 | if (s && (s->sym_scope == S->tccgen_local_scope || S->tccpp_tok != '{')) { |
| 4734 | if (u == s->type.t) | 4734 | if (u == s->type.t) |
| 4735 | goto do_decl; | 4735 | goto do_decl; |
| 4736 | if (u == VT_ENUM && IS_ENUM(s->type.t)) | 4736 | if (u == VT_ENUM && IS_ENUM(s->type.t)) |
| @@ -4750,7 +4750,7 @@ do_decl: · 13 unmodified lines | |||
| 4750 | type->t = s->type.t; | 4750 | type->t = s->type.t; |
| 4751 | type->ref = s; | 4751 | type->ref = s; |
| 4752 | 4752 | ||
| 4753 | if (S->tok == '{') { | 4753 | if (S->tccpp_tok == '{') { |
| 4754 | next(S); | 4754 | next(S); |
| 4755 | if (s->c != -1) | 4755 | if (s->c != -1) |
| 4756 | tcc_error(S, "struct/union/enum already defined"); | 4756 | tcc_error(S, "struct/union/enum already defined"); |
| @@ -4765,15 +4765,15 @@ do_decl: · 8 unmodified lines | |||
| 4765 | /* enum symbols have static storage */ | 4765 | /* enum symbols have static storage */ |
| 4766 | t.t = VT_INT|VT_STATIC|VT_ENUM_VAL; | 4766 | t.t = VT_INT|VT_STATIC|VT_ENUM_VAL; |
| 4767 | for(;;) { | 4767 | for(;;) { |
| 4768 | v = S->tok; | 4768 | v = S->tccpp_tok; |
| 4769 | if (v < TOK_UIDENT) | 4769 | if (v < TOK_UIDENT) |
| 4770 | expect(S, "identifier"); | 4770 | expect(S, "identifier"); |
| 4771 | ss = sym_find(S, v); | 4771 | ss = sym_find(S, v); |
| 4772 | if (ss && !S->local_stack) | 4772 | if (ss && !S->tccgen_local_stack) |
| 4773 | tcc_error(S, "redefinition of enumerator '%s'", | 4773 | tcc_error(S, "redefinition of enumerator '%s'", |
| 4774 | get_tok_str(S, v, NULL)); | 4774 | get_tok_str(S, v, NULL)); |
| 4775 | next(S); | 4775 | next(S); |
| 4776 | if (S->tok == '=') { | 4776 | if (S->tccpp_tok == '=') { |
| 4777 | next(S); | 4777 | next(S); |
| 4778 | ll = expr_const64(S); | 4778 | ll = expr_const64(S); |
| 4779 | } | 4779 | } |
| @@ -4784,12 +4784,12 @@ do_decl: · 4 unmodified lines | |||
| 4784 | nl = ll; | 4784 | nl = ll; |
| 4785 | if (ll > pl) | 4785 | if (ll > pl) |
| 4786 | pl = ll; | 4786 | pl = ll; |
| 4787 | if (S->tok != ',') | 4787 | if (S->tccpp_tok != ',') |
| 4788 | break; | 4788 | break; |
| 4789 | next(S); | 4789 | next(S); |
| 4790 | ll++; | 4790 | ll++; |
| 4791 | /* NOTE: we accept a trailing comma */ | 4791 | /* NOTE: we accept a trailing comma */ |
| 4792 | if (S->tok == '}') | 4792 | if (S->tccpp_tok == '}') |
| 4793 | break; | 4793 | break; |
| 4794 | } | 4794 | } |
| 4795 | skip(S, '}'); | 4795 | skip(S, '}'); |
| @@ -4819,7 +4819,7 @@ do_decl: · 23 unmodified lines | |||
| 4819 | } else { | 4819 | } else { |
| 4820 | c = 0; | 4820 | c = 0; |
| 4821 | flexible = 0; | 4821 | flexible = 0; |
| 4822 | while (S->tok != '}') { | 4822 | while (S->tccpp_tok != '}') { |
| 4823 | if (!parse_btype(S, &btype, &ad1)) { | 4823 | if (!parse_btype(S, &btype, &ad1)) { |
| 4824 | skip(S, ';'); | 4824 | skip(S, ';'); |
| 4825 | continue; | 4825 | continue; |
| @@ -4831,8 +4831,8 @@ do_decl: · 5 unmodified lines | |||
| 4831 | bit_size = -1; | 4831 | bit_size = -1; |
| 4832 | v = 0; | 4832 | v = 0; |
| 4833 | type1 = btype; | 4833 | type1 = btype; |
| 4834 | if (S->tok != ':') { | 4834 | if (S->tccpp_tok != ':') { |
| 4835 | if (S->tok != ';') | 4835 | if (S->tccpp_tok != ';') |
| 4836 | type_decl(S, &type1, &ad1, &v, TYPE_DIRECT); | 4836 | type_decl(S, &type1, &ad1, &v, TYPE_DIRECT); |
| 4837 | if (v == 0) { | 4837 | if (v == 0) { |
| 4838 | if ((type1.t & VT_BTYPE) != VT_STRUCT) | 4838 | if ((type1.t & VT_BTYPE) != VT_STRUCT) |
| @@ -4858,7 +4858,7 @@ do_decl: · 19 unmodified lines | |||
| 4858 | tcc_error(S, "invalid type for '%s'", | 4858 | tcc_error(S, "invalid type for '%s'", |
| 4859 | get_tok_str(S, v, NULL)); | 4859 | get_tok_str(S, v, NULL)); |
| 4860 | } | 4860 | } |
| 4861 | if (S->tok == ':') { | 4861 | if (S->tccpp_tok == ':') { |
| 4862 | next(S); | 4862 | next(S); |
| 4863 | bit_size = expr_const(S); | 4863 | bit_size = expr_const(S); |
| 4864 | /* XXX: handle v = 0 case for messages */ | 4864 | /* XXX: handle v = 0 case for messages */ |
| @@ -4913,7 +4913,7 @@ do_decl: · 48 unmodified lines | |||
| 4913 | *ps = ss; | 4913 | *ps = ss; |
| 4914 | ps = &ss->next; | 4914 | ps = &ss->next; |
| 4915 | } | 4915 | } |
| 4916 | if (S->tok == ';' || S->tok == TOK_EOF) | 4916 | if (S->tccpp_tok == ';' || S->tccpp_tok == TOK_EOF) |
| 4917 | break; | 4917 | break; |
| 4918 | skip(S, ','); | 4918 | skip(S, ','); |
| 4919 | } | 4919 | } |
| @@ -4939,7 +4939,7 @@ static void sym_to_attr(AttributeDef *ad, Sym *s) · 19 unmodified lines | |||
| 4939 | 4939 | ||
| 4940 | /* Add type qualifiers to a type. If the type is an array then the qualifiers | 4940 | /* Add type qualifiers to a type. If the type is an array then the qualifiers |
| 4941 | are added to the element type, copied because it could be a typedef. */ | 4941 | are added to the element type, copied because it could be a typedef. */ |
| 4942 | static void parse_btype_qualify(TCCState *S, CType *type, int qualifiers) | 4942 | static void parse_btype_qualify(TCCState* S, CType *type, int qualifiers) |
| 4943 | { | 4943 | { |
| 4944 | while (type->t & VT_ARRAY) { | 4944 | while (type->t & VT_ARRAY) { |
| 4945 | type->ref = sym_push(S, SYM_FIELD, &type->ref->type, 0, type->ref->c); | 4945 | type->ref = sym_push(S, SYM_FIELD, &type->ref->type, 0, type->ref->c); |
| @@ -4951,7 +4951,7 @@ static void parse_btype_qualify(TCCState *S, CType *type, int qualifiers) · 5 unmodified lines | |||
| 4951 | /* return 0 if no type declaration. otherwise, return the basic type | 4951 | /* return 0 if no type declaration. otherwise, return the basic type |
| 4952 | and skip it. | 4952 | and skip it. |
| 4953 | */ | 4953 | */ |
| 4954 | static int parse_btype(TCCState *S, CType *type, AttributeDef *ad) | 4954 | static int parse_btype(TCCState* S, CType *type, AttributeDef *ad) |
| 4955 | { | 4955 | { |
| 4956 | int t, u, bt, st, type_found, typespec_found, g, n; | 4956 | int t, u, bt, st, type_found, typespec_found, g, n; |
| 4957 | Sym *s; | 4957 | Sym *s; |
| @@ -4965,7 +4965,7 @@ static int parse_btype(TCCState *S, CType *type, AttributeDef *ad) · 7 unmodified lines | |||
| 4965 | type->ref = NULL; | 4965 | type->ref = NULL; |
| 4966 | 4966 | ||
| 4967 | while(1) { | 4967 | while(1) { |
| 4968 | switch(S->tok) { | 4968 | switch(S->tccpp_tok) { |
| 4969 | case TOK_EXTENSION: | 4969 | case TOK_EXTENSION: |
| 4970 | /* currently, we really ignore extension */ | 4970 | /* currently, we really ignore extension */ |
| 4971 | next(S); | 4971 | next(S); |
| @@ -5072,7 +5072,7 @@ static int parse_btype(TCCState *S, CType *type, AttributeDef *ad) · 100 unmodified lines | |||
| 5072 | type->t = t; | 5072 | type->t = t; |
| 5073 | parse_btype_qualify(S, type, VT_ATOMIC); | 5073 | parse_btype_qualify(S, type, VT_ATOMIC); |
| 5074 | t = type->t; | 5074 | t = type->t; |
| 5075 | if (S->tok == '(') { | 5075 | if (S->tccpp_tok == '(') { |
| 5076 | parse_expr_type(S, &type1); | 5076 | parse_expr_type(S, &type1); |
| 5077 | /* remove all storage modifiers except typedef */ | 5077 | /* remove all storage modifiers except typedef */ |
| 5078 | type1.t &= ~(VT_STORAGE&~VT_TYPEDEF); | 5078 | type1.t &= ~(VT_STORAGE&~VT_TYPEDEF); |
| @@ -5170,12 +5170,12 @@ static int parse_btype(TCCState *S, CType *type, AttributeDef *ad) · 91 unmodified lines | |||
| 5170 | default: | 5170 | default: |
| 5171 | if (typespec_found) | 5171 | if (typespec_found) |
| 5172 | goto the_end; | 5172 | goto the_end; |
| 5173 | s = sym_find(S, S->tok); | 5173 | s = sym_find(S, S->tccpp_tok); |
| 5174 | if (!s || !(s->type.t & VT_TYPEDEF)) | 5174 | if (!s || !(s->type.t & VT_TYPEDEF)) |
| 5175 | goto the_end; | 5175 | goto the_end; |
| 5176 | 5176 | ||
| 5177 | n = S->tok, next(S); | 5177 | n = S->tccpp_tok, next(S); |
| 5178 | if (S->tok == ':' && !S->tccgen_in_generic) { | 5178 | if (S->tccpp_tok == ':' && !S->tccgen_in_generic) { |
| 5179 | /* ignore if it's a label */ | 5179 | /* ignore if it's a label */ |
| 5180 | unget_tok(S, n); | 5180 | unget_tok(S, n); |
| 5181 | goto the_end; | 5181 | goto the_end; |
| @@ -5215,7 +5215,7 @@ the_end: · 33 unmodified lines | |||
| 5215 | 5215 | ||
| 5216 | /* convert a function parameter type (array to pointer and function to | 5216 | /* convert a function parameter type (array to pointer and function to |
| 5217 | function pointer) */ | 5217 | function pointer) */ |
| 5218 | static inline void convert_parameter_type(TCCState *S, CType *pt) | 5218 | static inline void convert_parameter_type(TCCState* S, CType *pt) |
| 5219 | { | 5219 | { |
| 5220 | /* remove const and volatile qualifiers (XXX: const could be used | 5220 | /* remove const and volatile qualifiers (XXX: const could be used |
| 5221 | to indicate a const function parameter */ | 5221 | to indicate a const function parameter */ |
| @@ -5227,14 +5227,14 @@ static inline void convert_parameter_type(TCCState *S, CType *pt) · 5 unmodified lines | |||
| 5227 | } | 5227 | } |
| 5228 | } | 5228 | } |
| 5229 | 5229 | ||
| 5230 | ST_FUNC void parse_asm_str(TCCState *S, CString *astr) | 5230 | ST_FUNC void parse_asm_str(TCCState* S, CString *astr) |
| 5231 | { | 5231 | { |
| 5232 | skip(S, '('); | 5232 | skip(S, '('); |
| 5233 | parse_mult_str(S, astr, "string constant"); | 5233 | parse_mult_str(S, astr, "string constant"); |
| 5234 | } | 5234 | } |
| 5235 | 5235 | ||
| 5236 | /* Parse an asm label and return the token */ | 5236 | /* Parse an asm label and return the token */ |
| 5237 | static int asm_label_instr(TCCState *S) | 5237 | static int asm_label_instr(TCCState* S) |
| 5238 | { | 5238 | { |
| 5239 | int v; | 5239 | int v; |
| 5240 | CString astr; | 5240 | CString astr; |
| @@ -5250,19 +5250,19 @@ static int asm_label_instr(TCCState *S) · 9 unmodified lines | |||
| 5250 | return v; | 5250 | return v; |
| 5251 | } | 5251 | } |
| 5252 | 5252 | ||
| 5253 | static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, int td) | 5253 | static int post_type(TCCState* S, CType *type, AttributeDef *ad, int storage, int td) |
| 5254 | { | 5254 | { |
| 5255 | int n, l, t1, arg_size, align, unused_align; | 5255 | int n, l, t1, arg_size, align, unused_align; |
| 5256 | Sym **plast, *s, *first; | 5256 | Sym **plast, *s, *first; |
| 5257 | AttributeDef ad1; | 5257 | AttributeDef ad1; |
| 5258 | CType pt; | 5258 | CType pt; |
| 5259 | 5259 | ||
| 5260 | if (S->tok == '(') { | 5260 | if (S->tccpp_tok == '(') { |
| 5261 | /* function type, or recursive declarator (return if so) */ | 5261 | /* function type, or recursive declarator (return if so) */ |
| 5262 | next(S); | 5262 | next(S); |
| 5263 | if (td && !(td & TYPE_ABSTRACT)) | 5263 | if (td && !(td & TYPE_ABSTRACT)) |
| 5264 | return 0; | 5264 | return 0; |
| 5265 | if (S->tok == ')') | 5265 | if (S->tccpp_tok == ')') |
| 5266 | l = 0; | 5266 | l = 0; |
| 5267 | else if (parse_btype(S, &pt, &ad1)) | 5267 | else if (parse_btype(S, &pt, &ad1)) |
| 5268 | l = FUNC_NEW; | 5268 | l = FUNC_NEW; |
| @@ -5278,13 +5278,13 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in · 9 unmodified lines | |||
| 5278 | for(;;) { | 5278 | for(;;) { |
| 5279 | /* read param name and compute offset */ | 5279 | /* read param name and compute offset */ |
| 5280 | if (l != FUNC_OLD) { | 5280 | if (l != FUNC_OLD) { |
| 5281 | if ((pt.t & VT_BTYPE) == VT_VOID && S->tok == ')') | 5281 | if ((pt.t & VT_BTYPE) == VT_VOID && S->tccpp_tok == ')') |
| 5282 | break; | 5282 | break; |
| 5283 | type_decl(S, &pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT); | 5283 | type_decl(S, &pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT); |
| 5284 | if ((pt.t & VT_BTYPE) == VT_VOID) | 5284 | if ((pt.t & VT_BTYPE) == VT_VOID) |
| 5285 | tcc_error(S, "parameter declared as void"); | 5285 | tcc_error(S, "parameter declared as void"); |
| 5286 | } else { | 5286 | } else { |
| 5287 | n = S->tok; | 5287 | n = S->tccpp_tok; |
| 5288 | if (n < TOK_UIDENT) | 5288 | if (n < TOK_UIDENT) |
| 5289 | expect(S, "identifier"); | 5289 | expect(S, "identifier"); |
| 5290 | pt.t = VT_VOID; /* invalid type */ | 5290 | pt.t = VT_VOID; /* invalid type */ |
| @@ -5296,10 +5296,10 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in · 5 unmodified lines | |||
| 5296 | s = sym_push(S, n | SYM_FIELD, &pt, 0, 0); | 5296 | s = sym_push(S, n | SYM_FIELD, &pt, 0, 0); |
| 5297 | *plast = s; | 5297 | *plast = s; |
| 5298 | plast = &s->next; | 5298 | plast = &s->next; |
| 5299 | if (S->tok == ')') | 5299 | if (S->tccpp_tok == ')') |
| 5300 | break; | 5300 | break; |
| 5301 | skip(S, ','); | 5301 | skip(S, ','); |
| 5302 | if (l == FUNC_NEW && S->tok == TOK_DOTS) { | 5302 | if (l == FUNC_NEW && S->tccpp_tok == TOK_DOTS) { |
| 5303 | l = FUNC_ELLIPSIS; | 5303 | l = FUNC_ELLIPSIS; |
| 5304 | next(S); | 5304 | next(S); |
| 5305 | break; | 5305 | break; |
| @@ -5317,7 +5317,7 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in · 11 unmodified lines | |||
| 5317 | /* some ancient pre-K&R C allows a function to return an array | 5317 | /* some ancient pre-K&R C allows a function to return an array |
| 5318 | and the array brackets to be put after the arguments, such | 5318 | and the array brackets to be put after the arguments, such |
| 5319 | that "int c()[]" means something like "int[] c()" */ | 5319 | that "int c()[]" means something like "int[] c()" */ |
| 5320 | if (S->tok == '[') { | 5320 | if (S->tccpp_tok == '[') { |
| 5321 | next(S); | 5321 | next(S); |
| 5322 | skip(S, ']'); /* only handle simple "[]" */ | 5322 | skip(S, ']'); /* only handle simple "[]" */ |
| 5323 | mk_pointer(S, type); | 5323 | mk_pointer(S, type); |
| @@ -5331,15 +5331,15 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in · 7 unmodified lines | |||
| 5331 | s->next = first; | 5331 | s->next = first; |
| 5332 | type->t = VT_FUNC; | 5332 | type->t = VT_FUNC; |
| 5333 | type->ref = s; | 5333 | type->ref = s; |
| 5334 | } else if (S->tok == '[') { | 5334 | } else if (S->tccpp_tok == '[') { |
| 5335 | int saved_nocode_wanted = S->nocode_wanted; | 5335 | int saved_nocode_wanted = S->tccgen_nocode_wanted; |
| 5336 | /* array definition */ | 5336 | /* array definition */ |
| 5337 | next(S); | 5337 | next(S); |
| 5338 | while (1) { | 5338 | while (1) { |
| 5339 | /* XXX The optional type-quals and static should only be accepted | 5339 | /* XXX The optional type-quals and static should only be accepted |
| 5340 | in parameter decls. The '*' as well, and then even only | 5340 | in parameter decls. The '*' as well, and then even only |
| 5341 | in prototypes (not function defs). */ | 5341 | in prototypes (not function defs). */ |
| 5342 | switch (S->tok) { | 5342 | switch (S->tccpp_tok) { |
| 5343 | case TOK_RESTRICT1: case TOK_RESTRICT2: case TOK_RESTRICT3: | 5343 | case TOK_RESTRICT1: case TOK_RESTRICT2: case TOK_RESTRICT3: |
| 5344 | case TOK_CONST1: | 5344 | case TOK_CONST1: |
| 5345 | case TOK_VOLATILE1: | 5345 | case TOK_VOLATILE1: |
| @@ -5354,23 +5354,23 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in · 8 unmodified lines | |||
| 5354 | } | 5354 | } |
| 5355 | n = -1; | 5355 | n = -1; |
| 5356 | t1 = 0; | 5356 | t1 = 0; |
| 5357 | if (S->tok != ']') { | 5357 | if (S->tccpp_tok != ']') { |
| 5358 | if (!S->local_stack || (storage & VT_STATIC)) | 5358 | if (!S->tccgen_local_stack || (storage & VT_STATIC)) |
| 5359 | vpushi(S, expr_const(S)); | 5359 | vpushi(S, expr_const(S)); |
| 5360 | else { | 5360 | else { |
| 5361 | /* VLAs (which can only happen with local_stack && !VT_STATIC) | 5361 | /* VLAs (which can only happen with local_stack && !VT_STATIC) |
| 5362 | length must always be evaluated, even under nocode_wanted, | 5362 | length must always be evaluated, even under nocode_wanted, |
| 5363 | so that its size slot is initialized (e.g. under sizeof | 5363 | so that its size slot is initialized (e.g. under sizeof |
| 5364 | or typeof). */ | 5364 | or typeof). */ |
| 5365 | S->nocode_wanted = 0; | 5365 | S->tccgen_nocode_wanted = 0; |
| 5366 | gexpr(S); | 5366 | gexpr(S); |
| 5367 | } | 5367 | } |
| 5368 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 5368 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 5369 | n = S->vtop->c.i; | 5369 | n = S->tccgen_vtop->c.i; |
| 5370 | if (n < 0) | 5370 | if (n < 0) |
| 5371 | tcc_error(S, "invalid array size"); | 5371 | tcc_error(S, "invalid array size"); |
| 5372 | } else { | 5372 | } else { |
| 5373 | if (!is_integer_btype(S->vtop->type.t & VT_BTYPE)) | 5373 | if (!is_integer_btype(S->tccgen_vtop->type.t & VT_BTYPE)) |
| 5374 | tcc_error(S, "size of variable length array should be an integer"); | 5374 | tcc_error(S, "size of variable length array should be an integer"); |
| 5375 | n = 0; | 5375 | n = 0; |
| 5376 | t1 = VT_VLA; | 5376 | t1 = VT_VLA; |
| @@ -5391,9 +5391,9 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in · 14 unmodified lines | |||
| 5391 | if (t1 & VT_VLA) { | 5391 | if (t1 & VT_VLA) { |
| 5392 | if (n < 0) | 5392 | if (n < 0) |
| 5393 | tcc_error(S, "need explicit inner array size in VLAs"); | 5393 | tcc_error(S, "need explicit inner array size in VLAs"); |
| 5394 | S->loc -= type_size(&S->tccgen_int_type, &align); | 5394 | S->tccgen_loc -= type_size(&S->tccgen_int_type, &align); |
| 5395 | S->loc &= -align; | 5395 | S->tccgen_loc &= -align; |
| 5396 | n = S->loc; | 5396 | n = S->tccgen_loc; |
| 5397 | 5397 | ||
| 5398 | vla_runtime_type_size(S, type, &align); | 5398 | vla_runtime_type_size(S, type, &align); |
| 5399 | gen_op(S, '*'); | 5399 | gen_op(S, '*'); |
| @@ -5403,7 +5403,7 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in · 3 unmodified lines | |||
| 5403 | } | 5403 | } |
| 5404 | if (n != -1) | 5404 | if (n != -1) |
| 5405 | vpop(S); | 5405 | vpop(S); |
| 5406 | S->nocode_wanted = saved_nocode_wanted; | 5406 | S->tccgen_nocode_wanted = saved_nocode_wanted; |
| 5407 | 5407 | ||
| 5408 | /* we push an anonymous symbol which will contain the array | 5408 | /* we push an anonymous symbol which will contain the array |
| 5409 | element type */ | 5409 | element type */ |
| @@ -5421,7 +5421,7 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in · 11 unmodified lines | |||
| 5421 | type_decl(). If this (possibly abstract) declarator is a pointer chain | 5421 | type_decl(). If this (possibly abstract) declarator is a pointer chain |
| 5422 | it returns the innermost pointed to type (equals *type, but is a different | 5422 | it returns the innermost pointed to type (equals *type, but is a different |
| 5423 | pointer), otherwise returns type itself, that's used for recursive calls. */ | 5423 | pointer), otherwise returns type itself, that's used for recursive calls. */ |
| 5424 | static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int td) | 5424 | static CType *type_decl(TCCState* S, CType *type, AttributeDef *ad, int *v, int td) |
| 5425 | { | 5425 | { |
| 5426 | CType *post, *ret; | 5426 | CType *post, *ret; |
| 5427 | int qualifiers, storage; | 5427 | int qualifiers, storage; |
| @@ -5431,11 +5431,11 @@ static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int · 3 unmodified lines | |||
| 5431 | type->t &= ~VT_STORAGE; | 5431 | type->t &= ~VT_STORAGE; |
| 5432 | post = ret = type; | 5432 | post = ret = type; |
| 5433 | 5433 | ||
| 5434 | while (S->tok == '*') { | 5434 | while (S->tccpp_tok == '*') { |
| 5435 | qualifiers = 0; | 5435 | qualifiers = 0; |
| 5436 | redo: | 5436 | redo: |
| 5437 | next(S); | 5437 | next(S); |
| 5438 | switch(S->tok) { | 5438 | switch(S->tccpp_tok) { |
| 5439 | case TOK__Atomic: | 5439 | case TOK__Atomic: |
| 5440 | qualifiers |= VT_ATOMIC; | 5440 | qualifiers |= VT_ATOMIC; |
| 5441 | goto redo; | 5441 | goto redo; |
| @@ -5466,7 +5466,7 @@ static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int · 24 unmodified lines | |||
| 5466 | ret = pointed_type(type); | 5466 | ret = pointed_type(type); |
| 5467 | } | 5467 | } |
| 5468 | 5468 | ||
| 5469 | if (S->tok == '(') { | 5469 | if (S->tccpp_tok == '(') { |
| 5470 | /* This is possibly a parameter type list for abstract declarators | 5470 | /* This is possibly a parameter type list for abstract declarators |
| 5471 | ('int ()'), use post_type for testing this. */ | 5471 | ('int ()'), use post_type for testing this. */ |
| 5472 | if (!post_type(S, type, ad, 0, td)) { | 5472 | if (!post_type(S, type, ad, 0, td)) { |
| @@ -5479,9 +5479,9 @@ static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int · 6 unmodified lines | |||
| 5479 | skip(S, ')'); | 5479 | skip(S, ')'); |
| 5480 | } else | 5480 | } else |
| 5481 | goto abstract; | 5481 | goto abstract; |
| 5482 | } else if (S->tok >= TOK_IDENT && (td & TYPE_DIRECT)) { | 5482 | } else if (S->tccpp_tok >= TOK_IDENT && (td & TYPE_DIRECT)) { |
| 5483 | /* type identifier */ | 5483 | /* type identifier */ |
| 5484 | *v = S->tok; | 5484 | *v = S->tccpp_tok; |
| 5485 | next(S); | 5485 | next(S); |
| 5486 | } else { | 5486 | } else { |
| 5487 | abstract: | 5487 | abstract: |
| @@ -5496,30 +5496,30 @@ static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int · 8 unmodified lines | |||
| 5496 | } | 5496 | } |
| 5497 | 5497 | ||
| 5498 | /* indirection with full error checking and bound check */ | 5498 | /* indirection with full error checking and bound check */ |
| 5499 | ST_FUNC void indir(TCCState *S) | 5499 | ST_FUNC void indir(TCCState* S) |
| 5500 | { | 5500 | { |
| 5501 | if ((S->vtop->type.t & VT_BTYPE) != VT_PTR) { | 5501 | if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_PTR) { |
| 5502 | if ((S->vtop->type.t & VT_BTYPE) == VT_FUNC) | 5502 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FUNC) |
| 5503 | return; | 5503 | return; |
| 5504 | expect(S, "pointer"); | 5504 | expect(S, "pointer"); |
| 5505 | } | 5505 | } |
| 5506 | if (S->vtop->r & VT_LVAL) | 5506 | if (S->tccgen_vtop->r & VT_LVAL) |
| 5507 | gv(S, RC_INT); | 5507 | gv(S, RC_INT); |
| 5508 | S->vtop->type = *pointed_type(&S->vtop->type); | 5508 | S->tccgen_vtop->type = *pointed_type(&S->tccgen_vtop->type); |
| 5509 | /* Arrays and functions are never lvalues */ | 5509 | /* Arrays and functions are never lvalues */ |
| 5510 | if (!(S->vtop->type.t & (VT_ARRAY | VT_VLA)) | 5510 | if (!(S->tccgen_vtop->type.t & (VT_ARRAY | VT_VLA)) |
| 5511 | && (S->vtop->type.t & VT_BTYPE) != VT_FUNC) { | 5511 | && (S->tccgen_vtop->type.t & VT_BTYPE) != VT_FUNC) { |
| 5512 | S->vtop->r |= VT_LVAL; | 5512 | S->tccgen_vtop->r |= VT_LVAL; |
| 5513 | /* if bound checking, the referenced pointer must be checked */ | 5513 | /* if bound checking, the referenced pointer must be checked */ |
| 5514 | #ifdef CONFIG_TCC_BCHECK | 5514 | #ifdef CONFIG_TCC_BCHECK |
| 5515 | if (S->do_bounds_check) | 5515 | if (S->do_bounds_check) |
| 5516 | S->vtop->r |= VT_MUSTBOUND; | 5516 | S->tccgen_vtop->r |= VT_MUSTBOUND; |
| 5517 | #endif | 5517 | #endif |
| 5518 | } | 5518 | } |
| 5519 | } | 5519 | } |
| 5520 | 5520 | ||
| 5521 | /* pass a parameter to a function and do type checking and casting */ | 5521 | /* pass a parameter to a function and do type checking and casting */ |
| 5522 | static void gfunc_param_typed(TCCState *S, Sym *func, Sym *arg) | 5522 | static void gfunc_param_typed(TCCState* S, Sym *func, Sym *arg) |
| 5523 | { | 5523 | { |
| 5524 | int func_type; | 5524 | int func_type; |
| 5525 | CType type; | 5525 | CType type; |
| @@ -5528,13 +5528,13 @@ static void gfunc_param_typed(TCCState *S, Sym *func, Sym *arg) · 2 unmodified lines | |||
| 5528 | if (func_type == FUNC_OLD || | 5528 | if (func_type == FUNC_OLD || |
| 5529 | (func_type == FUNC_ELLIPSIS && arg == NULL)) { | 5529 | (func_type == FUNC_ELLIPSIS && arg == NULL)) { |
| 5530 | /* default casting : only need to convert float to double */ | 5530 | /* default casting : only need to convert float to double */ |
| 5531 | if ((S->vtop->type.t & VT_BTYPE) == VT_FLOAT) { | 5531 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FLOAT) { |
| 5532 | gen_cast_s(S, VT_DOUBLE); | 5532 | gen_cast_s(S, VT_DOUBLE); |
| 5533 | } else if (S->vtop->type.t & VT_BITFIELD) { | 5533 | } else if (S->tccgen_vtop->type.t & VT_BITFIELD) { |
| 5534 | type.t = S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED); | 5534 | type.t = S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED); |
| 5535 | type.ref = S->vtop->type.ref; | 5535 | type.ref = S->tccgen_vtop->type.ref; |
| 5536 | gen_cast(S, &type); | 5536 | gen_cast(S, &type); |
| 5537 | } else if (S->vtop->r & VT_MUSTCAST) { | 5537 | } else if (S->tccgen_vtop->r & VT_MUSTCAST) { |
| 5538 | force_charshort_cast(S); | 5538 | force_charshort_cast(S); |
| 5539 | } | 5539 | } |
| 5540 | } else if (arg == NULL) { | 5540 | } else if (arg == NULL) { |
| @@ -5547,18 +5547,18 @@ static void gfunc_param_typed(TCCState *S, Sym *func, Sym *arg) · 6 unmodified lines | |||
| 5547 | } | 5547 | } |
| 5548 | 5548 | ||
| 5549 | /* parse an expression and return its type without any side effect. */ | 5549 | /* parse an expression and return its type without any side effect. */ |
| 5550 | static void expr_type(TCCState *S, CType *type, void (*expr_fn)(TCCState *S)) | 5550 | static void expr_type(TCCState* S, CType *type, void (*expr_fn)(TCCState* S)) |
| 5551 | { | 5551 | { |
| 5552 | S->nocode_wanted++; | 5552 | S->tccgen_nocode_wanted++; |
| 5553 | expr_fn(S); | 5553 | expr_fn(S); |
| 5554 | *type = S->vtop->type; | 5554 | *type = S->tccgen_vtop->type; |
| 5555 | vpop(S); | 5555 | vpop(S); |
| 5556 | S->nocode_wanted--; | 5556 | S->tccgen_nocode_wanted--; |
| 5557 | } | 5557 | } |
| 5558 | 5558 | ||
| 5559 | /* parse an expression of the form '(type)' or '(expr)' and return its | 5559 | /* parse an expression of the form '(type)' or '(expr)' and return its |
| 5560 | type */ | 5560 | type */ |
| 5561 | static void parse_expr_type(TCCState *S, CType *type) | 5561 | static void parse_expr_type(TCCState* S, CType *type) |
| 5562 | { | 5562 | { |
| 5563 | int n; | 5563 | int n; |
| 5564 | AttributeDef ad; | 5564 | AttributeDef ad; |
| @@ -5572,7 +5572,7 @@ static void parse_expr_type(TCCState *S, CType *type) · 7 unmodified lines | |||
| 5572 | skip(S, ')'); | 5572 | skip(S, ')'); |
| 5573 | } | 5573 | } |
| 5574 | 5574 | ||
| 5575 | static void parse_type(TCCState *S, CType *type) | 5575 | static void parse_type(TCCState* S, CType *type) |
| 5576 | { | 5576 | { |
| 5577 | AttributeDef ad; | 5577 | AttributeDef ad; |
| 5578 | int n; | 5578 | int n; |
| @@ -5583,12 +5583,12 @@ static void parse_type(TCCState *S, CType *type) · 4 unmodified lines | |||
| 5583 | type_decl(S, type, &ad, &n, TYPE_ABSTRACT); | 5583 | type_decl(S, type, &ad, &n, TYPE_ABSTRACT); |
| 5584 | } | 5584 | } |
| 5585 | 5585 | ||
| 5586 | static void parse_builtin_params(TCCState *S, int nc, const char *args) | 5586 | static void parse_builtin_params(TCCState* S, int nc, const char *args) |
| 5587 | { | 5587 | { |
| 5588 | char c, sep = '('; | 5588 | char c, sep = '('; |
| 5589 | CType type; | 5589 | CType type; |
| 5590 | if (nc) | 5590 | if (nc) |
| 5591 | S->nocode_wanted++; | 5591 | S->tccgen_nocode_wanted++; |
| 5592 | next(S); | 5592 | next(S); |
| 5593 | if (*args == 0) | 5593 | if (*args == 0) |
| 5594 | skip(S, sep); | 5594 | skip(S, sep); |
| @@ -5631,10 +5631,10 @@ static void parse_builtin_params(TCCState *S, int nc, const char *args) · 36 unmodified lines | |||
| 5631 | } | 5631 | } |
| 5632 | skip(S, ')'); | 5632 | skip(S, ')'); |
| 5633 | if (nc) | 5633 | if (nc) |
| 5634 | S->nocode_wanted--; | 5634 | S->tccgen_nocode_wanted--; |
| 5635 | } | 5635 | } |
| 5636 | 5636 | ||
| 5637 | static void parse_atomic(TCCState *S, int atok) | 5637 | static void parse_atomic(TCCState* S, int atok) |
| 5638 | { | 5638 | { |
| 5639 | int size, align, arg; | 5639 | int size, align, arg; |
| 5640 | CType *atom, *atom_ptr, ct = {0}; | 5640 | CType *atom, *atom_ptr, ct = {0}; |
| @@ -5675,7 +5675,7 @@ static void parse_atomic(TCCState *S, int atok) · 34 unmodified lines | |||
| 5675 | switch (template[arg]) { | 5675 | switch (template[arg]) { |
| 5676 | case 'a': | 5676 | case 'a': |
| 5677 | case 'A': | 5677 | case 'A': |
| 5678 | atom_ptr = &S->vtop->type; | 5678 | atom_ptr = &S->tccgen_vtop->type; |
| 5679 | if ((atom_ptr->t & VT_BTYPE) != VT_PTR) | 5679 | if ((atom_ptr->t & VT_BTYPE) != VT_PTR) |
| 5680 | expect(S, "pointer"); | 5680 | expect(S, "pointer"); |
| 5681 | atom = pointed_type(atom_ptr); | 5681 | atom = pointed_type(atom_ptr); |
| @@ -5692,8 +5692,8 @@ static void parse_atomic(TCCState *S, int atok) · 10 unmodified lines | |||
| 5692 | break; | 5692 | break; |
| 5693 | 5693 | ||
| 5694 | case 'p': | 5694 | case 'p': |
| 5695 | if ((S->vtop->type.t & VT_BTYPE) != VT_PTR | 5695 | if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_PTR |
| 5696 | || type_size(pointed_type(&S->vtop->type), &align) != size) | 5696 | || type_size(pointed_type(&S->tccgen_vtop->type), &align) != size) |
| 5697 | tcc_error(S, "pointer target type mismatch in argument %d", arg + 1); | 5697 | tcc_error(S, "pointer target type mismatch in argument %d", arg + 1); |
| 5698 | gen_assign_cast(S, atom_ptr); | 5698 | gen_assign_cast(S, atom_ptr); |
| 5699 | break; | 5699 | break; |
| @@ -5730,17 +5730,17 @@ static void parse_atomic(TCCState *S, int atok) · 30 unmodified lines | |||
| 5730 | gfunc_call(S, arg); | 5730 | gfunc_call(S, arg); |
| 5731 | 5731 | ||
| 5732 | vpush(S, &ct); | 5732 | vpush(S, &ct); |
| 5733 | PUT_R_RET(S->vtop, ct.t); | 5733 | PUT_R_RET(S->tccgen_vtop, ct.t); |
| 5734 | if (ct.t == VT_BOOL) { | 5734 | if (ct.t == VT_BOOL) { |
| 5735 | #ifdef PROMOTE_RET | 5735 | #ifdef PROMOTE_RET |
| 5736 | S->vtop->r |= BFVAL(VT_MUSTCAST, 1); | 5736 | S->tccgen_vtop->r |= BFVAL(VT_MUSTCAST, 1); |
| 5737 | #else | 5737 | #else |
| 5738 | S->vtop->type.t = VT_INT; | 5738 | S->tccgen_vtop->type.t = VT_INT; |
| 5739 | #endif | 5739 | #endif |
| 5740 | } | 5740 | } |
| 5741 | } | 5741 | } |
| 5742 | 5742 | ||
| 5743 | ST_FUNC void unary(TCCState *S) | 5743 | ST_FUNC void unary(TCCState* S) |
| 5744 | { | 5744 | { |
| 5745 | int n, t, align, size, r, sizeof_caller; | 5745 | int n, t, align, size, r, sizeof_caller; |
| 5746 | CType type; | 5746 | CType type; |
| @@ -5757,7 +5757,7 @@ ST_FUNC void unary(TCCState *S) · 10 unmodified lines | |||
| 5757 | /* XXX: GCC 2.95.3 does not generate a table although it should be | 5757 | /* XXX: GCC 2.95.3 does not generate a table although it should be |
| 5758 | better here */ | 5758 | better here */ |
| 5759 | tok_next: | 5759 | tok_next: |
| 5760 | switch(S->tok) { | 5760 | switch(S->tccpp_tok) { |
| 5761 | case TOK_EXTENSION: | 5761 | case TOK_EXTENSION: |
| 5762 | next(S); | 5762 | next(S); |
| 5763 | goto tok_next; | 5763 | goto tok_next; |
| @@ -5771,7 +5771,7 @@ ST_FUNC void unary(TCCState *S) · 7 unmodified lines | |||
| 5771 | t = VT_INT; | 5771 | t = VT_INT; |
| 5772 | push_tokc: | 5772 | push_tokc: |
| 5773 | type.t = t; | 5773 | type.t = t; |
| 5774 | vsetc(S, &type, VT_CONST, &S->tokc); | 5774 | vsetc(S, &type, VT_CONST, &S->tccpp_tokc); |
| 5775 | next(S); | 5775 | next(S); |
| 5776 | break; | 5776 | break; |
| 5777 | case TOK_CUINT: | 5777 | case TOK_CUINT: |
| @@ -5849,7 +5849,7 @@ ST_FUNC void unary(TCCState *S) · 71 unmodified lines | |||
| 5849 | type_decl(S, &type, &ad, &n, TYPE_ABSTRACT); | 5849 | type_decl(S, &type, &ad, &n, TYPE_ABSTRACT); |
| 5850 | skip(S, ')'); | 5850 | skip(S, ')'); |
| 5851 | /* check ISOC99 compound literal */ | 5851 | /* check ISOC99 compound literal */ |
| 5852 | if (S->tok == '{') { | 5852 | if (S->tccpp_tok == '{') { |
| 5853 | /* data is allocated locally by default */ | 5853 | /* data is allocated locally by default */ |
| 5854 | if (S->tccgen_global_expr) | 5854 | if (S->tccgen_global_expr) |
| 5855 | r = VT_CONST; | 5855 | r = VT_CONST; |
| @@ -5868,11 +5868,11 @@ ST_FUNC void unary(TCCState *S) · 12 unmodified lines | |||
| 5868 | unary(S); | 5868 | unary(S); |
| 5869 | gen_cast(S, &type); | 5869 | gen_cast(S, &type); |
| 5870 | } | 5870 | } |
| 5871 | } else if (S->tok == '{') { | 5871 | } else if (S->tccpp_tok == '{') { |
| 5872 | int saved_nocode_wanted = S->nocode_wanted; | 5872 | int saved_nocode_wanted = S->tccgen_nocode_wanted; |
| 5873 | if (S->tccgen_const_wanted && !(S->nocode_wanted & unevalmask)) | 5873 | if (S->tccgen_const_wanted && !(S->tccgen_nocode_wanted & unevalmask)) |
| 5874 | expect(S, "constant"); | 5874 | expect(S, "constant"); |
| 5875 | if (0 == S->local_scope) | 5875 | if (0 == S->tccgen_local_scope) |
| 5876 | tcc_error(S, "statement expression outside of function"); | 5876 | tcc_error(S, "statement expression outside of function"); |
| 5877 | /* save all registers */ | 5877 | /* save all registers */ |
| 5878 | save_regs(S, 0); | 5878 | save_regs(S, 0); |
| @@ -5882,7 +5882,7 @@ ST_FUNC void unary(TCCState *S) · 3 unmodified lines | |||
| 5882 | outside, so any reactivation of code emission (from labels | 5882 | outside, so any reactivation of code emission (from labels |
| 5883 | or loop heads) can be disabled again after the end of it. */ | 5883 | or loop heads) can be disabled again after the end of it. */ |
| 5884 | block(S, 1); | 5884 | block(S, 1); |
| 5885 | S->nocode_wanted = saved_nocode_wanted; | 5885 | S->tccgen_nocode_wanted = saved_nocode_wanted; |
| 5886 | skip(S, ')'); | 5886 | skip(S, ')'); |
| 5887 | } else { | 5887 | } else { |
| 5888 | gexpr(S); | 5888 | gexpr(S); |
| @@ -5902,12 +5902,12 @@ ST_FUNC void unary(TCCState *S) · 13 unmodified lines | |||
| 5902 | functions are not lvalues, we only have to handle it | 5902 | functions are not lvalues, we only have to handle it |
| 5903 | there and in function calls. */ | 5903 | there and in function calls. */ |
| 5904 | /* arrays can also be used although they are not lvalues */ | 5904 | /* arrays can also be used although they are not lvalues */ |
| 5905 | if ((S->vtop->type.t & VT_BTYPE) != VT_FUNC && | 5905 | if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FUNC && |
| 5906 | !(S->vtop->type.t & VT_ARRAY)) | 5906 | !(S->tccgen_vtop->type.t & VT_ARRAY)) |
| 5907 | test_lvalue(S); | 5907 | test_lvalue(S); |
| 5908 | if (S->vtop->sym) | 5908 | if (S->tccgen_vtop->sym) |
| 5909 | S->vtop->sym->a.addrtaken = 1; | 5909 | S->tccgen_vtop->sym->a.addrtaken = 1; |
| 5910 | mk_pointer(S, &S->vtop->type); | 5910 | mk_pointer(S, &S->tccgen_vtop->type); |
| 5911 | gaddrof(S); | 5911 | gaddrof(S); |
| 5912 | break; | 5912 | break; |
| 5913 | case '!': | 5913 | case '!': |
| @@ -5924,12 +5924,12 @@ ST_FUNC void unary(TCCState *S) · 10 unmodified lines | |||
| 5924 | case '+': | 5924 | case '+': |
| 5925 | next(S); | 5925 | next(S); |
| 5926 | unary(S); | 5926 | unary(S); |
| 5927 | if ((S->vtop->type.t & VT_BTYPE) == VT_PTR) | 5927 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_PTR) |
| 5928 | tcc_error(S, "pointer not accepted for unary plus"); | 5928 | tcc_error(S, "pointer not accepted for unary plus"); |
| 5929 | /* In order to force cast, we add zero, except for floating point | 5929 | /* In order to force cast, we add zero, except for floating point |
| 5930 | where we really need an noop (otherwise -0.0 will be transformed | 5930 | where we really need an noop (otherwise -0.0 will be transformed |
| 5931 | into +0.0). */ | 5931 | into +0.0). */ |
| 5932 | if (!is_float(S->vtop->type.t)) { | 5932 | if (!is_float(S->tccgen_vtop->type.t)) { |
| 5933 | vpushi(S, 0); | 5933 | vpushi(S, 0); |
| 5934 | gen_op(S, '+'); | 5934 | gen_op(S, '+'); |
| 5935 | } | 5935 | } |
| @@ -5938,13 +5938,13 @@ ST_FUNC void unary(TCCState *S) · 2 unmodified lines | |||
| 5938 | case TOK_ALIGNOF1: | 5938 | case TOK_ALIGNOF1: |
| 5939 | case TOK_ALIGNOF2: | 5939 | case TOK_ALIGNOF2: |
| 5940 | case TOK_ALIGNOF3: | 5940 | case TOK_ALIGNOF3: |
| 5941 | t = S->tok; | 5941 | t = S->tccpp_tok; |
| 5942 | next(S); | 5942 | next(S); |
| 5943 | S->tccgen_in_sizeof++; | 5943 | S->tccgen_in_sizeof++; |
| 5944 | expr_type(S, &type, unary); /* Perform a in_sizeof = 0; */ | 5944 | expr_type(S, &type, unary); /* Perform a in_sizeof = 0; */ |
| 5945 | s = NULL; | 5945 | s = NULL; |
| 5946 | if (S->vtop[1].r & VT_SYM) | 5946 | if (S->tccgen_vtop[1].r & VT_SYM) |
| 5947 | s = S->vtop[1].sym; /* hack: accessing previous vtop */ | 5947 | s = S->tccgen_vtop[1].sym; /* hack: accessing previous vtop */ |
| 5948 | size = type_size(&type, &align); | 5948 | size = type_size(&type, &align); |
| 5949 | if (s && s->a.aligned) | 5949 | if (s && s->a.aligned) |
| 5950 | align = 1 << (s->a.aligned - 1); | 5950 | align = 1 << (s->a.aligned - 1); |
| @@ -5959,7 +5959,7 @@ ST_FUNC void unary(TCCState *S) · 8 unmodified lines | |||
| 5959 | } else { | 5959 | } else { |
| 5960 | vpushs(S, align); | 5960 | vpushs(S, align); |
| 5961 | } | 5961 | } |
| 5962 | S->vtop->type.t |= VT_UNSIGNED; | 5962 | S->tccgen_vtop->type.t |= VT_UNSIGNED; |
| 5963 | break; | 5963 | break; |
| 5964 | 5964 | ||
| 5965 | case TOK_builtin_expect: | 5965 | case TOK_builtin_expect: |
| @@ -5969,10 +5969,10 @@ ST_FUNC void unary(TCCState *S) · 3 unmodified lines | |||
| 5969 | break; | 5969 | break; |
| 5970 | case TOK_builtin_types_compatible_p: | 5970 | case TOK_builtin_types_compatible_p: |
| 5971 | parse_builtin_params(S, 0, "tt"); | 5971 | parse_builtin_params(S, 0, "tt"); |
| 5972 | S->vtop[-1].type.t &= ~(VT_CONSTANT | VT_VOLATILE); | 5972 | S->tccgen_vtop[-1].type.t &= ~(VT_CONSTANT | VT_VOLATILE); |
| 5973 | S->vtop[0].type.t &= ~(VT_CONSTANT | VT_VOLATILE); | 5973 | S->tccgen_vtop[0].type.t &= ~(VT_CONSTANT | VT_VOLATILE); |
| 5974 | n = is_compatible_types(&S->vtop[-1].type, &S->vtop[0].type); | 5974 | n = is_compatible_types(&S->tccgen_vtop[-1].type, &S->tccgen_vtop[0].type); |
| 5975 | S->vtop -= 2; | 5975 | S->tccgen_vtop -= 2; |
| 5976 | vpushi(S, n); | 5976 | vpushi(S, n); |
| 5977 | break; | 5977 | break; |
| 5978 | case TOK_builtin_choose_expr: | 5978 | case TOK_builtin_choose_expr: |
| @@ -5983,46 +5983,46 @@ ST_FUNC void unary(TCCState *S) · 4 unmodified lines | |||
| 5983 | c = expr_const64(S); | 5983 | c = expr_const64(S); |
| 5984 | skip(S, ','); | 5984 | skip(S, ','); |
| 5985 | if (!c) { | 5985 | if (!c) { |
| 5986 | S->nocode_wanted++; | 5986 | S->tccgen_nocode_wanted++; |
| 5987 | } | 5987 | } |
| 5988 | expr_eq(S); | 5988 | expr_eq(S); |
| 5989 | if (!c) { | 5989 | if (!c) { |
| 5990 | vpop(S); | 5990 | vpop(S); |
| 5991 | S->nocode_wanted--; | 5991 | S->tccgen_nocode_wanted--; |
| 5992 | } | 5992 | } |
| 5993 | skip(S, ','); | 5993 | skip(S, ','); |
| 5994 | if (c) { | 5994 | if (c) { |
| 5995 | S->nocode_wanted++; | 5995 | S->tccgen_nocode_wanted++; |
| 5996 | } | 5996 | } |
| 5997 | expr_eq(S); | 5997 | expr_eq(S); |
| 5998 | if (c) { | 5998 | if (c) { |
| 5999 | vpop(S); | 5999 | vpop(S); |
| 6000 | S->nocode_wanted--; | 6000 | S->tccgen_nocode_wanted--; |
| 6001 | } | 6001 | } |
| 6002 | skip(S, ')'); | 6002 | skip(S, ')'); |
| 6003 | } | 6003 | } |
| 6004 | break; | 6004 | break; |
| 6005 | case TOK_builtin_constant_p: | 6005 | case TOK_builtin_constant_p: |
| 6006 | parse_builtin_params(S, 1, "e"); | 6006 | parse_builtin_params(S, 1, "e"); |
| 6007 | n = (S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && | 6007 | n = (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && |
| 6008 | !((S->vtop->r & VT_SYM) && S->vtop->sym->a.addrtaken); | 6008 | !((S->tccgen_vtop->r & VT_SYM) && S->tccgen_vtop->sym->a.addrtaken); |
| 6009 | S->vtop--; | 6009 | S->tccgen_vtop--; |
| 6010 | vpushi(S, n); | 6010 | vpushi(S, n); |
| 6011 | break; | 6011 | break; |
| 6012 | case TOK_builtin_frame_address: | 6012 | case TOK_builtin_frame_address: |
| 6013 | case TOK_builtin_return_address: | 6013 | case TOK_builtin_return_address: |
| 6014 | { | 6014 | { |
| 6015 | int tok1 = S->tok; | 6015 | int tok1 = S->tccpp_tok; |
| 6016 | int level; | 6016 | int level; |
| 6017 | next(S); | 6017 | next(S); |
| 6018 | skip(S, '('); | 6018 | skip(S, '('); |
| 6019 | if (S->tok != TOK_CINT) { | 6019 | if (S->tccpp_tok != TOK_CINT) { |
| 6020 | tcc_error(S, "%s only takes positive integers", | 6020 | tcc_error(S, "%s only takes positive integers", |
| 6021 | tok1 == TOK_builtin_return_address ? | 6021 | tok1 == TOK_builtin_return_address ? |
| 6022 | "__builtin_return_address" : | 6022 | "__builtin_return_address" : |
| 6023 | "__builtin_frame_address"); | 6023 | "__builtin_frame_address"); |
| 6024 | } | 6024 | } |
| 6025 | level = (uint32_t)S->tokc.i; | 6025 | level = (uint32_t)S->tccpp_tokc.i; |
| 6026 | next(S); | 6026 | next(S); |
| 6027 | skip(S, ')'); | 6027 | skip(S, ')'); |
| 6028 | type.t = VT_VOID; | 6028 | type.t = VT_VOID; |
| @@ -6033,7 +6033,7 @@ ST_FUNC void unary(TCCState *S) · 4 unmodified lines | |||
| 6033 | vpushi(S, 2*PTR_SIZE); | 6033 | vpushi(S, 2*PTR_SIZE); |
| 6034 | gen_op(S, '-'); | 6034 | gen_op(S, '-'); |
| 6035 | #endif | 6035 | #endif |
| 6036 | mk_pointer(S, &S->vtop->type); | 6036 | mk_pointer(S, &S->tccgen_vtop->type); |
| 6037 | indir(S); /* -> parent frame */ | 6037 | indir(S); /* -> parent frame */ |
| 6038 | } | 6038 | } |
| 6039 | if (tok1 == TOK_builtin_return_address) { | 6039 | if (tok1 == TOK_builtin_return_address) { |
| @@ -6048,7 +6048,7 @@ ST_FUNC void unary(TCCState *S) · 8 unmodified lines | |||
| 6048 | vpushi(S, PTR_SIZE); | 6048 | vpushi(S, PTR_SIZE); |
| 6049 | gen_op(S, '+'); | 6049 | gen_op(S, '+'); |
| 6050 | #endif | 6050 | #endif |
| 6051 | mk_pointer(S, &S->vtop->type); | 6051 | mk_pointer(S, &S->tccgen_vtop->type); |
| 6052 | indir(S); | 6052 | indir(S); |
| 6053 | } | 6053 | } |
| 6054 | } | 6054 | } |
| @@ -6056,7 +6056,7 @@ ST_FUNC void unary(TCCState *S) · 1 unmodified line | |||
| 6056 | #ifdef TCC_TARGET_RISCV64 | 6056 | #ifdef TCC_TARGET_RISCV64 |
| 6057 | case TOK_builtin_va_start: | 6057 | case TOK_builtin_va_start: |
| 6058 | parse_builtin_params(S, 0, "ee"); | 6058 | parse_builtin_params(S, 0, "ee"); |
| 6059 | r = S->vtop->r & VT_VALMASK; | 6059 | r = S->tccgen_vtop->r & VT_VALMASK; |
| 6060 | if (r == VT_LLOCAL) | 6060 | if (r == VT_LLOCAL) |
| 6061 | r = VT_LOCAL; | 6061 | r = VT_LOCAL; |
| 6062 | if (r != VT_LOCAL) | 6062 | if (r != VT_LOCAL) |
| @@ -6069,20 +6069,20 @@ ST_FUNC void unary(TCCState *S) · 6 unmodified lines | |||
| 6069 | #ifdef TCC_TARGET_PE | 6069 | #ifdef TCC_TARGET_PE |
| 6070 | case TOK_builtin_va_start: | 6070 | case TOK_builtin_va_start: |
| 6071 | parse_builtin_params(S, 0, "ee"); | 6071 | parse_builtin_params(S, 0, "ee"); |
| 6072 | r = S->vtop->r & VT_VALMASK; | 6072 | r = S->tccgen_vtop->r & VT_VALMASK; |
| 6073 | if (r == VT_LLOCAL) | 6073 | if (r == VT_LLOCAL) |
| 6074 | r = VT_LOCAL; | 6074 | r = VT_LOCAL; |
| 6075 | if (r != VT_LOCAL) | 6075 | if (r != VT_LOCAL) |
| 6076 | tcc_error(S, "__builtin_va_start expects a local variable"); | 6076 | tcc_error(S, "__builtin_va_start expects a local variable"); |
| 6077 | S->vtop->r = r; | 6077 | S->tccgen_vtop->r = r; |
| 6078 | S->vtop->type = S->char_pointer_type; | 6078 | S->tccgen_vtop->type = S->tccgen_char_pointer_type; |
| 6079 | S->vtop->c.i += 8; | 6079 | S->tccgen_vtop->c.i += 8; |
| 6080 | vstore(S); | 6080 | vstore(S); |
| 6081 | break; | 6081 | break; |
| 6082 | #else | 6082 | #else |
| 6083 | case TOK_builtin_va_arg_types: | 6083 | case TOK_builtin_va_arg_types: |
| 6084 | parse_builtin_params(S, 0, "t"); | 6084 | parse_builtin_params(S, 0, "t"); |
| 6085 | vpushi(S, classify_x86_64_va_arg(&S->vtop->type)); | 6085 | vpushi(S, classify_x86_64_va_arg(&S->tccgen_vtop->type)); |
| 6086 | vswap(S); | 6086 | vswap(S); |
| 6087 | vpop(S); | 6087 | vpop(S); |
| 6088 | break; | 6088 | break; |
| @@ -6095,23 +6095,23 @@ ST_FUNC void unary(TCCState *S) · 6 unmodified lines | |||
| 6095 | //xx check types | 6095 | //xx check types |
| 6096 | gen_va_start(S); | 6096 | gen_va_start(S); |
| 6097 | vpushi(S, 0); | 6097 | vpushi(S, 0); |
| 6098 | S->vtop->type.t = VT_VOID; | 6098 | S->tccgen_vtop->type.t = VT_VOID; |
| 6099 | break; | 6099 | break; |
| 6100 | } | 6100 | } |
| 6101 | case TOK_builtin_va_arg: { | 6101 | case TOK_builtin_va_arg: { |
| 6102 | parse_builtin_params(S, 0, "et"); | 6102 | parse_builtin_params(S, 0, "et"); |
| 6103 | type = S->vtop->type; | 6103 | type = S->tccgen_vtop->type; |
| 6104 | vpop(S); | 6104 | vpop(S); |
| 6105 | //xx check types | 6105 | //xx check types |
| 6106 | gen_va_arg(S, &type); | 6106 | gen_va_arg(S, &type); |
| 6107 | S->vtop->type = type; | 6107 | S->tccgen_vtop->type = type; |
| 6108 | break; | 6108 | break; |
| 6109 | } | 6109 | } |
| 6110 | case TOK___arm64_clear_cache: { | 6110 | case TOK___arm64_clear_cache: { |
| 6111 | parse_builtin_params(S, 0, "ee"); | 6111 | parse_builtin_params(S, 0, "ee"); |
| 6112 | gen_clear_cache(S); | 6112 | gen_clear_cache(S); |
| 6113 | vpushi(S, 0); | 6113 | vpushi(S, 0); |
| 6114 | S->vtop->type.t = VT_VOID; | 6114 | S->tccgen_vtop->type.t = VT_VOID; |
| 6115 | break; | 6115 | break; |
| 6116 | } | 6116 | } |
| 6117 | #endif | 6117 | #endif |
| @@ -6126,13 +6126,13 @@ ST_FUNC void unary(TCCState *S) · 8 unmodified lines | |||
| 6126 | case TOK___atomic_fetch_or: | 6126 | case TOK___atomic_fetch_or: |
| 6127 | case TOK___atomic_fetch_xor: | 6127 | case TOK___atomic_fetch_xor: |
| 6128 | case TOK___atomic_fetch_and: | 6128 | case TOK___atomic_fetch_and: |
| 6129 | parse_atomic(S, S->tok); | 6129 | parse_atomic(S, S->tccpp_tok); |
| 6130 | break; | 6130 | break; |
| 6131 | 6131 | ||
| 6132 | /* pre operations */ | 6132 | /* pre operations */ |
| 6133 | case TOK_INC: | 6133 | case TOK_INC: |
| 6134 | case TOK_DEC: | 6134 | case TOK_DEC: |
| 6135 | t = S->tok; | 6135 | t = S->tccpp_tok; |
| 6136 | next(S); | 6136 | next(S); |
| 6137 | unary(S); | 6137 | unary(S); |
| 6138 | inc(S, 0, t); | 6138 | inc(S, 0, t); |
| @@ -6140,7 +6140,7 @@ ST_FUNC void unary(TCCState *S) · 1 unmodified line | |||
| 6140 | case '-': | 6140 | case '-': |
| 6141 | next(S); | 6141 | next(S); |
| 6142 | unary(S); | 6142 | unary(S); |
| 6143 | if (is_float(S->vtop->type.t)) { | 6143 | if (is_float(S->tccgen_vtop->type.t)) { |
| 6144 | gen_opif(S, TOK_NEG); | 6144 | gen_opif(S, TOK_NEG); |
| 6145 | } else { | 6145 | } else { |
| 6146 | vpushi(S, 0); | 6146 | vpushi(S, 0); |
| @@ -6153,11 +6153,11 @@ ST_FUNC void unary(TCCState *S) · 6 unmodified lines | |||
| 6153 | goto tok_identifier; | 6153 | goto tok_identifier; |
| 6154 | next(S); | 6154 | next(S); |
| 6155 | /* allow to take the address of a label */ | 6155 | /* allow to take the address of a label */ |
| 6156 | if (S->tok < TOK_UIDENT) | 6156 | if (S->tccpp_tok < TOK_UIDENT) |
| 6157 | expect(S, "label identifier"); | 6157 | expect(S, "label identifier"); |
| 6158 | s = label_find(S, S->tok); | 6158 | s = label_find(S, S->tccpp_tok); |
| 6159 | if (!s) { | 6159 | if (!s) { |
| 6160 | s = label_push(S, &S->tccgen_global_label_stack, S->tok, LABEL_FORWARD); | 6160 | s = label_push(S, &S->tccgen_global_label_stack, S->tccpp_tok, LABEL_FORWARD); |
| 6161 | } else { | 6161 | } else { |
| 6162 | if (s->r == LABEL_DECLARED) | 6162 | if (s->r == LABEL_DECLARED) |
| 6163 | s->r = LABEL_FORWARD; | 6163 | s->r = LABEL_FORWARD; |
| @@ -6191,7 +6191,7 @@ ST_FUNC void unary(TCCState *S) · 27 unmodified lines | |||
| 6191 | for (;;) { | 6191 | for (;;) { |
| 6192 | learn = 0; | 6192 | learn = 0; |
| 6193 | skip(S, ','); | 6193 | skip(S, ','); |
| 6194 | if (S->tok == TOK_DEFAULT) { | 6194 | if (S->tccpp_tok == TOK_DEFAULT) { |
| 6195 | if (has_default) | 6195 | if (has_default) |
| 6196 | tcc_error(S, "too many 'default'"); | 6196 | tcc_error(S, "too many 'default'"); |
| 6197 | has_default = 1; | 6197 | has_default = 1; |
| @@ -6224,7 +6224,7 @@ ST_FUNC void unary(TCCState *S) · 26 unmodified lines | |||
| 6224 | } else { | 6224 | } else { |
| 6225 | skip_or_save_block(S, NULL); | 6225 | skip_or_save_block(S, NULL); |
| 6226 | } | 6226 | } |
| 6227 | if (S->tok == ')') | 6227 | if (S->tccpp_tok == ')') |
| 6228 | break; | 6228 | break; |
| 6229 | } | 6229 | } |
| 6230 | if (!str) { | 6230 | if (!str) { |
| @@ -6235,7 +6235,7 @@ ST_FUNC void unary(TCCState *S) · 4 unmodified lines | |||
| 6235 | begin_macro(S, str, 1); | 6235 | begin_macro(S, str, 1); |
| 6236 | next(S); | 6236 | next(S); |
| 6237 | expr_eq(S); | 6237 | expr_eq(S); |
| 6238 | if (S->tok != TOK_EOF) | 6238 | if (S->tccpp_tok != TOK_EOF) |
| 6239 | expect(S, ","); | 6239 | expect(S, ","); |
| 6240 | end_macro(S); | 6240 | end_macro(S); |
| 6241 | next(S); | 6241 | next(S); |
| @@ -6246,7 +6246,7 @@ ST_FUNC void unary(TCCState *S) · 4 unmodified lines | |||
| 6246 | n = 0x7fc00000; | 6246 | n = 0x7fc00000; |
| 6247 | special_math_val: | 6247 | special_math_val: |
| 6248 | vpushi(S, n); | 6248 | vpushi(S, n); |
| 6249 | S->vtop->type.t = VT_FLOAT; | 6249 | S->tccgen_vtop->type.t = VT_FLOAT; |
| 6250 | next(S); | 6250 | next(S); |
| 6251 | break; | 6251 | break; |
| 6252 | case TOK___SNAN__: | 6252 | case TOK___SNAN__: |
| @@ -6258,14 +6258,14 @@ special_math_val: · 5 unmodified lines | |||
| 6258 | 6258 | ||
| 6259 | default: | 6259 | default: |
| 6260 | tok_identifier: | 6260 | tok_identifier: |
| 6261 | t = S->tok; | 6261 | t = S->tccpp_tok; |
| 6262 | next(S); | 6262 | next(S); |
| 6263 | if (t < TOK_UIDENT) | 6263 | if (t < TOK_UIDENT) |
| 6264 | expect(S, "identifier"); | 6264 | expect(S, "identifier"); |
| 6265 | s = sym_find(S, t); | 6265 | s = sym_find(S, t); |
| 6266 | if (!s || IS_ASM_SYM(s)) { | 6266 | if (!s || IS_ASM_SYM(s)) { |
| 6267 | const char *name = get_tok_str(S, t, NULL); | 6267 | const char *name = get_tok_str(S, t, NULL); |
| 6268 | if (S->tok != '(') | 6268 | if (S->tccpp_tok != '(') |
| 6269 | tcc_error(S, "'%s' undeclared", name); | 6269 | tcc_error(S, "'%s' undeclared", name); |
| 6270 | /* for simple function calls, we tolerate undeclared | 6270 | /* for simple function calls, we tolerate undeclared |
| 6271 | external reference to int() function */ | 6271 | external reference to int() function */ |
| @@ -6284,84 +6284,84 @@ special_math_val: · 12 unmodified lines | |||
| 6284 | /* Point to s as backpointer (even without r&VT_SYM). | 6284 | /* Point to s as backpointer (even without r&VT_SYM). |
| 6285 | Will be used by at least the x86 inline asm parser for | 6285 | Will be used by at least the x86 inline asm parser for |
| 6286 | regvars. */ | 6286 | regvars. */ |
| 6287 | S->vtop->sym = s; | 6287 | S->tccgen_vtop->sym = s; |
| 6288 | 6288 | ||
| 6289 | if (r & VT_SYM) { | 6289 | if (r & VT_SYM) { |
| 6290 | S->vtop->c.i = 0; | 6290 | S->tccgen_vtop->c.i = 0; |
| 6291 | } else if (r == VT_CONST && IS_ENUM_VAL(s->type.t)) { | 6291 | } else if (r == VT_CONST && IS_ENUM_VAL(s->type.t)) { |
| 6292 | S->vtop->c.i = s->enum_val; | 6292 | S->tccgen_vtop->c.i = s->enum_val; |
| 6293 | } | 6293 | } |
| 6294 | break; | 6294 | break; |
| 6295 | } | 6295 | } |
| 6296 | 6296 | ||
| 6297 | /* post operations */ | 6297 | /* post operations */ |
| 6298 | while (1) { | 6298 | while (1) { |
| 6299 | if (S->tok == TOK_INC || S->tok == TOK_DEC) { | 6299 | if (S->tccpp_tok == TOK_INC || S->tccpp_tok == TOK_DEC) { |
| 6300 | inc(S, 1, S->tok); | 6300 | inc(S, 1, S->tccpp_tok); |
| 6301 | next(S); | 6301 | next(S); |
| 6302 | } else if (S->tok == '.' || S->tok == TOK_ARROW || S->tok == TOK_CDOUBLE) { | 6302 | } else if (S->tccpp_tok == '.' || S->tccpp_tok == TOK_ARROW || S->tccpp_tok == TOK_CDOUBLE) { |
| 6303 | int qualifiers, cumofs = 0; | 6303 | int qualifiers, cumofs = 0; |
| 6304 | /* field */ | 6304 | /* field */ |
| 6305 | if (S->tok == TOK_ARROW) | 6305 | if (S->tccpp_tok == TOK_ARROW) |
| 6306 | indir(S); | 6306 | indir(S); |
| 6307 | qualifiers = S->vtop->type.t & (VT_CONSTANT | VT_VOLATILE); | 6307 | qualifiers = S->tccgen_vtop->type.t & (VT_CONSTANT | VT_VOLATILE); |
| 6308 | test_lvalue(S); | 6308 | test_lvalue(S); |
| 6309 | gaddrof(S); | 6309 | gaddrof(S); |
| 6310 | /* expect pointer on structure */ | 6310 | /* expect pointer on structure */ |
| 6311 | if ((S->vtop->type.t & VT_BTYPE) != VT_STRUCT) | 6311 | if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_STRUCT) |
| 6312 | expect(S, "struct or union"); | 6312 | expect(S, "struct or union"); |
| 6313 | if (S->tok == TOK_CDOUBLE) | 6313 | if (S->tccpp_tok == TOK_CDOUBLE) |
| 6314 | expect(S, "field name"); | 6314 | expect(S, "field name"); |
| 6315 | next(S); | 6315 | next(S); |
| 6316 | if (S->tok == TOK_CINT || S->tok == TOK_CUINT) | 6316 | if (S->tccpp_tok == TOK_CINT || S->tccpp_tok == TOK_CUINT) |
| 6317 | expect(S, "field name"); | 6317 | expect(S, "field name"); |
| 6318 | s = find_field(&S->vtop->type, S->tok, &cumofs); | 6318 | s = find_field(&S->tccgen_vtop->type, S->tccpp_tok, &cumofs); |
| 6319 | if (!s) | 6319 | if (!s) |
| 6320 | tcc_error(S, "field not found: %s", get_tok_str(S, S->tok & ~SYM_FIELD, &S->tokc)); | 6320 | tcc_error(S, "field not found: %s", get_tok_str(S, S->tccpp_tok & ~SYM_FIELD, &S->tccpp_tokc)); |
| 6321 | /* add field offset to pointer */ | 6321 | /* add field offset to pointer */ |
| 6322 | S->vtop->type = S->char_pointer_type; /* change type to 'char *' */ | 6322 | S->tccgen_vtop->type = S->tccgen_char_pointer_type; /* change type to 'char *' */ |
| 6323 | vpushi(S, cumofs + s->c); | 6323 | vpushi(S, cumofs + s->c); |
| 6324 | gen_op(S, '+'); | 6324 | gen_op(S, '+'); |
| 6325 | /* change type to field type, and set to lvalue */ | 6325 | /* change type to field type, and set to lvalue */ |
| 6326 | S->vtop->type = s->type; | 6326 | S->tccgen_vtop->type = s->type; |
| 6327 | S->vtop->type.t |= qualifiers; | 6327 | S->tccgen_vtop->type.t |= qualifiers; |
| 6328 | /* an array is never an lvalue */ | 6328 | /* an array is never an lvalue */ |
| 6329 | if (!(S->vtop->type.t & VT_ARRAY)) { | 6329 | if (!(S->tccgen_vtop->type.t & VT_ARRAY)) { |
| 6330 | S->vtop->r |= VT_LVAL; | 6330 | S->tccgen_vtop->r |= VT_LVAL; |
| 6331 | #ifdef CONFIG_TCC_BCHECK | 6331 | #ifdef CONFIG_TCC_BCHECK |
| 6332 | /* if bound checking, the referenced pointer must be checked */ | 6332 | /* if bound checking, the referenced pointer must be checked */ |
| 6333 | if (S->do_bounds_check) | 6333 | if (S->do_bounds_check) |
| 6334 | S->vtop->r |= VT_MUSTBOUND; | 6334 | S->tccgen_vtop->r |= VT_MUSTBOUND; |
| 6335 | #endif | 6335 | #endif |
| 6336 | } | 6336 | } |
| 6337 | next(S); | 6337 | next(S); |
| 6338 | } else if (S->tok == '[') { | 6338 | } else if (S->tccpp_tok == '[') { |
| 6339 | next(S); | 6339 | next(S); |
| 6340 | gexpr(S); | 6340 | gexpr(S); |
| 6341 | gen_op(S, '+'); | 6341 | gen_op(S, '+'); |
| 6342 | indir(S); | 6342 | indir(S); |
| 6343 | skip(S, ']'); | 6343 | skip(S, ']'); |
| 6344 | } else if (S->tok == '(') { | 6344 | } else if (S->tccpp_tok == '(') { |
| 6345 | SValue ret; | 6345 | SValue ret; |
| 6346 | Sym *sa; | 6346 | Sym *sa; |
| 6347 | int nb_args, ret_nregs, ret_align, regsize, variadic; | 6347 | int nb_args, ret_nregs, ret_align, regsize, variadic; |
| 6348 | 6348 | ||
| 6349 | /* function call */ | 6349 | /* function call */ |
| 6350 | if ((S->vtop->type.t & VT_BTYPE) != VT_FUNC) { | 6350 | if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FUNC) { |
| 6351 | /* pointer test (no array accepted) */ | 6351 | /* pointer test (no array accepted) */ |
| 6352 | if ((S->vtop->type.t & (VT_BTYPE | VT_ARRAY)) == VT_PTR) { | 6352 | if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_ARRAY)) == VT_PTR) { |
| 6353 | S->vtop->type = *pointed_type(&S->vtop->type); | 6353 | S->tccgen_vtop->type = *pointed_type(&S->tccgen_vtop->type); |
| 6354 | if ((S->vtop->type.t & VT_BTYPE) != VT_FUNC) | 6354 | if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FUNC) |
| 6355 | goto error_func; | 6355 | goto error_func; |
| 6356 | } else { | 6356 | } else { |
| 6357 | error_func: | 6357 | error_func: |
| 6358 | expect(S, "function pointer"); | 6358 | expect(S, "function pointer"); |
| 6359 | } | 6359 | } |
| 6360 | } else { | 6360 | } else { |
| 6361 | S->vtop->r &= ~VT_LVAL; /* no lvalue */ | 6361 | S->tccgen_vtop->r &= ~VT_LVAL; /* no lvalue */ |
| 6362 | } | 6362 | } |
| 6363 | /* get return type */ | 6363 | /* get return type */ |
| 6364 | s = S->vtop->type.ref; | 6364 | s = S->tccgen_vtop->type.ref; |
| 6365 | next(S); | 6365 | next(S); |
| 6366 | sa = s->next; /* first parameter */ | 6366 | sa = s->next; /* first parameter */ |
| 6367 | nb_args = regsize = 0; | 6367 | nb_args = regsize = 0; |
| @@ -6383,19 +6383,19 @@ special_math_val: · 15 unmodified lines | |||
| 6383 | while (size & (size - 1)) | 6383 | while (size & (size - 1)) |
| 6384 | size = (size | (size - 1)) + 1; | 6384 | size = (size | (size - 1)) + 1; |
| 6385 | #endif | 6385 | #endif |
| 6386 | S->loc = (S->loc - size) & -align; | 6386 | S->tccgen_loc = (S->tccgen_loc - size) & -align; |
| 6387 | ret.type = s->type; | 6387 | ret.type = s->type; |
| 6388 | ret.r = VT_LOCAL | VT_LVAL; | 6388 | ret.r = VT_LOCAL | VT_LVAL; |
| 6389 | /* pass it as 'int' to avoid structure arg passing | 6389 | /* pass it as 'int' to avoid structure arg passing |
| 6390 | problems */ | 6390 | problems */ |
| 6391 | vseti(S, VT_LOCAL, S->loc); | 6391 | vseti(S, VT_LOCAL, S->tccgen_loc); |
| 6392 | #ifdef CONFIG_TCC_BCHECK | 6392 | #ifdef CONFIG_TCC_BCHECK |
| 6393 | if (S->do_bounds_check) | 6393 | if (S->do_bounds_check) |
| 6394 | --S->loc; | 6394 | --S->tccgen_loc; |
| 6395 | #endif | 6395 | #endif |
| 6396 | ret.c = S->vtop->c; | 6396 | ret.c = S->tccgen_vtop->c; |
| 6397 | if (ret_nregs < 0) | 6397 | if (ret_nregs < 0) |
| 6398 | S->vtop--; | 6398 | S->tccgen_vtop--; |
| 6399 | else | 6399 | else |
| 6400 | nb_args++; | 6400 | nb_args++; |
| 6401 | } | 6401 | } |
| @@ -6409,14 +6409,14 @@ special_math_val: · 7 unmodified lines | |||
| 6409 | ret.c.i = 0; | 6409 | ret.c.i = 0; |
| 6410 | PUT_R_RET(&ret, ret.type.t); | 6410 | PUT_R_RET(&ret, ret.type.t); |
| 6411 | } | 6411 | } |
| 6412 | if (S->tok != ')') { | 6412 | if (S->tccpp_tok != ')') { |
| 6413 | for(;;) { | 6413 | for(;;) { |
| 6414 | expr_eq(S); | 6414 | expr_eq(S); |
| 6415 | gfunc_param_typed(S, s, sa); | 6415 | gfunc_param_typed(S, s, sa); |
| 6416 | nb_args++; | 6416 | nb_args++; |
| 6417 | if (sa) | 6417 | if (sa) |
| 6418 | sa = sa->next; | 6418 | sa = sa->next; |
| 6419 | if (S->tok == ')') | 6419 | if (S->tccpp_tok == ')') |
| 6420 | break; | 6420 | break; |
| 6421 | skip(S, ','); | 6421 | skip(S, ','); |
| 6422 | } | 6422 | } |
| @@ -6435,7 +6435,7 @@ special_math_val: · 12 unmodified lines | |||
| 6435 | /* return value */ | 6435 | /* return value */ |
| 6436 | for (r = ret.r + ret_nregs + !ret_nregs; r-- > ret.r;) { | 6436 | for (r = ret.r + ret_nregs + !ret_nregs; r-- > ret.r;) { |
| 6437 | vsetc(S, &ret.type, r, &ret.c); | 6437 | vsetc(S, &ret.type, r, &ret.c); |
| 6438 | S->vtop->r2 = ret.r2; /* Loop only happens when r2 is VT_CONST */ | 6438 | S->tccgen_vtop->r2 = ret.r2; /* Loop only happens when r2 is VT_CONST */ |
| 6439 | } | 6439 | } |
| 6440 | 6440 | ||
| 6441 | /* handle packed struct return */ | 6441 | /* handle packed struct return */ |
| @@ -6447,14 +6447,14 @@ special_math_val: · 5 unmodified lines | |||
| 6447 | space. Assume register size is power of 2. */ | 6447 | space. Assume register size is power of 2. */ |
| 6448 | if (regsize > align) | 6448 | if (regsize > align) |
| 6449 | align = regsize; | 6449 | align = regsize; |
| 6450 | S->loc = (S->loc - size) & -align; | 6450 | S->tccgen_loc = (S->tccgen_loc - size) & -align; |
| 6451 | addr = S->loc; | 6451 | addr = S->tccgen_loc; |
| 6452 | offset = 0; | 6452 | offset = 0; |
| 6453 | for (;;) { | 6453 | for (;;) { |
| 6454 | vset(S, &ret.type, VT_LOCAL | VT_LVAL, addr + offset); | 6454 | vset(S, &ret.type, VT_LOCAL | VT_LVAL, addr + offset); |
| 6455 | vswap(S); | 6455 | vswap(S); |
| 6456 | vstore(S); | 6456 | vstore(S); |
| 6457 | S->vtop--; | 6457 | S->tccgen_vtop--; |
| 6458 | if (--ret_nregs == 0) | 6458 | if (--ret_nregs == 0) |
| 6459 | break; | 6459 | break; |
| 6460 | offset += regsize; | 6460 | offset += regsize; |
| @@ -6470,9 +6470,9 @@ special_math_val: · 9 unmodified lines | |||
| 6470 | t = s->type.t & VT_BTYPE; | 6470 | t = s->type.t & VT_BTYPE; |
| 6471 | if (t == VT_BYTE || t == VT_SHORT || t == VT_BOOL) { | 6471 | if (t == VT_BYTE || t == VT_SHORT || t == VT_BOOL) { |
| 6472 | #ifdef PROMOTE_RET | 6472 | #ifdef PROMOTE_RET |
| 6473 | S->vtop->r |= BFVAL(VT_MUSTCAST, 1); | 6473 | S->tccgen_vtop->r |= BFVAL(VT_MUSTCAST, 1); |
| 6474 | #else | 6474 | #else |
| 6475 | S->vtop->type.t = VT_INT; | 6475 | S->tccgen_vtop->type.t = VT_INT; |
| 6476 | #endif | 6476 | #endif |
| 6477 | } | 6477 | } |
| 6478 | } | 6478 | } |
| @@ -6494,7 +6494,7 @@ static void expr_prod(void) · 15 unmodified lines | |||
| 6494 | int t; | 6494 | int t; |
| 6495 | 6495 | ||
| 6496 | unary(S); | 6496 | unary(S); |
| 6497 | while ((t = Stok) == '*' || t == '/' || t == '%') { | 6497 | while ((t = Stccpp_tok) == '*' || t == '/' || t == '%') { |
| 6498 | next(S); | 6498 | next(S); |
| 6499 | unary(S); | 6499 | unary(S); |
| 6500 | gen_op(S, t); | 6500 | gen_op(S, t); |
| @@ -6506,7 +6506,7 @@ static void expr_sum(void) · 5 unmodified lines | |||
| 6506 | int t; | 6506 | int t; |
| 6507 | 6507 | ||
| 6508 | expr_prod(); | 6508 | expr_prod(); |
| 6509 | while ((t = Stok) == '+' || t == '-') { | 6509 | while ((t = Stccpp_tok) == '+' || t == '-') { |
| 6510 | next(S); | 6510 | next(S); |
| 6511 | expr_prod(); | 6511 | expr_prod(); |
| 6512 | gen_op(S, t); | 6512 | gen_op(S, t); |
| @@ -6518,7 +6518,7 @@ static void expr_shift(void) · 5 unmodified lines | |||
| 6518 | int t; | 6518 | int t; |
| 6519 | 6519 | ||
| 6520 | expr_sum(); | 6520 | expr_sum(); |
| 6521 | while ((t = Stok) == TOK_SHL || t == TOK_SAR) { | 6521 | while ((t = Stccpp_tok) == TOK_SHL || t == TOK_SAR) { |
| 6522 | next(S); | 6522 | next(S); |
| 6523 | expr_sum(); | 6523 | expr_sum(); |
| 6524 | gen_op(S, t); | 6524 | gen_op(S, t); |
| @@ -6530,7 +6530,7 @@ static void expr_cmp(void) · 5 unmodified lines | |||
| 6530 | int t; | 6530 | int t; |
| 6531 | 6531 | ||
| 6532 | expr_shift(); | 6532 | expr_shift(); |
| 6533 | while (((t = Stok) >= TOK_ULE && t <= TOK_GT) || | 6533 | while (((t = Stccpp_tok) >= TOK_ULE && t <= TOK_GT) || |
| 6534 | t == TOK_ULT || t == TOK_UGE) { | 6534 | t == TOK_ULT || t == TOK_UGE) { |
| 6535 | next(S); | 6535 | next(S); |
| 6536 | expr_shift(); | 6536 | expr_shift(); |
| @@ -6543,7 +6543,7 @@ static void expr_cmpeq(void) · 6 unmodified lines | |||
| 6543 | int t; | 6543 | int t; |
| 6544 | 6544 | ||
| 6545 | expr_cmp(); | 6545 | expr_cmp(); |
| 6546 | while ((t = Stok) == TOK_EQ || t == TOK_NE) { | 6546 | while ((t = Stccpp_tok) == TOK_EQ || t == TOK_NE) { |
| 6547 | next(S); | 6547 | next(S); |
| 6548 | expr_cmp(); | 6548 | expr_cmp(); |
| 6549 | gen_op(S, t); | 6549 | gen_op(S, t); |
| @@ -6553,7 +6553,7 @@ static void expr_cmpeq(void) · 3 unmodified lines | |||
| 6553 | static void expr_and(void) | 6553 | static void expr_and(void) |
| 6554 | { | 6554 | { |
| 6555 | expr_cmpeq(); | 6555 | expr_cmpeq(); |
| 6556 | while (Stok == '&') { | 6556 | while (Stccpp_tok == '&') { |
| 6557 | next(S); | 6557 | next(S); |
| 6558 | expr_cmpeq(); | 6558 | expr_cmpeq(); |
| 6559 | gen_op(S, '&'); | 6559 | gen_op(S, '&'); |
| @@ -6563,7 +6563,7 @@ static void expr_and(void) · 3 unmodified lines | |||
| 6563 | static void expr_xor(void) | 6563 | static void expr_xor(void) |
| 6564 | { | 6564 | { |
| 6565 | expr_and(); | 6565 | expr_and(); |
| 6566 | while (Stok == '^') { | 6566 | while (Stccpp_tok == '^') { |
| 6567 | next(S); | 6567 | next(S); |
| 6568 | expr_and(); | 6568 | expr_and(); |
| 6569 | gen_op(S, '^'); | 6569 | gen_op(S, '^'); |
| @@ -6573,7 +6573,7 @@ static void expr_xor(void) · 3 unmodified lines | |||
| 6573 | static void expr_or(void) | 6573 | static void expr_or(void) |
| 6574 | { | 6574 | { |
| 6575 | expr_xor(); | 6575 | expr_xor(); |
| 6576 | while (Stok == '|') { | 6576 | while (Stccpp_tok == '|') { |
| 6577 | next(S); | 6577 | next(S); |
| 6578 | expr_xor(); | 6578 | expr_xor(); |
| 6579 | gen_op(S, '|'); | 6579 | gen_op(S, '|'); |
| @@ -6585,15 +6585,15 @@ static void expr_landor(S, int op); · 5 unmodified lines | |||
| 6585 | static void expr_land(void) | 6585 | static void expr_land(void) |
| 6586 | { | 6586 | { |
| 6587 | expr_or(); | 6587 | expr_or(); |
| 6588 | if (Stok == TOK_LAND) | 6588 | if (Stccpp_tok == TOK_LAND) |
| 6589 | expr_landor(S, Stok); | 6589 | expr_landor(S, Stccpp_tok); |
| 6590 | } | 6590 | } |
| 6591 | 6591 | ||
| 6592 | static void expr_lor(void) | 6592 | static void expr_lor(void) |
| 6593 | { | 6593 | { |
| 6594 | expr_land(); | 6594 | expr_land(); |
| 6595 | if (Stok == TOK_LOR) | 6595 | if (Stccpp_tok == TOK_LOR) |
| 6596 | expr_landor(S, Stok); | 6596 | expr_landor(S, Stccpp_tok); |
| 6597 | } | 6597 | } |
| 6598 | 6598 | ||
| 6599 | # define expr_landor_next(op) op == TOK_LAND ? expr_or() : expr_land() | 6599 | # define expr_landor_next(op) op == TOK_LAND ? expr_or() : expr_land() |
| @@ -6620,7 +6620,7 @@ static int precedence(int tok) · 20 unmodified lines | |||
| 6620 | return 0; | 6620 | return 0; |
| 6621 | } | 6621 | } |
| 6622 | } | 6622 | } |
| 6623 | static void init_prec(TCCState *S) | 6623 | static void init_prec(TCCState* S) |
| 6624 | { | 6624 | { |
| 6625 | int i; | 6625 | int i; |
| 6626 | for (i = 0; i < 256; i++) | 6626 | for (i = 0; i < 256; i++) |
| @@ -6628,22 +6628,22 @@ static void init_prec(TCCState *S) · 1 unmodified line | |||
| 6628 | } | 6628 | } |
| 6629 | #define precedence(i) ((unsigned)i < 256 ? S->tccgen_prec[i] : 0) | 6629 | #define precedence(i) ((unsigned)i < 256 ? S->tccgen_prec[i] : 0) |
| 6630 | 6630 | ||
| 6631 | static void expr_landor(TCCState *S, int op); | 6631 | static void expr_landor(TCCState* S, int op); |
| 6632 | 6632 | ||
| 6633 | static void expr_infix(TCCState *S, int p) | 6633 | static void expr_infix(TCCState* S, int p) |
| 6634 | { | 6634 | { |
| 6635 | int t = S->tok, p2; | 6635 | int t = S->tccpp_tok, p2; |
| 6636 | while ((p2 = precedence(t)) >= p) { | 6636 | while ((p2 = precedence(t)) >= p) { |
| 6637 | if (t == TOK_LOR || t == TOK_LAND) { | 6637 | if (t == TOK_LOR || t == TOK_LAND) { |
| 6638 | expr_landor(S, t); | 6638 | expr_landor(S, t); |
| 6639 | } else { | 6639 | } else { |
| 6640 | next(S); | 6640 | next(S); |
| 6641 | unary(S); | 6641 | unary(S); |
| 6642 | if (precedence(S->tok) > p2) | 6642 | if (precedence(S->tccpp_tok) > p2) |
| 6643 | expr_infix(S, p2 + 1); | 6643 | expr_infix(S, p2 + 1); |
| 6644 | gen_op(S, t); | 6644 | gen_op(S, t); |
| 6645 | } | 6645 | } |
| 6646 | t = S->tok; | 6646 | t = S->tccpp_tok; |
| 6647 | } | 6647 | } |
| 6648 | } | 6648 | } |
| 6649 | #endif | 6649 | #endif |
| @@ -6651,20 +6651,20 @@ static void expr_infix(TCCState *S, int p) · 1 unmodified line | |||
| 6651 | /* Assuming vtop is a value used in a conditional context | 6651 | /* Assuming vtop is a value used in a conditional context |
| 6652 | (i.e. compared with zero) return 0 if it's false, 1 if | 6652 | (i.e. compared with zero) return 0 if it's false, 1 if |
| 6653 | true and -1 if it can't be statically determined. */ | 6653 | true and -1 if it can't be statically determined. */ |
| 6654 | static int condition_3way(TCCState *S) | 6654 | static int condition_3way(TCCState* S) |
| 6655 | { | 6655 | { |
| 6656 | int c = -1; | 6656 | int c = -1; |
| 6657 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && | 6657 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && |
| 6658 | (!(S->vtop->r & VT_SYM) || !S->vtop->sym->a.weak)) { | 6658 | (!(S->tccgen_vtop->r & VT_SYM) || !S->tccgen_vtop->sym->a.weak)) { |
| 6659 | vdup(S); | 6659 | vdup(S); |
| 6660 | gen_cast_s(S, VT_BOOL); | 6660 | gen_cast_s(S, VT_BOOL); |
| 6661 | c = S->vtop->c.i; | 6661 | c = S->tccgen_vtop->c.i; |
| 6662 | vpop(S); | 6662 | vpop(S); |
| 6663 | } | 6663 | } |
| 6664 | return c; | 6664 | return c; |
| 6665 | } | 6665 | } |
| 6666 | 6666 | ||
| 6667 | static void expr_landor(TCCState *S, int op) | 6667 | static void expr_landor(TCCState* S, int op) |
| 6668 | { | 6668 | { |
| 6669 | int t = 0, cc = 1, f = 0, i = op == TOK_LAND, c; | 6669 | int t = 0, cc = 1, f = 0, i = op == TOK_LAND, c; |
| 6670 | for(;;) { | 6670 | for(;;) { |
| @@ -6672,8 +6672,8 @@ static void expr_landor(TCCState *S, int op) · 1 unmodified line | |||
| 6672 | if (c < 0) | 6672 | if (c < 0) |
| 6673 | save_regs(S, 1), cc = 0; | 6673 | save_regs(S, 1), cc = 0; |
| 6674 | else if (c != i) | 6674 | else if (c != i) |
| 6675 | S->nocode_wanted++, f = 1; | 6675 | S->tccgen_nocode_wanted++, f = 1; |
| 6676 | if (S->tok != op) | 6676 | if (S->tccpp_tok != op) |
| 6677 | break; | 6677 | break; |
| 6678 | if (c < 0) | 6678 | if (c < 0) |
| 6679 | t = gvtst(S, i, t); | 6679 | t = gvtst(S, i, t); |
| @@ -6686,7 +6686,7 @@ static void expr_landor(TCCState *S, int op) · 6 unmodified lines | |||
| 6686 | vpop(S); | 6686 | vpop(S); |
| 6687 | vpushi(S, i ^ f); | 6687 | vpushi(S, i ^ f); |
| 6688 | gsym(S, t); | 6688 | gsym(S, t); |
| 6689 | S->nocode_wanted -= f; | 6689 | S->tccgen_nocode_wanted -= f; |
| 6690 | } else { | 6690 | } else { |
| 6691 | gvtst_set(S, i, t); | 6691 | gvtst_set(S, i, t); |
| 6692 | } | 6692 | } |
| @@ -6702,7 +6702,7 @@ static int is_cond_bool(SValue *sv) · 9 unmodified lines | |||
| 6702 | return 0; | 6702 | return 0; |
| 6703 | } | 6703 | } |
| 6704 | 6704 | ||
| 6705 | static void expr_cond(TCCState *S) | 6705 | static void expr_cond(TCCState* S) |
| 6706 | { | 6706 | { |
| 6707 | int tt, u, r1, r2, rc, t1, t2, islv, c, g; | 6707 | int tt, u, r1, r2, rc, t1, t2, islv, c, g; |
| 6708 | SValue sv; | 6708 | SValue sv; |
| @@ -6710,10 +6710,10 @@ static void expr_cond(TCCState *S) · 1 unmodified line | |||
| 6710 | int ncw_prev; | 6710 | int ncw_prev; |
| 6711 | 6711 | ||
| 6712 | expr_lor(); | 6712 | expr_lor(); |
| 6713 | if (S->tok == '?') { | 6713 | if (S->tccpp_tok == '?') { |
| 6714 | next(S); | 6714 | next(S); |
| 6715 | c = condition_3way(S); | 6715 | c = condition_3way(S); |
| 6716 | g = (S->tok == ':' && gnu_ext); | 6716 | g = (S->tccpp_tok == ':' && gnu_ext); |
| 6717 | tt = 0; | 6717 | tt = 0; |
| 6718 | if (!g) { | 6718 | if (!g) { |
| 6719 | if (c < 0) { | 6719 | if (c < 0) { |
| @@ -6730,16 +6730,16 @@ static void expr_cond(TCCState *S) · 10 unmodified lines | |||
| 6730 | tt = gvtst(S, 0, 0); | 6730 | tt = gvtst(S, 0, 0); |
| 6731 | } | 6731 | } |
| 6732 | 6732 | ||
| 6733 | ncw_prev = S->nocode_wanted; | 6733 | ncw_prev = S->tccgen_nocode_wanted; |
| 6734 | if (c == 0) | 6734 | if (c == 0) |
| 6735 | S->nocode_wanted++; | 6735 | S->tccgen_nocode_wanted++; |
| 6736 | if (!g) | 6736 | if (!g) |
| 6737 | gexpr(S); | 6737 | gexpr(S); |
| 6738 | 6738 | ||
| 6739 | if ((S->vtop->type.t & VT_BTYPE) == VT_FUNC) | 6739 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FUNC) |
| 6740 | mk_pointer(S, &S->vtop->type); | 6740 | mk_pointer(S, &S->tccgen_vtop->type); |
| 6741 | sv = *S->vtop; /* save value to handle it later */ | 6741 | sv = *S->tccgen_vtop; /* save value to handle it later */ |
| 6742 | S->vtop--; /* no vpop so that FP stack is not flushed */ | 6742 | S->tccgen_vtop--; /* no vpop so that FP stack is not flushed */ |
| 6743 | 6743 | ||
| 6744 | if (g) { | 6744 | if (g) { |
| 6745 | u = tt; | 6745 | u = tt; |
| @@ -6749,13 +6749,13 @@ static void expr_cond(TCCState *S) · 3 unmodified lines | |||
| 6749 | } else | 6749 | } else |
| 6750 | u = 0; | 6750 | u = 0; |
| 6751 | 6751 | ||
| 6752 | S->nocode_wanted = ncw_prev; | 6752 | S->tccgen_nocode_wanted = ncw_prev; |
| 6753 | if (c == 1) | 6753 | if (c == 1) |
| 6754 | S->nocode_wanted++; | 6754 | S->tccgen_nocode_wanted++; |
| 6755 | skip(S, ':'); | 6755 | skip(S, ':'); |
| 6756 | expr_cond(S); | 6756 | expr_cond(S); |
| 6757 | 6757 | ||
| 6758 | if (c < 0 && is_cond_bool(S->vtop) && is_cond_bool(&sv)) { | 6758 | if (c < 0 && is_cond_bool(S->tccgen_vtop) && is_cond_bool(&sv)) { |
| 6759 | /* optimize "if (f ? a > b : c || d) ..." for example, where normally | 6759 | /* optimize "if (f ? a > b : c || d) ..." for example, where normally |
| 6760 | "a < b" and "c || d" would be forced to "(int)0/1" first, whereas | 6760 | "a < b" and "c || d" would be forced to "(int)0/1" first, whereas |
| 6761 | this code jumps directly to the if's then/else branches. */ | 6761 | this code jumps directly to the if's then/else branches. */ |
| @@ -6766,29 +6766,29 @@ static void expr_cond(TCCState *S) · 4 unmodified lines | |||
| 6766 | /* combine jump targets of 2nd op with VT_CMP of 1st op */ | 6766 | /* combine jump targets of 2nd op with VT_CMP of 1st op */ |
| 6767 | gvtst_set(S, 0, t1); | 6767 | gvtst_set(S, 0, t1); |
| 6768 | gvtst_set(S, 1, t2); | 6768 | gvtst_set(S, 1, t2); |
| 6769 | S->nocode_wanted = ncw_prev; | 6769 | S->tccgen_nocode_wanted = ncw_prev; |
| 6770 | // tcc_warning(S, "two conditions expr_cond"); | 6770 | // tcc_warning(S, "two conditions expr_cond"); |
| 6771 | return; | 6771 | return; |
| 6772 | } | 6772 | } |
| 6773 | 6773 | ||
| 6774 | if ((S->vtop->type.t & VT_BTYPE) == VT_FUNC) | 6774 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FUNC) |
| 6775 | mk_pointer(S, &S->vtop->type); | 6775 | mk_pointer(S, &S->tccgen_vtop->type); |
| 6776 | 6776 | ||
| 6777 | /* cast operands to correct type according to ISOC rules */ | 6777 | /* cast operands to correct type according to ISOC rules */ |
| 6778 | if (!combine_types(S, &type, &sv, S->vtop, '?')) | 6778 | if (!combine_types(S, &type, &sv, S->tccgen_vtop, '?')) |
| 6779 | type_incompatibility_error(S, &sv.type, &S->vtop->type, | 6779 | type_incompatibility_error(S, &sv.type, &S->tccgen_vtop->type, |
| 6780 | "type mismatch in conditional expression (have '%s' and '%s')"); | 6780 | "type mismatch in conditional expression (have '%s' and '%s')"); |
| 6781 | /* keep structs lvalue by transforming `(expr ? a : b)` to `*(expr ? &a : &b)` so | 6781 | /* keep structs lvalue by transforming `(expr ? a : b)` to `*(expr ? &a : &b)` so |
| 6782 | that `(expr ? a : b).mem` does not error with "lvalue expected" */ | 6782 | that `(expr ? a : b).mem` does not error with "lvalue expected" */ |
| 6783 | islv = (S->vtop->r & VT_LVAL) && (sv.r & VT_LVAL) && VT_STRUCT == (type.t & VT_BTYPE); | 6783 | islv = (S->tccgen_vtop->r & VT_LVAL) && (sv.r & VT_LVAL) && VT_STRUCT == (type.t & VT_BTYPE); |
| 6784 | 6784 | ||
| 6785 | /* now we convert second operand */ | 6785 | /* now we convert second operand */ |
| 6786 | if (c != 1) { | 6786 | if (c != 1) { |
| 6787 | gen_cast(S, &type); | 6787 | gen_cast(S, &type); |
| 6788 | if (islv) { | 6788 | if (islv) { |
| 6789 | mk_pointer(S, &S->vtop->type); | 6789 | mk_pointer(S, &S->tccgen_vtop->type); |
| 6790 | gaddrof(S); | 6790 | gaddrof(S); |
| 6791 | } else if (VT_STRUCT == (S->vtop->type.t & VT_BTYPE)) | 6791 | } else if (VT_STRUCT == (S->tccgen_vtop->type.t & VT_BTYPE)) |
| 6792 | gaddrof(S); | 6792 | gaddrof(S); |
| 6793 | } | 6793 | } |
| 6794 | 6794 | ||
| @@ -6804,24 +6804,24 @@ static void expr_cond(TCCState *S) · 9 unmodified lines | |||
| 6804 | tt = gjmp(S, 0); | 6804 | tt = gjmp(S, 0); |
| 6805 | } | 6805 | } |
| 6806 | gsym(S, u); | 6806 | gsym(S, u); |
| 6807 | S->nocode_wanted = ncw_prev; | 6807 | S->tccgen_nocode_wanted = ncw_prev; |
| 6808 | 6808 | ||
| 6809 | /* this is horrible, but we must also convert first | 6809 | /* this is horrible, but we must also convert first |
| 6810 | operand */ | 6810 | operand */ |
| 6811 | if (c != 0) { | 6811 | if (c != 0) { |
| 6812 | *S->vtop = sv; | 6812 | *S->tccgen_vtop = sv; |
| 6813 | gen_cast(S, &type); | 6813 | gen_cast(S, &type); |
| 6814 | if (islv) { | 6814 | if (islv) { |
| 6815 | mk_pointer(S, &S->vtop->type); | 6815 | mk_pointer(S, &S->tccgen_vtop->type); |
| 6816 | gaddrof(S); | 6816 | gaddrof(S); |
| 6817 | } else if (VT_STRUCT == (S->vtop->type.t & VT_BTYPE)) | 6817 | } else if (VT_STRUCT == (S->tccgen_vtop->type.t & VT_BTYPE)) |
| 6818 | gaddrof(S); | 6818 | gaddrof(S); |
| 6819 | } | 6819 | } |
| 6820 | 6820 | ||
| 6821 | if (c < 0) { | 6821 | if (c < 0) { |
| 6822 | r1 = gv(S, rc); | 6822 | r1 = gv(S, rc); |
| 6823 | move_reg(S, r2, r1, islv ? VT_PTR : type.t); | 6823 | move_reg(S, r2, r1, islv ? VT_PTR : type.t); |
| 6824 | S->vtop->r = r2; | 6824 | S->tccgen_vtop->r = r2; |
| 6825 | gsym(S, tt); | 6825 | gsym(S, tt); |
| 6826 | } | 6826 | } |
| 6827 | 6827 | ||
| @@ -6830,12 +6830,12 @@ static void expr_cond(TCCState *S) · 2 unmodified lines | |||
| 6830 | } | 6830 | } |
| 6831 | } | 6831 | } |
| 6832 | 6832 | ||
| 6833 | static void expr_eq(TCCState *S) | 6833 | static void expr_eq(TCCState* S) |
| 6834 | { | 6834 | { |
| 6835 | int t; | 6835 | int t; |
| 6836 | 6836 | ||
| 6837 | expr_cond(S); | 6837 | expr_cond(S); |
| 6838 | if ((t = S->tok) == '=' || TOK_ASSIGN(t)) { | 6838 | if ((t = S->tccpp_tok) == '=' || TOK_ASSIGN(t)) { |
| 6839 | test_lvalue(S); | 6839 | test_lvalue(S); |
| 6840 | next(S); | 6840 | next(S); |
| 6841 | if (t == '=') { | 6841 | if (t == '=') { |
| @@ -6849,11 +6849,11 @@ static void expr_eq(TCCState *S) · 7 unmodified lines | |||
| 6849 | } | 6849 | } |
| 6850 | } | 6850 | } |
| 6851 | 6851 | ||
| 6852 | ST_FUNC void gexpr(TCCState *S) | 6852 | ST_FUNC void gexpr(TCCState* S) |
| 6853 | { | 6853 | { |
| 6854 | while (1) { | 6854 | while (1) { |
| 6855 | expr_eq(S); | 6855 | expr_eq(S); |
| 6856 | if (S->tok != ',') | 6856 | if (S->tccpp_tok != ',') |
| 6857 | break; | 6857 | break; |
| 6858 | vpop(S); | 6858 | vpop(S); |
| 6859 | next(S); | 6859 | next(S); |
| @@ -6861,30 +6861,30 @@ ST_FUNC void gexpr(TCCState *S) · 1 unmodified line | |||
| 6861 | } | 6861 | } |
| 6862 | 6862 | ||
| 6863 | /* parse a constant expression and return value in vtop. */ | 6863 | /* parse a constant expression and return value in vtop. */ |
| 6864 | static void expr_const1(TCCState *S) | 6864 | static void expr_const1(TCCState* S) |
| 6865 | { | 6865 | { |
| 6866 | S->tccgen_const_wanted++; | 6866 | S->tccgen_const_wanted++; |
| 6867 | S->nocode_wanted += unevalmask + 1; | 6867 | S->tccgen_nocode_wanted += unevalmask + 1; |
| 6868 | expr_cond(S); | 6868 | expr_cond(S); |
| 6869 | S->nocode_wanted -= unevalmask + 1; | 6869 | S->tccgen_nocode_wanted -= unevalmask + 1; |
| 6870 | S->tccgen_const_wanted--; | 6870 | S->tccgen_const_wanted--; |
| 6871 | } | 6871 | } |
| 6872 | 6872 | ||
| 6873 | /* parse an integer constant and return its value. */ | 6873 | /* parse an integer constant and return its value. */ |
| 6874 | static inline int64_t expr_const64(TCCState *S) | 6874 | static inline int64_t expr_const64(TCCState* S) |
| 6875 | { | 6875 | { |
| 6876 | int64_t c; | 6876 | int64_t c; |
| 6877 | expr_const1(S); | 6877 | expr_const1(S); |
| 6878 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST) | 6878 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST) |
| 6879 | expect(S, "constant expression"); | 6879 | expect(S, "constant expression"); |
| 6880 | c = S->vtop->c.i; | 6880 | c = S->tccgen_vtop->c.i; |
| 6881 | vpop(S); | 6881 | vpop(S); |
| 6882 | return c; | 6882 | return c; |
| 6883 | } | 6883 | } |
| 6884 | 6884 | ||
| 6885 | /* parse an integer constant and return its value. | 6885 | /* parse an integer constant and return its value. |
| 6886 | Complain if it doesn't fit 32bit (signed or unsigned). */ | 6886 | Complain if it doesn't fit 32bit (signed or unsigned). */ |
| 6887 | ST_FUNC int expr_const(TCCState *S) | 6887 | ST_FUNC int expr_const(TCCState* S) |
| 6888 | { | 6888 | { |
| 6889 | int c; | 6889 | int c; |
| 6890 | int64_t wc = expr_const64(S); | 6890 | int64_t wc = expr_const64(S); |
| @@ -6898,7 +6898,7 @@ ST_FUNC int expr_const(TCCState *S) · 7 unmodified lines | |||
| 6898 | /* return from function */ | 6898 | /* return from function */ |
| 6899 | 6899 | ||
| 6900 | #ifndef TCC_TARGET_ARM64 | 6900 | #ifndef TCC_TARGET_ARM64 |
| 6901 | static void gfunc_return(TCCState *S, CType *func_type) | 6901 | static void gfunc_return(TCCState* S, CType *func_type) |
| 6902 | { | 6902 | { |
| 6903 | if ((func_type->t & VT_BTYPE) == VT_STRUCT) { | 6903 | if ((func_type->t & VT_BTYPE) == VT_STRUCT) { |
| 6904 | CType type, ret_type; | 6904 | CType type, ret_type; |
| @@ -6923,11 +6923,11 @@ static void gfunc_return(TCCState *S, CType *func_type) · 18 unmodified lines | |||
| 6923 | /* returning structure packed into registers */ | 6923 | /* returning structure packed into registers */ |
| 6924 | int size, addr, align, rc; | 6924 | int size, addr, align, rc; |
| 6925 | size = type_size(func_type,&align); | 6925 | size = type_size(func_type,&align); |
| 6926 | if ((S->vtop->r != (VT_LOCAL | VT_LVAL) || | 6926 | if ((S->tccgen_vtop->r != (VT_LOCAL | VT_LVAL) || |
| 6927 | (S->vtop->c.i & (ret_align-1))) | 6927 | (S->tccgen_vtop->c.i & (ret_align-1))) |
| 6928 | && (align & (ret_align-1))) { | 6928 | && (align & (ret_align-1))) { |
| 6929 | S->loc = (S->loc - size) & -ret_align; | 6929 | S->tccgen_loc = (S->tccgen_loc - size) & -ret_align; |
| 6930 | addr = S->loc; | 6930 | addr = S->tccgen_loc; |
| 6931 | type = *func_type; | 6931 | type = *func_type; |
| 6932 | vset(S, &type, VT_LOCAL | VT_LVAL, addr); | 6932 | vset(S, &type, VT_LOCAL | VT_LVAL, addr); |
| 6933 | vswap(S); | 6933 | vswap(S); |
| @@ -6935,7 +6935,7 @@ static void gfunc_return(TCCState *S, CType *func_type) · 1 unmodified line | |||
| 6935 | vpop(S); | 6935 | vpop(S); |
| 6936 | vset(S, &ret_type, VT_LOCAL | VT_LVAL, addr); | 6936 | vset(S, &ret_type, VT_LOCAL | VT_LVAL, addr); |
| 6937 | } | 6937 | } |
| 6938 | S->vtop->type = ret_type; | 6938 | S->tccgen_vtop->type = ret_type; |
| 6939 | rc = RC_RET(ret_type.t); | 6939 | rc = RC_RET(ret_type.t); |
| 6940 | if (ret_nregs == 1) | 6940 | if (ret_nregs == 1) |
| 6941 | gv(S, rc); | 6941 | gv(S, rc); |
| @@ -6950,18 +6950,18 @@ static void gfunc_return(TCCState *S, CType *func_type) · 8 unmodified lines | |||
| 6950 | registers, their classes are consecutive values of the | 6950 | registers, their classes are consecutive values of the |
| 6951 | suite s(n) = 2^n */ | 6951 | suite s(n) = 2^n */ |
| 6952 | rc <<= 1; | 6952 | rc <<= 1; |
| 6953 | S->vtop->c.i += regsize; | 6953 | S->tccgen_vtop->c.i += regsize; |
| 6954 | } | 6954 | } |
| 6955 | } | 6955 | } |
| 6956 | } | 6956 | } |
| 6957 | } else { | 6957 | } else { |
| 6958 | gv(S, RC_RET(func_type->t)); | 6958 | gv(S, RC_RET(func_type->t)); |
| 6959 | } | 6959 | } |
| 6960 | S->vtop--; /* NOT vpop() because on x86 it would flush the fp stack */ | 6960 | S->tccgen_vtop--; /* NOT vpop() because on x86 it would flush the fp stack */ |
| 6961 | } | 6961 | } |
| 6962 | #endif | 6962 | #endif |
| 6963 | 6963 | ||
| 6964 | static void check_func_return(TCCState *S) | 6964 | static void check_func_return(TCCState* S) |
| 6965 | { | 6965 | { |
| 6966 | if ((S->tccgen_func_vt.t & VT_BTYPE) == VT_VOID) | 6966 | if ((S->tccgen_func_vt.t & VT_BTYPE) == VT_VOID) |
| 6967 | return; | 6967 | return; |
| @@ -6993,16 +6993,16 @@ static int case_cmpu(const void *pa, const void *pb) · 25 unmodified lines | |||
| 6993 | return a < b ? -1 : a > b; | 6993 | return a < b ? -1 : a > b; |
| 6994 | } | 6994 | } |
| 6995 | 6995 | ||
| 6996 | static void gtst_addr(TCCState *S, int t, int a) | 6996 | static void gtst_addr(TCCState* S, int t, int a) |
| 6997 | { | 6997 | { |
| 6998 | gsym_addr(S, gvtst(S, 0, t), a); | 6998 | gsym_addr(S, gvtst(S, 0, t), a); |
| 6999 | } | 6999 | } |
| 7000 | 7000 | ||
| 7001 | static void gcase(TCCState *S, struct case_t **base, int len, int *bsym) | 7001 | static void gcase(TCCState* S, struct case_t **base, int len, int *bsym) |
| 7002 | { | 7002 | { |
| 7003 | struct case_t *p; | 7003 | struct case_t *p; |
| 7004 | int e; | 7004 | int e; |
| 7005 | int ll = (S->vtop->type.t & VT_BTYPE) == VT_LLONG; | 7005 | int ll = (S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG; |
| 7006 | while (len > 8) { | 7006 | while (len > 8) { |
| 7007 | /* binary search */ | 7007 | /* binary search */ |
| 7008 | p = base[len/2]; | 7008 | p = base[len/2]; |
| @@ -7057,7 +7057,7 @@ static void gcase(TCCState *S, struct case_t **base, int len, int *bsym) · 48 unmodified lines | |||
| 7057 | /* ------------------------------------------------------------------------- */ | 7057 | /* ------------------------------------------------------------------------- */ |
| 7058 | /* __attribute__((cleanup(fn))) */ | 7058 | /* __attribute__((cleanup(fn))) */ |
| 7059 | 7059 | ||
| 7060 | static void try_call_scope_cleanup(TCCState *S, Sym *stop) | 7060 | static void try_call_scope_cleanup(TCCState* S, Sym *stop) |
| 7061 | { | 7061 | { |
| 7062 | Sym *cls = S->tccgen_cur_scope->cl.s; | 7062 | Sym *cls = S->tccgen_cur_scope->cl.s; |
| 7063 | 7063 | ||
| @@ -7067,14 +7067,14 @@ static void try_call_scope_cleanup(TCCState *S, Sym *stop) · 3 unmodified lines | |||
| 7067 | 7067 | ||
| 7068 | vpushsym(S, &fs->type, fs); | 7068 | vpushsym(S, &fs->type, fs); |
| 7069 | vset(S, &vs->type, vs->r, vs->c); | 7069 | vset(S, &vs->type, vs->r, vs->c); |
| 7070 | S->vtop->sym = vs; | 7070 | S->tccgen_vtop->sym = vs; |
| 7071 | mk_pointer(S, &S->vtop->type); | 7071 | mk_pointer(S, &S->tccgen_vtop->type); |
| 7072 | gaddrof(S); | 7072 | gaddrof(S); |
| 7073 | gfunc_call(S, 1); | 7073 | gfunc_call(S, 1); |
| 7074 | } | 7074 | } |
| 7075 | } | 7075 | } |
| 7076 | 7076 | ||
| 7077 | static void try_call_cleanup_goto(TCCState *S, Sym *cleanupstate) | 7077 | static void try_call_cleanup_goto(TCCState* S, Sym *cleanupstate) |
| 7078 | { | 7078 | { |
| 7079 | Sym *oc, *cc; | 7079 | Sym *oc, *cc; |
| 7080 | int ocd, ccd; | 7080 | int ocd, ccd; |
| @@ -7095,7 +7095,7 @@ static void try_call_cleanup_goto(TCCState *S, Sym *cleanupstate) · 14 unmodified lines | |||
| 7095 | } | 7095 | } |
| 7096 | 7096 | ||
| 7097 | /* call 'func' for each __attribute__((cleanup(func))) */ | 7097 | /* call 'func' for each __attribute__((cleanup(func))) */ |
| 7098 | static void block_cleanup(TCCState *S, scope_t *o) | 7098 | static void block_cleanup(TCCState* S, scope_t *o) |
| 7099 | { | 7099 | { |
| 7100 | int jmp = 0; | 7100 | int jmp = 0; |
| 7101 | Sym *g, **pg; | 7101 | Sym *g, **pg; |
| @@ -7143,7 +7143,7 @@ static void vla_leave(TCCState * S, scope_t *o) · 41 unmodified lines | |||
| 7143 | /* ------------------------------------------------------------------------- */ | 7143 | /* ------------------------------------------------------------------------- */ |
| 7144 | /* local scopes */ | 7144 | /* local scopes */ |
| 7145 | 7145 | ||
| 7146 | static void new_scope(TCCState *S, scope_t *o) | 7146 | static void new_scope(TCCState* S, scope_t *o) |
| 7147 | { | 7147 | { |
| 7148 | /* copy and link previous scope */ | 7148 | /* copy and link previous scope */ |
| 7149 | *o = *S->tccgen_cur_scope; | 7149 | *o = *S->tccgen_cur_scope; |
| @@ -7152,15 +7152,15 @@ static void new_scope(TCCState *S, scope_t *o) · 2 unmodified lines | |||
| 7152 | S->tccgen_cur_scope->vla.num = 0; | 7152 | S->tccgen_cur_scope->vla.num = 0; |
| 7153 | 7153 | ||
| 7154 | /* record local declaration stack position */ | 7154 | /* record local declaration stack position */ |
| 7155 | o->lstk = S->local_stack; | 7155 | o->lstk = S->tccgen_local_stack; |
| 7156 | o->llstk = S->local_label_stack; | 7156 | o->llstk = S->tccgen_local_label_stack; |
| 7157 | ++S->local_scope; | 7157 | ++S->tccgen_local_scope; |
| 7158 | 7158 | ||
| 7159 | if (S->tccgen_debug_modes) | 7159 | if (S->tccgen_debug_modes) |
| 7160 | tcc_debug_stabn(S, N_LBRAC, S->ind - S->tccgen_func_ind); | 7160 | tcc_debug_stabn(S, N_LBRAC, S->tccgen_ind - S->tccgen_func_ind); |
| 7161 | } | 7161 | } |
| 7162 | 7162 | ||
| 7163 | static void prev_scope(TCCState *S, scope_t *o, int is_expr) | 7163 | static void prev_scope(TCCState* S, scope_t *o, int is_expr) |
| 7164 | { | 7164 | { |
| 7165 | vla_leave(S, o->prev); | 7165 | vla_leave(S, o->prev); |
| 7166 | 7166 | ||
| @@ -7168,7 +7168,7 @@ static void prev_scope(TCCState *S, scope_t *o, int is_expr) · 1 unmodified line | |||
| 7168 | block_cleanup(S, o->prev); | 7168 | block_cleanup(S, o->prev); |
| 7169 | 7169 | ||
| 7170 | /* pop locally defined labels */ | 7170 | /* pop locally defined labels */ |
| 7171 | label_pop(S, &S->local_label_stack, o->llstk, is_expr); | 7171 | label_pop(S, &S->tccgen_local_label_stack, o->llstk, is_expr); |
| 7172 | 7172 | ||
| 7173 | /* In the is_expr case (a statement expression is finished here), | 7173 | /* In the is_expr case (a statement expression is finished here), |
| 7174 | vtop might refer to symbols on the local_stack. Either via the | 7174 | vtop might refer to symbols on the local_stack. Either via the |
| @@ -7181,14 +7181,14 @@ static void prev_scope(TCCState *S, scope_t *o, int is_expr) · 6 unmodified lines | |||
| 7181 | /* pop locally defined symbols */ | 7181 | /* pop locally defined symbols */ |
| 7182 | pop_local_syms(S, o->lstk, is_expr); | 7182 | pop_local_syms(S, o->lstk, is_expr); |
| 7183 | S->tccgen_cur_scope = o->prev; | 7183 | S->tccgen_cur_scope = o->prev; |
| 7184 | --S->local_scope; | 7184 | --S->tccgen_local_scope; |
| 7185 | 7185 | ||
| 7186 | if (S->tccgen_debug_modes) | 7186 | if (S->tccgen_debug_modes) |
| 7187 | tcc_debug_stabn(S, N_RBRAC, S->ind - S->tccgen_func_ind); | 7187 | tcc_debug_stabn(S, N_RBRAC, S->tccgen_ind - S->tccgen_func_ind); |
| 7188 | } | 7188 | } |
| 7189 | 7189 | ||
| 7190 | /* leave a scope via break/continue(/goto) */ | 7190 | /* leave a scope via break/continue(/goto) */ |
| 7191 | static void leave_scope(TCCState *S, scope_t *o) | 7191 | static void leave_scope(TCCState* S, scope_t *o) |
| 7192 | { | 7192 | { |
| 7193 | if (!o) | 7193 | if (!o) |
| 7194 | return; | 7194 | return; |
| @@ -7199,7 +7199,7 @@ static void leave_scope(TCCState *S, scope_t *o) · 4 unmodified lines | |||
| 7199 | /* ------------------------------------------------------------------------- */ | 7199 | /* ------------------------------------------------------------------------- */ |
| 7200 | /* call block from 'for do while' loops */ | 7200 | /* call block from 'for do while' loops */ |
| 7201 | 7201 | ||
| 7202 | static void lblock(TCCState *S, int *bsym, int *csym) | 7202 | static void lblock(TCCState* S, int *bsym, int *csym) |
| 7203 | { | 7203 | { |
| 7204 | scope_t *lo = S->tccgen_loop_scope, *co = S->tccgen_cur_scope; | 7204 | scope_t *lo = S->tccgen_loop_scope, *co = S->tccgen_cur_scope; |
| 7205 | int *b = co->bsym, *c = co->csym; | 7205 | int *b = co->bsym, *c = co->csym; |
| @@ -7216,7 +7216,7 @@ static void lblock(TCCState *S, int *bsym, int *csym) · 10 unmodified lines | |||
| 7216 | } | 7216 | } |
| 7217 | } | 7217 | } |
| 7218 | 7218 | ||
| 7219 | static void block(TCCState *S, int is_expr) | 7219 | static void block(TCCState* S, int is_expr) |
| 7220 | { | 7220 | { |
| 7221 | int a, b, c, d, e, t; | 7221 | int a, b, c, d, e, t; |
| 7222 | scope_t o; | 7222 | scope_t o; |
| @@ -7225,11 +7225,11 @@ static void block(TCCState *S, int is_expr) · 2 unmodified lines | |||
| 7225 | if (is_expr) { | 7225 | if (is_expr) { |
| 7226 | /* default return value is (void) */ | 7226 | /* default return value is (void) */ |
| 7227 | vpushi(S, 0); | 7227 | vpushi(S, 0); |
| 7228 | S->vtop->type.t = VT_VOID; | 7228 | S->tccgen_vtop->type.t = VT_VOID; |
| 7229 | } | 7229 | } |
| 7230 | 7230 | ||
| 7231 | again: | 7231 | again: |
| 7232 | t = S->tok; | 7232 | t = S->tccpp_tok; |
| 7233 | /* If the token carries a value, next() might destroy it. Only with | 7233 | /* If the token carries a value, next() might destroy it. Only with |
| 7234 | invalid code such as f(){"123"4;} */ | 7234 | invalid code such as f(){"123"4;} */ |
| 7235 | if (TOK_HAS_VALUE(t)) | 7235 | if (TOK_HAS_VALUE(t)) |
| @@ -7245,7 +7245,7 @@ again: · 9 unmodified lines | |||
| 7245 | skip(S, ')'); | 7245 | skip(S, ')'); |
| 7246 | a = gvtst(S, 1, 0); | 7246 | a = gvtst(S, 1, 0); |
| 7247 | block(S, 0); | 7247 | block(S, 0); |
| 7248 | if (S->tok == TOK_ELSE) { | 7248 | if (S->tccpp_tok == TOK_ELSE) { |
| 7249 | d = gjmp(S, 0); | 7249 | d = gjmp(S, 0); |
| 7250 | gsym(S, a); | 7250 | gsym(S, a); |
| 7251 | next(S); | 7251 | next(S); |
| @@ -7271,20 +7271,20 @@ again: · 19 unmodified lines | |||
| 7271 | new_scope(S, &o); | 7271 | new_scope(S, &o); |
| 7272 | 7272 | ||
| 7273 | /* handle local labels declarations */ | 7273 | /* handle local labels declarations */ |
| 7274 | while (S->tok == TOK_LABEL) { | 7274 | while (S->tccpp_tok == TOK_LABEL) { |
| 7275 | do { | 7275 | do { |
| 7276 | next(S); | 7276 | next(S); |
| 7277 | if (S->tok < TOK_UIDENT) | 7277 | if (S->tccpp_tok < TOK_UIDENT) |
| 7278 | expect(S, "label identifier"); | 7278 | expect(S, "label identifier"); |
| 7279 | label_push(S, &S->local_label_stack, S->tok, LABEL_DECLARED); | 7279 | label_push(S, &S->tccgen_local_label_stack, S->tccpp_tok, LABEL_DECLARED); |
| 7280 | next(S); | 7280 | next(S); |
| 7281 | } while (S->tok == ','); | 7281 | } while (S->tccpp_tok == ','); |
| 7282 | skip(S, ';'); | 7282 | skip(S, ';'); |
| 7283 | } | 7283 | } |
| 7284 | 7284 | ||
| 7285 | while (S->tok != '}') { | 7285 | while (S->tccpp_tok != '}') { |
| 7286 | decl(S, VT_LOCAL); | 7286 | decl(S, VT_LOCAL); |
| 7287 | if (S->tok != '}') { | 7287 | if (S->tccpp_tok != '}') { |
| 7288 | if (is_expr) | 7288 | if (is_expr) |
| 7289 | vpop(S); | 7289 | vpop(S); |
| 7290 | block(S, is_expr); | 7290 | block(S, is_expr); |
| @@ -7292,21 +7292,21 @@ again: · 1 unmodified line | |||
| 7292 | } | 7292 | } |
| 7293 | 7293 | ||
| 7294 | prev_scope(S, &o, is_expr); | 7294 | prev_scope(S, &o, is_expr); |
| 7295 | if (S->local_scope) | 7295 | if (S->tccgen_local_scope) |
| 7296 | next(S); | 7296 | next(S); |
| 7297 | else if (!S->nocode_wanted) | 7297 | else if (!S->tccgen_nocode_wanted) |
| 7298 | check_func_return(S); | 7298 | check_func_return(S); |
| 7299 | 7299 | ||
| 7300 | } else if (t == TOK_RETURN) { | 7300 | } else if (t == TOK_RETURN) { |
| 7301 | b = (S->tccgen_func_vt.t & VT_BTYPE) != VT_VOID; | 7301 | b = (S->tccgen_func_vt.t & VT_BTYPE) != VT_VOID; |
| 7302 | if (S->tok != ';') { | 7302 | if (S->tccpp_tok != ';') { |
| 7303 | gexpr(S); | 7303 | gexpr(S); |
| 7304 | if (b) { | 7304 | if (b) { |
| 7305 | gen_assign_cast(S, &S->tccgen_func_vt); | 7305 | gen_assign_cast(S, &S->tccgen_func_vt); |
| 7306 | } else { | 7306 | } else { |
| 7307 | if (S->vtop->type.t != VT_VOID) | 7307 | if (S->tccgen_vtop->type.t != VT_VOID) |
| 7308 | tcc_warning(S, "void function returns a value"); | 7308 | tcc_warning(S, "void function returns a value"); |
| 7309 | S->vtop--; | 7309 | S->tccgen_vtop--; |
| 7310 | } | 7310 | } |
| 7311 | } else if (b) { | 7311 | } else if (b) { |
| 7312 | tcc_warning(S, "'return' with no value"); | 7312 | tcc_warning(S, "'return' with no value"); |
| @@ -7317,7 +7317,7 @@ again: · 4 unmodified lines | |||
| 7317 | gfunc_return(S, &S->tccgen_func_vt); | 7317 | gfunc_return(S, &S->tccgen_func_vt); |
| 7318 | skip(S, ';'); | 7318 | skip(S, ';'); |
| 7319 | /* jump unless last stmt in top-level block */ | 7319 | /* jump unless last stmt in top-level block */ |
| 7320 | if (S->tok != '}' || S->local_scope != 1) | 7320 | if (S->tccpp_tok != '}' || S->tccgen_local_scope != 1) |
| 7321 | S->tccgen_rsym = gjmp(S, S->tccgen_rsym); | 7321 | S->tccgen_rsym = gjmp(S, S->tccgen_rsym); |
| 7322 | if (S->tccgen_debug_modes) | 7322 | if (S->tccgen_debug_modes) |
| 7323 | tcc_tcov_block_end (S, S->tccgen_tcov_data.line); | 7323 | tcc_tcov_block_end (S, S->tccgen_tcov_data.line); |
| @@ -7346,7 +7346,7 @@ again: · 22 unmodified lines | |||
| 7346 | new_scope(S, &o); | 7346 | new_scope(S, &o); |
| 7347 | 7347 | ||
| 7348 | skip(S, '('); | 7348 | skip(S, '('); |
| 7349 | if (S->tok != ';') { | 7349 | if (S->tccpp_tok != ';') { |
| 7350 | /* c99 for-loop init decl? */ | 7350 | /* c99 for-loop init decl? */ |
| 7351 | if (!decl0(S, VT_LOCAL, 1, NULL)) { | 7351 | if (!decl0(S, VT_LOCAL, 1, NULL)) { |
| 7352 | /* no, regular for-loop init expr */ | 7352 | /* no, regular for-loop init expr */ |
| @@ -7357,12 +7357,12 @@ again: · 4 unmodified lines | |||
| 7357 | skip(S, ';'); | 7357 | skip(S, ';'); |
| 7358 | a = b = 0; | 7358 | a = b = 0; |
| 7359 | c = d = gind(S); | 7359 | c = d = gind(S); |
| 7360 | if (S->tok != ';') { | 7360 | if (S->tccpp_tok != ';') { |
| 7361 | gexpr(S); | 7361 | gexpr(S); |
| 7362 | a = gvtst(S, 1, 0); | 7362 | a = gvtst(S, 1, 0); |
| 7363 | } | 7363 | } |
| 7364 | skip(S, ';'); | 7364 | skip(S, ';'); |
| 7365 | if (S->tok != ')') { | 7365 | if (S->tccpp_tok != ')') { |
| 7366 | e = gjmp(S, 0); | 7366 | e = gjmp(S, 0); |
| 7367 | d = gind(S); | 7367 | d = gind(S); |
| 7368 | gexpr(S); | 7368 | gexpr(S); |
| @@ -7403,7 +7403,7 @@ again: · 34 unmodified lines | |||
| 7403 | skip(S, '('); | 7403 | skip(S, '('); |
| 7404 | gexpr(S); | 7404 | gexpr(S); |
| 7405 | skip(S, ')'); | 7405 | skip(S, ')'); |
| 7406 | sw->sv = *S->vtop--; /* save switch value */ | 7406 | sw->sv = *S->tccgen_vtop--; /* save switch value */ |
| 7407 | 7407 | ||
| 7408 | a = 0; | 7408 | a = 0; |
| 7409 | b = gjmp(S, 0); /* jump to first case */ | 7409 | b = gjmp(S, 0); /* jump to first case */ |
| @@ -7443,7 +7443,7 @@ again: · 33 unmodified lines | |||
| 7443 | if (!S->tccgen_cur_switch) | 7443 | if (!S->tccgen_cur_switch) |
| 7444 | expect(S, "switch"); | 7444 | expect(S, "switch"); |
| 7445 | cr->v1 = cr->v2 = expr_const64(S); | 7445 | cr->v1 = cr->v2 = expr_const64(S); |
| 7446 | if (gnu_ext && S->tok == TOK_DOTS) { | 7446 | if (gnu_ext && S->tccpp_tok == TOK_DOTS) { |
| 7447 | next(S); | 7447 | next(S); |
| 7448 | cr->v2 = expr_const64(S); | 7448 | cr->v2 = expr_const64(S); |
| 7449 | if ((!(S->tccgen_cur_switch->sv.type.t & VT_UNSIGNED) && cr->v2 < cr->v1) | 7449 | if ((!(S->tccgen_cur_switch->sv.type.t & VT_UNSIGNED) && cr->v2 < cr->v1) |
| @@ -7471,25 +7471,25 @@ again: · 21 unmodified lines | |||
| 7471 | } else if (t == TOK_GOTO) { | 7471 | } else if (t == TOK_GOTO) { |
| 7472 | if (S->tccgen_cur_scope->vla.num) | 7472 | if (S->tccgen_cur_scope->vla.num) |
| 7473 | vla_restore(S, S->tccgen_cur_scope->vla.locorig); | 7473 | vla_restore(S, S->tccgen_cur_scope->vla.locorig); |
| 7474 | if (S->tok == '*' && gnu_ext) { | 7474 | if (S->tccpp_tok == '*' && gnu_ext) { |
| 7475 | /* computed goto */ | 7475 | /* computed goto */ |
| 7476 | next(S); | 7476 | next(S); |
| 7477 | gexpr(S); | 7477 | gexpr(S); |
| 7478 | if ((S->vtop->type.t & VT_BTYPE) != VT_PTR) | 7478 | if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_PTR) |
| 7479 | expect(S, "pointer"); | 7479 | expect(S, "pointer"); |
| 7480 | ggoto(S); | 7480 | ggoto(S); |
| 7481 | 7481 | ||
| 7482 | } else if (S->tok >= TOK_UIDENT) { | 7482 | } else if (S->tccpp_tok >= TOK_UIDENT) { |
| 7483 | s = label_find(S, S->tok); | 7483 | s = label_find(S, S->tccpp_tok); |
| 7484 | /* put forward definition if needed */ | 7484 | /* put forward definition if needed */ |
| 7485 | if (!s) | 7485 | if (!s) |
| 7486 | s = label_push(S, &S->tccgen_global_label_stack, S->tok, LABEL_FORWARD); | 7486 | s = label_push(S, &S->tccgen_global_label_stack, S->tccpp_tok, LABEL_FORWARD); |
| 7487 | else if (s->r == LABEL_DECLARED) | 7487 | else if (s->r == LABEL_DECLARED) |
| 7488 | s->r = LABEL_FORWARD; | 7488 | s->r = LABEL_FORWARD; |
| 7489 | 7489 | ||
| 7490 | if (s->r & LABEL_FORWARD) { | 7490 | if (s->r & LABEL_FORWARD) { |
| 7491 | /* start new goto chain for cleanups, linked via label->next */ | 7491 | /* start new goto chain for cleanups, linked via label->next */ |
| 7492 | if (S->tccgen_cur_scope->cl.s && !S->nocode_wanted) { | 7492 | if (S->tccgen_cur_scope->cl.s && !S->tccgen_nocode_wanted) { |
| 7493 | sym_push2(S, &S->tccgen_pending_gotos, SYM_FIELD, 0, S->tccgen_cur_scope->cl.n); | 7493 | sym_push2(S, &S->tccgen_pending_gotos, SYM_FIELD, 0, S->tccgen_cur_scope->cl.n); |
| 7494 | S->tccgen_pending_gotos->prev_tok = s; | 7494 | S->tccgen_pending_gotos->prev_tok = s; |
| 7495 | s = sym_push2(S, &s->next, SYM_FIELD, 0, 0); | 7495 | s = sym_push2(S, &s->next, SYM_FIELD, 0, 0); |
| @@ -7511,7 +7511,7 @@ again: · 15 unmodified lines | |||
| 7511 | asm_instr(S); | 7511 | asm_instr(S); |
| 7512 | 7512 | ||
| 7513 | } else { | 7513 | } else { |
| 7514 | if (S->tok == ':' && t >= TOK_UIDENT) { | 7514 | if (S->tccpp_tok == ':' && t >= TOK_UIDENT) { |
| 7515 | /* label case */ | 7515 | /* label case */ |
| 7516 | next(S); | 7516 | next(S); |
| 7517 | s = label_find(S, t); | 7517 | s = label_find(S, t); |
| @@ -7534,7 +7534,7 @@ again: · 16 unmodified lines | |||
| 7534 | 7534 | ||
| 7535 | block_after_label: | 7535 | block_after_label: |
| 7536 | vla_restore(S, S->tccgen_cur_scope->vla.loc); | 7536 | vla_restore(S, S->tccgen_cur_scope->vla.loc); |
| 7537 | if (S->tok != '}') | 7537 | if (S->tccpp_tok != '}') |
| 7538 | goto again; | 7538 | goto again; |
| 7539 | /* we accept this, but it is a mistake */ | 7539 | /* we accept this, but it is a mistake */ |
| 7540 | tcc_warning_c(warn_all)(S, "deprecated use of label at end of compound statement"); | 7540 | tcc_warning_c(warn_all)(S, "deprecated use of label at end of compound statement"); |
| @@ -7565,16 +7565,16 @@ again: · 24 unmodified lines | |||
| 7565 | with a '{'). If STR then allocates and stores the skipped tokens | 7565 | with a '{'). If STR then allocates and stores the skipped tokens |
| 7566 | in *STR. This doesn't check if () and {} are nested correctly, | 7566 | in *STR. This doesn't check if () and {} are nested correctly, |
| 7567 | i.e. "({)}" is accepted. */ | 7567 | i.e. "({)}" is accepted. */ |
| 7568 | static void skip_or_save_block(TCCState *S, TokenString **str) | 7568 | static void skip_or_save_block(TCCState* S, TokenString **str) |
| 7569 | { | 7569 | { |
| 7570 | int braces = S->tok == '{'; | 7570 | int braces = S->tccpp_tok == '{'; |
| 7571 | int level = 0; | 7571 | int level = 0; |
| 7572 | if (str) | 7572 | if (str) |
| 7573 | *str = tok_str_alloc(S); | 7573 | *str = tok_str_alloc(S); |
| 7574 | 7574 | ||
| 7575 | while ((level > 0 || (S->tok != '}' && S->tok != ',' && S->tok != ';' && S->tok != ')'))) { | 7575 | while ((level > 0 || (S->tccpp_tok != '}' && S->tccpp_tok != ',' && S->tccpp_tok != ';' && S->tccpp_tok != ')'))) { |
| 7576 | int t; | 7576 | int t; |
| 7577 | if (S->tok == TOK_EOF) { | 7577 | if (S->tccpp_tok == TOK_EOF) { |
| 7578 | if (str || level > 0) | 7578 | if (str || level > 0) |
| 7579 | tcc_error(S, "unexpected end of file"); | 7579 | tcc_error(S, "unexpected end of file"); |
| 7580 | else | 7580 | else |
| @@ -7582,7 +7582,7 @@ static void skip_or_save_block(TCCState *S, TokenString **str) · 1 unmodified line | |||
| 7582 | } | 7582 | } |
| 7583 | if (str) | 7583 | if (str) |
| 7584 | tok_str_add_tok(S, *str); | 7584 | tok_str_add_tok(S, *str); |
| 7585 | t = S->tok; | 7585 | t = S->tccpp_tok; |
| 7586 | next(S); | 7586 | next(S); |
| 7587 | if (t == '{' || t == '(') { | 7587 | if (t == '{' || t == '(') { |
| 7588 | level++; | 7588 | level++; |
| @@ -7601,7 +7601,7 @@ static void skip_or_save_block(TCCState *S, TokenString **str) · 12 unmodified lines | |||
| 7601 | #define EXPR_CONST 1 | 7601 | #define EXPR_CONST 1 |
| 7602 | #define EXPR_ANY 2 | 7602 | #define EXPR_ANY 2 |
| 7603 | 7603 | ||
| 7604 | static void parse_init_elem(TCCState *S, int expr_type) | 7604 | static void parse_init_elem(TCCState* S, int expr_type) |
| 7605 | { | 7605 | { |
| 7606 | int saved_global_expr; | 7606 | int saved_global_expr; |
| 7607 | switch(expr_type) { | 7607 | switch(expr_type) { |
| @@ -7613,11 +7613,11 @@ static void parse_init_elem(TCCState *S, int expr_type) · 5 unmodified lines | |||
| 7613 | S->tccgen_global_expr = saved_global_expr; | 7613 | S->tccgen_global_expr = saved_global_expr; |
| 7614 | /* NOTE: symbols are accepted, as well as lvalue for anon symbols | 7614 | /* NOTE: symbols are accepted, as well as lvalue for anon symbols |
| 7615 | (compound literals). */ | 7615 | (compound literals). */ |
| 7616 | if (((S->vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST | 7616 | if (((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST |
| 7617 | && ((S->vtop->r & (VT_SYM|VT_LVAL)) != (VT_SYM|VT_LVAL) | 7617 | && ((S->tccgen_vtop->r & (VT_SYM|VT_LVAL)) != (VT_SYM|VT_LVAL) |
| 7618 | || S->vtop->sym->v < SYM_FIRST_ANOM)) | 7618 | || S->tccgen_vtop->sym->v < SYM_FIRST_ANOM)) |
| 7619 | #ifdef TCC_TARGET_PE | 7619 | #ifdef TCC_TARGET_PE |
| 7620 | || ((S->vtop->r & VT_SYM) && S->vtop->sym->a.dllimport) | 7620 | || ((S->tccgen_vtop->r & VT_SYM) && S->tccgen_vtop->sym->a.dllimport) |
| 7621 | #endif | 7621 | #endif |
| 7622 | ) | 7622 | ) |
| 7623 | tcc_error(S, "initializer element is not constant"); | 7623 | tcc_error(S, "initializer element is not constant"); |
| @@ -7629,10 +7629,10 @@ static void parse_init_elem(TCCState *S, int expr_type) · 5 unmodified lines | |||
| 7629 | } | 7629 | } |
| 7630 | 7630 | ||
| 7631 | #if 1 | 7631 | #if 1 |
| 7632 | static void init_assert(TCCState *S, init_params *p, int offset) | 7632 | static void init_assert(TCCState* S, init_params *p, int offset) |
| 7633 | { | 7633 | { |
| 7634 | if (p->sec ? !NODATA_WANTED && offset > p->sec->data_offset | 7634 | if (p->sec ? !NODATA_WANTED && offset > p->sec->data_offset |
| 7635 | : !S->nocode_wanted && offset > p->local_offset) | 7635 | : !S->tccgen_nocode_wanted && offset > p->local_offset) |
| 7636 | tcc_internal_error(S, "initializer overflow"); | 7636 | tcc_internal_error(S, "initializer overflow"); |
| 7637 | } | 7637 | } |
| 7638 | #else | 7638 | #else |
| @@ -7640,7 +7640,7 @@ static void init_assert(TCCState *S, init_params *p, int offset) · 1 unmodified line | |||
| 7640 | #endif | 7640 | #endif |
| 7641 | 7641 | ||
| 7642 | /* put zeros for variable based init */ | 7642 | /* put zeros for variable based init */ |
| 7643 | static void init_putz(TCCState *S, init_params *p, unsigned long c, int size) | 7643 | static void init_putz(TCCState* S, init_params *p, unsigned long c, int size) |
| 7644 | { | 7644 | { |
| 7645 | init_assert(S, p, c + size); | 7645 | init_assert(S, p, c + size); |
| 7646 | if (p->sec) { | 7646 | if (p->sec) { |
| @@ -7685,7 +7685,7 @@ static void decl_design_delrels(Section *sec, int c, int size) · 38 unmodified lines | |||
| 7685 | } | 7685 | } |
| 7686 | } | 7686 | } |
| 7687 | 7687 | ||
| 7688 | static void decl_design_flex(TCCState *S, init_params *p, Sym *ref, int index) | 7688 | static void decl_design_flex(TCCState* S, init_params *p, Sym *ref, int index) |
| 7689 | { | 7689 | { |
| 7690 | if (ref == p->flex_array_ref) { | 7690 | if (ref == p->flex_array_ref) { |
| 7691 | if (index >= ref->c) | 7691 | if (index >= ref->c) |
| @@ -7700,7 +7700,7 @@ static void decl_design_flex(TCCState *S, init_params *p, Sym *ref, int index) · 8 unmodified lines | |||
| 7700 | index. 'flags' is as in decl_initializer. | 7700 | index. 'flags' is as in decl_initializer. |
| 7701 | 'al' contains the already initialized length of the | 7701 | 'al' contains the already initialized length of the |
| 7702 | current container (starting at c). This returns the new length of that. */ | 7702 | current container (starting at c). This returns the new length of that. */ |
| 7703 | static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned long c, | 7703 | static int decl_designator(TCCState* S, init_params *p, CType *type, unsigned long c, |
| 7704 | Sym **cur_field, int flags, int al) | 7704 | Sym **cur_field, int flags, int al) |
| 7705 | { | 7705 | { |
| 7706 | Sym *s, *f; | 7706 | Sym *s, *f; |
| @@ -7713,21 +7713,21 @@ static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned lo · 6 unmodified lines | |||
| 7713 | if (flags & DIF_HAVE_ELEM) | 7713 | if (flags & DIF_HAVE_ELEM) |
| 7714 | goto no_designator; | 7714 | goto no_designator; |
| 7715 | 7715 | ||
| 7716 | if (gnu_ext && S->tok >= TOK_UIDENT) { | 7716 | if (gnu_ext && S->tccpp_tok >= TOK_UIDENT) { |
| 7717 | l = S->tok, next(S); | 7717 | l = S->tccpp_tok, next(S); |
| 7718 | if (S->tok == ':') | 7718 | if (S->tccpp_tok == ':') |
| 7719 | goto struct_field; | 7719 | goto struct_field; |
| 7720 | unget_tok(S, l); | 7720 | unget_tok(S, l); |
| 7721 | } | 7721 | } |
| 7722 | 7722 | ||
| 7723 | /* NOTE: we only support ranges for last designator */ | 7723 | /* NOTE: we only support ranges for last designator */ |
| 7724 | while (nb_elems == 1 && (S->tok == '[' || S->tok == '.')) { | 7724 | while (nb_elems == 1 && (S->tccpp_tok == '[' || S->tccpp_tok == '.')) { |
| 7725 | if (S->tok == '[') { | 7725 | if (S->tccpp_tok == '[') { |
| 7726 | if (!(type->t & VT_ARRAY)) | 7726 | if (!(type->t & VT_ARRAY)) |
| 7727 | expect(S, "array type"); | 7727 | expect(S, "array type"); |
| 7728 | next(S); | 7728 | next(S); |
| 7729 | index = index_last = expr_const(S); | 7729 | index = index_last = expr_const(S); |
| 7730 | if (S->tok == TOK_DOTS && gnu_ext) { | 7730 | if (S->tccpp_tok == TOK_DOTS && gnu_ext) { |
| 7731 | next(S); | 7731 | next(S); |
| 7732 | index_last = expr_const(S); | 7732 | index_last = expr_const(S); |
| 7733 | } | 7733 | } |
| @@ -7745,7 +7745,7 @@ static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned lo · 11 unmodified lines | |||
| 7745 | } else { | 7745 | } else { |
| 7746 | int cumofs; | 7746 | int cumofs; |
| 7747 | next(S); | 7747 | next(S); |
| 7748 | l = S->tok; | 7748 | l = S->tccpp_tok; |
| 7749 | struct_field: | 7749 | struct_field: |
| 7750 | next(S); | 7750 | next(S); |
| 7751 | if ((type->t & VT_BTYPE) != VT_STRUCT) | 7751 | if ((type->t & VT_BTYPE) != VT_STRUCT) |
| @@ -7762,7 +7762,7 @@ static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned lo · 10 unmodified lines | |||
| 7762 | cur_field = NULL; | 7762 | cur_field = NULL; |
| 7763 | } | 7763 | } |
| 7764 | if (!cur_field) { | 7764 | if (!cur_field) { |
| 7765 | if (S->tok == '=') { | 7765 | if (S->tccpp_tok == '=') { |
| 7766 | next(S); | 7766 | next(S); |
| 7767 | } else if (!gnu_ext) { | 7767 | } else if (!gnu_ext) { |
| 7768 | expect(S, "="); | 7768 | expect(S, "="); |
| @@ -7830,7 +7830,7 @@ static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned lo · 61 unmodified lines | |||
| 7830 | } | 7830 | } |
| 7831 | 7831 | ||
| 7832 | /* store a value or an expression directly in global data or in local array */ | 7832 | /* store a value or an expression directly in global data or in local array */ |
| 7833 | static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) | 7833 | static void init_putv(TCCState* S, init_params *p, CType *type, unsigned long c) |
| 7834 | { | 7834 | { |
| 7835 | int bt; | 7835 | int bt; |
| 7836 | void *ptr; | 7836 | void *ptr; |
| @@ -7853,25 +7853,25 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) · 16 unmodified lines | |||
| 7853 | gen_assign_cast(S, &dtype); | 7853 | gen_assign_cast(S, &dtype); |
| 7854 | bt = type->t & VT_BTYPE; | 7854 | bt = type->t & VT_BTYPE; |
| 7855 | 7855 | ||
| 7856 | if ((S->vtop->r & VT_SYM) | 7856 | if ((S->tccgen_vtop->r & VT_SYM) |
| 7857 | && bt != VT_PTR | 7857 | && bt != VT_PTR |
| 7858 | && (bt != (PTR_SIZE == 8 ? VT_LLONG : VT_INT) | 7858 | && (bt != (PTR_SIZE == 8 ? VT_LLONG : VT_INT) |
| 7859 | || (type->t & VT_BITFIELD)) | 7859 | || (type->t & VT_BITFIELD)) |
| 7860 | && !((S->vtop->r & VT_CONST) && S->vtop->sym->v >= SYM_FIRST_ANOM) | 7860 | && !((S->tccgen_vtop->r & VT_CONST) && S->tccgen_vtop->sym->v >= SYM_FIRST_ANOM) |
| 7861 | ) | 7861 | ) |
| 7862 | tcc_error(S, "initializer element is not computable at load time"); | 7862 | tcc_error(S, "initializer element is not computable at load time"); |
| 7863 | 7863 | ||
| 7864 | if (NODATA_WANTED) { | 7864 | if (NODATA_WANTED) { |
| 7865 | S->vtop--; | 7865 | S->tccgen_vtop--; |
| 7866 | return; | 7866 | return; |
| 7867 | } | 7867 | } |
| 7868 | 7868 | ||
| 7869 | ptr = sec->data + c; | 7869 | ptr = sec->data + c; |
| 7870 | val = S->vtop->c.i; | 7870 | val = S->tccgen_vtop->c.i; |
| 7871 | 7871 | ||
| 7872 | /* XXX: make code faster ? */ | 7872 | /* XXX: make code faster ? */ |
| 7873 | if ((S->vtop->r & (VT_SYM|VT_CONST)) == (VT_SYM|VT_CONST) && | 7873 | if ((S->tccgen_vtop->r & (VT_SYM|VT_CONST)) == (VT_SYM|VT_CONST) && |
| 7874 | S->vtop->sym->v >= SYM_FIRST_ANOM && | 7874 | S->tccgen_vtop->sym->v >= SYM_FIRST_ANOM && |
| 7875 | /* XXX This rejects compound literals like | 7875 | /* XXX This rejects compound literals like |
| 7876 | '(void *){ptr}'. The problem is that '&sym' is | 7876 | '(void *){ptr}'. The problem is that '&sym' is |
| 7877 | represented the same way, which would be ruled out | 7877 | represented the same way, which would be ruled out |
| @@ -7882,14 +7882,14 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) · 4 unmodified lines | |||
| 7882 | between '(void *){x}' and '&(void *){x}'. Ignore | 7882 | between '(void *){x}' and '&(void *){x}'. Ignore |
| 7883 | pointer typed entities here. Hopefully no real code | 7883 | pointer typed entities here. Hopefully no real code |
| 7884 | will ever use compound literals with scalar type. */ | 7884 | will ever use compound literals with scalar type. */ |
| 7885 | (S->vtop->type.t & VT_BTYPE) != VT_PTR) { | 7885 | (S->tccgen_vtop->type.t & VT_BTYPE) != VT_PTR) { |
| 7886 | /* These come from compound literals, memcpy stuff over. */ | 7886 | /* These come from compound literals, memcpy stuff over. */ |
| 7887 | Section *ssec; | 7887 | Section *ssec; |
| 7888 | ElfSym *esym; | 7888 | ElfSym *esym; |
| 7889 | ElfW_Rel *rel; | 7889 | ElfW_Rel *rel; |
| 7890 | esym = elfsym(S, S->vtop->sym); | 7890 | esym = elfsym(S, S->tccgen_vtop->sym); |
| 7891 | ssec = S->sections[esym->st_shndx]; | 7891 | ssec = S->sections[esym->st_shndx]; |
| 7892 | memmove (ptr, ssec->data + esym->st_value + (int)S->vtop->c.i, size); | 7892 | memmove (ptr, ssec->data + esym->st_value + (int)S->tccgen_vtop->c.i, size); |
| 7893 | if (ssec->reloc) { | 7893 | if (ssec->reloc) { |
| 7894 | /* We need to copy over all memory contents, and that | 7894 | /* We need to copy over all memory contents, and that |
| 7895 | includes relocations. Use the fact that relocs are | 7895 | includes relocations. Use the fact that relocs are |
| @@ -7919,8 +7919,8 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) · 23 unmodified lines | |||
| 7919 | if (type->t & VT_BITFIELD) { | 7919 | if (type->t & VT_BITFIELD) { |
| 7920 | int bit_pos, bit_size, bits, n; | 7920 | int bit_pos, bit_size, bits, n; |
| 7921 | unsigned char *p, v, m; | 7921 | unsigned char *p, v, m; |
| 7922 | bit_pos = BIT_POS(S->vtop->type.t); | 7922 | bit_pos = BIT_POS(S->tccgen_vtop->type.t); |
| 7923 | bit_size = BIT_SIZE(S->vtop->type.t); | 7923 | bit_size = BIT_SIZE(S->tccgen_vtop->type.t); |
| 7924 | p = (unsigned char*)ptr + (bit_pos >> 3); | 7924 | p = (unsigned char*)ptr + (bit_pos >> 3); |
| 7925 | bit_pos &= 7, bits = 0; | 7925 | bit_pos &= 7, bits = 0; |
| 7926 | while (bit_size) { | 7926 | while (bit_size) { |
| @@ -7959,21 +7959,21 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) · 32 unmodified lines | |||
| 7959 | In any case we avoid possibly random bytes 11 and 12. | 7959 | In any case we avoid possibly random bytes 11 and 12. |
| 7960 | */ | 7960 | */ |
| 7961 | if (sizeof (long double) >= 10) | 7961 | if (sizeof (long double) >= 10) |
| 7962 | memcpy(ptr, &S->vtop->c.ld, 10); | 7962 | memcpy(ptr, &S->tccgen_vtop->c.ld, 10); |
| 7963 | #ifdef __TINYC__ | 7963 | #ifdef __TINYC__ |
| 7964 | else if (sizeof (long double) == sizeof (double)) | 7964 | else if (sizeof (long double) == sizeof (double)) |
| 7965 | __asm__("fldl %1\nfstpt %0\n" : "=m" (*ptr) : "m" (S->vtop->c.ld)); | 7965 | __asm__("fldl %1\nfstpt %0\n" : "=m" (*ptr) : "m" (S->tccgen_vtop->c.ld)); |
| 7966 | #endif | 7966 | #endif |
| 7967 | else if (S->vtop->c.ld == 0.0) | 7967 | else if (S->tccgen_vtop->c.ld == 0.0) |
| 7968 | ; | 7968 | ; |
| 7969 | else | 7969 | else |
| 7970 | #endif | 7970 | #endif |
| 7971 | /* For other platforms it should work natively, but may not work | 7971 | /* For other platforms it should work natively, but may not work |
| 7972 | for cross compilers */ | 7972 | for cross compilers */ |
| 7973 | if (sizeof(long double) == LDOUBLE_SIZE) | 7973 | if (sizeof(long double) == LDOUBLE_SIZE) |
| 7974 | memcpy(ptr, &S->vtop->c.ld, LDOUBLE_SIZE); | 7974 | memcpy(ptr, &S->tccgen_vtop->c.ld, LDOUBLE_SIZE); |
| 7975 | else if (sizeof(double) == LDOUBLE_SIZE) | 7975 | else if (sizeof(double) == LDOUBLE_SIZE) |
| 7976 | memcpy(ptr, &S->vtop->c.ld, LDOUBLE_SIZE); | 7976 | memcpy(ptr, &S->tccgen_vtop->c.ld, LDOUBLE_SIZE); |
| 7977 | #ifndef TCC_CROSS_TEST | 7977 | #ifndef TCC_CROSS_TEST |
| 7978 | else | 7978 | else |
| 7979 | tcc_error(S, "can't cross compile long double constants"); | 7979 | tcc_error(S, "can't cross compile long double constants"); |
| @@ -7984,8 +7984,8 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) · 4 unmodified lines | |||
| 7984 | /* intptr_t may need a reloc too, see tcctest.c:relocation_test() */ | 7984 | /* intptr_t may need a reloc too, see tcctest.c:relocation_test() */ |
| 7985 | case VT_LLONG: | 7985 | case VT_LLONG: |
| 7986 | case VT_PTR: | 7986 | case VT_PTR: |
| 7987 | if (S->vtop->r & VT_SYM) | 7987 | if (S->tccgen_vtop->r & VT_SYM) |
| 7988 | greloca(S, sec, S->vtop->sym, c, R_DATA_PTR, val); | 7988 | greloca(S, sec, S->tccgen_vtop->sym, c, R_DATA_PTR, val); |
| 7989 | else | 7989 | else |
| 7990 | write64le(ptr, val); | 7990 | write64le(ptr, val); |
| 7991 | break; | 7991 | break; |
| @@ -7998,8 +7998,8 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) · 6 unmodified lines | |||
| 7998 | break; | 7998 | break; |
| 7999 | case VT_PTR: | 7999 | case VT_PTR: |
| 8000 | case VT_INT: | 8000 | case VT_INT: |
| 8001 | if (S->vtop->r & VT_SYM) | 8001 | if (S->tccgen_vtop->r & VT_SYM) |
| 8002 | greloc(S, sec, S->vtop->sym, c, R_DATA_PTR); | 8002 | greloc(S, sec, S->tccgen_vtop->sym, c, R_DATA_PTR); |
| 8003 | write32le(ptr, val); | 8003 | write32le(ptr, val); |
| 8004 | break; | 8004 | break; |
| 8005 | #endif | 8005 | #endif |
| @@ -8008,7 +8008,7 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) · 2 unmodified lines | |||
| 8008 | break; | 8008 | break; |
| 8009 | } | 8009 | } |
| 8010 | } | 8010 | } |
| 8011 | S->vtop--; | 8011 | S->tccgen_vtop--; |
| 8012 | } else { | 8012 | } else { |
| 8013 | vset(S, &dtype, VT_LOCAL|VT_LVAL, c); | 8013 | vset(S, &dtype, VT_LOCAL|VT_LVAL, c); |
| 8014 | vswap(S); | 8014 | vswap(S); |
| @@ -8022,7 +8022,7 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c) · 7 unmodified lines | |||
| 8022 | allocation. 'flags & DIF_FIRST' is true if array '{' must be read (multi | 8022 | allocation. 'flags & DIF_FIRST' is true if array '{' must be read (multi |
| 8023 | dimension implicit array init handling). 'flags & DIF_SIZE_ONLY' is true if | 8023 | dimension implicit array init handling). 'flags & DIF_SIZE_ONLY' is true if |
| 8024 | size only evaluation is wanted (only for arrays). */ | 8024 | size only evaluation is wanted (only for arrays). */ |
| 8025 | static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned long c, int flags) | 8025 | static void decl_initializer(TCCState* S, init_params *p, CType *type, unsigned long c, int flags) |
| 8026 | { | 8026 | { |
| 8027 | int len, n, no_oblock, i; | 8027 | int len, n, no_oblock, i; |
| 8028 | int size1, align1; | 8028 | int size1, align1; |
| @@ -8034,11 +8034,11 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 5 unmodified lines | |||
| 8034 | if (S->tccgen_debug_modes && !p->sec) | 8034 | if (S->tccgen_debug_modes && !p->sec) |
| 8035 | tcc_debug_line(S), tcc_tcov_check_line (S, 1); | 8035 | tcc_debug_line(S), tcc_tcov_check_line (S, 1); |
| 8036 | 8036 | ||
| 8037 | if (!(flags & DIF_HAVE_ELEM) && S->tok != '{' && | 8037 | if (!(flags & DIF_HAVE_ELEM) && S->tccpp_tok != '{' && |
| 8038 | /* In case of strings we have special handling for arrays, so | 8038 | /* In case of strings we have special handling for arrays, so |
| 8039 | don't consume them as initializer value (which would commit them | 8039 | don't consume them as initializer value (which would commit them |
| 8040 | to some anonymous symbol). */ | 8040 | to some anonymous symbol). */ |
| 8041 | S->tok != TOK_LSTR && S->tok != TOK_STR && | 8041 | S->tccpp_tok != TOK_LSTR && S->tccpp_tok != TOK_STR && |
| 8042 | !(flags & DIF_SIZE_ONLY)) { | 8042 | !(flags & DIF_SIZE_ONLY)) { |
| 8043 | parse_init_elem(S, !p->sec ? EXPR_ANY : EXPR_CONST); | 8043 | parse_init_elem(S, !p->sec ? EXPR_ANY : EXPR_CONST); |
| 8044 | flags |= DIF_HAVE_ELEM; | 8044 | flags |= DIF_HAVE_ELEM; |
| @@ -8049,13 +8049,13 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 4 unmodified lines | |||
| 8049 | /* Use i_c_parameter_t, to strip toplevel qualifiers. | 8049 | /* Use i_c_parameter_t, to strip toplevel qualifiers. |
| 8050 | The source type might have VT_CONSTANT set, which is | 8050 | The source type might have VT_CONSTANT set, which is |
| 8051 | of course assignable to non-const elements. */ | 8051 | of course assignable to non-const elements. */ |
| 8052 | is_compatible_unqualified_types(type, &S->vtop->type)) { | 8052 | is_compatible_unqualified_types(type, &S->tccgen_vtop->type)) { |
| 8053 | goto init_putv; | 8053 | goto init_putv; |
| 8054 | 8054 | ||
| 8055 | } else if (type->t & VT_ARRAY) { | 8055 | } else if (type->t & VT_ARRAY) { |
| 8056 | no_oblock = 1; | 8056 | no_oblock = 1; |
| 8057 | if (((flags & DIF_FIRST) && S->tok != TOK_LSTR && S->tok != TOK_STR) || | 8057 | if (((flags & DIF_FIRST) && S->tccpp_tok != TOK_LSTR && S->tccpp_tok != TOK_STR) || |
| 8058 | S->tok == '{') { | 8058 | S->tccpp_tok == '{') { |
| 8059 | skip(S, '{'); | 8059 | skip(S, '{'); |
| 8060 | no_oblock = 0; | 8060 | no_oblock = 0; |
| 8061 | } | 8061 | } |
| @@ -8067,34 +8067,34 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 5 unmodified lines | |||
| 8067 | 8067 | ||
| 8068 | /* only parse strings here if correct type (otherwise: handle | 8068 | /* only parse strings here if correct type (otherwise: handle |
| 8069 | them as ((w)char *) expressions */ | 8069 | them as ((w)char *) expressions */ |
| 8070 | if ((S->tok == TOK_LSTR && | 8070 | if ((S->tccpp_tok == TOK_LSTR && |
| 8071 | #ifdef TCC_TARGET_PE | 8071 | #ifdef TCC_TARGET_PE |
| 8072 | (t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED) | 8072 | (t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED) |
| 8073 | #else | 8073 | #else |
| 8074 | (t1->t & VT_BTYPE) == VT_INT | 8074 | (t1->t & VT_BTYPE) == VT_INT |
| 8075 | #endif | 8075 | #endif |
| 8076 | ) || (S->tok == TOK_STR && (t1->t & VT_BTYPE) == VT_BYTE)) { | 8076 | ) || (S->tccpp_tok == TOK_STR && (t1->t & VT_BTYPE) == VT_BYTE)) { |
| 8077 | len = 0; | 8077 | len = 0; |
| 8078 | cstr_reset(&S->tccgen_initstr); | 8078 | cstr_reset(&S->tccgen_initstr); |
| 8079 | if (size1 != (S->tok == TOK_STR ? 1 : sizeof(nwchar_t))) | 8079 | if (size1 != (S->tccpp_tok == TOK_STR ? 1 : sizeof(nwchar_t))) |
| 8080 | tcc_error(S, "unhandled string literal merging"); | 8080 | tcc_error(S, "unhandled string literal merging"); |
| 8081 | while (S->tok == TOK_STR || S->tok == TOK_LSTR) { | 8081 | while (S->tccpp_tok == TOK_STR || S->tccpp_tok == TOK_LSTR) { |
| 8082 | if (S->tccgen_initstr.size) | 8082 | if (S->tccgen_initstr.size) |
| 8083 | S->tccgen_initstr.size -= size1; | 8083 | S->tccgen_initstr.size -= size1; |
| 8084 | if (S->tok == TOK_STR) | 8084 | if (S->tccpp_tok == TOK_STR) |
| 8085 | len += S->tokc.str.size; | 8085 | len += S->tccpp_tokc.str.size; |
| 8086 | else | 8086 | else |
| 8087 | len += S->tokc.str.size / sizeof(nwchar_t); | 8087 | len += S->tccpp_tokc.str.size / sizeof(nwchar_t); |
| 8088 | len--; | 8088 | len--; |
| 8089 | cstr_cat(S, &S->tccgen_initstr, S->tokc.str.data, S->tokc.str.size); | 8089 | cstr_cat(S, &S->tccgen_initstr, S->tccpp_tokc.str.data, S->tccpp_tokc.str.size); |
| 8090 | next(S); | 8090 | next(S); |
| 8091 | } | 8091 | } |
| 8092 | if (S->tok != ')' && S->tok != '}' && S->tok != ',' && S->tok != ';' | 8092 | if (S->tccpp_tok != ')' && S->tccpp_tok != '}' && S->tccpp_tok != ',' && S->tccpp_tok != ';' |
| 8093 | && S->tok != TOK_EOF) { | 8093 | && S->tccpp_tok != TOK_EOF) { |
| 8094 | /* Not a lone literal but part of a bigger expression. */ | 8094 | /* Not a lone literal but part of a bigger expression. */ |
| 8095 | unget_tok(S, size1 == 1 ? TOK_STR : TOK_LSTR); | 8095 | unget_tok(S, size1 == 1 ? TOK_STR : TOK_LSTR); |
| 8096 | S->tokc.str.size = S->tccgen_initstr.size; | 8096 | S->tccpp_tokc.str.size = S->tccgen_initstr.size; |
| 8097 | S->tokc.str.data = S->tccgen_initstr.data; | 8097 | S->tccpp_tokc.str.data = S->tccgen_initstr.data; |
| 8098 | goto do_init_array; | 8098 | goto do_init_array; |
| 8099 | } | 8099 | } |
| 8100 | 8100 | ||
| @@ -8147,7 +8147,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 46 unmodified lines | |||
| 8147 | } | 8147 | } |
| 8148 | 8148 | ||
| 8149 | len = 0; | 8149 | len = 0; |
| 8150 | while (S->tok != '}' || (flags & DIF_HAVE_ELEM)) { | 8150 | while (S->tccpp_tok != '}' || (flags & DIF_HAVE_ELEM)) { |
| 8151 | len = decl_designator(S, p, type, c, &f, flags, len); | 8151 | len = decl_designator(S, p, type, c, &f, flags, len); |
| 8152 | flags &= ~DIF_HAVE_ELEM; | 8152 | flags &= ~DIF_HAVE_ELEM; |
| 8153 | if (type->t & VT_ARRAY) { | 8153 | if (type->t & VT_ARRAY) { |
| @@ -8166,7 +8166,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 12 unmodified lines | |||
| 8166 | break; | 8166 | break; |
| 8167 | } | 8167 | } |
| 8168 | 8168 | ||
| 8169 | if (S->tok == '}') | 8169 | if (S->tccpp_tok == '}') |
| 8170 | break; | 8170 | break; |
| 8171 | skip(S, ','); | 8171 | skip(S, ','); |
| 8172 | } | 8172 | } |
| @@ -8175,7 +8175,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 2 unmodified lines | |||
| 8175 | skip(S, '}'); | 8175 | skip(S, '}'); |
| 8176 | } else if ((type->t & VT_BTYPE) == VT_STRUCT) { | 8176 | } else if ((type->t & VT_BTYPE) == VT_STRUCT) { |
| 8177 | no_oblock = 1; | 8177 | no_oblock = 1; |
| 8178 | if ((flags & DIF_FIRST) || S->tok == '{') { | 8178 | if ((flags & DIF_FIRST) || S->tccpp_tok == '{') { |
| 8179 | skip(S, '{'); | 8179 | skip(S, '{'); |
| 8180 | no_oblock = 0; | 8180 | no_oblock = 0; |
| 8181 | } | 8181 | } |
| @@ -8184,7 +8184,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 2 unmodified lines | |||
| 8184 | n = s->c; | 8184 | n = s->c; |
| 8185 | size1 = 1; | 8185 | size1 = 1; |
| 8186 | goto do_init_list; | 8186 | goto do_init_list; |
| 8187 | } else if (S->tok == '{') { | 8187 | } else if (S->tccpp_tok == '{') { |
| 8188 | if (flags & DIF_HAVE_ELEM) | 8188 | if (flags & DIF_HAVE_ELEM) |
| 8189 | skip(S, ';'); | 8189 | skip(S, ';'); |
| 8190 | next(S); | 8190 | next(S); |
| @@ -8204,14 +8204,14 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 13 unmodified lines | |||
| 8204 | /* This should happen only when we haven't parsed | 8204 | /* This should happen only when we haven't parsed |
| 8205 | the init element above for fear of committing a | 8205 | the init element above for fear of committing a |
| 8206 | string constant to memory too early. */ | 8206 | string constant to memory too early. */ |
| 8207 | if (S->tok != TOK_STR && S->tok != TOK_LSTR) | 8207 | if (S->tccpp_tok != TOK_STR && S->tccpp_tok != TOK_LSTR) |
| 8208 | expect(S, "string constant"); | 8208 | expect(S, "string constant"); |
| 8209 | parse_init_elem(S, !p->sec ? EXPR_ANY : EXPR_CONST); | 8209 | parse_init_elem(S, !p->sec ? EXPR_ANY : EXPR_CONST); |
| 8210 | } | 8210 | } |
| 8211 | init_putv: | 8211 | init_putv: |
| 8212 | if (!p->sec && (flags & DIF_CLEAR) /* container was already zero'd */ | 8212 | if (!p->sec && (flags & DIF_CLEAR) /* container was already zero'd */ |
| 8213 | && (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST | 8213 | && (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST |
| 8214 | && S->vtop->c.i == 0 | 8214 | && S->tccgen_vtop->c.i == 0 |
| 8215 | && btype_size(type->t & VT_BTYPE) /* not for fp constants */ | 8215 | && btype_size(type->t & VT_BTYPE) /* not for fp constants */ |
| 8216 | ) | 8216 | ) |
| 8217 | vpop(S); | 8217 | vpop(S); |
| @@ -8227,7 +8227,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned · 9 unmodified lines | |||
| 8227 | are parsed. If 'v' is zero, then a reference to the new object | 8227 | are parsed. If 'v' is zero, then a reference to the new object |
| 8228 | is put in the value stack. If 'has_init' is 2, a special parsing | 8228 | is put in the value stack. If 'has_init' is 2, a special parsing |
| 8229 | is done to handle string constants. */ | 8229 | is done to handle string constants. */ |
| 8230 | static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, int r, | 8230 | static void decl_initializer_alloc(TCCState* S, CType *type, AttributeDef *ad, int r, |
| 8231 | int has_init, int v, int scope) | 8231 | int has_init, int v, int scope) |
| 8232 | { | 8232 | { |
| 8233 | int size, align, addr; | 8233 | int size, align, addr; |
| @@ -8236,7 +8236,7 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i · 2 unmodified lines | |||
| 8236 | Section *sec; | 8236 | Section *sec; |
| 8237 | Sym *flexible_array; | 8237 | Sym *flexible_array; |
| 8238 | Sym *sym; | 8238 | Sym *sym; |
| 8239 | int saved_nocode_wanted = S->nocode_wanted; | 8239 | int saved_nocode_wanted = S->tccgen_nocode_wanted; |
| 8240 | #ifdef CONFIG_TCC_BCHECK | 8240 | #ifdef CONFIG_TCC_BCHECK |
| 8241 | int bcheck = S->do_bounds_check && !NODATA_WANTED; | 8241 | int bcheck = S->do_bounds_check && !NODATA_WANTED; |
| 8242 | #endif | 8242 | #endif |
| @@ -8244,7 +8244,7 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i · 1 unmodified line | |||
| 8244 | 8244 | ||
| 8245 | /* Always allocate static or global variables */ | 8245 | /* Always allocate static or global variables */ |
| 8246 | if (v && (r & VT_VALMASK) == VT_CONST) | 8246 | if (v && (r & VT_VALMASK) == VT_CONST) |
| 8247 | S->nocode_wanted |= 0x80000000; | 8247 | S->tccgen_nocode_wanted |= 0x80000000; |
| 8248 | 8248 | ||
| 8249 | flexible_array = NULL; | 8249 | flexible_array = NULL; |
| 8250 | size = type_size(type, &align); | 8250 | size = type_size(type, &align); |
| @@ -8280,7 +8280,7 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i · 29 unmodified lines | |||
| 8280 | if (has_init == 2) { | 8280 | if (has_init == 2) { |
| 8281 | /* only get strings */ | 8281 | /* only get strings */ |
| 8282 | init_str = tok_str_alloc(S); | 8282 | init_str = tok_str_alloc(S); |
| 8283 | while (S->tok == TOK_STR || S->tok == TOK_LSTR) { | 8283 | while (S->tccpp_tok == TOK_STR || S->tccpp_tok == TOK_LSTR) { |
| 8284 | tok_str_add_tok(S, init_str); | 8284 | tok_str_add_tok(S, init_str); |
| 8285 | next(S); | 8285 | next(S); |
| 8286 | } | 8286 | } |
| @@ -8327,16 +8327,16 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i · 40 unmodified lines | |||
| 8327 | #ifdef CONFIG_TCC_BCHECK | 8327 | #ifdef CONFIG_TCC_BCHECK |
| 8328 | if (bcheck && v) { | 8328 | if (bcheck && v) { |
| 8329 | /* add padding between stack variables for bound checking */ | 8329 | /* add padding between stack variables for bound checking */ |
| 8330 | S->loc -= align; | 8330 | S->tccgen_loc -= align; |
| 8331 | } | 8331 | } |
| 8332 | #endif | 8332 | #endif |
| 8333 | S->loc = (S->loc - size) & -align; | 8333 | S->tccgen_loc = (S->tccgen_loc - size) & -align; |
| 8334 | addr = S->loc; | 8334 | addr = S->tccgen_loc; |
| 8335 | p.local_offset = addr + size; | 8335 | p.local_offset = addr + size; |
| 8336 | #ifdef CONFIG_TCC_BCHECK | 8336 | #ifdef CONFIG_TCC_BCHECK |
| 8337 | if (bcheck && v) { | 8337 | if (bcheck && v) { |
| 8338 | /* add padding between stack variables for bound checking */ | 8338 | /* add padding between stack variables for bound checking */ |
| 8339 | S->loc -= align; | 8339 | S->tccgen_loc -= align; |
| 8340 | } | 8340 | } |
| 8341 | #endif | 8341 | #endif |
| 8342 | if (v) { | 8342 | if (v) { |
| @@ -8422,8 +8422,8 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i · 79 unmodified lines | |||
| 8422 | } else { | 8422 | } else { |
| 8423 | /* push global reference */ | 8423 | /* push global reference */ |
| 8424 | vpush_ref(S, type, sec, addr, size); | 8424 | vpush_ref(S, type, sec, addr, size); |
| 8425 | sym = S->vtop->sym; | 8425 | sym = S->tccgen_vtop->sym; |
| 8426 | S->vtop->r |= r; | 8426 | S->tccgen_vtop->r |= r; |
| 8427 | } | 8427 | } |
| 8428 | 8428 | ||
| 8429 | #ifdef CONFIG_TCC_BCHECK | 8429 | #ifdef CONFIG_TCC_BCHECK |
| @@ -8452,8 +8452,8 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i · 22 unmodified lines | |||
| 8452 | if (S->tccgen_cur_scope->prev && S->tccgen_cur_scope->prev->vla.num) { | 8452 | if (S->tccgen_cur_scope->prev && S->tccgen_cur_scope->prev->vla.num) { |
| 8453 | S->tccgen_cur_scope->vla.locorig = S->tccgen_cur_scope->prev->vla.loc; | 8453 | S->tccgen_cur_scope->vla.locorig = S->tccgen_cur_scope->prev->vla.loc; |
| 8454 | } else { | 8454 | } else { |
| 8455 | gen_vla_sp_save(S, S->loc -= PTR_SIZE); | 8455 | gen_vla_sp_save(S, S->tccgen_loc -= PTR_SIZE); |
| 8456 | S->tccgen_cur_scope->vla.locorig = S->loc; | 8456 | S->tccgen_cur_scope->vla.locorig = S->tccgen_loc; |
| 8457 | } | 8457 | } |
| 8458 | } | 8458 | } |
| 8459 | 8459 | ||
| @@ -8462,7 +8462,7 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i · 2 unmodified lines | |||
| 8462 | #if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64 | 8462 | #if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64 |
| 8463 | /* on _WIN64, because of the function args scratch area, the | 8463 | /* on _WIN64, because of the function args scratch area, the |
| 8464 | result of alloca differs from RSP and is returned in RAX. */ | 8464 | result of alloca differs from RSP and is returned in RAX. */ |
| 8465 | gen_vla_result(S, addr), addr = (S->loc -= PTR_SIZE); | 8465 | gen_vla_result(S, addr), addr = (S->tccgen_loc -= PTR_SIZE); |
| 8466 | #endif | 8466 | #endif |
| 8467 | gen_vla_sp_save(S, addr); | 8467 | gen_vla_sp_save(S, addr); |
| 8468 | S->tccgen_cur_scope->vla.loc = addr; | 8468 | S->tccgen_cur_scope->vla.loc = addr; |
| @@ -8483,64 +8483,64 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i · 14 unmodified lines | |||
| 8483 | next(S); | 8483 | next(S); |
| 8484 | } | 8484 | } |
| 8485 | 8485 | ||
| 8486 | S->nocode_wanted = saved_nocode_wanted; | 8486 | S->tccgen_nocode_wanted = saved_nocode_wanted; |
| 8487 | } | 8487 | } |
| 8488 | 8488 | ||
| 8489 | /* parse a function defined by symbol 'sym' and generate its code in | 8489 | /* parse a function defined by symbol 'sym' and generate its code in |
| 8490 | 'cur_text_section' */ | 8490 | 'cur_text_section' */ |
| 8491 | static void gen_function(TCCState *S, Sym *sym) | 8491 | static void gen_function(TCCState* S, Sym *sym) |
| 8492 | { | 8492 | { |
| 8493 | scope_t f = { 0 }; | 8493 | scope_t f = { 0 }; |
| 8494 | S->tccgen_cur_scope = S->tccgen_root_scope = &f; | 8494 | S->tccgen_cur_scope = S->tccgen_root_scope = &f; |
| 8495 | S->nocode_wanted = 0; | 8495 | S->tccgen_nocode_wanted = 0; |
| 8496 | S->ind = cur_text_section->data_offset; | 8496 | S->tccgen_ind = cur_text_section->data_offset; |
| 8497 | if (sym->a.aligned) { | 8497 | if (sym->a.aligned) { |
| 8498 | size_t newoff = section_add(S, cur_text_section, 0, | 8498 | size_t newoff = section_add(S, cur_text_section, 0, |
| 8499 | 1 << (sym->a.aligned - 1)); | 8499 | 1 << (sym->a.aligned - 1)); |
| 8500 | gen_fill_nops(S, newoff - S->ind); | 8500 | gen_fill_nops(S, newoff - S->tccgen_ind); |
| 8501 | } | 8501 | } |
| 8502 | /* NOTE: we patch the symbol size later */ | 8502 | /* NOTE: we patch the symbol size later */ |
| 8503 | put_extern_sym(S, sym, cur_text_section, S->ind, 0); | 8503 | put_extern_sym(S, sym, cur_text_section, S->tccgen_ind, 0); |
| 8504 | if (sym->type.ref->f.func_ctor) | 8504 | if (sym->type.ref->f.func_ctor) |
| 8505 | add_array (S, ".init_array", sym->c); | 8505 | add_array (S, ".init_array", sym->c); |
| 8506 | if (sym->type.ref->f.func_dtor) | 8506 | if (sym->type.ref->f.func_dtor) |
| 8507 | add_array (S, ".fini_array", sym->c); | 8507 | add_array (S, ".fini_array", sym->c); |
| 8508 | 8508 | ||
| 8509 | S->tccgen_funcname = get_tok_str(S, sym->v, NULL); | 8509 | S->tccgen_funcname = get_tok_str(S, sym->v, NULL); |
| 8510 | S->tccgen_func_ind = S->ind; | 8510 | S->tccgen_func_ind = S->tccgen_ind; |
| 8511 | S->tccgen_func_vt = sym->type.ref->type; | 8511 | S->tccgen_func_vt = sym->type.ref->type; |
| 8512 | S->tccgen_func_var = sym->type.ref->f.func_type == FUNC_ELLIPSIS; | 8512 | S->tccgen_func_var = sym->type.ref->f.func_type == FUNC_ELLIPSIS; |
| 8513 | 8513 | ||
| 8514 | /* put debug symbol */ | 8514 | /* put debug symbol */ |
| 8515 | tcc_debug_funcstart(S, sym); | 8515 | tcc_debug_funcstart(S, sym); |
| 8516 | /* push a dummy symbol to enable local sym storage */ | 8516 | /* push a dummy symbol to enable local sym storage */ |
| 8517 | sym_push2(S, &S->local_stack, SYM_FIELD, 0, 0); | 8517 | sym_push2(S, &S->tccgen_local_stack, SYM_FIELD, 0, 0); |
| 8518 | S->local_scope = 1; /* for function parameters */ | 8518 | S->tccgen_local_scope = 1; /* for function parameters */ |
| 8519 | gfunc_prolog(S, sym); | 8519 | gfunc_prolog(S, sym); |
| 8520 | S->local_scope = 0; | 8520 | S->tccgen_local_scope = 0; |
| 8521 | S->tccgen_rsym = 0; | 8521 | S->tccgen_rsym = 0; |
| 8522 | clear_temp_local_var_list(S); | 8522 | clear_temp_local_var_list(S); |
| 8523 | block(S, 0); | 8523 | block(S, 0); |
| 8524 | gsym(S, S->tccgen_rsym); | 8524 | gsym(S, S->tccgen_rsym); |
| 8525 | S->nocode_wanted = 0; | 8525 | S->tccgen_nocode_wanted = 0; |
| 8526 | /* reset local stack */ | 8526 | /* reset local stack */ |
| 8527 | pop_local_syms(S, NULL, 0); | 8527 | pop_local_syms(S, NULL, 0); |
| 8528 | gfunc_epilog(S); | 8528 | gfunc_epilog(S); |
| 8529 | cur_text_section->data_offset = S->ind; | 8529 | cur_text_section->data_offset = S->tccgen_ind; |
| 8530 | S->local_scope = 0; | 8530 | S->tccgen_local_scope = 0; |
| 8531 | label_pop(S, &S->tccgen_global_label_stack, NULL, 0); | 8531 | label_pop(S, &S->tccgen_global_label_stack, NULL, 0); |
| 8532 | sym_pop(S, &S->tccgen_all_cleanups, NULL, 0); | 8532 | sym_pop(S, &S->tccgen_all_cleanups, NULL, 0); |
| 8533 | /* patch symbol size */ | 8533 | /* patch symbol size */ |
| 8534 | elfsym(S, sym)->st_size = S->ind - S->tccgen_func_ind; | 8534 | elfsym(S, sym)->st_size = S->tccgen_ind - S->tccgen_func_ind; |
| 8535 | /* end of function */ | 8535 | /* end of function */ |
| 8536 | tcc_debug_funcend(S, S->ind - S->tccgen_func_ind); | 8536 | tcc_debug_funcend(S, S->tccgen_ind - S->tccgen_func_ind); |
| 8537 | /* It's better to crash than to generate wrong code */ | 8537 | /* It's better to crash than to generate wrong code */ |
| 8538 | cur_text_section = NULL; | 8538 | cur_text_section = NULL; |
| 8539 | S->tccgen_funcname = ""; /* for safety */ | 8539 | S->tccgen_funcname = ""; /* for safety */ |
| 8540 | S->tccgen_func_vt.t = VT_VOID; /* for safety */ | 8540 | S->tccgen_func_vt.t = VT_VOID; /* for safety */ |
| 8541 | S->tccgen_func_var = 0; /* for safety */ | 8541 | S->tccgen_func_var = 0; /* for safety */ |
| 8542 | S->ind = 0; /* for safety */ | 8542 | S->tccgen_ind = 0; /* for safety */ |
| 8543 | S->nocode_wanted = 0x80000000; | 8543 | S->tccgen_nocode_wanted = 0x80000000; |
| 8544 | check_vstack(S); | 8544 | check_vstack(S); |
| 8545 | /* do this after funcend debug info */ | 8545 | /* do this after funcend debug info */ |
| 8546 | next(S); | 8546 | next(S); |
| @@ -8591,7 +8591,7 @@ static void free_inline_functions(TCCState *S) · 44 unmodified lines | |||
| 8591 | 8591 | ||
| 8592 | /* 'l' is VT_LOCAL or VT_CONST to define default storage type, or VT_CMP | 8592 | /* 'l' is VT_LOCAL or VT_CONST to define default storage type, or VT_CMP |
| 8593 | if parsing old style parameter decl list (and FUNC_SYM is set then) */ | 8593 | if parsing old style parameter decl list (and FUNC_SYM is set then) */ |
| 8594 | static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym) | 8594 | static int decl0(TCCState* S, int l, int is_for_loop_init, Sym *func_sym) |
| 8595 | { | 8595 | { |
| 8596 | int v, has_init, r, oldint; | 8596 | int v, has_init, r, oldint; |
| 8597 | CType type, btype; | 8597 | CType type, btype; |
| @@ -8599,7 +8599,7 @@ static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym) · 1 unmodified line | |||
| 8599 | AttributeDef ad, adbase; | 8599 | AttributeDef ad, adbase; |
| 8600 | 8600 | ||
| 8601 | while (1) { | 8601 | while (1) { |
| 8602 | if (S->tok == TOK_STATIC_ASSERT) { | 8602 | if (S->tccpp_tok == TOK_STATIC_ASSERT) { |
| 8603 | CString error_str; | 8603 | CString error_str; |
| 8604 | int c; | 8604 | int c; |
| 8605 | 8605 | ||
| @@ -8607,7 +8607,7 @@ static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym) · 1 unmodified line | |||
| 8607 | skip(S, '('); | 8607 | skip(S, '('); |
| 8608 | c = expr_const(S); | 8608 | c = expr_const(S); |
| 8609 | 8609 | ||
| 8610 | if (S->tok == ')') { | 8610 | if (S->tccpp_tok == ')') { |
| 8611 | if (!c) | 8611 | if (!c) |
| 8612 | tcc_error(S, "_Static_assert fail"); | 8612 | tcc_error(S, "_Static_assert fail"); |
| 8613 | next(S); | 8613 | next(S); |
| @@ -8630,30 +8630,30 @@ static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym) · 16 unmodified lines | |||
| 8630 | if (is_for_loop_init) | 8630 | if (is_for_loop_init) |
| 8631 | return 0; | 8631 | return 0; |
| 8632 | /* skip redundant ';' if not in old parameter decl scope */ | 8632 | /* skip redundant ';' if not in old parameter decl scope */ |
| 8633 | if (S->tok == ';' && l != VT_CMP) { | 8633 | if (S->tccpp_tok == ';' && l != VT_CMP) { |
| 8634 | next(S); | 8634 | next(S); |
| 8635 | continue; | 8635 | continue; |
| 8636 | } | 8636 | } |
| 8637 | if (l != VT_CONST) | 8637 | if (l != VT_CONST) |
| 8638 | break; | 8638 | break; |
| 8639 | if (S->tok == TOK_ASM1 || S->tok == TOK_ASM2 || S->tok == TOK_ASM3) { | 8639 | if (S->tccpp_tok == TOK_ASM1 || S->tccpp_tok == TOK_ASM2 || S->tccpp_tok == TOK_ASM3) { |
| 8640 | /* global asm block */ | 8640 | /* global asm block */ |
| 8641 | asm_global_instr(S); | 8641 | asm_global_instr(S); |
| 8642 | continue; | 8642 | continue; |
| 8643 | } | 8643 | } |
| 8644 | if (S->tok >= TOK_UIDENT) { | 8644 | if (S->tccpp_tok >= TOK_UIDENT) { |
| 8645 | /* special test for old K&R protos without explicit int | 8645 | /* special test for old K&R protos without explicit int |
| 8646 | type. Only accepted when defining global data */ | 8646 | type. Only accepted when defining global data */ |
| 8647 | btype.t = VT_INT; | 8647 | btype.t = VT_INT; |
| 8648 | oldint = 1; | 8648 | oldint = 1; |
| 8649 | } else { | 8649 | } else { |
| 8650 | if (S->tok != TOK_EOF) | 8650 | if (S->tccpp_tok != TOK_EOF) |
| 8651 | expect(S, "declaration"); | 8651 | expect(S, "declaration"); |
| 8652 | break; | 8652 | break; |
| 8653 | } | 8653 | } |
| 8654 | } | 8654 | } |
| 8655 | 8655 | ||
| 8656 | if (S->tok == ';') { | 8656 | if (S->tccpp_tok == ';') { |
65 more lines aren’t shown here.
| @@ -249,7 +249,7 @@ struct macho { · 248 unmodified lines | |||
| 249 | #define SHT_LINKEDIT (SHT_LOOS + 42) | 249 | #define SHT_LINKEDIT (SHT_LOOS + 42) |
| 250 | #define SHN_FROMDLL (SHN_LOOS + 2) /* Symbol is undefined, comes from a DLL */ | 250 | #define SHN_FROMDLL (SHN_LOOS + 2) /* Symbol is undefined, comes from a DLL */ |
| 251 | 251 | ||
| 252 | static void * add_lc(TCCState *S, struct macho *mo, uint32_t cmd, uint32_t cmdsize) | 252 | static void * add_lc(TCCState* S, struct macho *mo, uint32_t cmd, uint32_t cmdsize) |
| 253 | { | 253 | { |
| 254 | struct load_command *lc = tcc_mallocz(S, cmdsize); | 254 | struct load_command *lc = tcc_mallocz(S, cmdsize); |
| 255 | lc->cmd = cmd; | 255 | lc->cmd = cmd; |
| @@ -259,7 +259,7 @@ static void * add_lc(TCCState *S, struct macho *mo, uint32_t cmd, uint32_t cmdsi · 3 unmodified lines | |||
| 259 | return lc; | 259 | return lc; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | static struct segment_command_64 * add_segment(TCCState *S, struct macho *mo, const char *name) | 262 | static struct segment_command_64 * add_segment(TCCState* S, struct macho *mo, const char *name) |
| 263 | { | 263 | { |
| 264 | struct segment_command_64 *sc = add_lc(S, mo, LC_SEGMENT_64, sizeof(*sc)); | 264 | struct segment_command_64 *sc = add_lc(S, mo, LC_SEGMENT_64, sizeof(*sc)); |
| 265 | strncpy(sc->segname, name, 16); | 265 | strncpy(sc->segname, name, 16); |
| @@ -272,7 +272,7 @@ static struct segment_command_64 * get_segment(struct macho *mo, int i) · 6 unmodified lines | |||
| 272 | return (struct segment_command_64 *) (mo->lc[mo->seg2lc[i]]); | 272 | return (struct segment_command_64 *) (mo->lc[mo->seg2lc[i]]); |
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | static int add_section(TCCState *S, struct macho *mo, struct segment_command_64 **_seg, const char *name) | 275 | static int add_section(TCCState* S, struct macho *mo, struct segment_command_64 **_seg, const char *name) |
| 276 | { | 276 | { |
| 277 | struct segment_command_64 *seg = *_seg; | 277 | struct segment_command_64 *seg = *_seg; |
| 278 | int ret = seg->nsects; | 278 | int ret = seg->nsects; |
| @@ -293,7 +293,7 @@ static struct section_64 *get_section(struct segment_command_64 *seg, int i) · 14 unmodified lines | |||
| 293 | return (struct section_64*)((char*)seg + sizeof(*seg)) + i; | 293 | return (struct section_64*)((char*)seg + sizeof(*seg)) + i; |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | static void * add_dylib(TCCState *S, struct macho *mo, char *name) | 296 | static void * add_dylib(TCCState* S, struct macho *mo, char *name) |
| 297 | { | 297 | { |
| 298 | struct dylib_command *lc; | 298 | struct dylib_command *lc; |
| 299 | int sz = (sizeof(*lc) + strlen(name) + 1 + 7) & -8; | 299 | int sz = (sizeof(*lc) + strlen(name) + 1 + 7) & -8; |
| @@ -836,7 +836,7 @@ static uint32_t macho_swap32(uint32_t x) · 536 unmodified lines | |||
| 836 | } | 836 | } |
| 837 | #define SWAP(x) (swap ? macho_swap32(x) : (x)) | 837 | #define SWAP(x) (swap ? macho_swap32(x) : (x)) |
| 838 | 838 | ||
| 839 | ST_FUNC int macho_add_dllref(TCCState *S, int lev, const char* soname) | 839 | ST_FUNC int macho_add_dllref(TCCState* S, int lev, const char* soname) |
| 840 | { | 840 | { |
| 841 | /* if the dll is already loaded, do not load it */ | 841 | /* if the dll is already loaded, do not load it */ |
| 842 | DLLReference *dllref; | 842 | DLLReference *dllref; |
| @@ -865,7 +865,7 @@ ST_FUNC int macho_add_dllref(TCCState *S, int lev, const char* soname) · 22 unmodified lines | |||
| 865 | #ifdef TCC_IS_NATIVE | 865 | #ifdef TCC_IS_NATIVE |
| 866 | /* Looks for the active developer SDK set by xcode-select (or the default | 866 | /* Looks for the active developer SDK set by xcode-select (or the default |
| 867 | one set during installation.) */ | 867 | one set during installation.) */ |
| 868 | ST_FUNC void tcc_add_macos_sdkpath(TCCState *S) | 868 | ST_FUNC void tcc_add_macos_sdkpath(TCCState* s) |
| 869 | { | 869 | { |
| 870 | char *sdkroot = NULL, *pos = NULL; | 870 | char *sdkroot = NULL, *pos = NULL; |
| 871 | void* xcs = dlopen("libxcselect.dylib", RTLD_GLOBAL | RTLD_LAZY); | 871 | void* xcs = dlopen("libxcselect.dylib", RTLD_GLOBAL | RTLD_LAZY); |
| @@ -912,7 +912,7 @@ the_end: · 40 unmodified lines | |||
| 912 | } | 912 | } |
| 913 | #endif /* TCC_IS_NATIVE */ | 913 | #endif /* TCC_IS_NATIVE */ |
| 914 | 914 | ||
| 915 | ST_FUNC int macho_load_tbd(TCCState *S, int fd, const char* filename, int lev) | 915 | ST_FUNC int macho_load_tbd(TCCState* S, int fd, const char* filename, int lev) |
| 916 | { | 916 | { |
| 917 | char *soname, *data, *pos; | 917 | char *soname, *data, *pos; |
| 918 | int ret = -1; | 918 | int ret = -1; |
| @@ -1492,7 +1492,7 @@ static void pe_print_sections(TCCState *S, const char *fname) · 1491 unmodified lines | |||
| 1492 | /* helper function for load/store to insert one more indirection */ | 1492 | /* helper function for load/store to insert one more indirection */ |
| 1493 | 1493 | ||
| 1494 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 | 1494 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 |
| 1495 | ST_FUNC SValue *pe_getimport(TCCState *S, SValue *sv, SValue *v2) | 1495 | ST_FUNC SValue *pe_getimport(TCCState* S, SValue *sv, SValue *v2) |
| 1496 | { | 1496 | { |
| 1497 | int r2; | 1497 | int r2; |
| 1498 | if ((sv->r & (VT_VALMASK|VT_SYM)) != (VT_CONST|VT_SYM) || (sv->r2 != VT_CONST)) | 1498 | if ((sv->r & (VT_VALMASK|VT_SYM)) != (VT_CONST|VT_SYM) || (sv->r2 != VT_CONST)) |
| @@ -1512,7 +1512,7 @@ ST_FUNC SValue *pe_getimport(TCCState *S, SValue *sv, SValue *v2) · 13 unmodified lines | |||
| 1512 | vpushv(S, v2); | 1512 | vpushv(S, v2); |
| 1513 | vpushi(S, sv->c.i); | 1513 | vpushi(S, sv->c.i); |
| 1514 | gen_opi(S, '+'); | 1514 | gen_opi(S, '+'); |
| 1515 | *v2 = *S->vtop--; | 1515 | *v2 = *S->tccgen_vtop--; |
| 1516 | } | 1516 | } |
| 1517 | v2->type.t = sv->type.t; | 1517 | v2->type.t = sv->type.t; |
| 1518 | v2->r |= sv->r & VT_LVAL; | 1518 | v2->r |= sv->r & VT_LVAL; |
| @@ -1551,7 +1551,7 @@ static int read_mem(int fd, unsigned offset, void *buffer, unsigned len) · 32 unmodified lines | |||
| 1551 | 1551 | ||
| 1552 | /* ------------------------------------------------------------- */ | 1552 | /* ------------------------------------------------------------- */ |
| 1553 | 1553 | ||
| 1554 | static int get_dllexports(TCCState *S, int fd, char **pp) | 1554 | static int get_dllexports(TCCState* S, int fd, char **pp) |
| 1555 | { | 1555 | { |
| 1556 | int l, i, n, n0, ret; | 1556 | int l, i, n, n0, ret; |
| 1557 | char *p; | 1557 | char *p; |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | |||
| 26 | 26 | ||
| 27 | /* ------------------------------------------------------------------------- */ | 27 | /* ------------------------------------------------------------------------- */ |
| 28 | 28 | ||
| 29 | static void tok_print(TCCState *S, const char *msg, const int *str); | 29 | static void tok_print(TCCState* S, const char *msg, const int *str); |
| 30 | 30 | ||
| 31 | static const char tcc_keywords[] = | 31 | static const char tcc_keywords[] = |
| 32 | #define DEF(id, str) str "\0" | 32 | #define DEF(id, str) str "\0" |
| @@ -65,16 +65,16 @@ static const unsigned char tok_two_chars[] = · 32 unmodified lines | |||
| 65 | 0 | 65 | 0 |
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | static void next_nomacro(TCCState *S); | 68 | static void next_nomacro(TCCState* S); |
| 69 | 69 | ||
| 70 | ST_FUNC void skip(TCCState *S, int c) | 70 | ST_FUNC void skip(TCCState* S, int c) |
| 71 | { | 71 | { |
| 72 | if (S->tok != c) | 72 | if (S->tccpp_tok != c) |
| 73 | tcc_error(S, "'%c' expected (got \"%s\")", c, get_tok_str(S, S->tok, &S->tokc)); | 73 | tcc_error(S, "'%c' expected (got \"%s\")", c, get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 74 | next(S); | 74 | next(S); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | ST_FUNC void expect(TCCState *S, const char *msg) | 77 | ST_FUNC void expect(TCCState* S, const char *msg) |
| 78 | { | 78 | { |
| 79 | tcc_error(S, "%s expected", msg); | 79 | tcc_error(S, "%s expected", msg); |
| 80 | } | 80 | } |
| @@ -120,7 +120,7 @@ typedef struct tal_header_t { · 39 unmodified lines | |||
| 120 | 120 | ||
| 121 | /* ------------------------------------------------------------------------- */ | 121 | /* ------------------------------------------------------------------------- */ |
| 122 | 122 | ||
| 123 | static TinyAlloc *tal_new(TCCState *S, TinyAlloc **pal, unsigned limit, unsigned size) | 123 | static TinyAlloc *tal_new(TCCState* S, TinyAlloc **pal, unsigned limit, unsigned size) |
| 124 | { | 124 | { |
| 125 | TinyAlloc *al = tcc_mallocz(S, sizeof(TinyAlloc)); | 125 | TinyAlloc *al = tcc_mallocz(S, sizeof(TinyAlloc)); |
| 126 | al->p = al->buffer = tcc_malloc(S, size); | 126 | al->p = al->buffer = tcc_malloc(S, size); |
| @@ -130,7 +130,7 @@ static TinyAlloc *tal_new(TCCState *S, TinyAlloc **pal, unsigned limit, unsigned · 3 unmodified lines | |||
| 130 | return al; | 130 | return al; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static void tal_delete(TCCState *S, TinyAlloc *al) | 133 | static void tal_delete(TCCState* S, TinyAlloc *al) |
| 134 | { | 134 | { |
| 135 | TinyAlloc *next; | 135 | TinyAlloc *next; |
| 136 | 136 | ||
| @@ -168,7 +168,7 @@ tail_call: · 31 unmodified lines | |||
| 168 | goto tail_call; | 168 | goto tail_call; |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | static void tal_free_impl(TCCState *S, TinyAlloc *al, void *p TAL_DEBUG_PARAMS) | 171 | static void tal_free_impl(TCCState* S, TinyAlloc *al, void *p TAL_DEBUG_PARAMS) |
| 172 | { | 172 | { |
| 173 | if (!p) | 173 | if (!p) |
| 174 | return; | 174 | return; |
| @@ -195,7 +195,7 @@ tail_call: · 20 unmodified lines | |||
| 195 | tcc_free(S, p); | 195 | tcc_free(S, p); |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | static void *tal_realloc_impl(TCCState *S, TinyAlloc **pal, void *p, unsigned size TAL_DEBUG_PARAMS) | 198 | static void *tal_realloc_impl(TCCState* S, TinyAlloc **pal, void *p, unsigned size TAL_DEBUG_PARAMS) |
| 199 | { | 199 | { |
| 200 | tal_header_t *header; | 200 | tal_header_t *header; |
| 201 | void *ret; | 201 | void *ret; |
| @@ -278,7 +278,7 @@ tail_call: · 76 unmodified lines | |||
| 278 | 278 | ||
| 279 | /* ------------------------------------------------------------------------- */ | 279 | /* ------------------------------------------------------------------------- */ |
| 280 | /* CString handling */ | 280 | /* CString handling */ |
| 281 | static void cstr_realloc(TCCState *S, CString *cstr, int new_size) | 281 | static void cstr_realloc(TCCState* S, CString *cstr, int new_size) |
| 282 | { | 282 | { |
| 283 | int size; | 283 | int size; |
| 284 | 284 | ||
| @@ -292,7 +292,7 @@ static void cstr_realloc(TCCState *S, CString *cstr, int new_size) · 7 unmodified lines | |||
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | /* add a byte */ | 294 | /* add a byte */ |
| 295 | ST_INLN void cstr_ccat(TCCState *S, CString *cstr, int ch) | 295 | ST_INLN void cstr_ccat(TCCState* S, CString *cstr, int ch) |
| 296 | { | 296 | { |
| 297 | int size; | 297 | int size; |
| 298 | size = cstr->size + 1; | 298 | size = cstr->size + 1; |
| @@ -313,14 +313,14 @@ ST_INLN char *unicode_to_utf8 (char *b, uint32_t Uc) · 14 unmodified lines | |||
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | /* add a unicode character expanded into utf8 */ | 315 | /* add a unicode character expanded into utf8 */ |
| 316 | ST_INLN void cstr_u8cat(TCCState *S, CString *cstr, int ch) | 316 | ST_INLN void cstr_u8cat(TCCState* S, CString *cstr, int ch) |
| 317 | { | 317 | { |
| 318 | char buf[4], *e; | 318 | char buf[4], *e; |
| 319 | e = unicode_to_utf8(buf, (uint32_t)ch); | 319 | e = unicode_to_utf8(buf, (uint32_t)ch); |
| 320 | cstr_cat(S, cstr, buf, e - buf); | 320 | cstr_cat(S, cstr, buf, e - buf); |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | ST_FUNC void cstr_cat(TCCState *S, CString *cstr, const char *str, int len) | 323 | ST_FUNC void cstr_cat(TCCState* S, CString *cstr, const char *str, int len) |
| 324 | { | 324 | { |
| 325 | int size; | 325 | int size; |
| 326 | if (len <= 0) | 326 | if (len <= 0) |
| @@ -333,7 +333,7 @@ ST_FUNC void cstr_cat(TCCState *S, CString *cstr, const char *str, int len) · 6 unmodified lines | |||
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | /* add a wide char */ | 335 | /* add a wide char */ |
| 336 | ST_FUNC void cstr_wccat(TCCState *S, CString *cstr, int ch) | 336 | ST_FUNC void cstr_wccat(TCCState* S, CString *cstr, int ch) |
| 337 | { | 337 | { |
| 338 | int size; | 338 | int size; |
| 339 | size = cstr->size + sizeof(nwchar_t); | 339 | size = cstr->size + sizeof(nwchar_t); |
| @@ -343,13 +343,13 @@ ST_FUNC void cstr_wccat(TCCState *S, CString *cstr, int ch) · 3 unmodified lines | |||
| 343 | cstr->size = size; | 343 | cstr->size = size; |
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | ST_FUNC void cstr_new(TCCState *S, CString *cstr) | 346 | ST_FUNC void cstr_new(TCCState* S, CString *cstr) |
| 347 | { | 347 | { |
| 348 | memset(cstr, 0, sizeof(CString)); | 348 | memset(cstr, 0, sizeof(CString)); |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | /* free string and reset it to NULL */ | 351 | /* free string and reset it to NULL */ |
| 352 | ST_FUNC void cstr_free(TCCState *S, CString *cstr) | 352 | ST_FUNC void cstr_free(TCCState* S, CString *cstr) |
| 353 | { | 353 | { |
| 354 | tcc_free(S, cstr->data); | 354 | tcc_free(S, cstr->data); |
| 355 | cstr_new(S, cstr); | 355 | cstr_new(S, cstr); |
| @@ -361,7 +361,7 @@ ST_FUNC void cstr_reset(CString *cstr) · 5 unmodified lines | |||
| 361 | cstr->size = 0; | 361 | cstr->size = 0; |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | ST_FUNC int cstr_vprintf(TCCState *S, CString *cstr, const char *fmt, va_list ap) | 364 | ST_FUNC int cstr_vprintf(TCCState* S, CString *cstr, const char *fmt, va_list ap) |
| 365 | { | 365 | { |
| 366 | va_list v; | 366 | va_list v; |
| 367 | int len, size = 80; | 367 | int len, size = 80; |
| @@ -381,7 +381,7 @@ ST_FUNC int cstr_vprintf(TCCState *S, CString *cstr, const char *fmt, va_list ap · 13 unmodified lines | |||
| 381 | return len; | 381 | return len; |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | ST_FUNC int cstr_printf(TCCState *S, CString *cstr, const char *fmt, ...) | 384 | ST_FUNC int cstr_printf(TCCState* S, CString *cstr, const char *fmt, ...) |
| 385 | { | 385 | { |
| 386 | va_list ap; int len; | 386 | va_list ap; int len; |
| 387 | va_start(ap, fmt); | 387 | va_start(ap, fmt); |
| @@ -391,7 +391,7 @@ ST_FUNC int cstr_printf(TCCState *S, CString *cstr, const char *fmt, ...) · 3 unmodified lines | |||
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | /* XXX: unicode ? */ | 393 | /* XXX: unicode ? */ |
| 394 | static void add_char(TCCState *S, CString *cstr, int c) | 394 | static void add_char(TCCState* S, CString *cstr, int c) |
| 395 | { | 395 | { |
| 396 | if (c == '\'' || c == '\"' || c == '\\') { | 396 | if (c == '\'' || c == '\"' || c == '\\') { |
| 397 | /* XXX: could be more precise if char or string */ | 397 | /* XXX: could be more precise if char or string */ |
| @@ -413,24 +413,24 @@ static void add_char(TCCState *S, CString *cstr, int c) · 15 unmodified lines | |||
| 413 | 413 | ||
| 414 | /* ------------------------------------------------------------------------- */ | 414 | /* ------------------------------------------------------------------------- */ |
| 415 | /* allocate a new token */ | 415 | /* allocate a new token */ |
| 416 | static TokenSym *tok_alloc_new(TCCState *S, TokenSym **pts, const char *str, int len) | 416 | static TokenSym *tok_alloc_new(TCCState* S, TokenSym **pts, const char *str, int len) |
| 417 | { | 417 | { |
| 418 | TokenSym *ts, **ptable; | 418 | TokenSym *ts, **ptable; |
| 419 | int i; | 419 | int i; |
| 420 | 420 | ||
| 421 | if (S->tok_ident >= SYM_FIRST_ANOM) | 421 | if (S->tccpp_tok_ident >= SYM_FIRST_ANOM) |
| 422 | tcc_error(S, "memory full (symbols)"); | 422 | tcc_error(S, "memory full (symbols)"); |
| 423 | 423 | ||
| 424 | /* expand token table if needed */ | 424 | /* expand token table if needed */ |
| 425 | i = S->tok_ident - TOK_IDENT; | 425 | i = S->tccpp_tok_ident - TOK_IDENT; |
| 426 | if ((i % TOK_ALLOC_INCR) == 0) { | 426 | if ((i % TOK_ALLOC_INCR) == 0) { |
| 427 | ptable = tcc_realloc(S, S->tccpp_table_ident, (i + TOK_ALLOC_INCR) * sizeof(TokenSym *)); | 427 | ptable = tcc_realloc(S, S->tccpp_table_ident, (i + TOK_ALLOC_INCR) * sizeof(TokenSym *)); |
| 428 | S->tccpp_table_ident = ptable; | 428 | S->tccpp_table_ident = ptable; |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | ts = tal_realloc(S, S->toksym_alloc, 0, sizeof(TokenSym) + len); | 431 | ts = tal_realloc(S, S->tccpp_toksym_alloc, 0, sizeof(TokenSym) + len); |
| 432 | S->tccpp_table_ident[i] = ts; | 432 | S->tccpp_table_ident[i] = ts; |
| 433 | ts->tok = S->tok_ident++; | 433 | ts->tok = S->tccpp_tok_ident++; |
| 434 | ts->sym_define = NULL; | 434 | ts->sym_define = NULL; |
| 435 | ts->sym_label = NULL; | 435 | ts->sym_label = NULL; |
| 436 | ts->sym_struct = NULL; | 436 | ts->sym_struct = NULL; |
| @@ -448,7 +448,7 @@ static TokenSym *tok_alloc_new(TCCState *S, TokenSym **pts, const char *str, int · 11 unmodified lines | |||
| 448 | 448 | ||
| 449 | 449 | ||
| 450 | /* find a token and add it if not found */ | 450 | /* find a token and add it if not found */ |
| 451 | ST_FUNC TokenSym *tok_alloc(TCCState *S, const char *str, int len) | 451 | ST_FUNC TokenSym *tok_alloc(TCCState* S, const char *str, int len) |
| 452 | { | 452 | { |
| 453 | TokenSym *ts, **pts; | 453 | TokenSym *ts, **pts; |
| 454 | int i; | 454 | int i; |
| @@ -471,7 +471,7 @@ ST_FUNC TokenSym *tok_alloc(TCCState *S, const char *str, int len) · 16 unmodified lines | |||
| 471 | return tok_alloc_new(S, pts, str, len); | 471 | return tok_alloc_new(S, pts, str, len); |
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | ST_FUNC int tok_alloc_const(TCCState *S, const char *str) | 474 | ST_FUNC int tok_alloc_const(TCCState* S, const char *str) |
| 475 | { | 475 | { |
| 476 | return tok_alloc(S, str, strlen(str))->tok; | 476 | return tok_alloc(S, str, strlen(str))->tok; |
| 477 | } | 477 | } |
| @@ -479,7 +479,7 @@ ST_FUNC int tok_alloc_const(TCCState *S, const char *str) · 1 unmodified line | |||
| 479 | 479 | ||
| 480 | /* XXX: buffer overflow */ | 480 | /* XXX: buffer overflow */ |
| 481 | /* XXX: float tokens */ | 481 | /* XXX: float tokens */ |
| 482 | ST_FUNC const char *get_tok_str(TCCState *S, int v, CValue *cv) | 482 | ST_FUNC const char *get_tok_str(TCCState* S, int v, CValue *cv) |
| 483 | { | 483 | { |
| 484 | char *p; | 484 | char *p; |
| 485 | int i, len; | 485 | int i, len; |
| @@ -578,7 +578,7 @@ ST_FUNC const char *get_tok_str(TCCState *S, int v, CValue *cv) · 92 unmodified lines | |||
| 578 | *p++ = v; | 578 | *p++ = v; |
| 579 | case 0: /* nameless anonymous symbol */ | 579 | case 0: /* nameless anonymous symbol */ |
| 580 | *p = '\0'; | 580 | *p = '\0'; |
| 581 | } else if (v < S->tok_ident) { | 581 | } else if (v < S->tccpp_tok_ident) { |
| 582 | return S->tccpp_table_ident[v - TOK_IDENT]->str; | 582 | return S->tccpp_table_ident[v - TOK_IDENT]->str; |
| 583 | } else if (v >= SYM_FIRST_ANOM) { | 583 | } else if (v >= SYM_FIRST_ANOM) { |
| 584 | /* special name for anonymous symbol */ | 584 | /* special name for anonymous symbol */ |
| @@ -594,7 +594,7 @@ ST_FUNC const char *get_tok_str(TCCState *S, int v, CValue *cv) · 9 unmodified lines | |||
| 594 | 594 | ||
| 595 | /* return the current character, handling end of block if necessary | 595 | /* return the current character, handling end of block if necessary |
| 596 | (but not stray) */ | 596 | (but not stray) */ |
| 597 | static int handle_eob(TCCState *S) | 597 | static int handle_eob(TCCState* S) |
| 598 | { | 598 | { |
| 599 | BufferedFile *bf = S->tccpp_file; | 599 | BufferedFile *bf = S->tccpp_file; |
| 600 | int len; | 600 | int len; |
| @@ -627,7 +627,7 @@ static int handle_eob(TCCState *S) · 26 unmodified lines | |||
| 627 | } | 627 | } |
| 628 | 628 | ||
| 629 | /* read next char from current input file and handle end of input buffer */ | 629 | /* read next char from current input file and handle end of input buffer */ |
| 630 | static inline void inp(TCCState *S) | 630 | static inline void inp(TCCState* S) |
| 631 | { | 631 | { |
| 632 | S->tccpp_ch = *(++(S->tccpp_file->buf_ptr)); | 632 | S->tccpp_ch = *(++(S->tccpp_file->buf_ptr)); |
| 633 | /* end of buffer/file handling */ | 633 | /* end of buffer/file handling */ |
| @@ -636,7 +636,7 @@ static inline void inp(TCCState *S) · 2 unmodified lines | |||
| 636 | } | 636 | } |
| 637 | 637 | ||
| 638 | /* handle '\[\r]\n' */ | 638 | /* handle '\[\r]\n' */ |
| 639 | static int handle_stray_noerror(TCCState *S) | 639 | static int handle_stray_noerror(TCCState* S) |
| 640 | { | 640 | { |
| 641 | while (S->tccpp_ch == '\\') { | 641 | while (S->tccpp_ch == '\\') { |
| 642 | inp(S); | 642 | inp(S); |
| @@ -657,7 +657,7 @@ static int handle_stray_noerror(TCCState *S) · 14 unmodified lines | |||
| 657 | return 0; | 657 | return 0; |
| 658 | } | 658 | } |
| 659 | 659 | ||
| 660 | static void handle_stray(TCCState *S) | 660 | static void handle_stray(TCCState* S) |
| 661 | { | 661 | { |
| 662 | if (handle_stray_noerror(S)) | 662 | if (handle_stray_noerror(S)) |
| 663 | tcc_error(S, "stray '\\' in program"); | 663 | tcc_error(S, "stray '\\' in program"); |
| @@ -665,7 +665,7 @@ static void handle_stray(TCCState *S) · 1 unmodified line | |||
| 665 | 665 | ||
| 666 | /* skip the stray and handle the \\n case. Output an error if | 666 | /* skip the stray and handle the \\n case. Output an error if |
| 667 | incorrect char after the stray */ | 667 | incorrect char after the stray */ |
| 668 | static int handle_stray1(TCCState *S, uint8_t *p) | 668 | static int handle_stray1(TCCState* S, uint8_t *p) |
| 669 | { | 669 | { |
| 670 | int c; | 670 | int c; |
| 671 | 671 | ||
| @@ -713,7 +713,7 @@ static int handle_stray1(TCCState *S, uint8_t *p) · 41 unmodified lines | |||
| 713 | /* input with '\[\r]\n' handling. Note that this function cannot | 713 | /* input with '\[\r]\n' handling. Note that this function cannot |
| 714 | handle other characters after '\', so you cannot call it inside | 714 | handle other characters after '\', so you cannot call it inside |
| 715 | strings or comments */ | 715 | strings or comments */ |
| 716 | static void minp(TCCState *S) | 716 | static void minp(TCCState* S) |
| 717 | { | 717 | { |
| 718 | inp(S); | 718 | inp(S); |
| 719 | if (S->tccpp_ch == '\\') | 719 | if (S->tccpp_ch == '\\') |
| @@ -721,7 +721,7 @@ static void minp(TCCState *S) · 1 unmodified line | |||
| 721 | } | 721 | } |
| 722 | 722 | ||
| 723 | /* single line C++ comments */ | 723 | /* single line C++ comments */ |
| 724 | static uint8_t *parse_line_comment(TCCState *S, uint8_t *p) | 724 | static uint8_t *parse_line_comment(TCCState* S, uint8_t *p) |
| 725 | { | 725 | { |
| 726 | int c; | 726 | int c; |
| 727 | 727 | ||
| @@ -758,7 +758,7 @@ static uint8_t *parse_line_comment(TCCState *S, uint8_t *p) · 30 unmodified lines | |||
| 758 | } | 758 | } |
| 759 | 759 | ||
| 760 | /* C comments */ | 760 | /* C comments */ |
| 761 | static uint8_t *parse_comment(TCCState *S, uint8_t *p) | 761 | static uint8_t *parse_comment(TCCState* S, uint8_t *p) |
| 762 | { | 762 | { |
| 763 | int c; | 763 | int c; |
| 764 | 764 | ||
| @@ -833,7 +833,7 @@ static uint8_t *parse_comment(TCCState *S, uint8_t *p) · 68 unmodified lines | |||
| 833 | return p; | 833 | return p; |
| 834 | } | 834 | } |
| 835 | 835 | ||
| 836 | ST_FUNC int set_idnum(TCCState *S, int c, int val) | 836 | ST_FUNC int set_idnum(TCCState* S, int c, int val) |
| 837 | { | 837 | { |
| 838 | int prev = S->tccpp_isidnum_table[c - CH_EOF]; | 838 | int prev = S->tccpp_isidnum_table[c - CH_EOF]; |
| 839 | S->tccpp_isidnum_table[c - CH_EOF] = val; | 839 | S->tccpp_isidnum_table[c - CH_EOF] = val; |
| @@ -842,13 +842,13 @@ ST_FUNC int set_idnum(TCCState *S, int c, int val) · 2 unmodified lines | |||
| 842 | 842 | ||
| 843 | #define cinp minp | 843 | #define cinp minp |
| 844 | 844 | ||
| 845 | static inline void skip_spaces(TCCState *S) | 845 | static inline void skip_spaces(TCCState* S) |
| 846 | { | 846 | { |
| 847 | while (S->tccpp_isidnum_table[S->tccpp_ch - CH_EOF] & IS_SPC) | 847 | while (S->tccpp_isidnum_table[S->tccpp_ch - CH_EOF] & IS_SPC) |
| 848 | cinp(S); | 848 | cinp(S); |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | static inline int check_space(TCCState *S, int t, int *spc) | 851 | static inline int check_space(TCCState* S, int t, int *spc) |
| 852 | { | 852 | { |
| 853 | if (t < 256 && (S->tccpp_isidnum_table[t - CH_EOF] & IS_SPC)) { | 853 | if (t < 256 && (S->tccpp_isidnum_table[t - CH_EOF] & IS_SPC)) { |
| 854 | if (*spc) | 854 | if (*spc) |
| @@ -860,7 +860,7 @@ static inline int check_space(TCCState *S, int t, int *spc) · 5 unmodified lines | |||
| 860 | } | 860 | } |
| 861 | 861 | ||
| 862 | /* parse a string without interpreting escapes */ | 862 | /* parse a string without interpreting escapes */ |
| 863 | static uint8_t *parse_pp_string(TCCState *S, uint8_t *p, | 863 | static uint8_t *parse_pp_string(TCCState* S, uint8_t *p, |
| 864 | int sep, CString *str) | 864 | int sep, CString *str) |
| 865 | { | 865 | { |
| 866 | int c; | 866 | int c; |
| @@ -924,7 +924,7 @@ static uint8_t *parse_pp_string(TCCState *S, uint8_t *p, · 57 unmodified lines | |||
| 924 | 924 | ||
| 925 | /* skip block of text until #else, #elif or #endif. skip also pairs of | 925 | /* skip block of text until #else, #elif or #endif. skip also pairs of |
| 926 | #if/#endif */ | 926 | #if/#endif */ |
| 927 | static void preprocess_skip(TCCState *S) | 927 | static void preprocess_skip(TCCState* S) |
| 928 | { | 928 | { |
| 929 | int a, start_of_line, c, in_warn_or_error; | 929 | int a, start_of_line, c, in_warn_or_error; |
| 930 | uint8_t *p; | 930 | uint8_t *p; |
| @@ -988,15 +988,15 @@ redo_start: · 57 unmodified lines | |||
| 988 | next_nomacro(S); | 988 | next_nomacro(S); |
| 989 | p = S->tccpp_file->buf_ptr; | 989 | p = S->tccpp_file->buf_ptr; |
| 990 | if (a == 0 && | 990 | if (a == 0 && |
| 991 | (S->tok == TOK_ELSE || S->tok == TOK_ELIF || S->tok == TOK_ENDIF)) | 991 | (S->tccpp_tok == TOK_ELSE || S->tccpp_tok == TOK_ELIF || S->tccpp_tok == TOK_ENDIF)) |
| 992 | goto the_end; | 992 | goto the_end; |
| 993 | if (S->tok == TOK_IF || S->tok == TOK_IFDEF || S->tok == TOK_IFNDEF) | 993 | if (S->tccpp_tok == TOK_IF || S->tccpp_tok == TOK_IFDEF || S->tccpp_tok == TOK_IFNDEF) |
| 994 | a++; | 994 | a++; |
| 995 | else if (S->tok == TOK_ENDIF) | 995 | else if (S->tccpp_tok == TOK_ENDIF) |
| 996 | a--; | 996 | a--; |
| 997 | else if( S->tok == TOK_ERROR || S->tok == TOK_WARNING) | 997 | else if( S->tccpp_tok == TOK_ERROR || S->tccpp_tok == TOK_WARNING) |
| 998 | in_warn_or_error = 1; | 998 | in_warn_or_error = 1; |
| 999 | else if (S->tok == TOK_LINEFEED) | 999 | else if (S->tccpp_tok == TOK_LINEFEED) |
| 1000 | goto redo_start; | 1000 | goto redo_start; |
| 1001 | else if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE) | 1001 | else if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE) |
| 1002 | p = parse_line_comment(S, p - 1); | 1002 | p = parse_line_comment(S, p - 1); |
| @@ -1062,34 +1062,34 @@ ST_INLN void tok_str_new(TokenString *s) · 59 unmodified lines | |||
| 1062 | s->last_line_num = -1; | 1062 | s->last_line_num = -1; |
| 1063 | } | 1063 | } |
| 1064 | 1064 | ||
| 1065 | ST_FUNC TokenString *tok_str_alloc(TCCState *S) | 1065 | ST_FUNC TokenString *tok_str_alloc(TCCState* S) |
| 1066 | { | 1066 | { |
| 1067 | TokenString *str = tal_realloc(S, S->tokstr_alloc, 0, sizeof *str); | 1067 | TokenString *str = tal_realloc(S, S->tccpp_tokstr_alloc, 0, sizeof *str); |
| 1068 | tok_str_new(str); | 1068 | tok_str_new(str); |
| 1069 | return str; | 1069 | return str; |
| 1070 | } | 1070 | } |
| 1071 | 1071 | ||
| 1072 | ST_FUNC int *tok_str_dup(TCCState *S, TokenString *s) | 1072 | ST_FUNC int *tok_str_dup(TCCState* S, TokenString *s) |
| 1073 | { | 1073 | { |
| 1074 | int *str; | 1074 | int *str; |
| 1075 | 1075 | ||
| 1076 | str = tal_realloc(S, S->tokstr_alloc, 0, s->len * sizeof(int)); | 1076 | str = tal_realloc(S, S->tccpp_tokstr_alloc, 0, s->len * sizeof(int)); |
| 1077 | memcpy(str, s->str, s->len * sizeof(int)); | 1077 | memcpy(str, s->str, s->len * sizeof(int)); |
| 1078 | return str; | 1078 | return str; |
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | ST_FUNC void tok_str_free_str(TCCState *S, int *str) | 1081 | ST_FUNC void tok_str_free_str(TCCState* S, int *str) |
| 1082 | { | 1082 | { |
| 1083 | tal_free(S, S->tokstr_alloc, str); | 1083 | tal_free(S, S->tccpp_tokstr_alloc, str); |
| 1084 | } | 1084 | } |
| 1085 | 1085 | ||
| 1086 | ST_FUNC void tok_str_free(TCCState *S, TokenString *str) | 1086 | ST_FUNC void tok_str_free(TCCState* S, TokenString *str) |
| 1087 | { | 1087 | { |
| 1088 | tok_str_free_str(S, str->str); | 1088 | tok_str_free_str(S, str->str); |
| 1089 | tal_free(S, S->tokstr_alloc, str); | 1089 | tal_free(S, S->tccpp_tokstr_alloc, str); |
| 1090 | } | 1090 | } |
| 1091 | 1091 | ||
| 1092 | ST_FUNC int *tok_str_realloc(TCCState *S, TokenString *s, int new_size) | 1092 | ST_FUNC int *tok_str_realloc(TCCState* S, TokenString *s, int new_size) |
| 1093 | { | 1093 | { |
| 1094 | int *str, size; | 1094 | int *str, size; |
| 1095 | 1095 | ||
| @@ -1099,14 +1099,14 @@ ST_FUNC int *tok_str_realloc(TCCState *S, TokenString *s, int new_size) · 3 unmodified lines | |||
| 1099 | while (size < new_size) | 1099 | while (size < new_size) |
| 1100 | size = size * 2; | 1100 | size = size * 2; |
| 1101 | if (size > s->allocated_len) { | 1101 | if (size > s->allocated_len) { |
| 1102 | str = tal_realloc(S, S->tokstr_alloc, s->str, size * sizeof(int)); | 1102 | str = tal_realloc(S, S->tccpp_tokstr_alloc, s->str, size * sizeof(int)); |
| 1103 | s->allocated_len = size; | 1103 | s->allocated_len = size; |
| 1104 | s->str = str; | 1104 | s->str = str; |
| 1105 | } | 1105 | } |
| 1106 | return s->str; | 1106 | return s->str; |
| 1107 | } | 1107 | } |
| 1108 | 1108 | ||
| 1109 | ST_FUNC void tok_str_add(TCCState *S, TokenString *s, int t) | 1109 | ST_FUNC void tok_str_add(TCCState* S, TokenString *s, int t) |
| 1110 | { | 1110 | { |
| 1111 | int len, *str; | 1111 | int len, *str; |
| 1112 | 1112 | ||
| @@ -1118,7 +1118,7 @@ ST_FUNC void tok_str_add(TCCState *S, TokenString *s, int t) · 5 unmodified lines | |||
| 1118 | s->len = len; | 1118 | s->len = len; |
| 1119 | } | 1119 | } |
| 1120 | 1120 | ||
| 1121 | ST_FUNC void begin_macro(TCCState *S, TokenString *str, int alloc) | 1121 | ST_FUNC void begin_macro(TCCState* S, TokenString *str, int alloc) |
| 1122 | { | 1122 | { |
| 1123 | str->alloc = alloc; | 1123 | str->alloc = alloc; |
| 1124 | str->prev = S->tccpp_macro_stack; | 1124 | str->prev = S->tccpp_macro_stack; |
| @@ -1128,7 +1128,7 @@ ST_FUNC void begin_macro(TCCState *S, TokenString *str, int alloc) · 3 unmodified lines | |||
| 1128 | S->tccpp_macro_stack = str; | 1128 | S->tccpp_macro_stack = str; |
| 1129 | } | 1129 | } |
| 1130 | 1130 | ||
| 1131 | ST_FUNC void end_macro(TCCState *S) | 1131 | ST_FUNC void end_macro(TCCState* S) |
| 1132 | { | 1132 | { |
| 1133 | TokenString *str = S->tccpp_macro_stack; | 1133 | TokenString *str = S->tccpp_macro_stack; |
| 1134 | S->tccpp_macro_stack = str->prev; | 1134 | S->tccpp_macro_stack = str->prev; |
| @@ -1141,7 +1141,7 @@ ST_FUNC void end_macro(TCCState *S) · 6 unmodified lines | |||
| 1141 | } | 1141 | } |
| 1142 | } | 1142 | } |
| 1143 | 1143 | ||
| 1144 | static void tok_str_add2(TCCState *S, TokenString *s, int t, CValue *cv) | 1144 | static void tok_str_add2(TCCState* S, TokenString *s, int t, CValue *cv) |
| 1145 | { | 1145 | { |
| 1146 | int len, *str; | 1146 | int len, *str; |
| 1147 | 1147 | ||
| @@ -1215,7 +1215,7 @@ static void tok_str_add2(TCCState *S, TokenString *s, int t, CValue *cv) · 67 unmodified lines | |||
| 1215 | } | 1215 | } |
| 1216 | 1216 | ||
| 1217 | /* add the current parse token in token string 's' */ | 1217 | /* add the current parse token in token string 's' */ |
| 1218 | ST_FUNC void tok_str_add_tok(TCCState *S, TokenString *s) | 1218 | ST_FUNC void tok_str_add_tok(TCCState* S, TokenString *s) |
| 1219 | { | 1219 | { |
| 1220 | CValue cval; | 1220 | CValue cval; |
| 1221 | 1221 | ||
| @@ -1225,7 +1225,7 @@ ST_FUNC void tok_str_add_tok(TCCState *S, TokenString *s) · 3 unmodified lines | |||
| 1225 | cval.i = s->last_line_num; | 1225 | cval.i = s->last_line_num; |
| 1226 | tok_str_add2(S, s, TOK_LINENUM, &cval); | 1226 | tok_str_add2(S, s, TOK_LINENUM, &cval); |
| 1227 | } | 1227 | } |
| 1228 | tok_str_add2(S, s, S->tok, &S->tokc); | 1228 | tok_str_add2(S, s, S->tccpp_tok, &S->tccpp_tokc); |
| 1229 | } | 1229 | } |
| 1230 | 1230 | ||
| 1231 | /* get a token from an integer array and increment pointer. */ | 1231 | /* get a token from an integer array and increment pointer. */ |
| @@ -1304,7 +1304,7 @@ static inline void tok_get(int *t, const int **pp, CValue *cv) · 72 unmodified lines | |||
| 1304 | } while (0) | 1304 | } while (0) |
| 1305 | #endif | 1305 | #endif |
| 1306 | 1306 | ||
| 1307 | static int macro_is_equal(TCCState *S, const int *a, const int *b) | 1307 | static int macro_is_equal(TCCState* S, const int *a, const int *b) |
| 1308 | { | 1308 | { |
| 1309 | CValue cv; | 1309 | CValue cv; |
| 1310 | int t; | 1310 | int t; |
| @@ -1325,7 +1325,7 @@ static int macro_is_equal(TCCState *S, const int *a, const int *b) · 14 unmodified lines | |||
| 1325 | } | 1325 | } |
| 1326 | 1326 | ||
| 1327 | /* defines handling */ | 1327 | /* defines handling */ |
| 1328 | ST_INLN void define_push(TCCState *S, int v, int macro_type, int *str, Sym *first_arg) | 1328 | ST_INLN void define_push(TCCState* S, int v, int macro_type, int *str, Sym *first_arg) |
| 1329 | { | 1329 | { |
| 1330 | Sym *s, *o; | 1330 | Sym *s, *o; |
| 1331 | 1331 | ||
| @@ -1340,23 +1340,23 @@ ST_INLN void define_push(TCCState *S, int v, int macro_type, int *str, Sym *firs · 8 unmodified lines | |||
| 1340 | } | 1340 | } |
| 1341 | 1341 | ||
| 1342 | /* undefined a define symbol. Its name is just set to zero */ | 1342 | /* undefined a define symbol. Its name is just set to zero */ |
| 1343 | ST_FUNC void define_undef(TCCState *S, Sym *s) | 1343 | ST_FUNC void define_undef(TCCState* S, Sym *s) |
| 1344 | { | 1344 | { |
| 1345 | int v = s->v; | 1345 | int v = s->v; |
| 1346 | if (v >= TOK_IDENT && v < S->tok_ident) | 1346 | if (v >= TOK_IDENT && v < S->tccpp_tok_ident) |
| 1347 | S->tccpp_table_ident[v - TOK_IDENT]->sym_define = NULL; | 1347 | S->tccpp_table_ident[v - TOK_IDENT]->sym_define = NULL; |
| 1348 | } | 1348 | } |
| 1349 | 1349 | ||
| 1350 | ST_INLN Sym *define_find(TCCState *S, int v) | 1350 | ST_INLN Sym *define_find(TCCState* S, int v) |
| 1351 | { | 1351 | { |
| 1352 | v -= TOK_IDENT; | 1352 | v -= TOK_IDENT; |
| 1353 | if ((unsigned)v >= (unsigned)(S->tok_ident - TOK_IDENT)) | 1353 | if ((unsigned)v >= (unsigned)(S->tccpp_tok_ident - TOK_IDENT)) |
| 1354 | return NULL; | 1354 | return NULL; |
| 1355 | return S->tccpp_table_ident[v]->sym_define; | 1355 | return S->tccpp_table_ident[v]->sym_define; |
| 1356 | } | 1356 | } |
| 1357 | 1357 | ||
| 1358 | /* free define stack until top reaches 'b' */ | 1358 | /* free define stack until top reaches 'b' */ |
| 1359 | ST_FUNC void free_defines(TCCState *S, Sym *b) | 1359 | ST_FUNC void free_defines(TCCState* S, Sym *b) |
| 1360 | { | 1360 | { |
| 1361 | while (S->tccgen_define_stack != b) { | 1361 | while (S->tccgen_define_stack != b) { |
| 1362 | Sym *top = S->tccgen_define_stack; | 1362 | Sym *top = S->tccgen_define_stack; |
| @@ -1368,15 +1368,15 @@ ST_FUNC void free_defines(TCCState *S, Sym *b) · 5 unmodified lines | |||
| 1368 | } | 1368 | } |
| 1369 | 1369 | ||
| 1370 | /* label lookup */ | 1370 | /* label lookup */ |
| 1371 | ST_FUNC Sym *label_find(TCCState *S, int v) | 1371 | ST_FUNC Sym *label_find(TCCState* S, int v) |
| 1372 | { | 1372 | { |
| 1373 | v -= TOK_IDENT; | 1373 | v -= TOK_IDENT; |
| 1374 | if ((unsigned)v >= (unsigned)(S->tok_ident - TOK_IDENT)) | 1374 | if ((unsigned)v >= (unsigned)(S->tccpp_tok_ident - TOK_IDENT)) |
| 1375 | return NULL; | 1375 | return NULL; |
| 1376 | return S->tccpp_table_ident[v]->sym_label; | 1376 | return S->tccpp_table_ident[v]->sym_label; |
| 1377 | } | 1377 | } |
| 1378 | 1378 | ||
| 1379 | ST_FUNC Sym *label_push(TCCState *S, Sym **ptop, int v, int flags) | 1379 | ST_FUNC Sym *label_push(TCCState* S, Sym **ptop, int v, int flags) |
| 1380 | { | 1380 | { |
| 1381 | Sym *s, **ps; | 1381 | Sym *s, **ps; |
| 1382 | s = sym_push2(S, ptop, v, 0, 0); | 1382 | s = sym_push2(S, ptop, v, 0, 0); |
| @@ -1395,7 +1395,7 @@ ST_FUNC Sym *label_push(TCCState *S, Sym **ptop, int v, int flags) · 12 unmodified lines | |||
| 1395 | 1395 | ||
| 1396 | /* pop labels until element last is reached. Look if any labels are | 1396 | /* pop labels until element last is reached. Look if any labels are |
| 1397 | undefined. Define symbols if '&&label' was used. */ | 1397 | undefined. Define symbols if '&&label' was used. */ |
| 1398 | ST_FUNC void label_pop(TCCState *S, Sym **ptop, Sym *slast, int keep) | 1398 | ST_FUNC void label_pop(TCCState* S, Sym **ptop, Sym *slast, int keep) |
| 1399 | { | 1399 | { |
| 1400 | Sym *s, *s1; | 1400 | Sym *s, *s1; |
| 1401 | for(s = *ptop; s != slast; s = s1) { | 1401 | for(s = *ptop; s != slast; s = s1) { |
| @@ -1430,60 +1430,60 @@ static void maybe_run_test(TCCState *S) · 28 unmodified lines | |||
| 1430 | const char *p; | 1430 | const char *p; |
| 1431 | if (S->include_stack_ptr != S->include_stack) | 1431 | if (S->include_stack_ptr != S->include_stack) |
| 1432 | return; | 1432 | return; |
| 1433 | p = get_tok_str(S, S->tok, NULL); | 1433 | p = get_tok_str(S, S->tccpp_tok, NULL); |
| 1434 | if (0 != memcmp(p, "test_", 5)) | 1434 | if (0 != memcmp(p, "test_", 5)) |
| 1435 | return; | 1435 | return; |
| 1436 | if (0 != --S->run_test) | 1436 | if (0 != --S->run_test) |
| 1437 | return; | 1437 | return; |
| 1438 | fprintf(S->ppfp, &"\n[%s]\n"[!(S->dflag & TCC_OPTION_d_32)], p), fflush(S->ppfp); | 1438 | fprintf(S->ppfp, &"\n[%s]\n"[!(S->dflag & TCC_OPTION_d_32)], p), fflush(S->ppfp); |
| 1439 | define_push(S, S->tok, MACRO_OBJ, NULL, NULL); | 1439 | define_push(S, S->tccpp_tok, MACRO_OBJ, NULL, NULL); |
| 1440 | } | 1440 | } |
| 1441 | 1441 | ||
| 1442 | /* eval an expression for #if/#elif */ | 1442 | /* eval an expression for #if/#elif */ |
| 1443 | static int expr_preprocess(TCCState *S) | 1443 | static int expr_preprocess(TCCState* S) |
| 1444 | { | 1444 | { |
| 1445 | int c, t; | 1445 | int c, t; |
| 1446 | TokenString *str; | 1446 | TokenString *str; |
| 1447 | 1447 | ||
| 1448 | str = tok_str_alloc(S); | 1448 | str = tok_str_alloc(S); |
| 1449 | S->tccpp_pp_expr = 1; | 1449 | S->tccpp_pp_expr = 1; |
| 1450 | while (S->tok != TOK_LINEFEED && S->tok != TOK_EOF) { | 1450 | while (S->tccpp_tok != TOK_LINEFEED && S->tccpp_tok != TOK_EOF) { |
| 1451 | next(S); /* do macro subst */ | 1451 | next(S); /* do macro subst */ |
| 1452 | redo: | 1452 | redo: |
| 1453 | if (S->tok == TOK_DEFINED) { | 1453 | if (S->tccpp_tok == TOK_DEFINED) { |
| 1454 | next_nomacro(S); | 1454 | next_nomacro(S); |
| 1455 | t = S->tok; | 1455 | t = S->tccpp_tok; |
| 1456 | if (t == '(') | 1456 | if (t == '(') |
| 1457 | next_nomacro(S); | 1457 | next_nomacro(S); |
| 1458 | if (S->tok < TOK_IDENT) | 1458 | if (S->tccpp_tok < TOK_IDENT) |
| 1459 | expect(S, "identifier"); | 1459 | expect(S, "identifier"); |
| 1460 | if (S->run_test) | 1460 | if (S->run_test) |
| 1461 | maybe_run_test(S); | 1461 | maybe_run_test(S); |
| 1462 | c = define_find(S, S->tok) != 0; | 1462 | c = define_find(S, S->tccpp_tok) != 0; |
| 1463 | if (t == '(') { | 1463 | if (t == '(') { |
| 1464 | next_nomacro(S); | 1464 | next_nomacro(S); |
| 1465 | if (S->tok != ')') | 1465 | if (S->tccpp_tok != ')') |
| 1466 | expect(S, "')'"); | 1466 | expect(S, "')'"); |
| 1467 | } | 1467 | } |
| 1468 | S->tok = TOK_CINT; | 1468 | S->tccpp_tok = TOK_CINT; |
| 1469 | S->tokc.i = c; | 1469 | S->tccpp_tokc.i = c; |
| 1470 | } else if (1 && S->tok == TOK___HAS_INCLUDE) { | 1470 | } else if (1 && S->tccpp_tok == TOK___HAS_INCLUDE) { |
| 1471 | next(S); /* XXX check if correct to use expansion */ | 1471 | next(S); /* XXX check if correct to use expansion */ |
| 1472 | skip(S, '('); | 1472 | skip(S, '('); |
| 1473 | while (S->tok != ')' && S->tok != TOK_EOF) | 1473 | while (S->tccpp_tok != ')' && S->tccpp_tok != TOK_EOF) |
| 1474 | next(S); | 1474 | next(S); |
| 1475 | if (S->tok != ')') | 1475 | if (S->tccpp_tok != ')') |
| 1476 | expect(S, "')'"); | 1476 | expect(S, "')'"); |
| 1477 | S->tok = TOK_CINT; | 1477 | S->tccpp_tok = TOK_CINT; |
| 1478 | S->tokc.i = 0; | 1478 | S->tccpp_tokc.i = 0; |
| 1479 | } else if (S->tok >= TOK_IDENT) { | 1479 | } else if (S->tccpp_tok >= TOK_IDENT) { |
| 1480 | /* if undefined macro, replace with zero, check for func-like */ | 1480 | /* if undefined macro, replace with zero, check for func-like */ |
| 1481 | t = S->tok; | 1481 | t = S->tccpp_tok; |
| 1482 | S->tok = TOK_CINT; | 1482 | S->tccpp_tok = TOK_CINT; |
| 1483 | S->tokc.i = 0; | 1483 | S->tccpp_tokc.i = 0; |
| 1484 | tok_str_add_tok(S, str); | 1484 | tok_str_add_tok(S, str); |
| 1485 | next(S); | 1485 | next(S); |
| 1486 | if (S->tok == '(') | 1486 | if (S->tccpp_tok == '(') |
| 1487 | tcc_error(S, "function-like macro '%s' is not defined", | 1487 | tcc_error(S, "function-like macro '%s' is not defined", |
| 1488 | get_tok_str(S, t, NULL)); | 1488 | get_tok_str(S, t, NULL)); |
| 1489 | goto redo; | 1489 | goto redo; |
| @@ -1503,15 +1503,15 @@ static int expr_preprocess(TCCState *S) · 13 unmodified lines | |||
| 1503 | 1503 | ||
| 1504 | 1504 | ||
| 1505 | /* parse after #define */ | 1505 | /* parse after #define */ |
| 1506 | ST_FUNC void parse_define(TCCState *S) | 1506 | ST_FUNC void parse_define(TCCState* S) |
| 1507 | { | 1507 | { |
| 1508 | Sym *s, *first, **ps; | 1508 | Sym *s, *first, **ps; |
| 1509 | int v, t, varg, is_vaargs, spc; | 1509 | int v, t, varg, is_vaargs, spc; |
| 1510 | int saved_parse_flags = S->tccpp_parse_flags; | 1510 | int saved_parse_flags = S->tccpp_parse_flags; |
| 1511 | 1511 | ||
| 1512 | v = S->tok; | 1512 | v = S->tccpp_tok; |
| 1513 | if (v < TOK_IDENT || v == TOK_DEFINED) | 1513 | if (v < TOK_IDENT || v == TOK_DEFINED) |
| 1514 | tcc_error(S, "invalid macro name '%s'", get_tok_str(S, S->tok, &S->tokc)); | 1514 | tcc_error(S, "invalid macro name '%s'", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 1515 | /* XXX: should check if same macro (ANSI) */ | 1515 | /* XXX: should check if same macro (ANSI) */ |
| 1516 | first = NULL; | 1516 | first = NULL; |
| 1517 | t = MACRO_OBJ; | 1517 | t = MACRO_OBJ; |
| @@ -1523,18 +1523,18 @@ ST_FUNC void parse_define(TCCState *S) · 5 unmodified lines | |||
| 1523 | /* '(' must be just after macro definition for MACRO_FUNC */ | 1523 | /* '(' must be just after macro definition for MACRO_FUNC */ |
| 1524 | next_nomacro(S); | 1524 | next_nomacro(S); |
| 1525 | S->tccpp_parse_flags &= ~PARSE_FLAG_SPACES; | 1525 | S->tccpp_parse_flags &= ~PARSE_FLAG_SPACES; |
| 1526 | if (S->tok == '(') { | 1526 | if (S->tccpp_tok == '(') { |
| 1527 | int dotid = set_idnum(S, '.', 0); | 1527 | int dotid = set_idnum(S, '.', 0); |
| 1528 | next_nomacro(S); | 1528 | next_nomacro(S); |
| 1529 | ps = &first; | 1529 | ps = &first; |
| 1530 | if (S->tok != ')') for (;;) { | 1530 | if (S->tccpp_tok != ')') for (;;) { |
| 1531 | varg = S->tok; | 1531 | varg = S->tccpp_tok; |
| 1532 | next_nomacro(S); | 1532 | next_nomacro(S); |
| 1533 | is_vaargs = 0; | 1533 | is_vaargs = 0; |
| 1534 | if (varg == TOK_DOTS) { | 1534 | if (varg == TOK_DOTS) { |
| 1535 | varg = TOK___VA_ARGS__; | 1535 | varg = TOK___VA_ARGS__; |
| 1536 | is_vaargs = 1; | 1536 | is_vaargs = 1; |
| 1537 | } else if (S->tok == TOK_DOTS && gnu_ext) { | 1537 | } else if (S->tccpp_tok == TOK_DOTS && gnu_ext) { |
| 1538 | is_vaargs = 1; | 1538 | is_vaargs = 1; |
| 1539 | next_nomacro(S); | 1539 | next_nomacro(S); |
| 1540 | } | 1540 | } |
| @@ -1544,9 +1544,9 @@ ST_FUNC void parse_define(TCCState *S) · 3 unmodified lines | |||
| 1544 | s = sym_push2(S, &S->tccgen_define_stack, varg | SYM_FIELD, is_vaargs, 0); | 1544 | s = sym_push2(S, &S->tccgen_define_stack, varg | SYM_FIELD, is_vaargs, 0); |
| 1545 | *ps = s; | 1545 | *ps = s; |
| 1546 | ps = &s->next; | 1546 | ps = &s->next; |
| 1547 | if (S->tok == ')') | 1547 | if (S->tccpp_tok == ')') |
| 1548 | break; | 1548 | break; |
| 1549 | if (S->tok != ',' || is_vaargs) | 1549 | if (S->tccpp_tok != ',' || is_vaargs) |
| 1550 | goto bad_list; | 1550 | goto bad_list; |
| 1551 | next_nomacro(S); | 1551 | next_nomacro(S); |
| 1552 | } | 1552 | } |
| @@ -1556,7 +1556,7 @@ ST_FUNC void parse_define(TCCState *S) · 3 unmodified lines | |||
| 1556 | set_idnum(S, '.', dotid); | 1556 | set_idnum(S, '.', dotid); |
| 1557 | } | 1557 | } |
| 1558 | 1558 | ||
| 1559 | S->tokstr_buf.len = 0; | 1559 | S->tccpp_tokstr_buf.len = 0; |
| 1560 | spc = 2; | 1560 | spc = 2; |
| 1561 | S->tccpp_parse_flags |= PARSE_FLAG_ACCEPT_STRAYS | PARSE_FLAG_SPACES | PARSE_FLAG_LINEFEED; | 1561 | S->tccpp_parse_flags |= PARSE_FLAG_ACCEPT_STRAYS | PARSE_FLAG_SPACES | PARSE_FLAG_LINEFEED; |
| 1562 | /* The body of a macro definition should be parsed such that identifiers | 1562 | /* The body of a macro definition should be parsed such that identifiers |
| @@ -1564,33 +1564,33 @@ ST_FUNC void parse_define(TCCState *S) · 1 unmodified line | |||
| 1564 | ID character in asm mode). But '#' should be retained instead of | 1564 | ID character in asm mode). But '#' should be retained instead of |
| 1565 | regarded as line comment leader, so still don't set ASM_FILE | 1565 | regarded as line comment leader, so still don't set ASM_FILE |
| 1566 | in parse_flags. */ | 1566 | in parse_flags. */ |
| 1567 | while (S->tok != TOK_LINEFEED && S->tok != TOK_EOF) { | 1567 | while (S->tccpp_tok != TOK_LINEFEED && S->tccpp_tok != TOK_EOF) { |
| 1568 | /* remove spaces around ## and after '#' */ | 1568 | /* remove spaces around ## and after '#' */ |
| 1569 | if (TOK_TWOSHARPS == S->tok) { | 1569 | if (TOK_TWOSHARPS == S->tccpp_tok) { |
| 1570 | if (2 == spc) | 1570 | if (2 == spc) |
| 1571 | goto bad_twosharp; | 1571 | goto bad_twosharp; |
| 1572 | if (1 == spc) | 1572 | if (1 == spc) |
| 1573 | --S->tokstr_buf.len; | 1573 | --S->tccpp_tokstr_buf.len; |
| 1574 | spc = 3; | 1574 | spc = 3; |
| 1575 | S->tok = TOK_PPJOIN; | 1575 | S->tccpp_tok = TOK_PPJOIN; |
| 1576 | } else if ('#' == S->tok) { | 1576 | } else if ('#' == S->tccpp_tok) { |
| 1577 | spc = 4; | 1577 | spc = 4; |
| 1578 | } else if (check_space(S, S->tok, &spc)) { | 1578 | } else if (check_space(S, S->tccpp_tok, &spc)) { |
| 1579 | goto skip; | 1579 | goto skip; |
| 1580 | } | 1580 | } |
| 1581 | tok_str_add2(S, &S->tokstr_buf, S->tok, &S->tokc); | 1581 | tok_str_add2(S, &S->tccpp_tokstr_buf, S->tccpp_tok, &S->tccpp_tokc); |
| 1582 | skip: | 1582 | skip: |
| 1583 | next_nomacro(S); | 1583 | next_nomacro(S); |
| 1584 | } | 1584 | } |
| 1585 | 1585 | ||
| 1586 | S->tccpp_parse_flags = saved_parse_flags; | 1586 | S->tccpp_parse_flags = saved_parse_flags; |
| 1587 | if (spc == 1) | 1587 | if (spc == 1) |
| 1588 | --S->tokstr_buf.len; /* remove trailing space */ | 1588 | --S->tccpp_tokstr_buf.len; /* remove trailing space */ |
| 1589 | tok_str_add(S, &S->tokstr_buf, 0); | 1589 | tok_str_add(S, &S->tccpp_tokstr_buf, 0); |
| 1590 | if (3 == spc) | 1590 | if (3 == spc) |
| 1591 | bad_twosharp: | 1591 | bad_twosharp: |
| 1592 | tcc_error(S, "'##' cannot appear at either end of macro"); | 1592 | tcc_error(S, "'##' cannot appear at either end of macro"); |
| 1593 | define_push(S, v, t, tok_str_dup(S, &S->tokstr_buf), first); | 1593 | define_push(S, v, t, tok_str_dup(S, &S->tccpp_tokstr_buf), first); |
| 1594 | } | 1594 | } |
| 1595 | 1595 | ||
| 1596 | static CachedInclude *search_cached_include(TCCState *S, const char *filename, int add) | 1596 | static CachedInclude *search_cached_include(TCCState *S, const char *filename, int add) |
| @@ -1640,16 +1640,16 @@ static CachedInclude *search_cached_include(TCCState *S, const char *filename, i · 43 unmodified lines | |||
| 1640 | static void pragma_parse(TCCState *S) | 1640 | static void pragma_parse(TCCState *S) |
| 1641 | { | 1641 | { |
| 1642 | next_nomacro(S); | 1642 | next_nomacro(S); |
| 1643 | if (S->tok == TOK_push_macro || S->tok == TOK_pop_macro) { | 1643 | if (S->tccpp_tok == TOK_push_macro || S->tccpp_tok == TOK_pop_macro) { |
| 1644 | int t = S->tok, v; | 1644 | int t = S->tccpp_tok, v; |
| 1645 | Sym *s; | 1645 | Sym *s; |
| 1646 | 1646 | ||
| 1647 | if (next(S), S->tok != '(') | 1647 | if (next(S), S->tccpp_tok != '(') |
| 1648 | goto pragma_err; | 1648 | goto pragma_err; |
| 1649 | if (next(S), S->tok != TOK_STR) | 1649 | if (next(S), S->tccpp_tok != TOK_STR) |
| 1650 | goto pragma_err; | 1650 | goto pragma_err; |
| 1651 | v = tok_alloc(S, S->tokc.str.data, S->tokc.str.size - 1)->tok; | 1651 | v = tok_alloc(S, S->tccpp_tokc.str.data, S->tccpp_tokc.str.size - 1)->tok; |
| 1652 | if (next(S), S->tok != ')') | 1652 | if (next(S), S->tccpp_tok != ')') |
| 1653 | goto pragma_err; | 1653 | goto pragma_err; |
| 1654 | if (t == TOK_push_macro) { | 1654 | if (t == TOK_push_macro) { |
| 1655 | while (NULL == (s = define_find(S, v))) | 1655 | while (NULL == (s = define_find(S, v))) |
| @@ -1668,7 +1668,7 @@ static void pragma_parse(TCCState *S) · 12 unmodified lines | |||
| 1668 | tcc_warning(S, "unbalanced #pragma pop_macro"); | 1668 | tcc_warning(S, "unbalanced #pragma pop_macro"); |
| 1669 | S->tccpp_pp_debug_tok = t, S->tccpp_pp_debug_symv = v; | 1669 | S->tccpp_pp_debug_tok = t, S->tccpp_pp_debug_symv = v; |
| 1670 | 1670 | ||
| 1671 | } else if (S->tok == TOK_once) { | 1671 | } else if (S->tccpp_tok == TOK_once) { |
| 1672 | search_cached_include(S, S->tccpp_file->filename, 1)->once = S->tccpp_pp_once; | 1672 | search_cached_include(S, S->tccpp_file->filename, 1)->once = S->tccpp_pp_once; |
| 1673 | 1673 | ||
| 1674 | } else if (S->output_type == TCC_OUTPUT_PREPROCESS) { | 1674 | } else if (S->output_type == TCC_OUTPUT_PREPROCESS) { |
| @@ -1678,7 +1678,7 @@ static void pragma_parse(TCCState *S) · 3 unmodified lines | |||
| 1678 | unget_tok(S, '#'); | 1678 | unget_tok(S, '#'); |
| 1679 | unget_tok(S, TOK_LINEFEED); | 1679 | unget_tok(S, TOK_LINEFEED); |
| 1680 | 1680 | ||
| 1681 | } else if (S->tok == TOK_pack) { | 1681 | } else if (S->tccpp_tok == TOK_pack) { |
| 1682 | /* This may be: | 1682 | /* This may be: |
| 1683 | #pragma pack(1) // set | 1683 | #pragma pack(1) // set |
| 1684 | #pragma pack() // reset to default | 1684 | #pragma pack() // reset to default |
| @@ -1687,7 +1687,7 @@ static void pragma_parse(TCCState *S) · 2 unmodified lines | |||
| 1687 | #pragma pack(pop) // restore previous */ | 1687 | #pragma pack(pop) // restore previous */ |
| 1688 | next(S); | 1688 | next(S); |
| 1689 | skip(S, '('); | 1689 | skip(S, '('); |
| 1690 | if (S->tok == TOK_ASM_pop) { | 1690 | if (S->tccpp_tok == TOK_ASM_pop) { |
| 1691 | next(S); | 1691 | next(S); |
| 1692 | if (S->pack_stack_ptr <= S->pack_stack) { | 1692 | if (S->pack_stack_ptr <= S->pack_stack) { |
| 1693 | stk_error: | 1693 | stk_error: |
| @@ -1696,19 +1696,19 @@ static void pragma_parse(TCCState *S) · 2 unmodified lines | |||
| 1696 | S->pack_stack_ptr--; | 1696 | S->pack_stack_ptr--; |
| 1697 | } else { | 1697 | } else { |
| 1698 | int val = 0; | 1698 | int val = 0; |
| 1699 | if (S->tok != ')') { | 1699 | if (S->tccpp_tok != ')') { |
| 1700 | if (S->tok == TOK_ASM_push) { | 1700 | if (S->tccpp_tok == TOK_ASM_push) { |
| 1701 | next(S); | 1701 | next(S); |
| 1702 | if (S->pack_stack_ptr >= S->pack_stack + PACK_STACK_SIZE - 1) | 1702 | if (S->pack_stack_ptr >= S->pack_stack + PACK_STACK_SIZE - 1) |
| 1703 | goto stk_error; | 1703 | goto stk_error; |
| 1704 | val = *S->pack_stack_ptr++; | 1704 | val = *S->pack_stack_ptr++; |
| 1705 | if (S->tok != ',') | 1705 | if (S->tccpp_tok != ',') |
| 1706 | goto pack_set; | 1706 | goto pack_set; |
| 1707 | next(S); | 1707 | next(S); |
| 1708 | } | 1708 | } |
| 1709 | if (S->tok != TOK_CINT) | 1709 | if (S->tccpp_tok != TOK_CINT) |
| 1710 | goto pragma_err; | 1710 | goto pragma_err; |
| 1711 | val = S->tokc.i; | 1711 | val = S->tccpp_tokc.i; |
| 1712 | if (val < 1 || val > 16 || (val & (val - 1)) != 0) | 1712 | if (val < 1 || val > 16 || (val & (val - 1)) != 0) |
| 1713 | goto pragma_err; | 1713 | goto pragma_err; |
| 1714 | next(S); | 1714 | next(S); |
| @@ -1716,21 +1716,21 @@ static void pragma_parse(TCCState *S) · 1 unmodified line | |||
| 1716 | pack_set: | 1716 | pack_set: |
| 1717 | *S->pack_stack_ptr = val; | 1717 | *S->pack_stack_ptr = val; |
| 1718 | } | 1718 | } |
| 1719 | if (S->tok != ')') | 1719 | if (S->tccpp_tok != ')') |
| 1720 | goto pragma_err; | 1720 | goto pragma_err; |
| 1721 | 1721 | ||
| 1722 | } else if (S->tok == TOK_comment) { | 1722 | } else if (S->tccpp_tok == TOK_comment) { |
| 1723 | char *p; int t; | 1723 | char *p; int t; |
| 1724 | next(S); | 1724 | next(S); |
| 1725 | skip(S, '('); | 1725 | skip(S, '('); |
| 1726 | t = S->tok; | 1726 | t = S->tccpp_tok; |
| 1727 | next(S); | 1727 | next(S); |
| 1728 | skip(S, ','); | 1728 | skip(S, ','); |
| 1729 | if (S->tok != TOK_STR) | 1729 | if (S->tccpp_tok != TOK_STR) |
| 1730 | goto pragma_err; | 1730 | goto pragma_err; |
| 1731 | p = tcc_strdup(S, (char *)S->tokc.str.data); | 1731 | p = tcc_strdup(S, (char *)S->tccpp_tokc.str.data); |
| 1732 | next(S); | 1732 | next(S); |
| 1733 | if (S->tok != ')') | 1733 | if (S->tccpp_tok != ')') |
| 1734 | goto pragma_err; | 1734 | goto pragma_err; |
| 1735 | if (t == TOK_lib) { | 1735 | if (t == TOK_lib) { |
| 1736 | dynarray_add(S, &S->pragma_libs, &S->nb_pragma_libs, p); | 1736 | dynarray_add(S, &S->pragma_libs, &S->nb_pragma_libs, p); |
| @@ -1741,7 +1741,7 @@ static void pragma_parse(TCCState *S) · 4 unmodified lines | |||
| 1741 | } | 1741 | } |
| 1742 | 1742 | ||
| 1743 | } else | 1743 | } else |
| 1744 | tcc_warning_c(warn_unsupported)(S, "#pragma %s ignored", get_tok_str(S, S->tok, &S->tokc)); | 1744 | tcc_warning_c(warn_unsupported)(S, "#pragma %s ignored", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 1745 | return; | 1745 | return; |
| 1746 | 1746 | ||
| 1747 | pragma_err: | 1747 | pragma_err: |
| @@ -1750,7 +1750,7 @@ pragma_err: · 2 unmodified lines | |||
| 1750 | } | 1750 | } |
| 1751 | 1751 | ||
| 1752 | /* is_bof is true if first non space token at beginning of file */ | 1752 | /* is_bof is true if first non space token at beginning of file */ |
| 1753 | ST_FUNC void preprocess(TCCState *S, int is_bof) | 1753 | ST_FUNC void preprocess(TCCState* S, int is_bof) |
| 1754 | { | 1754 | { |
| 1755 | int i, c, n, saved_parse_flags; | 1755 | int i, c, n, saved_parse_flags; |
| 1756 | char buf[1024], *q; | 1756 | char buf[1024], *q; |
| @@ -1766,18 +1766,18 @@ ST_FUNC void preprocess(TCCState *S, int is_bof) · 9 unmodified lines | |||
| 1766 | 1766 | ||
| 1767 | next_nomacro(S); | 1767 | next_nomacro(S); |
| 1768 | redo: | 1768 | redo: |
| 1769 | switch(S->tok) { | 1769 | switch(S->tccpp_tok) { |
| 1770 | case TOK_DEFINE: | 1770 | case TOK_DEFINE: |
| 1771 | S->tccpp_pp_debug_tok = S->tok; | 1771 | S->tccpp_pp_debug_tok = S->tccpp_tok; |
| 1772 | next_nomacro(S); | 1772 | next_nomacro(S); |
| 1773 | S->tccpp_pp_debug_symv = S->tok; | 1773 | S->tccpp_pp_debug_symv = S->tccpp_tok; |
| 1774 | parse_define(S); | 1774 | parse_define(S); |
| 1775 | break; | 1775 | break; |
| 1776 | case TOK_UNDEF: | 1776 | case TOK_UNDEF: |
| 1777 | S->tccpp_pp_debug_tok = S->tok; | 1777 | S->tccpp_pp_debug_tok = S->tccpp_tok; |
| 1778 | next_nomacro(S); | 1778 | next_nomacro(S); |
| 1779 | S->tccpp_pp_debug_symv = S->tok; | 1779 | S->tccpp_pp_debug_symv = S->tccpp_tok; |
| 1780 | s = define_find(S, S->tok); | 1780 | s = define_find(S, S->tccpp_tok); |
| 1781 | /* undefine symbol by putting an invalid name */ | 1781 | /* undefine symbol by putting an invalid name */ |
| 1782 | if (s) | 1782 | if (s) |
| 1783 | define_undef(S, s); | 1783 | define_undef(S, s); |
| @@ -1822,8 +1822,8 @@ ST_FUNC void preprocess(TCCState *S, int is_bof) · 38 unmodified lines | |||
| 1822 | | (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE)); | 1822 | | (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE)); |
| 1823 | next(S); | 1823 | next(S); |
| 1824 | buf[0] = '\0'; | 1824 | buf[0] = '\0'; |
| 1825 | while (S->tok != TOK_LINEFEED) { | 1825 | while (S->tccpp_tok != TOK_LINEFEED) { |
| 1826 | pstrcat(buf, sizeof(buf), get_tok_str(S, S->tok, &S->tokc)); | 1826 | pstrcat(buf, sizeof(buf), get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 1827 | next(S); | 1827 | next(S); |
| 1828 | } | 1828 | } |
| 1829 | len = strlen(buf); | 1829 | len = strlen(buf); |
| @@ -1838,7 +1838,7 @@ ST_FUNC void preprocess(TCCState *S, int is_bof) · 8 unmodified lines | |||
| 1838 | 1838 | ||
| 1839 | if (S->include_stack_ptr >= S->include_stack + INCLUDE_STACK_SIZE) | 1839 | if (S->include_stack_ptr >= S->include_stack + INCLUDE_STACK_SIZE) |
| 1840 | tcc_error(S,"#include recursion too deep"); | 1840 | tcc_error(S,"#include recursion too deep"); |
| 1841 | i = S->tok == TOK_INCLUDE_NEXT ? S->tccpp_file->include_next_index + 1 : 0; | 1841 | i = S->tccpp_tok == TOK_INCLUDE_NEXT ? S->tccpp_file->include_next_index + 1 : 0; |
| 1842 | n = 2 + S->nb_include_paths + S->nb_sysinclude_paths; | 1842 | n = 2 + S->nb_include_paths + S->nb_sysinclude_paths; |
| 1843 | for (; i < n; ++i) { | 1843 | for (; i < n; ++i) { |
| 1844 | char buf1[sizeof S->tccpp_file->filename]; | 1844 | char buf1[sizeof S->tccpp_file->filename]; |
| @@ -1898,7 +1898,7 @@ ST_FUNC void preprocess(TCCState *S, int is_bof) · 53 unmodified lines | |||
| 1898 | } | 1898 | } |
| 1899 | /* add include file debug info */ | 1899 | /* add include file debug info */ |
| 1900 | tcc_debug_bincl(S); | 1900 | tcc_debug_bincl(S); |
| 1901 | S->tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL; | 1901 | S->tccpp_tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL; |
| 1902 | S->tccpp_ch = S->tccpp_file->buf_ptr[0]; | 1902 | S->tccpp_ch = S->tccpp_file->buf_ptr[0]; |
| 1903 | goto the_end; | 1903 | goto the_end; |
| 1904 | } | 1904 | } |
| @@ -1915,17 +1915,17 @@ include_done: · 10 unmodified lines | |||
| 1915 | c = 0; | 1915 | c = 0; |
| 1916 | do_ifdef: | 1916 | do_ifdef: |
| 1917 | next_nomacro(S); | 1917 | next_nomacro(S); |
| 1918 | if (S->tok < TOK_IDENT) | 1918 | if (S->tccpp_tok < TOK_IDENT) |
| 1919 | tcc_error(S,"invalid argument for '#if%sdef'", c ? "n" : ""); | 1919 | tcc_error(S,"invalid argument for '#if%sdef'", c ? "n" : ""); |
| 1920 | if (is_bof) { | 1920 | if (is_bof) { |
| 1921 | if (c) { | 1921 | if (c) { |
| 1922 | #ifdef INC_DEBUG | 1922 | #ifdef INC_DEBUG |
| 1923 | printf("#ifndef %s\n", get_tok_str(S, S->tok, NULL)); | 1923 | printf("#ifndef %s\n", get_tok_str(S, S->tccpp_tok, NULL)); |
| 1924 | #endif | 1924 | #endif |
| 1925 | S->tccpp_file->ifndef_macro = S->tok; | 1925 | S->tccpp_file->ifndef_macro = S->tccpp_tok; |
| 1926 | } | 1926 | } |
| 1927 | } | 1927 | } |
| 1928 | c = (define_find(S, S->tok) != 0) ^ c; | 1928 | c = (define_find(S, S->tccpp_tok) != 0) ^ c; |
| 1929 | do_if: | 1929 | do_if: |
| 1930 | if (S->ifdef_stack_ptr >= S->ifdef_stack + IFDEF_STACK_SIZE) | 1930 | if (S->ifdef_stack_ptr >= S->ifdef_stack + IFDEF_STACK_SIZE) |
| 1931 | tcc_error(S,"memory full (ifdef)"); | 1931 | tcc_error(S,"memory full (ifdef)"); |
| @@ -1973,31 +1973,31 @@ include_done: · 41 unmodified lines | |||
| 1973 | /* need to set to zero to avoid false matches if another | 1973 | /* need to set to zero to avoid false matches if another |
| 1974 | #ifndef at middle of file */ | 1974 | #ifndef at middle of file */ |
| 1975 | S->tccpp_file->ifndef_macro = 0; | 1975 | S->tccpp_file->ifndef_macro = 0; |
| 1976 | while (S->tok != TOK_LINEFEED) | 1976 | while (S->tccpp_tok != TOK_LINEFEED) |
| 1977 | next_nomacro(S); | 1977 | next_nomacro(S); |
| 1978 | S->tok_flags |= TOK_FLAG_ENDIF; | 1978 | S->tccpp_tok_flags |= TOK_FLAG_ENDIF; |
| 1979 | goto the_end; | 1979 | goto the_end; |
| 1980 | } | 1980 | } |
| 1981 | break; | 1981 | break; |
| 1982 | case TOK_PPNUM: | 1982 | case TOK_PPNUM: |
| 1983 | n = strtoul((char*)S->tokc.str.data, &q, 10); | 1983 | n = strtoul((char*)S->tccpp_tokc.str.data, &q, 10); |
| 1984 | goto _line_num; | 1984 | goto _line_num; |
| 1985 | case TOK_LINE: | 1985 | case TOK_LINE: |
| 1986 | next(S); | 1986 | next(S); |
| 1987 | if (S->tok != TOK_CINT) | 1987 | if (S->tccpp_tok != TOK_CINT) |
| 1988 | _line_err: | 1988 | _line_err: |
| 1989 | tcc_error(S,"wrong #line format"); | 1989 | tcc_error(S,"wrong #line format"); |
| 1990 | n = S->tokc.i; | 1990 | n = S->tccpp_tokc.i; |
| 1991 | _line_num: | 1991 | _line_num: |
| 1992 | next(S); | 1992 | next(S); |
| 1993 | if (S->tok != TOK_LINEFEED) { | 1993 | if (S->tccpp_tok != TOK_LINEFEED) { |
| 1994 | if (S->tok == TOK_STR) { | 1994 | if (S->tccpp_tok == TOK_STR) { |
| 1995 | if (S->tccpp_file->true_filename == S->tccpp_file->filename) | 1995 | if (S->tccpp_file->true_filename == S->tccpp_file->filename) |
| 1996 | S->tccpp_file->true_filename = tcc_strdup(S, S->tccpp_file->filename); | 1996 | S->tccpp_file->true_filename = tcc_strdup(S, S->tccpp_file->filename); |
| 1997 | /* prepend directory from real file */ | 1997 | /* prepend directory from real file */ |
| 1998 | pstrcpy(buf, sizeof buf, S->tccpp_file->true_filename); | 1998 | pstrcpy(buf, sizeof buf, S->tccpp_file->true_filename); |
| 1999 | *tcc_basename(buf) = 0; | 1999 | *tcc_basename(buf) = 0; |
| 2000 | pstrcat(buf, sizeof buf, (char *)S->tokc.str.data); | 2000 | pstrcat(buf, sizeof buf, (char *)S->tccpp_tokc.str.data); |
| 2001 | tcc_debug_putfile(S, buf); | 2001 | tcc_debug_putfile(S, buf); |
| 2002 | } else if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE) | 2002 | } else if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE) |
| 2003 | break; | 2003 | break; |
| @@ -2011,7 +2011,7 @@ include_done: · 7 unmodified lines | |||
| 2011 | break; | 2011 | break; |
| 2012 | case TOK_ERROR: | 2012 | case TOK_ERROR: |
| 2013 | case TOK_WARNING: | 2013 | case TOK_WARNING: |
| 2014 | c = S->tok; | 2014 | c = S->tccpp_tok; |
| 2015 | S->tccpp_ch = S->tccpp_file->buf_ptr[0]; | 2015 | S->tccpp_ch = S->tccpp_file->buf_ptr[0]; |
| 2016 | skip_spaces(S); | 2016 | skip_spaces(S); |
| 2017 | q = buf; | 2017 | q = buf; |
| @@ -2039,23 +2039,23 @@ include_done: · 21 unmodified lines | |||
| 2039 | /* ignore gas line comment in an 'S' file. */ | 2039 | /* ignore gas line comment in an 'S' file. */ |
| 2040 | if (saved_parse_flags & PARSE_FLAG_ASM_FILE) | 2040 | if (saved_parse_flags & PARSE_FLAG_ASM_FILE) |
| 2041 | goto ignore; | 2041 | goto ignore; |
| 2042 | if (S->tok == '!' && is_bof) | 2042 | if (S->tccpp_tok == '!' && is_bof) |
| 2043 | /* '!' is ignored at beginning to allow C scripts. */ | 2043 | /* '!' is ignored at beginning to allow C scripts. */ |
| 2044 | goto ignore; | 2044 | goto ignore; |
| 2045 | tcc_warning(S,"Ignoring unknown preprocessing directive #%s", get_tok_str(S, S->tok, &S->tokc)); | 2045 | tcc_warning(S,"Ignoring unknown preprocessing directive #%s", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 2046 | ignore: | 2046 | ignore: |
| 2047 | S->tccpp_file->buf_ptr = parse_line_comment(S, S->tccpp_file->buf_ptr - 1); | 2047 | S->tccpp_file->buf_ptr = parse_line_comment(S, S->tccpp_file->buf_ptr - 1); |
| 2048 | goto the_end; | 2048 | goto the_end; |
| 2049 | } | 2049 | } |
| 2050 | /* ignore other preprocess commands or #! for C scripts */ | 2050 | /* ignore other preprocess commands or #! for C scripts */ |
| 2051 | while (S->tok != TOK_LINEFEED) | 2051 | while (S->tccpp_tok != TOK_LINEFEED) |
| 2052 | next_nomacro(S); | 2052 | next_nomacro(S); |
| 2053 | the_end: | 2053 | the_end: |
| 2054 | S->tccpp_parse_flags = saved_parse_flags; | 2054 | S->tccpp_parse_flags = saved_parse_flags; |
| 2055 | } | 2055 | } |
| 2056 | 2056 | ||
| 2057 | /* evaluate escape codes in a string. */ | 2057 | /* evaluate escape codes in a string. */ |
| 2058 | static void parse_escape_string(TCCState *S, CString *outstr, const uint8_t *buf, int is_long) | 2058 | static void parse_escape_string(TCCState* S, CString *outstr, const uint8_t *buf, int is_long) |
| 2059 | { | 2059 | { |
| 2060 | int c, n, i; | 2060 | int c, n, i; |
| 2061 | const uint8_t *p; | 2061 | const uint8_t *p; |
| @@ -2232,7 +2232,7 @@ static void parse_escape_string(TCCState *S, CString *outstr, const uint8_t *buf · 170 unmodified lines | |||
| 2232 | cstr_wccat(S, outstr, '\0'); | 2232 | cstr_wccat(S, outstr, '\0'); |
| 2233 | } | 2233 | } |
| 2234 | 2234 | ||
| 2235 | static void parse_string(TCCState *S, const char *s, int len) | 2235 | static void parse_string(TCCState* S, const char *s, int len) |
| 2236 | { | 2236 | { |
| 2237 | uint8_t buf[1000], *p = buf; | 2237 | uint8_t buf[1000], *p = buf; |
| 2238 | int is_long, sep; | 2238 | int is_long, sep; |
| @@ -2246,8 +2246,8 @@ static void parse_string(TCCState *S, const char *s, int len) · 7 unmodified lines | |||
| 2246 | memcpy(p, s, len); | 2246 | memcpy(p, s, len); |
| 2247 | p[len] = 0; | 2247 | p[len] = 0; |
| 2248 | 2248 | ||
| 2249 | cstr_reset(&S->tokcstr); | 2249 | cstr_reset(&S->tccpp_tokcstr); |
| 2250 | parse_escape_string(S, &S->tokcstr, p, is_long); | 2250 | parse_escape_string(S, &S->tccpp_tokcstr, p, is_long); |
| 2251 | if (p != buf) | 2251 | if (p != buf) |
| 2252 | tcc_free(S, p); | 2252 | tcc_free(S, p); |
| 2253 | 2253 | ||
| @@ -2255,28 +2255,28 @@ static void parse_string(TCCState *S, const char *s, int len) · 1 unmodified line | |||
| 2255 | int char_size, i, n, c; | 2255 | int char_size, i, n, c; |
| 2256 | /* XXX: make it portable */ | 2256 | /* XXX: make it portable */ |
| 2257 | if (!is_long) | 2257 | if (!is_long) |
| 2258 | S->tok = TOK_CCHAR, char_size = 1; | 2258 | S->tccpp_tok = TOK_CCHAR, char_size = 1; |
| 2259 | else | 2259 | else |
| 2260 | S->tok = TOK_LCHAR, char_size = sizeof(nwchar_t); | 2260 | S->tccpp_tok = TOK_LCHAR, char_size = sizeof(nwchar_t); |
| 2261 | n = S->tokcstr.size / char_size - 1; | 2261 | n = S->tccpp_tokcstr.size / char_size - 1; |
| 2262 | if (n < 1) | 2262 | if (n < 1) |
| 2263 | tcc_error(S,"empty character constant"); | 2263 | tcc_error(S,"empty character constant"); |
| 2264 | if (n > 1) | 2264 | if (n > 1) |
| 2265 | tcc_warning_c(warn_all)(S,"multi-character character constant"); | 2265 | tcc_warning_c(warn_all)(S,"multi-character character constant"); |
| 2266 | for (c = i = 0; i < n; ++i) { | 2266 | for (c = i = 0; i < n; ++i) { |
| 2267 | if (is_long) | 2267 | if (is_long) |
| 2268 | c = ((nwchar_t *)S->tokcstr.data)[i]; | 2268 | c = ((nwchar_t *)S->tccpp_tokcstr.data)[i]; |
| 2269 | else | 2269 | else |
| 2270 | c = (c << 8) | ((char *)S->tokcstr.data)[i]; | 2270 | c = (c << 8) | ((char *)S->tccpp_tokcstr.data)[i]; |
| 2271 | } | 2271 | } |
| 2272 | S->tokc.i = c; | 2272 | S->tccpp_tokc.i = c; |
| 2273 | } else { | 2273 | } else { |
| 2274 | S->tokc.str.size = S->tokcstr.size; | 2274 | S->tccpp_tokc.str.size = S->tccpp_tokcstr.size; |
| 2275 | S->tokc.str.data = S->tokcstr.data; | 2275 | S->tccpp_tokc.str.data = S->tccpp_tokcstr.data; |
| 2276 | if (!is_long) | 2276 | if (!is_long) |
| 2277 | S->tok = TOK_STR; | 2277 | S->tccpp_tok = TOK_STR; |
| 2278 | else | 2278 | else |
| 2279 | S->tok = TOK_LSTR; | 2279 | S->tccpp_tok = TOK_LSTR; |
| 2280 | } | 2280 | } |
| 2281 | } | 2281 | } |
| 2282 | 2282 | ||
| @@ -2305,7 +2305,7 @@ static void bn_zero(unsigned int *bn) · 22 unmodified lines | |||
| 2305 | 2305 | ||
| 2306 | /* parse number in null terminated string 'p' and return it in the | 2306 | /* parse number in null terminated string 'p' and return it in the |
| 2307 | current token */ | 2307 | current token */ |
| 2308 | static void parse_number(TCCState *S, const char *p) | 2308 | static void parse_number(TCCState* S, const char *p) |
| 2309 | { | 2309 | { |
| 2310 | int b, t, shift, frac_bits, s, exp_val, ch; | 2310 | int b, t, shift, frac_bits, s, exp_val, ch; |
| 2311 | char *q; | 2311 | char *q; |
| @@ -2313,7 +2313,7 @@ static void parse_number(TCCState *S, const char *p) · 1 unmodified line | |||
| 2313 | double d; | 2313 | double d; |
| 2314 | 2314 | ||
| 2315 | /* number */ | 2315 | /* number */ |
| 2316 | q = S->token_buf; | 2316 | q = S->tccpp_token_buf; |
| 2317 | ch = *p++; | 2317 | ch = *p++; |
| 2318 | t = ch; | 2318 | t = ch; |
| 2319 | ch = *p++; | 2319 | ch = *p++; |
| @@ -2345,7 +2345,7 @@ static void parse_number(TCCState *S, const char *p) · 25 unmodified lines | |||
| 2345 | break; | 2345 | break; |
| 2346 | if (t >= b) | 2346 | if (t >= b) |
| 2347 | break; | 2347 | break; |
| 2348 | if (q >= S->token_buf + STRING_MAX_SIZE) { | 2348 | if (q >= S->tccpp_token_buf + STRING_MAX_SIZE) { |
| 2349 | num_too_long: | 2349 | num_too_long: |
| 2350 | tcc_error(S,"number too long"); | 2350 | tcc_error(S,"number too long"); |
| 2351 | } | 2351 | } |
| @@ -2367,7 +2367,7 @@ static void parse_number(TCCState *S, const char *p) · 15 unmodified lines | |||
| 2367 | else | 2367 | else |
| 2368 | shift = 1; | 2368 | shift = 1; |
| 2369 | bn_zero(bn); | 2369 | bn_zero(bn); |
| 2370 | q = S->token_buf; | 2370 | q = S->tccpp_token_buf; |
| 2371 | while (1) { | 2371 | while (1) { |
| 2372 | t = *q++; | 2372 | t = *q++; |
| 2373 | if (t == '\0') { | 2373 | if (t == '\0') { |
| @@ -2428,45 +2428,45 @@ static void parse_number(TCCState *S, const char *p) · 54 unmodified lines | |||
| 2428 | t = toup(ch); | 2428 | t = toup(ch); |
| 2429 | if (t == 'F') { | 2429 | if (t == 'F') { |
| 2430 | ch = *p++; | 2430 | ch = *p++; |
| 2431 | S->tok = TOK_CFLOAT; | 2431 | S->tccpp_tok = TOK_CFLOAT; |
| 2432 | /* float : should handle overflow */ | 2432 | /* float : should handle overflow */ |
| 2433 | S->tokc.f = (float)d; | 2433 | S->tccpp_tokc.f = (float)d; |
| 2434 | } else if (t == 'L') { | 2434 | } else if (t == 'L') { |
| 2435 | ch = *p++; | 2435 | ch = *p++; |
| 2436 | #ifdef TCC_USING_DOUBLE_FOR_LDOUBLE | 2436 | #ifdef TCC_USING_DOUBLE_FOR_LDOUBLE |
| 2437 | S->tok = TOK_CDOUBLE; | 2437 | S->tccpp_tok = TOK_CDOUBLE; |
| 2438 | S->tokc.d = d; | 2438 | S->tccpp_tokc.d = d; |
| 2439 | #else | 2439 | #else |
| 2440 | S->tok = TOK_CLDOUBLE; | 2440 | S->tccpp_tok = TOK_CLDOUBLE; |
| 2441 | /* XXX: not large enough */ | 2441 | /* XXX: not large enough */ |
| 2442 | S->tokc.ld = (long double)d; | 2442 | S->tccpp_tokc.ld = (long double)d; |
| 2443 | #endif | 2443 | #endif |
| 2444 | } else { | 2444 | } else { |
| 2445 | S->tok = TOK_CDOUBLE; | 2445 | S->tccpp_tok = TOK_CDOUBLE; |
| 2446 | S->tokc.d = d; | 2446 | S->tccpp_tokc.d = d; |
| 2447 | } | 2447 | } |
| 2448 | } else { | 2448 | } else { |
| 2449 | /* decimal floats */ | 2449 | /* decimal floats */ |
| 2450 | if (ch == '.') { | 2450 | if (ch == '.') { |
| 2451 | if (q >= S->token_buf + STRING_MAX_SIZE) | 2451 | if (q >= S->tccpp_token_buf + STRING_MAX_SIZE) |
| 2452 | goto num_too_long; | 2452 | goto num_too_long; |
| 2453 | *q++ = ch; | 2453 | *q++ = ch; |
| 2454 | ch = *p++; | 2454 | ch = *p++; |
| 2455 | float_frac_parse: | 2455 | float_frac_parse: |
| 2456 | while (ch >= '0' && ch <= '9') { | 2456 | while (ch >= '0' && ch <= '9') { |
| 2457 | if (q >= S->token_buf + STRING_MAX_SIZE) | 2457 | if (q >= S->tccpp_token_buf + STRING_MAX_SIZE) |
| 2458 | goto num_too_long; | 2458 | goto num_too_long; |
| 2459 | *q++ = ch; | 2459 | *q++ = ch; |
| 2460 | ch = *p++; | 2460 | ch = *p++; |
| 2461 | } | 2461 | } |
| 2462 | } | 2462 | } |
| 2463 | if (ch == 'e' || ch == 'E') { | 2463 | if (ch == 'e' || ch == 'E') { |
| 2464 | if (q >= S->token_buf + STRING_MAX_SIZE) | 2464 | if (q >= S->tccpp_token_buf + STRING_MAX_SIZE) |
| 2465 | goto num_too_long; | 2465 | goto num_too_long; |
| 2466 | *q++ = ch; | 2466 | *q++ = ch; |
| 2467 | ch = *p++; | 2467 | ch = *p++; |
| 2468 | if (ch == '-' || ch == '+') { | 2468 | if (ch == '-' || ch == '+') { |
| 2469 | if (q >= S->token_buf + STRING_MAX_SIZE) | 2469 | if (q >= S->tccpp_token_buf + STRING_MAX_SIZE) |
| 2470 | goto num_too_long; | 2470 | goto num_too_long; |
| 2471 | *q++ = ch; | 2471 | *q++ = ch; |
| 2472 | ch = *p++; | 2472 | ch = *p++; |
| @@ -2474,7 +2474,7 @@ static void parse_number(TCCState *S, const char *p) · 1 unmodified line | |||
| 2474 | if (ch < '0' || ch > '9') | 2474 | if (ch < '0' || ch > '9') |
| 2475 | expect(S, "exponent digits"); | 2475 | expect(S, "exponent digits"); |
| 2476 | while (ch >= '0' && ch <= '9') { | 2476 | while (ch >= '0' && ch <= '9') { |
| 2477 | if (q >= S->token_buf + STRING_MAX_SIZE) | 2477 | if (q >= S->tccpp_token_buf + STRING_MAX_SIZE) |
| 2478 | goto num_too_long; | 2478 | goto num_too_long; |
| 2479 | *q++ = ch; | 2479 | *q++ = ch; |
| 2480 | ch = *p++; | 2480 | ch = *p++; |
| @@ -2485,20 +2485,20 @@ static void parse_number(TCCState *S, const char *p) · 4 unmodified lines | |||
| 2485 | errno = 0; | 2485 | errno = 0; |
| 2486 | if (t == 'F') { | 2486 | if (t == 'F') { |
| 2487 | ch = *p++; | 2487 | ch = *p++; |
| 2488 | S->tok = TOK_CFLOAT; | 2488 | S->tccpp_tok = TOK_CFLOAT; |
| 2489 | S->tokc.f = strtof(S->token_buf, NULL); | 2489 | S->tccpp_tokc.f = strtof(S->tccpp_token_buf, NULL); |
| 2490 | } else if (t == 'L') { | 2490 | } else if (t == 'L') { |
| 2491 | ch = *p++; | 2491 | ch = *p++; |
| 2492 | #ifdef TCC_USING_DOUBLE_FOR_LDOUBLE | 2492 | #ifdef TCC_USING_DOUBLE_FOR_LDOUBLE |
| 2493 | S->tok = TOK_CDOUBLE; | 2493 | S->tccpp_tok = TOK_CDOUBLE; |
| 2494 | S->tokc.d = strtod(S->token_buf, NULL); | 2494 | S->tccpp_tokc.d = strtod(S->tccpp_token_buf, NULL); |
| 2495 | #else | 2495 | #else |
| 2496 | S->tok = TOK_CLDOUBLE; | 2496 | S->tccpp_tok = TOK_CLDOUBLE; |
| 2497 | S->tokc.ld = strtold(S->token_buf, NULL); | 2497 | S->tccpp_tokc.ld = strtold(S->tccpp_token_buf, NULL); |
| 2498 | #endif | 2498 | #endif |
| 2499 | } else { | 2499 | } else { |
| 2500 | S->tok = TOK_CDOUBLE; | 2500 | S->tccpp_tok = TOK_CDOUBLE; |
| 2501 | S->tokc.d = strtod(S->token_buf, NULL); | 2501 | S->tccpp_tokc.d = strtod(S->tccpp_token_buf, NULL); |
| 2502 | } | 2502 | } |
| 2503 | } | 2503 | } |
| 2504 | } else { | 2504 | } else { |
| @@ -2508,7 +2508,7 @@ static void parse_number(TCCState *S, const char *p) · 3 unmodified lines | |||
| 2508 | 2508 | ||
| 2509 | /* integer number */ | 2509 | /* integer number */ |
| 2510 | *q = '\0'; | 2510 | *q = '\0'; |
| 2511 | q = S->token_buf; | 2511 | q = S->tccpp_token_buf; |
| 2512 | if (b == 10 && *q == '0') { | 2512 | if (b == 10 && *q == '0') { |
| 2513 | b = 8; | 2513 | b = 8; |
| 2514 | q++; | 2514 | q++; |
| @@ -2579,15 +2579,15 @@ static void parse_number(TCCState *S, const char *p) · 64 unmodified lines | |||
| 2579 | if (ov) | 2579 | if (ov) |
| 2580 | tcc_warning(S, "integer constant overflow"); | 2580 | tcc_warning(S, "integer constant overflow"); |
| 2581 | 2581 | ||
| 2582 | S->tok = TOK_CINT; | 2582 | S->tccpp_tok = TOK_CINT; |
| 2583 | if (lcount) { | 2583 | if (lcount) { |
| 2584 | S->tok = TOK_CLONG; | 2584 | S->tccpp_tok = TOK_CLONG; |
| 2585 | if (lcount == 2) | 2585 | if (lcount == 2) |
| 2586 | S->tok = TOK_CLLONG; | 2586 | S->tccpp_tok = TOK_CLLONG; |
| 2587 | } | 2587 | } |
| 2588 | if (ucount) | 2588 | if (ucount) |
| 2589 | ++S->tok; /* TOK_CU... */ | 2589 | ++S->tccpp_tok; /* TOK_CU... */ |
| 2590 | S->tokc.i = n; | 2590 | S->tccpp_tokc.i = n; |
| 2591 | } | 2591 | } |
| 2592 | if (ch) | 2592 | if (ch) |
| 2593 | tcc_error(S,"invalid number"); | 2593 | tcc_error(S,"invalid number"); |
| @@ -2599,14 +2599,14 @@ static void parse_number(TCCState *S, const char *p) · 5 unmodified lines | |||
| 2599 | PEEKC(c, p); \ | 2599 | PEEKC(c, p); \ |
| 2600 | if (c == c2) { \ | 2600 | if (c == c2) { \ |
| 2601 | p++; \ | 2601 | p++; \ |
| 2602 | S->tok = tok2; \ | 2602 | S->tccpp_tok = tok2; \ |
| 2603 | } else { \ | 2603 | } else { \ |
| 2604 | S->tok = tok1; \ | 2604 | S->tccpp_tok = tok1; \ |
| 2605 | } \ | 2605 | } \ |
| 2606 | break; | 2606 | break; |
| 2607 | 2607 | ||
| 2608 | /* return next token without macro substitution */ | 2608 | /* return next token without macro substitution */ |
| 2609 | static inline void next_nomacro1(TCCState *S) | 2609 | static inline void next_nomacro1(TCCState* S) |
| 2610 | { | 2610 | { |
| 2611 | int t, c, is_long, len; | 2611 | int t, c, is_long, len; |
| 2612 | TokenSym *ts; | 2612 | TokenSym *ts; |
| @@ -2619,7 +2619,7 @@ static inline void next_nomacro1(TCCState *S) · 6 unmodified lines | |||
| 2619 | switch(c) { | 2619 | switch(c) { |
| 2620 | case ' ': | 2620 | case ' ': |
| 2621 | case '\t': | 2621 | case '\t': |
| 2622 | S->tok = c; | 2622 | S->tccpp_tok = c; |
| 2623 | p++; | 2623 | p++; |
| 2624 | maybe_space: | 2624 | maybe_space: |
| 2625 | if (S->tccpp_parse_flags & PARSE_FLAG_SPACES) | 2625 | if (S->tccpp_parse_flags & PARSE_FLAG_SPACES) |
| @@ -2642,30 +2642,30 @@ static inline void next_nomacro1(TCCState *S) · 16 unmodified lines | |||
| 2642 | goto redo_no_start; | 2642 | goto redo_no_start; |
| 2643 | { | 2643 | { |
| 2644 | if ((S->tccpp_parse_flags & PARSE_FLAG_LINEFEED) | 2644 | if ((S->tccpp_parse_flags & PARSE_FLAG_LINEFEED) |
| 2645 | && !(S->tok_flags & TOK_FLAG_EOF)) { | 2645 | && !(S->tccpp_tok_flags & TOK_FLAG_EOF)) { |
| 2646 | S->tok_flags |= TOK_FLAG_EOF; | 2646 | S->tccpp_tok_flags |= TOK_FLAG_EOF; |
| 2647 | S->tok = TOK_LINEFEED; | 2647 | S->tccpp_tok = TOK_LINEFEED; |
| 2648 | goto keep_tok_flags; | 2648 | goto keep_tok_flags; |
| 2649 | } else if (!(S->tccpp_parse_flags & PARSE_FLAG_PREPROCESS)) { | 2649 | } else if (!(S->tccpp_parse_flags & PARSE_FLAG_PREPROCESS)) { |
| 2650 | S->tok = TOK_EOF; | 2650 | S->tccpp_tok = TOK_EOF; |
| 2651 | } else if (S->ifdef_stack_ptr != S->tccpp_file->ifdef_stack_ptr) { | 2651 | } else if (S->ifdef_stack_ptr != S->tccpp_file->ifdef_stack_ptr) { |
| 2652 | tcc_error(S,"missing #endif"); | 2652 | tcc_error(S,"missing #endif"); |
| 2653 | } else if (S->include_stack_ptr == S->include_stack) { | 2653 | } else if (S->include_stack_ptr == S->include_stack) { |
| 2654 | /* no include left : end of file. */ | 2654 | /* no include left : end of file. */ |
| 2655 | S->tok = TOK_EOF; | 2655 | S->tccpp_tok = TOK_EOF; |
| 2656 | } else { | 2656 | } else { |
| 2657 | S->tok_flags &= ~TOK_FLAG_EOF; | 2657 | S->tccpp_tok_flags &= ~TOK_FLAG_EOF; |
| 2658 | /* pop include file */ | 2658 | /* pop include file */ |
| 2659 | 2659 | ||
| 2660 | /* test if previous '#endif' was after a #ifdef at | 2660 | /* test if previous '#endif' was after a #ifdef at |
| 2661 | start of file */ | 2661 | start of file */ |
| 2662 | if (S->tok_flags & TOK_FLAG_ENDIF) { | 2662 | if (S->tccpp_tok_flags & TOK_FLAG_ENDIF) { |
| 2663 | #ifdef INC_DEBUG | 2663 | #ifdef INC_DEBUG |
| 2664 | printf("#endif %s\n", get_tok_str(S, S->tccpp_file->ifndef_macro_saved, NULL)); | 2664 | printf("#endif %s\n", get_tok_str(S, S->tccpp_file->ifndef_macro_saved, NULL)); |
| 2665 | #endif | 2665 | #endif |
| 2666 | search_cached_include(S, S->tccpp_file->filename, 1) | 2666 | search_cached_include(S, S->tccpp_file->filename, 1) |
| 2667 | ->ifndef_macro = S->tccpp_file->ifndef_macro_saved; | 2667 | ->ifndef_macro = S->tccpp_file->ifndef_macro_saved; |
| 2668 | S->tok_flags &= ~TOK_FLAG_ENDIF; | 2668 | S->tccpp_tok_flags &= ~TOK_FLAG_ENDIF; |
| 2669 | } | 2669 | } |
| 2670 | 2670 | ||
| 2671 | /* add end of include file debug info */ | 2671 | /* add end of include file debug info */ |
| @@ -2675,7 +2675,7 @@ static inline void next_nomacro1(TCCState *S) · 3 unmodified lines | |||
| 2675 | S->include_stack_ptr--; | 2675 | S->include_stack_ptr--; |
| 2676 | p = S->tccpp_file->buf_ptr; | 2676 | p = S->tccpp_file->buf_ptr; |
| 2677 | if (p == S->tccpp_file->buffer) | 2677 | if (p == S->tccpp_file->buffer) |
| 2678 | S->tok_flags = TOK_FLAG_BOF|TOK_FLAG_BOL; | 2678 | S->tccpp_tok_flags = TOK_FLAG_BOF|TOK_FLAG_BOL; |
| 2679 | goto redo_no_start; | 2679 | goto redo_no_start; |
| 2680 | } | 2680 | } |
| 2681 | } | 2681 | } |
| @@ -2683,27 +2683,27 @@ static inline void next_nomacro1(TCCState *S) · 1 unmodified line | |||
| 2683 | 2683 | ||
| 2684 | case '\n': | 2684 | case '\n': |
| 2685 | S->tccpp_file->line_num++; | 2685 | S->tccpp_file->line_num++; |
| 2686 | S->tok_flags |= TOK_FLAG_BOL; | 2686 | S->tccpp_tok_flags |= TOK_FLAG_BOL; |
| 2687 | p++; | 2687 | p++; |
| 2688 | maybe_newline: | 2688 | maybe_newline: |
| 2689 | if (0 == (S->tccpp_parse_flags & PARSE_FLAG_LINEFEED)) | 2689 | if (0 == (S->tccpp_parse_flags & PARSE_FLAG_LINEFEED)) |
| 2690 | goto redo_no_start; | 2690 | goto redo_no_start; |
| 2691 | S->tok = TOK_LINEFEED; | 2691 | S->tccpp_tok = TOK_LINEFEED; |
| 2692 | goto keep_tok_flags; | 2692 | goto keep_tok_flags; |
| 2693 | 2693 | ||
| 2694 | case '#': | 2694 | case '#': |
| 2695 | /* XXX: simplify */ | 2695 | /* XXX: simplify */ |
| 2696 | PEEKC(c, p); | 2696 | PEEKC(c, p); |
| 2697 | if ((S->tok_flags & TOK_FLAG_BOL) && | 2697 | if ((S->tccpp_tok_flags & TOK_FLAG_BOL) && |
| 2698 | (S->tccpp_parse_flags & PARSE_FLAG_PREPROCESS)) { | 2698 | (S->tccpp_parse_flags & PARSE_FLAG_PREPROCESS)) { |
| 2699 | S->tccpp_file->buf_ptr = p; | 2699 | S->tccpp_file->buf_ptr = p; |
| 2700 | preprocess(S, S->tok_flags & TOK_FLAG_BOF); | 2700 | preprocess(S, S->tccpp_tok_flags & TOK_FLAG_BOF); |
| 2701 | p = S->tccpp_file->buf_ptr; | 2701 | p = S->tccpp_file->buf_ptr; |
| 2702 | goto maybe_newline; | 2702 | goto maybe_newline; |
| 2703 | } else { | 2703 | } else { |
| 2704 | if (c == '#') { | 2704 | if (c == '#') { |
| 2705 | p++; | 2705 | p++; |
| 2706 | S->tok = TOK_TWOSHARPS; | 2706 | S->tccpp_tok = TOK_TWOSHARPS; |
| 2707 | } else { | 2707 | } else { |
| 2708 | #if !defined(TCC_TARGET_ARM) | 2708 | #if !defined(TCC_TARGET_ARM) |
| 2709 | if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE) { | 2709 | if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE) { |
| @@ -2712,7 +2712,7 @@ maybe_newline: · 2 unmodified lines | |||
| 2712 | } else | 2712 | } else |
| 2713 | #endif | 2713 | #endif |
| 2714 | { | 2714 | { |
| 2715 | S->tok = '#'; | 2715 | S->tccpp_tok = '#'; |
| 2716 | } | 2716 | } |
| 2717 | } | 2717 | } |
| 2718 | } | 2718 | } |
| @@ -2765,19 +2765,19 @@ maybe_newline: · 46 unmodified lines | |||
| 2765 | token_found: ; | 2765 | token_found: ; |
| 2766 | } else { | 2766 | } else { |
| 2767 | /* slower case */ | 2767 | /* slower case */ |
| 2768 | cstr_reset(&S->tokcstr); | 2768 | cstr_reset(&S->tccpp_tokcstr); |
| 2769 | cstr_cat(S, &S->tokcstr, (char *) p1, len); | 2769 | cstr_cat(S, &S->tccpp_tokcstr, (char *) p1, len); |
| 2770 | p--; | 2770 | p--; |
| 2771 | PEEKC(c, p); | 2771 | PEEKC(c, p); |
| 2772 | parse_ident_slow: | 2772 | parse_ident_slow: |
| 2773 | while (S->tccpp_isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) | 2773 | while (S->tccpp_isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) |
| 2774 | { | 2774 | { |
| 2775 | cstr_ccat(S, &S->tokcstr, c); | 2775 | cstr_ccat(S, &S->tccpp_tokcstr, c); |
| 2776 | PEEKC(c, p); | 2776 | PEEKC(c, p); |
| 2777 | } | 2777 | } |
| 2778 | ts = tok_alloc(S, S->tokcstr.data, S->tokcstr.size); | 2778 | ts = tok_alloc(S, S->tccpp_tokcstr.data, S->tccpp_tokcstr.size); |
| 2779 | } | 2779 | } |
| 2780 | S->tok = ts->tok; | 2780 | S->tccpp_tok = ts->tok; |
| 2781 | break; | 2781 | break; |
| 2782 | case 'L': | 2782 | case 'L': |
| 2783 | t = p[1]; | 2783 | t = p[1]; |
| @@ -2790,8 +2790,8 @@ maybe_newline: · 6 unmodified lines | |||
| 2790 | is_long = 1; | 2790 | is_long = 1; |
| 2791 | goto str_const; | 2791 | goto str_const; |
| 2792 | } else { | 2792 | } else { |
| 2793 | cstr_reset(&S->tokcstr); | 2793 | cstr_reset(&S->tccpp_tokcstr); |
| 2794 | cstr_ccat(S, &S->tokcstr, 'L'); | 2794 | cstr_ccat(S, &S->tccpp_tokcstr, 'L'); |
| 2795 | goto parse_ident_slow; | 2795 | goto parse_ident_slow; |
| 2796 | } | 2796 | } |
| 2797 | } | 2797 | } |
| @@ -2805,27 +2805,27 @@ maybe_newline: · 7 unmodified lines | |||
| 2805 | /* after the first digit, accept digits, alpha, '.' or sign if | 2805 | /* after the first digit, accept digits, alpha, '.' or sign if |
| 2806 | prefixed by 'eEpP' */ | 2806 | prefixed by 'eEpP' */ |
| 2807 | parse_num: | 2807 | parse_num: |
| 2808 | cstr_reset(&S->tokcstr); | 2808 | cstr_reset(&S->tccpp_tokcstr); |
| 2809 | for(;;) { | 2809 | for(;;) { |
| 2810 | cstr_ccat(S, &S->tokcstr, t); | 2810 | cstr_ccat(S, &S->tccpp_tokcstr, t); |
| 2811 | if (!((S->tccpp_isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) | 2811 | if (!((S->tccpp_isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) |
| 2812 | || c == '.' | 2812 | || c == '.' |
| 2813 | || ((c == '+' || c == '-') | 2813 | || ((c == '+' || c == '-') |
| 2814 | && (((t == 'e' || t == 'E') | 2814 | && (((t == 'e' || t == 'E') |
| 2815 | && !(S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE | 2815 | && !(S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE |
| 2816 | /* 0xe+1 is 3 tokens in asm */ | 2816 | /* 0xe+1 is 3 tokens in asm */ |
| 2817 | && ((char*)S->tokcstr.data)[0] == '0' | 2817 | && ((char*)S->tccpp_tokcstr.data)[0] == '0' |
| 2818 | && toup(((char*)S->tokcstr.data)[1]) == 'X')) | 2818 | && toup(((char*)S->tccpp_tokcstr.data)[1]) == 'X')) |
| 2819 | || t == 'p' || t == 'P')))) | 2819 | || t == 'p' || t == 'P')))) |
| 2820 | break; | 2820 | break; |
| 2821 | t = c; | 2821 | t = c; |
| 2822 | PEEKC(c, p); | 2822 | PEEKC(c, p); |
| 2823 | } | 2823 | } |
| 2824 | /* We add a trailing '\0' to ease parsing */ | 2824 | /* We add a trailing '\0' to ease parsing */ |
| 2825 | cstr_ccat(S, &S->tokcstr, '\0'); | 2825 | cstr_ccat(S, &S->tccpp_tokcstr, '\0'); |
| 2826 | S->tokc.str.size = S->tokcstr.size; | 2826 | S->tccpp_tokc.str.size = S->tccpp_tokcstr.size; |
| 2827 | S->tokc.str.data = S->tokcstr.data; | 2827 | S->tccpp_tokc.str.data = S->tccpp_tokcstr.data; |
| 2828 | S->tok = TOK_PPNUM; | 2828 | S->tccpp_tok = TOK_PPNUM; |
| 2829 | break; | 2829 | break; |
| 2830 | 2830 | ||
| 2831 | case '.': | 2831 | case '.': |
| @@ -2842,63 +2842,63 @@ maybe_newline: · 10 unmodified lines | |||
| 2842 | PEEKC(c, p); | 2842 | PEEKC(c, p); |
| 2843 | if (c == '.') { | 2843 | if (c == '.') { |
| 2844 | p++; | 2844 | p++; |
| 2845 | S->tok = TOK_DOTS; | 2845 | S->tccpp_tok = TOK_DOTS; |
| 2846 | } else { | 2846 | } else { |
| 2847 | *--p = '.'; /* may underflow into file->unget[] */ | 2847 | *--p = '.'; /* may underflow into file->unget[] */ |
| 2848 | S->tok = '.'; | 2848 | S->tccpp_tok = '.'; |
| 2849 | } | 2849 | } |
| 2850 | } else { | 2850 | } else { |
| 2851 | S->tok = '.'; | 2851 | S->tccpp_tok = '.'; |
| 2852 | } | 2852 | } |
| 2853 | break; | 2853 | break; |
| 2854 | case '\'': | 2854 | case '\'': |
| 2855 | case '\"': | 2855 | case '\"': |
| 2856 | is_long = 0; | 2856 | is_long = 0; |
| 2857 | str_const: | 2857 | str_const: |
| 2858 | cstr_reset(&S->tokcstr); | 2858 | cstr_reset(&S->tccpp_tokcstr); |
| 2859 | if (is_long) | 2859 | if (is_long) |
| 2860 | cstr_ccat(S, &S->tokcstr, 'L'); | 2860 | cstr_ccat(S, &S->tccpp_tokcstr, 'L'); |
| 2861 | cstr_ccat(S, &S->tokcstr, c); | 2861 | cstr_ccat(S, &S->tccpp_tokcstr, c); |
| 2862 | p = parse_pp_string(S, p, c, &S->tokcstr); | 2862 | p = parse_pp_string(S, p, c, &S->tccpp_tokcstr); |
| 2863 | cstr_ccat(S, &S->tokcstr, c); | 2863 | cstr_ccat(S, &S->tccpp_tokcstr, c); |
| 2864 | cstr_ccat(S, &S->tokcstr, '\0'); | 2864 | cstr_ccat(S, &S->tccpp_tokcstr, '\0'); |
| 2865 | S->tokc.str.size = S->tokcstr.size; | 2865 | S->tccpp_tokc.str.size = S->tccpp_tokcstr.size; |
| 2866 | S->tokc.str.data = S->tokcstr.data; | 2866 | S->tccpp_tokc.str.data = S->tccpp_tokcstr.data; |
| 2867 | S->tok = TOK_PPSTR; | 2867 | S->tccpp_tok = TOK_PPSTR; |
| 2868 | break; | 2868 | break; |
| 2869 | 2869 | ||
| 2870 | case '<': | 2870 | case '<': |
| 2871 | PEEKC(c, p); | 2871 | PEEKC(c, p); |
| 2872 | if (c == '=') { | 2872 | if (c == '=') { |
| 2873 | p++; | 2873 | p++; |
| 2874 | S->tok = TOK_LE; | 2874 | S->tccpp_tok = TOK_LE; |
| 2875 | } else if (c == '<') { | 2875 | } else if (c == '<') { |
| 2876 | PEEKC(c, p); | 2876 | PEEKC(c, p); |
| 2877 | if (c == '=') { | 2877 | if (c == '=') { |
| 2878 | p++; | 2878 | p++; |
| 2879 | S->tok = TOK_A_SHL; | 2879 | S->tccpp_tok = TOK_A_SHL; |
| 2880 | } else { | 2880 | } else { |
| 2881 | S->tok = TOK_SHL; | 2881 | S->tccpp_tok = TOK_SHL; |
| 2882 | } | 2882 | } |
| 2883 | } else { | 2883 | } else { |
| 2884 | S->tok = TOK_LT; | 2884 | S->tccpp_tok = TOK_LT; |
| 2885 | } | 2885 | } |
| 2886 | break; | 2886 | break; |
| 2887 | case '>': | 2887 | case '>': |
| 2888 | PEEKC(c, p); | 2888 | PEEKC(c, p); |
| 2889 | if (c == '=') { | 2889 | if (c == '=') { |
| 2890 | p++; | 2890 | p++; |
| 2891 | S->tok = TOK_GE; | 2891 | S->tccpp_tok = TOK_GE; |
| 2892 | } else if (c == '>') { | 2892 | } else if (c == '>') { |
| 2893 | PEEKC(c, p); | 2893 | PEEKC(c, p); |
| 2894 | if (c == '=') { | 2894 | if (c == '=') { |
| 2895 | p++; | 2895 | p++; |
| 2896 | S->tok = TOK_A_SAR; | 2896 | S->tccpp_tok = TOK_A_SAR; |
| 2897 | } else { | 2897 | } else { |
| 2898 | S->tok = TOK_SAR; | 2898 | S->tccpp_tok = TOK_SAR; |
| 2899 | } | 2899 | } |
| 2900 | } else { | 2900 | } else { |
| 2901 | S->tok = TOK_GT; | 2901 | S->tccpp_tok = TOK_GT; |
| 2902 | } | 2902 | } |
| 2903 | break; | 2903 | break; |
| 2904 | 2904 | ||
| @@ -2906,12 +2906,12 @@ maybe_newline: · 1 unmodified line | |||
| 2906 | PEEKC(c, p); | 2906 | PEEKC(c, p); |
| 2907 | if (c == '&') { | 2907 | if (c == '&') { |
| 2908 | p++; | 2908 | p++; |
| 2909 | S->tok = TOK_LAND; | 2909 | S->tccpp_tok = TOK_LAND; |
| 2910 | } else if (c == '=') { | 2910 | } else if (c == '=') { |
| 2911 | p++; | 2911 | p++; |
| 2912 | S->tok = TOK_A_AND; | 2912 | S->tccpp_tok = TOK_A_AND; |
| 2913 | } else { | 2913 | } else { |
| 2914 | S->tok = '&'; | 2914 | S->tccpp_tok = '&'; |
| 2915 | } | 2915 | } |
| 2916 | break; | 2916 | break; |
| 2917 | 2917 | ||
| @@ -2919,12 +2919,12 @@ maybe_newline: · 1 unmodified line | |||
| 2919 | PEEKC(c, p); | 2919 | PEEKC(c, p); |
| 2920 | if (c == '|') { | 2920 | if (c == '|') { |
| 2921 | p++; | 2921 | p++; |
| 2922 | S->tok = TOK_LOR; | 2922 | S->tccpp_tok = TOK_LOR; |
| 2923 | } else if (c == '=') { | 2923 | } else if (c == '=') { |
| 2924 | p++; | 2924 | p++; |
| 2925 | S->tok = TOK_A_OR; | 2925 | S->tccpp_tok = TOK_A_OR; |
| 2926 | } else { | 2926 | } else { |
| 2927 | S->tok = '|'; | 2927 | S->tccpp_tok = '|'; |
| 2928 | } | 2928 | } |
| 2929 | break; | 2929 | break; |
| 2930 | 2930 | ||
| @@ -2932,12 +2932,12 @@ maybe_newline: · 1 unmodified line | |||
| 2932 | PEEKC(c, p); | 2932 | PEEKC(c, p); |
| 2933 | if (c == '+') { | 2933 | if (c == '+') { |
| 2934 | p++; | 2934 | p++; |
| 2935 | S->tok = TOK_INC; | 2935 | S->tccpp_tok = TOK_INC; |
| 2936 | } else if (c == '=') { | 2936 | } else if (c == '=') { |
| 2937 | p++; | 2937 | p++; |
| 2938 | S->tok = TOK_A_ADD; | 2938 | S->tccpp_tok = TOK_A_ADD; |
| 2939 | } else { | 2939 | } else { |
| 2940 | S->tok = '+'; | 2940 | S->tccpp_tok = '+'; |
| 2941 | } | 2941 | } |
| 2942 | break; | 2942 | break; |
| 2943 | 2943 | ||
| @@ -2945,15 +2945,15 @@ maybe_newline: · 1 unmodified line | |||
| 2945 | PEEKC(c, p); | 2945 | PEEKC(c, p); |
| 2946 | if (c == '-') { | 2946 | if (c == '-') { |
| 2947 | p++; | 2947 | p++; |
| 2948 | S->tok = TOK_DEC; | 2948 | S->tccpp_tok = TOK_DEC; |
| 2949 | } else if (c == '=') { | 2949 | } else if (c == '=') { |
| 2950 | p++; | 2950 | p++; |
| 2951 | S->tok = TOK_A_SUB; | 2951 | S->tccpp_tok = TOK_A_SUB; |
| 2952 | } else if (c == '>') { | 2952 | } else if (c == '>') { |
| 2953 | p++; | 2953 | p++; |
| 2954 | S->tok = TOK_ARROW; | 2954 | S->tccpp_tok = TOK_ARROW; |
| 2955 | } else { | 2955 | } else { |
| 2956 | S->tok = '-'; | 2956 | S->tccpp_tok = '-'; |
| 2957 | } | 2957 | } |
| 2958 | break; | 2958 | break; |
| 2959 | 2959 | ||
| @@ -2969,17 +2969,17 @@ maybe_newline: · 9 unmodified lines | |||
| 2969 | if (c == '*') { | 2969 | if (c == '*') { |
| 2970 | p = parse_comment(S, p); | 2970 | p = parse_comment(S, p); |
| 2971 | /* comments replaced by a blank */ | 2971 | /* comments replaced by a blank */ |
| 2972 | S->tok = ' '; | 2972 | S->tccpp_tok = ' '; |
| 2973 | goto maybe_space; | 2973 | goto maybe_space; |
| 2974 | } else if (c == '/') { | 2974 | } else if (c == '/') { |
| 2975 | p = parse_line_comment(S, p); | 2975 | p = parse_line_comment(S, p); |
| 2976 | S->tok = ' '; | 2976 | S->tccpp_tok = ' '; |
| 2977 | goto maybe_space; | 2977 | goto maybe_space; |
| 2978 | } else if (c == '=') { | 2978 | } else if (c == '=') { |
| 2979 | p++; | 2979 | p++; |
| 2980 | S->tok = TOK_A_DIV; | 2980 | S->tccpp_tok = TOK_A_DIV; |
| 2981 | } else { | 2981 | } else { |
| 2982 | S->tok = '/'; | 2982 | S->tccpp_tok = '/'; |
| 2983 | } | 2983 | } |
| 2984 | break; | 2984 | break; |
| 2985 | 2985 | ||
| @@ -2997,7 +2997,7 @@ maybe_newline: · 11 unmodified lines | |||
| 2997 | case '~': | 2997 | case '~': |
| 2998 | case '@': /* only used in assembler */ | 2998 | case '@': /* only used in assembler */ |
| 2999 | parse_simple: | 2999 | parse_simple: |
| 3000 | S->tok = c; | 3000 | S->tccpp_tok = c; |
| 3001 | p++; | 3001 | p++; |
| 3002 | break; | 3002 | break; |
| 3003 | default: | 3003 | default: |
| @@ -3008,15 +3008,15 @@ maybe_newline: · 4 unmodified lines | |||
| 3008 | tcc_error(S,"unrecognized character \\x%02x", c); | 3008 | tcc_error(S,"unrecognized character \\x%02x", c); |
| 3009 | break; | 3009 | break; |
| 3010 | } | 3010 | } |
| 3011 | S->tok_flags = 0; | 3011 | S->tccpp_tok_flags = 0; |
| 3012 | keep_tok_flags: | 3012 | keep_tok_flags: |
| 3013 | S->tccpp_file->buf_ptr = p; | 3013 | S->tccpp_file->buf_ptr = p; |
| 3014 | #if defined(PARSE_DEBUG) | 3014 | #if defined(PARSE_DEBUG) |
| 3015 | printf("token = %d %s\n", S->tok, get_tok_str(S, S->tok, &S->tokc)); | 3015 | printf("token = %d %s\n", S->tccpp_tok, get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc)); |
| 3016 | #endif | 3016 | #endif |
| 3017 | } | 3017 | } |
| 3018 | 3018 | ||
| 3019 | static void macro_subst(TCCState *S, | 3019 | static void macro_subst(TCCState* S, |
| 3020 | TokenString *tok_str, | 3020 | TokenString *tok_str, |
| 3021 | Sym **nested_list, | 3021 | Sym **nested_list, |
| 3022 | const int *macro_str | 3022 | const int *macro_str |
| @@ -3024,7 +3024,7 @@ static void macro_subst(TCCState *S, · 1 unmodified line | |||
| 3024 | 3024 | ||
| 3025 | /* substitute arguments in replacement lists in macro_str by the values in | 3025 | /* substitute arguments in replacement lists in macro_str by the values in |
| 3026 | args (field d) and return allocated string */ | 3026 | args (field d) and return allocated string */ |
| 3027 | static int *macro_arg_subst(TCCState *S, Sym **nested_list, const int *macro_str, Sym *args) | 3027 | static int *macro_arg_subst(TCCState* S, Sym **nested_list, const int *macro_str, Sym *args) |
| 3028 | { | 3028 | { |
| 3029 | int t, t0, t1, spc; | 3029 | int t, t0, t1, spc; |
| 3030 | const int *st; | 3030 | const int *st; |
| @@ -3142,7 +3142,7 @@ static char const ab_month_name[12][4] = · 111 unmodified lines | |||
| 3142 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" | 3142 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" |
| 3143 | }; | 3143 | }; |
| 3144 | 3144 | ||
| 3145 | static int paste_tokens(TCCState *S, int t1, CValue *v1, int t2, CValue *v2) | 3145 | static int paste_tokens(TCCState* S, int t1, CValue *v1, int t2, CValue *v2) |
| 3146 | { | 3146 | { |
| 3147 | CString cstr; | 3147 | CString cstr; |
| 3148 | int n, ret = 1; | 3148 | int n, ret = 1; |
| @@ -3157,12 +3157,12 @@ static int paste_tokens(TCCState *S, int t1, CValue *v1, int t2, CValue *v2) · 8 unmodified lines | |||
| 3157 | 3157 | ||
| 3158 | tcc_open_bf(S, ":paste:", cstr.size); | 3158 | tcc_open_bf(S, ":paste:", cstr.size); |
| 3159 | memcpy(S->tccpp_file->buffer, cstr.data, cstr.size); | 3159 | memcpy(S->tccpp_file->buffer, cstr.data, cstr.size); |
| 3160 | S->tok_flags = 0; | 3160 | S->tccpp_tok_flags = 0; |
| 3161 | for (;;) { | 3161 | for (;;) { |
| 3162 | next_nomacro1(S); | 3162 | next_nomacro1(S); |
| 3163 | if (0 == *S->tccpp_file->buf_ptr) | 3163 | if (0 == *S->tccpp_file->buf_ptr) |
| 3164 | break; | 3164 | break; |
| 3165 | if (is_space(S->tok)) | 3165 | if (is_space(S->tccpp_tok)) |
| 3166 | continue; | 3166 | continue; |
| 3167 | tcc_warning(S, "pasting \"%.*s\" and \"%s\" does not give a valid" | 3167 | tcc_warning(S, "pasting \"%.*s\" and \"%s\" does not give a valid" |
| 3168 | " preprocessing token", n, (char *)cstr.data, (char*)cstr.data + n); | 3168 | " preprocessing token", n, (char *)cstr.data, (char*)cstr.data + n); |
| @@ -3177,7 +3177,7 @@ static int paste_tokens(TCCState *S, int t1, CValue *v1, int t2, CValue *v2) · 8 unmodified lines | |||
| 3177 | 3177 | ||
| 3178 | /* handle the '##' operator. Return NULL if no '##' seen. Otherwise | 3178 | /* handle the '##' operator. Return NULL if no '##' seen. Otherwise |
| 3179 | return the resulting string (which must be freed). */ | 3179 | return the resulting string (which must be freed). */ |
| 3180 | static inline int *macro_twosharps(TCCState *S, const int *ptr0) | 3180 | static inline int *macro_twosharps(TCCState* S, const int *ptr0) |
| 3181 | { | 3181 | { |
| 3182 | int t; | 3182 | int t; |
| 3183 | CValue cval; | 3183 | CValue cval; |
| @@ -3215,7 +3215,7 @@ static inline int *macro_twosharps(TCCState *S, const int *ptr0) · 31 unmodified lines | |||
| 3215 | TOK_GET(&t1, &ptr, &cv1); | 3215 | TOK_GET(&t1, &ptr, &cv1); |
| 3216 | if (t != TOK_PLCHLDR || t1 != TOK_PLCHLDR) { | 3216 | if (t != TOK_PLCHLDR || t1 != TOK_PLCHLDR) { |
| 3217 | if (paste_tokens(S, t, &cval, t1, &cv1)) { | 3217 | if (paste_tokens(S, t, &cval, t1, &cv1)) { |
| 3218 | t = S->tok, cval = S->tokc; | 3218 | t = S->tccpp_tok, cval = S->tccpp_tokc; |
| 3219 | } else { | 3219 | } else { |
| 3220 | tok_str_add2(S, ¯o_str1, t, &cval); | 3220 | tok_str_add2(S, ¯o_str1, t, &cval); |
| 3221 | t = t1, cval = cv1; | 3221 | t = t1, cval = cv1; |
| @@ -3238,7 +3238,7 @@ static inline int *macro_twosharps(TCCState *S, const int *ptr0) · 16 unmodified lines | |||
| 3238 | 3238 | ||
| 3239 | /* peek or read [ws_str == NULL] next token from function macro call, | 3239 | /* peek or read [ws_str == NULL] next token from function macro call, |
| 3240 | walking up macro levels up to the file if necessary */ | 3240 | walking up macro levels up to the file if necessary */ |
| 3241 | static int next_argstream(TCCState *S, Sym **nested_list, TokenString *ws_str) | 3241 | static int next_argstream(TCCState* S, Sym **nested_list, TokenString *ws_str) |
| 3242 | { | 3242 | { |
| 3243 | int t; | 3243 | int t; |
| 3244 | const int *p; | 3244 | const int *p; |
| @@ -3292,7 +3292,7 @@ static int next_argstream(TCCState *S, Sym **nested_list, TokenString *ws_str) · 47 unmodified lines | |||
| 3292 | if (ws_str) | 3292 | if (ws_str) |
| 3293 | return t; | 3293 | return t; |
| 3294 | next_nomacro(S); | 3294 | next_nomacro(S); |
| 3295 | return S->tok; | 3295 | return S->tccpp_tok; |
| 3296 | } | 3296 | } |
| 3297 | } | 3297 | } |
| 3298 | 3298 | ||
| @@ -3300,7 +3300,7 @@ static int next_argstream(TCCState *S, Sym **nested_list, TokenString *ws_str) · 1 unmodified line | |||
| 3300 | result to (tok_str,tok_len). 'nested_list' is the list of all | 3300 | result to (tok_str,tok_len). 'nested_list' is the list of all |
| 3301 | macros we got inside to avoid recursing. Return non zero if no | 3301 | macros we got inside to avoid recursing. Return non zero if no |
| 3302 | substitution needs to be done */ | 3302 | substitution needs to be done */ |
| 3303 | static int macro_subst_tok(TCCState *S, | 3303 | static int macro_subst_tok(TCCState* S, |
| 3304 | TokenString *tok_str, | 3304 | TokenString *tok_str, |
| 3305 | Sym **nested_list, | 3305 | Sym **nested_list, |
| 3306 | Sym *s) | 3306 | Sym *s) |
| @@ -3315,22 +3315,22 @@ static int macro_subst_tok(TCCState *S, · 8 unmodified lines | |||
| 3315 | 3315 | ||
| 3316 | /* if symbol is a macro, prepare substitution */ | 3316 | /* if symbol is a macro, prepare substitution */ |
| 3317 | /* special macros */ | 3317 | /* special macros */ |
| 3318 | if (S->tok == TOK___LINE__ || S->tok == TOK___COUNTER__) { | 3318 | if (S->tccpp_tok == TOK___LINE__ || S->tccpp_tok == TOK___COUNTER__) { |
| 3319 | t = S->tok == TOK___LINE__ ? S->tccpp_file->line_num : S->tccpp_pp_counter++; | 3319 | t = S->tccpp_tok == TOK___LINE__ ? S->tccpp_file->line_num : S->tccpp_pp_counter++; |
| 3320 | snprintf(buf, sizeof(buf), "%d", t); | 3320 | snprintf(buf, sizeof(buf), "%d", t); |
| 3321 | cstrval = buf; | 3321 | cstrval = buf; |
| 3322 | t1 = TOK_PPNUM; | 3322 | t1 = TOK_PPNUM; |
| 3323 | goto add_cstr1; | 3323 | goto add_cstr1; |
| 3324 | } else if (S->tok == TOK___FILE__) { | 3324 | } else if (S->tccpp_tok == TOK___FILE__) { |
| 3325 | cstrval = S->tccpp_file->filename; | 3325 | cstrval = S->tccpp_file->filename; |
| 3326 | goto add_cstr; | 3326 | goto add_cstr; |
| 3327 | } else if (S->tok == TOK___DATE__ || S->tok == TOK___TIME__) { | 3327 | } else if (S->tccpp_tok == TOK___DATE__ || S->tccpp_tok == TOK___TIME__) { |
| 3328 | time_t ti; | 3328 | time_t ti; |
| 3329 | struct tm *tm; | 3329 | struct tm *tm; |
| 3330 | 3330 | ||
| 3331 | time(&ti); | 3331 | time(&ti); |
| 3332 | tm = localtime(&ti); | 3332 | tm = localtime(&ti); |
| 3333 | if (S->tok == TOK___DATE__) { | 3333 | if (S->tccpp_tok == TOK___DATE__) { |
| 3334 | snprintf(buf, sizeof(buf), "%s %2d %d", | 3334 | snprintf(buf, sizeof(buf), "%s %2d %d", |
| 3335 | ab_month_name[tm->tm_mon], tm->tm_mday, tm->tm_year + 1900); | 3335 | ab_month_name[tm->tm_mon], tm->tm_mday, tm->tm_year + 1900); |
| 3336 | } else { | 3336 | } else { |
| @@ -3369,7 +3369,7 @@ static int macro_subst_tok(TCCState *S, · 32 unmodified lines | |||
| 3369 | * whitespace is intentionally not merged to preserve | 3369 | * whitespace is intentionally not merged to preserve |
| 3370 | * newlines. */ | 3370 | * newlines. */ |
| 3371 | S->tccpp_parse_flags = saved_parse_flags; | 3371 | S->tccpp_parse_flags = saved_parse_flags; |
| 3372 | tok_str_add(S, tok_str, S->tok); | 3372 | tok_str_add(S, tok_str, S->tccpp_tok); |
| 3373 | if (S->tccpp_parse_flags & PARSE_FLAG_SPACES) { | 3373 | if (S->tccpp_parse_flags & PARSE_FLAG_SPACES) { |
| 3374 | int i; | 3374 | int i; |
| 3375 | for (i = 0; i < ws_str.len; i++) | 3375 | for (i = 0; i < ws_str.len; i++) |
| @@ -3382,7 +3382,7 @@ static int macro_subst_tok(TCCState *S, · 6 unmodified lines | |||
| 3382 | } | 3382 | } |
| 3383 | do { | 3383 | do { |
| 3384 | next_nomacro(S); /* eat '(' */ | 3384 | next_nomacro(S); /* eat '(' */ |
| 3385 | } while (S->tok == TOK_PLCHLDR || is_space(S->tok)); | 3385 | } while (S->tccpp_tok == TOK_PLCHLDR || is_space(S->tccpp_tok)); |
| 3386 | 3386 | ||
| 3387 | /* argument macro */ | 3387 | /* argument macro */ |
| 3388 | args = NULL; | 3388 | args = NULL; |
| @@ -3391,11 +3391,11 @@ static int macro_subst_tok(TCCState *S, · 2 unmodified lines | |||
| 3391 | for(;;) { | 3391 | for(;;) { |
| 3392 | do { | 3392 | do { |
| 3393 | next_argstream(S, nested_list, NULL); | 3393 | next_argstream(S, nested_list, NULL); |
| 3394 | } while (S->tok == TOK_PLCHLDR || is_space(S->tok) || | 3394 | } while (S->tccpp_tok == TOK_PLCHLDR || is_space(S->tccpp_tok) || |
| 3395 | TOK_LINEFEED == S->tok); | 3395 | TOK_LINEFEED == S->tccpp_tok); |
| 3396 | empty_arg: | 3396 | empty_arg: |
| 3397 | /* handle '()' case */ | 3397 | /* handle '()' case */ |
| 3398 | if (!args && !sa && S->tok == ')') | 3398 | if (!args && !sa && S->tccpp_tok == ')') |
| 3399 | break; | 3399 | break; |
| 3400 | if (!sa) | 3400 | if (!sa) |
| 3401 | tcc_error(S,"macro '%s' used with too many args", | 3401 | tcc_error(S,"macro '%s' used with too many args", |
| @@ -3404,18 +3404,18 @@ static int macro_subst_tok(TCCState *S, · 2 unmodified lines | |||
| 3404 | parlevel = spc = 0; | 3404 | parlevel = spc = 0; |
| 3405 | /* NOTE: non zero sa->t indicates VA_ARGS */ | 3405 | /* NOTE: non zero sa->t indicates VA_ARGS */ |
| 3406 | while ((parlevel > 0 || | 3406 | while ((parlevel > 0 || |
| 3407 | (S->tok != ')' && | 3407 | (S->tccpp_tok != ')' && |
| 3408 | (S->tok != ',' || sa->type.t)))) { | 3408 | (S->tccpp_tok != ',' || sa->type.t)))) { |
| 3409 | if (S->tok == TOK_EOF || S->tok == 0) | 3409 | if (S->tccpp_tok == TOK_EOF || S->tccpp_tok == 0) |
| 3410 | break; | 3410 | break; |
| 3411 | if (S->tok == '(') | 3411 | if (S->tccpp_tok == '(') |
| 3412 | parlevel++; | 3412 | parlevel++; |
| 3413 | else if (S->tok == ')') | 3413 | else if (S->tccpp_tok == ')') |
| 3414 | parlevel--; | 3414 | parlevel--; |
| 3415 | if (S->tok == TOK_LINEFEED) | 3415 | if (S->tccpp_tok == TOK_LINEFEED) |
| 3416 | S->tok = ' '; | 3416 | S->tccpp_tok = ' '; |
| 3417 | if (!check_space(S, S->tok, &spc)) | 3417 | if (!check_space(S, S->tccpp_tok, &spc)) |
| 3418 | tok_str_add2(S, &str, S->tok, &S->tokc); | 3418 | tok_str_add2(S, &str, S->tccpp_tok, &S->tccpp_tokc); |
| 3419 | next_argstream(S, nested_list, NULL); | 3419 | next_argstream(S, nested_list, NULL); |
| 3420 | } | 3420 | } |
| 3421 | if (parlevel) | 3421 | if (parlevel) |
| @@ -3426,14 +3426,14 @@ static int macro_subst_tok(TCCState *S, · 4 unmodified lines | |||
| 3426 | sa1 = sym_push2(S, &args, sa->v & ~SYM_FIELD, sa->type.t, 0); | 3426 | sa1 = sym_push2(S, &args, sa->v & ~SYM_FIELD, sa->type.t, 0); |
| 3427 | sa1->d = str.str; | 3427 | sa1->d = str.str; |
| 3428 | sa = sa->next; | 3428 | sa = sa->next; |
| 3429 | if (S->tok == ')') { | 3429 | if (S->tccpp_tok == ')') { |
| 3430 | /* special case for gcc var args: add an empty | 3430 | /* special case for gcc var args: add an empty |
| 3431 | var arg argument if it is omitted */ | 3431 | var arg argument if it is omitted */ |
| 3432 | if (sa && sa->type.t && gnu_ext) | 3432 | if (sa && sa->type.t && gnu_ext) |
| 3433 | goto empty_arg; | 3433 | goto empty_arg; |
| 3434 | break; | 3434 | break; |
| 3435 | } | 3435 | } |
| 3436 | if (S->tok != ',') | 3436 | if (S->tccpp_tok != ',') |
| 3437 | expect(S, ","); | 3437 | expect(S, ","); |
| 3438 | } | 3438 | } |
| 3439 | if (sa) { | 3439 | if (sa) { |
| @@ -3478,7 +3478,7 @@ static int macro_subst_tok(TCCState *S, · 38 unmodified lines | |||
| 3478 | /* do macro substitution of macro_str and add result to | 3478 | /* do macro substitution of macro_str and add result to |
| 3479 | (tok_str,tok_len). 'nested_list' is the list of all macros we got | 3479 | (tok_str,tok_len). 'nested_list' is the list of all macros we got |
| 3480 | inside to avoid recursing. */ | 3480 | inside to avoid recursing. */ |
| 3481 | static void macro_subst(TCCState *S, | 3481 | static void macro_subst(TCCState* S, |
| 3482 | TokenString *tok_str, | 3482 | TokenString *tok_str, |
| 3483 | Sym **nested_list, | 3483 | Sym **nested_list, |
| 3484 | const int *macro_str | 3484 | const int *macro_str |
| @@ -3512,7 +3512,7 @@ static void macro_subst(TCCState *S, · 27 unmodified lines | |||
| 3512 | str->str = (int*)macro_str; | 3512 | str->str = (int*)macro_str; |
| 3513 | begin_macro(S, str, 2); | 3513 | begin_macro(S, str, 2); |
| 3514 | 3514 | ||
| 3515 | S->tok = t; | 3515 | S->tccpp_tok = t; |
| 3516 | macro_subst_tok(S, tok_str, nested_list, s); | 3516 | macro_subst_tok(S, tok_str, nested_list, s); |
| 3517 | 3517 | ||
| 3518 | if (S->tccpp_macro_stack != str) { | 3518 | if (S->tccpp_macro_stack != str) { |
| @@ -3546,16 +3546,16 @@ no_subst: · 27 unmodified lines | |||
| 3546 | 3546 | ||
| 3547 | /* return next token without macro substitution. Can read input from | 3547 | /* return next token without macro substitution. Can read input from |
| 3548 | macro_ptr buffer */ | 3548 | macro_ptr buffer */ |
| 3549 | static void next_nomacro(TCCState *S) | 3549 | static void next_nomacro(TCCState* S) |
| 3550 | { | 3550 | { |
| 3551 | int t; | 3551 | int t; |
| 3552 | if (S->tccpp_macro_ptr) { | 3552 | if (S->tccpp_macro_ptr) { |
| 3553 | redo: | 3553 | redo: |
| 3554 | t = *S->tccpp_macro_ptr; | 3554 | t = *S->tccpp_macro_ptr; |
| 3555 | if (TOK_HAS_VALUE(t)) { | 3555 | if (TOK_HAS_VALUE(t)) { |
| 3556 | tok_get(&S->tok, &S->tccpp_macro_ptr, &S->tokc); | 3556 | tok_get(&S->tccpp_tok, &S->tccpp_macro_ptr, &S->tccpp_tokc); |
| 3557 | if (t == TOK_LINENUM) { | 3557 | if (t == TOK_LINENUM) { |
| 3558 | S->tccpp_file->line_num = S->tokc.i; | 3558 | S->tccpp_file->line_num = S->tccpp_tokc.i; |
| 3559 | goto redo; | 3559 | goto redo; |
| 3560 | } | 3560 | } |
| 3561 | } else { | 3561 | } else { |
| @@ -3565,7 +3565,7 @@ static void next_nomacro(TCCState *S) · 3 unmodified lines | |||
| 3565 | && (S->tccpp_isidnum_table[t - CH_EOF] & IS_SPC)) | 3565 | && (S->tccpp_isidnum_table[t - CH_EOF] & IS_SPC)) |
| 3566 | goto redo; | 3566 | goto redo; |
| 3567 | } | 3567 | } |
| 3568 | S->tok = t; | 3568 | S->tccpp_tok = t; |
| 3569 | } | 3569 | } |
| 3570 | } else { | 3570 | } else { |
| 3571 | next_nomacro1(S); | 3571 | next_nomacro1(S); |
| @@ -3573,12 +3573,12 @@ static void next_nomacro(TCCState *S) · 1 unmodified line | |||
| 3573 | } | 3573 | } |
| 3574 | 3574 | ||
| 3575 | /* return next token with macro substitution */ | 3575 | /* return next token with macro substitution */ |
| 3576 | ST_FUNC void next(TCCState *S) | 3576 | ST_FUNC void next(TCCState* S) |
| 3577 | { | 3577 | { |
| 3578 | int t; | 3578 | int t; |
| 3579 | redo: | 3579 | redo: |
| 3580 | next_nomacro(S); | 3580 | next_nomacro(S); |
| 3581 | t = S->tok; | 3581 | t = S->tccpp_tok; |
| 3582 | if (S->tccpp_macro_ptr) { | 3582 | if (S->tccpp_macro_ptr) { |
| 3583 | if (!TOK_HAS_VALUE(t)) { | 3583 | if (!TOK_HAS_VALUE(t)) { |
| 3584 | if (t == TOK_NOSUBST || t == TOK_PLCHLDR) { | 3584 | if (t == TOK_NOSUBST || t == TOK_PLCHLDR) { |
| @@ -3599,10 +3599,10 @@ ST_FUNC void next(TCCState *S) · 14 unmodified lines | |||
| 3599 | Sym *s = define_find(S, t); | 3599 | Sym *s = define_find(S, t); |
| 3600 | if (s) { | 3600 | if (s) { |
| 3601 | Sym *nested_list = NULL; | 3601 | Sym *nested_list = NULL; |
| 3602 | S->tokstr_buf.len = 0; | 3602 | S->tccpp_tokstr_buf.len = 0; |
| 3603 | macro_subst_tok(S, &S->tokstr_buf, &nested_list, s); | 3603 | macro_subst_tok(S, &S->tccpp_tokstr_buf, &nested_list, s); |
| 3604 | tok_str_add(S, &S->tokstr_buf, 0); | 3604 | tok_str_add(S, &S->tccpp_tokstr_buf, 0); |
| 3605 | begin_macro(S, &S->tokstr_buf, 0); | 3605 | begin_macro(S, &S->tccpp_tokstr_buf, 0); |
| 3606 | goto redo; | 3606 | goto redo; |
| 3607 | } | 3607 | } |
| 3608 | return; | 3608 | return; |
| @@ -3610,23 +3610,23 @@ ST_FUNC void next(TCCState *S) · 1 unmodified line | |||
| 3610 | /* convert preprocessor tokens into C tokens */ | 3610 | /* convert preprocessor tokens into C tokens */ |
| 3611 | if (t == TOK_PPNUM) { | 3611 | if (t == TOK_PPNUM) { |
| 3612 | if (S->tccpp_parse_flags & PARSE_FLAG_TOK_NUM) | 3612 | if (S->tccpp_parse_flags & PARSE_FLAG_TOK_NUM) |
| 3613 | parse_number(S, (char *)S->tokc.str.data); | 3613 | parse_number(S, (char *)S->tccpp_tokc.str.data); |
| 3614 | } else if (t == TOK_PPSTR) { | 3614 | } else if (t == TOK_PPSTR) { |
| 3615 | if (S->tccpp_parse_flags & PARSE_FLAG_TOK_STR) | 3615 | if (S->tccpp_parse_flags & PARSE_FLAG_TOK_STR) |
| 3616 | parse_string(S, (char *)S->tokc.str.data, S->tokc.str.size - 1); | 3616 | parse_string(S, (char *)S->tccpp_tokc.str.data, S->tccpp_tokc.str.size - 1); |
| 3617 | } | 3617 | } |
| 3618 | } | 3618 | } |
| 3619 | 3619 | ||
| 3620 | /* push back current token and set current token to 'last_tok'. Only | 3620 | /* push back current token and set current token to 'last_tok'. Only |
| 3621 | identifier case handled for labels. */ | 3621 | identifier case handled for labels. */ |
| 3622 | ST_INLN void unget_tok(TCCState *S, int last_tok) | 3622 | ST_INLN void unget_tok(TCCState* S, int last_tok) |
| 3623 | { | 3623 | { |
| 3624 | 3624 | ||
| 3625 | TokenString *str = tok_str_alloc(S); | 3625 | TokenString *str = tok_str_alloc(S); |
| 3626 | tok_str_add2(S, str, S->tok, &S->tokc); | 3626 | tok_str_add2(S, str, S->tccpp_tok, &S->tccpp_tokc); |
| 3627 | tok_str_add(S, str, 0); | 3627 | tok_str_add(S, str, 0); |
| 3628 | begin_macro(S, str, 1); | 3628 | begin_macro(S, str, 1); |
| 3629 | S->tok = last_tok; | 3629 | S->tccpp_tok = last_tok; |
| 3630 | } | 3630 | } |
| 3631 | 3631 | ||
| 3632 | /* ------------------------------------------------------------------------- */ | 3632 | /* ------------------------------------------------------------------------- */ |
| @@ -3658,7 +3658,7 @@ static const char * const target_os_defs = · 25 unmodified lines | |||
| 3658 | #endif | 3658 | #endif |
| 3659 | ; | 3659 | ; |
| 3660 | 3660 | ||
| 3661 | static void putdef(TCCState *S, CString *cs, const char *p) | 3661 | static void putdef(TCCState* S, CString *cs, const char *p) |
| 3662 | { | 3662 | { |
| 3663 | cstr_printf(S, cs, "#define %s%s\n", p, &" 1"[!!strchr(p, ' ')*2]); | 3663 | cstr_printf(S, cs, "#define %s%s\n", p, &" 1"[!!strchr(p, ' ')*2]); |
| 3664 | } | 3664 | } |
| @@ -3748,7 +3748,7 @@ ST_FUNC void preprocess_start(TCCState *S, int filetype) · 83 unmodified lines | |||
| 3748 | } | 3748 | } |
| 3749 | 3749 | ||
| 3750 | S->tccpp_parse_flags = is_asm ? PARSE_FLAG_ASM_FILE : 0; | 3750 | S->tccpp_parse_flags = is_asm ? PARSE_FLAG_ASM_FILE : 0; |
| 3751 | S->tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF; | 3751 | S->tccpp_tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF; |
| 3752 | } | 3752 | } |
| 3753 | 3753 | ||
| 3754 | /* cleanup from error/setjmp */ | 3754 | /* cleanup from error/setjmp */ |
| @@ -3779,18 +3779,18 @@ ST_FUNC void tccpp_new(TCCState *S) · 24 unmodified lines | |||
| 3779 | set_idnum(S, i, IS_ID); | 3779 | set_idnum(S, i, IS_ID); |
| 3780 | 3780 | ||
| 3781 | /* init allocators */ | 3781 | /* init allocators */ |
| 3782 | tal_new(S, &S->toksym_alloc, TOKSYM_TAL_LIMIT, TOKSYM_TAL_SIZE); | 3782 | tal_new(S, &S->tccpp_toksym_alloc, TOKSYM_TAL_LIMIT, TOKSYM_TAL_SIZE); |
| 3783 | tal_new(S, &S->tokstr_alloc, TOKSTR_TAL_LIMIT, TOKSTR_TAL_SIZE); | 3783 | tal_new(S, &S->tccpp_tokstr_alloc, TOKSTR_TAL_LIMIT, TOKSTR_TAL_SIZE); |
| 3784 | 3784 | ||
| 3785 | memset(S->tccpp_hash_ident, 0, TOK_HASH_SIZE * sizeof(TokenSym *)); | 3785 | memset(S->tccpp_hash_ident, 0, TOK_HASH_SIZE * sizeof(TokenSym *)); |
| 3786 | memset(S->cached_includes_hash, 0, sizeof S->cached_includes_hash); | 3786 | memset(S->cached_includes_hash, 0, sizeof S->cached_includes_hash); |
| 3787 | 3787 | ||
| 3788 | cstr_new(S, &S->tccpp_cstr_buf); | 3788 | cstr_new(S, &S->tccpp_cstr_buf); |
| 3789 | cstr_realloc(S, &S->tccpp_cstr_buf, STRING_MAX_SIZE); | 3789 | cstr_realloc(S, &S->tccpp_cstr_buf, STRING_MAX_SIZE); |
| 3790 | tok_str_new(&S->tokstr_buf); | 3790 | tok_str_new(&S->tccpp_tokstr_buf); |
| 3791 | tok_str_realloc(S, &S->tokstr_buf, TOKSTR_MAX_SIZE); | 3791 | tok_str_realloc(S, &S->tccpp_tokstr_buf, TOKSTR_MAX_SIZE); |
| 3792 | 3792 | ||
| 3793 | S->tok_ident = TOK_IDENT; | 3793 | S->tccpp_tok_ident = TOK_IDENT; |
| 3794 | p = tcc_keywords; | 3794 | p = tcc_keywords; |
| 3795 | while (*p) { | 3795 | while (*p) { |
| 3796 | r = p; | 3796 | r = p; |
| @@ -3819,31 +3819,31 @@ ST_FUNC void tccpp_delete(TCCState *S) · 22 unmodified lines | |||
| 3819 | dynarray_reset(S, &S->cached_includes, &S->nb_cached_includes); | 3819 | dynarray_reset(S, &S->cached_includes, &S->nb_cached_includes); |
| 3820 | 3820 | ||
| 3821 | /* free tokens */ | 3821 | /* free tokens */ |
| 3822 | n = S->tok_ident - TOK_IDENT; | 3822 | n = S->tccpp_tok_ident - TOK_IDENT; |
| 3823 | if (n > total_idents) | 3823 | if (n > total_idents) |
| 3824 | total_idents = n; | 3824 | total_idents = n; |
| 3825 | for(i = 0; i < n; i++) | 3825 | for(i = 0; i < n; i++) |
| 3826 | tal_free(S, S->toksym_alloc, S->tccpp_table_ident[i]); | 3826 | tal_free(S, S->tccpp_toksym_alloc, S->tccpp_table_ident[i]); |
| 3827 | tcc_free(S, S->tccpp_table_ident); | 3827 | tcc_free(S, S->tccpp_table_ident); |
| 3828 | S->tccpp_table_ident = NULL; | 3828 | S->tccpp_table_ident = NULL; |
| 3829 | 3829 | ||
| 3830 | /* free static buffers */ | 3830 | /* free static buffers */ |
| 3831 | cstr_free(S, &S->tokcstr); | 3831 | cstr_free(S, &S->tccpp_tokcstr); |
| 3832 | cstr_free(S, &S->tccpp_cstr_buf); | 3832 | cstr_free(S, &S->tccpp_cstr_buf); |
| 3833 | cstr_free(S, &S->tccpp_macro_equal_buf); | 3833 | cstr_free(S, &S->tccpp_macro_equal_buf); |
| 3834 | tok_str_free_str(S, S->tokstr_buf.str); | 3834 | tok_str_free_str(S, S->tccpp_tokstr_buf.str); |
| 3835 | 3835 | ||
| 3836 | /* free allocators */ | 3836 | /* free allocators */ |
| 3837 | tal_delete(S, S->toksym_alloc); | 3837 | tal_delete(S, S->tccpp_toksym_alloc); |
| 3838 | S->toksym_alloc = NULL; | 3838 | S->tccpp_toksym_alloc = NULL; |
| 3839 | tal_delete(S, S->tokstr_alloc); | 3839 | tal_delete(S, S->tccpp_tokstr_alloc); |
| 3840 | S->tokstr_alloc = NULL; | 3840 | S->tccpp_tokstr_alloc = NULL; |
| 3841 | } | 3841 | } |
| 3842 | 3842 | ||
| 3843 | /* ------------------------------------------------------------------------- */ | 3843 | /* ------------------------------------------------------------------------- */ |
| 3844 | /* tcc -E [-P[1]] [-dD} support */ | 3844 | /* tcc -E [-P[1]] [-dD} support */ |
| 3845 | 3845 | ||
| 3846 | static void tok_print(TCCState *S, const char *msg, const int *str) | 3846 | static void tok_print(TCCState* S, const char *msg, const int *str) |
| 3847 | { | 3847 | { |
| 3848 | FILE *fp; | 3848 | FILE *fp; |
| 3849 | int t, s = 0; | 3849 | int t, s = 0; |
| @@ -3939,7 +3939,7 @@ static void pp_debug_defines(TCCState *S) · 89 unmodified lines | |||
| 3939 | static void pp_debug_builtins(TCCState *S) | 3939 | static void pp_debug_builtins(TCCState *S) |
| 3940 | { | 3940 | { |
| 3941 | int v; | 3941 | int v; |
| 3942 | for (v = TOK_IDENT; v < S->tok_ident; ++v) | 3942 | for (v = TOK_IDENT; v < S->tccpp_tok_ident; ++v) |
| 3943 | define_print(S, v); | 3943 | define_print(S, v); |
| 3944 | } | 3944 | } |
| 3945 | 3945 | ||
| @@ -3984,7 +3984,7 @@ ST_FUNC int tcc_preprocess(TCCState *S) · 38 unmodified lines | |||
| 3984 | 3984 | ||
| 3985 | if (S->do_bench) { | 3985 | if (S->do_bench) { |
| 3986 | /* for PP benchmarks */ | 3986 | /* for PP benchmarks */ |
| 3987 | do next(S); while (S->tok != TOK_EOF); | 3987 | do next(S); while (S->tccpp_tok != TOK_EOF); |
| 3988 | return 0; | 3988 | return 0; |
| 3989 | } | 3989 | } |
| 3990 | 3990 | ||
| @@ -4000,7 +4000,7 @@ ST_FUNC int tcc_preprocess(TCCState *S) · 9 unmodified lines | |||
| 4000 | for (;;) { | 4000 | for (;;) { |
| 4001 | iptr = S->include_stack_ptr; | 4001 | iptr = S->include_stack_ptr; |
| 4002 | next(S); | 4002 | next(S); |
| 4003 | if (S->tok == TOK_EOF) | 4003 | if (S->tccpp_tok == TOK_EOF) |
| 4004 | break; | 4004 | break; |
| 4005 | 4005 | ||
| 4006 | level = S->include_stack_ptr - iptr; | 4006 | level = S->include_stack_ptr - iptr; |
| @@ -4015,24 +4015,24 @@ ST_FUNC int tcc_preprocess(TCCState *S) · 8 unmodified lines | |||
| 4015 | continue; | 4015 | continue; |
| 4016 | } | 4016 | } |
| 4017 | 4017 | ||
| 4018 | if (is_space(S->tok)) { | 4018 | if (is_space(S->tccpp_tok)) { |
| 4019 | if (spcs < sizeof white - 1) | 4019 | if (spcs < sizeof white - 1) |
| 4020 | white[spcs++] = S->tok; | 4020 | white[spcs++] = S->tccpp_tok; |
| 4021 | continue; | 4021 | continue; |
| 4022 | } else if (S->tok == TOK_LINEFEED) { | 4022 | } else if (S->tccpp_tok == TOK_LINEFEED) { |
| 4023 | spcs = 0; | 4023 | spcs = 0; |
| 4024 | if (token_seen == TOK_LINEFEED) | 4024 | if (token_seen == TOK_LINEFEED) |
| 4025 | continue; | 4025 | continue; |
| 4026 | ++S->tccpp_file->line_ref; | 4026 | ++S->tccpp_file->line_ref; |
| 4027 | } else if (token_seen == TOK_LINEFEED) { | 4027 | } else if (token_seen == TOK_LINEFEED) { |
| 4028 | pp_line(S, S->tccpp_file, 0); | 4028 | pp_line(S, S->tccpp_file, 0); |
| 4029 | } else if (spcs == 0 && pp_need_space(token_seen, S->tok)) { | 4029 | } else if (spcs == 0 && pp_need_space(token_seen, S->tccpp_tok)) { |
| 4030 | white[spcs++] = ' '; | 4030 | white[spcs++] = ' '; |
| 4031 | } | 4031 | } |
| 4032 | 4032 | ||
| 4033 | white[spcs] = 0, fputs(white, S->ppfp), spcs = 0; | 4033 | white[spcs] = 0, fputs(white, S->ppfp), spcs = 0; |
| 4034 | fputs(p = get_tok_str(S, S->tok, &S->tokc), S->ppfp); | 4034 | fputs(p = get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc), S->ppfp); |
| 4035 | token_seen = pp_check_he0xE(S->tok, p); | 4035 | token_seen = pp_check_he0xE(S->tccpp_tok, p); |
| 4036 | } | 4036 | } |
| 4037 | return 0; | 4037 | return 0; |
| 4038 | } | 4038 | } |
| @@ -149,19 +149,19 @@ ST_DATA const int reg_classes[NB_REGS] = { · 148 unmodified lines | |||
| 149 | }; | 149 | }; |
| 150 | 150 | ||
| 151 | /* XXX: make it faster ? */ | 151 | /* XXX: make it faster ? */ |
| 152 | ST_FUNC void g(TCCState *S, int c) | 152 | ST_FUNC void g(TCCState* S, int c) |
| 153 | { | 153 | { |
| 154 | int ind1; | 154 | int ind1; |
| 155 | if (S->nocode_wanted) | 155 | if (S->tccgen_nocode_wanted) |
| 156 | return; | 156 | return; |
| 157 | ind1 = S->ind + 1; | 157 | ind1 = S->tccgen_ind + 1; |
| 158 | if (ind1 > cur_text_section->data_allocated) | 158 | if (ind1 > cur_text_section->data_allocated) |
| 159 | section_realloc(S, cur_text_section, ind1); | 159 | section_realloc(S, cur_text_section, ind1); |
| 160 | cur_text_section->data[S->ind] = c; | 160 | cur_text_section->data[S->tccgen_ind] = c; |
| 161 | S->ind = ind1; | 161 | S->tccgen_ind = ind1; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | ST_FUNC void o(TCCState *S, unsigned int c) | 164 | ST_FUNC void o(TCCState* S, unsigned int c) |
| 165 | { | 165 | { |
| 166 | while (c) { | 166 | while (c) { |
| 167 | g(S, c); | 167 | g(S, c); |
| @@ -169,13 +169,13 @@ ST_FUNC void o(TCCState *S, unsigned int c) · 1 unmodified line | |||
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | ST_FUNC void gen_le16(TCCState *S, int v) | 172 | ST_FUNC void gen_le16(TCCState* S, int v) |
| 173 | { | 173 | { |
| 174 | g(S, v); | 174 | g(S, v); |
| 175 | g(S, v >> 8); | 175 | g(S, v >> 8); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | ST_FUNC void gen_le32(TCCState *S, int c) | 178 | ST_FUNC void gen_le32(TCCState* S, int c) |
| 179 | { | 179 | { |
| 180 | g(S, c); | 180 | g(S, c); |
| 181 | g(S, c >> 8); | 181 | g(S, c >> 8); |
| @@ -183,7 +183,7 @@ ST_FUNC void gen_le32(TCCState *S, int c) · 1 unmodified line | |||
| 183 | g(S, c >> 24); | 183 | g(S, c >> 24); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | ST_FUNC void gen_le64(TCCState *S, int64_t c) | 186 | ST_FUNC void gen_le64(TCCState* S, int64_t c) |
| 187 | { | 187 | { |
| 188 | g(S, c); | 188 | g(S, c); |
| 189 | g(S, c >> 8); | 189 | g(S, c >> 8); |
| @@ -195,7 +195,7 @@ ST_FUNC void gen_le64(TCCState *S, int64_t c) · 5 unmodified lines | |||
| 195 | g(S, c >> 56); | 195 | g(S, c >> 56); |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | static void orex(TCCState *S, int ll, int r, int r2, int b) | 198 | static void orex(TCCState* S, int ll, int r, int r2, int b) |
| 199 | { | 199 | { |
| 200 | if ((r & VT_VALMASK) >= VT_CONST) | 200 | if ((r & VT_VALMASK) >= VT_CONST) |
| 201 | r = 0; | 201 | r = 0; |
| @@ -207,7 +207,7 @@ static void orex(TCCState *S, int ll, int r, int r2, int b) · 5 unmodified lines | |||
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | /* output a symbol and patch all calls to it */ | 209 | /* output a symbol and patch all calls to it */ |
| 210 | ST_FUNC void gsym_addr(TCCState *S, int t, int a) | 210 | ST_FUNC void gsym_addr(TCCState* S, int t, int a) |
| 211 | { | 211 | { |
| 212 | while (t) { | 212 | while (t) { |
| 213 | unsigned char *ptr = cur_text_section->data + t; | 213 | unsigned char *ptr = cur_text_section->data + t; |
| @@ -228,10 +228,10 @@ static int is64_type(int t) · 14 unmodified lines | |||
| 228 | static int oad(TCCState *S, int c, int s) | 228 | static int oad(TCCState *S, int c, int s) |
| 229 | { | 229 | { |
| 230 | int t; | 230 | int t; |
| 231 | if (S->nocode_wanted) | 231 | if (S->tccgen_nocode_wanted) |
| 232 | return s; | 232 | return s; |
| 233 | o(S, c); | 233 | o(S, c); |
| 234 | t = S->ind; | 234 | t = S->tccgen_ind; |
| 235 | gen_le32(S, s); | 235 | gen_le32(S, s); |
| 236 | return t; | 236 | return t; |
| 237 | } | 237 | } |
| @@ -242,7 +242,7 @@ static int oad(TCCState *S, int c, int s) · 4 unmodified lines | |||
| 242 | ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c) | 242 | ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c) |
| 243 | { | 243 | { |
| 244 | if (r & VT_SYM) | 244 | if (r & VT_SYM) |
| 245 | greloca(S, cur_text_section, sym, S->ind, R_X86_64_32S, c), c=0; | 245 | greloca(S, cur_text_section, sym, S->tccgen_ind, R_X86_64_32S, c), c=0; |
| 246 | gen_le32(S, c); | 246 | gen_le32(S, c); |
| 247 | } | 247 | } |
| 248 | 248 | ||
| @@ -250,7 +250,7 @@ ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c) · 1 unmodified line | |||
| 250 | ST_FUNC void gen_addr64(TCCState *S, int r, Sym *sym, int64_t c) | 250 | ST_FUNC void gen_addr64(TCCState *S, int r, Sym *sym, int64_t c) |
| 251 | { | 251 | { |
| 252 | if (r & VT_SYM) | 252 | if (r & VT_SYM) |
| 253 | greloca(S, cur_text_section, sym, S->ind, R_X86_64_64, c), c=0; | 253 | greloca(S, cur_text_section, sym, S->tccgen_ind, R_X86_64_64, c), c=0; |
| 254 | gen_le64(S, c); | 254 | gen_le64(S, c); |
| 255 | } | 255 | } |
| 256 | 256 | ||
| @@ -258,7 +258,7 @@ ST_FUNC void gen_addr64(TCCState *S, int r, Sym *sym, int64_t c) · 1 unmodified line | |||
| 258 | ST_FUNC void gen_addrpc32(TCCState *S, int r, Sym *sym, int c) | 258 | ST_FUNC void gen_addrpc32(TCCState *S, int r, Sym *sym, int c) |
| 259 | { | 259 | { |
| 260 | if (r & VT_SYM) | 260 | if (r & VT_SYM) |
| 261 | greloca(S, cur_text_section, sym, S->ind, R_X86_64_PC32, c-4), c=4; | 261 | greloca(S, cur_text_section, sym, S->tccgen_ind, R_X86_64_PC32, c-4), c=4; |
| 262 | gen_le32(S, c-4); | 262 | gen_le32(S, c-4); |
| 263 | } | 263 | } |
| 264 | 264 | ||
| @@ -268,12 +268,12 @@ static void gen_gotpcrel(TCCState *S, int r, Sym *sym, int c) · 3 unmodified lines | |||
| 268 | #ifdef TCC_TARGET_PE | 268 | #ifdef TCC_TARGET_PE |
| 269 | tcc_error(S, "internal error: no GOT on PE: %s %x %x | %02x %02x %02x\n", | 269 | tcc_error(S, "internal error: no GOT on PE: %s %x %x | %02x %02x %02x\n", |
| 270 | get_tok_str(S, sym->v, NULL), c, r, | 270 | get_tok_str(S, sym->v, NULL), c, r, |
| 271 | cur_text_section->data[S->ind-3], | 271 | cur_text_section->data[S->tccgen_ind-3], |
| 272 | cur_text_section->data[S->ind-2], | 272 | cur_text_section->data[S->tccgen_ind-2], |
| 273 | cur_text_section->data[S->ind-1] | 273 | cur_text_section->data[S->tccgen_ind-1] |
| 274 | ); | 274 | ); |
| 275 | #endif | 275 | #endif |
| 276 | greloca(S, cur_text_section, sym, S->ind, R_X86_64_GOTPCREL, -4); | 276 | greloca(S, cur_text_section, sym, S->tccgen_ind, R_X86_64_GOTPCREL, -4); |
| 277 | gen_le32(S, 0); | 277 | gen_le32(S, 0); |
| 278 | if (c) { | 278 | if (c) { |
| 279 | /* we use add c, %xxx for displacement */ | 279 | /* we use add c, %xxx for displacement */ |
| @@ -482,7 +482,7 @@ void load(TCCState *S, int r, SValue *sv) · 202 unmodified lines | |||
| 482 | } else if (v == VT_CMP) { | 482 | } else if (v == VT_CMP) { |
| 483 | if (fc & 0x100) | 483 | if (fc & 0x100) |
| 484 | { | 484 | { |
| 485 | v = S->vtop->cmp_r; | 485 | v = S->tccgen_vtop->cmp_r; |
| 486 | fc &= ~0x100; | 486 | fc &= ~0x100; |
| 487 | /* This was a float compare. If the parity bit is | 487 | /* This was a float compare. If the parity bit is |
| 488 | set the result was unordered, meaning false for everything | 488 | set the result was unordered, meaning false for everything |
| @@ -624,19 +624,19 @@ void store(TCCState *S, int r, SValue *v) · 135 unmodified lines | |||
| 624 | static void gcall_or_jmp(TCCState *S, int is_jmp) | 624 | static void gcall_or_jmp(TCCState *S, int is_jmp) |
| 625 | { | 625 | { |
| 626 | int r; | 626 | int r; |
| 627 | if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && | 627 | if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && |
| 628 | ((S->vtop->r & VT_SYM) && (S->vtop->c.i-4) == (int)(S->vtop->c.i-4))) { | 628 | ((S->tccgen_vtop->r & VT_SYM) && (S->tccgen_vtop->c.i-4) == (int)(S->tccgen_vtop->c.i-4))) { |
| 629 | /* constant symbolic case -> simple relocation */ | 629 | /* constant symbolic case -> simple relocation */ |
| 630 | #ifdef TCC_TARGET_PE | 630 | #ifdef TCC_TARGET_PE |
| 631 | greloca(S, cur_text_section, S->vtop->sym, S->ind + 1, R_X86_64_PC32, (int)(S->vtop->c.i-4)); | 631 | greloca(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind + 1, R_X86_64_PC32, (int)(S->tccgen_vtop->c.i-4)); |
| 632 | #else | 632 | #else |
| 633 | greloca(S, cur_text_section, S->vtop->sym, S->ind + 1, R_X86_64_PLT32, (int)(S->vtop->c.i-4)); | 633 | greloca(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind + 1, R_X86_64_PLT32, (int)(S->tccgen_vtop->c.i-4)); |
| 634 | #endif | 634 | #endif |
| 635 | oad(S, 0xe8 + is_jmp, 0); /* call/jmp im */ | 635 | oad(S, 0xe8 + is_jmp, 0); /* call/jmp im */ |
| 636 | } else { | 636 | } else { |
| 637 | /* otherwise, indirect call */ | 637 | /* otherwise, indirect call */ |
| 638 | r = TREG_R11; | 638 | r = TREG_R11; |
| 639 | load(S, r, S->vtop); | 639 | load(S, r, S->tccgen_vtop); |
| 640 | o(S, 0x41); /* REX */ | 640 | o(S, 0x41); /* REX */ |
| 641 | o(S, 0xff); /* call/jmp *r */ | 641 | o(S, 0xff); /* call/jmp *r */ |
| 642 | o(S, 0xd0 + REG_VALUE(r) + (is_jmp << 4)); | 642 | o(S, 0xd0 + REG_VALUE(r) + (is_jmp << 4)); |
| @@ -650,9 +650,9 @@ static void gen_bounds_call(TCCState *S, int v) · 7 unmodified lines | |||
| 650 | Sym *sym = external_helper_sym(S, v); | 650 | Sym *sym = external_helper_sym(S, v); |
| 651 | oad(S, 0xe8, 0); | 651 | oad(S, 0xe8, 0); |
| 652 | #ifdef TCC_TARGET_PE | 652 | #ifdef TCC_TARGET_PE |
| 653 | greloca(S, cur_text_section, sym, S->ind-4, R_X86_64_PC32, -4); | 653 | greloca(S, cur_text_section, sym, S->tccgen_ind-4, R_X86_64_PC32, -4); |
| 654 | #else | 654 | #else |
| 655 | greloca(S, cur_text_section, sym, S->ind-4, R_X86_64_PLT32, -4); | 655 | greloca(S, cur_text_section, sym, S->tccgen_ind-4, R_X86_64_PLT32, -4); |
| 656 | #endif | 656 | #endif |
| 657 | } | 657 | } |
| 658 | 658 | ||
| @@ -666,7 +666,7 @@ static void gen_bounds_prolog(TCCState *S) · 7 unmodified lines | |||
| 666 | { | 666 | { |
| 667 | /* leave some room for bound checking code */ | 667 | /* leave some room for bound checking code */ |
| 668 | S->func_bound_offset = lbounds_section->data_offset; | 668 | S->func_bound_offset = lbounds_section->data_offset; |
| 669 | S->func_bound_ind = S->ind; | 669 | S->func_bound_ind = S->tccgen_ind; |
| 670 | S->func_bound_add_epilog = 0; | 670 | S->func_bound_add_epilog = 0; |
| 671 | o(S, 0x0d8d48 + ((TREG_FASTCALL_1 == TREG_RDI) * 0x300000)); /*lbound section pointer */ | 671 | o(S, 0x0d8d48 + ((TREG_FASTCALL_1 == TREG_RDI) * 0x300000)); /*lbound section pointer */ |
| 672 | gen_le32(S, 0); | 672 | gen_le32(S, 0); |
| @@ -687,22 +687,22 @@ static void gen_bounds_epilog(TCCState *S) · 14 unmodified lines | |||
| 687 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); | 687 | bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t)); |
| 688 | *bounds_ptr = 0; | 688 | *bounds_ptr = 0; |
| 689 | 689 | ||
| 690 | sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section, | 690 | sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section, |
| 691 | S->func_bound_offset, lbounds_section->data_offset); | 691 | S->func_bound_offset, lbounds_section->data_offset); |
| 692 | 692 | ||
| 693 | /* generate bound local allocation */ | 693 | /* generate bound local allocation */ |
| 694 | if (offset_modified) { | 694 | if (offset_modified) { |
| 695 | saved_ind = S->ind; | 695 | saved_ind = S->tccgen_ind; |
| 696 | S->ind = S->func_bound_ind; | 696 | S->tccgen_ind = S->func_bound_ind; |
| 697 | greloca(S, cur_text_section, sym_data, S->ind + 3, R_X86_64_PC32, -4); | 697 | greloca(S, cur_text_section, sym_data, S->tccgen_ind + 3, R_X86_64_PC32, -4); |
| 698 | S->ind = S->ind + 7; | 698 | S->tccgen_ind = S->tccgen_ind + 7; |
| 699 | gen_bounds_call(S, TOK___bound_local_new); | 699 | gen_bounds_call(S, TOK___bound_local_new); |
| 700 | S->ind = saved_ind; | 700 | S->tccgen_ind = saved_ind; |
| 701 | } | 701 | } |
| 702 | 702 | ||
| 703 | /* generate bound check local freeing */ | 703 | /* generate bound check local freeing */ |
| 704 | o(S, 0x5250); /* save returned value, if any */ | 704 | o(S, 0x5250); /* save returned value, if any */ |
| 705 | greloca(S, cur_text_section, sym_data, S->ind + 3, R_X86_64_PC32, -4); | 705 | greloca(S, cur_text_section, sym_data, S->tccgen_ind + 3, R_X86_64_PC32, -4); |
| 706 | o(S, 0x0d8d48 + ((TREG_FASTCALL_1 == TREG_RDI) * 0x300000)); /* lea xxx(%rip), %rcx/rdi */ | 706 | o(S, 0x0d8d48 + ((TREG_FASTCALL_1 == TREG_RDI) * 0x300000)); /* lea xxx(%rip), %rcx/rdi */ |
| 707 | gen_le32(S, 0); | 707 | gen_le32(S, 0); |
| 708 | gen_bounds_call(S, TOK___bound_local_delete); | 708 | gen_bounds_call(S, TOK___bound_local_delete); |
| @@ -731,7 +731,7 @@ static int arg_prepare_reg(int idx) { · 22 unmodified lines | |||
| 731 | all the parameters in call order. This functions pops all the | 731 | all the parameters in call order. This functions pops all the |
| 732 | parameters and the function address. */ | 732 | parameters and the function address. */ |
| 733 | 733 | ||
| 734 | static void gen_offs_sp(TCCState *S, int b, int r, int d) | 734 | static void gen_offs_sp(TCCState* S, int b, int r, int d) |
| 735 | { | 735 | { |
| 736 | orex(S, 1,0,r & 0x100 ? 0 : r, b); | 736 | orex(S, 1,0,r & 0x100 ? 0 : r, b); |
| 737 | if (d == (char)d) { | 737 | if (d == (char)d) { |
| @@ -783,7 +783,7 @@ static int gfunc_arg_size(CType *type) { · 45 unmodified lines | |||
| 783 | return type_size(type, &align); | 783 | return type_size(type, &align); |
| 784 | } | 784 | } |
| 785 | 785 | ||
| 786 | void gfunc_call(TCCState *S, int nb_args) | 786 | void gfunc_call(TCCState* S, int nb_args) |
| 787 | { | 787 | { |
| 788 | int size, r, args_size, i, d, bt, struct_size; | 788 | int size, r, args_size, i, d, bt, struct_size; |
| 789 | int arg; | 789 | int arg; |
| @@ -804,7 +804,7 @@ void gfunc_call(TCCState *S, int nb_args) · 14 unmodified lines | |||
| 804 | SValue *sv; | 804 | SValue *sv; |
| 805 | 805 | ||
| 806 | --arg; | 806 | --arg; |
| 807 | sv = &S->vtop[-i]; | 807 | sv = &S->tccgen_vtop[-i]; |
| 808 | bt = (sv->type.t & VT_BTYPE); | 808 | bt = (sv->type.t & VT_BTYPE); |
| 809 | size = gfunc_arg_size(&sv->type); | 809 | size = gfunc_arg_size(&sv->type); |
| 810 | 810 | ||
| @@ -823,7 +823,7 @@ void gfunc_call(TCCState *S, int nb_args) · 12 unmodified lines | |||
| 823 | vset(S, &sv->type, r | VT_LVAL, 0); | 823 | vset(S, &sv->type, r | VT_LVAL, 0); |
| 824 | vpushv(S, sv); | 824 | vpushv(S, sv); |
| 825 | vstore(S); | 825 | vstore(S); |
| 826 | --S->vtop; | 826 | --S->tccgen_vtop; |
| 827 | } else if (bt == VT_LDOUBLE) { | 827 | } else if (bt == VT_LDOUBLE) { |
| 828 | gv(S, RC_ST0); | 828 | gv(S, RC_ST0); |
| 829 | gen_offs_sp(S, 0xdb, 0x107, struct_size); | 829 | gen_offs_sp(S, 0xdb, 0x107, struct_size); |
| @@ -839,9 +839,9 @@ void gfunc_call(TCCState *S, int nb_args) · 9 unmodified lines | |||
| 839 | 839 | ||
| 840 | for(i = 0; i < nb_args; i++) { | 840 | for(i = 0; i < nb_args; i++) { |
| 841 | --arg; | 841 | --arg; |
| 842 | bt = (S->vtop->type.t & VT_BTYPE); | 842 | bt = (S->tccgen_vtop->type.t & VT_BTYPE); |
| 843 | 843 | ||
| 844 | size = gfunc_arg_size(&S->vtop->type); | 844 | size = gfunc_arg_size(&S->tccgen_vtop->type); |
| 845 | if (!using_regs(size)) { | 845 | if (!using_regs(size)) { |
| 846 | /* align to stack align size */ | 846 | /* align to stack align size */ |
| 847 | size = (size + 15) & ~15; | 847 | size = (size + 15) & ~15; |
| @@ -855,7 +855,7 @@ void gfunc_call(TCCState *S, int nb_args) · 7 unmodified lines | |||
| 855 | } | 855 | } |
| 856 | struct_size += size; | 856 | struct_size += size; |
| 857 | } else { | 857 | } else { |
| 858 | if (is_sse_float(S->vtop->type.t)) { | 858 | if (is_sse_float(S->tccgen_vtop->type.t)) { |
| 859 | if (S->nosse) | 859 | if (S->nosse) |
| 860 | tcc_error(S, "SSE disabled"); | 860 | tcc_error(S, "SSE disabled"); |
| 861 | if (arg >= REGN) { | 861 | if (arg >= REGN) { |
| @@ -873,8 +873,8 @@ void gfunc_call(TCCState *S, int nb_args) · 11 unmodified lines | |||
| 873 | } | 873 | } |
| 874 | } else { | 874 | } else { |
| 875 | if (bt == VT_STRUCT) { | 875 | if (bt == VT_STRUCT) { |
| 876 | S->vtop->type.ref = NULL; | 876 | S->tccgen_vtop->type.ref = NULL; |
| 877 | S->vtop->type.t = size > 4 ? VT_LLONG : size > 2 ? VT_INT | 877 | S->tccgen_vtop->type.t = size > 4 ? VT_LLONG : size > 2 ? VT_INT |
| 878 | : size > 1 ? VT_SHORT : VT_BYTE; | 878 | : size > 1 ? VT_SHORT : VT_BYTE; |
| 879 | } | 879 | } |
| 880 | 880 | ||
| @@ -888,7 +888,7 @@ void gfunc_call(TCCState *S, int nb_args) · 7 unmodified lines | |||
| 888 | } | 888 | } |
| 889 | } | 889 | } |
| 890 | } | 890 | } |
| 891 | S->vtop--; | 891 | S->tccgen_vtop--; |
| 892 | } | 892 | } |
| 893 | save_regs(S, 0); | 893 | save_regs(S, 0); |
| 894 | /* Copy R10 and R11 into RCX and RDX, respectively */ | 894 | /* Copy R10 and R11 into RCX and RDX, respectively */ |
| @@ -901,7 +901,7 @@ void gfunc_call(TCCState *S, int nb_args) · 6 unmodified lines | |||
| 901 | 901 | ||
| 902 | gcall_or_jmp(S, 0); | 902 | gcall_or_jmp(S, 0); |
| 903 | 903 | ||
| 904 | if ((S->vtop->r & VT_SYM) && S->vtop->sym->v == TOK_alloca) { | 904 | if ((S->tccgen_vtop->r & VT_SYM) && S->tccgen_vtop->sym->v == TOK_alloca) { |
| 905 | /* need to add the "func_scratch" area after alloca */ | 905 | /* need to add the "func_scratch" area after alloca */ |
| 906 | o(S, 0x48); S->x86_64_gen_func_alloca = oad(S, 0x05, S->x86_64_gen_func_alloca); /* add $NN, %rax */ | 906 | o(S, 0x48); S->x86_64_gen_func_alloca = oad(S, 0x05, S->x86_64_gen_func_alloca); /* add $NN, %rax */ |
| 907 | #ifdef CONFIG_TCC_BCHECK | 907 | #ifdef CONFIG_TCC_BCHECK |
| @@ -909,14 +909,14 @@ void gfunc_call(TCCState *S, int nb_args) · 1 unmodified line | |||
| 909 | gen_bounds_call(S, TOK___bound_alloca_nr); /* new region */ | 909 | gen_bounds_call(S, TOK___bound_alloca_nr); /* new region */ |
| 910 | #endif | 910 | #endif |
| 911 | } | 911 | } |
| 912 | S->vtop--; | 912 | S->tccgen_vtop--; |
| 913 | } | 913 | } |
| 914 | 914 | ||
| 915 | 915 | ||
| 916 | #define FUNC_PROLOG_SIZE 11 | 916 | #define FUNC_PROLOG_SIZE 11 |
| 917 | 917 | ||
| 918 | /* generate function prolog of type 't' */ | 918 | /* generate function prolog of type 't' */ |
| 919 | void gfunc_prolog(TCCState *S, Sym *func_sym) | 919 | void gfunc_prolog(TCCState* S, Sym *func_sym) |
| 920 | { | 920 | { |
| 921 | CType *func_type = &func_sym->type; | 921 | CType *func_type = &func_sym->type; |
| 922 | int addr, reg_param_index, bt, size; | 922 | int addr, reg_param_index, bt, size; |
| @@ -926,11 +926,11 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 3 unmodified lines | |||
| 926 | S->x86_64_gen_func_ret_sub = 0; | 926 | S->x86_64_gen_func_ret_sub = 0; |
| 927 | S->x86_64_gen_func_scratch = 32; | 927 | S->x86_64_gen_func_scratch = 32; |
| 928 | S->x86_64_gen_func_alloca = 0; | 928 | S->x86_64_gen_func_alloca = 0; |
| 929 | S->loc = 0; | 929 | S->tccgen_loc = 0; |
| 930 | 930 | ||
| 931 | addr = PTR_SIZE * 2; | 931 | addr = PTR_SIZE * 2; |
| 932 | S->ind += FUNC_PROLOG_SIZE; | 932 | S->tccgen_ind += FUNC_PROLOG_SIZE; |
| 933 | S->x86_64_gen_func_sub_sp_offset = S->ind; | 933 | S->x86_64_gen_func_sub_sp_offset = S->tccgen_ind; |
| 934 | reg_param_index = 0; | 934 | reg_param_index = 0; |
| 935 | 935 | ||
| 936 | sym = func_type->ref; | 936 | sym = func_type->ref; |
| @@ -989,13 +989,13 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 52 unmodified lines | |||
| 989 | } | 989 | } |
| 990 | 990 | ||
| 991 | /* generate function epilog */ | 991 | /* generate function epilog */ |
| 992 | void gfunc_epilog(TCCState *S) | 992 | void gfunc_epilog(TCCState* S) |
| 993 | { | 993 | { |
| 994 | int v, saved_ind; | 994 | int v, saved_ind; |
| 995 | 995 | ||
| 996 | /* align local size to word & save local variables */ | 996 | /* align local size to word & save local variables */ |
| 997 | S->x86_64_gen_func_scratch = (S->x86_64_gen_func_scratch + 15) & -16; | 997 | S->x86_64_gen_func_scratch = (S->x86_64_gen_func_scratch + 15) & -16; |
| 998 | S->loc = (S->loc & -16) - S->x86_64_gen_func_scratch; | 998 | S->tccgen_loc = (S->tccgen_loc & -16) - S->x86_64_gen_func_scratch; |
| 999 | 999 | ||
| 1000 | #ifdef CONFIG_TCC_BCHECK | 1000 | #ifdef CONFIG_TCC_BCHECK |
| 1001 | if (S->do_bounds_check) | 1001 | if (S->do_bounds_check) |
| @@ -1011,15 +1011,15 @@ void gfunc_epilog(TCCState *S) · 9 unmodified lines | |||
| 1011 | g(S, S->x86_64_gen_func_ret_sub >> 8); | 1011 | g(S, S->x86_64_gen_func_ret_sub >> 8); |
| 1012 | } | 1012 | } |
| 1013 | 1013 | ||
| 1014 | saved_ind = S->ind; | 1014 | saved_ind = S->tccgen_ind; |
| 1015 | S->ind = S->x86_64_gen_func_sub_sp_offset - FUNC_PROLOG_SIZE; | 1015 | S->tccgen_ind = S->x86_64_gen_func_sub_sp_offset - FUNC_PROLOG_SIZE; |
| 1016 | v = -S->loc; | 1016 | v = -S->tccgen_loc; |
| 1017 | 1017 | ||
| 1018 | if (v >= 4096) { | 1018 | if (v >= 4096) { |
| 1019 | Sym *sym = external_helper_sym(S, TOK___chkstk); | 1019 | Sym *sym = external_helper_sym(S, TOK___chkstk); |
| 1020 | oad(S, 0xb8, v); /* mov stacksize, %eax */ | 1020 | oad(S, 0xb8, v); /* mov stacksize, %eax */ |
| 1021 | oad(S, 0xe8, 0); /* call __chkstk, (does the stackframe too) */ | 1021 | oad(S, 0xe8, 0); /* call __chkstk, (does the stackframe too) */ |
| 1022 | greloca(S, cur_text_section, sym, S->ind-4, R_X86_64_PC32, -4); | 1022 | greloca(S, cur_text_section, sym, S->tccgen_ind-4, R_X86_64_PC32, -4); |
| 1023 | o(S, 0x90); /* fill for FUNC_PROLOG_SIZE = 11 bytes */ | 1023 | o(S, 0x90); /* fill for FUNC_PROLOG_SIZE = 11 bytes */ |
| 1024 | } else { | 1024 | } else { |
| 1025 | o(S, 0xe5894855); /* push %rbp, mov %rsp, %rbp */ | 1025 | o(S, 0xe5894855); /* push %rbp, mov %rsp, %rbp */ |
| @@ -1031,13 +1031,13 @@ void gfunc_epilog(TCCState *S) · 5 unmodified lines | |||
| 1031 | gsym_addr(S, S->x86_64_gen_func_alloca, -S->x86_64_gen_func_scratch); | 1031 | gsym_addr(S, S->x86_64_gen_func_alloca, -S->x86_64_gen_func_scratch); |
| 1032 | 1032 | ||
| 1033 | cur_text_section->data_offset = saved_ind; | 1033 | cur_text_section->data_offset = saved_ind; |
| 1034 | pe_add_unwind_data(S, S->ind, saved_ind, v); | 1034 | pe_add_unwind_data(S, S->tccgen_ind, saved_ind, v); |
| 1035 | S->ind = cur_text_section->data_offset; | 1035 | S->tccgen_ind = cur_text_section->data_offset; |
| 1036 | } | 1036 | } |
| 1037 | 1037 | ||
| 1038 | #else | 1038 | #else |
| 1039 | 1039 | ||
| 1040 | static void gadd_sp(TCCState *S, int val) | 1040 | static void gadd_sp(TCCState* S, int val) |
| 1041 | { | 1041 | { |
| 1042 | if (val == (char)val) { | 1042 | if (val == (char)val) { |
| 1043 | o(S, 0xc48348); | 1043 | o(S, 0xc48348); |
| @@ -1216,7 +1216,7 @@ static int arg_prepare_reg(int idx) { · 172 unmodified lines | |||
| 1216 | /* Generate function call. The function address is pushed first, then | 1216 | /* Generate function call. The function address is pushed first, then |
| 1217 | all the parameters in call order. This functions pops all the | 1217 | all the parameters in call order. This functions pops all the |
| 1218 | parameters and the function address. */ | 1218 | parameters and the function address. */ |
| 1219 | void gfunc_call(TCCState *S, int nb_args) | 1219 | void gfunc_call(TCCState* S, int nb_args) |
| 1220 | { | 1220 | { |
| 1221 | X86_64_Mode mode; | 1221 | X86_64_Mode mode; |
| 1222 | CType type; | 1222 | CType type; |
| @@ -1237,7 +1237,7 @@ void gfunc_call(TCCState *S, int nb_args) · 14 unmodified lines | |||
| 1237 | to be done in a left-to-right pass over arguments. */ | 1237 | to be done in a left-to-right pass over arguments. */ |
| 1238 | stack_adjust = 0; | 1238 | stack_adjust = 0; |
| 1239 | for(i = nb_args - 1; i >= 0; i--) { | 1239 | for(i = nb_args - 1; i >= 0; i--) { |
| 1240 | mode = classify_x86_64_arg(&S->vtop[-i].type, NULL, &size, &align, ®_count); | 1240 | mode = classify_x86_64_arg(&S->tccgen_vtop[-i].type, NULL, &size, &align, ®_count); |
| 1241 | if (size == 0) continue; | 1241 | if (size == 0) continue; |
| 1242 | if (mode == x86_64_mode_sse && nb_sse_args + reg_count <= 8) { | 1242 | if (mode == x86_64_mode_sse && nb_sse_args + reg_count <= 8) { |
| 1243 | nb_sse_args += reg_count; | 1243 | nb_sse_args += reg_count; |
| @@ -1261,7 +1261,7 @@ void gfunc_call(TCCState *S, int nb_args) · 17 unmodified lines | |||
| 1261 | tcc_error(S, "SSE disabled but floating point arguments passed"); | 1261 | tcc_error(S, "SSE disabled but floating point arguments passed"); |
| 1262 | 1262 | ||
| 1263 | /* fetch cpu flag before generating any code */ | 1263 | /* fetch cpu flag before generating any code */ |
| 1264 | if ((S->vtop->r & VT_VALMASK) == VT_CMP) | 1264 | if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP) |
| 1265 | gv(S, RC_INT); | 1265 | gv(S, RC_INT); |
| 1266 | 1266 | ||
| 1267 | /* for struct arguments, we need to call memcpy and the function | 1267 | /* for struct arguments, we need to call memcpy and the function |
| @@ -1272,7 +1272,7 @@ void gfunc_call(TCCState *S, int nb_args) · 4 unmodified lines | |||
| 1272 | args_size = 0; | 1272 | args_size = 0; |
| 1273 | stack_adjust &= 15; | 1273 | stack_adjust &= 15; |
| 1274 | for (i = k = 0; i < nb_args;) { | 1274 | for (i = k = 0; i < nb_args;) { |
| 1275 | mode = classify_x86_64_arg(&S->vtop[-i].type, NULL, &size, &align, ®_count); | 1275 | mode = classify_x86_64_arg(&S->tccgen_vtop[-i].type, NULL, &size, &align, ®_count); |
| 1276 | if (size) { | 1276 | if (size) { |
| 1277 | if (!onstack[i + k]) { | 1277 | if (!onstack[i + k]) { |
| 1278 | ++i; | 1278 | ++i; |
| @@ -1293,7 +1293,7 @@ void gfunc_call(TCCState *S, int nb_args) · 14 unmodified lines | |||
| 1293 | 1293 | ||
| 1294 | vrotb(S, i+1); | 1294 | vrotb(S, i+1); |
| 1295 | 1295 | ||
| 1296 | switch (S->vtop->type.t & VT_BTYPE) { | 1296 | switch (S->tccgen_vtop->type.t & VT_BTYPE) { |
| 1297 | case VT_STRUCT: | 1297 | case VT_STRUCT: |
| 1298 | /* allocate the necessary size on stack */ | 1298 | /* allocate the necessary size on stack */ |
| 1299 | o(S, 0x48); | 1299 | o(S, 0x48); |
| @@ -1302,7 +1302,7 @@ void gfunc_call(TCCState *S, int nb_args) · 2 unmodified lines | |||
| 1302 | r = get_reg(S, RC_INT); | 1302 | r = get_reg(S, RC_INT); |
| 1303 | orex(S, 1, r, 0, 0x89); /* mov %rsp, r */ | 1303 | orex(S, 1, r, 0, 0x89); /* mov %rsp, r */ |
| 1304 | o(S, 0xe0 + REG_VALUE(r)); | 1304 | o(S, 0xe0 + REG_VALUE(r)); |
| 1305 | vset(S, &S->vtop->type, r | VT_LVAL, 0); | 1305 | vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0); |
| 1306 | vswap(S); | 1306 | vswap(S); |
| 1307 | vstore(S); | 1307 | vstore(S); |
| 1308 | break; | 1308 | break; |
| @@ -1353,10 +1353,10 @@ void gfunc_call(TCCState *S, int nb_args) · 44 unmodified lines | |||
| 1353 | assert(gen_reg <= REGN); | 1353 | assert(gen_reg <= REGN); |
| 1354 | assert(sse_reg <= 8); | 1354 | assert(sse_reg <= 8); |
| 1355 | for(i = 0; i < nb_args; i++) { | 1355 | for(i = 0; i < nb_args; i++) { |
| 1356 | mode = classify_x86_64_arg(&S->vtop->type, &type, &size, &align, ®_count); | 1356 | mode = classify_x86_64_arg(&S->tccgen_vtop->type, &type, &size, &align, ®_count); |
| 1357 | if (size == 0) continue; | 1357 | if (size == 0) continue; |
| 1358 | /* Alter stack entry type so that gv() knows how to treat it */ | 1358 | /* Alter stack entry type so that gv() knows how to treat it */ |
| 1359 | S->vtop->type = type; | 1359 | S->tccgen_vtop->type = type; |
| 1360 | if (mode == x86_64_mode_sse) { | 1360 | if (mode == x86_64_mode_sse) { |
| 1361 | if (reg_count == 2) { | 1361 | if (reg_count == 2) { |
| 1362 | sse_reg -= 2; | 1362 | sse_reg -= 2; |
| @@ -1386,11 +1386,11 @@ void gfunc_call(TCCState *S, int nb_args) · 23 unmodified lines | |||
| 1386 | o(S, 0xc0 + REG_VALUE(r) * 8 + REG_VALUE(d)); | 1386 | o(S, 0xc0 + REG_VALUE(r) * 8 + REG_VALUE(d)); |
| 1387 | if (reg_count == 2) { | 1387 | if (reg_count == 2) { |
| 1388 | d = arg_prepare_reg(gen_reg+1); | 1388 | d = arg_prepare_reg(gen_reg+1); |
| 1389 | orex(S, 1,d,S->vtop->r2,0x89); /* mov */ | 1389 | orex(S, 1,d,S->tccgen_vtop->r2,0x89); /* mov */ |
| 1390 | o(S, 0xc0 + REG_VALUE(S->vtop->r2) * 8 + REG_VALUE(d)); | 1390 | o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r2) * 8 + REG_VALUE(d)); |
| 1391 | } | 1391 | } |
| 1392 | } | 1392 | } |
| 1393 | S->vtop--; | 1393 | S->tccgen_vtop--; |
| 1394 | } | 1394 | } |
| 1395 | assert(gen_reg == 0); | 1395 | assert(gen_reg == 0); |
| 1396 | assert(sse_reg == 0); | 1396 | assert(sse_reg == 0); |
| @@ -1409,23 +1409,23 @@ void gfunc_call(TCCState *S, int nb_args) · 12 unmodified lines | |||
| 1409 | } | 1409 | } |
| 1410 | } | 1410 | } |
| 1411 | 1411 | ||
| 1412 | if (S->vtop->type.ref->f.func_type != FUNC_NEW) /* implies FUNC_OLD or FUNC_ELLIPSIS */ | 1412 | if (S->tccgen_vtop->type.ref->f.func_type != FUNC_NEW) /* implies FUNC_OLD or FUNC_ELLIPSIS */ |
| 1413 | oad(S, 0xb8, nb_sse_args < 8 ? nb_sse_args : 8); /* mov nb_sse_args, %eax */ | 1413 | oad(S, 0xb8, nb_sse_args < 8 ? nb_sse_args : 8); /* mov nb_sse_args, %eax */ |
| 1414 | gcall_or_jmp(S, 0); | 1414 | gcall_or_jmp(S, 0); |
| 1415 | if (args_size) | 1415 | if (args_size) |
| 1416 | gadd_sp(S, args_size); | 1416 | gadd_sp(S, args_size); |
| 1417 | S->vtop--; | 1417 | S->tccgen_vtop--; |
| 1418 | } | 1418 | } |
| 1419 | 1419 | ||
| 1420 | #define FUNC_PROLOG_SIZE 11 | 1420 | #define FUNC_PROLOG_SIZE 11 |
| 1421 | 1421 | ||
| 1422 | static void push_arg_reg(TCCState *S, int i) { | 1422 | static void push_arg_reg(TCCState* S, int i) { |
| 1423 | S->loc -= 8; | 1423 | S->tccgen_loc -= 8; |
| 1424 | gen_modrm64(S, 0x89, arg_regs[i], VT_LOCAL, NULL, S->loc); | 1424 | gen_modrm64(S, 0x89, arg_regs[i], VT_LOCAL, NULL, S->tccgen_loc); |
| 1425 | } | 1425 | } |
| 1426 | 1426 | ||
| 1427 | /* generate function prolog of type 't' */ | 1427 | /* generate function prolog of type 't' */ |
| 1428 | void gfunc_prolog(TCCState *S, Sym *func_sym) | 1428 | void gfunc_prolog(TCCState* S, Sym *func_sym) |
| 1429 | { | 1429 | { |
| 1430 | CType *func_type = &func_sym->type; | 1430 | CType *func_type = &func_sym->type; |
| 1431 | X86_64_Mode mode, ret_mode; | 1431 | X86_64_Mode mode, ret_mode; |
| @@ -1436,9 +1436,9 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 4 unmodified lines | |||
| 1436 | 1436 | ||
| 1437 | sym = func_type->ref; | 1437 | sym = func_type->ref; |
| 1438 | addr = PTR_SIZE * 2; | 1438 | addr = PTR_SIZE * 2; |
| 1439 | S->loc = 0; | 1439 | S->tccgen_loc = 0; |
| 1440 | S->ind += FUNC_PROLOG_SIZE; | 1440 | S->tccgen_ind += FUNC_PROLOG_SIZE; |
| 1441 | S->x86_64_gen_func_sub_sp_offset = S->ind; | 1441 | S->x86_64_gen_func_sub_sp_offset = S->tccgen_ind; |
| 1442 | S->x86_64_gen_func_ret_sub = 0; | 1442 | S->x86_64_gen_func_ret_sub = 0; |
| 1443 | ret_mode = classify_x86_64_arg(&S->tccgen_func_vt, NULL, &size, &align, ®_count); | 1443 | ret_mode = classify_x86_64_arg(&S->tccgen_func_vt, NULL, &size, &align, ®_count); |
| 1444 | 1444 | ||
| @@ -1473,7 +1473,7 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 28 unmodified lines | |||
| 1473 | } | 1473 | } |
| 1474 | } | 1474 | } |
| 1475 | 1475 | ||
| 1476 | S->loc -= 24; | 1476 | S->tccgen_loc -= 24; |
| 1477 | /* movl $0x????????, -0x18(%rbp) */ | 1477 | /* movl $0x????????, -0x18(%rbp) */ |
| 1478 | o(S, 0xe845c7); | 1478 | o(S, 0xe845c7); |
| 1479 | gen_le32(S, seen_reg_num * 8); | 1479 | gen_le32(S, seen_reg_num * 8); |
| @@ -1493,14 +1493,14 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 13 unmodified lines | |||
| 1493 | 1493 | ||
| 1494 | /* save all register passing arguments */ | 1494 | /* save all register passing arguments */ |
| 1495 | for (i = 0; i < 8; i++) { | 1495 | for (i = 0; i < 8; i++) { |
| 1496 | S->loc -= 16; | 1496 | S->tccgen_loc -= 16; |
| 1497 | if (!S->nosse) { | 1497 | if (!S->nosse) { |
| 1498 | o(S, 0xd60f66); /* movq */ | 1498 | o(S, 0xd60f66); /* movq */ |
| 1499 | gen_modrm(S, 7 - i, VT_LOCAL, NULL, S->loc); | 1499 | gen_modrm(S, 7 - i, VT_LOCAL, NULL, S->tccgen_loc); |
| 1500 | } | 1500 | } |
| 1501 | /* movq $0, loc+8(%rbp) */ | 1501 | /* movq $0, loc+8(%rbp) */ |
| 1502 | o(S, 0x85c748); | 1502 | o(S, 0x85c748); |
| 1503 | gen_le32(S, S->loc + 8); | 1503 | gen_le32(S, S->tccgen_loc + 8); |
| 1504 | gen_le32(S, 0); | 1504 | gen_le32(S, 0); |
| 1505 | } | 1505 | } |
| 1506 | for (i = 0; i < REGN; i++) { | 1506 | for (i = 0; i < REGN; i++) { |
| @@ -1516,7 +1516,7 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 9 unmodified lines | |||
| 1516 | implicit pointer parameter */ | 1516 | implicit pointer parameter */ |
| 1517 | if (ret_mode == x86_64_mode_memory) { | 1517 | if (ret_mode == x86_64_mode_memory) { |
| 1518 | push_arg_reg(S, reg_param_index); | 1518 | push_arg_reg(S, reg_param_index); |
| 1519 | S->tccgen_func_vc = S->loc; | 1519 | S->tccgen_func_vc = S->tccgen_loc; |
| 1520 | reg_param_index++; | 1520 | reg_param_index++; |
| 1521 | } | 1521 | } |
| 1522 | /* define parameters */ | 1522 | /* define parameters */ |
| @@ -1529,8 +1529,8 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 6 unmodified lines | |||
| 1529 | tcc_error(S, "SSE disabled but floating point arguments used"); | 1529 | tcc_error(S, "SSE disabled but floating point arguments used"); |
| 1530 | if (sse_param_index + reg_count <= 8) { | 1530 | if (sse_param_index + reg_count <= 8) { |
| 1531 | /* save arguments passed by register */ | 1531 | /* save arguments passed by register */ |
| 1532 | S->loc -= reg_count * 8; | 1532 | S->tccgen_loc -= reg_count * 8; |
| 1533 | param_addr = S->loc; | 1533 | param_addr = S->tccgen_loc; |
| 1534 | for (i = 0; i < reg_count; ++i) { | 1534 | for (i = 0; i < reg_count; ++i) { |
| 1535 | o(S, 0xd60f66); /* movq */ | 1535 | o(S, 0xd60f66); /* movq */ |
| 1536 | gen_modrm(S, sse_param_index, VT_LOCAL, NULL, param_addr + i*8); | 1536 | gen_modrm(S, sse_param_index, VT_LOCAL, NULL, param_addr + i*8); |
| @@ -1553,8 +1553,8 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 16 unmodified lines | |||
| 1553 | case x86_64_mode_integer: { | 1553 | case x86_64_mode_integer: { |
| 1554 | if (reg_param_index + reg_count <= REGN) { | 1554 | if (reg_param_index + reg_count <= REGN) { |
| 1555 | /* save arguments passed by register */ | 1555 | /* save arguments passed by register */ |
| 1556 | S->loc -= reg_count * 8; | 1556 | S->tccgen_loc -= reg_count * 8; |
| 1557 | param_addr = S->loc; | 1557 | param_addr = S->tccgen_loc; |
| 1558 | for (i = 0; i < reg_count; ++i) { | 1558 | for (i = 0; i < reg_count; ++i) { |
| 1559 | gen_modrm64(S, 0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, param_addr + i*8); | 1559 | gen_modrm64(S, 0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, param_addr + i*8); |
| 1560 | ++reg_param_index; | 1560 | ++reg_param_index; |
| @@ -1579,7 +1579,7 @@ void gfunc_prolog(TCCState *S, Sym *func_sym) · 18 unmodified lines | |||
| 1579 | } | 1579 | } |
| 1580 | 1580 | ||
| 1581 | /* generate function epilog */ | 1581 | /* generate function epilog */ |
| 1582 | void gfunc_epilog(TCCState *S) | 1582 | void gfunc_epilog(TCCState* S) |
| 1583 | { | 1583 | { |
| 1584 | int v, saved_ind; | 1584 | int v, saved_ind; |
| 1585 | 1585 | ||
| @@ -1596,39 +1596,39 @@ void gfunc_epilog(TCCState *S) · 10 unmodified lines | |||
| 1596 | g(S, S->x86_64_gen_func_ret_sub >> 8); | 1596 | g(S, S->x86_64_gen_func_ret_sub >> 8); |
| 1597 | } | 1597 | } |
| 1598 | /* align local size to word & save local variables */ | 1598 | /* align local size to word & save local variables */ |
| 1599 | v = (-S->loc + 15) & -16; | 1599 | v = (-S->tccgen_loc + 15) & -16; |
| 1600 | saved_ind = S->ind; | 1600 | saved_ind = S->tccgen_ind; |
| 1601 | S->ind = S->x86_64_gen_func_sub_sp_offset - FUNC_PROLOG_SIZE; | 1601 | S->tccgen_ind = S->x86_64_gen_func_sub_sp_offset - FUNC_PROLOG_SIZE; |
| 1602 | o(S, 0xe5894855); /* push %rbp, mov %rsp, %rbp */ | 1602 | o(S, 0xe5894855); /* push %rbp, mov %rsp, %rbp */ |
| 1603 | o(S, 0xec8148); /* sub rsp, stacksize */ | 1603 | o(S, 0xec8148); /* sub rsp, stacksize */ |
| 1604 | gen_le32(S, v); | 1604 | gen_le32(S, v); |
| 1605 | S->ind = saved_ind; | 1605 | S->tccgen_ind = saved_ind; |
| 1606 | } | 1606 | } |
| 1607 | 1607 | ||
| 1608 | #endif /* not PE */ | 1608 | #endif /* not PE */ |
| 1609 | 1609 | ||
| 1610 | ST_FUNC void gen_fill_nops(TCCState *S, int bytes) | 1610 | ST_FUNC void gen_fill_nops(TCCState* S, int bytes) |
| 1611 | { | 1611 | { |
| 1612 | while (bytes--) | 1612 | while (bytes--) |
| 1613 | g(S, 0x90); | 1613 | g(S, 0x90); |
| 1614 | } | 1614 | } |
| 1615 | 1615 | ||
| 1616 | /* generate a jump to a label */ | 1616 | /* generate a jump to a label */ |
| 1617 | int gjmp(TCCState *S, int t) | 1617 | int gjmp(TCCState* S, int t) |
| 1618 | { | 1618 | { |
| 1619 | return gjmp2(S, 0xe9, t); | 1619 | return gjmp2(S, 0xe9, t); |
| 1620 | } | 1620 | } |
| 1621 | 1621 | ||
| 1622 | /* generate a jump to a fixed address */ | 1622 | /* generate a jump to a fixed address */ |
| 1623 | void gjmp_addr(TCCState *S, int a) | 1623 | void gjmp_addr(TCCState* S, int a) |
| 1624 | { | 1624 | { |
| 1625 | int r; | 1625 | int r; |
| 1626 | r = a - S->ind - 2; | 1626 | r = a - S->tccgen_ind - 2; |
| 1627 | if (r == (char)r) { | 1627 | if (r == (char)r) { |
| 1628 | g(S, 0xeb); | 1628 | g(S, 0xeb); |
| 1629 | g(S, r); | 1629 | g(S, r); |
| 1630 | } else { | 1630 | } else { |
| 1631 | oad(S, 0xe9, a - S->ind - 5); | 1631 | oad(S, 0xe9, a - S->tccgen_ind - 5); |
| 1632 | } | 1632 | } |
| 1633 | } | 1633 | } |
| 1634 | 1634 | ||
| @@ -1646,7 +1646,7 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t) · 11 unmodified lines | |||
| 1646 | return t; | 1646 | return t; |
| 1647 | } | 1647 | } |
| 1648 | 1648 | ||
| 1649 | ST_FUNC int gjmp_cond(TCCState *S, int op, int t) | 1649 | ST_FUNC int gjmp_cond(TCCState* S, int op, int t) |
| 1650 | { | 1650 | { |
| 1651 | if (op & 0x100) | 1651 | if (op & 0x100) |
| 1652 | { | 1652 | { |
| @@ -1657,7 +1657,7 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t) · 4 unmodified lines | |||
| 1657 | Take care about inverting the test. We need to jump | 1657 | Take care about inverting the test. We need to jump |
| 1658 | to our target if the result was unordered and test wasn't NE, | 1658 | to our target if the result was unordered and test wasn't NE, |
| 1659 | otherwise if unordered we don't want to jump. */ | 1659 | otherwise if unordered we don't want to jump. */ |
| 1660 | int v = S->vtop->cmp_r; | 1660 | int v = S->tccgen_vtop->cmp_r; |
| 1661 | op &= ~0x100; | 1661 | op &= ~0x100; |
| 1662 | if (op ^ v ^ (v != TOK_NE)) | 1662 | if (op ^ v ^ (v != TOK_NE)) |
| 1663 | o(S, 0x067a); /* jp +6 */ | 1663 | o(S, 0x067a); /* jp +6 */ |
| @@ -1673,26 +1673,26 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t) · 9 unmodified lines | |||
| 1673 | } | 1673 | } |
| 1674 | 1674 | ||
| 1675 | /* generate an integer binary operation */ | 1675 | /* generate an integer binary operation */ |
| 1676 | void gen_opi(TCCState *S, int op) | 1676 | void gen_opi(TCCState* S, int op) |
| 1677 | { | 1677 | { |
| 1678 | int r, fr, opc, c; | 1678 | int r, fr, opc, c; |
| 1679 | int ll, uu, cc; | 1679 | int ll, uu, cc; |
| 1680 | 1680 | ||
| 1681 | ll = is64_type(S->vtop[-1].type.t); | 1681 | ll = is64_type(S->tccgen_vtop[-1].type.t); |
| 1682 | uu = (S->vtop[-1].type.t & VT_UNSIGNED) != 0; | 1682 | uu = (S->tccgen_vtop[-1].type.t & VT_UNSIGNED) != 0; |
| 1683 | cc = (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST; | 1683 | cc = (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST; |
| 1684 | 1684 | ||
| 1685 | switch(op) { | 1685 | switch(op) { |
| 1686 | case '+': | 1686 | case '+': |
| 1687 | case TOK_ADDC1: /* add with carry generation */ | 1687 | case TOK_ADDC1: /* add with carry generation */ |
| 1688 | opc = 0; | 1688 | opc = 0; |
| 1689 | gen_op8: | 1689 | gen_op8: |
| 1690 | if (cc && (!ll || (int)S->vtop->c.i == S->vtop->c.i)) { | 1690 | if (cc && (!ll || (int)S->tccgen_vtop->c.i == S->tccgen_vtop->c.i)) { |
| 1691 | /* constant case */ | 1691 | /* constant case */ |
| 1692 | vswap(S); | 1692 | vswap(S); |
| 1693 | r = gv(S, RC_INT); | 1693 | r = gv(S, RC_INT); |
| 1694 | vswap(S); | 1694 | vswap(S); |
| 1695 | c = S->vtop->c.i; | 1695 | c = S->tccgen_vtop->c.i; |
| 1696 | if (c == (char)c) { | 1696 | if (c == (char)c) { |
| 1697 | /* XXX: generate inc and dec for smaller code ? */ | 1697 | /* XXX: generate inc and dec for smaller code ? */ |
| 1698 | orex(S, ll, r, 0, 0x83); | 1698 | orex(S, ll, r, 0, 0x83); |
| @@ -1704,12 +1704,12 @@ void gen_opi(TCCState *S, int op) · 5 unmodified lines | |||
| 1704 | } | 1704 | } |
| 1705 | } else { | 1705 | } else { |
| 1706 | gv2(S, RC_INT, RC_INT); | 1706 | gv2(S, RC_INT, RC_INT); |
| 1707 | r = S->vtop[-1].r; | 1707 | r = S->tccgen_vtop[-1].r; |
| 1708 | fr = S->vtop[0].r; | 1708 | fr = S->tccgen_vtop[0].r; |
| 1709 | orex(S, ll, r, fr, (opc << 3) | 0x01); | 1709 | orex(S, ll, r, fr, (opc << 3) | 0x01); |
| 1710 | o(S, 0xc0 + REG_VALUE(r) + REG_VALUE(fr) * 8); | 1710 | o(S, 0xc0 + REG_VALUE(r) + REG_VALUE(fr) * 8); |
| 1711 | } | 1711 | } |
| 1712 | S->vtop--; | 1712 | S->tccgen_vtop--; |
| 1713 | if (op >= TOK_ULT && op <= TOK_GT) | 1713 | if (op >= TOK_ULT && op <= TOK_GT) |
| 1714 | vset_VT_CMP(S, op); | 1714 | vset_VT_CMP(S, op); |
| 1715 | break; | 1715 | break; |
| @@ -1734,11 +1734,11 @@ void gen_opi(TCCState *S, int op) · 18 unmodified lines | |||
| 1734 | goto gen_op8; | 1734 | goto gen_op8; |
| 1735 | case '*': | 1735 | case '*': |
| 1736 | gv2(S, RC_INT, RC_INT); | 1736 | gv2(S, RC_INT, RC_INT); |
| 1737 | r = S->vtop[-1].r; | 1737 | r = S->tccgen_vtop[-1].r; |
| 1738 | fr = S->vtop[0].r; | 1738 | fr = S->tccgen_vtop[0].r; |
| 1739 | orex(S, ll, fr, r, 0xaf0f); /* imul fr, r */ | 1739 | orex(S, ll, fr, r, 0xaf0f); /* imul fr, r */ |
| 1740 | o(S, 0xc0 + REG_VALUE(fr) + REG_VALUE(r) * 8); | 1740 | o(S, 0xc0 + REG_VALUE(fr) + REG_VALUE(r) * 8); |
| 1741 | S->vtop--; | 1741 | S->tccgen_vtop--; |
| 1742 | break; | 1742 | break; |
| 1743 | case TOK_SHL: | 1743 | case TOK_SHL: |
| 1744 | opc = 4; | 1744 | opc = 4; |
| @@ -1757,15 +1757,15 @@ void gen_opi(TCCState *S, int op) · 12 unmodified lines | |||
| 1757 | vswap(S); | 1757 | vswap(S); |
| 1758 | orex(S, ll, r, 0, 0xc1); /* shl/shr/sar $xxx, r */ | 1758 | orex(S, ll, r, 0, 0xc1); /* shl/shr/sar $xxx, r */ |
| 1759 | o(S, opc | REG_VALUE(r)); | 1759 | o(S, opc | REG_VALUE(r)); |
| 1760 | g(S, S->vtop->c.i & (ll ? 63 : 31)); | 1760 | g(S, S->tccgen_vtop->c.i & (ll ? 63 : 31)); |
| 1761 | } else { | 1761 | } else { |
| 1762 | /* we generate the shift in ecx */ | 1762 | /* we generate the shift in ecx */ |
| 1763 | gv2(S, RC_INT, RC_RCX); | 1763 | gv2(S, RC_INT, RC_RCX); |
| 1764 | r = S->vtop[-1].r; | 1764 | r = S->tccgen_vtop[-1].r; |
| 1765 | orex(S, ll, r, 0, 0xd3); /* shl/shr/sar %cl, r */ | 1765 | orex(S, ll, r, 0, 0xd3); /* shl/shr/sar %cl, r */ |
| 1766 | o(S, opc | REG_VALUE(r)); | 1766 | o(S, opc | REG_VALUE(r)); |
| 1767 | } | 1767 | } |
| 1768 | S->vtop--; | 1768 | S->tccgen_vtop--; |
| 1769 | break; | 1769 | break; |
| 1770 | case TOK_UDIV: | 1770 | case TOK_UDIV: |
| 1771 | case TOK_UMOD: | 1771 | case TOK_UMOD: |
| @@ -1779,9 +1779,9 @@ void gen_opi(TCCState *S, int op) · 7 unmodified lines | |||
| 1779 | /* first operand must be in eax */ | 1779 | /* first operand must be in eax */ |
| 1780 | /* XXX: need better constraint for second operand */ | 1780 | /* XXX: need better constraint for second operand */ |
| 1781 | gv2(S, RC_RAX, RC_RCX); | 1781 | gv2(S, RC_RAX, RC_RCX); |
| 1782 | r = S->vtop[-1].r; | 1782 | r = S->tccgen_vtop[-1].r; |
| 1783 | fr = S->vtop[0].r; | 1783 | fr = S->tccgen_vtop[0].r; |
| 1784 | S->vtop--; | 1784 | S->tccgen_vtop--; |
| 1785 | save_reg(S, TREG_RDX); | 1785 | save_reg(S, TREG_RDX); |
| 1786 | orex(S, ll, 0, 0, uu ? 0xd231 : 0x99); /* xor %edx,%edx : cqto */ | 1786 | orex(S, ll, 0, 0, uu ? 0xd231 : 0x99); /* xor %edx,%edx : cqto */ |
| 1787 | orex(S, ll, fr, 0, 0xf7); /* div fr, %eax */ | 1787 | orex(S, ll, fr, 0, 0xf7); /* div fr, %eax */ |
| @@ -1790,7 +1790,7 @@ void gen_opi(TCCState *S, int op) · 2 unmodified lines | |||
| 1790 | r = TREG_RDX; | 1790 | r = TREG_RDX; |
| 1791 | else | 1791 | else |
| 1792 | r = TREG_RAX; | 1792 | r = TREG_RAX; |
| 1793 | S->vtop->r = r; | 1793 | S->tccgen_vtop->r = r; |
| 1794 | break; | 1794 | break; |
| 1795 | default: | 1795 | default: |
| 1796 | opc = 7; | 1796 | opc = 7; |
| @@ -1798,25 +1798,25 @@ void gen_opi(TCCState *S, int op) · 1 unmodified line | |||
| 1798 | } | 1798 | } |
| 1799 | } | 1799 | } |
| 1800 | 1800 | ||
| 1801 | void gen_opl(TCCState *S, int op) | 1801 | void gen_opl(TCCState* S, int op) |
| 1802 | { | 1802 | { |
| 1803 | gen_opi(S, op); | 1803 | gen_opi(S, op); |
| 1804 | } | 1804 | } |
| 1805 | 1805 | ||
| 1806 | void vpush_const(TCCState *S, int t, int v) | 1806 | void vpush_const(TCCState* S, int t, int v) |
| 1807 | { | 1807 | { |
| 1808 | CType ctype = { t | VT_CONSTANT, 0 }; | 1808 | CType ctype = { t | VT_CONSTANT, 0 }; |
| 1809 | vpushsym(S, &ctype, external_global_sym(S, v, &ctype)); | 1809 | vpushsym(S, &ctype, external_global_sym(S, v, &ctype)); |
| 1810 | S->vtop->r |= VT_LVAL; | 1810 | S->tccgen_vtop->r |= VT_LVAL; |
| 1811 | } | 1811 | } |
| 1812 | 1812 | ||
| 1813 | /* generate a floating point operation 'v = t1 op t2' instruction. The | 1813 | /* generate a floating point operation 'v = t1 op t2' instruction. The |
| 1814 | two operands are guaranteed to have the same floating point type */ | 1814 | two operands are guaranteed to have the same floating point type */ |
| 1815 | /* XXX: need to use ST1 too */ | 1815 | /* XXX: need to use ST1 too */ |
| 1816 | void gen_opf(TCCState *S, int op) | 1816 | void gen_opf(TCCState* S, int op) |
| 1817 | { | 1817 | { |
| 1818 | int a, ft, fc, swapped, r; | 1818 | int a, ft, fc, swapped, r; |
| 1819 | int bt = S->vtop->type.t & VT_BTYPE; | 1819 | int bt = S->tccgen_vtop->type.t & VT_BTYPE; |
| 1820 | int float_type = bt == VT_LDOUBLE ? RC_ST0 : RC_FLOAT; | 1820 | int float_type = bt == VT_LDOUBLE ? RC_ST0 : RC_FLOAT; |
| 1821 | 1821 | ||
| 1822 | if (op == TOK_NEG) { /* unary minus */ | 1822 | if (op == TOK_NEG) { /* unary minus */ |
| @@ -1830,24 +1830,24 @@ void gen_opf(TCCState *S, int op) · 7 unmodified lines | |||
| 1830 | if (bt == VT_DOUBLE) | 1830 | if (bt == VT_DOUBLE) |
| 1831 | o(S, 0x66); | 1831 | o(S, 0x66); |
| 1832 | /* xorp[sd] %xmm1, %xmm0 */ | 1832 | /* xorp[sd] %xmm1, %xmm0 */ |
| 1833 | o(S, 0xc0570f | (REG_VALUE(S->vtop[0].r) + REG_VALUE(S->vtop[-1].r)*8) << 16); | 1833 | o(S, 0xc0570f | (REG_VALUE(S->tccgen_vtop[0].r) + REG_VALUE(S->tccgen_vtop[-1].r)*8) << 16); |
| 1834 | S->vtop--; | 1834 | S->tccgen_vtop--; |
| 1835 | } | 1835 | } |
| 1836 | return; | 1836 | return; |
| 1837 | } | 1837 | } |
| 1838 | 1838 | ||
| 1839 | /* convert constants to memory references */ | 1839 | /* convert constants to memory references */ |
| 1840 | if ((S->vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { | 1840 | if ((S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| 1841 | vswap(S); | 1841 | vswap(S); |
| 1842 | gv(S, float_type); | 1842 | gv(S, float_type); |
| 1843 | vswap(S); | 1843 | vswap(S); |
| 1844 | } | 1844 | } |
| 1845 | if ((S->vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) | 1845 | if ((S->tccgen_vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) |
| 1846 | gv(S, float_type); | 1846 | gv(S, float_type); |
| 1847 | 1847 | ||
| 1848 | /* must put at least one value in the floating point register */ | 1848 | /* must put at least one value in the floating point register */ |
| 1849 | if ((S->vtop[-1].r & VT_LVAL) && | 1849 | if ((S->tccgen_vtop[-1].r & VT_LVAL) && |
| 1850 | (S->vtop[0].r & VT_LVAL)) { | 1850 | (S->tccgen_vtop[0].r & VT_LVAL)) { |
| 1851 | vswap(S); | 1851 | vswap(S); |
| 1852 | gv(S, float_type); | 1852 | gv(S, float_type); |
| 1853 | vswap(S); | 1853 | vswap(S); |
| @@ -1855,14 +1855,14 @@ void gen_opf(TCCState *S, int op) · 1 unmodified line | |||
| 1855 | swapped = 0; | 1855 | swapped = 0; |
| 1856 | /* swap the stack if needed so that t1 is the register and t2 is | 1856 | /* swap the stack if needed so that t1 is the register and t2 is |
| 1857 | the memory reference */ | 1857 | the memory reference */ |
| 1858 | if (S->vtop[-1].r & VT_LVAL) { | 1858 | if (S->tccgen_vtop[-1].r & VT_LVAL) { |
| 1859 | vswap(S); | 1859 | vswap(S); |
| 1860 | swapped = 1; | 1860 | swapped = 1; |
| 1861 | } | 1861 | } |
| 1862 | if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { | 1862 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { |
| 1863 | if (op >= TOK_ULT && op <= TOK_GT) { | 1863 | if (op >= TOK_ULT && op <= TOK_GT) { |
| 1864 | /* load on stack second operand */ | 1864 | /* load on stack second operand */ |
| 1865 | load(S, TREG_ST0, S->vtop); | 1865 | load(S, TREG_ST0, S->tccgen_vtop); |
| 1866 | save_reg(S, TREG_RAX); /* eax is used by FP comparison code */ | 1866 | save_reg(S, TREG_RAX); /* eax is used by FP comparison code */ |
| 1867 | if (op == TOK_GE || op == TOK_GT) | 1867 | if (op == TOK_GE || op == TOK_GT) |
| 1868 | swapped = !swapped; | 1868 | swapped = !swapped; |
| @@ -1889,11 +1889,11 @@ void gen_opf(TCCState *S, int op) · 20 unmodified lines | |||
| 1889 | o(S, 0x45c4f6); /* test $0x45, %ah */ | 1889 | o(S, 0x45c4f6); /* test $0x45, %ah */ |
| 1890 | op = TOK_EQ; | 1890 | op = TOK_EQ; |
| 1891 | } | 1891 | } |
| 1892 | S->vtop--; | 1892 | S->tccgen_vtop--; |
| 1893 | vset_VT_CMP(S, op); | 1893 | vset_VT_CMP(S, op); |
| 1894 | } else { | 1894 | } else { |
| 1895 | /* no memory reference possible for long double operations */ | 1895 | /* no memory reference possible for long double operations */ |
| 1896 | load(S, TREG_ST0, S->vtop); | 1896 | load(S, TREG_ST0, S->tccgen_vtop); |
| 1897 | swapped = !swapped; | 1897 | swapped = !swapped; |
| 1898 | 1898 | ||
| 1899 | switch(op) { | 1899 | switch(op) { |
| @@ -1915,17 +1915,17 @@ void gen_opf(TCCState *S, int op) · 15 unmodified lines | |||
| 1915 | a++; | 1915 | a++; |
| 1916 | break; | 1916 | break; |
| 1917 | } | 1917 | } |
| 1918 | ft = S->vtop->type.t; | 1918 | ft = S->tccgen_vtop->type.t; |
| 1919 | fc = S->vtop->c.i; | 1919 | fc = S->tccgen_vtop->c.i; |
| 1920 | o(S, 0xde); /* fxxxp %st, %st(1) */ | 1920 | o(S, 0xde); /* fxxxp %st, %st(1) */ |
| 1921 | o(S, 0xc1 + (a << 3)); | 1921 | o(S, 0xc1 + (a << 3)); |
| 1922 | S->vtop--; | 1922 | S->tccgen_vtop--; |
| 1923 | } | 1923 | } |
| 1924 | } else { | 1924 | } else { |
| 1925 | if (op >= TOK_ULT && op <= TOK_GT) { | 1925 | if (op >= TOK_ULT && op <= TOK_GT) { |
| 1926 | /* if saved lvalue, then we must reload it */ | 1926 | /* if saved lvalue, then we must reload it */ |
| 1927 | r = S->vtop->r; | 1927 | r = S->tccgen_vtop->r; |
| 1928 | fc = S->vtop->c.i; | 1928 | fc = S->tccgen_vtop->c.i; |
| 1929 | if ((r & VT_VALMASK) == VT_LLOCAL) { | 1929 | if ((r & VT_VALMASK) == VT_LLOCAL) { |
| 1930 | SValue v1; | 1930 | SValue v1; |
| 1931 | r = get_reg(S, RC_INT); | 1931 | r = get_reg(S, RC_INT); |
| @@ -1934,7 +1934,7 @@ void gen_opf(TCCState *S, int op) · 2 unmodified lines | |||
| 1934 | v1.c.i = fc; | 1934 | v1.c.i = fc; |
| 1935 | load(S, r, &v1); | 1935 | load(S, r, &v1); |
| 1936 | fc = 0; | 1936 | fc = 0; |
| 1937 | S->vtop->r = r = r | VT_LVAL; | 1937 | S->tccgen_vtop->r = r = r | VT_LVAL; |
| 1938 | } | 1938 | } |
| 1939 | 1939 | ||
| 1940 | if (op == TOK_EQ || op == TOK_NE) { | 1940 | if (op == TOK_EQ || op == TOK_NE) { |
| @@ -1953,26 +1953,26 @@ void gen_opf(TCCState *S, int op) · 12 unmodified lines | |||
| 1953 | gv(S, RC_FLOAT); | 1953 | gv(S, RC_FLOAT); |
| 1954 | vswap(S); | 1954 | vswap(S); |
| 1955 | } | 1955 | } |
| 1956 | assert(!(S->vtop[-1].r & VT_LVAL)); | 1956 | assert(!(S->tccgen_vtop[-1].r & VT_LVAL)); |
| 1957 | 1957 | ||
| 1958 | if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE) | 1958 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE) |
| 1959 | o(S, 0x66); | 1959 | o(S, 0x66); |
| 1960 | if (op == TOK_EQ || op == TOK_NE) | 1960 | if (op == TOK_EQ || op == TOK_NE) |
| 1961 | o(S, 0x2e0f); /* ucomisd */ | 1961 | o(S, 0x2e0f); /* ucomisd */ |
| 1962 | else | 1962 | else |
| 1963 | o(S, 0x2f0f); /* comisd */ | 1963 | o(S, 0x2f0f); /* comisd */ |
| 1964 | 1964 | ||
| 1965 | if (S->vtop->r & VT_LVAL) { | 1965 | if (S->tccgen_vtop->r & VT_LVAL) { |
| 1966 | gen_modrm(S, S->vtop[-1].r, r, S->vtop->sym, fc); | 1966 | gen_modrm(S, S->tccgen_vtop[-1].r, r, S->tccgen_vtop->sym, fc); |
| 1967 | } else { | 1967 | } else { |
| 1968 | o(S, 0xc0 + REG_VALUE(S->vtop[0].r) + REG_VALUE(S->vtop[-1].r)*8); | 1968 | o(S, 0xc0 + REG_VALUE(S->tccgen_vtop[0].r) + REG_VALUE(S->tccgen_vtop[-1].r)*8); |
| 1969 | } | 1969 | } |
| 1970 | 1970 | ||
| 1971 | S->vtop--; | 1971 | S->tccgen_vtop--; |
| 1972 | vset_VT_CMP(S, op | 0x100); | 1972 | vset_VT_CMP(S, op | 0x100); |
| 1973 | S->vtop->cmp_r = op; | 1973 | S->tccgen_vtop->cmp_r = op; |
| 1974 | } else { | 1974 | } else { |
| 1975 | assert((S->vtop->type.t & VT_BTYPE) != VT_LDOUBLE); | 1975 | assert((S->tccgen_vtop->type.t & VT_BTYPE) != VT_LDOUBLE); |
| 1976 | switch(op) { | 1976 | switch(op) { |
| 1977 | default: | 1977 | default: |
| 1978 | case '+': | 1978 | case '+': |
| @@ -1988,13 +1988,13 @@ void gen_opf(TCCState *S, int op) · 9 unmodified lines | |||
| 1988 | a = 6; | 1988 | a = 6; |
| 1989 | break; | 1989 | break; |
| 1990 | } | 1990 | } |
| 1991 | ft = S->vtop->type.t; | 1991 | ft = S->tccgen_vtop->type.t; |
| 1992 | fc = S->vtop->c.i; | 1992 | fc = S->tccgen_vtop->c.i; |
| 1993 | assert((ft & VT_BTYPE) != VT_LDOUBLE); | 1993 | assert((ft & VT_BTYPE) != VT_LDOUBLE); |
| 1994 | 1994 | ||
| 1995 | r = S->vtop->r; | 1995 | r = S->tccgen_vtop->r; |
| 1996 | /* if saved lvalue, then we must reload it */ | 1996 | /* if saved lvalue, then we must reload it */ |
| 1997 | if ((S->vtop->r & VT_VALMASK) == VT_LLOCAL) { | 1997 | if ((S->tccgen_vtop->r & VT_VALMASK) == VT_LLOCAL) { |
| 1998 | SValue v1; | 1998 | SValue v1; |
| 1999 | r = get_reg(S, RC_INT); | 1999 | r = get_reg(S, RC_INT); |
| 2000 | v1.type.t = VT_PTR; | 2000 | v1.type.t = VT_PTR; |
| @@ -2002,12 +2002,12 @@ void gen_opf(TCCState *S, int op) · 1 unmodified line | |||
| 2002 | v1.c.i = fc; | 2002 | v1.c.i = fc; |
| 2003 | load(S, r, &v1); | 2003 | load(S, r, &v1); |
| 2004 | fc = 0; | 2004 | fc = 0; |
| 2005 | S->vtop->r = r = r | VT_LVAL; | 2005 | S->tccgen_vtop->r = r = r | VT_LVAL; |
| 2006 | } | 2006 | } |
| 2007 | 2007 | ||
| 2008 | assert(!(S->vtop[-1].r & VT_LVAL)); | 2008 | assert(!(S->tccgen_vtop[-1].r & VT_LVAL)); |
| 2009 | if (swapped) { | 2009 | if (swapped) { |
| 2010 | assert(S->vtop->r & VT_LVAL); | 2010 | assert(S->tccgen_vtop->r & VT_LVAL); |
| 2011 | gv(S, RC_FLOAT); | 2011 | gv(S, RC_FLOAT); |
| 2012 | vswap(S); | 2012 | vswap(S); |
| 2013 | } | 2013 | } |
| @@ -2020,66 +2020,66 @@ void gen_opf(TCCState *S, int op) · 6 unmodified lines | |||
| 2020 | o(S, 0x0f); | 2020 | o(S, 0x0f); |
| 2021 | o(S, 0x58 + a); | 2021 | o(S, 0x58 + a); |
| 2022 | 2022 | ||
| 2023 | if (S->vtop->r & VT_LVAL) { | 2023 | if (S->tccgen_vtop->r & VT_LVAL) { |
| 2024 | gen_modrm(S, S->vtop[-1].r, r, S->vtop->sym, fc); | 2024 | gen_modrm(S, S->tccgen_vtop[-1].r, r, S->tccgen_vtop->sym, fc); |
| 2025 | } else { | 2025 | } else { |
| 2026 | o(S, 0xc0 + REG_VALUE(S->vtop[0].r) + REG_VALUE(S->vtop[-1].r)*8); | 2026 | o(S, 0xc0 + REG_VALUE(S->tccgen_vtop[0].r) + REG_VALUE(S->tccgen_vtop[-1].r)*8); |
| 2027 | } | 2027 | } |
| 2028 | 2028 | ||
| 2029 | S->vtop--; | 2029 | S->tccgen_vtop--; |
| 2030 | } | 2030 | } |
| 2031 | } | 2031 | } |
| 2032 | } | 2032 | } |
| 2033 | 2033 | ||
| 2034 | /* convert integers to fp 't' type. Must handle 'int', 'unsigned int' | 2034 | /* convert integers to fp 't' type. Must handle 'int', 'unsigned int' |
| 2035 | and 'long long' cases. */ | 2035 | and 'long long' cases. */ |
| 2036 | void gen_cvt_itof(TCCState *S, int t) | 2036 | void gen_cvt_itof(TCCState* S, int t) |
| 2037 | { | 2037 | { |
| 2038 | if ((t & VT_BTYPE) == VT_LDOUBLE) { | 2038 | if ((t & VT_BTYPE) == VT_LDOUBLE) { |
| 2039 | save_reg(S, TREG_ST0); | 2039 | save_reg(S, TREG_ST0); |
| 2040 | gv(S, RC_INT); | 2040 | gv(S, RC_INT); |
| 2041 | if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) { | 2041 | if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) { |
| 2042 | /* signed long long to float/double/long double (unsigned case | 2042 | /* signed long long to float/double/long double (unsigned case |
| 2043 | is handled generically) */ | 2043 | is handled generically) */ |
| 2044 | o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */ | 2044 | o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */ |
| 2045 | o(S, 0x242cdf); /* fildll (%rsp) */ | 2045 | o(S, 0x242cdf); /* fildll (%rsp) */ |
| 2046 | o(S, 0x08c48348); /* add $8, %rsp */ | 2046 | o(S, 0x08c48348); /* add $8, %rsp */ |
| 2047 | } else if ((S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == | 2047 | } else if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == |
| 2048 | (VT_INT | VT_UNSIGNED)) { | 2048 | (VT_INT | VT_UNSIGNED)) { |
| 2049 | /* unsigned int to float/double/long double */ | 2049 | /* unsigned int to float/double/long double */ |
| 2050 | o(S, 0x6a); /* push $0 */ | 2050 | o(S, 0x6a); /* push $0 */ |
| 2051 | g(S, 0x00); | 2051 | g(S, 0x00); |
| 2052 | o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */ | 2052 | o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */ |
| 2053 | o(S, 0x242cdf); /* fildll (%rsp) */ | 2053 | o(S, 0x242cdf); /* fildll (%rsp) */ |
| 2054 | o(S, 0x10c48348); /* add $16, %rsp */ | 2054 | o(S, 0x10c48348); /* add $16, %rsp */ |
| 2055 | } else { | 2055 | } else { |
| 2056 | /* int to float/double/long double */ | 2056 | /* int to float/double/long double */ |
| 2057 | o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */ | 2057 | o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */ |
| 2058 | o(S, 0x2404db); /* fildl (%rsp) */ | 2058 | o(S, 0x2404db); /* fildl (%rsp) */ |
| 2059 | o(S, 0x08c48348); /* add $8, %rsp */ | 2059 | o(S, 0x08c48348); /* add $8, %rsp */ |
| 2060 | } | 2060 | } |
| 2061 | S->vtop->r = TREG_ST0; | 2061 | S->tccgen_vtop->r = TREG_ST0; |
| 2062 | } else { | 2062 | } else { |
| 2063 | int r = get_reg(S, RC_FLOAT); | 2063 | int r = get_reg(S, RC_FLOAT); |
| 2064 | gv(S, RC_INT); | 2064 | gv(S, RC_INT); |
| 2065 | o(S, 0xf2 + ((t & VT_BTYPE) == VT_FLOAT?1:0)); | 2065 | o(S, 0xf2 + ((t & VT_BTYPE) == VT_FLOAT?1:0)); |
| 2066 | if ((S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == | 2066 | if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == |
| 2067 | (VT_INT | VT_UNSIGNED) || | 2067 | (VT_INT | VT_UNSIGNED) || |
| 2068 | (S->vtop->type.t & VT_BTYPE) == VT_LLONG) { | 2068 | (S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) { |
| 2069 | o(S, 0x48); /* REX */ | 2069 | o(S, 0x48); /* REX */ |
| 2070 | } | 2070 | } |
| 2071 | o(S, 0x2a0f); | 2071 | o(S, 0x2a0f); |
| 2072 | o(S, 0xc0 + (S->vtop->r & VT_VALMASK) + REG_VALUE(r)*8); /* cvtsi2sd */ | 2072 | o(S, 0xc0 + (S->tccgen_vtop->r & VT_VALMASK) + REG_VALUE(r)*8); /* cvtsi2sd */ |
| 2073 | S->vtop->r = r; | 2073 | S->tccgen_vtop->r = r; |
| 2074 | } | 2074 | } |
| 2075 | } | 2075 | } |
| 2076 | 2076 | ||
| 2077 | /* convert from one floating point type to another */ | 2077 | /* convert from one floating point type to another */ |
| 2078 | void gen_cvt_ftof(TCCState *S, int t) | 2078 | void gen_cvt_ftof(TCCState* S, int t) |
| 2079 | { | 2079 | { |
| 2080 | int ft, bt, tbt; | 2080 | int ft, bt, tbt; |
| 2081 | 2081 | ||
| 2082 | ft = S->vtop->type.t; | 2082 | ft = S->tccgen_vtop->type.t; |
| 2083 | bt = ft & VT_BTYPE; | 2083 | bt = ft & VT_BTYPE; |
| 2084 | tbt = t & VT_BTYPE; | 2084 | tbt = t & VT_BTYPE; |
| 2085 | 2085 | ||
| @@ -2087,33 +2087,33 @@ void gen_cvt_ftof(TCCState *S, int t) · 1 unmodified line | |||
| 2087 | gv(S, RC_FLOAT); | 2087 | gv(S, RC_FLOAT); |
| 2088 | if (tbt == VT_DOUBLE) { | 2088 | if (tbt == VT_DOUBLE) { |
| 2089 | o(S, 0x140f); /* unpcklps */ | 2089 | o(S, 0x140f); /* unpcklps */ |
| 2090 | o(S, 0xc0 + REG_VALUE(S->vtop->r)*9); | 2090 | o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r)*9); |
| 2091 | o(S, 0x5a0f); /* cvtps2pd */ | 2091 | o(S, 0x5a0f); /* cvtps2pd */ |
| 2092 | o(S, 0xc0 + REG_VALUE(S->vtop->r)*9); | 2092 | o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r)*9); |
| 2093 | } else if (tbt == VT_LDOUBLE) { | 2093 | } else if (tbt == VT_LDOUBLE) { |
| 2094 | save_reg(S, RC_ST0); | 2094 | save_reg(S, RC_ST0); |
| 2095 | /* movss %xmm0,-0x10(%rsp) */ | 2095 | /* movss %xmm0,-0x10(%rsp) */ |
| 2096 | o(S, 0x110ff3); | 2096 | o(S, 0x110ff3); |
| 2097 | o(S, 0x44 + REG_VALUE(S->vtop->r)*8); | 2097 | o(S, 0x44 + REG_VALUE(S->tccgen_vtop->r)*8); |
| 2098 | o(S, 0xf024); | 2098 | o(S, 0xf024); |
| 2099 | o(S, 0xf02444d9); /* flds -0x10(%rsp) */ | 2099 | o(S, 0xf02444d9); /* flds -0x10(%rsp) */ |
| 2100 | S->vtop->r = TREG_ST0; | 2100 | S->tccgen_vtop->r = TREG_ST0; |
| 2101 | } | 2101 | } |
| 2102 | } else if (bt == VT_DOUBLE) { | 2102 | } else if (bt == VT_DOUBLE) { |
| 2103 | gv(S, RC_FLOAT); | 2103 | gv(S, RC_FLOAT); |
| 2104 | if (tbt == VT_FLOAT) { | 2104 | if (tbt == VT_FLOAT) { |
| 2105 | o(S, 0x140f66); /* unpcklpd */ | 2105 | o(S, 0x140f66); /* unpcklpd */ |
| 2106 | o(S, 0xc0 + REG_VALUE(S->vtop->r)*9); | 2106 | o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r)*9); |
| 2107 | o(S, 0x5a0f66); /* cvtpd2ps */ | 2107 | o(S, 0x5a0f66); /* cvtpd2ps */ |
| 2108 | o(S, 0xc0 + REG_VALUE(S->vtop->r)*9); | 2108 | o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r)*9); |
| 2109 | } else if (tbt == VT_LDOUBLE) { | 2109 | } else if (tbt == VT_LDOUBLE) { |
| 2110 | save_reg(S, RC_ST0); | 2110 | save_reg(S, RC_ST0); |
| 2111 | /* movsd %xmm0,-0x10(%rsp) */ | 2111 | /* movsd %xmm0,-0x10(%rsp) */ |
| 2112 | o(S, 0x110ff2); | 2112 | o(S, 0x110ff2); |
| 2113 | o(S, 0x44 + REG_VALUE(S->vtop->r)*8); | 2113 | o(S, 0x44 + REG_VALUE(S->tccgen_vtop->r)*8); |
| 2114 | o(S, 0xf024); | 2114 | o(S, 0xf024); |
| 2115 | o(S, 0xf02444dd); /* fldl -0x10(%rsp) */ | 2115 | o(S, 0xf02444dd); /* fldl -0x10(%rsp) */ |
| 2116 | S->vtop->r = TREG_ST0; | 2116 | S->tccgen_vtop->r = TREG_ST0; |
| 2117 | } | 2117 | } |
| 2118 | } else { | 2118 | } else { |
| 2119 | int r; | 2119 | int r; |
| @@ -2125,23 +2125,23 @@ void gen_cvt_ftof(TCCState *S, int t) · 5 unmodified lines | |||
| 2125 | o(S, 0x100ff2); | 2125 | o(S, 0x100ff2); |
| 2126 | o(S, 0x44 + REG_VALUE(r)*8); | 2126 | o(S, 0x44 + REG_VALUE(r)*8); |
| 2127 | o(S, 0xf024); | 2127 | o(S, 0xf024); |
| 2128 | S->vtop->r = r; | 2128 | S->tccgen_vtop->r = r; |
| 2129 | } else if (tbt == VT_FLOAT) { | 2129 | } else if (tbt == VT_FLOAT) { |
| 2130 | o(S, 0xf0245cd9); /* fstps -0x10(%rsp) */ | 2130 | o(S, 0xf0245cd9); /* fstps -0x10(%rsp) */ |
| 2131 | /* movss -0x10(%rsp),%xmm0 */ | 2131 | /* movss -0x10(%rsp),%xmm0 */ |
| 2132 | o(S, 0x100ff3); | 2132 | o(S, 0x100ff3); |
| 2133 | o(S, 0x44 + REG_VALUE(r)*8); | 2133 | o(S, 0x44 + REG_VALUE(r)*8); |
| 2134 | o(S, 0xf024); | 2134 | o(S, 0xf024); |
| 2135 | S->vtop->r = r; | 2135 | S->tccgen_vtop->r = r; |
| 2136 | } | 2136 | } |
| 2137 | } | 2137 | } |
| 2138 | } | 2138 | } |
| 2139 | 2139 | ||
| 2140 | /* convert fp to int 't' type */ | 2140 | /* convert fp to int 't' type */ |
| 2141 | void gen_cvt_ftoi(TCCState *S, int t) | 2141 | void gen_cvt_ftoi(TCCState* S, int t) |
| 2142 | { | 2142 | { |
| 2143 | int ft, bt, size, r; | 2143 | int ft, bt, size, r; |
| 2144 | ft = S->vtop->type.t; | 2144 | ft = S->tccgen_vtop->type.t; |
| 2145 | bt = ft & VT_BTYPE; | 2145 | bt = ft & VT_BTYPE; |
| 2146 | if (bt == VT_LDOUBLE) { | 2146 | if (bt == VT_LDOUBLE) { |
| 2147 | gen_cvt_ftof(S, VT_DOUBLE); | 2147 | gen_cvt_ftof(S, VT_DOUBLE); |
| @@ -2163,12 +2163,12 @@ void gen_cvt_ftoi(TCCState *S, int t) · 15 unmodified lines | |||
| 2163 | assert(0); | 2163 | assert(0); |
| 2164 | } | 2164 | } |
| 2165 | orex(S, size == 8, r, 0, 0x2c0f); /* cvttss2si or cvttsd2si */ | 2165 | orex(S, size == 8, r, 0, 0x2c0f); /* cvttss2si or cvttsd2si */ |
| 2166 | o(S, 0xc0 + REG_VALUE(S->vtop->r) + REG_VALUE(r)*8); | 2166 | o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r) + REG_VALUE(r)*8); |
| 2167 | S->vtop->r = r; | 2167 | S->tccgen_vtop->r = r; |
| 2168 | } | 2168 | } |
| 2169 | 2169 | ||
| 2170 | // Generate sign extension from 32 to 64 bits: | 2170 | // Generate sign extension from 32 to 64 bits: |
| 2171 | ST_FUNC void gen_cvt_sxtw(TCCState *S) | 2171 | ST_FUNC void gen_cvt_sxtw(TCCState* S) |
| 2172 | { | 2172 | { |
| 2173 | int r = gv(S, RC_INT); | 2173 | int r = gv(S, RC_INT); |
| 2174 | /* x86_64 specific: movslq */ | 2174 | /* x86_64 specific: movslq */ |
| @@ -2177,13 +2177,13 @@ ST_FUNC void gen_cvt_sxtw(TCCState *S) · 2 unmodified lines | |||
| 2177 | } | 2177 | } |
| 2178 | 2178 | ||
| 2179 | /* char/short to int conversion */ | 2179 | /* char/short to int conversion */ |
| 2180 | ST_FUNC void gen_cvt_csti(TCCState *S, int t) | 2180 | ST_FUNC void gen_cvt_csti(TCCState* S, int t) |
| 2181 | { | 2181 | { |
| 2182 | int r, sz, xl, ll; | 2182 | int r, sz, xl, ll; |
| 2183 | r = gv(S, RC_INT); | 2183 | r = gv(S, RC_INT); |
| 2184 | sz = !(t & VT_UNSIGNED); | 2184 | sz = !(t & VT_UNSIGNED); |
| 2185 | xl = (t & VT_BTYPE) == VT_SHORT; | 2185 | xl = (t & VT_BTYPE) == VT_SHORT; |
| 2186 | ll = (S->vtop->type.t & VT_BTYPE) == VT_LLONG; | 2186 | ll = (S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG; |
| 2187 | orex(S, ll, r, 0, 0xc0b60f /* mov[sz] %a[xl], %eax */ | 2187 | orex(S, ll, r, 0, 0xc0b60f /* mov[sz] %a[xl], %eax */ |
| 2188 | | (sz << 3 | xl) << 8 | 2188 | | (sz << 3 | xl) << 8 |
| 2189 | | (REG_VALUE(r) << 3 | REG_VALUE(r)) << 16 | 2189 | | (REG_VALUE(r) << 3 | REG_VALUE(r)) << 16 |
| @@ -2191,42 +2191,42 @@ ST_FUNC void gen_cvt_csti(TCCState *S, int t) · 1 unmodified line | |||
| 2191 | } | 2191 | } |
| 2192 | 2192 | ||
| 2193 | /* increment tcov counter */ | 2193 | /* increment tcov counter */ |
| 2194 | ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv) | 2194 | ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv) |
| 2195 | { | 2195 | { |
| 2196 | o(S, 0x058348); /* addq $1, xxx(%rip) */ | 2196 | o(S, 0x058348); /* addq $1, xxx(%rip) */ |
| 2197 | greloca(S, cur_text_section, sv->sym, S->ind, R_X86_64_PC32, -5); | 2197 | greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_X86_64_PC32, -5); |
| 2198 | gen_le32(S, 0); | 2198 | gen_le32(S, 0); |
| 2199 | o(S, 1); | 2199 | o(S, 1); |
| 2200 | } | 2200 | } |
| 2201 | 2201 | ||
| 2202 | /* computed goto support */ | 2202 | /* computed goto support */ |
| 2203 | void ggoto(TCCState *S) | 2203 | void ggoto(TCCState* S) |
| 2204 | { | 2204 | { |
| 2205 | gcall_or_jmp(S, 1); | 2205 | gcall_or_jmp(S, 1); |
| 2206 | S->vtop--; | 2206 | S->tccgen_vtop--; |
| 2207 | } | 2207 | } |
| 2208 | 2208 | ||
| 2209 | /* Save the stack pointer onto the stack and return the location of its address */ | 2209 | /* Save the stack pointer onto the stack and return the location of its address */ |
| 2210 | ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) { | 2210 | ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) { |
| 2211 | /* mov %rsp,addr(%rbp)*/ | 2211 | /* mov %rsp,addr(%rbp)*/ |
| 2212 | gen_modrm64(S, 0x89, TREG_RSP, VT_LOCAL, NULL, addr); | 2212 | gen_modrm64(S, 0x89, TREG_RSP, VT_LOCAL, NULL, addr); |
| 2213 | } | 2213 | } |
| 2214 | 2214 | ||
| 2215 | /* Restore the SP from a location on the stack */ | 2215 | /* Restore the SP from a location on the stack */ |
| 2216 | ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) { | 2216 | ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) { |
| 2217 | gen_modrm64(S, 0x8b, TREG_RSP, VT_LOCAL, NULL, addr); | 2217 | gen_modrm64(S, 0x8b, TREG_RSP, VT_LOCAL, NULL, addr); |
| 2218 | } | 2218 | } |
| 2219 | 2219 | ||
| 2220 | #ifdef TCC_TARGET_PE | 2220 | #ifdef TCC_TARGET_PE |
| 2221 | /* Save result of gen_vla_alloc onto the stack */ | 2221 | /* Save result of gen_vla_alloc onto the stack */ |
| 2222 | ST_FUNC void gen_vla_result(TCCState *S, int addr) { | 2222 | ST_FUNC void gen_vla_result(TCCState* S, int addr) { |
| 2223 | /* mov %rax,addr(%rbp)*/ | 2223 | /* mov %rax,addr(%rbp)*/ |
| 2224 | gen_modrm64(S, 0x89, TREG_RAX, VT_LOCAL, NULL, addr); | 2224 | gen_modrm64(S, 0x89, TREG_RAX, VT_LOCAL, NULL, addr); |
| 2225 | } | 2225 | } |
| 2226 | #endif | 2226 | #endif |
| 2227 | 2227 | ||
| 2228 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ | 2228 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ |
| 2229 | ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) { | 2229 | ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) { |
| 2230 | int use_call = 0; | 2230 | int use_call = 0; |
| 2231 | 2231 | ||
| 2232 | #if defined(CONFIG_TCC_BCHECK) | 2232 | #if defined(CONFIG_TCC_BCHECK) |