summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormingodad <mingodad@gmail.com>2021-10-22 07:39:26 +0200
committermingodad <mingodad@gmail.com>2021-10-22 07:39:26 +0200
commit2ce2dbcb09b6c2455512ab9bd54a3be8b322c0e5 (patch)
tree53da0d8a37f433bf27e7c6494fd5e9cb29d8922b
parentd33f582e257f9fe1d8425641904eeb9bb08863fc (diff)
Revert "Fix some errors on arm64-asm.c, rename some variables, fix several code style declarations"
This reverts commit 61537d899af7bc163238ac21f666170ad84b6851.
-rw-r--r--arm-asm.c238
-rw-r--r--arm-gen.c374
-rw-r--r--arm64-asm.c46
-rw-r--r--arm64-gen.c284
-rw-r--r--c67-gen.c366
-rw-r--r--i386-asm.c104
-rw-r--r--i386-gen.c258
-rw-r--r--libtcc.c44
-rw-r--r--riscv64-asm.c74
-rw-r--r--riscv64-gen.c394
-rw-r--r--tcc.h327
-rw-r--r--tccasm.c246
-rw-r--r--tccelf.c20
-rw-r--r--tccgen.c1802
-rw-r--r--tccmacho.c14
-rw-r--r--tccpe.c6
-rw-r--r--tccpp.c710
-rw-r--r--x86_64-gen.c400
18 files changed, 2854 insertions, 2853 deletions
diff --git a/arm-asm.c b/arm-asm.c
index a041f2a..88a6d05 100644
--- a/arm-asm.c
+++ b/arm-asm.c
@@ -24,9 +24,9 @@
#define CONFIG_TCC_ASM
#define NB_ASM_REGS 16
-ST_FUNC void g(TCCState *S, int c);
-ST_FUNC void gen_le16(TCCState *S, int c);
-ST_FUNC void gen_le32(TCCState *S, int c);
+ST_FUNC void g(TCCState* S, int c);
+ST_FUNC void gen_le16(TCCState* S, int c);
+ST_FUNC void gen_le32(TCCState* S, int c);
/*************************************************************/
#else
@@ -100,10 +100,10 @@ static void parse_operand(TCCState *S, Operand *op)
op->type = 0;
- if (S->tok == '{') { // regset literal
+ if (S->tccpp_tok == '{') { // regset literal
next(S); // skip '{'
- while (S->tok != '}' && S->tok != TOK_EOF) {
- reg = asm_parse_regvar(S, S->tok);
+ while (S->tccpp_tok != '}' && S->tccpp_tok != TOK_EOF) {
+ reg = asm_parse_regvar(S, S->tccpp_tok);
if (reg == -1) {
expect(S, "register");
return;
@@ -113,11 +113,11 @@ static void parse_operand(TCCState *S, Operand *op)
if ((1 << reg) < regset)
tcc_warning(S, "registers will be processed in ascending order by hardware--but are not specified in ascending order here");
regset |= 1 << reg;
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
break;
next(S); // skip ','
}
- if (S->tok != '}')
+ if (S->tccpp_tok != '}')
expect(S, "'}'");
next(S); // skip '}'
if (regset == 0) {
@@ -128,22 +128,22 @@ static void parse_operand(TCCState *S, Operand *op)
op->regset = regset;
}
return;
- } else if ((reg = asm_parse_regvar(S, S->tok)) != -1) {
+ } else if ((reg = asm_parse_regvar(S, S->tccpp_tok)) != -1) {
next(S); // skip register name
op->type = OP_REG32;
op->reg = (uint8_t) reg;
return;
- } else if ((reg = asm_parse_vfp_regvar(S->tok, 0)) != -1) {
+ } else if ((reg = asm_parse_vfp_regvar(S->tccpp_tok, 0)) != -1) {
next(S); // skip register name
op->type = OP_VREG32;
op->reg = (uint8_t) reg;
return;
- } else if ((reg = asm_parse_vfp_regvar(S->tok, 1)) != -1) {
+ } else if ((reg = asm_parse_vfp_regvar(S->tccpp_tok, 1)) != -1) {
next(S); // skip register name
op->type = OP_VREG64;
op->reg = (uint8_t) reg;
return;
- } else if (S->tok == '#' || S->tok == '$') {
+ } else if (S->tccpp_tok == '#' || S->tccpp_tok == '$') {
/* constant value */
next(S); // skip '#' or '$'
}
@@ -160,44 +160,44 @@ static void parse_operand(TCCState *S, Operand *op)
}
/* XXX: make it faster ? */
-ST_FUNC void g(TCCState *S, int c)
+ST_FUNC void g(TCCState* S, int c)
{
int ind1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
- ind1 = S->ind + 1;
+ ind1 = S->tccgen_ind + 1;
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind] = c;
- S->ind = ind1;
+ cur_text_section->data[S->tccgen_ind] = c;
+ S->tccgen_ind = ind1;
}
-ST_FUNC void gen_le16 (TCCState *S, int i)
+ST_FUNC void gen_le16 (TCCState* S, int i)
{
g(S, i);
g(S, i>>8);
}
-ST_FUNC void gen_le32 (TCCState *S, int i)
+ST_FUNC void gen_le32 (TCCState* S, int i)
{
int ind1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
- ind1 = S->ind + 4;
+ ind1 = S->tccgen_ind + 4;
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind++] = i & 0xFF;
- cur_text_section->data[S->ind++] = (i >> 8) & 0xFF;
- cur_text_section->data[S->ind++] = (i >> 16) & 0xFF;
- cur_text_section->data[S->ind++] = (i >> 24) & 0xFF;
+ cur_text_section->data[S->tccgen_ind++] = i & 0xFF;
+ cur_text_section->data[S->tccgen_ind++] = (i >> 8) & 0xFF;
+ cur_text_section->data[S->tccgen_ind++] = (i >> 16) & 0xFF;
+ cur_text_section->data[S->tccgen_ind++] = (i >> 24) & 0xFF;
}
-ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe)
+ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe)
{
gen_le32(S, pe->v);
}
-static uint32_t condition_code_of_token(TCCState *S, int token) {
+static uint32_t condition_code_of_token(TCCState* S, int token) {
if (token < TOK_ASM_nopeq) {
expect(S, "condition-enabled instruction");
return 0;
@@ -205,15 +205,15 @@ static uint32_t condition_code_of_token(TCCState *S, int token) {
return (token - TOK_ASM_nopeq) & 15;
}
-static void asm_emit_opcode(TCCState *S, int token, uint32_t opcode) {
+static void asm_emit_opcode(TCCState* S, int token, uint32_t opcode) {
gen_le32(S, (condition_code_of_token(S, token) << 28) | opcode);
}
-static void asm_emit_unconditional_opcode(TCCState *S, uint32_t opcode) {
+static void asm_emit_unconditional_opcode(TCCState* S, uint32_t opcode) {
gen_le32(S, opcode);
}
-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)
+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)
{
uint32_t opcode = 0xe000000;
if (inter_processor_transfer)
@@ -233,7 +233,7 @@ static void asm_emit_coprocessor_opcode(TCCState *S, uint32_t high_nibble, uint8
asm_emit_unconditional_opcode(S, (high_nibble << 28) | opcode);
}
-static void asm_nullary_opcode(TCCState *S, int token)
+static void asm_nullary_opcode(TCCState* S, int token)
{
switch (ARM_INSTRUCTION_GROUP(token)) {
case TOK_ASM_nopeq:
@@ -276,7 +276,7 @@ static void asm_binary_opcode(TCCState *S, int token)
uint32_t encoded_rotation = 0;
uint64_t amount;
parse_operand(S, &ops[0]);
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -328,9 +328,9 @@ static void asm_binary_opcode(TCCState *S, int token)
if (ops[1].reg == 13)
tcc_warning(S, "Using 'sp' as operand with '%s' is deprecated by ARM", get_tok_str(S, token, NULL));
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S); // skip ','
- if (S->tok == TOK_ASM_ror) {
+ if (S->tccpp_tok == TOK_ASM_ror) {
next(S); // skip 'ror'
parse_operand(S, &rotation);
if (rotation.type != OP_IM8) {
@@ -387,15 +387,15 @@ static void asm_coprocessor_opcode(TCCState *S, int token) {
uint8_t high_nibble;
uint8_t mrc = 0;
- if (S->tok >= TOK_ASM_p0 && S->tok <= TOK_ASM_p15) {
- coprocessor = S->tok - TOK_ASM_p0;
+ if (S->tccpp_tok >= TOK_ASM_p0 && S->tccpp_tok <= TOK_ASM_p15) {
+ coprocessor = S->tccpp_tok - TOK_ASM_p0;
next(S);
} else {
expect(S, "'p<number>'");
return;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -407,21 +407,21 @@ static void asm_coprocessor_opcode(TCCState *S, int token) {
}
for (i = 0; i < 3; ++i) {
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
if (i == 0 && token != TOK_ASM_cdp2 && (ARM_INSTRUCTION_GROUP(token) == TOK_ASM_mrceq || ARM_INSTRUCTION_GROUP(token) == TOK_ASM_mcreq)) {
- if (S->tok >= TOK_ASM_r0 && S->tok <= TOK_ASM_r15) {
- registers[i] = S->tok - TOK_ASM_r0;
+ if (S->tccpp_tok >= TOK_ASM_r0 && S->tccpp_tok <= TOK_ASM_r15) {
+ registers[i] = S->tccpp_tok - TOK_ASM_r0;
next(S);
} else {
expect(S, "'r<number>'");
return;
}
} else {
- if (S->tok >= TOK_ASM_c0 && S->tok <= TOK_ASM_c15) {
- registers[i] = S->tok - TOK_ASM_c0;
+ if (S->tccpp_tok >= TOK_ASM_c0 && S->tccpp_tok <= TOK_ASM_c15) {
+ registers[i] = S->tccpp_tok - TOK_ASM_c0;
next(S);
} else {
expect(S, "'c<number>'");
@@ -429,7 +429,7 @@ static void asm_coprocessor_opcode(TCCState *S, int token) {
}
}
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
parse_operand(S, &opcode2);
} else {
@@ -493,11 +493,11 @@ static void asm_block_data_transfer_opcode(TCCState *S, int token)
Operand ops[2];
int nb_ops = 1;
parse_operand(S, &ops[0]);
- if (S->tok == '!') {
+ if (S->tccpp_tok == '!') {
op0_exclam = 1;
next(S); // skip '!'
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S); // skip comma
parse_operand(S, &ops[1]);
++nb_ops;
@@ -600,17 +600,17 @@ static void asm_block_data_transfer_opcode(TCCState *S, int token)
NB_SHIFT: will be set to 1 iff SHIFT is filled. Note that for rrx, there's no need to fill SHIFT.
SHIFT: will be filled in with the shift operand to use, if any. */
-static uint32_t asm_parse_optional_shift(TCCState *S, int* nb_shift, Operand* shift)
+static uint32_t asm_parse_optional_shift(TCCState* S, int* nb_shift, Operand* shift)
{
uint32_t opcode = 0;
*nb_shift = 0;
- switch (S->tok) {
+ switch (S->tccpp_tok) {
case TOK_ASM_asl:
case TOK_ASM_lsl:
case TOK_ASM_asr:
case TOK_ASM_lsr:
case TOK_ASM_ror:
- switch (S->tok) {
+ switch (S->tccpp_tok) {
case TOK_ASM_asl:
/* fallthrough */
case TOK_ASM_lsl:
@@ -677,15 +677,15 @@ static void asm_data_processing_opcode(TCCState *S, int token)
uint32_t opcode_nos = opcode_idx >> 1; // without "s"; "OpCode" in ARM docs
for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ) {
- 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)
+ 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)
break;
parse_operand(S, &ops[nb_ops]);
++nb_ops;
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
break;
next(S); // skip ','
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
operands |= asm_parse_optional_shift(S, &nb_shift, &shift);
if (nb_ops < 2)
@@ -852,7 +852,7 @@ static void asm_shift_opcode(TCCState *S, int token)
for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) {
parse_operand(S, &ops[nb_ops]);
- if (S->tok != ',') {
+ if (S->tccpp_tok != ',') {
++nb_ops;
break;
}
@@ -961,7 +961,7 @@ static void asm_multiplication_opcode(TCCState *S, int token)
for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) {
parse_operand(S, &ops[nb_ops]);
- if (S->tok != ',') {
+ if (S->tccpp_tok != ',') {
++nb_ops;
break;
}
@@ -1043,7 +1043,7 @@ static void asm_long_multiplication_opcode(TCCState *S, int token)
for (nb_ops = 0; nb_ops < sizeof(ops)/sizeof(ops[0]); ++nb_ops) {
parse_operand(S, &ops[nb_ops]);
- if (S->tok != ',') {
+ if (S->tccpp_tok != ',') {
++nb_ops;
break;
}
@@ -1133,7 +1133,7 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token)
expect(S, "(destination operand) register");
return;
}
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
expect(S, "at least two arguments");
else
next(S); // skip ','
@@ -1146,14 +1146,14 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token)
expect(S, "register");
return;
}
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
expect(S, "at least three arguments");
else
next(S); // skip ','
break;
}
- if (S->tok != '[')
+ if (S->tccpp_tok != '[')
expect(S, "'['");
else
next(S); // skip '['
@@ -1165,14 +1165,14 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token)
expect(S, "(first source operand) register");
return;
}
- if (S->tok == ']') {
+ if (S->tccpp_tok == ']') {
next(S);
closed_bracket = 1;
// exclam = 1; // implicit in hardware; don't do it in software
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S); // skip ','
- if (S->tok == '-') {
+ if (S->tccpp_tok == '-') {
op2_minus = 1;
next(S);
}
@@ -1182,7 +1182,7 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token)
tcc_error(S, "Using 'pc' for register offset in '%s' is not implemented by ARM", get_tok_str(S, token, NULL));
return;
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
opcode |= asm_parse_optional_shift(S, &nb_shift, &shift);
if (opcode == 0)
@@ -1196,12 +1196,12 @@ static void asm_single_data_transfer_opcode(TCCState *S, int token)
opcode |= 1 << 24; // add offset before transfer
}
if (!closed_bracket) {
- if (S->tok != ']')
+ if (S->tccpp_tok != ']')
expect(S, "']'");
else
next(S); // skip ']'
opcode |= 1 << 24; // add offset before transfer
- if (S->tok == '!') {
+ if (S->tccpp_tok == '!') {
exclam = 1;
next(S); // skip '!'
}
@@ -1389,33 +1389,33 @@ static void asm_coprocessor_data_transfer_opcode(TCCState *S, int token)
// Note: ldc p2, c0, [r4, #4]! ; pre-indexed: r0 = *(int*)(r4+4); r4 = r4+4
// Note: ldc p3, c0, [r4], #4 ; post-indexed: r0 = *(int*)(r4+0); r4 = r4+4
- if (S->tok >= TOK_ASM_p0 && S->tok <= TOK_ASM_p15) {
- coprocessor = S->tok - TOK_ASM_p0;
+ if (S->tccpp_tok >= TOK_ASM_p0 && S->tccpp_tok <= TOK_ASM_p15) {
+ coprocessor = S->tccpp_tok - TOK_ASM_p0;
next(S);
} else {
expect(S, "'c<number>'");
return;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
- if (S->tok >= TOK_ASM_c0 && S->tok <= TOK_ASM_c15) {
- coprocessor_destination_register = S->tok - TOK_ASM_c0;
+ if (S->tccpp_tok >= TOK_ASM_c0 && S->tccpp_tok <= TOK_ASM_c15) {
+ coprocessor_destination_register = S->tccpp_tok - TOK_ASM_c0;
next(S);
} else {
expect(S, "'c<number>'");
return;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
- if (S->tok != '[')
+ if (S->tccpp_tok != '[')
expect(S, "'['");
else
next(S); // skip '['
@@ -1425,14 +1425,14 @@ static void asm_coprocessor_data_transfer_opcode(TCCState *S, int token)
expect(S, "(first source operand) register");
return;
}
- if (S->tok == ']') {
+ if (S->tccpp_tok == ']') {
next(S);
closed_bracket = 1;
// exclam = 1; // implicit in hardware; don't do it in software
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S); // skip ','
- if (S->tok == '-') {
+ if (S->tccpp_tok == '-') {
op2_minus = 1;
next(S);
}
@@ -1453,12 +1453,12 @@ static void asm_coprocessor_data_transfer_opcode(TCCState *S, int token)
preincrement = 1; // add offset before transfer
}
if (!closed_bracket) {
- if (S->tok != ']')
+ if (S->tccpp_tok != ']')
expect(S, "']'");
else
next(S); // skip ']'
preincrement = 1; // add offset before transfer
- if (S->tok == '!') {
+ if (S->tccpp_tok == '!') {
exclam = 1;
next(S); // skip '!'
}
@@ -1528,12 +1528,12 @@ static void asm_floating_point_single_data_transfer_opcode(TCCState *S, int toke
return;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
- if (S->tok != '[')
+ if (S->tccpp_tok != '[')
expect(S, "'['");
else
next(S); // skip '['
@@ -1543,7 +1543,7 @@ static void asm_floating_point_single_data_transfer_opcode(TCCState *S, int toke
expect(S, "(first source operand) register");
return;
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S); // skip ','
parse_operand(S, &ops[2]);
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
ops[2].type = OP_IM8;
ops[2].e.v = 0;
}
- if (S->tok != ']')
+ if (S->tccpp_tok != ']')
expect(S, "']'");
else
next(S); // skip ']'
@@ -1593,11 +1593,11 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token
break;
default:
parse_operand(S, &ops[0]);
- if (S->tok == '!') {
+ if (S->tccpp_tok == '!') {
op0_exclam = 1;
next(S); // skip '!'
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S); // skip comma
else {
expect(S, "','");
@@ -1605,16 +1605,16 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token
}
}
- if (S->tok != '{') {
+ if (S->tccpp_tok != '{') {
expect(S, "'{'");
return;
}
next(S); // skip '{'
- first_regset_register = asm_parse_vfp_regvar(S->tok, 1);
- if ((first_regset_register = asm_parse_vfp_regvar(S->tok, 1)) != -1) {
+ first_regset_register = asm_parse_vfp_regvar(S->tccpp_tok, 1);
+ if ((first_regset_register = asm_parse_vfp_regvar(S->tccpp_tok, 1)) != -1) {
coprocessor = CP_DOUBLE_PRECISION_FLOAT;
next(S);
- } else if ((first_regset_register = asm_parse_vfp_regvar(S->tok, 0)) != -1) {
+ } else if ((first_regset_register = asm_parse_vfp_regvar(S->tccpp_tok, 0)) != -1) {
coprocessor = CP_SINGLE_PRECISION_FLOAT;
next(S);
} else {
@@ -1622,9 +1622,9 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token
return;
}
- if (S->tok == '-') {
+ if (S->tccpp_tok == '-') {
next(S);
- if ((last_regset_register = asm_parse_vfp_regvar(S->tok, coprocessor == CP_DOUBLE_PRECISION_FLOAT)) != -1)
+ if ((last_regset_register = asm_parse_vfp_regvar(S->tccpp_tok, coprocessor == CP_DOUBLE_PRECISION_FLOAT)) != -1)
next(S);
else {
expect(S, "floating-point register");
@@ -1637,7 +1637,7 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token
tcc_error(S, "registers will be processed in ascending order by hardware--but are not specified in ascending order here");
return;
}
- if (S->tok != '}') {
+ if (S->tccpp_tok != '}') {
expect(S, "'}'");
return;
}
@@ -1688,7 +1688,7 @@ static void asm_floating_point_block_data_transfer_opcode(TCCState *S, int token
#define VMOV_FRACTIONAL_DIGITS 7
#define VMOV_ONE 10000000 /* pow(10, VMOV_FRACTIONAL_DIGITS) */
-static uint32_t vmov_parse_fractional_part(TCCState *S, const char* s)
+static uint32_t vmov_parse_fractional_part(TCCState* S, const char* s)
{
uint32_t result = 0;
int i;
@@ -1720,16 +1720,16 @@ static int vmov_linear_approx_index(uint32_t beginning, uint32_t end, uint32_t v
return -1;
}
-static uint32_t vmov_parse_immediate_value(TCCState *S) {
+static uint32_t vmov_parse_immediate_value(TCCState* S) {
uint32_t value;
unsigned long integral_value;
const char *p;
- if (S->tok != TOK_PPNUM) {
+ if (S->tccpp_tok != TOK_PPNUM) {
expect(S, "immediate value");
return 0;
}
- p = S->tokc.str.data;
+ p = S->tccpp_tokc.str.data;
errno = 0;
integral_value = strtoul(p, (char **)&p, 0);
@@ -1747,7 +1747,7 @@ static uint32_t vmov_parse_immediate_value(TCCState *S) {
return value;
}
-static uint8_t vmov_encode_immediate_value(TCCState *S, uint32_t value)
+static uint8_t vmov_encode_immediate_value(TCCState* S, uint32_t value)
{
uint32_t limit;
uint32_t end = 0;
@@ -1785,10 +1785,10 @@ static void asm_floating_point_immediate_data_processing_opcode_tail(TCCState *S
operands[0] = CRd;
- if (S->tok == '#' || S->tok == '$') {
+ if (S->tccpp_tok == '#' || S->tccpp_tok == '$') {
next(S);
}
- if (S->tok == '-') {
+ if (S->tccpp_tok == '-') {
op_minus = 1;
next(S);
}
@@ -1956,7 +1956,7 @@ static void asm_floating_point_vcvt_data_processing_opcode(TCCState *S, int toke
break;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -2078,7 +2078,7 @@ static void asm_floating_point_data_processing_opcode(TCCState *S, int token) {
for (nb_ops = 0; nb_ops < 3; ) {
// Note: Necessary because parse_operand can't parse decimal numerals.
- if (nb_ops == 1 && (S->tok == '#' || S->tok == '$' || S->tok == TOK_PPNUM || S->tok == '-')) {
+ if (nb_ops == 1 && (S->tccpp_tok == '#' || S->tccpp_tok == '$' || S->tccpp_tok == TOK_PPNUM || S->tccpp_tok == '-')) {
asm_floating_point_immediate_data_processing_opcode_tail(S, token, coprocessor, ops[0].reg);
return;
}
@@ -2100,7 +2100,7 @@ static void asm_floating_point_data_processing_opcode(TCCState *S, int token) {
return;
}
++nb_ops;
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
break;
@@ -2239,7 +2239,7 @@ static void asm_floating_point_data_processing_opcode(TCCState *S, int token) {
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);
}
-static void asm_floating_point_status_register_opcode(TCCState *S, int token)
+static void asm_floating_point_status_register_opcode(TCCState* S, int token)
{
uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT;
uint8_t opcode;
@@ -2248,7 +2248,7 @@ static void asm_floating_point_status_register_opcode(TCCState *S, int token)
switch (ARM_INSTRUCTION_GROUP(token)) {
case TOK_ASM_vmrseq:
opcode = 0xf;
- if (S->tok == TOK_ASM_apsr_nzcv) {
+ if (S->tccpp_tok == TOK_ASM_apsr_nzcv) {
arm_operand.type = OP_REG32;
arm_operand.reg = 15; // not PC
next(S); // skip apsr_nzcv
@@ -2260,11 +2260,11 @@ static void asm_floating_point_status_register_opcode(TCCState *S, int token)
}
}
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
expect(S, "','");
else
next(S); // skip ','
- vfp_sys_reg = asm_parse_vfp_status_regvar(S->tok);
+ vfp_sys_reg = asm_parse_vfp_status_regvar(S->tccpp_tok);
next(S); // skip vfp sys reg
if (arm_operand.type == OP_REG32 && arm_operand.reg == 15 && vfp_sys_reg != 1) {
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)
break;
case TOK_ASM_vmsreq:
opcode = 0xe;
- vfp_sys_reg = asm_parse_vfp_status_regvar(S->tok);
+ vfp_sys_reg = asm_parse_vfp_status_regvar(S->tccpp_tok);
next(S); // skip vfp sys reg
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
expect(S, "','");
else
next(S); // skip ','
@@ -2329,12 +2329,12 @@ static void asm_misc_single_data_transfer_opcode(TCCState *S, int token)
expect(S, "(destination operand) register");
return;
}
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
expect(S, "at least two arguments");
else
next(S); // skip ','
- if (S->tok != '[')
+ if (S->tccpp_tok != '[')
expect(S, "'['");
else
next(S); // skip '['
@@ -2346,14 +2346,14 @@ static void asm_misc_single_data_transfer_opcode(TCCState *S, int token)
expect(S, "(first source operand) register");
return;
}
- if (S->tok == ']') {
+ if (S->tccpp_tok == ']') {
next(S);
closed_bracket = 1;
// exclam = 1; // implicit in hardware; don't do it in software
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S); // skip ','
- if (S->tok == '-') {
+ if (S->tccpp_tok == '-') {
op2_minus = 1;
next(S);
}
@@ -2365,12 +2365,12 @@ static void asm_misc_single_data_transfer_opcode(TCCState *S, int token)
opcode |= 1 << 24; // add offset before transfer
}
if (!closed_bracket) {
- if (S->tok != ']')
+ if (S->tccpp_tok != ']')
expect(S, "']'");
else
next(S); // skip ']'
opcode |= 1 << 24; // add offset before transfer
- if (S->tok == '!') {
+ if (S->tccpp_tok == '!') {
exclam = 1;
next(S); // skip '!'
}
@@ -2439,7 +2439,7 @@ static void asm_misc_single_data_transfer_opcode(TCCState *S, int token)
}
/* Note: almost dupe of encbranch in arm-gen.c */
-static uint32_t encbranchoffset(TCCState *S, int pos, int addr, int fail)
+static uint32_t encbranchoffset(TCCState* S, int pos, int addr, int fail)
{
addr-=pos+8;
addr/=4;
@@ -2467,7 +2467,7 @@ static void asm_branch_opcode(TCCState *S, int token)
tcc_error(S, "invalid branch target");
return;
}
- jmp_disp = encbranchoffset(S, S->ind, e.v + esym->st_value, 1);
+ jmp_disp = encbranchoffset(S, S->tccgen_ind, e.v + esym->st_value, 1);
break;
default:
parse_operand(S, &op);
@@ -2501,7 +2501,7 @@ ST_FUNC void asm_opcode(TCCState *S, int token)
{
while (token == TOK_LINEFEED) {
next(S);
- token = S->tok;
+ token = S->tccpp_tok;
}
if (token == TOK_EOF)
return;
@@ -2737,7 +2737,7 @@ ST_FUNC void asm_opcode(TCCState *S, int token)
}
}
-ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, SValue *sv, int modifier)
+ST_FUNC void subst_asm_operand(TCCState* S, CString *add_str, SValue *sv, int modifier)
{
int r, reg, size, val;
char buf[64];
@@ -2814,7 +2814,7 @@ ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, SValue *sv, int mo
}
/* generate prolog and epilog code for asm statement */
-ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands,
+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)
@@ -2900,7 +2900,7 @@ ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands,
/* return the constraint priority (we allocate first the lowest
numbered constraints) */
-static inline int constraint_priority(TCCState *S, const char *str)
+static inline int constraint_priority(TCCState* S, const char *str)
{
int priority, c, pr;
@@ -2956,7 +2956,7 @@ static const char *skip_constraint_modifiers(const char *p)
#define is_reg_allocated(reg) (regs_allocated[reg] & reg_mask)
-ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands,
+ST_FUNC void asm_compute_constraints(TCCState* S, ASMOperand *operands,
int nb_operands, int nb_outputs,
const uint8_t *clobber_regs,
int *pout_reg)
@@ -3191,7 +3191,7 @@ ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands,
#endif
}
-ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str)
+ST_FUNC void asm_clobber(TCCState* S, uint8_t *clobber_regs, const char *str)
{
int reg;
TokenSym *ts;
diff --git a/arm-gen.c b/arm-gen.c
index e6140ae..4a1b775 100644
--- a/arm-gen.c
+++ b/arm-gen.c
@@ -216,13 +216,13 @@ ST_FUNC void arm_init(struct TCCState *s)
#define CHECK_R(r) ((r) >= TREG_R0 && (r) <= TREG_LR)
-static int two2mask(TCCState *S, int a,int b) {
+static int two2mask(TCCState* S, int a,int b) {
if (!CHECK_R(a) || !CHECK_R(b))
tcc_error(S, "compiler error! registers %i,%i is not valid",a,b);
return (reg_classes[a]|reg_classes[b])&~(RC_INT|RC_FLOAT);
}
-static int regmask(TCCState *S, int r) {
+static int regmask(TCCState* S, int r) {
if (!CHECK_R(r))
tcc_error(S, "compiler error! register %i is not valid",r);
return reg_classes[r]&~(RC_INT|RC_FLOAT);
@@ -240,25 +240,25 @@ const char *default_elfinterp(struct TCCState *s)
}
#endif
-void o(TCCState *S, uint32_t i)
+void o(TCCState* S, uint32_t i)
{
/* this is a good place to start adding big-endian support*/
int ind1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
- ind1 = S->ind + 4;
+ ind1 = S->tccgen_ind + 4;
if (!cur_text_section)
tcc_error(S, "compiler error! This happens f.ex. if the compiler\n"
"can't evaluate constant expressions outside of a function.");
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind++] = i&255;
+ cur_text_section->data[S->tccgen_ind++] = i&255;
i>>=8;
- cur_text_section->data[S->ind++] = i&255;
+ cur_text_section->data[S->tccgen_ind++] = i&255;
i>>=8;
- cur_text_section->data[S->ind++] = i&255;
+ cur_text_section->data[S->tccgen_ind++] = i&255;
i>>=8;
- cur_text_section->data[S->ind++] = i;
+ cur_text_section->data[S->tccgen_ind++] = i;
}
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)
//only add,sub
-void stuff_const_harder(TCCState *S, uint32_t op, uint32_t v) {
+void stuff_const_harder(TCCState* S, uint32_t op, uint32_t v) {
uint32_t x;
x=stuff_const(op,v);
if(x)
@@ -371,7 +371,7 @@ void stuff_const_harder(TCCState *S, uint32_t op, uint32_t v) {
}
}
-uint32_t encbranch(TCCState *S, int pos, int addr, int fail)
+uint32_t encbranch(TCCState* S, int pos, int addr, int fail)
{
addr-=pos+8;
addr/=4;
@@ -383,7 +383,7 @@ uint32_t encbranch(TCCState *S, int pos, int addr, int fail)
return 0x0A000000|(addr&0xffffff);
}
-int decbranch(TCCState *S, int pos)
+int decbranch(TCCState* S, int pos)
{
int x;
x=*(uint32_t *)(cur_text_section->data + pos);
@@ -394,7 +394,7 @@ int decbranch(TCCState *S, int pos)
}
/* output a symbol and patch all calls to it */
-void gsym_addr(TCCState *S, int t, int a)
+void gsym_addr(TCCState* S, int t, int a)
{
uint32_t *x;
int lt;
@@ -411,14 +411,14 @@ void gsym_addr(TCCState *S, int t, int a)
}
#ifdef TCC_ARM_VFP
-static uint32_t vfpr(TCCState *S, int r)
+static uint32_t vfpr(TCCState* S, int r)
{
if(r<TREG_F0 || r>TREG_F7)
tcc_error(S, "compiler error! register %i is no vfp register",r);
return r - TREG_F0;
}
#else
-static uint32_t fpr(TCCState *S, int r)
+static uint32_t fpr(TCCState* S, int r)
{
if(r<TREG_F0 || r>TREG_F3)
tcc_error(S, "compiler error! register %i is no fpa register",r);
@@ -426,7 +426,7 @@ static uint32_t fpr(TCCState *S, int r)
}
#endif
-static uint32_t intr(TCCState *S, int r)
+static uint32_t intr(TCCState* S, int r)
{
if(r == TREG_R12)
return 12;
@@ -437,7 +437,7 @@ static uint32_t intr(TCCState *S, int r)
return r + (13 - TREG_SP);
}
-static void calcaddr(TCCState *S, uint32_t *base, int *off, int *sgn, int maxoff, unsigned shift)
+static void calcaddr(TCCState* S, uint32_t *base, int *off, int *sgn, int maxoff, unsigned shift)
{
if(*off>maxoff || *off&((1<<shift)-1)) {
uint32_t x, y;
@@ -464,7 +464,7 @@ static void calcaddr(TCCState *S, uint32_t *base, int *off, int *sgn, int maxoff
}
}
-static uint32_t mapcc(TCCState *S, int cc)
+static uint32_t mapcc(TCCState* S, int cc)
{
switch(cc)
{
@@ -497,7 +497,7 @@ static uint32_t mapcc(TCCState *S, int cc)
return 0xE0000000; /* AL */
}
-static int negcc(TCCState *S, int cc)
+static int negcc(TCCState* S, int cc)
{
switch(cc)
{
@@ -532,13 +532,13 @@ static int negcc(TCCState *S, int cc)
/* Load value into register r.
Use relative/got addressing to avoid setting DT_TEXTREL */
-static void load_value(TCCState *S, SValue *sv, int r)
+static void load_value(TCCState* S, SValue *sv, int r)
{
o(S, 0xE59F0000|(intr(S, r)<<12)); /* ldr r, [pc] */
o(S, 0xEA000000); /* b $+4 */
#ifndef CONFIG_TCC_PIE
if(sv->r & VT_SYM)
- greloc(S, cur_text_section, sv->sym, S->ind, R_ARM_ABS32);
+ greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_ARM_ABS32);
o(S, sv->c.i);
#else
if(sv->r & VT_SYM) {
@@ -563,7 +563,7 @@ static void load_value(TCCState *S, SValue *sv, int r)
}
/* load 'r' from value 'sv' */
-void load(TCCState *S, int r, SValue *sv)
+void load(TCCState* S, int r, SValue *sv)
{
int v, ft, fc, fr, sign;
uint32_t op;
@@ -696,7 +696,7 @@ void load(TCCState *S, int r, SValue *sv)
}
/* store register 'r' in lvalue 'v' */
-void store(TCCState *S, int r, SValue *sv)
+void store(TCCState* S, int r, SValue *sv)
{
SValue v1;
int v, ft, fc, fr, sign;
@@ -777,27 +777,27 @@ void store(TCCState *S, int r, SValue *sv)
tcc_error(S, "store unimplemented");
}
-static void gadd_sp(TCCState *S, int val)
+static void gadd_sp(TCCState* S, int val)
{
stuff_const_harder(S, 0xE28DD000,val);
}
/* 'is_jmp' is '1' if it is a jump */
-static void gcall_or_jmp(TCCState *S, int is_jmp)
+static void gcall_or_jmp(TCCState* S, int is_jmp)
{
int r;
uint32_t x;
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
/* constant case */
- if(S->vtop->r & VT_SYM){
- x=encbranch(S, S->ind, S->ind+S->vtop->c.i,0);
+ if(S->tccgen_vtop->r & VT_SYM){
+ x=encbranch(S, S->tccgen_ind, S->tccgen_ind+S->tccgen_vtop->c.i,0);
if(x) {
/* relocation case */
- greloc(S, cur_text_section, S->vtop->sym, S->ind, R_ARM_PC24);
+ greloc(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind, R_ARM_PC24);
o(S, x|(is_jmp?0xE0000000:0xE1000000));
} else {
r = TREG_LR;
- load_value(S, S->vtop, r);
+ load_value(S, S->tccgen_vtop, r);
if(is_jmp)
o(S, 0xE1A0F000 | intr(S, r)); // mov pc, r
else
@@ -807,12 +807,12 @@ static void gcall_or_jmp(TCCState *S, int is_jmp)
if(!is_jmp)
o(S, 0xE28FE004); // add lr,pc,#4
o(S, 0xE51FF004); // ldr pc,[pc,#-4]
- o(S, S->vtop->c.i);
+ o(S, S->tccgen_vtop->c.i);
}
} else {
/* otherwise, indirect call */
#ifdef CONFIG_TCC_BCHECK
- S->vtop->r &= ~VT_MUSTBOUND;
+ S->tccgen_vtop->r &= ~VT_MUSTBOUND;
#endif
r = gv(S, RC_INT);
if(!is_jmp)
@@ -823,19 +823,19 @@ static void gcall_or_jmp(TCCState *S, int is_jmp)
#if defined(CONFIG_TCC_BCHECK)
-static void gen_bounds_call(TCCState *S, int v)
+static void gen_bounds_call(TCCState* S, int v)
{
Sym *sym = external_helper_sym(S, v);
- greloc(S, cur_text_section, sym, S->ind, R_ARM_PC24);
+ greloc(S, cur_text_section, sym, S->tccgen_ind, R_ARM_PC24);
o(S, 0xebfffffe);
}
-static void gen_bounds_prolog(TCCState *S)
+static void gen_bounds_prolog(TCCState* S)
{
/* leave some room for bound checking code */
S->func_bound_offset = lbounds_section->data_offset;
- S->func_bound_ind = S->ind;
+ S->func_bound_ind = S->tccgen_ind;
S->func_bound_add_epilog = 0;
o(S, 0xe1a00000); /* ld r0,lbounds_section->data_offset */
o(S, 0xe1a00000);
@@ -844,7 +844,7 @@ static void gen_bounds_prolog(TCCState *S)
o(S, 0xe1a00000); /* call __bound_local_new */
}
-static void gen_bounds_epilog(TCCState *S)
+static void gen_bounds_epilog(TCCState* S)
{
addr_t saved_ind;
addr_t *bounds_ptr;
@@ -858,20 +858,20 @@ static void gen_bounds_epilog(TCCState *S)
bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t));
*bounds_ptr = 0;
- sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section,
+ sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section,
S->func_bound_offset, lbounds_section->data_offset);
/* generate bound local allocation */
if (offset_modified) {
- saved_ind = S->ind;
- S->ind = S->func_bound_ind;
+ saved_ind = S->tccgen_ind;
+ S->tccgen_ind = S->func_bound_ind;
o(S, 0xe59f0000); /* ldr r0, [pc] */
o(S, 0xea000000); /* b $+4 */
- greloc(S, cur_text_section, sym_data, S->ind, R_ARM_REL32);
+ greloc(S, cur_text_section, sym_data, S->tccgen_ind, R_ARM_REL32);
o(S, -12); /* lbounds_section->data_offset */
o(S, 0xe080000f); /* add r0,r0,pc */
gen_bounds_call(S, TOK___bound_local_new);
- S->ind = saved_ind;
+ S->tccgen_ind = saved_ind;
}
/* generate bound check local freeing */
@@ -879,7 +879,7 @@ static void gen_bounds_epilog(TCCState *S)
o(S, 0xed2d0b02); /* vpush {d0} */
o(S, 0xe59f0000); /* ldr r0, [pc] */
o(S, 0xea000000); /* b $+4 */
- greloc(S, cur_text_section, sym_data, S->ind, R_ARM_REL32);
+ greloc(S, cur_text_section, sym_data, S->tccgen_ind, R_ARM_REL32);
o(S, -12); /* lbounds_section->data_offset */
o(S, 0xe080000f); /* add r0,r0,pc */
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
for(i = nb_args; i-- ;) {
int j, start_vfpreg = 0;
- CType type = S->vtop[-i].type;
+ CType type = S->tccgen_vtop[-i].type;
type.t &= ~VT_ARRAY;
size = type_size(&type, &align);
size = (size + 3) & ~3;
align = (align + 3) & ~3;
- switch(S->vtop[-i].type.t & VT_BTYPE) {
+ switch(S->tccgen_vtop[-i].type.t & VT_BTYPE) {
case VT_STRUCT:
case VT_FLOAT:
case VT_DOUBLE:
@@ -1094,15 +1094,15 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla
if (float_abi == ARM_HARD_FLOAT) {
int is_hfa = 0; /* Homogeneous float aggregate */
- if (is_float(S->vtop[-i].type.t)
- || (is_hfa = is_hgen_float_aggr(&S->vtop[-i].type))) {
+ if (is_float(S->tccgen_vtop[-i].type.t)
+ || (is_hfa = is_hgen_float_aggr(&S->tccgen_vtop[-i].type))) {
int end_vfpreg;
start_vfpreg = assign_vfpreg(&avregs, align, size);
end_vfpreg = start_vfpreg + ((size - 1) >> 2);
if (start_vfpreg >= 0) {
add_param_plan(plan, is_hfa ? VFP_STRUCT_CLASS : VFP_CLASS,
- start_vfpreg, end_vfpreg, &S->vtop[-i]);
+ start_vfpreg, end_vfpreg, &S->tccgen_vtop[-i]);
continue;
} else
break;
@@ -1115,7 +1115,7 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla
* CORE_STRUCT_CLASS or the first of STACK_CLASS. */
for (j = ncrn; j < 4 && j < ncrn + size / 4; j++)
*todo|=(1<<j);
- add_param_plan(plan, CORE_STRUCT_CLASS, ncrn, j, &S->vtop[-i]);
+ add_param_plan(plan, CORE_STRUCT_CLASS, ncrn, j, &S->tccgen_vtop[-i]);
ncrn += size/4;
if (ncrn > 4)
nsaa = (ncrn - 4) * 4;
@@ -1126,20 +1126,20 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla
continue;
default:
if (ncrn < 4) {
- int is_long = (S->vtop[-i].type.t & VT_BTYPE) == VT_LLONG;
+ int is_long = (S->tccgen_vtop[-i].type.t & VT_BTYPE) == VT_LLONG;
if (is_long) {
ncrn = (ncrn + 1) & -2;
if (ncrn == 4)
break;
}
- add_param_plan(plan, CORE_CLASS, ncrn, ncrn + is_long, &S->vtop[-i]);
+ add_param_plan(plan, CORE_CLASS, ncrn, ncrn + is_long, &S->tccgen_vtop[-i]);
ncrn += 1 + is_long;
continue;
}
}
nsaa = (nsaa + (align - 1)) & ~(align - 1);
- add_param_plan(plan, STACK_CLASS, nsaa, nsaa + size, &S->vtop[-i]);
+ add_param_plan(plan, STACK_CLASS, nsaa, nsaa + size, &S->tccgen_vtop[-i]);
nsaa += size; /* size already rounded up before */
}
return nsaa;
@@ -1153,7 +1153,7 @@ static int assign_regs(TCCState *S, int nb_args, int float_abi, struct plan *pla
todo: a bitmap indicating what core reg will hold a parameter
Returns the number of SValue added by this function on the value stack */
-static int copy_params(TCCState *S, int nb_args, struct plan *plan, int todo)
+static int copy_params(TCCState* S, int nb_args, struct plan *plan, int todo)
{
int size, align, r, i, nb_extra_sval = 0;
struct param_plan *pplan;
@@ -1201,7 +1201,7 @@ again:
/* generate structure store */
r = get_reg(S, RC_INT);
o(S, 0xE28D0000|(intr(S, r)<<12)|padding); /* add r, sp, padding */
- vset(S, &S->vtop->type, r | VT_LVAL, 0);
+ vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0);
vswap(S);
/* XXX: optimize. Save all register because memcpy can use them */
o(S, 0xED2D0A00|(0&1)<<22|(0>>1)<<12|16); /* vpush {s0-s15} */
@@ -1255,7 +1255,7 @@ again:
size = 8;
r = gv(S, RC_INT);
o(S, 0xE52D0004|(intr(S, r)<<12)); /* push r */
- S->vtop--;
+ S->tccgen_vtop--;
}
r = gv(S, RC_INT);
o(S, 0xE52D0004|(intr(S, r)<<12)); /* push r */
@@ -1269,7 +1269,7 @@ again:
gv(S, regmask(S, TREG_F0 + (pplan->start >> 1)));
if (pplan->start & 1) { /* Must be in upper part of double register */
o(S, 0xEEF00A40|((pplan->start>>1)<<12)|(pplan->start>>1)); /* vmov.f32 s(n+1), sn */
- S->vtop->r = VT_CONST; /* avoid being saved on stack by gv for next float */
+ S->tccgen_vtop->r = VT_CONST; /* avoid being saved on stack by gv for next float */
}
break;
@@ -1277,16 +1277,16 @@ again:
if ((pplan->sval->type.t & VT_BTYPE) == VT_LLONG) {
lexpand(S);
gv(S, regmask(S, pplan->end));
- pplan->sval->r2 = S->vtop->r;
- S->vtop--;
+ pplan->sval->r2 = S->tccgen_vtop->r;
+ S->tccgen_vtop--;
}
gv(S, regmask(S, pplan->start));
/* Mark register as used so that gcall_or_jmp use another one
(regs >=4 are free as never used to pass parameters) */
- pplan->sval->r = S->vtop->r;
+ pplan->sval->r = S->tccgen_vtop->r;
break;
}
- S->vtop--;
+ S->tccgen_vtop--;
}
}
@@ -1312,7 +1312,7 @@ again:
if (todo & (1 << r)) {
nb_extra_sval++;
vpushi(S, 0);
- S->vtop->r = r;
+ S->tccgen_vtop->r = r;
}
}
}
@@ -1323,7 +1323,7 @@ again:
/* Generate function call. The function address is pushed first, then
all the parameters in call order. This functions pops all the
parameters and the function address. */
-void gfunc_call(TCCState *S, int nb_args)
+void gfunc_call(TCCState* S, int nb_args)
{
int r, args_size;
int def_float_abi = float_abi;
@@ -1340,15 +1340,15 @@ void gfunc_call(TCCState *S, int nb_args)
#ifdef TCC_ARM_EABI
if (float_abi == ARM_HARD_FLOAT) {
- variadic = (S->vtop[-nb_args].type.ref->f.func_type == FUNC_ELLIPSIS);
- if (variadic || floats_in_core_regs(&S->vtop[-nb_args]))
+ variadic = (S->tccgen_vtop[-nb_args].type.ref->f.func_type == FUNC_ELLIPSIS);
+ if (variadic || floats_in_core_regs(&S->tccgen_vtop[-nb_args]))
float_abi = ARM_SOFTFP_FLOAT;
}
#endif
/* cannot let cpu flags if other instruction are generated. Also avoid leaving
VT_JMP anywhere except on the top of the stack because it would complicate
the code generator. */
- r = S->vtop->r & VT_VALMASK;
+ r = S->tccgen_vtop->r & VT_VALMASK;
if (r == VT_CMP || (r & ~1) == VT_JMP)
gv(S, RC_INT);
@@ -1374,8 +1374,8 @@ void gfunc_call(TCCState *S, int nb_args)
if (args_size)
gadd_sp(S, args_size); /* pop all parameters passed on the stack */
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
- if(float_abi == ARM_SOFTFP_FLOAT && is_float(S->vtop->type.ref->type.t)) {
- if((S->vtop->type.ref->type.t & VT_BTYPE) == VT_FLOAT) {
+ if(float_abi == ARM_SOFTFP_FLOAT && is_float(S->tccgen_vtop->type.ref->type.t)) {
+ if((S->tccgen_vtop->type.ref->type.t & VT_BTYPE) == VT_FLOAT) {
o(S, 0xEE000A10); /*vmov s0, r0 */
} else {
o(S, 0xEE000B10); /* vmov.32 d0[0], r0 */
@@ -1383,13 +1383,13 @@ void gfunc_call(TCCState *S, int nb_args)
}
}
#endif
- S->vtop -= nb_args + 1; /* Pop all params and fct address from value stack */
+ S->tccgen_vtop -= nb_args + 1; /* Pop all params and fct address from value stack */
leaffunc = 0; /* we are calling a function, so we aren't in a leaf function */
float_abi = def_float_abi;
}
/* generate function prolog of type 't' */
-void gfunc_prolog(TCCState *S, Sym *func_sym)
+void gfunc_prolog(TCCState* S, Sym *func_sym)
{
CType *func_type = &func_sym->type;
Sym *sym,*sym2;
@@ -1443,7 +1443,7 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
}
o(S, 0xE92D5800); /* save fp, ip, lr */
o(S, 0xE1A0B00D); /* mov fp, sp */
- func_sub_sp_offset = S->ind;
+ func_sub_sp_offset = S->tccgen_ind;
o(S, 0xE1A00000); /* nop, leave space for stack adjustment in epilog */
#ifdef TCC_ARM_EABI
@@ -1490,7 +1490,7 @@ from_stack:
}
last_itod_magic=0;
leaffunc = 1;
- S->loc = 0;
+ S->tccgen_loc = 0;
#ifdef CONFIG_TCC_BCHECK
if (S->do_bounds_check)
gen_bounds_prolog(S);
@@ -1498,7 +1498,7 @@ from_stack:
}
/* generate function epilog */
-void gfunc_epilog(TCCState *S)
+void gfunc_epilog(TCCState* S)
{
uint32_t x;
int diff;
@@ -1520,7 +1520,7 @@ void gfunc_epilog(TCCState *S)
}
#endif
o(S, 0xE89BA800); /* restore fp, sp, pc */
- diff = (-S->loc + 3) & -4;
+ diff = (-S->tccgen_loc + 3) & -4;
#ifdef TCC_ARM_EABI
if(!leaffunc)
diff = ((diff + 11) & -8) - 4;
@@ -1531,7 +1531,7 @@ void gfunc_epilog(TCCState *S)
*(uint32_t *)(cur_text_section->data + func_sub_sp_offset) = x;
else {
int addr;
- addr=S->ind;
+ addr=S->tccgen_ind;
o(S, 0xE59FC004); /* ldr ip,[pc+4] */
o(S, 0xE04BD00C); /* sub sp,fp,ip */
o(S, 0xE1A0F00E); /* mov pc,lr */
@@ -1541,7 +1541,7 @@ void gfunc_epilog(TCCState *S)
}
}
-ST_FUNC void gen_fill_nops(TCCState *S, int bytes)
+ST_FUNC void gen_fill_nops(TCCState* S, int bytes)
{
if ((bytes & 3))
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)
}
/* generate a jump to a label */
-ST_FUNC int gjmp(TCCState *S, int t)
+ST_FUNC int gjmp(TCCState* S, int t)
{
int r;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return t;
- r=S->ind;
+ r=S->tccgen_ind;
o(S, 0xE0000000|encbranch(S, r,t,1));
return r;
}
/* generate a jump to a fixed address */
-ST_FUNC void gjmp_addr(TCCState *S, int a)
+ST_FUNC void gjmp_addr(TCCState* S, int a)
{
gjmp(S, a);
}
-ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
+ST_FUNC int gjmp_cond(TCCState* S, int op, int t)
{
int r;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return t;
- r=S->ind;
+ r=S->tccgen_ind;
op=mapcc(S, op);
op|=encbranch(S, r,t,1);
o(S, op);
return r;
}
-ST_FUNC int gjmp_append(TCCState *S, int n, int t)
+ST_FUNC int gjmp_append(TCCState* S, int n, int t)
{
uint32_t *x;
int p,lp;
@@ -1598,7 +1598,7 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t)
}
/* generate an integer binary operation */
-void gen_opi(TCCState *S, int op)
+void gen_opi(TCCState* S, int op)
{
int c, func = 0;
uint32_t opc = 0, r, fr;
@@ -1644,9 +1644,9 @@ void gen_opi(TCCState *S, int op)
break;
case '*':
gv2(S, RC_INT, RC_INT);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
- S->vtop--;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
+ S->tccgen_vtop--;
o(S, 0xE0000090|(intr(S, r)<<16)|(intr(S, r)<<8)|intr(S, fr));
return;
case TOK_SHL:
@@ -1690,11 +1690,11 @@ void gen_opi(TCCState *S, int op)
break;
case TOK_UMULL:
gv2(S, RC_INT, RC_INT);
- r=intr(S, S->vtop[-1].r2=get_reg(S, RC_INT));
- c=S->vtop[-1].r;
- S->vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, c));
- S->vtop--;
- o(S, 0xE0800090|(r<<16)|(intr(S, S->vtop->r)<<12)|(intr(S, c)<<8)|intr(S, S->vtop[1].r));
+ r=intr(S, S->tccgen_vtop[-1].r2=get_reg(S, RC_INT));
+ c=S->tccgen_vtop[-1].r;
+ S->tccgen_vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, c));
+ S->tccgen_vtop--;
+ o(S, 0xE0800090|(r<<16)|(intr(S, S->tccgen_vtop->r)<<12)|(intr(S, c)<<8)|intr(S, S->tccgen_vtop[1].r));
return;
default:
opc = 0x15;
@@ -1703,27 +1703,27 @@ void gen_opi(TCCState *S, int op)
}
switch(c) {
case 1:
- if((S->vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ if((S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
if(opc == 4 || opc == 5 || opc == 0xc) {
vswap(S);
opc|=2; // sub -> rsb
}
}
- if ((S->vtop->r & VT_VALMASK) == VT_CMP ||
- (S->vtop->r & (VT_VALMASK & ~1)) == VT_JMP)
+ if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP ||
+ (S->tccgen_vtop->r & (VT_VALMASK & ~1)) == VT_JMP)
gv(S, RC_INT);
vswap(S);
c=intr(S, gv(S, RC_INT));
vswap(S);
opc=0xE0000000|(opc<<20);
- if((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ if((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
uint32_t x;
- x=stuff_const(opc|0x2000000|(c<<16),S->vtop->c.i);
+ x=stuff_const(opc|0x2000000|(c<<16),S->tccgen_vtop->c.i);
if(x) {
if ((x & 0xfff00000) == 0xe3500000) // cmp rx,#c
o(S, x);
else {
- r=intr(S, S->vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, S->vtop[-1].r)));
+ r=intr(S, S->tccgen_vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, S->tccgen_vtop[-1].r)));
o(S, x|(r<<12));
}
goto done;
@@ -1731,7 +1731,7 @@ void gen_opi(TCCState *S, int op)
}
fr=intr(S, gv(S, RC_INT));
#ifdef CONFIG_TCC_BCHECK
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
c=intr(S, gv(S, RC_INT));
vswap(S);
@@ -1740,46 +1740,46 @@ void gen_opi(TCCState *S, int op)
if ((opc & 0xfff00000) == 0xe1500000) // cmp rx,ry
o(S, opc|(c<<16)|fr);
else {
- r=intr(S, S->vtop[-1].r=get_reg_ex(S, RC_INT,two2mask(S, S->vtop->r,S->vtop[-1].r)));
+ 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)));
o(S, opc|(c<<16)|(r<<12)|fr);
}
done:
- S->vtop--;
+ S->tccgen_vtop--;
if (op >= TOK_ULT && op <= TOK_GT)
vset_VT_CMP(S, op);
break;
case 2:
opc=0xE1A00000|(opc<<5);
- if ((S->vtop->r & VT_VALMASK) == VT_CMP ||
- (S->vtop->r & (VT_VALMASK & ~1)) == VT_JMP)
+ if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP ||
+ (S->tccgen_vtop->r & (VT_VALMASK & ~1)) == VT_JMP)
gv(S, RC_INT);
vswap(S);
r=intr(S, gv(S, RC_INT));
vswap(S);
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
- fr=intr(S, S->vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, S->vtop[-1].r)));
- c = S->vtop->c.i & 0x1f;
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ fr=intr(S, S->tccgen_vtop[-1].r=get_reg_ex(S, RC_INT,regmask(S, S->tccgen_vtop[-1].r)));
+ c = S->tccgen_vtop->c.i & 0x1f;
o(S, opc|r|(c<<7)|(fr<<12));
} else {
fr=intr(S, gv(S, RC_INT));
#ifdef CONFIG_TCC_BCHECK
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
r=intr(S, gv(S, RC_INT));
vswap(S);
}
#endif
- c=intr(S, S->vtop[-1].r=get_reg_ex(S, RC_INT,two2mask(S, S->vtop->r,S->vtop[-1].r)));
+ 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)));
o(S, opc|r|(c<<12)|(fr<<8)|0x10);
}
- S->vtop--;
+ S->tccgen_vtop--;
break;
case 3:
vpush_helper_func(S, func);
vrott(S, 3);
gfunc_call(S, 2);
vpushi(S, 0);
- S->vtop->r = retreg;
+ S->tccgen_vtop->r = retreg;
break;
default:
tcc_error(S, "gen_opi %i unimplemented!",op);
@@ -1787,30 +1787,30 @@ done:
}
#ifdef TCC_ARM_VFP
-static int is_zero(TCCState *S, int i)
+static int is_zero(TCCState* S, int i)
{
- if((S->vtop[i].r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
+ if((S->tccgen_vtop[i].r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
return 0;
- if (S->vtop[i].type.t == VT_FLOAT)
- return (S->vtop[i].c.f == 0.f);
- else if (S->vtop[i].type.t == VT_DOUBLE)
- return (S->vtop[i].c.d == 0.0);
- return (S->vtop[i].c.ld == 0.l);
+ if (S->tccgen_vtop[i].type.t == VT_FLOAT)
+ return (S->tccgen_vtop[i].c.f == 0.f);
+ else if (S->tccgen_vtop[i].type.t == VT_DOUBLE)
+ return (S->tccgen_vtop[i].c.d == 0.0);
+ return (S->tccgen_vtop[i].c.ld == 0.l);
}
/* generate a floating point operation 'v = t1 op t2' instruction. The
* two operands are guaranteed to have the same floating point type */
-void gen_opf(TCCState *S, int op)
+void gen_opf(TCCState* S, int op)
{
uint32_t x;
int fneg=0,r;
- x=0xEE000A00|T2CPR(S->vtop->type.t);
+ x=0xEE000A00|T2CPR(S->tccgen_vtop->type.t);
switch(op) {
case '+':
if(is_zero(S, -1))
vswap(S);
if(is_zero(S, 0)) {
- S->vtop--;
+ S->tccgen_vtop--;
return;
}
x|=0x300000;
@@ -1818,13 +1818,13 @@ void gen_opf(TCCState *S, int op)
case '-':
x|=0x300040;
if(is_zero(S, 0)) {
- S->vtop--;
+ S->tccgen_vtop--;
return;
}
if(is_zero(S, -1)) {
x|=0x810000; /* fsubX -> fnegX */
vswap(S);
- S->vtop--;
+ S->tccgen_vtop--;
fneg=1;
}
break;
@@ -1852,13 +1852,13 @@ void gen_opf(TCCState *S, int op)
if(op!=TOK_EQ && op!=TOK_NE)
x|=0x80; /* fcmpX -> fcmpeX */
if(is_zero(S, 0)) {
- S->vtop--;
+ S->tccgen_vtop--;
o(S, x|0x10000|(vfpr(S, gv(S, RC_FLOAT))<<12)); /* fcmp(e)X -> fcmp(e)zX */
} else {
gv2(S, RC_FLOAT,RC_FLOAT);
- x|=vfpr(S, S->vtop[0].r);
- o(S, x|(vfpr(S, S->vtop[-1].r) << 12));
- S->vtop--;
+ x|=vfpr(S, S->tccgen_vtop[0].r);
+ o(S, x|(vfpr(S, S->tccgen_vtop[-1].r) << 12));
+ S->tccgen_vtop--;
}
o(S, 0xEEF1FA10); /* fmstat */
@@ -1881,7 +1881,7 @@ void gen_opf(TCCState *S, int op)
x|=vfpr(S, r2)<<16;
r|=regmask(S, r2);
#ifdef CONFIG_TCC_BCHECK
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
r=gv(S, RC_FLOAT);
vswap(S);
@@ -1889,25 +1889,25 @@ void gen_opf(TCCState *S, int op)
}
#endif
}
- S->vtop->r=get_reg_ex(S, RC_FLOAT,r);
+ S->tccgen_vtop->r=get_reg_ex(S, RC_FLOAT,r);
if(!fneg)
- S->vtop--;
- o(S, x|(vfpr(S, S->vtop->r)<<12));
+ S->tccgen_vtop--;
+ o(S, x|(vfpr(S, S->tccgen_vtop->r)<<12));
}
#else
-static uint32_t is_fconst(TCCState *S)
+static uint32_t is_fconst(TCCState* S)
{
long double f;
uint32_t r;
- if((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
+ if((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
return 0;
- if (S->vtop->type.t == VT_FLOAT)
- f = S->vtop->c.f;
- else if (S->vtop->type.t == VT_DOUBLE)
- f = S->vtop->c.d;
+ if (S->tccgen_vtop->type.t == VT_FLOAT)
+ f = S->tccgen_vtop->c.f;
+ else if (S->tccgen_vtop->type.t == VT_DOUBLE)
+ f = S->tccgen_vtop->c.d;
else
- f = S->vtop->c.ld;
+ f = S->tccgen_vtop->c.ld;
if(!ieee_finite(f))
return 0;
r=0x8;
@@ -1936,7 +1936,7 @@ static uint32_t is_fconst(TCCState *S)
/* generate a floating point operation 'v = t1 op t2' instruction. The
two operands are guaranteed to have the same floating point type */
-void gen_opf(TCCState *S, int op)
+void gen_opf(TCCState* S, int op)
{
uint32_t x, r, r2, c1, c2;
//fputs("gen_opf\n",stderr);
@@ -1946,12 +1946,12 @@ void gen_opf(TCCState *S, int op)
c2 = is_fconst(S);
x=0xEE000100;
#if LDOUBLE_SIZE == 8
- if ((S->vtop->type.t & VT_BTYPE) != VT_FLOAT)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FLOAT)
x|=0x80;
#else
- if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE)
x|=0x80;
- else if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE)
+ else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE)
x|=0x80000;
#endif
switch(op)
@@ -1971,7 +1971,7 @@ void gen_opf(TCCState *S, int op)
} else {
r2=fpr(S, gv(S, RC_FLOAT));
#ifdef CONFIG_TCC_BCHECK
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
r=fpr(S, gv(S, RC_FLOAT));
vswap(S);
@@ -1999,7 +1999,7 @@ void gen_opf(TCCState *S, int op)
vswap(S);
r2=fpr(S, gv(S, RC_FLOAT));
#ifdef CONFIG_TCC_BCHECK
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
r=fpr(S, gv(S, RC_FLOAT));
vswap(S);
@@ -2020,7 +2020,7 @@ void gen_opf(TCCState *S, int op)
else {
r2=fpr(S, gv(S, RC_FLOAT));
#ifdef CONFIG_TCC_BCHECK
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
r=fpr(S, gv(S, RC_FLOAT));
vswap(S);
@@ -2048,7 +2048,7 @@ void gen_opf(TCCState *S, int op)
vswap(S);
r2=fpr(S, gv(S, RC_FLOAT));
#ifdef CONFIG_TCC_BCHECK
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
r=fpr(S, gv(S, RC_FLOAT));
vswap(S);
@@ -2107,65 +2107,65 @@ void gen_opf(TCCState *S, int op)
} else {
r2=fpr(S, gv(S, RC_FLOAT));
#ifdef CONFIG_TCC_BCHECK
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
r=fpr(S, gv(S, RC_FLOAT));
vswap(S);
}
#endif
}
- --S->vtop;
+ --S->tccgen_vtop;
vset_VT_CMP(S, op);
- ++S->vtop;
+ ++S->tccgen_vtop;
} else {
tcc_error(S, "unknown fp op %x!",op);
return;
}
}
- if(S->vtop[-1].r == VT_CMP)
+ if(S->tccgen_vtop[-1].r == VT_CMP)
c1=15;
else {
- c1=S->vtop->r;
+ c1=S->tccgen_vtop->r;
if(r2&0x8)
- c1=S->vtop[-1].r;
- S->vtop[-1].r=get_reg_ex(S, RC_FLOAT,two2mask(S, S->vtop[-1].r,c1));
- c1=fpr(S, S->vtop[-1].r);
+ c1=S->tccgen_vtop[-1].r;
+ S->tccgen_vtop[-1].r=get_reg_ex(S, RC_FLOAT,two2mask(S, S->tccgen_vtop[-1].r,c1));
+ c1=fpr(S, S->tccgen_vtop[-1].r);
}
- S->vtop--;
+ S->tccgen_vtop--;
o(S, x|(r<<16)|(c1<<12)|r2);
}
#endif
/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
and 'long long' cases. */
-ST_FUNC void gen_cvt_itof(TCCState *S, int t)
+ST_FUNC void gen_cvt_itof(TCCState* S, int t)
{
uint32_t r, r2;
int bt;
- bt=S->vtop->type.t & VT_BTYPE;
+ bt=S->tccgen_vtop->type.t & VT_BTYPE;
if(bt == VT_INT || bt == VT_SHORT || bt == VT_BYTE) {
#ifndef TCC_ARM_VFP
uint32_t dsize = 0;
#endif
r=intr(S, gv(S, RC_INT));
#ifdef TCC_ARM_VFP
- r2=vfpr(S, S->vtop->r=get_reg(S, RC_FLOAT));
+ r2=vfpr(S, S->tccgen_vtop->r=get_reg(S, RC_FLOAT));
o(S, 0xEE000A10|(r<<12)|(r2<<16)); /* fmsr */
r2|=r2<<12;
- if(!(S->vtop->type.t & VT_UNSIGNED))
+ if(!(S->tccgen_vtop->type.t & VT_UNSIGNED))
r2|=0x80; /* fuitoX -> fsituX */
o(S, 0xEEB80A40|r2|T2CPR(t)); /* fYitoX*/
#else
- r2=fpr(S, S->vtop->r=get_reg(S, RC_FLOAT));
+ r2=fpr(S, S->tccgen_vtop->r=get_reg(S, RC_FLOAT));
if((t & VT_BTYPE) != VT_FLOAT)
dsize=0x80; /* flts -> fltd */
o(S, 0xEE000110|dsize|(r2<<16)|(r<<12)); /* flts */
- if((S->vtop->type.t & (VT_UNSIGNED|VT_BTYPE)) == (VT_UNSIGNED|VT_INT)) {
+ if((S->tccgen_vtop->type.t & (VT_UNSIGNED|VT_BTYPE)) == (VT_UNSIGNED|VT_INT)) {
uint32_t off = 0;
o(S, 0xE3500000|(r<<12)); /* cmp */
r=fpr(S, get_reg(S, RC_FLOAT));
if(last_itod_magic) {
- off=S->ind+8-last_itod_magic;
+ off=S->tccgen_ind+8-last_itod_magic;
off/=4;
if(off>255)
off=0;
@@ -2173,7 +2173,7 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t)
o(S, 0xBD1F0100|(r<<12)|off); /* ldflts */
if(!off) {
o(S, 0xEA000000); /* b */
- last_itod_magic=S->ind;
+ last_itod_magic=S->tccgen_ind;
o(S, 0x4F800000); /* 4294967296.0f */
}
o(S, 0xBE000100|dsize|(r2<<16)|(r2<<12)|r); /* adflt */
@@ -2185,14 +2185,14 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t)
CType *func_type = 0;
if((t & VT_BTYPE) == VT_FLOAT) {
func_type = &S->armgen_func_float_type;
- if(S->vtop->type.t & VT_UNSIGNED)
+ if(S->tccgen_vtop->type.t & VT_UNSIGNED)
func=TOK___floatundisf;
else
func=TOK___floatdisf;
#if LDOUBLE_SIZE != 8
} else if((t & VT_BTYPE) == VT_LDOUBLE) {
func_type = &S->armgen_func_ldouble_type;
- if(S->vtop->type.t & VT_UNSIGNED)
+ if(S->tccgen_vtop->type.t & VT_UNSIGNED)
func=TOK___floatundixf;
else
func=TOK___floatdixf;
@@ -2201,7 +2201,7 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t)
} else if((t & VT_BTYPE) == VT_DOUBLE || (t & VT_BTYPE) == VT_LDOUBLE) {
#endif
func_type = &S->armgen_func_double_type;
- if(S->vtop->type.t & VT_UNSIGNED)
+ if(S->tccgen_vtop->type.t & VT_UNSIGNED)
func=TOK___floatundidf;
else
func=TOK___floatdidf;
@@ -2211,27 +2211,27 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t)
vswap(S);
gfunc_call(S, 1);
vpushi(S, 0);
- S->vtop->r=TREG_F0;
+ S->tccgen_vtop->r=TREG_F0;
return;
}
}
- tcc_error(S, "unimplemented gen_cvt_itof %x!",S->vtop->type.t);
+ tcc_error(S, "unimplemented gen_cvt_itof %x!",S->tccgen_vtop->type.t);
}
/* convert fp to int 't' type */
-void gen_cvt_ftoi(TCCState *S, int t)
+void gen_cvt_ftoi(TCCState* S, int t)
{
uint32_t r, r2;
int u, func = 0;
u=t&VT_UNSIGNED;
t&=VT_BTYPE;
- r2=S->vtop->type.t & VT_BTYPE;
+ r2=S->tccgen_vtop->type.t & VT_BTYPE;
if(t==VT_INT) {
#ifdef TCC_ARM_VFP
r=vfpr(S, gv(S, RC_FLOAT));
u=u?0:0x10000;
o(S, 0xEEBC0AC0|(r<<12)|r|T2CPR(r2)|u); /* ftoXizY */
- r2=intr(S, S->vtop->r=get_reg(S, RC_INT));
+ r2=intr(S, S->tccgen_vtop->r=get_reg(S, RC_INT));
o(S, 0xEE100A10|(r<<16)|(r2<<12));
return;
#else
@@ -2248,7 +2248,7 @@ void gen_cvt_ftoi(TCCState *S, int t)
func=TOK___fixunsdfsi;
} else {
r=fpr(S, gv(S, RC_FLOAT));
- r2=intr(S, S->vtop->r=get_reg(S, RC_INT));
+ r2=intr(S, S->tccgen_vtop->r=get_reg(S, RC_INT));
o(S, 0xEE100170|(r2<<12)|r);
return;
}
@@ -2271,20 +2271,20 @@ void gen_cvt_ftoi(TCCState *S, int t)
gfunc_call(S, 1);
vpushi(S, 0);
if(t == VT_LLONG)
- S->vtop->r2 = REG_IRE2;
- S->vtop->r = REG_IRET;
+ S->tccgen_vtop->r2 = REG_IRE2;
+ S->tccgen_vtop->r = REG_IRET;
return;
}
tcc_error(S, "unimplemented gen_cvt_ftoi!");
}
/* convert from one floating point type to another */
-void gen_cvt_ftof(TCCState *S, int t)
+void gen_cvt_ftof(TCCState* S, int t)
{
#ifdef TCC_ARM_VFP
- if(((S->vtop->type.t & VT_BTYPE) == VT_FLOAT) != ((t & VT_BTYPE) == VT_FLOAT)) {
+ if(((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FLOAT) != ((t & VT_BTYPE) == VT_FLOAT)) {
uint32_t r = vfpr(S, gv(S, RC_FLOAT));
- o(S, 0xEEB70AC0|(r<<12)|r|T2CPR(S->vtop->type.t));
+ o(S, 0xEEB70AC0|(r<<12)|r|T2CPR(S->tccgen_vtop->type.t));
}
#else
/* 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)
}
/* increment tcov counter */
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv)
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv)
{
int r1, r2;
vpushv(S, sv);
- S->vtop->r = r1 = get_reg(S, RC_INT);
+ S->tccgen_vtop->r = r1 = get_reg(S, RC_INT);
r2 = get_reg(S, RC_INT);
o(S, 0xE59F0000 | (intr(S, r1)<<12)); // ldr r1,[pc]
o(S, 0xEA000000); // b $+4
- greloc(S, cur_text_section, sv->sym, S->ind, R_ARM_REL32);
+ greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_ARM_REL32);
o(S, -12);
o(S, 0xe080000f | (intr(S, r1)<<16) | (intr(S, r1)<<12)); // add r1,r1,pc
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)
}
/* computed goto support */
-void ggoto(TCCState *S)
+void ggoto(TCCState* S)
{
gcall_or_jmp(S, 1);
- S->vtop--;
+ S->tccgen_vtop--;
}
/* Save the stack pointer onto the stack and return the location of its address */
-ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) {
+ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) {
SValue v;
v.type.t = VT_PTR;
v.r = VT_LOCAL | VT_LVAL;
@@ -2332,7 +2332,7 @@ ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) {
}
/* Restore the SP from a location on the stack */
-ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) {
+ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) {
SValue v;
v.type.t = VT_PTR;
v.r = VT_LOCAL | VT_LVAL;
@@ -2341,11 +2341,11 @@ ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) {
}
/* Subtract from the stack pointer, and push the resulting value onto the stack */
-ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) {
+ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) {
int r;
#if defined(CONFIG_TCC_BCHECK)
if (S->do_bounds_check)
- vpushv(S, S->vtop);
+ vpushv(S, S->tccgen_vtop);
#endif
r = intr(S, gv(S, RC_INT));
#if defined(CONFIG_TCC_BCHECK)
@@ -2367,8 +2367,8 @@ ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) {
#if defined(CONFIG_TCC_BCHECK)
if (S->do_bounds_check) {
vpushi(S, 0);
- S->vtop->r = TREG_R0;
- o(S, 0xe1a0000d | (S->vtop->r << 12)); // mov r0,sp
+ S->tccgen_vtop->r = TREG_R0;
+ o(S, 0xe1a0000d | (S->tccgen_vtop->r << 12)); // mov r0,sp
vswap(S);
vpush_helper_func(S, TOK___bound_new_region);
vrott(S, 3);
diff --git a/arm64-asm.c b/arm64-asm.c
index 7e31841..3c576a1 100644
--- a/arm64-asm.c
+++ b/arm64-asm.c
@@ -9,9 +9,9 @@
#define CONFIG_TCC_ASM
#define NB_ASM_REGS 16
-ST_FUNC void g(TCCState *S, int c);
-ST_FUNC void gen_le16(TCCState *S, int c);
-ST_FUNC void gen_le32(TCCState *S, int c);
+ST_FUNC void g(TCCState* S, int c);
+ST_FUNC void gen_le16(TCCState* S, int c);
+ST_FUNC void gen_le32(TCCState* S, int c);
/*************************************************************/
#else
@@ -19,74 +19,74 @@ ST_FUNC void gen_le32(TCCState *S, int c);
#define USING_GLOBALS
#include "tcc.h"
-static void asm_error(TCCState *S)
+static void asm_error(void)
{
- tcc_error(S, "ARM asm not implemented.");
+ tcc_error("ARM asm not implemented.");
}
/* XXX: make it faster ? */
-ST_FUNC void g(TCCState *S, int c)
+ST_FUNC void g(TCCState* S, int c)
{
int ind1;
- if (S->nocode_wanted)
+ if (nocode_wanted)
return;
- ind1 = S->ind + 1;
+ ind1 = ind + 1;
if (ind1 > cur_text_section->data_allocated)
- section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind] = c;
- S->ind = ind1;
+ section_realloc(cur_text_section, ind1);
+ cur_text_section->data[ind] = c;
+ ind = ind1;
}
-ST_FUNC void gen_le16 (TCCState *S, int i)
+ST_FUNC void gen_le16 (TCCState* S, int i)
{
g(S, i);
g(S, i>>8);
}
-ST_FUNC void gen_le32 (TCCState *S, int i)
+ST_FUNC void gen_le32 (TCCState* S, int i)
{
gen_le16(S, i);
gen_le16(S, i>>16);
}
-ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe)
+ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe)
{
gen_le32(S, pe->v);
}
ST_FUNC void asm_opcode(TCCState *S, int opcode)
{
- asm_error(S);
+ asm_error();
}
-ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, SValue *sv, int modifier)
+ST_FUNC void subst_asm_operand(CString *add_str, SValue *sv, int modifier)
{
- asm_error(S);
+ asm_error();
}
/* generate prolog and epilog code for asm statement */
-ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands,
+ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands,
int nb_outputs, int is_output,
uint8_t *clobber_regs,
int out_reg)
{
}
-ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands,
+ST_FUNC void asm_compute_constraints(ASMOperand *operands,
int nb_operands, int nb_outputs,
const uint8_t *clobber_regs,
int *pout_reg)
{
}
-ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str)
+ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str)
{
- asm_error(S);
+ asm_error();
}
-ST_FUNC int asm_parse_regvar (TCCState *S, int t)
+ST_FUNC int asm_parse_regvar (int t)
{
- asm_error(S);
+ asm_error();
return -1;
}
diff --git a/arm64-gen.c b/arm64-gen.c
index 40f0b60..7def111 100644
--- a/arm64-gen.c
+++ b/arm64-gen.c
@@ -107,13 +107,13 @@ static uint32_t fltr(int r)
// Add an instruction to text section:
ST_FUNC void o(TCCState *S, unsigned int c)
{
- int ind1 = S->ind + 4;
- if (S->nocode_wanted)
+ int ind1 = S->tccgen_ind + 4;
+ if (S->tccgen_nocode_wanted)
return;
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- write32le(cur_text_section->data + S->ind, c);
- S->ind = ind1;
+ write32le(cur_text_section->data + S->tccgen_ind, c);
+ S->tccgen_ind = ind1;
}
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)
static void arm64_sym(TCCState *S, int r, Sym *sym, unsigned long addend)
{
- greloca(S, cur_text_section, sym, S->ind, R_AARCH64_ADR_GOT_PAGE, 0);
+ greloca(S, cur_text_section, sym, S->tccgen_ind, R_AARCH64_ADR_GOT_PAGE, 0);
o(S, 0x90000000 | r); // adrp xr, #sym
- greloca(S, cur_text_section, sym, S->ind, R_AARCH64_LD64_GOT_LO12_NC, 0);
+ greloca(S, cur_text_section, sym, S->tccgen_ind, R_AARCH64_LD64_GOT_LO12_NC, 0);
o(S, 0xf9400000 | r | (r << 5)); // ld xr,[xr, #sym]
if (addend) {
// add xr, xr, #addend
@@ -654,14 +654,14 @@ ST_FUNC void store(TCCState *S, int r, SValue *sv)
static void arm64_gen_bl_or_b(TCCState *S, int b)
{
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && (S->vtop->r & VT_SYM)) {
- greloca(S, cur_text_section, S->vtop->sym, S->ind,
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && (S->tccgen_vtop->r & VT_SYM)) {
+ greloca(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind,
b ? R_AARCH64_JUMP26 : R_AARCH64_CALL26, 0);
o(S, 0x14000000 | (uint32_t)!b << 31); // b/bl .
}
else {
#ifdef CONFIG_TCC_BCHECK
- S->vtop->r &= ~VT_MUSTBOUND;
+ S->tccgen_vtop->r &= ~VT_MUSTBOUND;
#endif
o(S, 0xd61f0000 | (uint32_t)!b << 21 | intr(S, gv(S, RC_R30)) << 5); // br/blr
}
@@ -673,7 +673,7 @@ static void gen_bounds_call(TCCState *S, int v)
{
Sym *sym = external_helper_sym(S, v);
- greloca(S, cur_text_section, sym, S->ind, R_AARCH64_CALL26, 0);
+ greloca(S, cur_text_section, sym, S->tccgen_ind, R_AARCH64_CALL26, 0);
o(S, 0x94000000); // bl
}
@@ -681,7 +681,7 @@ static void gen_bounds_prolog(TCCState *S)
{
/* leave some room for bound checking code */
S->func_bound_offset = lbounds_section->data_offset;
- S->func_bound_ind = S->ind;
+ S->func_bound_ind = S->tccgen_ind;
S->func_bound_add_epilog = 0;
o(S, 0xd503201f); /* nop -> mov x0, lbound section pointer */
o(S, 0xd503201f);
@@ -703,27 +703,27 @@ static void gen_bounds_epilog(TCCState *S)
bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t));
*bounds_ptr = 0;
- sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section,
+ sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section,
S->func_bound_offset, lbounds_section->data_offset);
/* generate bound local allocation */
if (offset_modified) {
- saved_ind = S->ind;
- S->ind = S->func_bound_ind;
- greloca(S, cur_text_section, sym_data, S->ind, R_AARCH64_ADR_GOT_PAGE, 0);
+ saved_ind = S->tccgen_ind;
+ S->tccgen_ind = S->func_bound_ind;
+ greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_AARCH64_ADR_GOT_PAGE, 0);
o(S, 0x90000000 | 0); // adrp x0, #sym_data
- greloca(S, cur_text_section, sym_data, S->ind, R_AARCH64_LD64_GOT_LO12_NC, 0);
+ greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_AARCH64_LD64_GOT_LO12_NC, 0);
o(S, 0xf9400000 | 0 | (0 << 5)); // ld x0,[x0, #sym_data]
gen_bounds_call(S, TOK___bound_local_new);
- S->ind = saved_ind;
+ S->tccgen_ind = saved_ind;
}
/* generate bound check local freeing */
o(S, 0xf81f0fe0); /* str x0, [sp, #-16]! */
o(S, 0x3c9f0fe0); /* str q0, [sp, #-16]! */
- greloca(S, cur_text_section, sym_data, S->ind, R_AARCH64_ADR_GOT_PAGE, 0);
+ greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_AARCH64_ADR_GOT_PAGE, 0);
o(S, 0x90000000 | 0); // adrp x0, #sym_data
- greloca(S, cur_text_section, sym_data, S->ind, R_AARCH64_LD64_GOT_LO12_NC, 0);
+ greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_AARCH64_LD64_GOT_LO12_NC, 0);
o(S, 0xf9400000 | 0 | (0 << 5)); // ld x0,[x0, #sym_data]
gen_bounds_call(S, TOK___bound_local_delete);
o(S, 0x3cc107e0); /* ldr q0, [sp], #16 */
@@ -977,7 +977,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
gbound_args(S, nb_args);
#endif
- return_type = &S->vtop[-nb_args].type.ref->type;
+ return_type = &S->tccgen_vtop[-nb_args].type.ref->type;
if ((return_type->t & VT_BTYPE) == VT_STRUCT)
--nb_args;
@@ -987,14 +987,14 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
t[0] = return_type;
for (i = 0; i < nb_args; i++)
- t[nb_args - i] = &S->vtop[-i].type;
+ t[nb_args - i] = &S->tccgen_vtop[-i].type;
stack = arm64_pcs(nb_args, t, a);
// Allocate space for structs replaced by pointer:
for (i = nb_args; i; i--)
if (a[i] & 1) {
- SValue *arg = &S->vtop[i - nb_args];
+ SValue *arg = &S->tccgen_vtop[i - nb_args];
int align, size = type_size(&arg->type, &align);
assert((arg->type.t & VT_BTYPE) == VT_STRUCT);
stack = (stack + align - 1) & -align;
@@ -1005,7 +1005,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
stack = (stack + 15) >> 4 << 4;
/* fetch cpu flag before generating any code */
- if ((S->vtop->r & VT_VALMASK) == VT_CMP)
+ if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP)
gv(S, RC_INT);
if (stack >= 0x1000000) // 16Mb
@@ -1017,13 +1017,13 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
// First pass: set all values on stack
for (i = nb_args; i; i--) {
- vpushv(S, S->vtop - nb_args + i);
+ vpushv(S, S->tccgen_vtop - nb_args + i);
if (a[i] & 1) {
// struct replaced by pointer
int r = get_reg(S, RC_INT);
arm64_spoff(S, intr(S, r), a1[i]);
- vset(S, &S->vtop->type, r | VT_LVAL, 0);
+ vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0);
vswap(S);
vstore(S);
if (a[i] >= 32) {
@@ -1035,36 +1035,36 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
}
else if (a[i] >= 32) {
// value on stack
- if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) {
int r = get_reg(S, RC_INT);
arm64_spoff(S, intr(S, r), a[i] - 32);
- vset(S, &S->vtop->type, r | VT_LVAL, 0);
+ vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0);
vswap(S);
vstore(S);
}
- else if (is_float(S->vtop->type.t)) {
+ else if (is_float(S->tccgen_vtop->type.t)) {
gv(S, RC_FLOAT);
- arm64_strv(S, arm64_type_size(S->vtop[0].type.t),
- fltr(S->vtop[0].r), 31, a[i] - 32);
+ arm64_strv(S, arm64_type_size(S->tccgen_vtop[0].type.t),
+ fltr(S->tccgen_vtop[0].r), 31, a[i] - 32);
}
else {
gv(S, RC_INT);
- arm64_strx(S, arm64_type_size(S->vtop[0].type.t),
- intr(S, S->vtop[0].r), 31, a[i] - 32);
+ arm64_strx(S, arm64_type_size(S->tccgen_vtop[0].type.t),
+ intr(S, S->tccgen_vtop[0].r), 31, a[i] - 32);
}
}
- --S->vtop;
+ --S->tccgen_vtop;
}
// Second pass: assign values to registers
- for (i = nb_args; i; i--, S->vtop--) {
+ for (i = nb_args; i; i--, S->tccgen_vtop--) {
if (a[i] < 16 && !(a[i] & 1)) {
// value in general-purpose registers
- if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) {
- int align, size = type_size(&S->vtop->type, &align);
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+ int align, size = type_size(&S->tccgen_vtop->type, &align);
if (size) {
- S->vtop->type.t = VT_PTR;
+ S->tccgen_vtop->type.t = VT_PTR;
gaddrof(S);
gv(S, RC_R(a[i] / 2));
arm64_ldrs(S, a[i] / 2, size);
@@ -1078,9 +1078,9 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
arm64_spoff(S, a[i] / 2, a1[i]);
else if (a[i] < 32) {
// value in floating-point registers
- if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) {
- uint32_t j, sz, n = arm64_hfa(&S->vtop->type, &sz);
- S->vtop->type.t = VT_PTR;
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+ uint32_t j, sz, n = arm64_hfa(&S->tccgen_vtop->type, &sz);
+ S->tccgen_vtop->type.t = VT_PTR;
gaddrof(S);
gv(S, RC_R30);
for (j = 0; j < n; j++)
@@ -1098,7 +1098,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
if (a[0] == 1) {
// indirect return: set x8 and discard the stack value
gv(S, RC_R(8));
- --S->vtop;
+ --S->tccgen_vtop;
}
else
// return in registers: keep the address for after the call
@@ -1107,7 +1107,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
save_regs(S, 0);
arm64_gen_bl_or_b(S, 0);
- --S->vtop;
+ --S->tccgen_vtop;
if (stack & 0xfff)
o(S, 0x910003ff | (stack & 0xfff) << 10); // add sp,sp,#(n)
if (stack >> 12)
@@ -1119,7 +1119,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
if (bt == VT_STRUCT && !(a[0] & 1)) {
// A struct was returned in registers, so write it out:
gv(S, RC_R(8));
- --S->vtop;
+ --S->tccgen_vtop;
if (a[0] == 0) {
int align, size = type_size(return_type, &align);
assert(size <= 16);
@@ -1220,11 +1220,11 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
tcc_free(S, t);
o(S, 0x910003fd); // mov x29,sp
- arm64_func_sub_sp_offset = S->ind;
+ arm64_func_sub_sp_offset = S->tccgen_ind;
// In gfunc_epilog these will be replaced with code to decrement SP:
o(S, 0xd503201f); // nop
o(S, 0xd503201f); // nop
- S->loc = 0;
+ S->tccgen_loc = 0;
#ifdef CONFIG_TCC_BCHECK
if (S->do_bounds_check)
gen_bounds_prolog(S);
@@ -1234,7 +1234,7 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
ST_FUNC void gen_va_start(TCCState *S)
{
int r;
- --S->vtop; // we don't need the "arg"
+ --S->tccgen_vtop; // we don't need the "arg"
gaddrof(S);
r = intr(S, gv(S, RC_INT));
@@ -1264,7 +1264,7 @@ ST_FUNC void gen_va_start(TCCState *S)
arm64_movimm(S, 30, arm64_func_va_list_vr_offs);
o(S, 0xb9001c1e | r << 5); // str w30,[x(r),#28]
- --S->vtop;
+ --S->tccgen_vtop;
}
ST_FUNC void gen_va_arg(TCCState *S, CType *t)
@@ -1281,7 +1281,7 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t)
gaddrof(S);
r0 = intr(S, gv(S, RC_INT));
r1 = get_reg(S, RC_INT);
- S->vtop[0].r = r1 | VT_LVAL;
+ S->tccgen_vtop[0].r = r1 | VT_LVAL;
r1 = intr(S, r1);
if (!hfa) {
@@ -1310,7 +1310,7 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t)
uint32_t b1, b2;
o(S, 0xb9401c1e | r0 << 5); // ldr w30,[x(r0),#28] // __vr_offs
o(S, 0x310003c0 | r1 | rsz << 10); // adds w(r1),w30,#(rsz)
- b1 = S->ind; o(S, 0x5400000d); // b.le lab1
+ b1 = S->tccgen_ind; o(S, 0x5400000d); // b.le lab1
o(S, 0xf9400000 | r1 | r0 << 5); // ldr x(r1),[x(r0)] // __stack
if (fsize == 16) {
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)
}
o(S, 0x9100001e | r1 << 5 | ssz << 10); // add x30,x(r1),#(ssz)
o(S, 0xf900001e | r0 << 5); // str x30,[x(r0)] // __stack
- b2 = S->ind; o(S, 0x14000000); // b lab2
+ b2 = S->tccgen_ind; o(S, 0x14000000); // b lab2
// lab1:
- write32le(cur_text_section->data + b1, 0x5400000d | (S->ind - b1) << 3);
+ write32le(cur_text_section->data + b1, 0x5400000d | (S->tccgen_ind - b1) << 3);
o(S, 0xb9001c00 | r1 | r0 << 5); // str w(r1),[x(r0),#28] // __vr_offs
o(S, 0xf9400800 | r1 | r0 << 5); // ldr x(r1),[x(r0),#16] // __vr_top
if (hfa == 1 || fsize == 16)
@@ -1328,9 +1328,9 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t)
else {
// We need to change the layout of this HFA.
// Get some space on the stack using global variable "loc":
- S->loc = (S->loc - size) & -(uint32_t)align;
+ S->tccgen_loc = (S->tccgen_loc - size) & -(uint32_t)align;
o(S, 0x8b3ec000 | 30 | r1 << 5); // add x30,x(r1),w30,sxtw
- arm64_movimm(S, r1, S->loc);
+ arm64_movimm(S, r1, S->tccgen_loc);
o(S, 0x8b0003a0 | r1 | r1 << 16); // add x(r1),x29,x(r1)
o(S, 0x4c402bdc | (uint32_t)fsize << 7 |
(uint32_t)(hfa == 2) << 15 |
@@ -1340,7 +1340,7 @@ ST_FUNC void gen_va_arg(TCCState *S, CType *t)
(uint32_t)(hfa != 3) << 21); // st(hfa) {v28.(s|d),...}[0],[x(r1)]
}
// lab2:
- write32le(cur_text_section->data + b2, 0x14000000 | (S->ind - b2) >> 2);
+ write32le(cur_text_section->data + b2, 0x14000000 | (S->tccgen_ind - b2) >> 2);
}
}
@@ -1380,7 +1380,7 @@ ST_FUNC void gfunc_return(TCCState *S, CType *func_type)
}
case 16:
if ((func_type->t & VT_BTYPE) == VT_STRUCT) {
- uint32_t j, sz, n = arm64_hfa(&S->vtop->type, &sz);
+ uint32_t j, sz, n = arm64_hfa(&S->tccgen_vtop->type, &sz);
gaddrof(S);
gv(S, RC_R(0));
for (j = 0; j < n; j++)
@@ -1394,7 +1394,7 @@ ST_FUNC void gfunc_return(TCCState *S, CType *func_type)
default:
assert(0);
}
- S->vtop--;
+ S->tccgen_vtop--;
}
ST_FUNC void gfunc_epilog(TCCState *S)
@@ -1404,10 +1404,10 @@ ST_FUNC void gfunc_epilog(TCCState *S)
gen_bounds_epilog(S);
#endif
- if (S->loc) {
+ if (S->tccgen_loc) {
// Insert instructions to subtract size of stack frame from SP.
unsigned char *ptr = cur_text_section->data + arm64_func_sub_sp_offset;
- uint64_t diff = (-S->loc + 15) & ~15;
+ uint64_t diff = (-S->tccgen_loc + 15) & ~15;
if (!(diff >> 24)) {
if (diff & 0xfff) // sub sp,sp,#(diff & 0xfff)
write32le(ptr, 0xd10003ff | (diff & 0xfff) << 10);
@@ -1452,8 +1452,8 @@ ST_FUNC void gen_fill_nops(TCCState *S, int bytes)
// Generate forward branch to label:
ST_FUNC int gjmp(TCCState *S, int t)
{
- int r = S->ind;
- if (S->nocode_wanted)
+ int r = S->tccgen_ind;
+ if (S->tccgen_nocode_wanted)
return t;
o(S, t);
return r;
@@ -1462,8 +1462,8 @@ ST_FUNC int gjmp(TCCState *S, int t)
// Generate branch to known address:
ST_FUNC void gjmp_addr(TCCState *S, int a)
{
- assert(a - S->ind + 0x8000000 < 0x10000000);
- o(S, 0x14000000 | ((a - S->ind) >> 2 & 0x3ffffff));
+ assert(a - S->tccgen_ind + 0x8000000 < 0x10000000);
+ o(S, 0x14000000 | ((a - S->tccgen_ind) >> 2 & 0x3ffffff));
}
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)
void arm64_vset_VT_CMP(TCCState *S, int op)
{
if (op >= TOK_ULT && op <= TOK_GT) {
- S->vtop->cmp_r = S->vtop->r;
+ S->tccgen_vtop->cmp_r = S->tccgen_vtop->r;
vset_VT_CMP(S, 0x80);
}
}
@@ -1505,16 +1505,16 @@ static void arm64_load_cmp(TCCState *S, int r, SValue *sv)
ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
{
- int bt = S->vtop->type.t & VT_BTYPE;
+ int bt = S->tccgen_vtop->type.t & VT_BTYPE;
int inv = op & 1;
- S->vtop->r = S->vtop->cmp_r;
+ S->tccgen_vtop->r = S->tccgen_vtop->cmp_r;
if (bt == VT_LDOUBLE) {
uint32_t a, b, f = fltr(gv(S, RC_FLOAT));
a = get_reg(S, RC_INT);
vpushi(S, 0);
- S->vtop[0].r = a;
+ S->tccgen_vtop[0].r = a;
b = get_reg(S, RC_INT);
a = intr(S, a);
b = intr(S, b);
@@ -1522,7 +1522,7 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
o(S, 0x4e183c00 | b | f << 5); // mov x(b),v(f).d[1]
o(S, 0xaa000400 | a | a << 5 | b << 16); // orr x(a),x(a),x(b),lsl #1
o(S, 0xb4000040 | a | !!inv << 24); // cbz/cbnz x(a),.+8
- --S->vtop;
+ --S->tccgen_vtop;
}
else if (bt == VT_FLOAT || bt == VT_DOUBLE) {
uint32_t a = fltr(gv(S, RC_FLOAT));
@@ -1639,20 +1639,20 @@ static void arm64_gen_opil(TCCState *S, int op, uint32_t l)
uint64_t val;
int rev = 1;
- if (arm64_iconst(0, &S->vtop[0])) {
+ if (arm64_iconst(0, &S->tccgen_vtop[0])) {
vswap(S);
rev = 0;
}
- if (arm64_iconst(&val, &S->vtop[-1])) {
+ if (arm64_iconst(&val, &S->tccgen_vtop[-1])) {
gv(S, RC_INT);
- a = intr(S, S->vtop[0].r);
- --S->vtop;
+ a = intr(S, S->tccgen_vtop[0].r);
+ --S->tccgen_vtop;
x = get_reg(S, RC_INT);
- ++S->vtop;
+ ++S->tccgen_vtop;
if (arm64_gen_opic(S, op, l, rev, val, intr(S, x), a)) {
- S->vtop[0].r = x;
+ S->tccgen_vtop[0].r = x;
vswap(S);
- --S->vtop;
+ --S->tccgen_vtop;
return;
}
}
@@ -1661,13 +1661,13 @@ static void arm64_gen_opil(TCCState *S, int op, uint32_t l)
}
gv2(S, RC_INT, RC_INT);
- assert(S->vtop[-1].r < VT_CONST && S->vtop[0].r < VT_CONST);
- a = intr(S, S->vtop[-1].r);
- b = intr(S, S->vtop[0].r);
- S->vtop -= 2;
+ assert(S->tccgen_vtop[-1].r < VT_CONST && S->tccgen_vtop[0].r < VT_CONST);
+ a = intr(S, S->tccgen_vtop[-1].r);
+ b = intr(S, S->tccgen_vtop[0].r);
+ S->tccgen_vtop -= 2;
x = get_reg(S, RC_INT);
- ++S->vtop;
- S->vtop[0].r = x;
+ ++S->tccgen_vtop;
+ S->tccgen_vtop[0].r = x;
x = intr(S, x);
switch (op) {
@@ -1768,7 +1768,7 @@ ST_FUNC void gen_opi(TCCState *S, int op)
arm64_vset_VT_CMP(S, op);
}
-ST_FUNC void gen_opl(TCCState *S, int op)
+ST_FUNC void gen_opl(TCCState* S, int op)
{
arm64_gen_opil(S, op, 1);
arm64_vset_VT_CMP(S, op);
@@ -1778,8 +1778,8 @@ ST_FUNC void gen_opf(TCCState *S, int op)
{
uint32_t x, a, b, dbl;
- if (S->vtop[0].type.t == VT_LDOUBLE) {
- CType type = S->vtop[0].type;
+ if (S->tccgen_vtop[0].type.t == VT_LDOUBLE) {
+ CType type = S->tccgen_vtop[0].type;
int func = 0;
int cond = -1;
switch (op) {
@@ -1799,9 +1799,9 @@ ST_FUNC void gen_opf(TCCState *S, int op)
vrott(S, 3);
gfunc_call(S, 2);
vpushi(S, 0);
- S->vtop->r = cond < 0 ? REG_FRET : REG_IRET;
+ S->tccgen_vtop->r = cond < 0 ? REG_FRET : REG_IRET;
if (cond < 0)
- S->vtop->type = type;
+ S->tccgen_vtop->type = type;
else {
o(S, 0x7100001f); // cmp w0,#0
o(S, 0x1a9f07e0 | (uint32_t)cond << 12); // cset w0,(cond)
@@ -1809,24 +1809,24 @@ ST_FUNC void gen_opf(TCCState *S, int op)
return;
}
- dbl = S->vtop[0].type.t != VT_FLOAT;
+ dbl = S->tccgen_vtop[0].type.t != VT_FLOAT;
gv2(S, RC_FLOAT, RC_FLOAT);
- assert(S->vtop[-1].r < VT_CONST && S->vtop[0].r < VT_CONST);
- a = fltr(S->vtop[-1].r);
- b = fltr(S->vtop[0].r);
- S->vtop -= 2;
+ assert(S->tccgen_vtop[-1].r < VT_CONST && S->tccgen_vtop[0].r < VT_CONST);
+ a = fltr(S->tccgen_vtop[-1].r);
+ b = fltr(S->tccgen_vtop[0].r);
+ S->tccgen_vtop -= 2;
switch (op) {
case TOK_EQ: case TOK_NE:
case TOK_LT: case TOK_GE: case TOK_LE: case TOK_GT:
x = get_reg(S, RC_INT);
- ++S->vtop;
- S->vtop[0].r = x;
+ ++S->tccgen_vtop;
+ S->tccgen_vtop[0].r = x;
x = intr(S, x);
break;
default:
x = get_reg(S, RC_FLOAT);
- ++S->vtop;
- S->vtop[0].r = x;
+ ++S->tccgen_vtop;
+ S->tccgen_vtop[0].r = x;
x = fltr(x);
break;
}
@@ -1894,7 +1894,7 @@ ST_FUNC void gen_cvt_csti(TCCState *S, int t)
ST_FUNC void gen_cvt_itof(TCCState *S, int t)
{
if (t == VT_LDOUBLE) {
- int f = S->vtop->type.t;
+ int f = S->tccgen_vtop->type.t;
int func = (f & VT_BTYPE) == VT_LLONG ?
(f & VT_UNSIGNED ? TOK___floatunditf : TOK___floatditf) :
(f & VT_UNSIGNED ? TOK___floatunsitf : TOK___floatsitf);
@@ -1902,18 +1902,18 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t)
vrott(S, 2);
gfunc_call(S, 1);
vpushi(S, 0);
- S->vtop->type.t = t;
- S->vtop->r = REG_FRET;
+ S->tccgen_vtop->type.t = t;
+ S->tccgen_vtop->r = REG_FRET;
return;
}
else {
int d, n = intr(S, gv(S, RC_INT));
- int s = !(S->vtop->type.t & VT_UNSIGNED);
- uint32_t l = ((S->vtop->type.t & VT_BTYPE) == VT_LLONG);
- --S->vtop;
+ int s = !(S->tccgen_vtop->type.t & VT_UNSIGNED);
+ uint32_t l = ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG);
+ --S->tccgen_vtop;
d = get_reg(S, RC_FLOAT);
- ++S->vtop;
- S->vtop[0].r = d;
+ ++S->tccgen_vtop;
+ S->tccgen_vtop[0].r = d;
o(S, 0x1e220000 | (uint32_t)!s << 16 |
(uint32_t)(t != VT_FLOAT) << 22 | fltr(d) |
l << 31 | n << 5); // [us]cvtf [sd](d),[wx](n)
@@ -1922,7 +1922,7 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t)
ST_FUNC void gen_cvt_ftoi(TCCState *S, int t)
{
- if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
int func = (t & VT_BTYPE) == VT_LLONG ?
(t & VT_UNSIGNED ? TOK___fixunstfdi : TOK___fixtfdi) :
(t & VT_UNSIGNED ? TOK___fixunstfsi : TOK___fixtfsi);
@@ -1930,17 +1930,17 @@ ST_FUNC void gen_cvt_ftoi(TCCState *S, int t)
vrott(S, 2);
gfunc_call(S, 1);
vpushi(S, 0);
- S->vtop->type.t = t;
- S->vtop->r = REG_IRET;
+ S->tccgen_vtop->type.t = t;
+ S->tccgen_vtop->r = REG_IRET;
return;
}
else {
int d, n = fltr(gv(S, RC_FLOAT));
- uint32_t l = ((S->vtop->type.t & VT_BTYPE) != VT_FLOAT);
- --S->vtop;
+ uint32_t l = ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FLOAT);
+ --S->tccgen_vtop;
d = get_reg(S, RC_INT);
- ++S->vtop;
- S->vtop[0].r = d;
+ ++S->tccgen_vtop;
+ S->tccgen_vtop[0].r = d;
o(S, 0x1e380000 |
(uint32_t)!!(t & VT_UNSIGNED) << 16 |
(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)
ST_FUNC void gen_cvt_ftof(TCCState *S, int t)
{
- int f = S->vtop[0].type.t & VT_BTYPE;
+ int f = S->tccgen_vtop[0].type.t & VT_BTYPE;
assert(t == VT_FLOAT || t == VT_DOUBLE || t == VT_LDOUBLE);
assert(f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE);
if (t == f)
@@ -1964,18 +1964,18 @@ ST_FUNC void gen_cvt_ftof(TCCState *S, int t)
vrott(S, 2);
gfunc_call(S, 1);
vpushi(S, 0);
- S->vtop->type.t = t;
- S->vtop->r = REG_FRET;
+ S->tccgen_vtop->type.t = t;
+ S->tccgen_vtop->r = REG_FRET;
}
else {
int x, a;
gv(S, RC_FLOAT);
- assert(S->vtop[0].r < VT_CONST);
- a = fltr(S->vtop[0].r);
- --S->vtop;
+ assert(S->tccgen_vtop[0].r < VT_CONST);
+ a = fltr(S->tccgen_vtop[0].r);
+ --S->tccgen_vtop;
x = get_reg(S, RC_FLOAT);
- ++S->vtop;
- S->vtop[0].r = x;
+ ++S->tccgen_vtop;
+ S->tccgen_vtop[0].r = x;
x = fltr(x);
if (f == VT_FLOAT)
@@ -1986,16 +1986,16 @@ ST_FUNC void gen_cvt_ftof(TCCState *S, int t)
}
/* increment tcov counter */
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv)
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv)
{
int r1, r2;
vpushv(S, sv);
- S->vtop->r = r1 = get_reg(S, RC_INT);
+ S->tccgen_vtop->r = r1 = get_reg(S, RC_INT);
r2 = get_reg(S, RC_INT);
- greloca(S, cur_text_section, sv->sym, S->ind, R_AARCH64_ADR_GOT_PAGE, 0);
+ greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_AARCH64_ADR_GOT_PAGE, 0);
o(S, 0x90000000 | r1); // adrp r1, #sym
- greloca(S, cur_text_section, sv->sym, S->ind, R_AARCH64_LD64_GOT_LO12_NC, 0);
+ greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_AARCH64_LD64_GOT_LO12_NC, 0);
o(S, 0xf9400000 | r1 | (r1 << 5)); // ld xr,[xr, #sym]
o(S, 0xf9400000 | (intr(S, r1)<<5) | intr(S, r2)); // ldr r2, [r1]
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)
ST_FUNC void ggoto(TCCState *S)
{
arm64_gen_bl_or_b(S, 1);
- --S->vtop;
+ --S->tccgen_vtop;
}
ST_FUNC void gen_clear_cache(TCCState *S)
@@ -2014,17 +2014,17 @@ ST_FUNC void gen_clear_cache(TCCState *S)
uint32_t beg, end, dsz, isz, p, lab1, b1;
gv2(S, RC_INT, RC_INT);
vpushi(S, 0);
- S->vtop->r = get_reg(S, RC_INT);
+ S->tccgen_vtop->r = get_reg(S, RC_INT);
vpushi(S, 0);
- S->vtop->r = get_reg(S, RC_INT);
+ S->tccgen_vtop->r = get_reg(S, RC_INT);
vpushi(S, 0);
- S->vtop->r = get_reg(S, RC_INT);
- beg = intr(S, S->vtop[-4].r); // x0
- end = intr(S, S->vtop[-3].r); // x1
- dsz = intr(S, S->vtop[-2].r); // x2
- isz = intr(S, S->vtop[-1].r); // x3
- p = intr(S, S->vtop[0].r); // x4
- S->vtop -= 5;
+ S->tccgen_vtop->r = get_reg(S, RC_INT);
+ beg = intr(S, S->tccgen_vtop[-4].r); // x0
+ end = intr(S, S->tccgen_vtop[-3].r); // x1
+ dsz = intr(S, S->tccgen_vtop[-2].r); // x2
+ isz = intr(S, S->tccgen_vtop[-1].r); // x3
+ p = intr(S, S->tccgen_vtop[0].r); // x4
+ S->tccgen_vtop -= 5;
o(S, 0xd53b0020 | isz); // mrs x(isz),ctr_el0
o(S, 0x52800080 | p); // mov w(p),#4
@@ -2034,23 +2034,23 @@ ST_FUNC void gen_clear_cache(TCCState *S)
o(S, 0x1ac02000 | isz | p << 5 | isz << 16); // lsl w(isz),w(p),w(isz)
o(S, 0x51000400 | p | dsz << 5); // sub w(p),w(dsz),#1
o(S, 0x8a240004 | p | beg << 5 | p << 16); // bic x(p),x(beg),x(p)
- b1 = S->ind; o(S, 0x14000000); // b
- lab1 = S->ind;
+ b1 = S->tccgen_ind; o(S, 0x14000000); // b
+ lab1 = S->tccgen_ind;
o(S, 0xd50b7b20 | p); // dc cvau,x(p)
o(S, 0x8b000000 | p | p << 5 | dsz << 16); // add x(p),x(p),x(dsz)
- write32le(cur_text_section->data + b1, 0x14000000 | (S->ind - b1) >> 2);
+ write32le(cur_text_section->data + b1, 0x14000000 | (S->tccgen_ind - b1) >> 2);
o(S, 0xeb00001f | p << 5 | end << 16); // cmp x(p),x(end)
- o(S, 0x54ffffa3 | ((lab1 - S->ind) << 3 & 0xffffe0)); // b.cc lab1
+ o(S, 0x54ffffa3 | ((lab1 - S->tccgen_ind) << 3 & 0xffffe0)); // b.cc lab1
o(S, 0xd5033b9f); // dsb ish
o(S, 0x51000400 | p | isz << 5); // sub w(p),w(isz),#1
o(S, 0x8a240004 | p | beg << 5 | p << 16); // bic x(p),x(beg),x(p)
- b1 = S->ind; o(S, 0x14000000); // b
- lab1 = S->ind;
+ b1 = S->tccgen_ind; o(S, 0x14000000); // b
+ lab1 = S->tccgen_ind;
o(S, 0xd50b7520 | p); // ic ivau,x(p)
o(S, 0x8b000000 | p | p << 5 | isz << 16); // add x(p),x(p),x(isz)
- write32le(cur_text_section->data + b1, 0x14000000 | (S->ind - b1) >> 2);
+ write32le(cur_text_section->data + b1, 0x14000000 | (S->tccgen_ind - b1) >> 2);
o(S, 0xeb00001f | p << 5 | end << 16); // cmp x(p),x(end)
- o(S, 0x54ffffa3 | ((lab1 - S->ind) << 3 & 0xffffe0)); // b.cc lab1
+ o(S, 0x54ffffa3 | ((lab1 - S->tccgen_ind) << 3 & 0xffffe0)); // b.cc lab1
o(S, 0xd5033b9f); // dsb ish
o(S, 0xd5033fdf); // isb
}
@@ -2074,7 +2074,7 @@ ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) {
uint32_t r;
#if defined(CONFIG_TCC_BCHECK)
if (S->do_bounds_check)
- vpushv(S, S->vtop);
+ vpushv(S, S->tccgen_vtop);
#endif
r = intr(S, gv(S, RC_INT));
#if defined(CONFIG_TCC_BCHECK)
@@ -2089,8 +2089,8 @@ ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) {
#if defined(CONFIG_TCC_BCHECK)
if (S->do_bounds_check) {
vpushi(S, 0);
- S->vtop->r = TREG_R(0);
- o(S, 0x910003e0 | S->vtop->r); // mov r0,sp
+ S->tccgen_vtop->r = TREG_R(0);
+ o(S, 0x910003e0 | S->tccgen_vtop->r); // mov r0,sp
vswap(S);
vpush_helper_func(S, TOK___bound_new_region);
vrott(S, 3);
diff --git a/c67-gen.c b/c67-gen.c
index 618b5cd..d80f58f 100644
--- a/c67-gen.c
+++ b/c67-gen.c
@@ -186,27 +186,27 @@ static int C67_compare_reg;
FILE *f = NULL;
#endif
-void C67_g(TCCState *S, int c)
+void C67_g(TCCState* S, int c)
{
int ind1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
#ifdef ASSEMBLY_LISTING_C67
fprintf(f, " %08X", c);
#endif
- ind1 = S->ind + 4;
+ ind1 = S->tccgen_ind + 4;
if (ind1 > (int) cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind] = c & 0xff;
- cur_text_section->data[S->ind + 1] = (c >> 8) & 0xff;
- cur_text_section->data[S->ind + 2] = (c >> 16) & 0xff;
- cur_text_section->data[S->ind + 3] = (c >> 24) & 0xff;
- S->ind = ind1;
+ cur_text_section->data[S->tccgen_ind] = c & 0xff;
+ cur_text_section->data[S->tccgen_ind + 1] = (c >> 8) & 0xff;
+ cur_text_section->data[S->tccgen_ind + 2] = (c >> 16) & 0xff;
+ cur_text_section->data[S->tccgen_ind + 3] = (c >> 24) & 0xff;
+ S->tccgen_ind = ind1;
}
/* output a symbol and patch all calls to it */
-void gsym_addr(TCCState *S, int t, int a)
+void gsym_addr(TCCState* S, int t, int a)
{
int n, *ptr;
while (t) {
@@ -220,7 +220,7 @@ void gsym_addr(TCCState *S, int t, int a)
// define a label that will be relocated
- sym = get_sym_ref(S, &S->char_pointer_type, cur_text_section, a, 0);
+ sym = get_sym_ref(S, &S->tccgen_char_pointer_type, cur_text_section, a, 0);
greloc(S, cur_text_section, sym, t, R_C60LO16);
greloc(S, cur_text_section, sym, t + 4, R_C60HI16);
@@ -255,7 +255,7 @@ int ConvertRegToRegClass(int r)
// map TCC reg to C67 reg number
-int C67_map_regn(TCCState *S, int r)
+int C67_map_regn(TCCState* S, int r)
{
if (r == 0) // normal tcc regs
return 0x2; // A2
@@ -296,7 +296,7 @@ int C67_map_regn(TCCState *S, int r)
// tcc reg 1 -> A3 -> X
// tcc reg B2 -> 3
-int C67_map_regc(TCCState *S, int r)
+int C67_map_regc(TCCState* S, int r)
{
if (r == 0) // normal tcc regs
return 0x5;
@@ -317,7 +317,7 @@ int C67_map_regc(TCCState *S, int r)
// map TCC reg to C67 reg side A or B
-int C67_map_regs(TCCState *S, int r)
+int C67_map_regs(TCCState* S, int r)
{
if (r == 0) // normal tcc regs
return 0x0;
@@ -345,7 +345,7 @@ int C67_map_regs(TCCState *S, int r)
return 0;
}
-int C67_map_S12(TCCState *S, char *s)
+int C67_map_S12(TCCState* S, char *s)
{
if (strstr(s, ".S1") != NULL)
return 0;
@@ -357,7 +357,7 @@ int C67_map_S12(TCCState *S, char *s)
return 0;
}
-int C67_map_D12(TCCState *S, char *s)
+int C67_map_D12(TCCState* S, char *s)
{
if (strstr(s, ".D1") != NULL)
return 0;
@@ -371,7 +371,7 @@ int C67_map_D12(TCCState *S, char *s)
-void C67_asm(TCCState *S, const char *s, int a, int b, int c)
+void C67_asm(TCCState* S, const char *s, int a, int b, int c)
{
BOOL xpath;
@@ -1195,189 +1195,189 @@ void C67_asm(TCCState *S, const char *s, int a, int b, int c)
//r=reg to load, fr=from reg, symbol for relocation, constant
-void C67_MVKL(TCCState *S, int r, int fc)
+void C67_MVKL(TCCState* S, int r, int fc)
{
C67_asm(S, "MVKL.", fc, r, 0);
}
-void C67_MVKH(TCCState *S, int r, int fc)
+void C67_MVKH(TCCState* S, int r, int fc)
{
C67_asm(S, "MVKH.", fc, r, 0);
}
-void C67_STB_SP_A0(TCCState *S, int r)
+void C67_STB_SP_A0(TCCState* S, int r)
{
C67_asm(S, "STB.D *+SP[A0]", r, 0, 0); // STB r,*+SP[A0]
}
-void C67_STH_SP_A0(TCCState *S, int r)
+void C67_STH_SP_A0(TCCState* S, int r)
{
C67_asm(S, "STH.D *+SP[A0]", r, 0, 0); // STH r,*+SP[A0]
}
-void C67_STW_SP_A0(TCCState *S, int r)
+void C67_STW_SP_A0(TCCState* S, int r)
{
C67_asm(S, "STW.D *+SP[A0]", r, 0, 0); // STW r,*+SP[A0]
}
-void C67_STB_PTR(TCCState *S, int r, int r2)
+void C67_STB_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "STB.D *", r, r2, 0); // STB r, *r2
}
-void C67_STH_PTR(TCCState *S, int r, int r2)
+void C67_STH_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "STH.D *", r, r2, 0); // STH r, *r2
}
-void C67_STW_PTR(TCCState *S, int r, int r2)
+void C67_STW_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "STW.D *", r, r2, 0); // STW r, *r2
}
-void C67_STW_PTR_PRE_INC(TCCState *S, int r, int r2, int n)
+void C67_STW_PTR_PRE_INC(TCCState* S, int r, int r2, int n)
{
C67_asm(S, "STW.D +*", r, r2, n); // STW r, *+r2
}
-void C67_PUSH(TCCState *S, int r)
+void C67_PUSH(TCCState* S, int r)
{
C67_asm(S, "STW.D SP POST DEC", r, 0, 0); // STW r,*SP--
}
-void C67_LDW_SP_A0(TCCState *S, int r)
+void C67_LDW_SP_A0(TCCState* S, int r)
{
C67_asm(S, "LDW.D *+SP[A0]", r, 0, 0); // LDW *+SP[A0],r
}
-void C67_LDDW_SP_A0(TCCState *S, int r)
+void C67_LDDW_SP_A0(TCCState* S, int r)
{
C67_asm(S, "LDDW.D *+SP[A0]", r, 0, 0); // LDDW *+SP[A0],r
}
-void C67_LDH_SP_A0(TCCState *S, int r)
+void C67_LDH_SP_A0(TCCState* S, int r)
{
C67_asm(S, "LDH.D *+SP[A0]", r, 0, 0); // LDH *+SP[A0],r
}
-void C67_LDB_SP_A0(TCCState *S, int r)
+void C67_LDB_SP_A0(TCCState* S, int r)
{
C67_asm(S, "LDB.D *+SP[A0]", r, 0, 0); // LDB *+SP[A0],r
}
-void C67_LDHU_SP_A0(TCCState *S, int r)
+void C67_LDHU_SP_A0(TCCState* S, int r)
{
C67_asm(S, "LDHU.D *+SP[A0]", r, 0, 0); // LDHU *+SP[A0],r
}
-void C67_LDBU_SP_A0(TCCState *S, int r)
+void C67_LDBU_SP_A0(TCCState* S, int r)
{
C67_asm(S, "LDBU.D *+SP[A0]", r, 0, 0); // LDBU *+SP[A0],r
}
-void C67_LDW_PTR(TCCState *S, int r, int r2)
+void C67_LDW_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "LDW.D *", r, r2, 0); // LDW *r,r2
}
-void C67_LDDW_PTR(TCCState *S, int r, int r2)
+void C67_LDDW_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "LDDW.D *", r, r2, 0); // LDDW *r,r2
}
-void C67_LDH_PTR(TCCState *S, int r, int r2)
+void C67_LDH_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "LDH.D *", r, r2, 0); // LDH *r,r2
}
-void C67_LDB_PTR(TCCState *S, int r, int r2)
+void C67_LDB_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "LDB.D *", r, r2, 0); // LDB *r,r2
}
-void C67_LDHU_PTR(TCCState *S, int r, int r2)
+void C67_LDHU_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "LDHU.D *", r, r2, 0); // LDHU *r,r2
}
-void C67_LDBU_PTR(TCCState *S, int r, int r2)
+void C67_LDBU_PTR(TCCState* S, int r, int r2)
{
C67_asm(S, "LDBU.D *", r, r2, 0); // LDBU *r,r2
}
-void C67_LDW_PTR_PRE_INC(TCCState *S, int r, int r2)
+void C67_LDW_PTR_PRE_INC(TCCState* S, int r, int r2)
{
C67_asm(S, "LDW.D +*", r, r2, 0); // LDW *+r,r2
}
-void C67_POP(TCCState *S, int r)
+void C67_POP(TCCState* S, int r)
{
C67_asm(S, "LDW.D SP PRE INC", r, 0, 0); // LDW *++SP,r
}
-void C67_POP_DW(TCCState *S, int r)
+void C67_POP_DW(TCCState* S, int r)
{
C67_asm(S, "LDDW.D SP PRE INC", r, 0, 0); // LDDW *++SP,r
}
-void C67_CMPLT(TCCState *S, int s1, int s2, int dst)
+void C67_CMPLT(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPLT.L1", s1, s2, dst);
}
-void C67_CMPGT(TCCState *S, int s1, int s2, int dst)
+void C67_CMPGT(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPGT.L1", s1, s2, dst);
}
-void C67_CMPEQ(TCCState *S, int s1, int s2, int dst)
+void C67_CMPEQ(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPEQ.L1", s1, s2, dst);
}
-void C67_CMPLTU(TCCState *S, int s1, int s2, int dst)
+void C67_CMPLTU(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPLTU.L1", s1, s2, dst);
}
-void C67_CMPGTU(TCCState *S, int s1, int s2, int dst)
+void C67_CMPGTU(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPGTU.L1", s1, s2, dst);
}
-void C67_CMPLTSP(TCCState *S, int s1, int s2, int dst)
+void C67_CMPLTSP(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPLTSP.S1", s1, s2, dst);
}
-void C67_CMPGTSP(TCCState *S, int s1, int s2, int dst)
+void C67_CMPGTSP(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPGTSP.S1", s1, s2, dst);
}
-void C67_CMPEQSP(TCCState *S, int s1, int s2, int dst)
+void C67_CMPEQSP(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPEQSP.S1", s1, s2, dst);
}
-void C67_CMPLTDP(TCCState *S, int s1, int s2, int dst)
+void C67_CMPLTDP(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPLTDP.S1", s1, s2, dst);
}
-void C67_CMPGTDP(TCCState *S, int s1, int s2, int dst)
+void C67_CMPGTDP(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPGTDP.S1", s1, s2, dst);
}
-void C67_CMPEQDP(TCCState *S, int s1, int s2, int dst)
+void C67_CMPEQDP(TCCState* S, int s1, int s2, int dst)
{
C67_asm(S, "CMPEQDP.S1", s1, s2, dst);
}
-void C67_IREG_B_REG(TCCState *S, int inv, int r1, int r2) // [!R] B r2
+void C67_IREG_B_REG(TCCState* S, int inv, int r1, int r2) // [!R] B r2
{
C67_asm(S, "B.S2", inv, r1, r2);
}
@@ -1386,7 +1386,7 @@ void C67_IREG_B_REG(TCCState *S, int inv, int r1, int r2) // [!R] B r2
// call with how many 32 bit words to skip
// (0 would branch to the branch instruction)
-void C67_B_DISP(TCCState *S, int disp) // B +2 Branch with constant displacement
+void C67_B_DISP(TCCState* S, int disp) // B +2 Branch with constant displacement
{
// Branch point is relative to the 8 word fetch packet
//
@@ -1395,152 +1395,152 @@ void C67_B_DISP(TCCState *S, int disp) // B +2 Branch with constant displacem
// so add in how many words into the fetch packet the branch is
- C67_asm(S, "B DISP", disp + ((S->ind & 31) >> 2), 0, 0);
+ C67_asm(S, "B DISP", disp + ((S->tccgen_ind & 31) >> 2), 0, 0);
}
-void C67_NOP(TCCState *S, int n)
+void C67_NOP(TCCState* S, int n)
{
C67_asm(S, "NOP", n, 0, 0);
}
-void C67_ADDK(TCCState *S, int n, int r)
+void C67_ADDK(TCCState* S, int n, int r)
{
ALWAYS_ASSERT(abs(n) < 32767);
C67_asm(S, "ADDK", n, r, 0);
}
-void C67_ADDK_PARALLEL(TCCState *S, int n, int r)
+void C67_ADDK_PARALLEL(TCCState* S, int n, int r)
{
ALWAYS_ASSERT(abs(n) < 32767);
C67_asm(S, "||ADDK", n, r, 0);
}
-void C67_Adjust_ADDK(TCCState *S, int *inst, int n)
+void C67_Adjust_ADDK(TCCState* S, int *inst, int n)
{
ALWAYS_ASSERT(abs(n) < 32767);
*inst = (*inst & (~(0xffff << 7))) | ((n & 0xffff) << 7);
}
-void C67_MV(TCCState *S, int r, int v)
+void C67_MV(TCCState* S, int r, int v)
{
C67_asm(S, "MV.L", 0, r, v);
}
-void C67_DPTRUNC(TCCState *S, int r, int v)
+void C67_DPTRUNC(TCCState* S, int r, int v)
{
C67_asm(S, "DPTRUNC.L", 0, r, v);
}
-void C67_SPTRUNC(TCCState *S, int r, int v)
+void C67_SPTRUNC(TCCState* S, int r, int v)
{
C67_asm(S, "SPTRUNC.L", 0, r, v);
}
-void C67_INTSP(TCCState *S, int r, int v)
+void C67_INTSP(TCCState* S, int r, int v)
{
C67_asm(S, "INTSP.L", 0, r, v);
}
-void C67_INTDP(TCCState *S, int r, int v)
+void C67_INTDP(TCCState* S, int r, int v)
{
C67_asm(S, "INTDP.L", 0, r, v);
}
-void C67_INTSPU(TCCState *S, int r, int v)
+void C67_INTSPU(TCCState* S, int r, int v)
{
C67_asm(S, "INTSPU.L", 0, r, v);
}
-void C67_INTDPU(TCCState *S, int r, int v)
+void C67_INTDPU(TCCState* S, int r, int v)
{
C67_asm(S, "INTDPU.L", 0, r, v);
}
-void C67_SPDP(TCCState *S, int r, int v)
+void C67_SPDP(TCCState* S, int r, int v)
{
C67_asm(S, "SPDP.L", 0, r, v);
}
-void C67_DPSP(TCCState *S, int r, int v) // note regs must be on the same side
+void C67_DPSP(TCCState* S, int r, int v) // note regs must be on the same side
{
C67_asm(S, "DPSP.L", 0, r, v);
}
-void C67_ADD(TCCState *S, int r, int v)
+void C67_ADD(TCCState* S, int r, int v)
{
C67_asm(S, "ADD.L", v, r, v);
}
-void C67_SUB(TCCState *S, int r, int v)
+void C67_SUB(TCCState* S, int r, int v)
{
C67_asm(S, "SUB.L", v, r, v);
}
-void C67_AND(TCCState *S, int r, int v)
+void C67_AND(TCCState* S, int r, int v)
{
C67_asm(S, "AND.L", v, r, v);
}
-void C67_OR(TCCState *S, int r, int v)
+void C67_OR(TCCState* S, int r, int v)
{
C67_asm(S, "OR.L", v, r, v);
}
-void C67_XOR(TCCState *S, int r, int v)
+void C67_XOR(TCCState* S, int r, int v)
{
C67_asm(S, "XOR.L", v, r, v);
}
-void C67_ADDSP(TCCState *S, int r, int v)
+void C67_ADDSP(TCCState* S, int r, int v)
{
C67_asm(S, "ADDSP.L", v, r, v);
}
-void C67_SUBSP(TCCState *S, int r, int v)
+void C67_SUBSP(TCCState* S, int r, int v)
{
C67_asm(S, "SUBSP.L", v, r, v);
}
-void C67_MPYSP(TCCState *S, int r, int v)
+void C67_MPYSP(TCCState* S, int r, int v)
{
C67_asm(S, "MPYSP.M", v, r, v);
}
-void C67_ADDDP(TCCState *S, int r, int v)
+void C67_ADDDP(TCCState* S, int r, int v)
{
C67_asm(S, "ADDDP.L", v, r, v);
}
-void C67_SUBDP(TCCState *S, int r, int v)
+void C67_SUBDP(TCCState* S, int r, int v)
{
C67_asm(S, "SUBDP.L", v, r, v);
}
-void C67_MPYDP(TCCState *S, int r, int v)
+void C67_MPYDP(TCCState* S, int r, int v)
{
C67_asm(S, "MPYDP.M", v, r, v);
}
-void C67_MPYI(TCCState *S, int r, int v)
+void C67_MPYI(TCCState* S, int r, int v)
{
C67_asm(S, "MPYI.M", v, r, v);
}
-void C67_SHL(TCCState *S, int r, int v)
+void C67_SHL(TCCState* S, int r, int v)
{
C67_asm(S, "SHL.S", r, v, v);
}
-void C67_SHRU(TCCState *S, int r, int v)
+void C67_SHRU(TCCState* S, int r, int v)
{
C67_asm(S, "SHRU.S", r, v, v);
}
-void C67_SHR(TCCState *S, int r, int v)
+void C67_SHR(TCCState* S, int r, int v)
{
C67_asm(S, "SHR.S", r, v, v);
}
@@ -1548,7 +1548,7 @@ void C67_SHR(TCCState *S, int r, int v)
/* load 'r' from value 'sv' */
-void load(TCCState *S, int r, SValue * sv)
+void load(TCCState* S, int r, SValue * sv)
{
int v, t, ft, fc, fr, size = 0, element;
BOOL Unsigned = FALSE;
@@ -1625,8 +1625,8 @@ void load(TCCState *S, int r, SValue * sv)
C67_NOP(S, 4); // NOP 4
return;
} else if (fr & VT_SYM) {
- greloc(S, cur_text_section, sv->sym, S->ind, R_C60LO16); // rem the inst need to be patched
- greloc(S, cur_text_section, sv->sym, S->ind + 4, R_C60HI16);
+ greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched
+ greloc(S, cur_text_section, sv->sym, S->tccgen_ind + 4, R_C60HI16);
C67_MVKL(S, C67_A0, fc); //r=reg to load, constant
@@ -1681,8 +1681,8 @@ void load(TCCState *S, int r, SValue * sv)
} else {
if (v == VT_CONST) {
if (fr & VT_SYM) {
- greloc(S, cur_text_section, sv->sym, S->ind, R_C60LO16); // rem the inst need to be patched
- greloc(S, cur_text_section, sv->sym, S->ind + 4, R_C60HI16);
+ greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched
+ greloc(S, cur_text_section, sv->sym, S->tccgen_ind + 4, R_C60HI16);
}
C67_MVKL(S, r, fc); //r=reg to load, constant
C67_MVKH(S, r, fc); //r=reg to load, constant
@@ -1710,7 +1710,7 @@ void load(TCCState *S, int r, SValue * sv)
/* store register 'r' in lvalue 'v' */
-void store(TCCState *S, int r, SValue * v)
+void store(TCCState* S, int r, SValue * v)
{
int fr, bt, ft, fc, size, t, element;
@@ -1736,8 +1736,8 @@ void store(TCCState *S, int r, SValue * v)
/* constant memory reference */
if (v->r & VT_SYM) {
- greloc(S, cur_text_section, v->sym, S->ind, R_C60LO16); // rem the inst need to be patched
- greloc(S, cur_text_section, v->sym, S->ind + 4, R_C60HI16);
+ greloc(S, cur_text_section, v->sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched
+ greloc(S, cur_text_section, v->sym, S->tccgen_ind + 4, R_C60HI16);
}
C67_MVKL(S, C67_A0, fc); //r=reg to load, constant
C67_MVKH(S, C67_A0, fc); //r=reg to load, constant
@@ -1813,20 +1813,20 @@ void store(TCCState *S, int r, SValue * v)
}
/* 'is_jmp' is '1' if it is a jump */
-static void gcall_or_jmp(TCCState *S, int is_jmp)
+static void gcall_or_jmp(TCCState* S, int is_jmp)
{
int r;
Sym *sym;
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
/* constant case */
- if (S->vtop->r & VT_SYM) {
+ if (S->tccgen_vtop->r & VT_SYM) {
/* relocation case */
// get add into A0, then start the jump B3
- greloc(S, cur_text_section, S->vtop->sym, S->ind, R_C60LO16); // rem the inst need to be patched
- greloc(S, cur_text_section, S->vtop->sym, S->ind + 4, R_C60HI16);
+ greloc(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched
+ greloc(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind + 4, R_C60HI16);
C67_MVKL(S, C67_A0, 0); //r=reg to load, constant
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)
} else {
// Call, must load return address into B3 during delay slots
- sym = get_sym_ref(S, &S->char_pointer_type, cur_text_section, S->ind + 12, 0); // symbol for return address
- greloc(S, cur_text_section, sym, S->ind, R_C60LO16); // rem the inst need to be patched
- greloc(S, cur_text_section, sym, S->ind + 4, R_C60HI16);
+ sym = get_sym_ref(S, &S->tccgen_char_pointer_type, cur_text_section, S->tccgen_ind + 12, 0); // symbol for return address
+ greloc(S, cur_text_section, sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched
+ greloc(S, cur_text_section, sym, S->tccgen_ind + 4, R_C60HI16);
C67_MVKL(S, C67_B3, 0); //r=reg to load, constant
C67_MVKH(S, C67_B3, 0); //r=reg to load, constant
C67_NOP(S, 3); // put remaining NOPs
@@ -1858,9 +1858,9 @@ static void gcall_or_jmp(TCCState *S, int is_jmp)
} else {
// Call, must load return address into B3 during delay slots
- sym = get_sym_ref(S, &S->char_pointer_type, cur_text_section, S->ind + 12, 0); // symbol for return address
- greloc(S, cur_text_section, sym, S->ind, R_C60LO16); // rem the inst need to be patched
- greloc(S, cur_text_section, sym, S->ind + 4, R_C60HI16);
+ sym = get_sym_ref(S, &S->tccgen_char_pointer_type, cur_text_section, S->tccgen_ind + 12, 0); // symbol for return address
+ greloc(S, cur_text_section, sym, S->tccgen_ind, R_C60LO16); // rem the inst need to be patched
+ greloc(S, cur_text_section, sym, S->tccgen_ind + 4, R_C60HI16);
C67_MVKL(S, C67_B3, 0); //r=reg to load, constant
C67_MVKH(S, C67_B3, 0); //r=reg to load, constant
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
/* generate function call with address in (vtop->t, vtop->c) and free function
context. Stack entry is popped */
-void gfunc_call(TCCState *S, int nb_args)
+void gfunc_call(TCCState* S, int nb_args)
{
int i, r, size = 0;
int args_sizes[NoCallArgsPassedOnStack];
@@ -1888,18 +1888,18 @@ void gfunc_call(TCCState *S, int nb_args)
}
for (i = 0; i < nb_args; i++) {
- if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) {
ALWAYS_ASSERT(FALSE);
} else {
/* simple type (currently always same size) */
/* XXX: implicit cast ? */
- if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) {
tcc_error(S, "long long not supported");
- } else if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+ } else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
tcc_error(S, "long double not supported");
- } else if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
+ } else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
size = 8;
} else {
size = 4;
@@ -1919,7 +1919,7 @@ void gfunc_call(TCCState *S, int nb_args)
}
args_sizes[i] = size;
}
- S->vtop--;
+ S->tccgen_vtop--;
}
// POP all the params on the stack into registers for the
// immediate call (in reverse order)
@@ -1932,7 +1932,7 @@ void gfunc_call(TCCState *S, int nb_args)
C67_POP(S, TREG_C67_A4 + i * 2);
}
gcall_or_jmp(S, 0);
- S->vtop--;
+ S->tccgen_vtop--;
}
@@ -1946,7 +1946,7 @@ void gfunc_call(TCCState *S, int nb_args)
// parameters are loaded and restored upon return (or if/when needed).
/* generate function prolog of type 't' */
-void gfunc_prolog(TCCState *S, Sym *func_sym)
+void gfunc_prolog(TCCState* S, Sym *func_sym)
{
CType *func_type = &func_sym->type;
int addr, align, size, func_call, i;
@@ -1997,11 +1997,11 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
// place all the args passed in regs onto the stack
- S->loc = 0;
+ S->tccgen_loc = 0;
for (i = 0; i < NoOfCurFuncArgs; i++) {
- ParamLocOnStack[i] = S->loc; // remember where the param is
- S->loc += -8;
+ ParamLocOnStack[i] = S->tccgen_loc; // remember where the param is
+ S->tccgen_loc += -8;
C67_PUSH(S, TREG_C67_A4 + i * 2);
@@ -2010,9 +2010,9 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
}
}
- TotalBytesPushedOnStack = -S->loc;
+ TotalBytesPushedOnStack = -S->tccgen_loc;
- func_sub_sp_offset = S->ind; // remember where we put the stack instruction
+ func_sub_sp_offset = S->tccgen_ind; // remember where we put the stack instruction
C67_ADDK(S, 0, C67_SP); // ADDK.L2 loc,SP (just put zero temporarily)
C67_PUSH(S, C67_A0);
@@ -2020,10 +2020,10 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
}
/* generate function epilog */
-void gfunc_epilog(TCCState *S)
+void gfunc_epilog(TCCState* S)
{
{
- int local = (-S->loc + 7) & -8; // stack must stay aligned to 8 bytes for LDDW instr
+ int local = (-S->tccgen_loc + 7) & -8; // stack must stay aligned to 8 bytes for LDDW instr
C67_POP(S, C67_B3);
C67_NOP(S, 4); // NOP wait for load
C67_IREG_B_REG(S, 0, C67_CREG_ZERO, C67_B3); // B.S2 B3
@@ -2036,7 +2036,7 @@ void gfunc_epilog(TCCState *S)
}
}
-ST_FUNC void gen_fill_nops(TCCState *S, int bytes)
+ST_FUNC void gen_fill_nops(TCCState* S, int bytes)
{
if ((bytes & 3))
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)
}
/* generate a jump to a label */
-int gjmp(TCCState *S, int t)
+int gjmp(TCCState* S, int t)
{
- int ind1 = S->ind;
- if (S->nocode_wanted)
+ int ind1 = S->tccgen_ind;
+ if (S->tccgen_nocode_wanted)
return t;
C67_MVKL(S, C67_A0, t); //r=reg to load, constant
@@ -2061,7 +2061,7 @@ int gjmp(TCCState *S, int t)
}
/* generate a jump to a fixed address */
-void gjmp_addr(TCCState *S, int a)
+void gjmp_addr(TCCState* S, int a)
{
Sym *sym;
// I guess this routine is used for relative short
@@ -2070,24 +2070,24 @@ void gjmp_addr(TCCState *S, int a)
// define a label that will be relocated
- sym = get_sym_ref(S, &S->char_pointer_type, cur_text_section, a, 0);
- greloc(S, cur_text_section, sym, S->ind, R_C60LO16);
- greloc(S, cur_text_section, sym, S->ind + 4, R_C60HI16);
+ sym = get_sym_ref(S, &S->tccgen_char_pointer_type, cur_text_section, a, 0);
+ greloc(S, cur_text_section, sym, S->tccgen_ind, R_C60LO16);
+ greloc(S, cur_text_section, sym, S->tccgen_ind + 4, R_C60HI16);
gjmp(S, 0); // place a zero there later the symbol will be added to it
}
/* generate a test. set 'inv' to invert test. Stack entry is popped */
-ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
+ST_FUNC int gjmp_cond(TCCState* S, int op, int t)
{
int ind1;
int inv = op & 1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return t;
/* fast case : can jump directly since flags are set */
// C67 uses B2 sort of as flags register
- ind1 = S->ind;
+ ind1 = S->tccgen_ind;
C67_MVKL(S, C67_A0, t); //r=reg to load, constant
C67_MVKH(S, C67_A0, t); //r=reg to load, constant
@@ -2105,7 +2105,7 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
return t;
}
-ST_FUNC int gjmp_append(TCCState *S, int n0, int t)
+ST_FUNC int gjmp_append(TCCState* S, int n0, int t)
{
if (n0) {
int n = n0, *p;
@@ -2129,7 +2129,7 @@ ST_FUNC int gjmp_append(TCCState *S, int n0, int t)
}
/* generate an integer binary operation */
-void gen_opi(TCCState *S, int op)
+void gen_opi(TCCState* S, int op)
{
int r, fr, opc, t;
@@ -2150,8 +2150,8 @@ void gen_opi(TCCState *S, int op)
else
gv2(S, RC_INT, RC_INT);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
C67_compare_reg = C67_B2;
@@ -2199,7 +2199,7 @@ void gen_opi(TCCState *S, int op)
else
ALWAYS_ASSERT(FALSE);
- S->vtop--;
+ S->tccgen_vtop--;
if (op >= TOK_ULT && op <= TOK_GT)
vset_VT_CMP(S, 0x80);
break;
@@ -2225,33 +2225,33 @@ void gen_opi(TCCState *S, int op)
case '*':
case TOK_UMULL:
gv2(S, RC_INT, RC_INT);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
- S->vtop--;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
+ S->tccgen_vtop--;
C67_MPYI(S, fr, r); // 32 bit multiply fr,r,fr
C67_NOP(S, 8); // NOP 8 for worst case
break;
case TOK_SHL:
gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
- S->vtop--;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
+ S->tccgen_vtop--;
C67_SHL(S, fr, r); // arithmetic/logical shift
break;
case TOK_SHR:
gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
- S->vtop--;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
+ S->tccgen_vtop--;
C67_SHRU(S, fr, r); // logical shift
break;
case TOK_SAR:
gv2(S, RC_INT_BSIDE, RC_INT_BSIDE); // shift amount must be on same side as dst
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
- S->vtop--;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
+ S->tccgen_vtop--;
C67_SHR(S, fr, r); // arithmetic shift
break;
@@ -2264,8 +2264,8 @@ void gen_opi(TCCState *S, int op)
vrott(S, 3);
gfunc_call(S, 2);
vpushi(S, 0);
- S->vtop->r = REG_IRET;
- S->vtop->r2 = VT_CONST;
+ S->tccgen_vtop->r = REG_IRET;
+ S->tccgen_vtop->r2 = VT_CONST;
break;
case TOK_UDIV:
case TOK_PDIV:
@@ -2287,7 +2287,7 @@ void gen_opi(TCCState *S, int op)
/* generate a floating point operation 'v = t1 op t2' instruction. The
two operands are guaranteed to have the same floating point type */
/* XXX: need to use ST1 too */
-void gen_opf(TCCState *S, int op)
+void gen_opf(TCCState* S, int op)
{
int ft, fc, fr, r;
@@ -2296,10 +2296,10 @@ void gen_opf(TCCState *S, int op)
else
gv2(S, RC_FLOAT, RC_FLOAT); // make sure src2 is on b side
- ft = S->vtop->type.t;
- fc = S->vtop->c.i;
- r = S->vtop->r;
- fr = S->vtop[-1].r;
+ ft = S->tccgen_vtop->type.t;
+ fc = S->tccgen_vtop->c.i;
+ r = S->tccgen_vtop->r;
+ fr = S->tccgen_vtop[-1].r;
if ((ft & VT_BTYPE) == VT_LDOUBLE)
@@ -2307,8 +2307,8 @@ void gen_opf(TCCState *S, int op)
if (op >= TOK_ULT && op <= TOK_GT) {
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
C67_compare_reg = C67_B2;
@@ -2367,7 +2367,7 @@ void gen_opf(TCCState *S, int op)
C67_ADDSP(S, r, fr); // ADD fr,r,fr
C67_NOP(S, 3);
}
- S->vtop--;
+ S->tccgen_vtop--;
} else if (op == '-') {
if ((ft & VT_BTYPE) == VT_DOUBLE) {
C67_SUBDP(S, r, fr); // SUB fr,r,fr
@@ -2376,7 +2376,7 @@ void gen_opf(TCCState *S, int op)
C67_SUBSP(S, r, fr); // SUB fr,r,fr
C67_NOP(S, 3);
}
- S->vtop--;
+ S->tccgen_vtop--;
} else if (op == '*') {
if ((ft & VT_BTYPE) == VT_DOUBLE) {
C67_MPYDP(S, r, fr); // MPY fr,r,fr
@@ -2385,7 +2385,7 @@ void gen_opf(TCCState *S, int op)
C67_MPYSP(S, r, fr); // MPY fr,r,fr
C67_NOP(S, 3);
}
- S->vtop--;
+ S->tccgen_vtop--;
} else if (op == '/') {
if ((ft & VT_BTYPE) == VT_DOUBLE) {
// must call intrinsic DP floating point divide
@@ -2395,8 +2395,8 @@ void gen_opf(TCCState *S, int op)
vrott(S, 3);
gfunc_call(S, 2);
vpushi(S, 0);
- S->vtop->r = REG_FRET;
- S->vtop->r2 = REG_IRE2;
+ S->tccgen_vtop->r = REG_FRET;
+ S->tccgen_vtop->r2 = REG_IRE2;
} else {
// must call intrinsic SP floating point divide
@@ -2406,8 +2406,8 @@ void gen_opf(TCCState *S, int op)
vrott(S, 3);
gfunc_call(S, 2);
vpushi(S, 0);
- S->vtop->r = REG_FRET;
- S->vtop->r2 = VT_CONST;
+ S->tccgen_vtop->r = REG_FRET;
+ S->tccgen_vtop->r2 = VT_CONST;
}
} else
ALWAYS_ASSERT(FALSE);
@@ -2419,12 +2419,12 @@ void gen_opf(TCCState *S, int op)
/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
and 'long long' cases. */
-void gen_cvt_itof(TCCState *S, int t)
+void gen_cvt_itof(TCCState* S, int t)
{
int r;
gv(S, RC_INT);
- r = S->vtop->r;
+ r = S->tccgen_vtop->r;
if ((t & VT_BTYPE) == VT_DOUBLE) {
if (t & VT_UNSIGNED)
@@ -2433,31 +2433,31 @@ void gen_cvt_itof(TCCState *S, int t)
C67_INTDP(S, r, r);
C67_NOP(S, 4);
- S->vtop->type.t = VT_DOUBLE;
+ S->tccgen_vtop->type.t = VT_DOUBLE;
} else {
if (t & VT_UNSIGNED)
C67_INTSPU(S, r, r);
else
C67_INTSP(S, r, r);
C67_NOP(S, 3);
- S->vtop->type.t = VT_FLOAT;
+ S->tccgen_vtop->type.t = VT_FLOAT;
}
}
/* convert fp to int 't' type */
/* XXX: handle long long case */
-void gen_cvt_ftoi(TCCState *S, int t)
+void gen_cvt_ftoi(TCCState* S, int t)
{
int r;
gv(S, RC_FLOAT);
- r = S->vtop->r;
+ r = S->tccgen_vtop->r;
if (t != VT_INT)
tcc_error(S, "long long not supported");
else {
- if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
C67_DPTRUNC(S, r, r);
C67_NOP(S, 3);
} else {
@@ -2465,36 +2465,36 @@ void gen_cvt_ftoi(TCCState *S, int t)
C67_NOP(S, 3);
}
- S->vtop->type.t = VT_INT;
+ S->tccgen_vtop->type.t = VT_INT;
}
}
/* convert from one floating point type to another */
-void gen_cvt_ftof(TCCState *S, int t)
+void gen_cvt_ftof(TCCState* S, int t)
{
int r, r2;
- if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE &&
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE &&
(t & VT_BTYPE) == VT_FLOAT) {
// convert double to float
gv(S, RC_FLOAT); // get it in a register pair
- r = S->vtop->r;
+ r = S->tccgen_vtop->r;
C67_DPSP(S, r, r); // convert it to SP same register
C67_NOP(S, 3);
- S->vtop->type.t = VT_FLOAT;
- S->vtop->r2 = VT_CONST; // set this as unused
- } else if ((S->vtop->type.t & VT_BTYPE) == VT_FLOAT &&
+ S->tccgen_vtop->type.t = VT_FLOAT;
+ S->tccgen_vtop->r2 = VT_CONST; // set this as unused
+ } else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FLOAT &&
(t & VT_BTYPE) == VT_DOUBLE) {
// convert float to double
gv(S, RC_FLOAT); // get it in a register
- r = S->vtop->r;
+ r = S->tccgen_vtop->r;
if (r == TREG_EAX) { // make sure the paired reg is avail
r2 = get_reg(S, RC_ECX);
@@ -2508,32 +2508,32 @@ void gen_cvt_ftof(TCCState *S, int t)
C67_SPDP(S, r, r); // convert it to DP same register
C67_NOP(S, 1);
- S->vtop->type.t = VT_DOUBLE;
- S->vtop->r2 = r2; // set this as unused
+ S->tccgen_vtop->type.t = VT_DOUBLE;
+ S->tccgen_vtop->r2 = r2; // set this as unused
} else {
ALWAYS_ASSERT(FALSE);
}
}
/* computed goto support */
-void ggoto(TCCState *S)
+void ggoto(TCCState* S)
{
gcall_or_jmp(S, 1);
- S->vtop--;
+ S->tccgen_vtop--;
}
/* Save the stack pointer onto the stack and return the location of its address */
-ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) {
+ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) {
tcc_error(S, "variable length arrays unsupported for this target");
}
/* Restore the SP from a location on the stack */
-ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) {
+ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) {
tcc_error(S, "variable length arrays unsupported for this target");
}
/* Subtract from the stack pointer, and push the resulting value onto the stack */
-ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) {
+ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) {
tcc_error(S, "variable length arrays unsupported for this target");
}
diff --git a/i386-asm.c b/i386-asm.c
index f285447..fdd2787 100644
--- a/i386-asm.c
+++ b/i386-asm.c
@@ -282,7 +282,7 @@ static inline int get_reg_shift(TCCState *S)
static int asm_parse_numeric_reg(TCCState *S, int t, unsigned int *type)
{
int reg = -1;
- if (t >= TOK_IDENT && t < S->tok_ident) {
+ if (t >= TOK_IDENT && t < S->tccpp_tok_ident) {
const char *s = S->tccpp_table_ident[t - TOK_IDENT]->str;
char c;
*type = OP_REG64;
@@ -318,24 +318,24 @@ static int asm_parse_numeric_reg(TCCState *S, int t, unsigned int *type)
}
#endif
-static int asm_parse_reg(TCCState *S, unsigned int *type)
+static int asm_parse_reg(TCCState* S, unsigned int *type)
{
int reg = 0;
*type = 0;
- if (S->tok != '%')
+ if (S->tccpp_tok != '%')
goto error_32;
next(S);
- if (S->tok >= TOK_ASM_eax && S->tok <= TOK_ASM_edi) {
- reg = S->tok - TOK_ASM_eax;
+ if (S->tccpp_tok >= TOK_ASM_eax && S->tccpp_tok <= TOK_ASM_edi) {
+ reg = S->tccpp_tok - TOK_ASM_eax;
*type = OP_REG32;
#ifdef TCC_TARGET_X86_64
- } else if (S->tok >= TOK_ASM_rax && S->tok <= TOK_ASM_rdi) {
- reg = S->tok - TOK_ASM_rax;
+ } else if (S->tccpp_tok >= TOK_ASM_rax && S->tccpp_tok <= TOK_ASM_rdi) {
+ reg = S->tccpp_tok - TOK_ASM_rax;
*type = OP_REG64;
- } else if (S->tok == TOK_ASM_rip) {
+ } else if (S->tccpp_tok == TOK_ASM_rip) {
reg = -2; /* Probably should use different escape code. */
*type = OP_REG64;
- } else if ((reg = asm_parse_numeric_reg(S, S->tok, type)) >= 0
+ } else if ((reg = asm_parse_numeric_reg(S, S->tccpp_tok, type)) >= 0
&& (*type == OP_REG32 || *type == OP_REG64)) {
;
#endif
@@ -354,15 +354,15 @@ static void parse_operand(TCCState *S, Operand *op)
const char *p;
indir = 0;
- if (S->tok == '*') {
+ if (S->tccpp_tok == '*') {
next(S);
indir = OP_INDIR;
}
- if (S->tok == '%') {
+ if (S->tccpp_tok == '%') {
next(S);
- if (S->tok >= TOK_ASM_al && S->tok <= TOK_ASM_db7) {
- reg = S->tok - TOK_ASM_al;
+ if (S->tccpp_tok >= TOK_ASM_al && S->tccpp_tok <= TOK_ASM_db7) {
+ reg = S->tccpp_tok - TOK_ASM_al;
op->type = 1 << (reg >> 3); /* WARNING: do not change constant order */
op->reg = reg & 7;
if ((op->type & OP_REG) && op->reg == TREG_XAX)
@@ -371,21 +371,21 @@ static void parse_operand(TCCState *S, Operand *op)
op->type |= OP_CL;
else if (op->type == OP_REG16 && op->reg == TREG_XDX)
op->type |= OP_DX;
- } else if (S->tok >= TOK_ASM_dr0 && S->tok <= TOK_ASM_dr7) {
+ } else if (S->tccpp_tok >= TOK_ASM_dr0 && S->tccpp_tok <= TOK_ASM_dr7) {
op->type = OP_DB;
- op->reg = S->tok - TOK_ASM_dr0;
- } else if (S->tok >= TOK_ASM_es && S->tok <= TOK_ASM_gs) {
+ op->reg = S->tccpp_tok - TOK_ASM_dr0;
+ } else if (S->tccpp_tok >= TOK_ASM_es && S->tccpp_tok <= TOK_ASM_gs) {
op->type = OP_SEG;
- op->reg = S->tok - TOK_ASM_es;
- } else if (S->tok == TOK_ASM_st) {
+ op->reg = S->tccpp_tok - TOK_ASM_es;
+ } else if (S->tccpp_tok == TOK_ASM_st) {
op->type = OP_ST;
op->reg = 0;
next(S);
- if (S->tok == '(') {
+ if (S->tccpp_tok == '(') {
next(S);
- if (S->tok != TOK_PPNUM)
+ if (S->tccpp_tok != TOK_PPNUM)
goto reg_error;
- p = S->tokc.str.data;
+ p = S->tccpp_tokc.str.data;
reg = p[0] - '0';
if ((unsigned)reg >= 8 || p[1] != '\0')
goto reg_error;
@@ -397,19 +397,19 @@ static void parse_operand(TCCState *S, Operand *op)
op->type |= OP_ST0;
goto no_skip;
#ifdef TCC_TARGET_X86_64
- } else if (S->tok >= TOK_ASM_spl && S->tok <= TOK_ASM_dil) {
+ } else if (S->tccpp_tok >= TOK_ASM_spl && S->tccpp_tok <= TOK_ASM_dil) {
op->type = OP_REG8 | OP_REG8_LOW;
- op->reg = 4 + S->tok - TOK_ASM_spl;
- } else if ((op->reg = asm_parse_numeric_reg(S, S->tok, &op->type)) >= 0) {
+ op->reg = 4 + S->tccpp_tok - TOK_ASM_spl;
+ } else if ((op->reg = asm_parse_numeric_reg(S, S->tccpp_tok, &op->type)) >= 0) {
;
#endif
} else {
reg_error:
- tcc_error(S, "unknown register %%%s", get_tok_str(S, S->tok, &S->tokc));
+ tcc_error(S, "unknown register %%%s", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
}
next(S);
no_skip: ;
- } else if (S->tok == '$') {
+ } else if (S->tccpp_tok == '$') {
/* constant value */
next(S);
asm_expr(S, &e);
@@ -433,19 +433,19 @@ static void parse_operand(TCCState *S, Operand *op)
op->reg = -1;
op->reg2 = -1;
op->shift = 0;
- if (S->tok != '(') {
+ if (S->tccpp_tok != '(') {
asm_expr(S, &e);
op->e = e;
} else {
next(S);
- if (S->tok == '%') {
+ if (S->tccpp_tok == '%') {
unget_tok(S, '(');
op->e.v = 0;
op->e.sym = NULL;
} else {
/* bracketed offset expression */
asm_expr(S, &e);
- if (S->tok != ')')
+ if (S->tccpp_tok != ')')
expect(S, ")");
next(S);
op->e.v = e.v;
@@ -453,18 +453,18 @@ static void parse_operand(TCCState *S, Operand *op)
}
op->e.pcrel = 0;
}
- if (S->tok == '(') {
+ if (S->tccpp_tok == '(') {
unsigned int type = 0;
next(S);
- if (S->tok != ',') {
+ if (S->tccpp_tok != ',') {
op->reg = asm_parse_reg(S, &type);
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
- if (S->tok != ',') {
+ if (S->tccpp_tok != ',') {
op->reg2 = asm_parse_reg(S, &type);
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
op->shift = get_reg_shift(S);
}
@@ -480,7 +480,7 @@ static void parse_operand(TCCState *S, Operand *op)
}
/* XXX: unify with C code output ? */
-ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe)
+ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe)
{
if (pe->pcrel)
/* If PC-relative, always set VT_SYM, even without symbol,
@@ -491,14 +491,14 @@ ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe)
}
#ifdef TCC_TARGET_X86_64
-ST_FUNC void gen_expr64(TCCState *S, ExprValue *pe)
+ST_FUNC void gen_expr64(TCCState* S, ExprValue *pe)
{
gen_addr64(S, pe->sym ? VT_SYM : 0, pe->sym, pe->v);
}
#endif
/* XXX: unify with C code output ? */
-static void gen_disp32(TCCState *S, ExprValue *pe)
+static void gen_disp32(TCCState* S, ExprValue *pe)
{
Sym *sym = pe->sym;
ElfSym *esym = elfsym(S, sym);
@@ -507,7 +507,7 @@ static void gen_disp32(TCCState *S, ExprValue *pe)
that the TCC compiler behaves differently here because
it always outputs a relocation to ease (future) code
elimination in the linker */
- gen_le32(S, pe->v + esym->st_value - S->ind - 4);
+ gen_le32(S, pe->v + esym->st_value - S->tccgen_ind - 4);
} else {
if (sym && sym->type.t == VT_VOID) {
sym->type.t = VT_FUNC;
@@ -518,7 +518,7 @@ static void gen_disp32(TCCState *S, ExprValue *pe)
}
/* generate the modrm operand */
-static inline int asm_modrm(TCCState *S, int reg, Operand *op)
+static inline int asm_modrm(TCCState* S, int reg, Operand *op)
{
int mod, reg1, reg2, sib_reg1;
@@ -538,7 +538,7 @@ static inline int asm_modrm(TCCState *S, int reg, Operand *op)
ExprValue *pe = &op->e;
g(S, 0x05 + (reg << 3));
gen_addrpc32(S, pe->sym ? VT_SYM : 0, pe->sym, pe->v);
- return S->ind;
+ return S->tccgen_ind;
#endif
} else {
sib_reg1 = op->reg;
@@ -581,7 +581,7 @@ static inline int asm_modrm(TCCState *S, int reg, Operand *op)
#define REX_X 0x42
#define REX_B 0x41
-static void asm_rex(TCCState *S, int width64, Operand *ops, int nb_ops, int *op_type,
+static void asm_rex(TCCState* S, int width64, Operand *ops, int nb_ops, int *op_type,
int regi, int rmi)
{
unsigned char rex = width64 ? 0x48 : 0;
@@ -705,13 +705,13 @@ ST_FUNC void asm_opcode(TCCState *S, int opcode)
seg_prefix = 0;
alltypes = 0;
for(;;) {
- if (S->tok == ';' || S->tok == TOK_LINEFEED)
+ if (S->tccpp_tok == ';' || S->tccpp_tok == TOK_LINEFEED)
break;
if (nb_ops >= MAX_OPERANDS) {
tcc_error(S, "incorrect number of operands");
}
parse_operand(S, pop);
- if (S->tok == ':') {
+ if (S->tccpp_tok == ':') {
if (pop->type != OP_SEG || seg_prefix)
tcc_error(S, "incorrect prefix");
seg_prefix = segment_prefixes[pop->reg];
@@ -723,7 +723,7 @@ ST_FUNC void asm_opcode(TCCState *S, int opcode)
}
pop++;
nb_ops++;
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
break;
next(S);
}
@@ -1038,7 +1038,7 @@ again:
esym = elfsym(S, ops[0].e.sym);
if (!esym || esym->st_shndx != cur_text_section->sh_num)
goto no_short_jump;
- jmp_disp = ops[0].e.v + esym->st_value - S->ind - 2 - (v >= 0xff);
+ jmp_disp = ops[0].e.v + esym->st_value - S->tccgen_ind - 2 - (v >= 0xff);
if (jmp_disp == (int8_t)jmp_disp) {
/* OK to generate jump */
ops[0].e.sym = 0;
@@ -1136,12 +1136,12 @@ again:
/* after immediate operands, adjust pc-relative address */
if (pc)
- add32le(cur_text_section->data + pc - 4, pc - S->ind);
+ add32le(cur_text_section->data + pc - 4, pc - S->tccgen_ind);
}
/* return the constraint priority (we allocate first the lowest
numbered constraints) */
-static inline int constraint_priority(TCCState *S, const char *str)
+static inline int constraint_priority(TCCState* S, const char *str)
{
int priority, c, pr;
@@ -1200,7 +1200,7 @@ static const char *skip_constraint_modifiers(const char *p)
/* If T (a token) is of the form "%reg" returns the register
number and type, otherwise return -1. */
-ST_FUNC int asm_parse_regvar (TCCState *S, int t)
+ST_FUNC int asm_parse_regvar (TCCState* S, int t)
{
const char *s;
Operand op;
@@ -1225,7 +1225,7 @@ ST_FUNC int asm_parse_regvar (TCCState *S, int t)
#define is_reg_allocated(reg) (regs_allocated[reg] & reg_mask)
-ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands,
+ST_FUNC void asm_compute_constraints(TCCState* S, ASMOperand *operands,
int nb_operands, int nb_outputs,
const uint8_t *clobber_regs,
int *pout_reg)
@@ -1471,7 +1471,7 @@ ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands,
#endif
}
-ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str,
+ST_FUNC void subst_asm_operand(TCCState* S, CString *add_str,
SValue *sv, int modifier)
{
int r, reg, size, val;
@@ -1593,7 +1593,7 @@ ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str,
}
/* generate prolog and epilog code for asm statement */
-ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands,
+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)
@@ -1697,7 +1697,7 @@ ST_FUNC void asm_gen_code(TCCState *S, ASMOperand *operands, int nb_operands,
}
}
-ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str)
+ST_FUNC void asm_clobber(TCCState* S, uint8_t *clobber_regs, const char *str)
{
int reg;
#ifdef TCC_TARGET_X86_64
diff --git a/i386-gen.c b/i386-gen.c
index 7425eeb..0b61683 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -100,24 +100,24 @@ ST_DATA const int reg_classes[NB_REGS] = {
static unsigned long func_sub_sp_offset;
static int func_ret_sub;
#ifdef CONFIG_TCC_BCHECK
-static void gen_bounds_prolog(TCCState *S);
-static void gen_bounds_epilog(TCCState *S);
+static void gen_bounds_prolog(TCCState* S);
+static void gen_bounds_epilog(TCCState* S);
#endif
/* XXX: make it faster ? */
-ST_FUNC void g(TCCState *S, int c)
+ST_FUNC void g(TCCState* S, int c)
{
int ind1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
- ind1 = S->ind + 1;
+ ind1 = S->tccgen_ind + 1;
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind] = c;
- S->ind = ind1;
+ cur_text_section->data[S->tccgen_ind] = c;
+ S->tccgen_ind = ind1;
}
-ST_FUNC void o(TCCState *S, unsigned int c)
+ST_FUNC void o(TCCState* S, unsigned int c)
{
while (c) {
g(S, c);
@@ -125,13 +125,13 @@ ST_FUNC void o(TCCState *S, unsigned int c)
}
}
-ST_FUNC void gen_le16(TCCState *S, int v)
+ST_FUNC void gen_le16(TCCState* S, int v)
{
g(S, v);
g(S, v >> 8);
}
-ST_FUNC void gen_le32(TCCState *S, int c)
+ST_FUNC void gen_le32(TCCState* S, int c)
{
g(S, c);
g(S, c >> 8);
@@ -140,7 +140,7 @@ ST_FUNC void gen_le32(TCCState *S, int c)
}
/* output a symbol and patch all calls to it */
-ST_FUNC void gsym_addr(TCCState *S, int t, int a)
+ST_FUNC void gsym_addr(TCCState* S, int t, int a)
{
while (t) {
unsigned char *ptr = cur_text_section->data + t;
@@ -151,18 +151,18 @@ ST_FUNC void gsym_addr(TCCState *S, int t, int a)
}
/* instruction + 4 bytes data. Return the address of the data */
-static int oad(TCCState *S, int c, int s)
+static int oad(TCCState* S, int c, int s)
{
int t;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return s;
o(S, c);
- t = S->ind;
+ t = S->tccgen_ind;
gen_le32(S, s);
return t;
}
-ST_FUNC void gen_fill_nops(TCCState *S, int bytes)
+ST_FUNC void gen_fill_nops(TCCState* S, int bytes)
{
while (bytes--)
g(S, 0x90);
@@ -172,23 +172,23 @@ ST_FUNC void gen_fill_nops(TCCState *S, int bytes)
#define gjmp2(s, instr,lbl) oad(s, instr,lbl)
/* output constant with relocation if 'r & VT_SYM' is true */
-ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c)
+ST_FUNC void gen_addr32(TCCState* S, int r, Sym *sym, int c)
{
if (r & VT_SYM)
- greloc(S, cur_text_section, sym, S->ind, R_386_32);
+ greloc(S, cur_text_section, sym, S->tccgen_ind, R_386_32);
gen_le32(S, c);
}
-ST_FUNC void gen_addrpc32(TCCState *S, int r, Sym *sym, int c)
+ST_FUNC void gen_addrpc32(TCCState* S, int r, Sym *sym, int c)
{
if (r & VT_SYM)
- greloc(S, cur_text_section, sym, S->ind, R_386_PC32);
+ greloc(S, cur_text_section, sym, S->tccgen_ind, R_386_PC32);
gen_le32(S, c - 4);
}
/* generate a modrm reference. 'op_reg' contains the additional 3
opcode bits */
-static void gen_modrm(TCCState *S, int op_reg, int r, Sym *sym, int c)
+static void gen_modrm(TCCState* S, int op_reg, int r, Sym *sym, int c)
{
op_reg = op_reg << 3;
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)
}
/* load 'r' from value 'sv' */
-ST_FUNC void load(TCCState *S, int r, SValue *sv)
+ST_FUNC void load(TCCState* S, int r, SValue *sv)
{
int v, t, ft, fc, fr;
SValue v1;
@@ -290,7 +290,7 @@ ST_FUNC void load(TCCState *S, int r, SValue *sv)
}
/* store register 'r' in lvalue 'v' */
-ST_FUNC void store(TCCState *S, int r, SValue *v)
+ST_FUNC void store(TCCState* S, int r, SValue *v)
{
int fr, bt, ft, fc;
@@ -332,7 +332,7 @@ ST_FUNC void store(TCCState *S, int r, SValue *v)
}
}
-static void gadd_sp(TCCState *S, int val)
+static void gadd_sp(TCCState* S, int val)
{
if (val == (char)val) {
o(S, 0xc483);
@@ -343,24 +343,24 @@ static void gadd_sp(TCCState *S, int val)
}
#if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_PE
-static void gen_static_call(TCCState *S, int v)
+static void gen_static_call(TCCState* S, int v)
{
Sym *sym;
sym = external_helper_sym(S, v);
oad(S, 0xe8, -4);
- greloc(S, cur_text_section, sym, S->ind-4, R_386_PC32);
+ greloc(S, cur_text_section, sym, S->tccgen_ind-4, R_386_PC32);
}
#endif
/* 'is_jmp' is '1' if it is a jump */
-static void gcall_or_jmp(TCCState *S, int is_jmp)
+static void gcall_or_jmp(TCCState* S, int is_jmp)
{
int r;
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && (S->vtop->r & VT_SYM)) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST && (S->tccgen_vtop->r & VT_SYM)) {
/* constant and relocation case */
- greloc(S, cur_text_section, S->vtop->sym, S->ind + 1, R_386_PC32);
- oad(S, 0xe8 + is_jmp, S->vtop->c.i - 4); /* call/jmp im */
+ greloc(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind + 1, R_386_PC32);
+ oad(S, 0xe8 + is_jmp, S->tccgen_vtop->c.i - 4); /* call/jmp im */
} else {
/* otherwise, indirect call */
r = gv(S, RC_INT);
@@ -402,7 +402,7 @@ ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align, int
/* Generate function call. The function address is pushed first, then
all the parameters in call order. This functions pops all the
parameters and the function address. */
-ST_FUNC void gfunc_call(TCCState *S, int nb_args)
+ST_FUNC void gfunc_call(TCCState* S, int nb_args)
{
int size, align, r, args_size, i, func_call;
Sym *func_sym;
@@ -414,8 +414,8 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
args_size = 0;
for(i = 0;i < nb_args; i++) {
- if ((S->vtop->type.t & VT_BTYPE) == VT_STRUCT) {
- size = type_size(&S->vtop->type, &align);
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+ size = type_size(&S->tccgen_vtop->type, &align);
/* align to stack align size */
size = (size + 3) & ~3;
/* allocate the necessary size on stack */
@@ -434,15 +434,15 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
r = get_reg(S, RC_INT);
o(S, 0xe089 + (r << 8)); /* mov %esp, r */
}
- vset(S, &S->vtop->type, r | VT_LVAL, 0);
+ vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0);
vswap(S);
vstore(S);
args_size += size;
- } else if (is_float(S->vtop->type.t)) {
+ } else if (is_float(S->tccgen_vtop->type.t)) {
gv(S, RC_FLOAT); /* only one float register */
- if ((S->vtop->type.t & VT_BTYPE) == VT_FLOAT)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FLOAT)
size = 4;
- else if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE)
+ else if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE)
size = 8;
else
size = 12;
@@ -458,19 +458,19 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
/* simple type (currently always same size) */
/* XXX: implicit cast ? */
r = gv(S, RC_INT);
- if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) {
size = 8;
- o(S, 0x50 + S->vtop->r2); /* push r */
+ o(S, 0x50 + S->tccgen_vtop->r2); /* push r */
} else {
size = 4;
}
o(S, 0x50 + r); /* push r */
args_size += size;
}
- S->vtop--;
+ S->tccgen_vtop--;
}
save_regs(S, 0); /* save used temporary registers */
- func_sym = S->vtop->type.ref;
+ func_sym = S->tccgen_vtop->type.ref;
func_call = func_sym->f.func_call;
/* fast call case */
if ((func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) ||
@@ -493,7 +493,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
}
}
#if !defined(TCC_TARGET_PE) && !TARGETOS_FreeBSD || TARGETOS_OpenBSD
- else if ((S->vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT)
+ else if ((S->tccgen_vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT)
args_size -= 4;
#endif
@@ -501,7 +501,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
if (args_size && func_call != FUNC_STDCALL && func_call != FUNC_FASTCALLW)
gadd_sp(S, args_size);
- S->vtop--;
+ S->tccgen_vtop--;
}
#ifdef TCC_TARGET_PE
@@ -511,7 +511,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
#endif
/* generate function prolog of type 't' */
-ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
+ST_FUNC void gfunc_prolog(TCCState* S, Sym *func_sym)
{
CType *func_type = &func_sym->type;
int addr, align, size, func_call, fastcall_nb_regs;
@@ -523,7 +523,7 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
sym = func_type->ref;
func_call = sym->f.func_call;
addr = 8;
- S->loc = 0;
+ S->tccgen_loc = 0;
S->tccgen_func_vc = 0;
if (func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) {
@@ -538,8 +538,8 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
}
param_index = 0;
- S->ind += FUNC_PROLOG_SIZE;
- func_sub_sp_offset = S->ind;
+ S->tccgen_ind += FUNC_PROLOG_SIZE;
+ func_sub_sp_offset = S->tccgen_ind;
/* if the function returns a structure, then add an
implicit pointer parameter */
#if defined(TCC_TARGET_PE) || TARGETOS_FreeBSD || TARGETOS_OpenBSD
@@ -567,10 +567,10 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
#endif
if (param_index < fastcall_nb_regs) {
/* save FASTCALL register */
- S->loc -= 4;
+ S->tccgen_loc -= 4;
o(S, 0x89); /* movl */
- gen_modrm(S, fastcall_regs_ptr[param_index], VT_LOCAL, NULL, S->loc);
- param_addr = S->loc;
+ gen_modrm(S, fastcall_regs_ptr[param_index], VT_LOCAL, NULL, S->tccgen_loc);
+ param_addr = S->tccgen_loc;
} else {
param_addr = addr;
addr += size;
@@ -595,7 +595,7 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
}
/* generate function epilog */
-ST_FUNC void gfunc_epilog(TCCState *S)
+ST_FUNC void gfunc_epilog(TCCState* S)
{
addr_t v, saved_ind;
@@ -605,7 +605,7 @@ ST_FUNC void gfunc_epilog(TCCState *S)
#endif
/* align local size to word & save local variables */
- v = (-S->loc + 3) & -4;
+ v = (-S->tccgen_loc + 3) & -4;
#if USE_EBX
o(S, 0x8b);
@@ -620,8 +620,8 @@ ST_FUNC void gfunc_epilog(TCCState *S)
g(S, func_ret_sub);
g(S, func_ret_sub >> 8);
}
- saved_ind = S->ind;
- S->ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
+ saved_ind = S->tccgen_ind;
+ S->tccgen_ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
#ifdef TCC_TARGET_PE
if (v >= 4096) {
oad(S, 0xb8, v); /* mov stacksize, %eax */
@@ -637,33 +637,33 @@ ST_FUNC void gfunc_epilog(TCCState *S)
#endif
}
o(S, 0x53 * USE_EBX); /* push ebx */
- S->ind = saved_ind;
+ S->tccgen_ind = saved_ind;
}
/* generate a jump to a label */
-ST_FUNC int gjmp(TCCState *S, int t)
+ST_FUNC int gjmp(TCCState* S, int t)
{
return gjmp2(S, 0xe9, t);
}
/* generate a jump to a fixed address */
-ST_FUNC void gjmp_addr(TCCState *S, int a)
+ST_FUNC void gjmp_addr(TCCState* S, int a)
{
int r;
- r = a - S->ind - 2;
+ r = a - S->tccgen_ind - 2;
if (r == (char)r) {
g(S, 0xeb);
g(S, r);
} else {
- oad(S, 0xe9, a - S->ind - 5);
+ oad(S, 0xe9, a - S->tccgen_ind - 5);
}
}
#if 0
/* generate a jump to a fixed address */
-ST_FUNC void gjmp_cond_addr(TCCState *S, int a, int op)
+ST_FUNC void gjmp_cond_addr(TCCState* S, int a, int op)
{
- int r = a - S->ind - 2;
+ int r = a - S->tccgen_ind - 2;
if (r == (char)r)
g(S, op - 32), g(r);
else
@@ -671,7 +671,7 @@ ST_FUNC void gjmp_cond_addr(TCCState *S, int a, int op)
}
#endif
-ST_FUNC int gjmp_append(TCCState *S, int n, int t)
+ST_FUNC int gjmp_append(TCCState* S, int n, int t)
{
void *p;
/* insert vtop->c jump list in t */
@@ -685,14 +685,14 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t)
return t;
}
-ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
+ST_FUNC int gjmp_cond(TCCState* S, int op, int t)
{
g(S, 0x0f);
t = gjmp2(S, op - 16, t);
return t;
}
-ST_FUNC void gen_opi(TCCState *S, int op)
+ST_FUNC void gen_opi(TCCState* S, int op)
{
int r, fr, opc, c;
@@ -701,12 +701,12 @@ ST_FUNC void gen_opi(TCCState *S, int op)
case TOK_ADDC1: /* add with carry generation */
opc = 0;
gen_op8:
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
/* constant case */
vswap(S);
r = gv(S, RC_INT);
vswap(S);
- c = S->vtop->c.i;
+ c = S->tccgen_vtop->c.i;
if (c == (char)c) {
/* generate inc and dec for smaller code */
if ((c == 1 || c == -1) && (op == '+' || op == '-')) {
@@ -723,12 +723,12 @@ ST_FUNC void gen_opi(TCCState *S, int op)
}
} else {
gv2(S, RC_INT, RC_INT);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
o(S, (opc << 3) | 0x01);
o(S, 0xc0 + r + fr * 8);
}
- S->vtop--;
+ S->tccgen_vtop--;
if (op >= TOK_ULT && op <= TOK_GT)
vset_VT_CMP(S, op);
break;
@@ -753,9 +753,9 @@ ST_FUNC void gen_opi(TCCState *S, int op)
goto gen_op8;
case '*':
gv2(S, RC_INT, RC_INT);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
- S->vtop--;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
+ S->tccgen_vtop--;
o(S, 0xaf0f); /* imul fr, r */
o(S, 0xc0 + fr + r * 8);
break;
@@ -769,23 +769,23 @@ ST_FUNC void gen_opi(TCCState *S, int op)
opc = 7;
gen_shift:
opc = 0xc0 | (opc << 3);
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
/* constant case */
vswap(S);
r = gv(S, RC_INT);
vswap(S);
- c = S->vtop->c.i & 0x1f;
+ c = S->tccgen_vtop->c.i & 0x1f;
o(S, 0xc1); /* shl/shr/sar $xxx, r */
o(S, opc | r);
g(S, c);
} else {
/* we generate the shift in ecx */
gv2(S, RC_INT, RC_ECX);
- r = S->vtop[-1].r;
+ r = S->tccgen_vtop[-1].r;
o(S, 0xd3); /* shl/shr/sar %cl, r */
o(S, opc | r);
}
- S->vtop--;
+ S->tccgen_vtop--;
break;
case '/':
case TOK_UDIV:
@@ -796,16 +796,16 @@ ST_FUNC void gen_opi(TCCState *S, int op)
/* first operand must be in eax */
/* XXX: need better constraint for second operand */
gv2(S, RC_EAX, RC_ECX);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
- S->vtop--;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
+ S->tccgen_vtop--;
save_reg(S, TREG_EDX);
/* save EAX too if used otherwise */
save_reg_upstack(S, TREG_EAX, 1);
if (op == TOK_UMULL) {
o(S, 0xf7); /* mul fr */
o(S, 0xe0 + fr);
- S->vtop->r2 = TREG_EDX;
+ S->tccgen_vtop->r2 = TREG_EDX;
r = TREG_EAX;
} else {
if (op == TOK_UDIV || op == TOK_UMOD) {
@@ -820,7 +820,7 @@ ST_FUNC void gen_opi(TCCState *S, int op)
else
r = TREG_EAX;
}
- S->vtop->r = r;
+ S->tccgen_vtop->r = r;
break;
default:
opc = 7;
@@ -831,7 +831,7 @@ ST_FUNC void gen_opi(TCCState *S, int op)
/* generate a floating point operation 'v = t1 op t2' instruction. The
two operands are guaranteed to have the same floating point type */
/* XXX: need to use ST1 too */
-ST_FUNC void gen_opf(TCCState *S, int op)
+ST_FUNC void gen_opf(TCCState* S, int op)
{
int a, ft, fc, swapped, r;
@@ -842,17 +842,17 @@ ST_FUNC void gen_opf(TCCState *S, int op)
}
/* convert constants to memory references */
- if ((S->vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
vswap(S);
gv(S, RC_FLOAT);
vswap(S);
}
- if ((S->vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST)
+ if ((S->tccgen_vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST)
gv(S, RC_FLOAT);
/* must put at least one value in the floating point register */
- if ((S->vtop[-1].r & VT_LVAL) &&
- (S->vtop[0].r & VT_LVAL)) {
+ if ((S->tccgen_vtop[-1].r & VT_LVAL) &&
+ (S->tccgen_vtop[0].r & VT_LVAL)) {
vswap(S);
gv(S, RC_FLOAT);
vswap(S);
@@ -860,13 +860,13 @@ ST_FUNC void gen_opf(TCCState *S, int op)
swapped = 0;
/* swap the stack if needed so that t1 is the register and t2 is
the memory reference */
- if (S->vtop[-1].r & VT_LVAL) {
+ if (S->tccgen_vtop[-1].r & VT_LVAL) {
vswap(S);
swapped = 1;
}
if (op >= TOK_ULT && op <= TOK_GT) {
/* load on stack second operand */
- load(S, TREG_ST0, S->vtop);
+ load(S, TREG_ST0, S->tccgen_vtop);
save_reg(S, TREG_EAX); /* eax is used by FP comparison code */
if (op == TOK_GE || op == TOK_GT)
swapped = !swapped;
@@ -893,12 +893,12 @@ ST_FUNC void gen_opf(TCCState *S, int op)
o(S, 0x45c4f6); /* test $0x45, %ah */
op = TOK_EQ;
}
- S->vtop--;
+ S->tccgen_vtop--;
vset_VT_CMP(S, op);
} else {
/* no memory reference possible for long double operations */
- if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
- load(S, TREG_ST0, S->vtop);
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+ load(S, TREG_ST0, S->tccgen_vtop);
swapped = !swapped;
}
@@ -921,14 +921,14 @@ ST_FUNC void gen_opf(TCCState *S, int op)
a++;
break;
}
- ft = S->vtop->type.t;
- fc = S->vtop->c.i;
+ ft = S->tccgen_vtop->type.t;
+ fc = S->tccgen_vtop->c.i;
if ((ft & VT_BTYPE) == VT_LDOUBLE) {
o(S, 0xde); /* fxxxp %st, %st(1) */
o(S, 0xc1 + (a << 3));
} else {
/* if saved lvalue, then we must reload it */
- r = S->vtop->r;
+ r = S->tccgen_vtop->r;
if ((r & VT_VALMASK) == VT_LLOCAL) {
SValue v1;
r = get_reg(S, RC_INT);
@@ -944,48 +944,48 @@ ST_FUNC void gen_opf(TCCState *S, int op)
o(S, 0xdc);
else
o(S, 0xd8);
- gen_modrm(S, a, r, S->vtop->sym, fc);
+ gen_modrm(S, a, r, S->tccgen_vtop->sym, fc);
}
- S->vtop--;
+ S->tccgen_vtop--;
}
}
/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
and 'long long' cases. */
-ST_FUNC void gen_cvt_itof(TCCState *S, int t)
+ST_FUNC void gen_cvt_itof(TCCState* S, int t)
{
save_reg(S, TREG_ST0);
gv(S, RC_INT);
- if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) {
/* signed long long to float/double/long double (unsigned case
is handled generically) */
- o(S, 0x50 + S->vtop->r2); /* push r2 */
- o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */
+ o(S, 0x50 + S->tccgen_vtop->r2); /* push r2 */
+ o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */
o(S, 0x242cdf); /* fildll (%esp) */
o(S, 0x08c483); /* add $8, %esp */
- S->vtop->r2 = VT_CONST;
- } else if ((S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
+ S->tccgen_vtop->r2 = VT_CONST;
+ } else if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
(VT_INT | VT_UNSIGNED)) {
/* unsigned int to float/double/long double */
o(S, 0x6a); /* push $0 */
g(S, 0x00);
- o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */
+ o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */
o(S, 0x242cdf); /* fildll (%esp) */
o(S, 0x08c483); /* add $8, %esp */
} else {
/* int to float/double/long double */
- o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */
+ o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */
o(S, 0x2404db); /* fildl (%esp) */
o(S, 0x04c483); /* add $4, %esp */
}
- S->vtop->r2 = VT_CONST;
- S->vtop->r = TREG_ST0;
+ S->tccgen_vtop->r2 = VT_CONST;
+ S->tccgen_vtop->r = TREG_ST0;
}
/* convert fp to int 't' type */
-ST_FUNC void gen_cvt_ftoi(TCCState *S, int t)
+ST_FUNC void gen_cvt_ftoi(TCCState* S, int t)
{
- int bt = S->vtop->type.t & VT_BTYPE;
+ int bt = S->tccgen_vtop->type.t & VT_BTYPE;
if (bt == VT_FLOAT)
vpush_helper_func(S, TOK___fixsfdi);
else if (bt == VT_LDOUBLE)
@@ -995,20 +995,20 @@ ST_FUNC void gen_cvt_ftoi(TCCState *S, int t)
vswap(S);
gfunc_call(S, 1);
vpushi(S, 0);
- S->vtop->r = REG_IRET;
+ S->tccgen_vtop->r = REG_IRET;
if ((t & VT_BTYPE) == VT_LLONG)
- S->vtop->r2 = REG_IRE2;
+ S->tccgen_vtop->r2 = REG_IRE2;
}
/* convert from one floating point type to another */
-ST_FUNC void gen_cvt_ftof(TCCState *S, int t)
+ST_FUNC void gen_cvt_ftof(TCCState* S, int t)
{
/* all we have to do on i386 is to put the float in a register */
gv(S, RC_FLOAT);
}
/* char/short to int conversion */
-ST_FUNC void gen_cvt_csti(TCCState *S, int t)
+ST_FUNC void gen_cvt_csti(TCCState* S, int t)
{
int r, sz, xl;
r = gv(S, RC_INT);
@@ -1021,39 +1021,39 @@ ST_FUNC void gen_cvt_csti(TCCState *S, int t)
}
/* increment tcov counter */
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv)
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv)
{
o(S, 0x0583); /* addl $1, xxx */
- greloc(S, cur_text_section, sv->sym, S->ind, R_386_32);
+ greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_386_32);
gen_le32(S, 0);
o(S, 1);
o(S, 0x1583); /* addcl $0, xxx */
- greloc(S, cur_text_section, sv->sym, S->ind, R_386_32);
+ greloc(S, cur_text_section, sv->sym, S->tccgen_ind, R_386_32);
gen_le32(S, 4);
g(S, 0);
}
/* computed goto support */
-ST_FUNC void ggoto(TCCState *S)
+ST_FUNC void ggoto(TCCState* S)
{
gcall_or_jmp(S, 1);
- S->vtop--;
+ S->tccgen_vtop--;
}
/* bound check support functions */
#ifdef CONFIG_TCC_BCHECK
-static void gen_bounds_prolog(TCCState *S)
+static void gen_bounds_prolog(TCCState* S)
{
/* leave some room for bound checking code */
S->func_bound_offset = lbounds_section->data_offset;
- S->func_bound_ind = S->ind;
+ S->func_bound_ind = S->tccgen_ind;
S->func_bound_add_epilog = 0;
oad(S, 0xb8, 0); /* lbound section pointer */
oad(S, 0xb8, 0); /* call to function */
}
-static void gen_bounds_epilog(TCCState *S)
+static void gen_bounds_epilog(TCCState* S)
{
addr_t saved_ind;
addr_t *bounds_ptr;
@@ -1067,22 +1067,22 @@ static void gen_bounds_epilog(TCCState *S)
bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t));
*bounds_ptr = 0;
- sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section,
+ sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section,
S->func_bound_offset, lbounds_section->data_offset);
/* generate bound local allocation */
if (offset_modified) {
- saved_ind = S->ind;
- S->ind = S->func_bound_ind;
- greloc(S, cur_text_section, sym_data, S->ind + 1, R_386_32);
- S->ind = S->ind + 5;
+ saved_ind = S->tccgen_ind;
+ S->tccgen_ind = S->func_bound_ind;
+ greloc(S, cur_text_section, sym_data, S->tccgen_ind + 1, R_386_32);
+ S->tccgen_ind = S->tccgen_ind + 5;
gen_static_call(S, TOK___bound_local_new);
- S->ind = saved_ind;
+ S->tccgen_ind = saved_ind;
}
/* generate bound check local freeing */
o(S, 0x5250); /* save returned value, if any */
- greloc(S, cur_text_section, sym_data, S->ind + 1, R_386_32);
+ greloc(S, cur_text_section, sym_data, S->tccgen_ind + 1, R_386_32);
oad(S, 0xb8, 0); /* mov %eax, xxx */
gen_static_call(S, TOK___bound_local_delete);
o(S, 0x585a); /* restore returned value, if any */
@@ -1090,20 +1090,20 @@ static void gen_bounds_epilog(TCCState *S)
#endif
/* Save the stack pointer onto the stack */
-ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) {
+ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) {
/* mov %esp,addr(%ebp)*/
o(S, 0x89);
gen_modrm(S, TREG_ESP, VT_LOCAL, NULL, addr);
}
/* Restore the SP from a location on the stack */
-ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) {
+ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) {
o(S, 0x8b);
gen_modrm(S, TREG_ESP, VT_LOCAL, NULL, addr);
}
/* Subtract from the stack pointer, and push the resulting value onto the stack */
-ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) {
+ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) {
int use_call = 0;
#if defined(CONFIG_TCC_BCHECK)
diff --git a/libtcc.c b/libtcc.c
index 72700b2..5374525 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -233,7 +233,7 @@ PUB_FUNC char *tcc_fileextension (const char *name)
return e ? e : strchr(b, 0);
}
-ST_FUNC char *tcc_load_text(TCCState *S, int fd)
+ST_FUNC char *tcc_load_text(TCCState* S, int fd)
{
int len = lseek(fd, 0, SEEK_END);
char *buf = load_data(S, fd, 0, len + 1);
@@ -275,12 +275,12 @@ PUB_FUNC void *tcc_mallocz_base(unsigned long size)
#ifndef MEM_DEBUG
-PUB_FUNC void tcc_free(TCCState *S, void *ptr)
+PUB_FUNC void tcc_free(TCCState* S, void *ptr)
{
free(ptr);
}
-PUB_FUNC void *tcc_malloc(TCCState *S, unsigned long size)
+PUB_FUNC void *tcc_malloc(TCCState* S, unsigned long size)
{
void *ptr;
ptr = malloc(size);
@@ -289,7 +289,7 @@ PUB_FUNC void *tcc_malloc(TCCState *S, unsigned long size)
return ptr;
}
-PUB_FUNC void *tcc_mallocz(TCCState *S, unsigned long size)
+PUB_FUNC void *tcc_mallocz(TCCState* S, unsigned long size)
{
void *ptr;
ptr = tcc_malloc(S, size);
@@ -298,7 +298,7 @@ PUB_FUNC void *tcc_mallocz(TCCState *S, unsigned long size)
return ptr;
}
-PUB_FUNC void *tcc_realloc(TCCState *S, void *ptr, unsigned long size)
+PUB_FUNC void *tcc_realloc(TCCState* S, void *ptr, unsigned long size)
{
void *ptr1;
ptr1 = realloc(ptr, size);
@@ -307,7 +307,7 @@ PUB_FUNC void *tcc_realloc(TCCState *S, void *ptr, unsigned long size)
return ptr1;
}
-PUB_FUNC char *tcc_strdup(TCCState *S, const char *str)
+PUB_FUNC char *tcc_strdup(TCCState* S, const char *str)
{
char *ptr;
ptr = tcc_malloc(S, strlen(str) + 1);
@@ -361,7 +361,7 @@ static mem_debug_header_t *malloc_check(void *ptr, const char *msg)
return header;
}
-PUB_FUNC void *tcc_malloc_debug(TCCState *S, unsigned long size, const char *file, int line)
+PUB_FUNC void *tcc_malloc_debug(TCCState* S, unsigned long size, const char *file, int line)
{
int ofs;
mem_debug_header_t *header;
@@ -392,7 +392,7 @@ PUB_FUNC void *tcc_malloc_debug(TCCState *S, unsigned long size, const char *fil
return MEM_USER_PTR(header);
}
-PUB_FUNC void tcc_free_debug(TCCState *S, void *ptr)
+PUB_FUNC void tcc_free_debug(TCCState* S, void *ptr)
{
mem_debug_header_t *header;
if (!ptr)
@@ -409,7 +409,7 @@ PUB_FUNC void tcc_free_debug(TCCState *S, void *ptr)
free(header);
}
-PUB_FUNC void *tcc_mallocz_debug(TCCState *S, unsigned long size, const char *file, int line)
+PUB_FUNC void *tcc_mallocz_debug(TCCState* S, unsigned long size, const char *file, int line)
{
void *ptr;
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
return ptr;
}
-PUB_FUNC void *tcc_realloc_debug(TCCState *S, void *ptr, unsigned long size, const char *file, int line)
+PUB_FUNC void *tcc_realloc_debug(TCCState* S, void *ptr, unsigned long size, const char *file, int line)
{
mem_debug_header_t *header;
int mem_debug_chain_update = 0;
@@ -443,7 +443,7 @@ PUB_FUNC void *tcc_realloc_debug(TCCState *S, void *ptr, unsigned long size, con
return MEM_USER_PTR(header);
}
-PUB_FUNC char *tcc_strdup_debug(TCCState *S, const char *str, const char *file, int line)
+PUB_FUNC char *tcc_strdup_debug(TCCState* S, const char *str, const char *file, int line)
{
char *ptr;
ptr = tcc_malloc_debug(S, strlen(str) + 1, file, line);
@@ -532,7 +532,7 @@ int vio_close(vio_fd *fd) {
/********************************************************/
/* dynarrays */
-ST_FUNC void dynarray_add(TCCState *S, void *ptab, int *nb_ptr, void *data)
+ST_FUNC void dynarray_add(TCCState* S, void *ptab, int *nb_ptr, void *data)
{
int nb, nb_alloc;
void **pp;
@@ -552,7 +552,7 @@ ST_FUNC void dynarray_add(TCCState *S, void *ptab, int *nb_ptr, void *data)
*nb_ptr = nb;
}
-ST_FUNC void dynarray_reset(TCCState *S, void *pp, int *n)
+ST_FUNC void dynarray_reset(TCCState* S, void *pp, int *n)
{
void **p;
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 *
/* error1() modes */
enum { ERROR_WARN, ERROR_NOABORT, ERROR_ERROR };
-static void error1(TCCState *S, int mode, const char *fmt, va_list ap)
+static void error1(TCCState* S, int mode, const char *fmt, va_list ap)
{
BufferedFile **pf, *f;
CString cs;
@@ -650,7 +650,7 @@ static void error1(TCCState *S, int mode, const char *fmt, va_list ap)
cstr_printf(S, &cs, "In file included from %s:%d:\n",
(*pf)->filename, (*pf)->line_num);
cstr_printf(S, &cs, "%s:%d: ",
- f->filename, (*pf)->line_num - !!(S->tok_flags & TOK_FLAG_BOL));
+ f->filename, (*pf)->line_num - !!(S->tccpp_tok_flags & TOK_FLAG_BOL));
} else if (S->current_filename) {
cstr_printf(S, &cs, "%s: ", S->current_filename);
}
@@ -699,7 +699,7 @@ LIBTCCAPI void *tcc_get_error_opaque(TCCState *S)
}
/* error without aborting current compilation */
-PUB_FUNC void _tcc_error_noabort(TCCState *S, const char *fmt, ...)
+PUB_FUNC void _tcc_error_noabort(TCCState* S, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -707,14 +707,14 @@ PUB_FUNC void _tcc_error_noabort(TCCState *S, const char *fmt, ...)
va_end(ap);
}
-PUB_FUNC void _tcc_error(TCCState *S, const char *fmt, ...)
+PUB_FUNC void _tcc_error(TCCState* S, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
for (;;) error1(S, ERROR_ERROR, fmt, ap);
}
-PUB_FUNC void _tcc_warning(TCCState *S, const char *fmt, ...)
+PUB_FUNC void _tcc_warning(TCCState* S, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -744,10 +744,10 @@ ST_FUNC void tcc_open_bf(TCCState *S, const char *filename, int initlen)
bf->fd = -1;
bf->prev = S->tccpp_file;
S->tccpp_file = bf;
- S->tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
+ S->tccpp_tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
}
-ST_FUNC void tcc_close(TCCState *S)
+ST_FUNC void tcc_close(TCCState* S)
{
BufferedFile *bf = S->tccpp_file;
if (bf->fd > 0) {
@@ -1388,7 +1388,7 @@ static const char *skip_linker_arg(const char **str)
return s2;
}
-static void copy_linker_arg(TCCState *S, char **pp, const char *s, int sep)
+static void copy_linker_arg(TCCState* S, char **pp, const char *s, int sep)
{
const char *q = s;
char *p = *pp;
@@ -1723,7 +1723,7 @@ static void args_parser_add_file(TCCState *S, const char* filename, int filetype
dynarray_add(S, &S->files, &S->nb_files, f);
}
-static int args_parser_make_argv(TCCState *S, const char *r, int *argc, char ***argv)
+static int args_parser_make_argv(TCCState* S, const char *r, int *argc, char ***argv)
{
int ret = 0, q, c;
CString str;
diff --git a/riscv64-asm.c b/riscv64-asm.c
index e1483a2..fbb60ba 100644
--- a/riscv64-asm.c
+++ b/riscv64-asm.c
@@ -9,9 +9,9 @@
#define CONFIG_TCC_ASM
#define NB_ASM_REGS 32
-ST_FUNC void g(TCCState *S, int c);
-ST_FUNC void gen_le16(TCCState *S, int c);
-ST_FUNC void gen_le32(TCCState *S, int c);
+ST_FUNC void g(TCCState* S, int c);
+ST_FUNC void gen_le16(TCCState* S, int c);
+ST_FUNC void gen_le32(TCCState* S, int c);
/*************************************************************/
#else
@@ -20,44 +20,44 @@ ST_FUNC void gen_le32(TCCState *S, int c);
#include "tcc.h"
/* XXX: make it faster ? */
-ST_FUNC void g(TCCState *S, int c)
+ST_FUNC void g(TCCState* S, int c)
{
int ind1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
- ind1 = S->ind + 1;
+ ind1 = S->tccgen_ind + 1;
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind] = c;
- S->ind = ind1;
+ cur_text_section->data[S->tccgen_ind] = c;
+ S->tccgen_ind = ind1;
}
-ST_FUNC void gen_le16 (TCCState *S, int i)
+ST_FUNC void gen_le16 (TCCState* S, int i)
{
g(S, i);
g(S, i>>8);
}
-ST_FUNC void gen_le32 (TCCState *S, int i)
+ST_FUNC void gen_le32 (TCCState* S, int i)
{
int ind1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
- ind1 = S->ind + 4;
+ ind1 = S->tccgen_ind + 4;
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind++] = i & 0xFF;
- cur_text_section->data[S->ind++] = (i >> 8) & 0xFF;
- cur_text_section->data[S->ind++] = (i >> 16) & 0xFF;
- cur_text_section->data[S->ind++] = (i >> 24) & 0xFF;
+ cur_text_section->data[S->tccgen_ind++] = i & 0xFF;
+ cur_text_section->data[S->tccgen_ind++] = (i >> 8) & 0xFF;
+ cur_text_section->data[S->tccgen_ind++] = (i >> 16) & 0xFF;
+ cur_text_section->data[S->tccgen_ind++] = (i >> 24) & 0xFF;
}
-ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe)
+ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe)
{
gen_le32(S, pe->v);
}
-static void asm_emit_opcode(TCCState *S, uint32_t opcode) {
+static void asm_emit_opcode(TCCState* S, uint32_t opcode) {
gen_le32(S, opcode);
}
@@ -128,12 +128,12 @@ static void parse_operand(TCCState *S, Operand *op)
op->type = 0;
- if ((reg = asm_parse_regvar(S, S->tok)) != -1) {
+ if ((reg = asm_parse_regvar(S, S->tccpp_tok)) != -1) {
next(S); // skip register name
op->type = OP_REG;
op->reg = (uint8_t) reg;
return;
- } else if (S->tok == '$') {
+ } else if (S->tccpp_tok == '$') {
/* constant value */
next(S); // skip '#' or '$'
}
@@ -207,11 +207,11 @@ static void asm_emit_u(TCCState *S, int token, uint32_t opcode, const Operand* r
gen_le32(S, opcode | ENCODE_RD(rd->reg) | (rs2->e.v << 12));
}
-static void asm_binary_opcode(TCCState *S, int token)
+static void asm_binary_opcode(TCCState* S, int token)
{
Operand ops[2];
parse_operand(S, &ops[0]);
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -230,7 +230,7 @@ static void asm_binary_opcode(TCCState *S, int token)
}
/* caller: Add funct3, funct7 into opcode */
-static void asm_emit_r(TCCState *S, int token, uint32_t opcode, const Operand* rd, const Operand* rs1, const Operand* rs2)
+static void asm_emit_r(TCCState* S, int token, uint32_t opcode, const Operand* rd, const Operand* rs1, const Operand* rs2)
{
if (rd->type != OP_REG) {
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
}
/* caller: Add funct3 into opcode */
-static void asm_emit_i(TCCState *S, int token, uint32_t opcode, const Operand* rd, const Operand* rs1, const Operand* rs2)
+static void asm_emit_i(TCCState* S, int token, uint32_t opcode, const Operand* rd, const Operand* rs1, const Operand* rs2)
{
if (rd->type != OP_REG) {
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)
{
Operand ops[3];
parse_operand(S, &ops[0]);
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
parse_operand(S, &ops[1]);
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -336,16 +336,16 @@ static void asm_shift_opcode(TCCState *S, int token)
}
}
-static void asm_data_processing_opcode(TCCState *S, int token)
+static void asm_data_processing_opcode(TCCState* S, int token)
{
Operand ops[3];
parse_operand(S, &ops[0]);
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
parse_operand(S, &ops[1]);
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -414,7 +414,7 @@ static void asm_data_processing_opcode(TCCState *S, int token)
}
/* caller: Add funct3 to opcode */
-static void asm_emit_s(TCCState *S, int token, uint32_t opcode, const Operand* rs1, const Operand* rs2, const Operand* imm)
+static void asm_emit_s(TCCState* S, int token, uint32_t opcode, const Operand* rs1, const Operand* rs2, const Operand* imm)
{
if (rs1->type != OP_REG) {
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
}
}
-static void asm_data_transfer_opcode(TCCState *S, int token)
+static void asm_data_transfer_opcode(TCCState* S, int token)
{
Operand ops[3];
parse_operand(S, &ops[0]);
@@ -450,7 +450,7 @@ static void asm_data_transfer_opcode(TCCState *S, int token)
expect(S, "register");
return;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -459,7 +459,7 @@ static void asm_data_transfer_opcode(TCCState *S, int token)
expect(S, "register");
return;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -511,7 +511,7 @@ static void asm_data_transfer_opcode(TCCState *S, int token)
}
}
-static void asm_branch_opcode(TCCState *S, int token)
+static void asm_branch_opcode(TCCState* S, int token)
{
// Branch (RS1,RS2,IMM); SB-format
uint32_t opcode = (0x18 << 2) | 3;
@@ -522,7 +522,7 @@ static void asm_branch_opcode(TCCState *S, int token)
expect(S, "register");
return;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -531,7 +531,7 @@ static void asm_branch_opcode(TCCState *S, int token)
expect(S, "register");
return;
}
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
next(S);
else
expect(S, "','");
@@ -709,7 +709,7 @@ ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str)
clobber_regs[reg] = 1;
}
-ST_FUNC int asm_parse_regvar (TCCState *S, int t)
+ST_FUNC int asm_parse_regvar (TCCState* S, int t)
{
if (t >= TOK_ASM_x0 && t <= TOK_ASM_pc) { /* register name */
switch (t) {
diff --git a/riscv64-gen.c b/riscv64-gen.c
index 979ac3c..8a1ef7c 100644
--- a/riscv64-gen.c
+++ b/riscv64-gen.c
@@ -100,37 +100,37 @@ static int is_freg(int r)
return r >= 8 && r < 16;
}
-ST_FUNC void o(TCCState *S, unsigned int c)
+ST_FUNC void o(TCCState* S, unsigned int c)
{
- int ind1 = S->ind + 4;
- if (S->nocode_wanted)
+ int ind1 = S->tccgen_ind + 4;
+ if (S->tccgen_nocode_wanted)
return;
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- write32le(cur_text_section->data + S->ind, c);
- S->ind = ind1;
+ write32le(cur_text_section->data + S->tccgen_ind, c);
+ S->tccgen_ind = ind1;
}
-static void EIu(TCCState *S, uint32_t opcode, uint32_t func3,
+static void EIu(TCCState* S, uint32_t opcode, uint32_t func3,
uint32_t rd, uint32_t rs1, uint32_t imm)
{
o(S, opcode | (func3 << 12) | (rd << 7) | (rs1 << 15) | (imm << 20));
}
-static void ER(TCCState *S, uint32_t opcode, uint32_t func3,
+static void ER(TCCState* S, uint32_t opcode, uint32_t func3,
uint32_t rd, uint32_t rs1, uint32_t rs2, uint32_t func7)
{
o(S, opcode | func3 << 12 | rd << 7 | rs1 << 15 | rs2 << 20 | func7 << 25);
}
-static void EI(TCCState *S, uint32_t opcode, uint32_t func3,
+static void EI(TCCState* S, uint32_t opcode, uint32_t func3,
uint32_t rd, uint32_t rs1, uint32_t imm)
{
assert(! ((imm + (1 << 11)) >> 12));
EIu(S, opcode, func3, rd, rs1, imm);
}
-static void ES(TCCState *S, uint32_t opcode, uint32_t func3,
+static void ES(TCCState* S, uint32_t opcode, uint32_t func3,
uint32_t rs1, uint32_t rs2, uint32_t imm)
{
assert(! ((imm + (1 << 11)) >> 12));
@@ -139,7 +139,7 @@ static void ES(TCCState *S, uint32_t opcode, uint32_t func3,
}
// Patch all branches in list pointed to by t to branch to a:
-ST_FUNC void gsym_addr(TCCState *S, int t_, int a_)
+ST_FUNC void gsym_addr(TCCState* S, int t_, int a_)
{
uint32_t t = t_;
uint32_t a = a_;
@@ -158,7 +158,7 @@ ST_FUNC void gsym_addr(TCCState *S, int t_, int a_)
}
}
-static int load_symofs(TCCState *S, int r, SValue *sv, int forstore)
+static int load_symofs(TCCState* S, int r, SValue *sv, int forstore)
{
int rr, doload = 0;
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)
Sym label = {0};
assert(v == VT_CONST);
if (sv->sym->type.t & VT_STATIC) { // XXX do this per linker relax
- greloca(S, cur_text_section, sv->sym, S->ind,
+ greloca(S, cur_text_section, sv->sym, S->tccgen_ind,
R_RISCV_PCREL_HI20, sv->c.i);
sv->c.i = 0;
} else {
if (((unsigned)fc + (1 << 11)) >> 12)
tcc_error(S, "unimp: large addend for global address (0x%lx)", (long)sv->c.i);
- greloca(S, cur_text_section, sv->sym, S->ind,
+ greloca(S, cur_text_section, sv->sym, S->tccgen_ind,
R_RISCV_GOT_HI20, 0);
doload = 1;
}
label.type.t = VT_VOID | VT_STATIC;
- put_extern_sym(S, &label, cur_text_section, S->ind, 0);
+ put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0);
rr = is_ireg(r) ? ireg(r) : 5;
o(S, 0x17 | (rr << 7)); // auipc RR, 0 %pcrel_hi(sym)+addend
- greloca(S, cur_text_section, &label, S->ind,
+ greloca(S, cur_text_section, &label, S->tccgen_ind,
doload || !forstore
? R_RISCV_PCREL_LO12_I : R_RISCV_PCREL_LO12_S, 0);
if (doload) {
@@ -201,7 +201,7 @@ static int load_symofs(TCCState *S, int r, SValue *sv, int forstore)
return rr;
}
-static void load_large_constant(TCCState *S, int rr, int fc, uint32_t pi)
+static void load_large_constant(TCCState* S, int rr, int fc, uint32_t pi)
{
if (fc < 0)
pi++;
@@ -215,7 +215,7 @@ static void load_large_constant(TCCState *S, int rr, int fc, uint32_t pi)
EI(S, 0x13, 1, rr, rr, 8); // slli RR, RR, 8
}
-ST_FUNC void load(TCCState *S, int r, SValue *sv)
+ST_FUNC void load(TCCState* S, int r, SValue *sv)
{
int fr = sv->r;
int v = fr & VT_VALMASK;
@@ -314,9 +314,9 @@ ST_FUNC void load(TCCState *S, int r, SValue *sv)
| (func7 << 25)); // fmv.{w.x, x.w, d.x, x.d} RR, VR
}
} else if (v == VT_CMP) {
- int op = S->vtop->cmp_op;
- int a = S->vtop->cmp_r & 0xff;
- int b = (S->vtop->cmp_r >> 8) & 0xff;
+ int op = S->tccgen_vtop->cmp_op;
+ int a = S->tccgen_vtop->cmp_r & 0xff;
+ int b = (S->tccgen_vtop->cmp_r >> 8) & 0xff;
int inv = 0;
switch (op) {
case TOK_ULT:
@@ -353,14 +353,14 @@ ST_FUNC void load(TCCState *S, int r, SValue *sv)
int t = v & 1;
assert(is_ireg(r));
EI(S, 0x13, 0, rr, 0, t); // addi RR, x0, t
- gjmp_addr(S, S->ind + 8);
+ gjmp_addr(S, S->tccgen_ind + 8);
gsym(S, fc);
EI(S, 0x13, 0, rr, 0, t ^ 1); // addi RR, x0, !t
} else
tcc_error(S, "unimp: load(non-const)");
}
-ST_FUNC void store(TCCState *S, int r, SValue *sv)
+ST_FUNC void store(TCCState* S, int r, SValue *sv)
{
int fr = sv->r & VT_VALMASK;
int rr = is_ireg(r) ? ireg(r) : freg(r), ptrreg;
@@ -403,22 +403,22 @@ ST_FUNC void store(TCCState *S, int r, SValue *sv)
ptrreg, rr, fc); // RR, fc(base)
}
-static void gcall_or_jmp(TCCState *S, int docall)
+static void gcall_or_jmp(TCCState* S, int docall)
{
int tr = docall ? 1 : 5; // ra or t0
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
- ((S->vtop->r & VT_SYM) && S->vtop->c.i == (int)S->vtop->c.i)) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
+ ((S->tccgen_vtop->r & VT_SYM) && S->tccgen_vtop->c.i == (int)S->tccgen_vtop->c.i)) {
/* constant symbolic case -> simple relocation */
- greloca(S, cur_text_section, S->vtop->sym, S->ind,
- R_RISCV_CALL_PLT, (int)S->vtop->c.i);
+ greloca(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind,
+ R_RISCV_CALL_PLT, (int)S->tccgen_vtop->c.i);
o(S, 0x17 | (tr << 7)); // auipc TR, 0 %call(func)
EI(S, 0x67, 0, tr, tr, 0);// jalr TR, r(TR)
- } else if (S->vtop->r < VT_CONST) {
- int r = ireg(S->vtop->r);
+ } else if (S->tccgen_vtop->r < VT_CONST) {
+ int r = ireg(S->tccgen_vtop->r);
EI(S, 0x67, 0, tr, r, 0); // jalr TR, 0(R)
} else {
int r = TREG_RA;
- load(S, r, S->vtop);
+ load(S, r, S->tccgen_vtop);
r = ireg(r);
EI(S, 0x67, 0, tr, r, 0); // jalr TR, 0(R)
}
@@ -426,20 +426,20 @@ static void gcall_or_jmp(TCCState *S, int docall)
#if defined(CONFIG_TCC_BCHECK)
-static void gen_bounds_call(TCCState *S, int v)
+static void gen_bounds_call(TCCState* S, int v)
{
Sym *sym = external_helper_sym(S, v);
- greloca(S, cur_text_section, sym, S->ind, R_RISCV_CALL_PLT, 0);
+ greloca(S, cur_text_section, sym, S->tccgen_ind, R_RISCV_CALL_PLT, 0);
o(S, 0x17 | (1 << 7)); // auipc TR, 0 %call(func)
EI(S, 0x67, 0, 1, 1, 0); // jalr TR, r(TR)
}
-static void gen_bounds_prolog(TCCState *S)
+static void gen_bounds_prolog(TCCState* S)
{
/* leave some room for bound checking code */
S->func_bound_offset = lbounds_section->data_offset;
- S->func_bound_ind = S->ind;
+ S->func_bound_ind = S->tccgen_ind;
S->func_bound_add_epilog = 0;
o(S, 0x00000013); /* ld a0,#lbound section pointer */
o(S, 0x00000013);
@@ -447,7 +447,7 @@ static void gen_bounds_prolog(TCCState *S)
o(S, 0x00000013);
}
-static void gen_bounds_epilog(TCCState *S)
+static void gen_bounds_epilog(TCCState* S)
{
addr_t saved_ind;
addr_t *bounds_ptr;
@@ -463,31 +463,31 @@ static void gen_bounds_epilog(TCCState *S)
bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t));
*bounds_ptr = 0;
- sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section,
+ sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section,
S->func_bound_offset, lbounds_section->data_offset);
label.type.t = VT_VOID | VT_STATIC;
/* generate bound local allocation */
if (offset_modified) {
- saved_ind = S->ind;
- S->ind = S->func_bound_ind;
- put_extern_sym(S, &label, cur_text_section, S->ind, 0);
- greloca(S, cur_text_section, sym_data, S->ind, R_RISCV_GOT_HI20, 0);
+ saved_ind = S->tccgen_ind;
+ S->tccgen_ind = S->func_bound_ind;
+ put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0);
+ greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_RISCV_GOT_HI20, 0);
o(S, 0x17 | (10 << 7)); // auipc a0, 0 %pcrel_hi(sym)+addend
- greloca(S, cur_text_section, &label, S->ind, R_RISCV_PCREL_LO12_I, 0);
+ greloca(S, cur_text_section, &label, S->tccgen_ind, R_RISCV_PCREL_LO12_I, 0);
EI(S, 0x03, 3, 10, 10, 0); // ld a0, 0(a0)
gen_bounds_call(S, TOK___bound_local_new);
- S->ind = saved_ind;
+ S->tccgen_ind = saved_ind;
label.c = 0; /* force new local ELF symbol */
}
/* generate bound check local freeing */
o(S, 0xe02a1101); /* addi sp,sp,-32 sd a0,0(sp) */
o(S, 0xa82ae42e); /* sd a1,8(sp) fsd fa0,16(sp) */
- put_extern_sym(S, &label, cur_text_section, S->ind, 0);
- greloca(S, cur_text_section, sym_data, S->ind, R_RISCV_GOT_HI20, 0);
+ put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0);
+ greloca(S, cur_text_section, sym_data, S->tccgen_ind, R_RISCV_GOT_HI20, 0);
o(S, 0x17 | (10 << 7)); // auipc a0, 0 %pcrel_hi(sym)+addend
- greloca(S, cur_text_section, &label, S->ind, R_RISCV_PCREL_LO12_I, 0);
+ greloca(S, cur_text_section, &label, S->tccgen_ind, R_RISCV_PCREL_LO12_I, 0);
EI(S, 0x03, 3, 10, 10, 0); // ld a0, 0(a0)
gen_bounds_call(S, TOK___bound_local_delete);
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)
}
}
-ST_FUNC void gfunc_call(TCCState *S, int nb_args)
+ST_FUNC void gfunc_call(TCCState* S, int nb_args)
{
int i, align, size, areg[2];
int *info = tcc_malloc(S, (nb_args + 1) * sizeof (int));
@@ -556,11 +556,11 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
areg[0] = 0; /* int arg regs */
areg[1] = 8; /* float arg regs */
- sa = S->vtop[-nb_args].type.ref->next;
+ sa = S->tccgen_vtop[-nb_args].type.ref->next;
for (i = 0; i < nb_args; i++) {
int nregs, byref = 0, tempofs;
int prc[3], fieldofs[3];
- sv = &S->vtop[1 + i - nb_args];
+ sv = &S->tccgen_vtop[1 + i - nb_args];
sv->type.t &= ~VT_ARRAY; // XXX this should be done in tccgen.c
size = type_size(&sv->type, &align);
if (size > 16) {
@@ -617,7 +617,7 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
stack_add = stack_adj + tempspace;
/* fetch cpu flag before generating any code */
- if ((S->vtop->r & VT_VALMASK) == VT_CMP)
+ if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP)
gv(S, RC_INT);
if (stack_add) {
@@ -631,15 +631,15 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
for (i = ofs = 0; i < nb_args; i++) {
if (info[i] & (64 | 32)) {
vrotb(S, nb_args - i);
- size = type_size(&S->vtop->type, &align);
+ size = type_size(&S->tccgen_vtop->type, &align);
if (info[i] & 64) {
- vset(S, &S->char_pointer_type, TREG_SP, 0);
+ vset(S, &S->tccgen_char_pointer_type, TREG_SP, 0);
vpushi(S, stack_adj + (info[i] >> 7));
gen_op(S, '+');
- vpushv(S, S->vtop); // this replaces the old argument
+ vpushv(S, S->tccgen_vtop); // this replaces the old argument
vrott(S, 3);
indir(S);
- S->vtop->type = S->vtop[-1].type;
+ S->tccgen_vtop->type = S->tccgen_vtop[-1].type;
vswap(S);
vstore(S);
vpop(S);
@@ -649,18 +649,18 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
if (align < XLEN)
align = XLEN;
/* Once we support offseted regs we can do this:
- vset(S, &S->vtop->type, TREG_SP | VT_LVAL, ofs);
+ vset(S, &S->tccgen_vtop->type, TREG_SP | VT_LVAL, ofs);
to construct the lvalue for the outgoing stack slot,
until then we have to jump through hoops. */
- vset(S, &S->char_pointer_type, TREG_SP, 0);
+ vset(S, &S->tccgen_char_pointer_type, TREG_SP, 0);
ofs = (ofs + align - 1) & -align;
vpushi(S, ofs);
gen_op(S, '+');
indir(S);
- S->vtop->type = S->vtop[-1].type;
+ S->tccgen_vtop->type = S->tccgen_vtop[-1].type;
vswap(S);
vstore(S);
- S->vtop->r = S->vtop->r2 = VT_CONST; // this arg is done
+ S->tccgen_vtop->r = S->tccgen_vtop->r2 = VT_CONST; // this arg is done
ofs += size;
}
vrott(S, nb_args - i);
@@ -680,11 +680,11 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
r2 = r2 & 64 ? 0 : (r2 >> 7) & 31;
assert(r2 <= 16);
vrotb(S, i+1);
- origtype = S->vtop->type;
- size = type_size(&S->vtop->type, &align);
+ origtype = S->tccgen_vtop->type;
+ size = type_size(&S->tccgen_vtop->type, &align);
if (size == 0)
goto done;
- loadt = S->vtop->type.t & VT_BTYPE;
+ loadt = S->tccgen_vtop->type.t & VT_BTYPE;
if (loadt == VT_STRUCT) {
loadt = (ii >> 12) & VT_BTYPE;
}
@@ -697,18 +697,18 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
r2--;
} else if (r2) {
test_lvalue(S);
- vpushv(S, S->vtop);
+ vpushv(S, S->tccgen_vtop);
}
- S->vtop->type.t = loadt | (S->vtop->type.t & VT_UNSIGNED);
+ S->tccgen_vtop->type.t = loadt | (S->tccgen_vtop->type.t & VT_UNSIGNED);
gv(S, r < 8 ? RC_R(r) : RC_F(r - 8));
- S->vtop->type = origtype;
+ S->tccgen_vtop->type = origtype;
if (r2 && loadt != VT_LDOUBLE) {
r2--;
assert(r2 < 16 || r2 == TREG_RA);
vswap(S);
gaddrof(S);
- S->vtop->type = S->char_pointer_type;
+ S->tccgen_vtop->type = S->tccgen_char_pointer_type;
vpushi(S, ii >> 20);
#ifdef CONFIG_TCC_BCHECK
if ((origtype.t & VT_BTYPE) == VT_STRUCT)
@@ -719,27 +719,27 @@ ST_FUNC void gfunc_call(TCCState *S, int nb_args)
S->do_bounds_check = bc_save;
#endif
indir(S);
- S->vtop->type = origtype;
- loadt = S->vtop->type.t & VT_BTYPE;
+ S->tccgen_vtop->type = origtype;
+ loadt = S->tccgen_vtop->type.t & VT_BTYPE;
if (loadt == VT_STRUCT) {
loadt = (ii >> 16) & VT_BTYPE;
}
save_reg_upstack(S, r2, 1);
- S->vtop->type.t = loadt | (S->vtop->type.t & VT_UNSIGNED);
- load(S, r2, S->vtop);
+ S->tccgen_vtop->type.t = loadt | (S->tccgen_vtop->type.t & VT_UNSIGNED);
+ load(S, r2, S->tccgen_vtop);
assert(r2 < VT_CONST);
- S->vtop--;
- S->vtop->r2 = r2;
+ S->tccgen_vtop--;
+ S->tccgen_vtop->r2 = r2;
}
if (info[nb_args - 1 - i] & 16) {
- ES(S, 0x23, 3, 2, ireg(S->vtop->r2), splitofs); // sd t0, ofs(sp)
- S->vtop->r2 = VT_CONST;
- } else if (loadt == VT_LDOUBLE && S->vtop->r2 != r2) {
- assert(S->vtop->r2 <= 7 && r2 <= 7);
+ ES(S, 0x23, 3, 2, ireg(S->tccgen_vtop->r2), splitofs); // sd t0, ofs(sp)
+ S->tccgen_vtop->r2 = VT_CONST;
+ } else if (loadt == VT_LDOUBLE && S->tccgen_vtop->r2 != r2) {
+ assert(S->tccgen_vtop->r2 <= 7 && r2 <= 7);
/* XXX we'd like to have 'gv' move directly into
the right class instead of us fixing it up. */
- EI(S, 0x13, 0, ireg(r2), ireg(S->vtop->r2), 0); // mv Ra+1, RR2
- S->vtop->r2 = r2;
+ EI(S, 0x13, 0, ireg(r2), ireg(S->tccgen_vtop->r2), 0); // mv Ra+1, RR2
+ S->tccgen_vtop->r2 = r2;
}
done:
vrott(S, i+1);
@@ -748,7 +748,7 @@ done:
vrotb(S, nb_args + 1);
save_regs(S, nb_args + 1);
gcall_or_jmp(S, 1);
- S->vtop -= nb_args + 1;
+ S->tccgen_vtop -= nb_args + 1;
if (stack_add) {
if (stack_add >= 0x1000) {
o(S, 0x37 | (5 << 7) | (stack_add & 0xfffff000)); //lui t0, upper(v)
@@ -763,7 +763,7 @@ done:
static int func_sub_sp_offset, num_va_regs, func_va_list_ofs;
-ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
+ST_FUNC void gfunc_prolog(TCCState* S, Sym *func_sym)
{
CType *func_type = &func_sym->type;
int i, addr, align, size;
@@ -773,9 +773,9 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
CType *type;
sym = func_type->ref;
- S->loc = -16; // for ra and s0
- func_sub_sp_offset = S->ind;
- S->ind += 5 * 4;
+ S->tccgen_loc = -16; // for ra and s0
+ func_sub_sp_offset = S->tccgen_ind;
+ S->tccgen_ind += 5 * 4;
areg[0] = 0, areg[1] = 0;
addr = 0;
@@ -783,9 +783,9 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
implicit pointer parameter */
size = type_size(&S->tccgen_func_vt, &align);
if (size > 2 * XLEN) {
- S->loc -= 8;
- S->tccgen_func_vc = S->loc;
- ES(S, 0x23, 3, 8, 10 + areg[0]++, S->loc); // sd a0, loc(s0)
+ S->tccgen_loc -= 8;
+ S->tccgen_func_vc = S->tccgen_loc;
+ ES(S, 0x23, 3, 8, 10 + areg[0]++, S->tccgen_loc); // sd a0, loc(s0)
}
/* define parameters */
while ((sym = sym->next) != NULL) {
@@ -795,7 +795,7 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
type = &sym->type;
size = type_size(type, &align);
if (size > 2 * XLEN) {
- type = &S->char_pointer_type;
+ type = &S->tccgen_char_pointer_type;
size = align = byref = 8;
}
reg_pass(type, prc, fieldofs, 1);
@@ -810,18 +810,18 @@ ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym)
param_addr = addr;
addr += size;
} else {
- S->loc -= regcount * 8; // XXX could reserve only 'size' bytes
- param_addr = S->loc;
+ S->tccgen_loc -= regcount * 8; // XXX could reserve only 'size' bytes
+ param_addr = S->tccgen_loc;
for (i = 0; i < regcount; i++) {
if (areg[prc[1+i] - 1] >= 8) {
assert(i == 1 && regcount == 2 && !(addr & 7));
EI(S, 0x03, 3, 5, 8, addr); // ld t0, addr(s0)
addr += 8;
- ES(S, 0x23, 3, 8, 5, S->loc + i*8); // sd t0, loc(s0)
+ ES(S, 0x23, 3, 8, 5, S->tccgen_loc + i*8); // sd t0, loc(s0)
} else if (prc[1+i] == RC_FLOAT) {
- ES(S, 0x27, (size / regcount) == 4 ? 2 : 3, 8, 10 + areg[1]++, S->loc + (fieldofs[i+1] >> 4)); // fs[wd] FAi, loc(s0)
+ ES(S, 0x27, (size / regcount) == 4 ? 2 : 3, 8, 10 + areg[1]++, S->tccgen_loc + (fieldofs[i+1] >> 4)); // fs[wd] FAi, loc(s0)
} else {
- ES(S, 0x23, 3, 8, 10 + areg[0]++, S->loc + i*8); // sd aX, loc(s0) // XXX
+ ES(S, 0x23, 3, 8, 10 + areg[0]++, S->tccgen_loc + i*8); // sd aX, loc(s0) // XXX
}
}
}
@@ -864,22 +864,22 @@ ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret,
return nregs;
}
-ST_FUNC void arch_transfer_ret_regs(TCCState *S, int aftercall)
+ST_FUNC void arch_transfer_ret_regs(TCCState* S, int aftercall)
{
int prc[3], fieldofs[3];
- reg_pass(&S->vtop->type, prc, fieldofs, 1);
+ reg_pass(&S->tccgen_vtop->type, prc, fieldofs, 1);
assert(prc[0] == 2 && prc[1] != prc[2] && !(fieldofs[1] >> 4));
- assert(S->vtop->r == (VT_LOCAL | VT_LVAL));
- vpushv(S, S->vtop);
- S->vtop->type.t = fieldofs[1] & VT_BTYPE;
- (aftercall ? store : load)(S, prc[1] == RC_INT ? REG_IRET : REG_FRET, S->vtop);
- S->vtop->c.i += fieldofs[2] >> 4;
- S->vtop->type.t = fieldofs[2] & VT_BTYPE;
- (aftercall ? store : load)(S, prc[2] == RC_INT ? REG_IRET : REG_FRET, S->vtop);
- S->vtop--;
+ assert(S->tccgen_vtop->r == (VT_LOCAL | VT_LVAL));
+ vpushv(S, S->tccgen_vtop);
+ S->tccgen_vtop->type.t = fieldofs[1] & VT_BTYPE;
+ (aftercall ? store : load)(S, prc[1] == RC_INT ? REG_IRET : REG_FRET, S->tccgen_vtop);
+ S->tccgen_vtop->c.i += fieldofs[2] >> 4;
+ S->tccgen_vtop->type.t = fieldofs[2] & VT_BTYPE;
+ (aftercall ? store : load)(S, prc[2] == RC_INT ? REG_IRET : REG_FRET, S->tccgen_vtop);
+ S->tccgen_vtop--;
}
-ST_FUNC void gfunc_epilog(TCCState *S)
+ST_FUNC void gfunc_epilog(TCCState* S)
{
int v, saved_ind, d, large_ofs_ind;
@@ -888,8 +888,8 @@ ST_FUNC void gfunc_epilog(TCCState *S)
gen_bounds_epilog(S);
#endif
- S->loc = (S->loc - num_va_regs * 8);
- d = v = (-S->loc + 15) & -16;
+ S->tccgen_loc = (S->tccgen_loc - num_va_regs * 8);
+ d = v = (-S->tccgen_loc + 15) & -16;
if (v >= (1 << 11)) {
d = 16;
@@ -901,7 +901,7 @@ ST_FUNC void gfunc_epilog(TCCState *S)
EI(S, 0x03, 3, 8, 2, d - 16 - num_va_regs * 8); // ld s0, v-16(sp)
EI(S, 0x13, 0, 2, 2, d); // addi sp, sp, v
EI(S, 0x67, 0, 0, 1, 0); // jalr x0, 0(x1), aka ret
- large_ofs_ind = S->ind;
+ large_ofs_ind = S->tccgen_ind;
if (v >= (1 << 11)) {
EI(S, 0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d
o(S, 0x37 | (5 << 7) | ((0x800 + (v-16)) & 0xfffff000)); //lui t0, upper(v)
@@ -909,9 +909,9 @@ ST_FUNC void gfunc_epilog(TCCState *S)
ER(S, 0x33, 0, 2, 2, 5, 0x20); // sub sp, sp, t0
gjmp_addr(S, func_sub_sp_offset + 5*4);
}
- saved_ind = S->ind;
+ saved_ind = S->tccgen_ind;
- S->ind = func_sub_sp_offset;
+ S->tccgen_ind = func_sub_sp_offset;
EI(S, 0x13, 0, 2, 2, -d); // addi sp, sp, -d
ES(S, 0x23, 3, 2, 1, d - 8 - num_va_regs * 8); // sd ra, d-8(sp)
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)
EI(S, 0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d
else
gjmp_addr(S, large_ofs_ind);
- if ((S->ind - func_sub_sp_offset) != 5*4)
+ if ((S->tccgen_ind - func_sub_sp_offset) != 5*4)
EI(S, 0x13, 0, 0, 0, 0); // addi x0, x0, 0 == nop
- S->ind = saved_ind;
+ S->tccgen_ind = saved_ind;
}
ST_FUNC void gen_va_start(TCCState *S)
{
- S->vtop--;
- vset(S, &S->char_pointer_type, VT_LOCAL, func_va_list_ofs);
+ S->tccgen_vtop--;
+ vset(S, &S->tccgen_char_pointer_type, VT_LOCAL, func_va_list_ofs);
}
-ST_FUNC void gen_fill_nops(TCCState *S, int bytes)
+ST_FUNC void gen_fill_nops(TCCState* S, int bytes)
{
if ((bytes & 3))
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)
}
// Generate forward branch to label:
-ST_FUNC int gjmp(TCCState *S, int t)
+ST_FUNC int gjmp(TCCState* S, int t)
{
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return t;
o(S, t);
- return S->ind - 4;
+ return S->tccgen_ind - 4;
}
// Generate branch to known address:
-ST_FUNC void gjmp_addr(TCCState *S, int a)
+ST_FUNC void gjmp_addr(TCCState* S, int a)
{
- uint32_t r = a - S->ind, imm;
+ uint32_t r = a - S->tccgen_ind, imm;
if ((r + (1 << 21)) & ~((1U << 22) - 2)) {
o(S, 0x17 | (5 << 7) | (((r + 0x800) & 0xfffff000))); // lui RR, up(r)
r = (int)r << 20 >> 20;
@@ -966,11 +966,11 @@ ST_FUNC void gjmp_addr(TCCState *S, int a)
}
}
-ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
+ST_FUNC int gjmp_cond(TCCState* S, int op, int t)
{
int tmp;
- int a = S->vtop->cmp_r & 0xff;
- int b = (S->vtop->cmp_r >> 8) & 0xff;
+ int a = S->tccgen_vtop->cmp_r & 0xff;
+ int b = (S->tccgen_vtop->cmp_r >> 8) & 0xff;
switch (op) {
case TOK_ULT: op = 6; break;
case TOK_UGE: op = 7; break;
@@ -987,7 +987,7 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
return gjmp(S, t);
}
-ST_FUNC int gjmp_append(TCCState *S, int n, int t)
+ST_FUNC int gjmp_append(TCCState* S, int n, int t)
{
void *p;
/* insert jump list n into t */
@@ -1001,22 +1001,22 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t)
return t;
}
-static void gen_opil(TCCState *S, int op, int ll)
+static void gen_opil(TCCState* S, int op, int ll)
{
int a, b, d;
int func3 = 0;
ll = ll ? 0 : 8;
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
- int fc = S->vtop->c.i;
- if (fc == S->vtop->c.i && !(((unsigned)fc + (1 << 11)) >> 12)) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ int fc = S->tccgen_vtop->c.i;
+ if (fc == S->tccgen_vtop->c.i && !(((unsigned)fc + (1 << 11)) >> 12)) {
int cll = 0;
int m = ll ? 31 : 63;
vswap(S);
gv(S, RC_INT);
- a = ireg(S->vtop[0].r);
- --S->vtop;
+ a = ireg(S->tccgen_vtop[0].r);
+ --S->tccgen_vtop;
d = get_reg(S, RC_INT);
- ++S->vtop;
+ ++S->tccgen_vtop;
vswap(S);
switch (op) {
case '-':
@@ -1028,12 +1028,12 @@ static void gen_opil(TCCState *S, int op, int ll)
cll = ll;
do_cop:
EI(S, 0x13 | cll, func3, ireg(d), a, fc);
- --S->vtop;
+ --S->tccgen_vtop;
if (op >= TOK_ULT && op <= TOK_GT) {
vset_VT_CMP(S, TOK_NE);
- S->vtop->cmp_r = ireg(d) | 0 << 8;
+ S->tccgen_vtop->cmp_r = ireg(d) | 0 << 8;
} else
- S->vtop[0].r = d;
+ S->tccgen_vtop[0].r = d;
return;
case TOK_LE:
if (fc >= (1 << 11) - 1)
@@ -1057,33 +1057,33 @@ static void gen_opil(TCCState *S, int op, int ll)
case TOK_GE: /* -> TOK_LT */
case TOK_GT: /* -> TOK_LE */
gen_opil(S, op - 1, !ll);
- S->vtop->cmp_op ^= 1;
+ S->tccgen_vtop->cmp_op ^= 1;
return;
case TOK_NE:
case TOK_EQ:
if (fc)
- gen_opil(S, '-', !ll), a = ireg(S->vtop++->r);
- --S->vtop;
+ gen_opil(S, '-', !ll), a = ireg(S->tccgen_vtop++->r);
+ --S->tccgen_vtop;
vset_VT_CMP(S, op);
- S->vtop->cmp_r = a | 0 << 8;
+ S->tccgen_vtop->cmp_r = a | 0 << 8;
return;
}
}
}
gv2(S, RC_INT, RC_INT);
- a = ireg(S->vtop[-1].r);
- b = ireg(S->vtop[0].r);
- S->vtop -= 2;
+ a = ireg(S->tccgen_vtop[-1].r);
+ b = ireg(S->tccgen_vtop[0].r);
+ S->tccgen_vtop -= 2;
d = get_reg(S, RC_INT);
- S->vtop++;
- S->vtop[0].r = d;
+ S->tccgen_vtop++;
+ S->tccgen_vtop[0].r = d;
d = ireg(d);
switch (op) {
default:
if (op >= TOK_ULT && op <= TOK_GT) {
vset_VT_CMP(S, op);
- S->vtop->cmp_r = a | b << 8;
+ S->tccgen_vtop->cmp_r = a | b << 8;
break;
}
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)
}
}
-ST_FUNC void gen_opi(TCCState *S, int op)
+ST_FUNC void gen_opi(TCCState* S, int op)
{
gen_opil(S, op, 0);
}
-ST_FUNC void gen_opl(TCCState *S, int op)
+ST_FUNC void gen_opl(TCCState* S, int op)
{
gen_opil(S, op, 1);
}
-ST_FUNC void gen_opf(TCCState *S, int op)
+ST_FUNC void gen_opf(TCCState* S, int op)
{
int rs1, rs2, rd, dbl, invert;
- if (S->vtop[0].type.t == VT_LDOUBLE) {
- CType type = S->vtop[0].type;
+ if (S->tccgen_vtop[0].type.t == VT_LDOUBLE) {
+ CType type = S->tccgen_vtop[0].type;
int func = 0;
int cond = -1;
switch (op) {
@@ -1166,10 +1166,10 @@ ST_FUNC void gen_opf(TCCState *S, int op)
vrott(S, 3);
gfunc_call(S, 2);
vpushi(S, 0);
- S->vtop->r = REG_IRET;
- S->vtop->r2 = cond < 0 ? TREG_R(1) : VT_CONST;
+ S->tccgen_vtop->r = REG_IRET;
+ S->tccgen_vtop->r2 = cond < 0 ? TREG_R(1) : VT_CONST;
if (cond < 0)
- S->vtop->type = type;
+ S->tccgen_vtop->type = type;
else {
vpushi(S, 0);
gen_opil(S, op, 1);
@@ -1178,11 +1178,11 @@ ST_FUNC void gen_opf(TCCState *S, int op)
}
gv2(S, RC_FLOAT, RC_FLOAT);
- assert(S->vtop->type.t == VT_DOUBLE || S->vtop->type.t == VT_FLOAT);
- dbl = S->vtop->type.t == VT_DOUBLE;
- rs1 = freg(S->vtop[-1].r);
- rs2 = freg(S->vtop->r);
- S->vtop--;
+ assert(S->tccgen_vtop->type.t == VT_DOUBLE || S->tccgen_vtop->type.t == VT_FLOAT);
+ dbl = S->tccgen_vtop->type.t == VT_DOUBLE;
+ rs1 = freg(S->tccgen_vtop[-1].r);
+ rs2 = freg(S->tccgen_vtop->r);
+ S->tccgen_vtop--;
invert = 0;
switch(op) {
default:
@@ -1191,7 +1191,7 @@ ST_FUNC void gen_opf(TCCState *S, int op)
op = 0; // fadd
arithop:
rd = get_reg(S, RC_FLOAT);
- S->vtop->r = rd;
+ S->tccgen_vtop->r = rd;
rd = freg(rd);
ER(S, 0x53, 7, rd, rs1, rs2, dbl | (op << 2)); // fop.[sd] RD, RS1, RS2 (dyn rm)
break;
@@ -1208,7 +1208,7 @@ ST_FUNC void gen_opf(TCCState *S, int op)
op = 2; // EQ
cmpop:
rd = get_reg(S, RC_INT);
- S->vtop->r = rd;
+ S->tccgen_vtop->r = rd;
rd = ireg(rd);
ER(S, 0x53, op, rd, rs1, rs2, dbl | 0x50); // fcmp.[sd] RD, RS1, RS2 (op == eq/lt/le)
if (invert)
@@ -1241,11 +1241,11 @@ ST_FUNC void gen_cvt_sxtw(TCCState *S)
Let's try to not do anything here. */
}
-ST_FUNC void gen_cvt_itof(TCCState *S, int t)
+ST_FUNC void gen_cvt_itof(TCCState* S, int t)
{
int rr = ireg(gv(S, RC_INT)), dr;
- int u = S->vtop->type.t & VT_UNSIGNED;
- int l = (S->vtop->type.t & VT_BTYPE) == VT_LLONG;
+ int u = S->tccgen_vtop->type.t & VT_UNSIGNED;
+ int l = (S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG;
if (t == VT_LDOUBLE) {
int func = l ?
(u ? TOK___floatunditf : TOK___floatditf) :
@@ -1254,22 +1254,22 @@ ST_FUNC void gen_cvt_itof(TCCState *S, int t)
vrott(S, 2);
gfunc_call(S, 1);
vpushi(S, 0);
- S->vtop->type.t = t;
- S->vtop->r = REG_IRET;
- S->vtop->r2 = TREG_R(1);
+ S->tccgen_vtop->type.t = t;
+ S->tccgen_vtop->r = REG_IRET;
+ S->tccgen_vtop->r2 = TREG_R(1);
} else {
- S->vtop--;
+ S->tccgen_vtop--;
dr = get_reg(S, RC_FLOAT);
- S->vtop++;
- S->vtop->r = dr;
+ S->tccgen_vtop++;
+ S->tccgen_vtop->r = dr;
dr = freg(dr);
EIu(S, 0x53, 7, dr, rr, ((0x68 | (t == VT_DOUBLE ? 1 : 0)) << 5) | (u ? 1 : 0) | (l ? 2 : 0)); // fcvt.[sd].[wl][u]
}
}
-ST_FUNC void gen_cvt_ftoi(TCCState *S, int t)
+ST_FUNC void gen_cvt_ftoi(TCCState* S, int t)
{
- int ft = S->vtop->type.t & VT_BTYPE;
+ int ft = S->tccgen_vtop->type.t & VT_BTYPE;
int l = (t & VT_BTYPE) == VT_LLONG;
int u = t & VT_UNSIGNED;
if (ft == VT_LDOUBLE) {
@@ -1280,22 +1280,22 @@ ST_FUNC void gen_cvt_ftoi(TCCState *S, int t)
vrott(S, 2);
gfunc_call(S, 1);
vpushi(S, 0);
- S->vtop->type.t = t;
- S->vtop->r = REG_IRET;
+ S->tccgen_vtop->type.t = t;
+ S->tccgen_vtop->r = REG_IRET;
} else {
int rr = freg(gv(S, RC_FLOAT)), dr;
- S->vtop--;
+ S->tccgen_vtop--;
dr = get_reg(S, RC_INT);
- S->vtop++;
- S->vtop->r = dr;
+ S->tccgen_vtop++;
+ S->tccgen_vtop->r = dr;
dr = ireg(dr);
EIu(S, 0x53, 1, dr, rr, ((0x60 | (ft == VT_DOUBLE ? 1 : 0)) << 5) | (u ? 1 : 0) | (l ? 2 : 0)); // fcvt.[wl][u].[sd] rtz
}
}
-ST_FUNC void gen_cvt_ftof(TCCState *S, int dt)
+ST_FUNC void gen_cvt_ftof(TCCState* S, int dt)
{
- int st = S->vtop->type.t & VT_BTYPE, rs, rd;
+ int st = S->tccgen_vtop->type.t & VT_BTYPE, rs, rd;
dt &= VT_BTYPE;
if (st == dt)
return;
@@ -1312,21 +1312,21 @@ ST_FUNC void gen_cvt_ftof(TCCState *S, int dt)
gv(S, RC_F(0));
else {
gv(S, RC_R(0));
- assert(S->vtop->r2 < 7);
- if (S->vtop->r2 != 1 + S->vtop->r) {
- EI(S, 0x13, 0, ireg(S->vtop->r) + 1, ireg(S->vtop->r2), 0); // mv Ra+1, RR2
- S->vtop->r2 = 1 + S->vtop->r;
+ assert(S->tccgen_vtop->r2 < 7);
+ if (S->tccgen_vtop->r2 != 1 + S->tccgen_vtop->r) {
+ EI(S, 0x13, 0, ireg(S->tccgen_vtop->r) + 1, ireg(S->tccgen_vtop->r2), 0); // mv Ra+1, RR2
+ S->tccgen_vtop->r2 = 1 + S->tccgen_vtop->r;
}
}
vpush_helper_func(S, func);
gcall_or_jmp(S, 1);
- S->vtop -= 2;
+ S->tccgen_vtop -= 2;
vpushi(S, 0);
- S->vtop->type.t = dt;
+ S->tccgen_vtop->type.t = dt;
if (dt == VT_LDOUBLE)
- S->vtop->r = REG_IRET, S->vtop->r2 = REG_IRET+1;
+ S->tccgen_vtop->r = REG_IRET, S->tccgen_vtop->r2 = REG_IRET+1;
else
- S->vtop->r = REG_FRET;
+ S->tccgen_vtop->r = REG_FRET;
} else {
assert (dt == VT_FLOAT || dt == VT_DOUBLE);
assert (st == VT_FLOAT || st == VT_DOUBLE);
@@ -1336,59 +1336,59 @@ ST_FUNC void gen_cvt_ftof(TCCState *S, int dt)
EI(S, 0x53, 0, freg(rd), freg(rs), 0x21 << 5); // fcvt.d.s RD, RS (no rm)
else
EI(S, 0x53, 7, freg(rd), freg(rs), (0x20 << 5) | 1); // fcvt.s.d RD, RS (dyn rm)
- S->vtop->r = rd;
+ S->tccgen_vtop->r = rd;
}
}
/* increment tcov counter */
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv)
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv)
{
int r1, r2;
Sym label = {0};
label.type.t = VT_VOID | VT_STATIC;
vpushv(S, sv);
- S->vtop->r = r1 = get_reg(S, RC_INT);
+ S->tccgen_vtop->r = r1 = get_reg(S, RC_INT);
r2 = get_reg(S, RC_INT);
r1 = ireg(r1);
r2 = ireg(r2);
- greloca(S, cur_text_section, sv->sym, S->ind, R_RISCV_PCREL_HI20, 0);
- put_extern_sym(S, &label, cur_text_section, S->ind, 0);
+ greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_RISCV_PCREL_HI20, 0);
+ put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0);
o(S, 0x17 | (r1 << 7)); // auipc RR, 0 %pcrel_hi(sym)
- greloca(S, cur_text_section, &label, S->ind, R_RISCV_PCREL_LO12_I, 0);
+ greloca(S, cur_text_section, &label, S->tccgen_ind, R_RISCV_PCREL_LO12_I, 0);
EI(S, 0x03, 3, r2, r1, 0); // ld r2, x[r1]
EI(S, 0x13, 0, r2, r2, 1); // addi r2, r2, #1
- greloca(S, cur_text_section, sv->sym, S->ind, R_RISCV_PCREL_HI20, 0);
+ greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_RISCV_PCREL_HI20, 0);
label.c = 0; /* force new local ELF symbol */
- put_extern_sym(S, &label, cur_text_section, S->ind, 0);
+ put_extern_sym(S, &label, cur_text_section, S->tccgen_ind, 0);
o(S, 0x17 | (r1 << 7)); // auipc RR, 0 %pcrel_hi(sym)
- greloca(S, cur_text_section, &label, S->ind, R_RISCV_PCREL_LO12_S, 0);
+ greloca(S, cur_text_section, &label, S->tccgen_ind, R_RISCV_PCREL_LO12_S, 0);
ES(S, 0x23, 3, r1, r2, 0); // sd r2, [r1]
vpop(S);
}
-ST_FUNC void ggoto(TCCState *S)
+ST_FUNC void ggoto(TCCState* S)
{
gcall_or_jmp(S, 0);
- S->vtop--;
+ S->tccgen_vtop--;
}
-ST_FUNC void gen_vla_sp_save(TCCState *S, int addr)
+ST_FUNC void gen_vla_sp_save(TCCState* S, int addr)
{
ES(S, 0x23, 3, 8, 2, addr); // sd sp, fc(s0)
}
-ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr)
+ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr)
{
EI(S, 0x03, 3, 2, 8, addr); // ld sp, fc(s0)
}
-ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align)
+ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align)
{
int rr;
#if defined(CONFIG_TCC_BCHECK)
if (S->do_bounds_check)
- vpushv(S, S->vtop);
+ vpushv(S, S->tccgen_vtop);
#endif
rr = ireg(gv(S, RC_INT));
#if defined(CONFIG_TCC_BCHECK)
@@ -1403,7 +1403,7 @@ ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align)
#if defined(CONFIG_TCC_BCHECK)
if (S->do_bounds_check) {
vpushi(S, 0);
- S->vtop->r = TREG_R(0);
+ S->tccgen_vtop->r = TREG_R(0);
o(S, 0x00010513); /* mv a0,sp */
vswap(S);
vpush_helper_func(S, TOK___bound_new_region);
diff --git a/tcc.h b/tcc.h
index 3c39c5e..b020b90 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1074,21 +1074,21 @@ struct TCCState {
/* ------------ tccpp.c ------------ */
struct BufferedFile *tccpp_file;
- int tccpp_ch, tok;
- CValue tokc;
+ int tccpp_ch, tccpp_tok;
+ CValue tccpp_tokc;
const int *tccpp_macro_ptr;
int tccpp_parse_flags;
- int tok_flags;
- CString tokcstr; /* current parsed string, if any */
+ int tccpp_tok_flags;
+ CString tccpp_tokcstr; /* current parsed string, if any */
CString tccpp_cstr_buf;
CString tccpp_macro_equal_buf;
- TokenString tokstr_buf;
+ TokenString tccpp_tokstr_buf;
TokenString *tccpp_macro_stack;
/* display benchmark infos */
int tccpp_total_lines;
int tccpp_total_bytes;
- int tok_ident;
+ int tccpp_tok_ident;
TokenSym **tccpp_table_ident;
int *tccpp_macro_ptr_allocated;
@@ -1096,7 +1096,7 @@ struct TCCState {
int tccpp_unget_saved_buffer[TOK_MAX_SIZE + 1];
int tccpp_unget_buffer_enabled;
TokenSym *tccpp_hash_ident[TOK_HASH_SIZE];
- char token_buf[STRING_MAX_SIZE + 1];
+ char tccpp_token_buf[STRING_MAX_SIZE + 1];
/* true if isid(c) || isnum(c) */
unsigned char tccpp_isidnum_table[256-CH_EOF];
@@ -1105,8 +1105,8 @@ struct TCCState {
int tccpp_pp_expr;
int tccpp_pp_counter;
- TinyAlloc *toksym_alloc;
- TinyAlloc *tokstr_alloc;
+ TinyAlloc *tccpp_toksym_alloc;
+ TinyAlloc *tccpp_tokstr_alloc;
/*----------- tccasm.c --------*/
Section *tccasm_last_text_section; /* to handle .previous asm directive */
@@ -1114,18 +1114,18 @@ struct TCCState {
/* ------------ tccgen.c ------------ */
Sym *tccgen_global_stack;
- Sym *local_stack;
- Sym *local_label_stack;
+ Sym *tccgen_local_stack;
+ Sym *tccgen_local_label_stack;
Sym *tccgen_global_label_stack;
Sym *tccgen_define_stack;
- CType tccgen_int_type, tccgen_func_old_type, tccgen_char_type, char_pointer_type;
- SValue *vtop;
+ CType tccgen_int_type, tccgen_func_old_type, tccgen_char_type, tccgen_char_pointer_type;
+ SValue *tccgen_vtop;
SValue tccgen__vstack[1 + VSTACK_SIZE];
- int tccgen_rsym, tccgen_anon_sym, ind, loc;
+ int tccgen_rsym, tccgen_anon_sym, tccgen_ind, tccgen_loc;
char tccgen_debug_modes;
int tccgen_const_wanted; /* true if constant wanted */
- int nocode_wanted; /* true if no code generation wanted for an expression */
+ int tccgen_nocode_wanted; /* true if no code generation wanted for an expression */
int tccgen_global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */
CType tccgen_func_vt; /* current function return type (used by return instruction) */
int tccgen_func_var; /* true if current function is variadic */
@@ -1136,7 +1136,7 @@ struct TCCState {
void **tccgen_sym_pools;
int tccgen_nb_sym_pools;
Sym *tccgen_all_cleanups, *tccgen_pending_gotos;
- int local_scope;
+ int tccgen_local_scope;
int tccgen_in_sizeof;
int tccgen_in_generic;
int tccgen_section_sym;
@@ -1155,7 +1155,7 @@ struct TCCState {
int tccgen_debug_next_type;
debug_hash_t *tccgen_debug_hash;
int tccgen_n_debug_hash;
- debug_info_t *debug_info, *debug_info_root;
+ debug_info_t *tccgen_debug_info, *tccgen_debug_info_root;
unsigned char tccgen_prec[256];
@@ -1374,22 +1374,22 @@ PUB_FUNC void tcc_free_base(void *ptr);
PUB_FUNC void *tcc_malloc_base(unsigned long size);
PUB_FUNC void *tcc_mallocz_base(unsigned long size);
#ifndef MEM_DEBUG
-PUB_FUNC void tcc_free(TCCState *S, void *ptr);
-PUB_FUNC void *tcc_malloc(TCCState *S, unsigned long size);
-PUB_FUNC void *tcc_mallocz(TCCState *S, unsigned long size);
-PUB_FUNC void *tcc_realloc(TCCState *S, void *ptr, unsigned long size);
-PUB_FUNC char *tcc_strdup(TCCState *S, const char *str);
+PUB_FUNC void tcc_free(TCCState* S, void *ptr);
+PUB_FUNC void *tcc_malloc(TCCState* S, unsigned long size);
+PUB_FUNC void *tcc_mallocz(TCCState* S, unsigned long size);
+PUB_FUNC void *tcc_realloc(TCCState* S, void *ptr, unsigned long size);
+PUB_FUNC char *tcc_strdup(TCCState* S, const char *str);
#else
#define tcc_free(s, ptr) tcc_free_debug(s, ptr)
#define tcc_malloc(s, size) tcc_malloc_debug(s, size, __FILE__, __LINE__)
#define tcc_mallocz(s, size) tcc_mallocz_debug(s, size, __FILE__, __LINE__)
#define tcc_realloc(s, ptr, size) tcc_realloc_debug(s, ptr, size, __FILE__, __LINE__)
#define tcc_strdup(s, str) tcc_strdup_debug(s, str, __FILE__, __LINE__)
-PUB_FUNC void tcc_free_debug(TCCState *S, void *ptr);
-PUB_FUNC void *tcc_malloc_debug(TCCState *S, unsigned long size, const char *file, int line);
-PUB_FUNC void *tcc_mallocz_debug(TCCState *S, unsigned long size, const char *file, int line);
-PUB_FUNC void *tcc_realloc_debug(TCCState *S, void *ptr, unsigned long size, const char *file, int line);
-PUB_FUNC char *tcc_strdup_debug(TCCState *S, const char *str, const char *file, int line);
+PUB_FUNC void tcc_free_debug(TCCState* S, void *ptr);
+PUB_FUNC void *tcc_malloc_debug(TCCState* S, unsigned long size, const char *file, int line);
+PUB_FUNC void *tcc_mallocz_debug(TCCState* S, unsigned long size, const char *file, int line);
+PUB_FUNC void *tcc_realloc_debug(TCCState* S, void *ptr, unsigned long size, const char *file, int line);
+PUB_FUNC char *tcc_strdup_debug(TCCState* S, const char *str, const char *file, int line);
#endif
#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,
#define realloc(p, s) use_tcc_realloc(S, p, s)
#undef strdup
#define strdup(s) use_tcc_strdup(S, s)
-PUB_FUNC void _tcc_error_noabort(TCCState *S, const char *fmt, ...) PRINTF_LIKE(2,3);
-PUB_FUNC NORETURN void _tcc_error(TCCState *S, const char *fmt, ...) PRINTF_LIKE(2,3);
-PUB_FUNC void _tcc_warning(TCCState *S, const char *fmt, ...) PRINTF_LIKE(2,3);
+PUB_FUNC void _tcc_error_noabort(TCCState* S, const char *fmt, ...) PRINTF_LIKE(2,3);
+PUB_FUNC NORETURN void _tcc_error(TCCState* S, const char *fmt, ...) PRINTF_LIKE(2,3);
+PUB_FUNC void _tcc_warning(TCCState* S, const char *fmt, ...) PRINTF_LIKE(2,3);
#define tcc_internal_error(S, msg) tcc_error(S, "internal compiler error\n"\
"%s:%d: in %s(): " msg, __FILE__,__LINE__,__FUNCTION__)
/* other utilities */
-ST_FUNC void dynarray_add(TCCState *S, void *ptab, int *nb_ptr, void *data);
-ST_FUNC void dynarray_reset(TCCState *S, void *pp, int *n);
-ST_INLN void cstr_ccat(TCCState *S, CString *cstr, int ch);
-ST_FUNC void cstr_cat(TCCState *S, CString *cstr, const char *str, int len);
-ST_FUNC void cstr_wccat(TCCState *S, CString *cstr, int ch);
-ST_FUNC void cstr_new(TCCState *S, CString *cstr);
-ST_FUNC void cstr_free(TCCState *S, CString *cstr);
-ST_FUNC int cstr_printf(TCCState *S, CString *cs, const char *fmt, ...) PRINTF_LIKE(3,4);
-ST_FUNC int cstr_vprintf(TCCState *S, CString *cstr, const char *fmt, va_list ap);
+ST_FUNC void dynarray_add(TCCState* S, void *ptab, int *nb_ptr, void *data);
+ST_FUNC void dynarray_reset(TCCState* S, void *pp, int *n);
+ST_INLN void cstr_ccat(TCCState* S, CString *cstr, int ch);
+ST_FUNC void cstr_cat(TCCState* S, CString *cstr, const char *str, int len);
+ST_FUNC void cstr_wccat(TCCState* S, CString *cstr, int ch);
+ST_FUNC void cstr_new(TCCState* S, CString *cstr);
+ST_FUNC void cstr_free(TCCState* S, CString *cstr);
+ST_FUNC int cstr_printf(TCCState* S, CString *cs, const char *fmt, ...) PRINTF_LIKE(3,4);
+ST_FUNC int cstr_vprintf(TCCState* S, CString *cstr, const char *fmt, va_list ap);
ST_FUNC void cstr_reset(CString *cstr);
ST_FUNC void tcc_open_bf(TCCState *S, const char *filename, int initlen);
@@ -1499,36 +1499,36 @@ enum line_macro_output_format {
LINE_MACRO_OUTPUT_FORMAT_P10 = 11
};
-ST_FUNC TokenSym *tok_alloc(TCCState *S, const char *str, int len);
-ST_FUNC int tok_alloc_const(TCCState *S, const char *str);
-ST_FUNC const char *get_tok_str(TCCState *S, int v, CValue *cv);
-ST_FUNC void begin_macro(TCCState *S, TokenString *str, int alloc);
-ST_FUNC void end_macro(TCCState *S);
-ST_FUNC int set_idnum(TCCState *S, int c, int val);
+ST_FUNC TokenSym *tok_alloc(TCCState* S, const char *str, int len);
+ST_FUNC int tok_alloc_const(TCCState* S, const char *str);
+ST_FUNC const char *get_tok_str(TCCState* S, int v, CValue *cv);
+ST_FUNC void begin_macro(TCCState* S, TokenString *str, int alloc);
+ST_FUNC void end_macro(TCCState* S);
+ST_FUNC int set_idnum(TCCState* S, int c, int val);
ST_INLN void tok_str_new(TokenString *s);
-ST_FUNC TokenString *tok_str_alloc(TCCState *S);
-ST_FUNC void tok_str_free(TCCState *S, TokenString *s);
-ST_FUNC void tok_str_free_str(TCCState *S, int *str);
-ST_FUNC void tok_str_add(TCCState *S, TokenString *s, int t);
-ST_FUNC void tok_str_add_tok(TCCState *S, TokenString *s);
-ST_INLN void define_push(TCCState *S, int v, int macro_type, int *str, Sym *first_arg);
-ST_FUNC void define_undef(TCCState *S, Sym *s);
-ST_INLN Sym *define_find(TCCState *S, int v);
-ST_FUNC void free_defines(TCCState *S, Sym *b);
-ST_FUNC Sym *label_find(TCCState *S, int v);
-ST_FUNC Sym *label_push(TCCState *S, Sym **ptop, int v, int flags);
-ST_FUNC void label_pop(TCCState *S, Sym **ptop, Sym *slast, int keep);
-ST_FUNC void parse_define(TCCState *S);
-ST_FUNC void preprocess(TCCState *S, int is_bof);
-ST_FUNC void next(TCCState *S);
-ST_INLN void unget_tok(TCCState *S, int last_tok);
+ST_FUNC TokenString *tok_str_alloc(TCCState* S);
+ST_FUNC void tok_str_free(TCCState* S, TokenString *s);
+ST_FUNC void tok_str_free_str(TCCState* S, int *str);
+ST_FUNC void tok_str_add(TCCState* S, TokenString *s, int t);
+ST_FUNC void tok_str_add_tok(TCCState* S, TokenString *s);
+ST_INLN void define_push(TCCState* S, int v, int macro_type, int *str, Sym *first_arg);
+ST_FUNC void define_undef(TCCState* S, Sym *s);
+ST_INLN Sym *define_find(TCCState* S, int v);
+ST_FUNC void free_defines(TCCState* S, Sym *b);
+ST_FUNC Sym *label_find(TCCState* S, int v);
+ST_FUNC Sym *label_push(TCCState* S, Sym **ptop, int v, int flags);
+ST_FUNC void label_pop(TCCState* S, Sym **ptop, Sym *slast, int keep);
+ST_FUNC void parse_define(TCCState* S);
+ST_FUNC void preprocess(TCCState* S, int is_bof);
+ST_FUNC void next(TCCState* S);
+ST_INLN void unget_tok(TCCState* S, int last_tok);
ST_FUNC void preprocess_start(TCCState *S, int filetype);
ST_FUNC void preprocess_end(TCCState *S);
ST_FUNC void tccpp_new(TCCState *S);
ST_FUNC void tccpp_delete(TCCState *S);
ST_FUNC int tcc_preprocess(TCCState *S);
-ST_FUNC void skip(TCCState *S, int c);
-ST_FUNC NORETURN void expect(TCCState *S, const char *msg);
+ST_FUNC void skip(TCCState* S, int c);
+ST_FUNC NORETURN void expect(TCCState* S, const char *msg);
/* space excluding newline */
static inline int is_space(int ch) {
@@ -1559,76 +1559,77 @@ ST_FUNC void tcc_debug_putfile(TCCState *S, const char *filename);
ST_FUNC void tccgen_init(TCCState *S);
ST_FUNC int tccgen_compile(TCCState *S);
ST_FUNC void tccgen_finish(TCCState *S);
-ST_FUNC void check_vstack(TCCState *S);
+ST_FUNC void check_vstack(TCCState* S);
ST_INLN int is_float(int t);
ST_FUNC int ieee_finite(double d);
ST_FUNC int exact_log2p1(int i);
-ST_FUNC void test_lvalue(TCCState *S);
+ST_FUNC void test_lvalue(TCCState* S);
-ST_FUNC ElfSym *elfsym(TCCState *S, Sym *);
-ST_FUNC void update_storage(TCCState *S, Sym *sym);
-ST_FUNC void put_extern_sym2(TCCState *S, Sym *sym, int sh_num, addr_t value, unsigned long size, int can_add_underscore);
-ST_FUNC void put_extern_sym(TCCState *S, Sym *sym, Section *section, addr_t value, unsigned long size);
+ST_FUNC ElfSym *elfsym(TCCState* S, Sym *);
+ST_FUNC void update_storage(TCCState* S, Sym *sym);
+ST_FUNC void put_extern_sym2(TCCState* S, Sym *sym, int sh_num, addr_t value, unsigned long size, int can_add_underscore);
+ST_FUNC void put_extern_sym(TCCState* S, Sym *sym, Section *section, addr_t value, unsigned long size);
#if PTR_SIZE == 4
-ST_FUNC void greloc(TCCState *S, Section *s, Sym *sym, unsigned long offset, int type);
+ST_FUNC void greloc(TCCState* S, Section *s, Sym *sym, unsigned long offset, int type);
#endif
-ST_FUNC void greloca(TCCState *S, Section *s, Sym *sym, unsigned long offset, int type, addr_t addend);
+ST_FUNC void greloca(TCCState* S, Section *s, Sym *sym, unsigned long offset, int type, addr_t addend);
-ST_INLN void sym_free(TCCState *S, Sym *sym);
-ST_FUNC Sym *sym_push(TCCState *S, int v, CType *type, int r, int c);
-ST_FUNC void sym_pop(TCCState *S, Sym **ptop, Sym *b, int keep);
-ST_FUNC Sym *sym_push2(TCCState *S, Sym **ps, int v, int t, int c);
+ST_INLN void sym_free(TCCState* S, Sym *sym);
+ST_FUNC Sym *sym_push(TCCState* S, int v, CType *type, int r, int c);
+ST_FUNC void sym_pop(TCCState* S, Sym **ptop, Sym *b, int keep);
+ST_FUNC Sym *sym_push2(TCCState* S, Sym **ps, int v, int t, int c);
ST_FUNC Sym *sym_find2(Sym *s, int v);
-ST_INLN Sym *sym_find(TCCState *S, int v);
-ST_INLN Sym *struct_find(TCCState *S, int v);
-
-ST_FUNC Sym *global_identifier_push(TCCState *S, int v, int t, int c);
-ST_FUNC Sym *external_global_sym(TCCState *S, int v, CType *type);
-ST_FUNC Sym *external_helper_sym(TCCState *S, int v);
-ST_FUNC void vpush_helper_func(TCCState *S, int v);
-ST_FUNC void vset(TCCState *S, CType *type, int r, int v);
-ST_FUNC void vset_VT_CMP(TCCState *S, int op);
-ST_FUNC void vpushi(TCCState *S, int v);
-ST_FUNC void vpushv(TCCState *S, SValue *v);
-ST_FUNC void vpushsym(TCCState *S, CType *type, Sym *sym);
-ST_FUNC void vswap(TCCState *S);
-ST_FUNC void vrote(TCCState *S, SValue *e, int n);
-ST_FUNC void vrott(TCCState *S, int n);
-ST_FUNC void vrotb(TCCState *S, int n);
-ST_FUNC void vpop(TCCState *S);
+ST_INLN Sym *sym_find(TCCState* S, int v);
+ST_INLN Sym *struct_find(TCCState* S, int v);
+
+ST_FUNC Sym *global_identifier_push(TCCState* S, int v, int t, int c);
+ST_FUNC Sym *external_global_sym(TCCState* S, int v, CType *type);
+ST_FUNC Sym *external_helper_sym(TCCState* S, int v);
+ST_FUNC void vpush_helper_func(TCCState* S, int v);
+ST_FUNC void vset(TCCState* S, CType *type, int r, int v);
+ST_FUNC void vset_VT_CMP(TCCState* S, int op);
+ST_FUNC void vpushi(TCCState* S, int v);
+ST_FUNC void vpushv(TCCState* S, SValue *v);
+ST_FUNC void vpushsym(TCCState* S, CType *type, Sym *sym);
+ST_FUNC void vswap(TCCState* S);
+ST_FUNC void vrote(TCCState* S, SValue *e, int n);
+ST_FUNC void vrott(TCCState* S, int n);
+ST_FUNC void vrotb(TCCState* S, int n);
+ST_FUNC void vpop(TCCState* S);
#if PTR_SIZE == 4
-ST_FUNC void lexpand(TCCState *S);
+ST_FUNC void lexpand(TCCState* S);
#endif
#ifdef TCC_TARGET_ARM
-ST_FUNC int get_reg_ex(TCCState *S, int rc, int rc2);
-#endif
-ST_FUNC void save_reg(TCCState *S, int r);
-ST_FUNC void save_reg_upstack(TCCState *S, int r, int n);
-ST_FUNC int get_reg(TCCState *S, int rc);
-ST_FUNC void save_regs(TCCState *S, int n);
-ST_FUNC void gaddrof(TCCState *S);
-ST_FUNC int gv(TCCState *S, int rc);
-ST_FUNC void gv2(TCCState *S, int rc1, int rc2);
-ST_FUNC void gen_op(TCCState *S, int op);
+ST_FUNC int get_reg_ex(TCCState* S, int rc, int rc2);
+#endif
+ST_FUNC void save_reg(TCCState* S, int r);
+ST_FUNC void save_reg_upstack(TCCState* S, int r, int n);
+ST_FUNC int get_reg(TCCState* S, int rc);
+ST_FUNC void save_regs(TCCState* S, int n);
+ST_FUNC void gaddrof(TCCState* S);
+ST_FUNC int gv(TCCState* S, int rc);
+ST_FUNC void gv2(TCCState* S, int rc1, int rc2);
+ST_FUNC void gen_op(TCCState* S, int op);
ST_FUNC int type_size(CType *type, int *a);
-ST_FUNC void mk_pointer(TCCState *S, CType *type);
-ST_FUNC void vstore(TCCState *S);
-ST_FUNC void inc(TCCState *S, int post, int c);
-ST_FUNC void parse_mult_str (TCCState *S, CString *astr, const char *msg);
-ST_FUNC void parse_asm_str(TCCState *S, CString *astr);
-ST_FUNC void indir(TCCState *S);
-ST_FUNC void unary(TCCState *S);
-ST_FUNC void gexpr(TCCState *S);
-ST_FUNC int expr_const(TCCState *S);
+ST_FUNC void mk_pointer(TCCState* S, CType *type);
+ST_FUNC void vstore(TCCState* S);
+ST_FUNC void inc(TCCState* S, int post, int c);
+ST_FUNC void parse_mult_str (TCCState* S, CString *astr, const char *msg);
+ST_FUNC void parse_asm_str(TCCState* S, CString *astr);
+ST_FUNC void indir(TCCState* S);
+ST_FUNC void unary(TCCState* S);
+ST_FUNC void gexpr(TCCState* S);
+ST_FUNC int expr_const(TCCState* S);
#if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_C67
-ST_FUNC Sym *get_sym_ref(TCCState *S, CType *type, Section *sec, unsigned long offset, unsigned long size);
+ST_FUNC Sym *get_sym_ref(TCCState* S, CType *type, Section *sec, unsigned long offset, unsigned long size);
#endif
#if defined TCC_TARGET_X86_64 && !defined TCC_TARGET_PE
ST_FUNC int classify_x86_64_va_arg(CType *ty);
#endif
#ifdef CONFIG_TCC_BCHECK
-ST_FUNC void gbound_args(TCCState *S, int nb_args);
+ST_FUNC void gbound_args(TCCState* S, int nb_args);
+ST_DATA int func_bound_add_epilog;
#endif
/* ------------ tccelf.c ------------ */
@@ -1656,14 +1657,14 @@ ST_FUNC void tccelf_end_file(TCCState *S);
ST_FUNC void tccelf_bounds_new(TCCState *S);
#endif
ST_FUNC Section *new_section(TCCState *S, const char *name, int sh_type, int sh_flags);
-ST_FUNC void section_realloc(TCCState *S, Section *sec, unsigned long new_size);
-ST_FUNC size_t section_add(TCCState *S, Section *sec, addr_t size, int align);
-ST_FUNC void *section_ptr_add(TCCState *S, Section *sec, addr_t size);
+ST_FUNC void section_realloc(TCCState* S, Section *sec, unsigned long new_size);
+ST_FUNC size_t section_add(TCCState* S, Section *sec, addr_t size, int align);
+ST_FUNC void *section_ptr_add(TCCState* S, Section *sec, addr_t size);
ST_FUNC Section *find_section(TCCState *S, const char *name);
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);
-ST_FUNC int put_elf_str(TCCState *S, Section *s, const char *sym);
-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);
+ST_FUNC int put_elf_str(TCCState* S, Section *s, const char *sym);
+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);
ST_FUNC int set_elf_sym(Section *S, addr_t value, unsigned long size, int info, int other, int shndx, const char *name);
ST_FUNC int find_elf_sym(Section *S, const char *name);
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);
ST_FUNC void relocate_sections(TCCState *S);
ST_FUNC ssize_t full_read(int fd, void *buf, size_t count);
-ST_FUNC void *load_data(TCCState *S, int fd, unsigned long file_offset, unsigned long size);
+ST_FUNC void *load_data(TCCState* S, int fd, unsigned long file_offset, unsigned long size);
ST_FUNC int tcc_object_type(int fd, ElfW(Ehdr) *h);
ST_FUNC int tcc_load_object_file(TCCState *S, int fd, unsigned long file_offset);
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,
ST_DATA const char * const target_machine_defs;
ST_DATA const int reg_classes[NB_REGS];
-ST_FUNC void gsym_addr(TCCState *S, int t, int a);
-ST_FUNC void gsym(TCCState *S, int t);
+ST_FUNC void gsym_addr(TCCState* S, int t, int a);
+ST_FUNC void gsym(TCCState* S, int t);
ST_FUNC void load(TCCState *S, int r, SValue *sv);
ST_FUNC void store(TCCState *S, int r, SValue *v);
ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *align, int *regsize);
ST_FUNC void gfunc_call(TCCState *S, int nb_args);
ST_FUNC void gfunc_prolog(TCCState *S, Sym *func_sym);
ST_FUNC void gfunc_epilog(TCCState *S);
-ST_FUNC void gen_fill_nops(TCCState *S, int);
-ST_FUNC int gjmp(TCCState *S, int t);
-ST_FUNC void gjmp_addr(TCCState *S, int a);
-ST_FUNC int gjmp_cond(TCCState *S, int op, int t);
+ST_FUNC void gen_fill_nops(TCCState* S, int);
+ST_FUNC int gjmp(TCCState* S, int t);
+ST_FUNC void gjmp_addr(TCCState* S, int a);
+ST_FUNC int gjmp_cond(TCCState* S, int op, int t);
ST_FUNC int gjmp_append(TCCState *S, int n, int t);
-ST_FUNC void gen_opi(TCCState *S, int op);
-ST_FUNC void gen_opf(TCCState *S, int op);
+ST_FUNC void gen_opi(TCCState* S, int op);
+ST_FUNC void gen_opf(TCCState* S, int op);
ST_FUNC void gen_cvt_ftoi(TCCState *S, int t);
ST_FUNC void gen_cvt_itof(TCCState *S, int t);
ST_FUNC void gen_cvt_ftof(TCCState *S, int t);
ST_FUNC void ggoto(TCCState *S);
#ifndef TCC_TARGET_C67
-ST_FUNC void o(TCCState *S, unsigned int c);
+ST_FUNC void o(TCCState* S, unsigned int c);
#endif
-ST_FUNC void gen_vla_sp_save(TCCState *S, int addr);
-ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr);
-ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align);
+ST_FUNC void gen_vla_sp_save(TCCState* S, int addr);
+ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr);
+ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align);
static inline uint16_t read16le(unsigned char *p) {
return p[0] | (uint16_t)p[1] << 8;
@@ -1785,26 +1786,26 @@ static inline void add64le(unsigned char *p, int64_t x) {
/* ------------ i386-gen.c ------------ */
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 || defined TCC_TARGET_ARM
-ST_FUNC void g(TCCState *S, int c);
-ST_FUNC void gen_le16(TCCState *S, int c);
-ST_FUNC void gen_le32(TCCState *S, int c);
+ST_FUNC void g(TCCState* S, int c);
+ST_FUNC void gen_le16(TCCState* S, int c);
+ST_FUNC void gen_le32(TCCState* S, int c);
#endif
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
-ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c);
-ST_FUNC void gen_addrpc32(TCCState *S, int r, Sym *sym, int c);
-ST_FUNC void gen_cvt_csti(TCCState *S, int t);
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv);
+ST_FUNC void gen_addr32(TCCState* S, int r, Sym *sym, int c);
+ST_FUNC void gen_addrpc32(TCCState* S, int r, Sym *sym, int c);
+ST_FUNC void gen_cvt_csti(TCCState* S, int t);
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv);
#endif
/* ------------ x86_64-gen.c ------------ */
#ifdef TCC_TARGET_X86_64
-ST_FUNC void gen_addr64(TCCState *S, int r, Sym *sym, int64_t c);
-ST_FUNC void gen_opl(TCCState *S, int op);
+ST_FUNC void gen_addr64(TCCState* S, int r, Sym *sym, int64_t c);
+ST_FUNC void gen_opl(TCCState* S, int op);
#ifdef TCC_TARGET_PE
-ST_FUNC void gen_vla_result(TCCState *S, int addr);
+ST_FUNC void gen_vla_result(TCCState* S, int addr);
#endif
ST_FUNC void gen_cvt_sxtw(TCCState *S);
-ST_FUNC void gen_cvt_csti(TCCState *S, int t);
+ST_FUNC void gen_cvt_csti(TCCState* S, int t);
#endif
/* ------------ arm-gen.c ------------ */
@@ -1813,29 +1814,29 @@ ST_FUNC void gen_cvt_csti(TCCState *S, int t);
PUB_FUNC const char *default_elfinterp(TCCState *S);
#endif
ST_FUNC void arm_init(TCCState *S);
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv);
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv);
#endif
/* ------------ arm64-gen.c ------------ */
#ifdef TCC_TARGET_ARM64
-ST_FUNC void gen_opl(TCCState *S, int op);
+ST_FUNC void gen_opl(TCCState* S, int op);
ST_FUNC void gfunc_return(TCCState *S, CType *func_type);
ST_FUNC void gen_va_start(TCCState *S);
ST_FUNC void gen_va_arg(TCCState *S, CType *t);
ST_FUNC void gen_clear_cache(TCCState *S);
ST_FUNC void gen_cvt_sxtw(TCCState *S);
ST_FUNC void gen_cvt_csti(TCCState *S, int t);
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv);
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv);
#endif
/* ------------ riscv64-gen.c ------------ */
#ifdef TCC_TARGET_RISCV64
-ST_FUNC void gen_opl(TCCState *S, int op);
+ST_FUNC void gen_opl(TCCState* S, int op);
//ST_FUNC void gfunc_return(TCCState *S, CType *func_type);
ST_FUNC void gen_va_start(TCCState *S);
-ST_FUNC void arch_transfer_ret_regs(TCCState *S, int);
+ST_FUNC void arch_transfer_ret_regs(TCCState* S, int);
ST_FUNC void gen_cvt_sxtw(TCCState *S);
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv);
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv);
#endif
/* ------------ c67-gen.c ------------ */
@@ -1850,25 +1851,25 @@ ST_FUNC int tcc_load_coff(TCCState *S, int fd);
#endif
/* ------------ tccasm.c ------------ */
-ST_FUNC void asm_instr(TCCState *S);
-ST_FUNC void asm_global_instr(TCCState *S);
+ST_FUNC void asm_instr(TCCState* S);
+ST_FUNC void asm_global_instr(TCCState* S);
ST_FUNC int tcc_assemble(TCCState *S, int do_preprocess);
#ifdef CONFIG_TCC_ASM
-ST_FUNC int find_constraint(TCCState *S, ASMOperand *operands, int nb_operands, const char *name, const char **pp);
-ST_FUNC Sym* get_asm_sym(TCCState *S, int name, Sym *csym);
+ST_FUNC int find_constraint(TCCState* S, ASMOperand *operands, int nb_operands, const char *name, const char **pp);
+ST_FUNC Sym* get_asm_sym(TCCState* S, int name, Sym *csym);
ST_FUNC void asm_expr(TCCState *S, ExprValue *pe);
ST_FUNC int asm_int_expr(TCCState *S);
/* ------------ i386-asm.c ------------ */
-ST_FUNC void gen_expr32(TCCState *S, ExprValue *pe);
+ST_FUNC void gen_expr32(TCCState* S, ExprValue *pe);
#ifdef TCC_TARGET_X86_64
-ST_FUNC void gen_expr64(TCCState *S, ExprValue *pe);
+ST_FUNC void gen_expr64(TCCState* S, ExprValue *pe);
#endif
ST_FUNC void asm_opcode(TCCState *S, int opcode);
-ST_FUNC int asm_parse_regvar(TCCState *S, int t);
-ST_FUNC void asm_compute_constraints(TCCState *S, ASMOperand *operands, int nb_operands, int nb_outputs, const uint8_t *clobber_regs, int *pout_reg);
-ST_FUNC void subst_asm_operand(TCCState *S, CString *add_str, SValue *sv, int modifier);
-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);
-ST_FUNC void asm_clobber(TCCState *S, uint8_t *clobber_regs, const char *str);
+ST_FUNC int asm_parse_regvar(TCCState* S, int t);
+ST_FUNC void asm_compute_constraints(TCCState* S, ASMOperand *operands, int nb_operands, int nb_outputs, const uint8_t *clobber_regs, int *pout_reg);
+ST_FUNC void subst_asm_operand(TCCState* S, CString *add_str, SValue *sv, int modifier);
+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);
+ST_FUNC void asm_clobber(TCCState* S, uint8_t *clobber_regs, const char *str);
#endif
/* ------------ tccpe.c -------------- */
@@ -1880,9 +1881,9 @@ ST_FUNC int pe_putimport(TCCState *S, int dllindex, const char *name, addr_t val
ST_FUNC SValue *pe_getimport(TCCState * S, SValue *sv, SValue *v2);
#endif
#ifdef TCC_TARGET_X86_64
-ST_FUNC void pe_add_unwind_data(TCCState *S, unsigned start, unsigned end, unsigned stack);
+ST_FUNC void pe_add_unwind_data(TCCState* S, unsigned start, unsigned end, unsigned stack);
#endif
-PUB_FUNC int tcc_get_dllexports(TCCState *S, const char *filename, char **pp);
+PUB_FUNC int tcc_get_dllexports(TCCState* S, const char *filename, char **pp);
/* symbol properties stored in Elf32_Sym->st_other */
# define ST_PE_EXPORT 0x10
# define ST_PE_IMPORT 0x20
@@ -1896,7 +1897,7 @@ ST_FUNC int macho_output_file(TCCState * S, const char *filename);
ST_FUNC int macho_load_dll(TCCState *S, int fd, const char *filename, int lev);
ST_FUNC int macho_load_tbd(TCCState *S, int fd, const char *filename, int lev);
#ifdef TCC_IS_NATIVE
-ST_FUNC void tcc_add_macos_sdkpath(TCCState *S);
+ST_FUNC void tcc_add_macos_sdkpath(TCCState* S);
ST_FUNC const char* macho_tbd_soname(const char* filename);
#endif
#endif
diff --git a/tccasm.c b/tccasm.c
index 3141153..be8b7cb 100644
--- a/tccasm.c
+++ b/tccasm.c
@@ -39,7 +39,7 @@ static Sym* asm_new_label1(TCCState *S, int label, int is_local, int sh_num, int
the global C symbol table to track ASM names as well, so we need to
transform those into ones that don't conflict with a C name,
so prepend a '.' for them, but force the ELF asm name to be set. */
-static int asm2cname(TCCState *S, int v, int *addeddot)
+static int asm2cname(TCCState* S, int v, int *addeddot)
{
const char *name;
*addeddot = 0;
@@ -59,7 +59,7 @@ static int asm2cname(TCCState *S, int v, int *addeddot)
return v;
}
-static Sym *asm_label_find(TCCState *S, int v)
+static Sym *asm_label_find(TCCState* S, int v)
{
Sym *sym;
int addeddot;
@@ -70,7 +70,7 @@ static Sym *asm_label_find(TCCState *S, int v)
return sym;
}
-static Sym *asm_label_push(TCCState *S, int v)
+static Sym *asm_label_push(TCCState* S, int v)
{
int addeddot, v2 = asm2cname(S, v, &addeddot);
/* We always add VT_EXTERN, for sym definition that's tentative
@@ -92,7 +92,7 @@ static Sym *asm_label_push(TCCState *S, int v)
are anonymous in C, in this case CSYM can be used to transfer
all information from that symbol to the (possibly newly created)
asm symbol. */
-ST_FUNC Sym* get_asm_sym(TCCState *S, int name, Sym *csym)
+ST_FUNC Sym* get_asm_sym(TCCState* S, int name, Sym *csym)
{
Sym *sym = asm_label_find(S, name);
if (!sym) {
@@ -122,9 +122,9 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe)
uint64_t n;
const char *p;
- switch(S->tok) {
+ switch(S->tccpp_tok) {
case TOK_PPNUM:
- p = S->tokc.str.data;
+ p = S->tccpp_tokc.str.data;
n = strtoull(p, (char **)&p, 0);
if (*p == 'b' || *p == 'f') {
/* backward or forward label */
@@ -161,7 +161,7 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe)
break;
case '-':
case '~':
- op = S->tok;
+ op = S->tccpp_tok;
next(S);
asm_expr_unary(S, pe);
if (pe->sym)
@@ -173,7 +173,7 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe)
break;
case TOK_CCHAR:
case TOK_LCHAR:
- pe->v = S->tokc.i;
+ pe->v = S->tccpp_tokc.i;
pe->sym = NULL;
pe->pcrel = 0;
next(S);
@@ -184,16 +184,16 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe)
skip(S, ')');
break;
case '.':
- pe->v = S->ind;
+ pe->v = S->tccgen_ind;
pe->sym = asm_section_sym(S, cur_text_section);
pe->pcrel = 0;
next(S);
break;
default:
- if (S->tok >= TOK_IDENT) {
+ if (S->tccpp_tok >= TOK_IDENT) {
ElfSym *esym;
/* label case : if the label was not found, add one */
- sym = get_asm_sym(S, S->tok, NULL);
+ sym = get_asm_sym(S, S->tccpp_tok, NULL);
esym = elfsym(S, sym);
if (esym && esym->st_shndx == SHN_ABS) {
/* if absolute symbol, no need to put a symbol value */
@@ -207,7 +207,7 @@ static void asm_expr_unary(TCCState *S, ExprValue *pe)
}
next(S);
} else {
- tcc_error(S, "bad expression syntax [%s]", get_tok_str(S, S->tok, &S->tokc));
+ tcc_error(S, "bad expression syntax [%s]", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
}
break;
}
@@ -220,7 +220,7 @@ static void asm_expr_prod(TCCState *S, ExprValue *pe)
asm_expr_unary(S, pe);
for(;;) {
- op = S->tok;
+ op = S->tccpp_tok;
if (op != '*' && op != '/' && op != '%' &&
op != TOK_SHL && op != TOK_SAR)
break;
@@ -262,7 +262,7 @@ static void asm_expr_logic(TCCState *S, ExprValue *pe)
asm_expr_prod(S, pe);
for(;;) {
- op = S->tok;
+ op = S->tccpp_tok;
if (op != '&' && op != '|' && op != '^')
break;
next(S);
@@ -291,7 +291,7 @@ static inline void asm_expr_sum(TCCState *S, ExprValue *pe)
asm_expr_logic(S, pe);
for(;;) {
- op = S->tok;
+ op = S->tccpp_tok;
if (op != '+' && op != '-')
break;
next(S);
@@ -323,7 +323,7 @@ static inline void asm_expr_sum(TCCState *S, ExprValue *pe)
} else if (esym2->st_shndx == cur_text_section->sh_num) {
/* When subtracting a defined symbol in current section
this actually makes the value PC-relative. */
- pe->v -= esym2->st_value - S->ind - 4;
+ pe->v -= esym2->st_value - S->tccgen_ind - 4;
pe->pcrel = 1;
e2.sym = NULL;
} else {
@@ -342,7 +342,7 @@ static inline void asm_expr_cmp(TCCState *S, ExprValue *pe)
asm_expr_sum(S, pe);
for(;;) {
- op = S->tok;
+ op = S->tccpp_tok;
if (op != TOK_EQ && op != TOK_NE
&& (op > TOK_GT || op < TOK_ULE))
break;
@@ -428,7 +428,7 @@ static Sym* asm_new_label1(TCCState *S, int label, int is_local,
static Sym* asm_new_label(TCCState *S, int label, int is_local)
{
- return asm_new_label1(S, label, is_local, cur_text_section->sh_num, S->ind);
+ return asm_new_label1(S, label, is_local, cur_text_section->sh_num, S->tccgen_ind);
}
/* Set the value of LABEL to that of some expression (possibly
@@ -452,9 +452,9 @@ static Sym* set_symbol(TCCState *S, int label)
static void use_section1(TCCState *S, Section *sec)
{
- cur_text_section->data_offset = S->ind;
+ cur_text_section->data_offset = S->tccgen_ind;
cur_text_section = sec;
- S->ind = cur_text_section->data_offset;
+ S->tccgen_ind = cur_text_section->data_offset;
}
static void use_section(TCCState *S, const char *name)
@@ -488,13 +488,13 @@ static void asm_parse_directive(TCCState *S, int global)
/* assembler directive */
sec = cur_text_section;
- switch(S->tok) {
+ switch(S->tccpp_tok) {
case TOK_ASMDIR_align:
case TOK_ASMDIR_balign:
case TOK_ASMDIR_p2align:
case TOK_ASMDIR_skip:
case TOK_ASMDIR_space:
- tok1 = S->tok;
+ tok1 = S->tccpp_tok;
next(S);
n = asm_int_expr(S);
if (tok1 == TOK_ASMDIR_p2align)
@@ -507,8 +507,8 @@ static void asm_parse_directive(TCCState *S, int global)
if (tok1 == TOK_ASMDIR_align || tok1 == TOK_ASMDIR_balign) {
if (n < 0 || (n & (n-1)) != 0)
tcc_error(S, "alignment must be a positive power of two");
- offset = (S->ind + n - 1) & -n;
- size = offset - S->ind;
+ offset = (S->tccgen_ind + n - 1) & -n;
+ size = offset - S->tccgen_ind;
/* the section must have a compatible alignment */
if (sec->sh_addralign < n)
sec->sh_addralign = n;
@@ -518,17 +518,17 @@ static void asm_parse_directive(TCCState *S, int global)
size = n;
}
v = 0;
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
v = asm_int_expr(S);
}
zero_pad:
if (sec->sh_type != SHT_NOBITS) {
- sec->data_offset = S->ind;
+ sec->data_offset = S->tccgen_ind;
ptr = section_ptr_add(S, sec, size);
memset(ptr, v, size);
}
- S->ind += size;
+ S->tccgen_ind += size;
break;
case TOK_ASMDIR_quad:
#ifdef TCC_TARGET_X86_64
@@ -540,8 +540,8 @@ static void asm_parse_directive(TCCState *S, int global)
uint64_t vl;
const char *p;
- p = S->tokc.str.data;
- if (S->tok != TOK_PPNUM) {
+ p = S->tccpp_tokc.str.data;
+ if (S->tccpp_tok != TOK_PPNUM) {
error_constant:
tcc_error(S, "64 bit constant");
}
@@ -554,9 +554,9 @@ static void asm_parse_directive(TCCState *S, int global)
gen_le32(S, vl);
gen_le32(S, vl >> 32);
} else {
- S->ind += 8;
+ S->tccgen_ind += 8;
}
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
break;
next(S);
}
@@ -593,9 +593,9 @@ static void asm_parse_directive(TCCState *S, int global)
gen_le16(S, e.v);
}
} else {
- S->ind += size;
+ S->tccgen_ind += size;
}
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
break;
next(S);
}
@@ -612,7 +612,7 @@ static void asm_parse_directive(TCCState *S, int global)
}
size = 1;
val = 0;
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
size = asm_int_expr(S);
if (size < 0) {
@@ -621,7 +621,7 @@ static void asm_parse_directive(TCCState *S, int global)
}
if (size > 8)
size = 8;
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
val = asm_int_expr(S);
}
@@ -649,8 +649,8 @@ static void asm_parse_directive(TCCState *S, int global)
next(S);
repeat = asm_int_expr(S);
init_str = tok_str_alloc(S);
- while (next(S), S->tok != TOK_ASMDIR_endr) {
- if (S->tok == CH_EOF)
+ while (next(S), S->tccpp_tok != TOK_ASMDIR_endr) {
+ if (S->tccpp_tok == CH_EOF)
tcc_error(S, "we at end of file, .endr not found");
tok_str_add_tok(S, init_str);
}
@@ -680,31 +680,31 @@ static void asm_parse_directive(TCCState *S, int global)
expect(S, "constant or same-section symbol");
n += esym->st_value;
}
- if (n < S->ind)
+ if (n < S->tccgen_ind)
tcc_error(S, "attempt to .org backwards");
v = 0;
- size = n - S->ind;
+ size = n - S->tccgen_ind;
goto zero_pad;
}
break;
case TOK_ASMDIR_set:
next(S);
- tok1 = S->tok;
+ tok1 = S->tccpp_tok;
next(S);
/* Also accept '.set stuff', but don't do anything with this.
It's used in GAS to set various features like '.set mips16'. */
- if (S->tok == ',')
+ if (S->tccpp_tok == ',')
set_symbol(S, tok1);
break;
case TOK_ASMDIR_globl:
case TOK_ASMDIR_global:
case TOK_ASMDIR_weak:
case TOK_ASMDIR_hidden:
- tok1 = S->tok;
+ tok1 = S->tccpp_tok;
do {
Sym *sym;
next(S);
- sym = get_asm_sym(S, S->tok, NULL);
+ sym = get_asm_sym(S, S->tccpp_tok, NULL);
if (tok1 != TOK_ASMDIR_hidden)
sym->type.t &= ~VT_STATIC;
if (tok1 == TOK_ASMDIR_weak)
@@ -713,7 +713,7 @@ static void asm_parse_directive(TCCState *S, int global)
sym->a.visibility = STV_HIDDEN;
update_storage(S, sym);
next(S);
- } while (S->tok == ',');
+ } while (S->tccpp_tok == ',');
break;
case TOK_ASMDIR_string:
case TOK_ASMDIR_ascii:
@@ -722,21 +722,21 @@ static void asm_parse_directive(TCCState *S, int global)
const uint8_t *p;
int i, size, t;
- t = S->tok;
+ t = S->tccpp_tok;
next(S);
for(;;) {
- if (S->tok != TOK_STR)
+ if (S->tccpp_tok != TOK_STR)
expect(S, "string constant");
- p = S->tokc.str.data;
- size = S->tokc.str.size;
+ p = S->tccpp_tokc.str.data;
+ size = S->tccpp_tokc.str.size;
if (t == TOK_ASMDIR_ascii && size > 0)
size--;
for(i = 0; i < size; i++)
g(S, p[i]);
next(S);
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
- } else if (S->tok != TOK_STR) {
+ } else if (S->tccpp_tok != TOK_STR) {
break;
}
}
@@ -747,10 +747,10 @@ static void asm_parse_directive(TCCState *S, int global)
case TOK_ASMDIR_bss:
{
char sname[64];
- tok1 = S->tok;
+ tok1 = S->tccpp_tok;
n = 0;
next(S);
- if (S->tok != ';' && S->tok != TOK_LINEFEED) {
+ if (S->tccpp_tok != ';' && S->tccpp_tok != TOK_LINEFEED) {
n = asm_int_expr(S);
next(S);
}
@@ -767,10 +767,10 @@ static void asm_parse_directive(TCCState *S, int global)
filename[0] = '\0';
next(S);
- if (S->tok == TOK_STR)
- pstrcat(filename, sizeof(filename), S->tokc.str.data);
+ if (S->tccpp_tok == TOK_STR)
+ pstrcat(filename, sizeof(filename), S->tccpp_tokc.str.data);
else
- pstrcat(filename, sizeof(filename), get_tok_str(S, S->tok, NULL));
+ pstrcat(filename, sizeof(filename), get_tok_str(S, S->tccpp_tok, NULL));
tcc_warning_c(warn_unsupported)(S, "ignoring .file %s", filename);
next(S);
}
@@ -781,10 +781,10 @@ static void asm_parse_directive(TCCState *S, int global)
ident[0] = '\0';
next(S);
- if (S->tok == TOK_STR)
- pstrcat(ident, sizeof(ident), S->tokc.str.data);
+ if (S->tccpp_tok == TOK_STR)
+ pstrcat(ident, sizeof(ident), S->tccpp_tokc.str.data);
else
- pstrcat(ident, sizeof(ident), get_tok_str(S, S->tok, NULL));
+ pstrcat(ident, sizeof(ident), get_tok_str(S, S->tccpp_tok, NULL));
tcc_warning_c(warn_unsupported)(S, "ignoring .ident %s", ident);
next(S);
}
@@ -794,15 +794,15 @@ static void asm_parse_directive(TCCState *S, int global)
Sym *sym;
next(S);
- sym = asm_label_find(S, S->tok);
+ sym = asm_label_find(S, S->tccpp_tok);
if (!sym) {
- tcc_error(S, "label not found: %s", get_tok_str(S, S->tok, NULL));
+ tcc_error(S, "label not found: %s", get_tok_str(S, S->tccpp_tok, NULL));
}
/* XXX .size name,label2-label1 */
- tcc_warning_c(warn_unsupported)(S, "ignoring .size %s,*", get_tok_str(S, S->tok, NULL));
+ tcc_warning_c(warn_unsupported)(S, "ignoring .size %s,*", get_tok_str(S, S->tccpp_tok, NULL));
next(S);
skip(S, ',');
- while (S->tok != TOK_LINEFEED && S->tok != ';' && S->tok != CH_EOF) {
+ while (S->tccpp_tok != TOK_LINEFEED && S->tccpp_tok != ';' && S->tccpp_tok != CH_EOF) {
next(S);
}
}
@@ -813,15 +813,15 @@ static void asm_parse_directive(TCCState *S, int global)
const char *newtype;
next(S);
- sym = get_asm_sym(S, S->tok, NULL);
+ sym = get_asm_sym(S, S->tccpp_tok, NULL);
next(S);
skip(S, ',');
- if (S->tok == TOK_STR) {
- newtype = S->tokc.str.data;
+ if (S->tccpp_tok == TOK_STR) {
+ newtype = S->tccpp_tokc.str.data;
} else {
- if (S->tok == '@' || S->tok == '%')
+ if (S->tccpp_tok == '@' || S->tccpp_tok == '%')
next(S);
- newtype = get_tok_str(S, S->tok, NULL);
+ newtype = get_tok_str(S, S->tccpp_tok, NULL);
}
if (!strcmp(newtype, "function") || !strcmp(newtype, "STT_FUNC")) {
@@ -839,26 +839,26 @@ static void asm_parse_directive(TCCState *S, int global)
char sname[256];
int old_nb_section = S->nb_sections;
- tok1 = S->tok;
+ tok1 = S->tccpp_tok;
/* XXX: support more options */
next(S);
sname[0] = '\0';
- while (S->tok != ';' && S->tok != TOK_LINEFEED && S->tok != ',') {
- if (S->tok == TOK_STR)
- pstrcat(sname, sizeof(sname), S->tokc.str.data);
+ while (S->tccpp_tok != ';' && S->tccpp_tok != TOK_LINEFEED && S->tccpp_tok != ',') {
+ if (S->tccpp_tok == TOK_STR)
+ pstrcat(sname, sizeof(sname), S->tccpp_tokc.str.data);
else
- pstrcat(sname, sizeof(sname), get_tok_str(S, S->tok, NULL));
+ pstrcat(sname, sizeof(sname), get_tok_str(S, S->tccpp_tok, NULL));
next(S);
}
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
/* skip section options */
next(S);
- if (S->tok != TOK_STR)
+ if (S->tccpp_tok != TOK_STR)
expect(S, "string constant");
next(S);
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
- if (S->tok == '@' || S->tok == '%')
+ if (S->tccpp_tok == '@' || S->tccpp_tok == '%')
next(S);
next(S);
}
@@ -911,7 +911,7 @@ static void asm_parse_directive(TCCState *S, int global)
break;
#endif
default:
- tcc_error(S, "unknown assembler directive '.%s'", get_tok_str(S, S->tok, NULL));
+ tcc_error(S, "unknown assembler directive '.%s'", get_tok_str(S, S->tccpp_tok, NULL));
break;
}
}
@@ -928,20 +928,20 @@ static int tcc_assemble_internal(TCCState *S, int do_preprocess, int global)
S->tccpp_parse_flags |= PARSE_FLAG_PREPROCESS;
for(;;) {
next(S);
- if (S->tok == TOK_EOF)
+ if (S->tccpp_tok == TOK_EOF)
break;
S->tccpp_parse_flags |= PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */
redo:
- if (S->tok == '#') {
+ if (S->tccpp_tok == '#') {
/* horrible gas comment */
- while (S->tok != TOK_LINEFEED)
+ while (S->tccpp_tok != TOK_LINEFEED)
next(S);
- } else if (S->tok >= TOK_ASMDIR_FIRST && S->tok <= TOK_ASMDIR_LAST) {
+ } else if (S->tccpp_tok >= TOK_ASMDIR_FIRST && S->tccpp_tok <= TOK_ASMDIR_LAST) {
asm_parse_directive(S, global);
- } else if (S->tok == TOK_PPNUM) {
+ } else if (S->tccpp_tok == TOK_PPNUM) {
const char *p;
int n;
- p = S->tokc.str.data;
+ p = S->tccpp_tokc.str.data;
n = strtoul(p, (char **)&p, 10);
if (*p != '\0')
expect(S, "':'");
@@ -950,16 +950,16 @@ static int tcc_assemble_internal(TCCState *S, int do_preprocess, int global)
next(S);
skip(S, ':');
goto redo;
- } else if (S->tok >= TOK_IDENT) {
+ } else if (S->tccpp_tok >= TOK_IDENT) {
/* instruction or label */
- opcode = S->tok;
+ opcode = S->tccpp_tok;
next(S);
- if (S->tok == ':') {
+ if (S->tccpp_tok == ':') {
/* new label */
asm_new_label(S, opcode, 0);
next(S);
goto redo;
- } else if (S->tok == '=') {
+ } else if (S->tccpp_tok == '=') {
set_symbol(S, opcode);
goto redo;
} else {
@@ -967,7 +967,7 @@ static int tcc_assemble_internal(TCCState *S, int do_preprocess, int global)
}
}
/* end of line */
- if (S->tok != ';' && S->tok != TOK_LINEFEED)
+ if (S->tccpp_tok != ';' && S->tccpp_tok != TOK_LINEFEED)
expect(S, "end of line");
S->tccpp_parse_flags &= ~PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */
}
@@ -983,10 +983,10 @@ ST_FUNC int tcc_assemble(TCCState *S, int do_preprocess)
tcc_debug_start(S);
/* default section is text */
cur_text_section = text_section;
- S->ind = cur_text_section->data_offset;
- S->nocode_wanted = 0;
+ S->tccgen_ind = cur_text_section->data_offset;
+ S->tccgen_nocode_wanted = 0;
ret = tcc_assemble_internal(S, do_preprocess, 1);
- cur_text_section->data_offset = S->ind;
+ cur_text_section->data_offset = S->tccgen_ind;
tcc_debug_end(S);
return ret;
}
@@ -1017,7 +1017,7 @@ static void tcc_assemble_inline(TCCState *S, char *str, int len, int global)
/* find a constraint by its number or id (gcc 3 extended
syntax). return -1 if not found. Return in *pp in char after the
constraint */
-ST_FUNC int find_constraint(TCCState *S, ASMOperand *operands, int nb_operands,
+ST_FUNC int find_constraint(TCCState* S, ASMOperand *operands, int nb_operands,
const char *name, const char **pp)
{
int index;
@@ -1055,7 +1055,7 @@ ST_FUNC int find_constraint(TCCState *S, ASMOperand *operands, int nb_operands,
return index;
}
-static void subst_asm_operands(TCCState *S, ASMOperand *operands, int nb_operands,
+static void subst_asm_operands(TCCState* S, ASMOperand *operands, int nb_operands,
CString *out_str, CString *in_str)
{
int c, index, modifier;
@@ -1101,13 +1101,13 @@ static void subst_asm_operands(TCCState *S, ASMOperand *operands, int nb_operand
}
-static void parse_asm_operands(TCCState *S, ASMOperand *operands, int *nb_operands_ptr,
+static void parse_asm_operands(TCCState* S, ASMOperand *operands, int *nb_operands_ptr,
int is_output)
{
ASMOperand *op;
int nb_operands;
- if (S->tok != ':') {
+ if (S->tccpp_tok != ':') {
nb_operands = *nb_operands_ptr;
for(;;) {
CString astr;
@@ -1115,11 +1115,11 @@ static void parse_asm_operands(TCCState *S, ASMOperand *operands, int *nb_operan
tcc_error(S, "too many asm operands");
op = &operands[nb_operands++];
op->id = 0;
- if (S->tok == '[') {
+ if (S->tccpp_tok == '[') {
next(S);
- if (S->tok < TOK_IDENT)
+ if (S->tccpp_tok < TOK_IDENT)
expect(S, "identifier");
- op->id = S->tok;
+ op->id = S->tccpp_tok;
next(S);
skip(S, ']');
}
@@ -1130,23 +1130,23 @@ static void parse_asm_operands(TCCState *S, ASMOperand *operands, int *nb_operan
skip(S, '(');
gexpr(S);
if (is_output) {
- if (!(S->vtop->type.t & VT_ARRAY))
+ if (!(S->tccgen_vtop->type.t & VT_ARRAY))
test_lvalue(S);
} else {
/* we want to avoid LLOCAL case, except when the 'm'
constraint is used. Note that it may come from
register storage, so we need to convert (reg)
case */
- if ((S->vtop->r & VT_LVAL) &&
- ((S->vtop->r & VT_VALMASK) == VT_LLOCAL ||
- (S->vtop->r & VT_VALMASK) < VT_CONST) &&
+ if ((S->tccgen_vtop->r & VT_LVAL) &&
+ ((S->tccgen_vtop->r & VT_VALMASK) == VT_LLOCAL ||
+ (S->tccgen_vtop->r & VT_VALMASK) < VT_CONST) &&
!strchr(op->constraint, 'm')) {
gv(S, RC_INT);
}
}
- op->vt = S->vtop;
+ op->vt = S->tccgen_vtop;
skip(S, ')');
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
} else {
break;
@@ -1157,7 +1157,7 @@ static void parse_asm_operands(TCCState *S, ASMOperand *operands, int *nb_operan
}
/* parse the GCC asm() instruction */
-ST_FUNC void asm_instr(TCCState *S)
+ST_FUNC void asm_instr(TCCState* S)
{
CString astr, astr1;
ASMOperand operands[MAX_ASM_OPERANDS];
@@ -1167,7 +1167,7 @@ ST_FUNC void asm_instr(TCCState *S)
/* since we always generate the asm() instruction, we can ignore
volatile */
- if (S->tok == TOK_VOLATILE1 || S->tok == TOK_VOLATILE2 || S->tok == TOK_VOLATILE3) {
+ if (S->tccpp_tok == TOK_VOLATILE1 || S->tccpp_tok == TOK_VOLATILE2 || S->tccpp_tok == TOK_VOLATILE3) {
next(S);
}
parse_asm_str(S, &astr);
@@ -1175,27 +1175,27 @@ ST_FUNC void asm_instr(TCCState *S)
nb_outputs = 0;
must_subst = 0;
memset(clobber_regs, 0, sizeof(clobber_regs));
- if (S->tok == ':') {
+ if (S->tccpp_tok == ':') {
next(S);
must_subst = 1;
/* output args */
parse_asm_operands(S, operands, &nb_operands, 1);
nb_outputs = nb_operands;
- if (S->tok == ':') {
+ if (S->tccpp_tok == ':') {
next(S);
- if (S->tok != ')') {
+ if (S->tccpp_tok != ')') {
/* input args */
parse_asm_operands(S, operands, &nb_operands, 0);
- if (S->tok == ':') {
+ if (S->tccpp_tok == ':') {
/* clobber list */
/* XXX: handle registers */
next(S);
for(;;) {
- if (S->tok != TOK_STR)
+ if (S->tccpp_tok != TOK_STR)
expect(S, "string constant");
- asm_clobber(S, clobber_regs, S->tokc.str.data);
+ asm_clobber(S, clobber_regs, S->tccpp_tokc.str.data);
next(S);
- if (S->tok == ',') {
+ if (S->tccpp_tok == ',') {
next(S);
} else {
break;
@@ -1208,7 +1208,7 @@ ST_FUNC void asm_instr(TCCState *S)
skip(S, ')');
/* NOTE: we do not eat the ';' so that we can restore the current
token after the assembler parsing */
- if (S->tok != ';')
+ if (S->tccpp_tok != ';')
expect(S, "';'");
/* save all values in the memory */
@@ -1264,37 +1264,37 @@ ST_FUNC void asm_instr(TCCState *S)
cstr_free(S, &astr1);
}
-ST_FUNC void asm_global_instr(TCCState *S)
+ST_FUNC void asm_global_instr(TCCState* S)
{
CString astr;
- int saved_nocode_wanted = S->nocode_wanted;
+ int saved_nocode_wanted = S->tccgen_nocode_wanted;
/* Global asm blocks are always emitted. */
- S->nocode_wanted = 0;
+ S->tccgen_nocode_wanted = 0;
next(S);
parse_asm_str(S, &astr);
skip(S, ')');
/* NOTE: we do not eat the ';' so that we can restore the current
token after the assembler parsing */
- if (S->tok != ';')
+ if (S->tccpp_tok != ';')
expect(S, "';'");
#ifdef ASM_DEBUG
printf("asm_global: \"%s\"\n", (char *)astr.data);
#endif
cur_text_section = text_section;
- S->ind = cur_text_section->data_offset;
+ S->tccgen_ind = cur_text_section->data_offset;
/* assemble the string with tcc internal assembler */
tcc_assemble_inline(S, astr.data, astr.size - 1, 1);
- cur_text_section->data_offset = S->ind;
+ cur_text_section->data_offset = S->tccgen_ind;
/* restore the current C token */
next(S);
cstr_free(S, &astr);
- S->nocode_wanted = saved_nocode_wanted;
+ S->tccgen_nocode_wanted = saved_nocode_wanted;
}
/********************************************************/
@@ -1304,12 +1304,12 @@ ST_FUNC int tcc_assemble(TCCState *S, int do_preprocess)
tcc_error(S, "asm not supported");
}
-ST_FUNC void asm_instr(TCCState *S)
+ST_FUNC void asm_instr(S)
{
tcc_error(S, "inline asm() not supported");
}
-ST_FUNC void asm_global_instr(TCCState *S)
+ST_FUNC void asm_global_instr(S)
{
tcc_error(S, "inline asm() not supported");
}
diff --git a/tccelf.c b/tccelf.c
index c68349f..16337da 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -107,7 +107,7 @@ ST_FUNC void tccelf_stab_new(TCCState *S)
put_stabs(S, "", 0, 0, 0, 0);
}
-static void free_section(TCCState *S, Section *s)
+static void free_section(TCCState* S, Section *s)
{
tcc_free(S, s->data);
}
@@ -284,7 +284,7 @@ ST_FUNC Section *new_symtab(TCCState *S,
}
/* realloc section and set its content to zero */
-ST_FUNC void section_realloc(TCCState *S, Section *sec, unsigned long new_size)
+ST_FUNC void section_realloc(TCCState* S, Section *sec, unsigned long new_size)
{
unsigned long size;
unsigned char *data;
@@ -302,7 +302,7 @@ ST_FUNC void section_realloc(TCCState *S, Section *sec, unsigned long new_size)
/* reserve at least 'size' bytes aligned per 'align' in section
'sec' from current offset, and return the aligned offset */
-ST_FUNC size_t section_add(TCCState *S, Section *sec, addr_t size, int align)
+ST_FUNC size_t section_add(TCCState* S, Section *sec, addr_t size, int align)
{
size_t offset, offset1;
@@ -318,7 +318,7 @@ ST_FUNC size_t section_add(TCCState *S, Section *sec, addr_t size, int align)
/* reserve at least 'size' bytes in section 'sec' from
sec->data_offset. */
-ST_FUNC void *section_ptr_add(TCCState *S, Section *sec, addr_t size)
+ST_FUNC void *section_ptr_add(TCCState* S, Section *sec, addr_t size)
{
size_t offset = section_add(S, sec, size, 1);
return sec->data + offset;
@@ -326,7 +326,7 @@ ST_FUNC void *section_ptr_add(TCCState *S, Section *sec, addr_t size)
#ifndef ELF_OBJ_ONLY
/* reserve at least 'size' bytes from section start */
-static void section_reserve(TCCState *S, Section *sec, unsigned long size)
+static void section_reserve(TCCState* S, Section *sec, unsigned long size)
{
if (size > sec->data_allocated)
section_realloc(S, sec, size);
@@ -357,7 +357,7 @@ ST_FUNC Section *find_section(TCCState *S, const char *name)
/* ------------------------------------------------------------------------- */
-ST_FUNC int put_elf_str(TCCState *S, Section *s, const char *sym)
+ST_FUNC int put_elf_str(TCCState* S, Section *s, const char *sym)
{
int offset, len;
char *ptr;
@@ -386,7 +386,7 @@ static unsigned long elf_hash(const unsigned char *name)
/* rebuild hash table of section s */
/* NOTE: we do factorize the hash table code to go faster */
-static void rebuild_hash(TCCState *S, Section *s, unsigned int nb_buckets)
+static void rebuild_hash(TCCState* S, Section *s, unsigned int nb_buckets)
{
ElfW(Sym) *sym;
int *ptr, *hash, nb_syms, sym_index, h;
@@ -422,7 +422,7 @@ static void rebuild_hash(TCCState *S, Section *s, unsigned int nb_buckets)
}
/* return the symbol number */
-ST_FUNC int put_elf_sym(TCCState *S, Section *s, addr_t value, unsigned long size,
+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)
{
int name_offset, sym_index;
@@ -2082,7 +2082,7 @@ static int layout_sections(TCCState *S, ElfW(Phdr) *phdr,
}
/* put dynamic tag */
-static void put_dt(TCCState *S, Section *dynamic, int dt, addr_t val)
+static void put_dt(TCCState* S, Section *dynamic, int dt, addr_t val)
{
ElfW(Dyn) *dyn;
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) {
}
}
-ST_FUNC void *load_data(TCCState *S, int fd, unsigned long file_offset, unsigned long size)
+ST_FUNC void *load_data(TCCState* S, int fd, unsigned long file_offset, unsigned long size)
{
void *data;
diff --git a/tccgen.c b/tccgen.c
index 9f92940..c1fb291 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -33,22 +33,22 @@
#define vstack (S->tccgen__vstack + 1)
#define unevalmask 0xffff /* unevaluated subexpression */
-#define NODATA_WANTED (S->nocode_wanted > 0) /* no static data output wanted either */
-#define STATIC_DATA_WANTED (S->nocode_wanted & 0xC0000000) /* only static data output */
+#define NODATA_WANTED (S->tccgen_nocode_wanted > 0) /* no static data output wanted either */
+#define STATIC_DATA_WANTED (S->tccgen_nocode_wanted & 0xC0000000) /* only static data output */
/* Automagical code suppression ----> */
-#define CODE_OFF() (S->nocode_wanted |= 0x20000000)
-#define CODE_ON() (S->nocode_wanted &= ~0x20000000)
+#define CODE_OFF() (S->tccgen_nocode_wanted |= 0x20000000)
+#define CODE_ON() (S->tccgen_nocode_wanted &= ~0x20000000)
-static void tcc_tcov_block_begin(TCCState *S);
+static void tcc_tcov_block_begin(TCCState* S);
/* Clear 'nocode_wanted' at label if it was used */
-ST_FUNC void gsym(TCCState *S, int t) { if (t) { gsym_addr(S, t, S->ind); CODE_ON(); }}
-static int gind(TCCState *S) { int t = S->ind; CODE_ON(); if (S->tccgen_debug_modes) tcc_tcov_block_begin(S); return t; }
+ST_FUNC void gsym(TCCState* S, int t) { if (t) { gsym_addr(S, t, S->tccgen_ind); CODE_ON(); }}
+static int gind(TCCState* S) { int t = S->tccgen_ind; CODE_ON(); if (S->tccgen_debug_modes) tcc_tcov_block_begin(S); return t; }
/* Set 'nocode_wanted' after unconditional jumps */
-static void gjmp_addr_acs(TCCState *S, int t) { gjmp_addr(S, t); CODE_OFF(); }
-static int gjmp_acs(TCCState *S, int t) { t = gjmp(S, t); CODE_OFF(); return t; }
+static void gjmp_addr_acs(TCCState* S, int t) { gjmp_addr(S, t); CODE_OFF(); }
+static int gjmp_acs(TCCState* S, int t) { t = gjmp(S, t); CODE_OFF(); return t; }
/* These are #undef'd at the end of this file */
#define gjmp_addr gjmp_addr_acs
@@ -74,7 +74,7 @@ typedef struct {
#if 1
#define precedence_parser
-static void init_prec(TCCState *S);
+static void init_prec(TCCState* S);
#endif
/********************************************************/
@@ -129,33 +129,33 @@ static const struct {
};
/********************************************************/
-static void gen_cast(TCCState *S, CType *type);
-static void gen_cast_s(TCCState *S, int t);
+static void gen_cast(TCCState* S, CType *type);
+static void gen_cast_s(TCCState* S, int t);
static inline CType *pointed_type(CType *type);
static int is_compatible_types(CType *type1, CType *type2);
-static int parse_btype(TCCState *S, CType *type, AttributeDef *ad);
-static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int td);
-static void parse_expr_type(TCCState *S, CType *type);
-static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c);
-static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned long c, int flags);
-static void block(TCCState *S, int is_expr);
-static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, int r, int has_init, int v, int scope);
-static void decl(TCCState *S, int l);
-static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *);
-static void expr_eq(TCCState *S);
-static void vla_runtime_type_size(TCCState *S, CType *type, int *a);
+static int parse_btype(TCCState* S, CType *type, AttributeDef *ad);
+static CType *type_decl(TCCState* S, CType *type, AttributeDef *ad, int *v, int td);
+static void parse_expr_type(TCCState* S, CType *type);
+static void init_putv(TCCState* S, init_params *p, CType *type, unsigned long c);
+static void decl_initializer(TCCState* S, init_params *p, CType *type, unsigned long c, int flags);
+static void block(TCCState* S, int is_expr);
+static void decl_initializer_alloc(TCCState* S, CType *type, AttributeDef *ad, int r, int has_init, int v, int scope);
+static void decl(TCCState* S, int l);
+static int decl0(TCCState* S, int l, int is_for_loop_init, Sym *);
+static void expr_eq(TCCState* S);
+static void vla_runtime_type_size(TCCState* S, CType *type, int *a);
static int is_compatible_unqualified_types(CType *type1, CType *type2);
-static inline int64_t expr_const64(TCCState *S);
-static void vpush64(TCCState *S, int ty, unsigned long long v);
-static void vpush(TCCState *S, CType *type);
-static int gvtst(TCCState *S, int inv, int t);
+static inline int64_t expr_const64(TCCState* S);
+static void vpush64(TCCState* S, int ty, unsigned long long v);
+static void vpush(TCCState* S, CType *type);
+static int gvtst(TCCState* S, int inv, int t);
static void gen_inline_functions(TCCState *S);
static void free_inline_functions(TCCState *S);
-static void skip_or_save_block(TCCState *S, TokenString **str);
-static void gv_dup(TCCState *S);
-static int get_temp_local_var(TCCState *S, int size,int align);
+static void skip_or_save_block(TCCState* S, TokenString **str);
+static void gv_dup(TCCState* S);
+static int get_temp_local_var(TCCState* S, int size,int align);
static void clear_temp_local_var_list();
-static void cast_error(TCCState *S, CType *st, CType *dt);
+static void cast_error(TCCState* S, CType *st, CType *dt);
ST_INLN int is_float(int t)
{
@@ -284,17 +284,17 @@ ST_FUNC int ieee_finite(double d)
# define TCC_IS_NATIVE_387
#endif
-ST_FUNC void test_lvalue(TCCState *S)
+ST_FUNC void test_lvalue(TCCState* S)
{
- if (!(S->vtop->r & VT_LVAL))
+ if (!(S->tccgen_vtop->r & VT_LVAL))
expect(S, "lvalue");
}
-ST_FUNC void check_vstack(TCCState *S)
+ST_FUNC void check_vstack(TCCState* S)
{
- if (S->vtop != vstack - 1)
+ if (S->tccgen_vtop != vstack - 1)
tcc_error(S, "internal compiler error: vstack leak (%d)",
- (int)(S->vtop - vstack + 1));
+ (int)(S->tccgen_vtop - vstack + 1));
}
/* ------------------------------------------------------------------------- */
@@ -305,7 +305,7 @@ void pv (const char *lbl, int a, int b)
{
int i;
for (i = a; i < a + b; ++i) {
- SValue *p = &S->vtop[-i];
+ SValue *p = &S->tccgen_vtop[-i];
printf("%s vtop[-%d] : type.t:%04x r:%04x r2:%04x c.i:%d\n",
lbl, i, p->type.t, p->r, p->r2, (int)p->c.i);
}
@@ -371,7 +371,7 @@ static BufferedFile* put_new_file(TCCState *S)
if (f->filename[0] == ':')
f = f->prev;
if (f && S->tccgen_new_file) {
- put_stabs_r(S, f->filename, N_SOL, 0, 0, S->ind, text_section, S->tccgen_section_sym);
+ put_stabs_r(S, f->filename, N_SOL, 0, 0, S->tccgen_ind, text_section, S->tccgen_section_sym);
S->tccgen_new_file = S->tccgen_last_line_num = 0;
}
return f;
@@ -414,10 +414,10 @@ static void tcc_debug_line(TCCState *S)
|| S->tccgen_last_line_num == f->line_num)
return;
if (S->tccgen_func_ind != -1) {
- put_stabn(S, N_SLINE, 0, f->line_num, S->ind - S->tccgen_func_ind);
+ put_stabn(S, N_SLINE, 0, f->line_num, S->tccgen_ind - S->tccgen_func_ind);
} else {
/* from tcc_assemble */
- put_stabs_r(S, NULL, N_SLINE, 0, f->line_num, S->ind, text_section, S->tccgen_section_sym);
+ put_stabs_r(S, NULL, N_SLINE, 0, f->line_num, S->tccgen_ind, text_section, S->tccgen_section_sym);
}
S->tccgen_last_line_num = f->line_num;
}
@@ -427,12 +427,12 @@ static void tcc_debug_stabs (TCCState *S, const char *str, int type, unsigned lo
{
struct debug_sym *s;
- if (S->debug_info) {
- S->debug_info->sym =
- (struct debug_sym *)tcc_realloc (S, S->debug_info->sym,
+ if (S->tccgen_debug_info) {
+ S->tccgen_debug_info->sym =
+ (struct debug_sym *)tcc_realloc (S, S->tccgen_debug_info->sym,
sizeof(struct debug_sym) *
- (S->debug_info->n_sym + 1));
- s = S->debug_info->sym + S->debug_info->n_sym++;
+ (S->tccgen_debug_info->n_sym + 1));
+ s = S->tccgen_debug_info->sym + S->tccgen_debug_info->n_sym++;
s->type = type;
s->value = value;
s->str = tcc_strdup(S, str);
@@ -454,25 +454,25 @@ static void tcc_debug_stabn(TCCState *S, int type, int value)
(debug_info_t *) tcc_mallocz(S, sizeof (*info));
info->start = value;
- info->parent = S->debug_info;
- if (S->debug_info) {
- if (S->debug_info->child) {
- if (S->debug_info->child->last)
- S->debug_info->child->last->next = info;
+ info->parent = S->tccgen_debug_info;
+ if (S->tccgen_debug_info) {
+ if (S->tccgen_debug_info->child) {
+ if (S->tccgen_debug_info->child->last)
+ S->tccgen_debug_info->child->last->next = info;
else
- S->debug_info->child->next = info;
- S->debug_info->child->last = info;
+ S->tccgen_debug_info->child->next = info;
+ S->tccgen_debug_info->child->last = info;
}
else
- S->debug_info->child = info;
+ S->tccgen_debug_info->child = info;
}
else
- S->debug_info_root = info;
- S->debug_info = info;
+ S->tccgen_debug_info_root = info;
+ S->tccgen_debug_info = info;
}
else {
- S->debug_info->end = value;
- S->debug_info = S->debug_info->parent;
+ S->tccgen_debug_info->end = value;
+ S->tccgen_debug_info = S->tccgen_debug_info->parent;
}
}
@@ -644,9 +644,9 @@ static void tcc_debug_funcstart(TCCState *S, Sym *sym)
BufferedFile *f;
if (!S->do_debug)
return;
- S->debug_info_root = NULL;
- S->debug_info = NULL;
- tcc_debug_stabn(S, N_LBRAC, S->ind - S->tccgen_func_ind);
+ S->tccgen_debug_info_root = NULL;
+ S->tccgen_debug_info = NULL;
+ tcc_debug_stabn(S, N_LBRAC, S->tccgen_ind - S->tccgen_func_ind);
if (!(f = put_new_file(S)))
return;
cstr_new (S, &debug_str);
@@ -664,7 +664,7 @@ static void tcc_debug_funcend(TCCState *S, int size)
if (!S->do_debug)
return;
tcc_debug_stabn(S, N_RBRAC, size);
- tcc_debug_finish (S, S->debug_info_root);
+ tcc_debug_finish (S, S->tccgen_debug_info_root);
}
@@ -682,7 +682,7 @@ static void tcc_debug_extern_sym(TCCState *S, Sym *sym, int sh_num, int sym_bind
cstr_new (S, &str);
cstr_printf (S, &str, "%s:%c",
get_tok_str(S, sym->v, NULL),
- sym_bind == STB_GLOBAL ? 'G' : S->local_scope ? 'V' : 'S'
+ sym_bind == STB_GLOBAL ? 'G' : S->tccgen_local_scope ? 'V' : 'S'
);
tcc_get_debug_info(S, sym, &str);
if (sym_bind == STB_GLOBAL)
@@ -712,16 +712,16 @@ static void tcc_debug_typedef(TCCState *S, Sym *sym)
/* ------------------------------------------------------------------------- */
/* for section layout see lib/tcov.c */
-static void tcc_tcov_block_end(TCCState *S, int line);
+static void tcc_tcov_block_end(TCCState* S, int line);
-static void tcc_tcov_block_begin(TCCState *S)
+static void tcc_tcov_block_begin(TCCState* S)
{
SValue sv;
void *ptr;
unsigned long last_offset = S->tccgen_tcov_data.offset;
tcc_tcov_block_end (S, 0);
- if (S->test_coverage == 0 || S->nocode_wanted)
+ if (S->test_coverage == 0 || S->tccgen_nocode_wanted)
return;
if (S->tccgen_tcov_data.last_file_name == 0 ||
@@ -767,7 +767,7 @@ static void tcc_tcov_block_begin(TCCState *S)
ptr = section_ptr_add(S, tcov_section, 8);
write64le (ptr, S->tccpp_file->line_num);
}
- if (S->ind == S->tccgen_tcov_data.ind && S->tccgen_tcov_data.line == S->tccpp_file->line_num)
+ if (S->tccgen_ind == S->tccgen_tcov_data.ind && S->tccgen_tcov_data.line == S->tccpp_file->line_num)
S->tccgen_tcov_data.offset = last_offset;
else {
Sym label = {0};
@@ -793,11 +793,11 @@ static void tcc_tcov_block_begin(TCCState *S)
vpop(S);
#endif
S->tccgen_tcov_data.offset = (unsigned char *)ptr - tcov_section->data;
- S->tccgen_tcov_data.ind = S->ind;
+ S->tccgen_tcov_data.ind = S->tccgen_ind;
}
}
-static void tcc_tcov_block_end(TCCState *S, int line)
+static void tcc_tcov_block_end(TCCState* S, int line)
{
if (S->test_coverage == 0)
return;
@@ -810,7 +810,7 @@ static void tcc_tcov_block_end(TCCState *S, int line)
}
}
-static void tcc_tcov_check_line(TCCState *S, int start)
+static void tcc_tcov_check_line(TCCState* S, int start)
{
if (S->test_coverage == 0)
return;
@@ -825,7 +825,7 @@ static void tcc_tcov_check_line(TCCState *S, int start)
}
}
-static void tcc_tcov_start(TCCState *S)
+static void tcc_tcov_start(TCCState* S)
{
if (S->test_coverage == 0)
return;
@@ -837,7 +837,7 @@ static void tcc_tcov_start(TCCState *S)
}
}
-static void tcc_tcov_end(TCCState *S)
+static void tcc_tcov_end(TCCState* S)
{
if (S->test_coverage == 0)
return;
@@ -851,8 +851,8 @@ static void tcc_tcov_end(TCCState *S)
/* initialize vstack and types. This must be done also for tcc -E */
ST_FUNC void tccgen_init(TCCState *S)
{
- S->vtop = vstack - 1;
- memset(S->vtop, 0, sizeof *S->vtop);
+ S->tccgen_vtop = vstack - 1;
+ memset(S->tccgen_vtop, 0, sizeof *S->tccgen_vtop);
/* define some often used types */
S->tccgen_int_type.t = VT_INT;
@@ -860,8 +860,8 @@ ST_FUNC void tccgen_init(TCCState *S)
S->tccgen_char_type.t = VT_BYTE;
if (S->char_is_unsigned)
S->tccgen_char_type.t |= VT_UNSIGNED;
- S->char_pointer_type = S->tccgen_char_type;
- mk_pointer(S, &S->char_pointer_type);
+ S->tccgen_char_pointer_type = S->tccgen_char_type;
+ mk_pointer(S, &S->tccgen_char_pointer_type);
S->tccgen_func_old_type.t = VT_FUNC;
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)
S->tccgen_anon_sym = SYM_FIRST_ANOM;
S->tccgen_section_sym = 0;
S->tccgen_const_wanted = 0;
- S->nocode_wanted = 0x80000000;
- S->local_scope = 0;
+ S->tccgen_nocode_wanted = 0x80000000;
+ S->tccgen_local_scope = 0;
S->tccgen_debug_modes = S->do_debug | S->test_coverage << 1;
tcc_debug_start(S);
@@ -908,7 +908,7 @@ ST_FUNC void tccgen_finish(TCCState *S)
cstr_free(S, &S->tccgen_initstr);
free_inline_functions(S);
sym_pop(S, &S->tccgen_global_stack, NULL, 0);
- sym_pop(S, &S->local_stack, NULL, 0);
+ sym_pop(S, &S->tccgen_local_stack, NULL, 0);
/* free preprocessor macros */
free_defines(S, NULL);
/* free sym_pools */
@@ -917,7 +917,7 @@ ST_FUNC void tccgen_finish(TCCState *S)
}
/* ------------------------------------------------------------------------- */
-ST_FUNC ElfSym *elfsym(TCCState *S, Sym *s)
+ST_FUNC ElfSym *elfsym(TCCState* S, Sym *s)
{
if (!s || !s->c)
return NULL;
@@ -925,7 +925,7 @@ ST_FUNC ElfSym *elfsym(TCCState *S, Sym *s)
}
/* apply storage attributes to Elf symbol */
-ST_FUNC void update_storage(TCCState *S, Sym *sym)
+ST_FUNC void update_storage(TCCState* S, Sym *sym)
{
ElfSym *esym;
int sym_bind, old_sym_bind;
@@ -971,7 +971,7 @@ ST_FUNC void update_storage(TCCState *S, Sym *sym)
/* update sym->c so that it points to an external symbol in section
'section' with value 'value' */
-ST_FUNC void put_extern_sym2(TCCState *S, Sym *sym, int sh_num,
+ST_FUNC void put_extern_sym2(TCCState* S, Sym *sym, int sh_num,
addr_t value, unsigned long size,
int can_add_underscore)
{
@@ -1039,7 +1039,7 @@ ST_FUNC void put_extern_sym2(TCCState *S, Sym *sym, int sh_num,
update_storage(S, sym);
}
-ST_FUNC void put_extern_sym(TCCState *S, Sym *sym, Section *section,
+ST_FUNC void put_extern_sym(TCCState* S, Sym *sym, Section *section,
addr_t value, unsigned long size)
{
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,
}
/* add a new relocation entry to symbol 'sym' in section 's' */
-ST_FUNC void greloca(TCCState *S, Section *s, Sym *sym, unsigned long offset, int type,
+ST_FUNC void greloca(TCCState* S, Section *s, Sym *sym, unsigned long offset, int type,
addr_t addend)
{
int c = 0;
- if (S->nocode_wanted && s == cur_text_section)
+ if (S->tccgen_nocode_wanted && s == cur_text_section)
return;
if (sym) {
@@ -1066,7 +1066,7 @@ ST_FUNC void greloca(TCCState *S, Section *s, Sym *sym, unsigned long offset, in
}
#if PTR_SIZE == 4
-ST_FUNC void greloc(TCCState *S, Section *s, Sym *sym, unsigned long offset, int type)
+ST_FUNC void greloc(TCCState* S, Section *s, Sym *sym, unsigned long offset, int type)
{
greloca(S, s, sym, offset, type, 0);
}
@@ -1074,7 +1074,7 @@ ST_FUNC void greloc(TCCState *S, Section *s, Sym *sym, unsigned long offset, int
/* ------------------------------------------------------------------------- */
/* symbol allocator */
-static Sym *__sym_malloc(TCCState *S)
+static Sym *__sym_malloc(TCCState* S)
{
Sym *sym_pool, *sym, *last_sym;
int i;
@@ -1093,7 +1093,7 @@ static Sym *__sym_malloc(TCCState *S)
return last_sym;
}
-static inline Sym *sym_malloc(TCCState *S)
+static inline Sym *sym_malloc(TCCState* S)
{
Sym *sym;
#ifndef SYM_DEBUG
@@ -1108,7 +1108,7 @@ static inline Sym *sym_malloc(TCCState *S)
#endif
}
-ST_INLN void sym_free(TCCState *S, Sym *sym)
+ST_INLN void sym_free(TCCState* S, Sym *sym)
{
#ifndef SYM_DEBUG
sym->next = S->tccgen_sym_free_first;
@@ -1119,7 +1119,7 @@ ST_INLN void sym_free(TCCState *S, Sym *sym)
}
/* push, without hashing */
-ST_FUNC Sym *sym_push2(TCCState *S, Sym **ps, int v, int t, int c)
+ST_FUNC Sym *sym_push2(TCCState* S, Sym **ps, int v, int t, int c)
{
Sym *s;
@@ -1149,19 +1149,19 @@ ST_FUNC Sym *sym_find2(Sym *s, int v)
}
/* structure lookup */
-ST_INLN Sym *struct_find(TCCState *S, int v)
+ST_INLN Sym *struct_find(TCCState* S, int v)
{
v -= TOK_IDENT;
- if ((unsigned)v >= (unsigned)(S->tok_ident - TOK_IDENT))
+ if ((unsigned)v >= (unsigned)(S->tccpp_tok_ident - TOK_IDENT))
return NULL;
return S->tccpp_table_ident[v]->sym_struct;
}
/* find an identifier */
-ST_INLN Sym *sym_find(TCCState *S, int v)
+ST_INLN Sym *sym_find(TCCState* S, int v)
{
v -= TOK_IDENT;
- if ((unsigned)v >= (unsigned)(S->tok_ident - TOK_IDENT))
+ if ((unsigned)v >= (unsigned)(S->tccpp_tok_ident - TOK_IDENT))
return NULL;
return S->tccpp_table_ident[v]->sym_identifier;
}
@@ -1175,13 +1175,13 @@ static int sym_scope(Sym *s)
}
/* push a given symbol on the symbol stack */
-ST_FUNC Sym *sym_push(TCCState *S, int v, CType *type, int r, int c)
+ST_FUNC Sym *sym_push(TCCState* S, int v, CType *type, int r, int c)
{
Sym *s, **ps;
TokenSym *ts;
- if (S->local_stack)
- ps = &S->local_stack;
+ if (S->tccgen_local_stack)
+ ps = &S->tccgen_local_stack;
else
ps = &S->tccgen_global_stack;
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)
ps = &ts->sym_identifier;
s->prev_tok = *ps;
*ps = s;
- s->sym_scope = S->local_scope;
+ s->sym_scope = S->tccgen_local_scope;
if (s->prev_tok && sym_scope(s->prev_tok) == s->sym_scope)
tcc_error(S, "redeclaration of '%s'",
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)
}
/* push a global identifier */
-ST_FUNC Sym *global_identifier_push(TCCState *S, int v, int t, int c)
+ST_FUNC Sym *global_identifier_push(TCCState* S, int v, int t, int c)
{
Sym *s, **ps;
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)
/* pop symbols until top reaches 'b'. If KEEP is non-zero don't really
pop them yet from the list, but do remove them from the token array. */
-ST_FUNC void sym_pop(TCCState *S, Sym **ptop, Sym *b, int keep)
+ST_FUNC void sym_pop(TCCState* S, Sym **ptop, Sym *b, int keep)
{
Sym *s, *ss, **ps;
TokenSym *ts;
@@ -1256,7 +1256,7 @@ ST_FUNC void sym_pop(TCCState *S, Sym **ptop, Sym *b, int keep)
}
/* ------------------------------------------------------------------------- */
-static void vcheck_cmp(TCCState *S)
+static void vcheck_cmp(TCCState* S)
{
/* cannot let cpu flags if other instruction are generated. Also
avoid leaving VT_JMP anywhere except on the top of the stack
@@ -1270,38 +1270,38 @@ static void vcheck_cmp(TCCState *S)
again, so that the VT_CMP/VT_JMP value will be in vtop
when code is unsuppressed again. */
- if (S->vtop->r == VT_CMP && !S->nocode_wanted)
+ if (S->tccgen_vtop->r == VT_CMP && !S->tccgen_nocode_wanted)
gv(S, RC_INT);
}
-static void vsetc(TCCState *S, CType *type, int r, CValue *vc)
+static void vsetc(TCCState* S, CType *type, int r, CValue *vc)
{
- if (S->vtop >= vstack + (VSTACK_SIZE - 1))
+ if (S->tccgen_vtop >= vstack + (VSTACK_SIZE - 1))
tcc_error(S, "memory full (vstack)");
vcheck_cmp(S);
- S->vtop++;
- S->vtop->type = *type;
- S->vtop->r = r;
- S->vtop->r2 = VT_CONST;
- S->vtop->c = *vc;
- S->vtop->sym = NULL;
+ S->tccgen_vtop++;
+ S->tccgen_vtop->type = *type;
+ S->tccgen_vtop->r = r;
+ S->tccgen_vtop->r2 = VT_CONST;
+ S->tccgen_vtop->c = *vc;
+ S->tccgen_vtop->sym = NULL;
}
-ST_FUNC void vswap(TCCState *S)
+ST_FUNC void vswap(TCCState* S)
{
SValue tmp;
vcheck_cmp(S);
- tmp = S->vtop[0];
- S->vtop[0] = S->vtop[-1];
- S->vtop[-1] = tmp;
+ tmp = S->tccgen_vtop[0];
+ S->tccgen_vtop[0] = S->tccgen_vtop[-1];
+ S->tccgen_vtop[-1] = tmp;
}
/* pop stack value */
-ST_FUNC void vpop(TCCState *S)
+ST_FUNC void vpop(TCCState* S)
{
int v;
- v = S->vtop->r & VT_VALMASK;
+ v = S->tccgen_vtop->r & VT_VALMASK;
#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
/* for x86, we need to pop the FP stack */
if (v == TREG_ST0) {
@@ -1310,20 +1310,20 @@ ST_FUNC void vpop(TCCState *S)
#endif
if (v == VT_CMP) {
/* need to put correct jump if && or || without test */
- gsym(S, S->vtop->jtrue);
- gsym(S, S->vtop->jfalse);
+ gsym(S, S->tccgen_vtop->jtrue);
+ gsym(S, S->tccgen_vtop->jfalse);
}
- S->vtop--;
+ S->tccgen_vtop--;
}
/* push constant of type "type" with useless value */
-static void vpush(TCCState *S, CType *type)
+static void vpush(TCCState* S, CType *type)
{
vset(S, type, VT_CONST, 0);
}
/* push arbitrary 64bit constant */
-static void vpush64(TCCState *S, int ty, unsigned long long v)
+static void vpush64(TCCState* S, int ty, unsigned long long v)
{
CValue cval;
CType ctype;
@@ -1334,31 +1334,31 @@ static void vpush64(TCCState *S, int ty, unsigned long long v)
}
/* push integer constant */
-ST_FUNC void vpushi(TCCState *S, int v)
+ST_FUNC void vpushi(TCCState* S, int v)
{
vpush64(S, VT_INT, v);
}
/* push a pointer sized constant */
-static void vpushs(TCCState *S, addr_t v)
+static void vpushs(TCCState* S, addr_t v)
{
vpush64(S, VT_SIZE_T, v);
}
/* push long long constant */
-static inline void vpushll(TCCState *S, long long v)
+static inline void vpushll(TCCState* S, long long v)
{
vpush64(S, VT_LLONG, v);
}
-ST_FUNC void vset(TCCState *S, CType *type, int r, int v)
+ST_FUNC void vset(TCCState* S, CType *type, int r, int v)
{
CValue cval;
cval.i = v;
vsetc(S, type, r, &cval);
}
-static void vseti(TCCState *S, int r, int v)
+static void vseti(TCCState* S, int r, int v)
{
CType type;
type.t = VT_INT;
@@ -1366,38 +1366,38 @@ static void vseti(TCCState *S, int r, int v)
vset(S, &type, r, v);
}
-ST_FUNC void vpushv(TCCState *S, SValue *v)
+ST_FUNC void vpushv(TCCState* S, SValue *v)
{
- if (S->vtop >= vstack + (VSTACK_SIZE - 1))
+ if (S->tccgen_vtop >= vstack + (VSTACK_SIZE - 1))
tcc_error(S, "memory full (vstack)");
- S->vtop++;
- *S->vtop = *v;
+ S->tccgen_vtop++;
+ *S->tccgen_vtop = *v;
}
-static void vdup(TCCState *S)
+static void vdup(TCCState* S)
{
- vpushv(S, S->vtop);
+ vpushv(S, S->tccgen_vtop);
}
/* rotate n first stack elements to the bottom
I1 ... In -> I2 ... In I1 [top is right]
*/
-ST_FUNC void vrotb(TCCState *S, int n)
+ST_FUNC void vrotb(TCCState* S, int n)
{
int i;
SValue tmp;
vcheck_cmp(S);
- tmp = S->vtop[-n + 1];
+ tmp = S->tccgen_vtop[-n + 1];
for(i=-n+1;i!=0;i++)
- S->vtop[i] = S->vtop[i+1];
- S->vtop[0] = tmp;
+ S->tccgen_vtop[i] = S->tccgen_vtop[i+1];
+ S->tccgen_vtop[0] = tmp;
}
/* rotate the n elements before entry e towards the top
I1 ... In ... -> In I1 ... I(n-1) ... [top is right]
*/
-ST_FUNC void vrote(TCCState *S, SValue *e, int n)
+ST_FUNC void vrote(TCCState* S, SValue *e, int n)
{
int i;
SValue tmp;
@@ -1412,68 +1412,68 @@ ST_FUNC void vrote(TCCState *S, SValue *e, int n)
/* rotate n first stack elements to the top
I1 ... In -> In I1 ... I(n-1) [top is right]
*/
-ST_FUNC void vrott(TCCState *S, int n)
+ST_FUNC void vrott(TCCState* S, int n)
{
- vrote(S, S->vtop, n);
+ vrote(S, S->tccgen_vtop, n);
}
/* ------------------------------------------------------------------------- */
/* vtop->r = VT_CMP means CPU-flags have been set from comparison or test. */
/* called from generators to set the result from relational ops */
-ST_FUNC void vset_VT_CMP(TCCState *S, int op)
+ST_FUNC void vset_VT_CMP(TCCState* S, int op)
{
- S->vtop->r = VT_CMP;
- S->vtop->cmp_op = op;
- S->vtop->jfalse = 0;
- S->vtop->jtrue = 0;
+ S->tccgen_vtop->r = VT_CMP;
+ S->tccgen_vtop->cmp_op = op;
+ S->tccgen_vtop->jfalse = 0;
+ S->tccgen_vtop->jtrue = 0;
}
/* called once before asking generators to load VT_CMP to a register */
-static void vset_VT_JMP(TCCState *S)
+static void vset_VT_JMP(TCCState* S)
{
- int op = S->vtop->cmp_op;
+ int op = S->tccgen_vtop->cmp_op;
- if (S->vtop->jtrue || S->vtop->jfalse) {
+ if (S->tccgen_vtop->jtrue || S->tccgen_vtop->jfalse) {
/* we need to jump to 'mov $0,%R' or 'mov $1,%R' */
int inv = op & (op < 2); /* small optimization */
vseti(S, VT_JMP+inv, gvtst(S, inv, 0));
} else {
/* otherwise convert flags (rsp. 0/1) to register */
- S->vtop->c.i = op;
+ S->tccgen_vtop->c.i = op;
if (op < 2) /* doesn't seem to happen */
- S->vtop->r = VT_CONST;
+ S->tccgen_vtop->r = VT_CONST;
}
}
/* Set CPU Flags, doesn't yet jump */
-static void gvtst_set(TCCState *S, int inv, int t)
+static void gvtst_set(TCCState* S, int inv, int t)
{
int *p;
- if (S->vtop->r != VT_CMP) {
+ if (S->tccgen_vtop->r != VT_CMP) {
vpushi(S, 0);
gen_op(S, TOK_NE);
- if (S->vtop->r != VT_CMP) /* must be VT_CONST then */
- vset_VT_CMP(S, S->vtop->c.i != 0);
+ if (S->tccgen_vtop->r != VT_CMP) /* must be VT_CONST then */
+ vset_VT_CMP(S, S->tccgen_vtop->c.i != 0);
}
- p = inv ? &S->vtop->jfalse : &S->vtop->jtrue;
+ p = inv ? &S->tccgen_vtop->jfalse : &S->tccgen_vtop->jtrue;
*p = gjmp_append(S, *p, t);
}
/* Generate value test
*
* Generate a test for any value (jump, comparison and integers) */
-static int gvtst(TCCState *S, int inv, int t)
+static int gvtst(TCCState* S, int inv, int t)
{
int op, x, u;
gvtst_set(S, inv, t);
- t = S->vtop->jtrue, u = S->vtop->jfalse;
+ t = S->tccgen_vtop->jtrue, u = S->tccgen_vtop->jfalse;
if (inv)
x = u, u = t, t = x;
- op = S->vtop->cmp_op;
+ op = S->tccgen_vtop->cmp_op;
/* jump to the wanted target */
if (op > 1)
@@ -1483,20 +1483,20 @@ static int gvtst(TCCState *S, int inv, int t)
/* resolve complementary jumps to here */
gsym(S, u);
- S->vtop--;
+ S->tccgen_vtop--;
return t;
}
/* generate a zero or nozero test */
-static void gen_test_zero(TCCState *S, int op)
+static void gen_test_zero(TCCState* S, int op)
{
- if (S->vtop->r == VT_CMP) {
+ if (S->tccgen_vtop->r == VT_CMP) {
int j;
if (op == TOK_EQ) {
- j = S->vtop->jfalse;
- S->vtop->jfalse = S->vtop->jtrue;
- S->vtop->jtrue = j;
- S->vtop->cmp_op ^= 1;
+ j = S->tccgen_vtop->jfalse;
+ S->tccgen_vtop->jfalse = S->tccgen_vtop->jtrue;
+ S->tccgen_vtop->jtrue = j;
+ S->tccgen_vtop->cmp_op ^= 1;
}
} else {
vpushi(S, 0);
@@ -1506,16 +1506,16 @@ static void gen_test_zero(TCCState *S, int op)
/* ------------------------------------------------------------------------- */
/* push a symbol value of TYPE */
-ST_FUNC void vpushsym(TCCState *S, CType *type, Sym *sym)
+ST_FUNC void vpushsym(TCCState* S, CType *type, Sym *sym)
{
CValue cval;
cval.i = 0;
vsetc(S, type, VT_CONST | VT_SYM, &cval);
- S->vtop->sym = sym;
+ S->tccgen_vtop->sym = sym;
}
/* Return a static symbol pointing to a section */
-ST_FUNC Sym *get_sym_ref(TCCState *S, CType *type, Section *sec, unsigned long offset, unsigned long size)
+ST_FUNC Sym *get_sym_ref(TCCState* S, CType *type, Section *sec, unsigned long offset, unsigned long size)
{
int v;
Sym *sym;
@@ -1528,13 +1528,13 @@ ST_FUNC Sym *get_sym_ref(TCCState *S, CType *type, Section *sec, unsigned long o
}
/* push a reference to a section offset by adding a dummy symbol */
-static void vpush_ref(TCCState *S, CType *type, Section *sec, unsigned long offset, unsigned long size)
+static void vpush_ref(TCCState* S, CType *type, Section *sec, unsigned long offset, unsigned long size)
{
vpushsym(S, type, get_sym_ref(S, type, sec, offset, size));
}
/* define a new external reference to a symbol 'v' of type 'u' */
-ST_FUNC Sym *external_global_sym(TCCState *S, int v, CType *type)
+ST_FUNC Sym *external_global_sym(TCCState* S, int v, CType *type)
{
Sym *s;
@@ -1553,14 +1553,14 @@ ST_FUNC Sym *external_global_sym(TCCState *S, int v, CType *type)
/* create an external reference with no specific type similar to asm labels.
This avoids type conflicts if the symbol is used from C too */
-ST_FUNC Sym *external_helper_sym(TCCState *S, int v)
+ST_FUNC Sym *external_helper_sym(TCCState* S, int v)
{
CType ct = { VT_ASM_FUNC, NULL };
return external_global_sym(S, v, &ct);
}
/* push a reference to an helper function (such as memmove) */
-ST_FUNC void vpush_helper_func(TCCState *S, int v)
+ST_FUNC void vpush_helper_func(TCCState* S, int v)
{
vpushsym(S, &S->tccgen_func_old_type, external_helper_sym(S, v));
}
@@ -1618,7 +1618,7 @@ static void merge_attr(AttributeDef *ad, AttributeDef *ad1)
}
/* Merge some type attributes. */
-static void patch_type(TCCState *S, Sym *sym, CType *type)
+static void patch_type(TCCState* S, Sym *sym, CType *type)
{
if (!(type->t & VT_EXTERN) || IS_ENUM_VAL(sym->type.t)) {
if (!(sym->type.t & VT_EXTERN))
@@ -1681,7 +1681,7 @@ static void patch_type(TCCState *S, Sym *sym, CType *type)
}
/* Merge some storage attributes. */
-static void patch_storage(TCCState *S, Sym *sym, AttributeDef *ad, CType *type)
+static void patch_storage(TCCState* S, Sym *sym, AttributeDef *ad, CType *type)
{
if (type)
patch_type(S, sym, type);
@@ -1698,7 +1698,7 @@ static void patch_storage(TCCState *S, Sym *sym, AttributeDef *ad, CType *type)
}
/* copy sym to other stack */
-static Sym *sym_copy(TCCState *S, Sym *s0, Sym **ps)
+static Sym *sym_copy(TCCState* S, Sym *s0, Sym **ps)
{
Sym *s;
s = sym_malloc(S), *s = *s0;
@@ -1711,7 +1711,7 @@ static Sym *sym_copy(TCCState *S, Sym *s0, Sym **ps)
}
/* copy s->type.ref to stack 'ps' for VT_FUNC and VT_PTR */
-static void sym_copy_ref(TCCState *S, Sym *s, Sym **ps)
+static void sym_copy_ref(TCCState* S, Sym *s, Sym **ps)
{
int bt = s->type.t & VT_BTYPE;
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)
}
/* define a new external reference to a symbol 'v' */
-static Sym *external_sym(TCCState *S, int v, CType *type, int r, AttributeDef *ad)
+static Sym *external_sym(TCCState* S, int v, CType *type, int r, AttributeDef *ad)
{
Sym *s;
@@ -1742,44 +1742,44 @@ static Sym *external_sym(TCCState *S, int v, CType *type, int r, AttributeDef *a
s->asm_label = ad->asm_label;
s->type.ref = type->ref;
/* copy type to the global stack */
- if (S->local_stack)
+ if (S->tccgen_local_stack)
sym_copy_ref(S, s, &S->tccgen_global_stack);
} else {
patch_storage(S, s, ad, type);
}
/* push variables on local_stack if any */
- if (S->local_stack && (s->type.t & VT_BTYPE) != VT_FUNC)
- s = sym_copy(S, s, &S->local_stack);
+ if (S->tccgen_local_stack && (s->type.t & VT_BTYPE) != VT_FUNC)
+ s = sym_copy(S, s, &S->tccgen_local_stack);
return s;
}
/* save registers up to (vtop - n) stack entry */
-ST_FUNC void save_regs(TCCState *S, int n)
+ST_FUNC void save_regs(TCCState* S, int n)
{
SValue *p, *p1;
- for(p = vstack, p1 = S->vtop - n; p <= p1; p++)
+ for(p = vstack, p1 = S->tccgen_vtop - n; p <= p1; p++)
save_reg(S, p->r);
}
/* save r to the memory stack, and mark it as being free */
-ST_FUNC void save_reg(TCCState *S, int r)
+ST_FUNC void save_reg(TCCState* S, int r)
{
save_reg_upstack(S, r, 0);
}
/* save r to the memory stack, and mark it as being free,
if seen up to (vtop - n) stack entry */
-ST_FUNC void save_reg_upstack(TCCState *S, int r, int n)
+ST_FUNC void save_reg_upstack(TCCState* S, int r, int n)
{
int l, size, align, bt;
SValue *p, *p1, sv;
if ((r &= VT_VALMASK) >= VT_CONST)
return;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
l = 0;
- for(p = vstack, p1 = S->vtop - n; p <= p1; p++) {
+ for(p = vstack, p1 = S->tccgen_vtop - n; p <= p1; p++) {
if ((p->r & VT_VALMASK) == r || p->r2 == r) {
/* must save value on stack if not already done */
if (!l) {
@@ -1825,7 +1825,7 @@ ST_FUNC void save_reg_upstack(TCCState *S, int r, int n)
#ifdef TCC_TARGET_ARM
/* find a register of class 'rc2' with at most one reference on stack.
* If none, call get_reg(rc) */
-ST_FUNC int get_reg_ex(TCCState *S, int rc, int rc2)
+ST_FUNC int get_reg_ex(TCCState* S, int rc, int rc2)
{
int r;
SValue *p;
@@ -1834,7 +1834,7 @@ ST_FUNC int get_reg_ex(TCCState *S, int rc, int rc2)
if (reg_classes[r] & rc2) {
int n;
n=0;
- for(p = vstack; p <= S->vtop; p++) {
+ for(p = vstack; p <= S->tccgen_vtop; p++) {
if ((p->r & VT_VALMASK) == r ||
p->r2 == r)
n++;
@@ -1848,7 +1848,7 @@ ST_FUNC int get_reg_ex(TCCState *S, int rc, int rc2)
#endif
/* find a free register of class 'rc'. If none, save one register */
-ST_FUNC int get_reg(TCCState *S, int rc)
+ST_FUNC int get_reg(TCCState* S, int rc)
{
int r;
SValue *p;
@@ -1856,9 +1856,9 @@ ST_FUNC int get_reg(TCCState *S, int rc)
/* find a free register */
for(r=0;r<NB_REGS;r++) {
if (reg_classes[r] & rc) {
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return r;
- for(p=vstack;p<=S->vtop;p++) {
+ for(p=vstack;p<=S->tccgen_vtop;p++) {
if ((p->r & VT_VALMASK) == r ||
p->r2 == r)
goto notfound;
@@ -1871,7 +1871,7 @@ ST_FUNC int get_reg(TCCState *S, int rc)
/* no register left : free the first one on the stack (VERY
IMPORTANT to start from the bottom to ensure that we don't
spill registers used in gen_opi()) */
- for(p=vstack;p<=S->vtop;p++) {
+ for(p=vstack;p<=S->tccgen_vtop;p++) {
/* look at second register (if long long) */
r = p->r2;
if (r < VT_CONST && (reg_classes[r] & rc))
@@ -1888,7 +1888,7 @@ ST_FUNC int get_reg(TCCState *S, int rc)
}
/* find a free temporary local variable (return the offset on stack) match the size and align. If none, add new temporary stack variable*/
-static int get_temp_local_var(TCCState *S, int size,int align){
+static int get_temp_local_var(TCCState* S, int size,int align){
int i;
temp_local_variable_t *temp_var;
int found_var;
@@ -1904,7 +1904,7 @@ static int get_temp_local_var(TCCState *S, int size,int align){
}
/*check if temp_var is free*/
free=1;
- for(p=vstack;p<=S->vtop;p++) {
+ for(p=vstack;p<=S->tccgen_vtop;p++) {
r=p->r&VT_VALMASK;
if(r==VT_LOCAL||r==VT_LLOCAL){
if(p->c.i==temp_var->location){
@@ -1920,26 +1920,26 @@ static int get_temp_local_var(TCCState *S, int size,int align){
}
}
if(!found){
- S->loc = (S->loc - size) & -align;
+ S->tccgen_loc = (S->tccgen_loc - size) & -align;
if(S->tccgen_nb_temp_local_vars<MAX_TEMP_LOCAL_VARIABLE_NUMBER){
temp_var=&S->tccgen_arr_temp_local_vars[i];
- temp_var->location=S->loc;
+ temp_var->location=S->tccgen_loc;
temp_var->size=size;
temp_var->align=align;
S->tccgen_nb_temp_local_vars++;
}
- found_var=S->loc;
+ found_var=S->tccgen_loc;
}
return found_var;
}
-static void clear_temp_local_var_list(TCCState *S){
+static void clear_temp_local_var_list(TCCState* S){
S->tccgen_nb_temp_local_vars=0;
}
/* move register 's' (of type 't') to 'r', and flush previous value of r to memory
if needed */
-static void move_reg(TCCState *S, int r, int s, int t)
+static void move_reg(TCCState* S, int r, int s, int t)
{
SValue sv;
@@ -1954,49 +1954,49 @@ static void move_reg(TCCState *S, int r, int s, int t)
}
/* get address of vtop (vtop MUST BE an lvalue) */
-ST_FUNC void gaddrof(TCCState *S)
+ST_FUNC void gaddrof(TCCState* S)
{
- S->vtop->r &= ~VT_LVAL;
+ S->tccgen_vtop->r &= ~VT_LVAL;
/* tricky: if saved lvalue, then we can go back to lvalue */
- if ((S->vtop->r & VT_VALMASK) == VT_LLOCAL)
- S->vtop->r = (S->vtop->r & ~VT_VALMASK) | VT_LOCAL | VT_LVAL;
+ if ((S->tccgen_vtop->r & VT_VALMASK) == VT_LLOCAL)
+ S->tccgen_vtop->r = (S->tccgen_vtop->r & ~VT_VALMASK) | VT_LOCAL | VT_LVAL;
}
#ifdef CONFIG_TCC_BCHECK
/* generate a bounded pointer addition */
-static void gen_bounded_ptr_add(TCCState *S)
+static void gen_bounded_ptr_add(TCCState* S)
{
- int save = (S->vtop[-1].r & VT_VALMASK) == VT_LOCAL;
+ int save = (S->tccgen_vtop[-1].r & VT_VALMASK) == VT_LOCAL;
if (save) {
- vpushv(S, &S->vtop[-1]);
+ vpushv(S, &S->tccgen_vtop[-1]);
vrott(S, 3);
}
vpush_helper_func(S, TOK___bound_ptr_add);
vrott(S, 3);
gfunc_call(S, 2);
- S->vtop -= save;
+ S->tccgen_vtop -= save;
vpushi(S, 0);
/* returned pointer is in REG_IRET */
- S->vtop->r = REG_IRET | VT_BOUNDED;
- if (S->nocode_wanted)
+ S->tccgen_vtop->r = REG_IRET | VT_BOUNDED;
+ if (S->tccgen_nocode_wanted)
return;
/* relocation offset of the bounding function call point */
- S->vtop->c.i = (cur_text_section->reloc->data_offset - sizeof(ElfW_Rel));
+ S->tccgen_vtop->c.i = (cur_text_section->reloc->data_offset - sizeof(ElfW_Rel));
}
/* patch pointer addition in vtop so that pointer dereferencing is
also tested */
-static void gen_bounded_ptr_deref(TCCState *S)
+static void gen_bounded_ptr_deref(TCCState* S)
{
addr_t func;
int size, align;
ElfW_Rel *rel;
Sym *sym;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
- size = type_size(&S->vtop->type, &align);
+ size = type_size(&S->tccgen_vtop->type, &align);
switch(size) {
case 1: func = TOK___bound_ptr_indir1; break;
case 2: func = TOK___bound_ptr_indir2; break;
@@ -2013,28 +2013,28 @@ static void gen_bounded_ptr_deref(TCCState *S)
put_extern_sym(S, sym, NULL, 0, 0);
/* patch relocation */
/* XXX: find a better solution ? */
- rel = (ElfW_Rel *)(cur_text_section->reloc->data + S->vtop->c.i);
+ rel = (ElfW_Rel *)(cur_text_section->reloc->data + S->tccgen_vtop->c.i);
rel->r_info = ELFW(R_INFO)(sym->c, ELFW(R_TYPE)(rel->r_info));
}
/* generate lvalue bound code */
-static void gbound(TCCState *S)
+static void gbound(TCCState* S)
{
CType type1;
- S->vtop->r &= ~VT_MUSTBOUND;
+ S->tccgen_vtop->r &= ~VT_MUSTBOUND;
/* if lvalue, then use checking code before dereferencing */
- if (S->vtop->r & VT_LVAL) {
+ if (S->tccgen_vtop->r & VT_LVAL) {
/* if not VT_BOUNDED value, then make one */
- if (!(S->vtop->r & VT_BOUNDED)) {
+ if (!(S->tccgen_vtop->r & VT_BOUNDED)) {
/* must save type because we must set it to int to get pointer */
- type1 = S->vtop->type;
- S->vtop->type.t = VT_PTR;
+ type1 = S->tccgen_vtop->type;
+ S->tccgen_vtop->type.t = VT_PTR;
gaddrof(S);
vpushi(S, 0);
gen_bounded_ptr_add(S);
- S->vtop->r |= VT_LVAL;
- S->vtop->type = type1;
+ S->tccgen_vtop->r |= VT_LVAL;
+ S->tccgen_vtop->type = type1;
}
/* then check for dereferencing */
gen_bounded_ptr_deref(S);
@@ -2043,19 +2043,19 @@ static void gbound(TCCState *S)
/* we need to call __bound_ptr_add before we start to load function
args into registers */
-ST_FUNC void gbound_args(TCCState *S, int nb_args)
+ST_FUNC void gbound_args(TCCState* S, int nb_args)
{
int i, v;
SValue *sv;
for (i = 1; i <= nb_args; ++i)
- if (S->vtop[1 - i].r & VT_MUSTBOUND) {
+ if (S->tccgen_vtop[1 - i].r & VT_MUSTBOUND) {
vrotb(S, i);
gbound(S);
vrott(S, i);
}
- sv = S->vtop - nb_args;
+ sv = S->tccgen_vtop - nb_args;
if (sv->r & VT_SYM) {
v = sv->sym->v;
if (v == TOK_setjmp
@@ -2082,7 +2082,7 @@ ST_FUNC void gbound_args(TCCState *S, int nb_args)
}
/* Add bounds for local symbols from S to E (via ->prev) */
-static void add_local_bounds(TCCState *S, Sym *s, Sym *e)
+static void add_local_bounds(TCCState* S, Sym *s, Sym *e)
{
for (; s != e; s = s->prev) {
if (!s->v || (s->r & VT_VALMASK) != VT_LOCAL)
@@ -2103,32 +2103,32 @@ static void add_local_bounds(TCCState *S, Sym *s, Sym *e)
#endif
/* Wrapper around sym_pop, that potentially also registers local bounds. */
-static void pop_local_syms(TCCState *S, Sym *b, int keep)
+static void pop_local_syms(TCCState* S, Sym *b, int keep)
{
#ifdef CONFIG_TCC_BCHECK
- if (S->do_bounds_check && !keep && (S->local_scope || !S->tccgen_func_var))
- add_local_bounds(S, S->local_stack, b);
+ if (S->do_bounds_check && !keep && (S->tccgen_local_scope || !S->tccgen_func_var))
+ add_local_bounds(S, S->tccgen_local_stack, b);
#endif
if (S->tccgen_debug_modes)
- tcc_add_debug_info (S, !S->local_scope, S->local_stack, b);
- sym_pop(S, &S->local_stack, b, keep);
+ tcc_add_debug_info (S, !S->tccgen_local_scope, S->tccgen_local_stack, b);
+ sym_pop(S, &S->tccgen_local_stack, b, keep);
}
-static void incr_bf_adr(TCCState *S, int o)
+static void incr_bf_adr(TCCState* S, int o)
{
- S->vtop->type = S->char_pointer_type;
+ S->tccgen_vtop->type = S->tccgen_char_pointer_type;
gaddrof(S);
vpushs(S, o);
gen_op(S, '+');
- S->vtop->type.t = VT_BYTE | VT_UNSIGNED;
- S->vtop->r |= VT_LVAL;
+ S->tccgen_vtop->type.t = VT_BYTE | VT_UNSIGNED;
+ S->tccgen_vtop->r |= VT_LVAL;
}
/* single-byte load mode for packed or otherwise unaligned bitfields */
-static void load_packed_bf(TCCState *S, CType *type, int bit_pos, int bit_size)
+static void load_packed_bf(TCCState* S, CType *type, int bit_pos, int bit_size)
{
int n, o, bits;
- save_reg_upstack(S, S->vtop->r, 1);
+ save_reg_upstack(S, S->tccgen_vtop->r, 1);
vpush64(S, type->t & VT_BTYPE, 0); // B X
bits = 0, o = bit_pos >> 3, bit_pos &= 7;
do {
@@ -2158,12 +2158,12 @@ static void load_packed_bf(TCCState *S, CType *type, int bit_pos, int bit_size)
}
/* single-byte store mode for packed or otherwise unaligned bitfields */
-static void store_packed_bf(TCCState *S, int bit_pos, int bit_size)
+static void store_packed_bf(TCCState* S, int bit_pos, int bit_size)
{
int bits, n, o, m, c;
- c = (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+ c = (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
vswap(S); // X B
- save_reg_upstack(S, S->vtop->r, 1);
+ save_reg_upstack(S, S->tccgen_vtop->r, 1);
bits = 0, o = bit_pos >> 3, bit_pos &= 7;
do {
incr_bf_adr(S, o); // X B
@@ -2180,12 +2180,12 @@ static void store_packed_bf(TCCState *S, int bit_pos, int bit_size)
if (n < 8) {
m = ((1 << n) - 1) << bit_pos;
vpushi(S, m), gen_op(S, '&'); // X B V1
- vpushv(S, S->vtop-1); // X B V1 B
+ vpushv(S, S->tccgen_vtop-1); // X B V1 B
vpushi(S, m & 0x80 ? ~m & 0x7f : ~m);
gen_op(S, '&'); // X B V1 B1
gen_op(S, '|'); // X B V2
}
- vdup(S), S->vtop[-1] = S->vtop[-2]; // X B B V2
+ vdup(S), S->tccgen_vtop[-1] = S->tccgen_vtop[-2]; // X B B V2
vstore(S), vpop(S); // X B
bits += n, bit_size -= n, bit_pos = 0, o = 1;
} while (bit_size);
@@ -2208,28 +2208,28 @@ static int adjust_bf(SValue *sv, int bit_pos, int bit_size)
/* store vtop a register belonging to class 'rc'. lvalues are
converted to values. Cannot be used if cannot be converted to
register value (such as structures). */
-ST_FUNC int gv(TCCState *S, int rc)
+ST_FUNC int gv(TCCState* S, int rc)
{
int r, r2, r_ok, r2_ok, rc2, bt;
int bit_pos, bit_size, size, align;
/* NOTE: get_reg can modify vstack[] */
- if (S->vtop->type.t & VT_BITFIELD) {
+ if (S->tccgen_vtop->type.t & VT_BITFIELD) {
CType type;
- bit_pos = BIT_POS(S->vtop->type.t);
- bit_size = BIT_SIZE(S->vtop->type.t);
+ bit_pos = BIT_POS(S->tccgen_vtop->type.t);
+ bit_size = BIT_SIZE(S->tccgen_vtop->type.t);
/* remove bit field info to avoid loops */
- S->vtop->type.t &= ~VT_STRUCT_MASK;
+ S->tccgen_vtop->type.t &= ~VT_STRUCT_MASK;
type.ref = NULL;
- type.t = S->vtop->type.t & VT_UNSIGNED;
- if ((S->vtop->type.t & VT_BTYPE) == VT_BOOL)
+ type.t = S->tccgen_vtop->type.t & VT_UNSIGNED;
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_BOOL)
type.t |= VT_UNSIGNED;
- r = adjust_bf(S->vtop, bit_pos, bit_size);
+ r = adjust_bf(S->tccgen_vtop, bit_pos, bit_size);
- if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG)
type.t |= VT_LLONG;
else
type.t |= VT_INT;
@@ -2249,27 +2249,27 @@ ST_FUNC int gv(TCCState *S, int rc)
}
r = gv(S, rc);
} else {
- if (is_float(S->vtop->type.t) &&
- (S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+ if (is_float(S->tccgen_vtop->type.t) &&
+ (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
/* CPUs usually cannot use float constants, so we store them
generically in data segment */
init_params p = { rodata_section };
unsigned long offset;
- size = type_size(&S->vtop->type, &align);
+ size = type_size(&S->tccgen_vtop->type, &align);
if (NODATA_WANTED)
size = 0, align = 1;
offset = section_add(S, p.sec, size, align);
- vpush_ref(S, &S->vtop->type, p.sec, offset, size);
+ vpush_ref(S, &S->tccgen_vtop->type, p.sec, offset, size);
vswap(S);
- init_putv(S, &p, &S->vtop->type, offset);
- S->vtop->r |= VT_LVAL;
+ init_putv(S, &p, &S->tccgen_vtop->type, offset);
+ S->tccgen_vtop->r |= VT_LVAL;
}
#ifdef CONFIG_TCC_BCHECK
- if (S->vtop->r & VT_MUSTBOUND)
+ if (S->tccgen_vtop->r & VT_MUSTBOUND)
gbound(S);
#endif
- bt = S->vtop->type.t & VT_BTYPE;
+ bt = S->tccgen_vtop->type.t & VT_BTYPE;
#ifdef TCC_TARGET_RISCV64
/* XXX mega hack */
@@ -2282,91 +2282,91 @@ ST_FUNC int gv(TCCState *S, int rc)
- constant
- lvalue (need to dereference pointer)
- already a register, but not in the right class */
- r = S->vtop->r & VT_VALMASK;
- r_ok = !(S->vtop->r & VT_LVAL) && (r < VT_CONST) && (reg_classes[r] & rc);
- r2_ok = !rc2 || ((S->vtop->r2 < VT_CONST) && (reg_classes[S->vtop->r2] & rc2));
+ r = S->tccgen_vtop->r & VT_VALMASK;
+ r_ok = !(S->tccgen_vtop->r & VT_LVAL) && (r < VT_CONST) && (reg_classes[r] & rc);
+ r2_ok = !rc2 || ((S->tccgen_vtop->r2 < VT_CONST) && (reg_classes[S->tccgen_vtop->r2] & rc2));
if (!r_ok || !r2_ok) {
if (!r_ok)
r = get_reg(S, rc);
if (rc2) {
int load_type = (bt == VT_QFLOAT) ? VT_DOUBLE : VT_PTRDIFF_T;
- int original_type = S->vtop->type.t;
+ int original_type = S->tccgen_vtop->type.t;
/* two register type load :
expand to two words temporarily */
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
/* load constant */
- unsigned long long ll = S->vtop->c.i;
- S->vtop->c.i = ll; /* first word */
- load(S, r, S->vtop);
- S->vtop->r = r; /* save register value */
+ unsigned long long ll = S->tccgen_vtop->c.i;
+ S->tccgen_vtop->c.i = ll; /* first word */
+ load(S, r, S->tccgen_vtop);
+ S->tccgen_vtop->r = r; /* save register value */
vpushi(S, ll >> 32); /* second word */
- } else if (S->vtop->r & VT_LVAL) {
+ } else if (S->tccgen_vtop->r & VT_LVAL) {
/* We do not want to modifier the long long pointer here.
So we save any other instances down the stack */
- save_reg_upstack(S, S->vtop->r, 1);
+ save_reg_upstack(S, S->tccgen_vtop->r, 1);
/* load from memory */
- S->vtop->type.t = load_type;
- load(S, r, S->vtop);
+ S->tccgen_vtop->type.t = load_type;
+ load(S, r, S->tccgen_vtop);
vdup(S);
- S->vtop[-1].r = r; /* save register value */
+ S->tccgen_vtop[-1].r = r; /* save register value */
/* increment pointer to get second word */
- S->vtop->type.t = VT_PTRDIFF_T;
+ S->tccgen_vtop->type.t = VT_PTRDIFF_T;
gaddrof(S);
vpushs(S, PTR_SIZE);
gen_op(S, '+');
- S->vtop->r |= VT_LVAL;
- S->vtop->type.t = load_type;
+ S->tccgen_vtop->r |= VT_LVAL;
+ S->tccgen_vtop->type.t = load_type;
} else {
/* move registers */
if (!r_ok)
- load(S, r, S->vtop);
- if (r2_ok && S->vtop->r2 < VT_CONST)
+ load(S, r, S->tccgen_vtop);
+ if (r2_ok && S->tccgen_vtop->r2 < VT_CONST)
goto done;
vdup(S);
- S->vtop[-1].r = r; /* save register value */
- S->vtop->r = S->vtop[-1].r2;
+ S->tccgen_vtop[-1].r = r; /* save register value */
+ S->tccgen_vtop->r = S->tccgen_vtop[-1].r2;
}
/* Allocate second register. Here we rely on the fact that
get_reg() tries first to free r2 of an SValue. */
r2 = get_reg(S, rc2);
- load(S, r2, S->vtop);
+ load(S, r2, S->tccgen_vtop);
vpop(S);
/* write second register */
- S->vtop->r2 = r2;
+ S->tccgen_vtop->r2 = r2;
done:
- S->vtop->type.t = original_type;
+ S->tccgen_vtop->type.t = original_type;
} else {
- if (S->vtop->r == VT_CMP)
+ if (S->tccgen_vtop->r == VT_CMP)
vset_VT_JMP(S);
/* one register type load */
- load(S, r, S->vtop);
+ load(S, r, S->tccgen_vtop);
}
}
- S->vtop->r = r;
+ S->tccgen_vtop->r = r;
#ifdef TCC_TARGET_C67
/* uses register pairs for doubles */
if (bt == VT_DOUBLE)
- S->vtop->r2 = r+1;
+ S->tccgen_vtop->r2 = r+1;
#endif
}
return r;
}
/* generate vtop[-1] and vtop[0] in resp. classes rc1 and rc2 */
-ST_FUNC void gv2(TCCState *S, int rc1, int rc2)
+ST_FUNC void gv2(TCCState* S, int rc1, int rc2)
{
/* generate more generic register first. But VT_JMP or VT_CMP
values must be generated first in all cases to avoid possible
reload errors */
- if (S->vtop->r != VT_CMP && rc1 <= rc2) {
+ if (S->tccgen_vtop->r != VT_CMP && rc1 <= rc2) {
vswap(S);
gv(S, rc1);
vswap(S);
gv(S, rc2);
/* test if reload is needed for first register */
- if ((S->vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) >= VT_CONST) {
vswap(S);
gv(S, rc1);
vswap(S);
@@ -2377,7 +2377,7 @@ ST_FUNC void gv2(TCCState *S, int rc1, int rc2)
gv(S, rc1);
vswap(S);
/* test if reload is needed for first register */
- if ((S->vtop[0].r & VT_VALMASK) >= VT_CONST) {
+ if ((S->tccgen_vtop[0].r & VT_VALMASK) >= VT_CONST) {
gv(S, rc2);
}
}
@@ -2385,50 +2385,50 @@ ST_FUNC void gv2(TCCState *S, int rc1, int rc2)
#if PTR_SIZE == 4
/* expand 64bit on stack in two ints */
-ST_FUNC void lexpand(TCCState *S)
+ST_FUNC void lexpand(TCCState* S)
{
int u, v;
- u = S->vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED);
- v = S->vtop->r & (VT_VALMASK | VT_LVAL);
+ u = S->tccgen_vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED);
+ v = S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL);
if (v == VT_CONST) {
vdup(S);
- S->vtop[0].c.i >>= 32;
+ S->tccgen_vtop[0].c.i >>= 32;
} else if (v == (VT_LVAL|VT_CONST) || v == (VT_LVAL|VT_LOCAL)) {
vdup(S);
- S->vtop[0].c.i += 4;
+ S->tccgen_vtop[0].c.i += 4;
} else {
gv(S, RC_INT);
vdup(S);
- S->vtop[0].r = S->vtop[-1].r2;
- S->vtop[0].r2 = S->vtop[-1].r2 = VT_CONST;
+ S->tccgen_vtop[0].r = S->tccgen_vtop[-1].r2;
+ S->tccgen_vtop[0].r2 = S->tccgen_vtop[-1].r2 = VT_CONST;
}
- S->vtop[0].type.t = S->vtop[-1].type.t = VT_INT | u;
+ S->tccgen_vtop[0].type.t = S->tccgen_vtop[-1].type.t = VT_INT | u;
}
#endif
#if PTR_SIZE == 4
/* build a long long from two ints */
-static void lbuild(TCCState *S, int t)
+static void lbuild(TCCState* S, int t)
{
gv2(S, RC_INT, RC_INT);
- S->vtop[-1].r2 = S->vtop[0].r;
- S->vtop[-1].type.t = t;
+ S->tccgen_vtop[-1].r2 = S->tccgen_vtop[0].r;
+ S->tccgen_vtop[-1].type.t = t;
vpop(S);
}
#endif
/* convert stack entry to register and duplicate its value in another
register */
-static void gv_dup(TCCState *S)
+static void gv_dup(TCCState* S)
{
int t, rc, r;
- t = S->vtop->type.t;
+ t = S->tccgen_vtop->type.t;
#if PTR_SIZE == 4
if ((t & VT_BTYPE) == VT_LLONG) {
if (t & VT_BITFIELD) {
gv(S, RC_INT);
- t = S->vtop->type.t;
+ t = S->tccgen_vtop->type.t;
}
lexpand(S);
gv_dup(S);
@@ -2451,13 +2451,13 @@ static void gv_dup(TCCState *S)
gv(S, rc);
r = get_reg(S, rc);
vdup(S);
- load(S, r, S->vtop);
- S->vtop->r = r;
+ load(S, r, S->tccgen_vtop);
+ S->tccgen_vtop->r = r;
}
#if PTR_SIZE == 4
/* generate CPU independent (unsigned) long long operations */
-static void gen_opl(TCCState *S, int op)
+static void gen_opl(TCCState* S, int op)
{
int t, a, b, op1, c, i;
int func;
@@ -2489,8 +2489,8 @@ static void gen_opl(TCCState *S, int op)
vrott(S, 3);
gfunc_call(S, 2);
vpushi(S, 0);
- S->vtop->r = reg_iret;
- S->vtop->r2 = reg_lret;
+ S->tccgen_vtop->r = reg_iret;
+ S->tccgen_vtop->r2 = reg_lret;
break;
case '^':
case '&':
@@ -2499,33 +2499,33 @@ static void gen_opl(TCCState *S, int op)
case '+':
case '-':
//pv("gen_opl A",0,2);
- t = S->vtop->type.t;
+ t = S->tccgen_vtop->type.t;
vswap(S);
lexpand(S);
vrotb(S, 3);
lexpand(S);
/* stack: L1 H1 L2 H2 */
- tmp = S->vtop[0];
- S->vtop[0] = S->vtop[-3];
- S->vtop[-3] = tmp;
- tmp = S->vtop[-2];
- S->vtop[-2] = S->vtop[-3];
- S->vtop[-3] = tmp;
+ tmp = S->tccgen_vtop[0];
+ S->tccgen_vtop[0] = S->tccgen_vtop[-3];
+ S->tccgen_vtop[-3] = tmp;
+ tmp = S->tccgen_vtop[-2];
+ S->tccgen_vtop[-2] = S->tccgen_vtop[-3];
+ S->tccgen_vtop[-3] = tmp;
vswap(S);
/* stack: H1 H2 L1 L2 */
//pv("gen_opl B",0,4);
if (op == '*') {
- vpushv(S, S->vtop - 1);
- vpushv(S, S->vtop - 1);
+ vpushv(S, S->tccgen_vtop - 1);
+ vpushv(S, S->tccgen_vtop - 1);
gen_op(S, TOK_UMULL);
lexpand(S);
/* stack: H1 H2 L1 L2 ML MH */
for(i=0;i<4;i++)
vrotb(S, 6);
/* stack: ML MH H1 H2 L1 L2 */
- tmp = S->vtop[0];
- S->vtop[0] = S->vtop[-2];
- S->vtop[-2] = tmp;
+ tmp = S->tccgen_vtop[0];
+ S->tccgen_vtop[0] = S->tccgen_vtop[-2];
+ S->tccgen_vtop[-2] = tmp;
/* stack: ML MH H1 L2 H2 L1 */
gen_op(S, '*');
vrotb(S, 3);
@@ -2560,13 +2560,13 @@ static void gen_opl(TCCState *S, int op)
case TOK_SAR:
case TOK_SHR:
case TOK_SHL:
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
- t = S->vtop[-1].type.t;
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ t = S->tccgen_vtop[-1].type.t;
vswap(S);
lexpand(S);
vrotb(S, 3);
/* stack: L H shift */
- c = (int)S->vtop->c.i;
+ c = (int)S->tccgen_vtop->c.i;
/* constant: simpler */
/* NOTE: all comments are for SHL. the other cases are
done by swapping words */
@@ -2629,15 +2629,15 @@ static void gen_opl(TCCState *S, int op)
break;
default:
/* compare operations */
- t = S->vtop->type.t;
+ t = S->tccgen_vtop->type.t;
vswap(S);
lexpand(S);
vrotb(S, 3);
lexpand(S);
/* stack: L1 H1 L2 H2 */
- tmp = S->vtop[-1];
- S->vtop[-1] = S->vtop[-2];
- S->vtop[-2] = tmp;
+ tmp = S->tccgen_vtop[-1];
+ S->tccgen_vtop[-1] = S->tccgen_vtop[-2];
+ S->tccgen_vtop[-2] = tmp;
/* stack: L1 L2 H1 H2 */
save_regs(S, 4);
/* compare high */
@@ -2701,10 +2701,10 @@ static int gen_opic_lt(uint64_t a, uint64_t b)
/* handle integer constant optimizations and various machine
independent opt */
-static void gen_opic(TCCState *S, int op)
+static void gen_opic(TCCState* S, int op)
{
- SValue *v1 = S->vtop - 1;
- SValue *v2 = S->vtop;
+ SValue *v1 = S->tccgen_vtop - 1;
+ SValue *v2 = S->tccgen_vtop;
int t1 = v1->type.t & VT_BTYPE;
int t2 = v2->type.t & VT_BTYPE;
int c1 = (v1->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
@@ -2736,7 +2736,7 @@ static void gen_opic(TCCState *S, int op)
case TOK_UMOD:
/* if division by zero, generate explicit division */
if (l2 == 0) {
- if (S->tccgen_const_wanted && !(S->nocode_wanted & unevalmask))
+ if (S->tccgen_const_wanted && !(S->tccgen_nocode_wanted & unevalmask))
tcc_error(S, "division by zero in constant");
goto general_case;
}
@@ -2773,7 +2773,7 @@ static void gen_opic(TCCState *S, int op)
l1 = ((uint32_t)l1 |
(v1->type.t & VT_UNSIGNED ? 0 : -(l1 & 0x80000000)));
v1->c.i = l1;
- S->vtop--;
+ S->tccgen_vtop--;
} else {
/* if commutative ops, put c2 as constant */
if (c1 && (op == '+' || op == '&' || op == '^' ||
@@ -2787,7 +2787,7 @@ static void gen_opic(TCCState *S, int op)
(op == TOK_SHL || op == TOK_SHR || op == TOK_SAR)) ||
(l1 == -1 && op == TOK_SAR))) {
/* treat (0 << x), (0 >> x) and (-1 >> x) as constant */
- S->vtop--;
+ S->tccgen_vtop--;
} else if (!S->tccgen_const_wanted &&
c2 && ((l2 == 0 && (op == '&' || op == '*')) ||
(op == '|' &&
@@ -2795,9 +2795,9 @@ static void gen_opic(TCCState *S, int op)
(l2 == 1 && (op == '%' || op == TOK_UMOD)))) {
/* treat (x & 0), (x * 0), (x | -1) and (x % 1) as constant */
if (l2 == 1)
- S->vtop->c.i = 0;
+ S->tccgen_vtop->c.i = 0;
vswap(S);
- S->vtop--;
+ S->tccgen_vtop--;
} else if (c2 && (((op == '*' || op == '/' || op == TOK_UDIV ||
op == TOK_PDIV) &&
l2 == 1) ||
@@ -2807,7 +2807,7 @@ static void gen_opic(TCCState *S, int op)
(op == '&' &&
(l2 == -1 || (l2 == 0xFFFFFFFF && t2 != VT_LLONG))))) {
/* filter out NOP operations like x*1, x-0, x&-1... */
- S->vtop--;
+ S->tccgen_vtop--;
} else if (c2 && (op == '*' || op == TOK_PDIV || op == TOK_UDIV)) {
/* try to use shifts instead of muls or divs */
if (l2 > 0 && (l2 & (l2 - 1)) == 0) {
@@ -2816,7 +2816,7 @@ static void gen_opic(TCCState *S, int op)
l2 >>= 1;
n++;
}
- S->vtop->c.i = n;
+ S->tccgen_vtop->c.i = n;
if (op == '*')
op = TOK_SHL;
else if (op == TOK_PDIV)
@@ -2826,18 +2826,18 @@ static void gen_opic(TCCState *S, int op)
}
goto general_case;
} else if (c2 && (op == '+' || op == '-') &&
- (((S->vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == (VT_CONST | VT_SYM))
- || (S->vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_LOCAL)) {
+ (((S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == (VT_CONST | VT_SYM))
+ || (S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_LOCAL)) {
/* symbol + constant case */
if (op == '-')
l2 = -l2;
- l2 += S->vtop[-1].c.i;
+ l2 += S->tccgen_vtop[-1].c.i;
/* The backends can't always deal with addends to symbols
larger than +-1<<31. Don't construct such. */
if ((int)l2 != l2)
goto general_case;
- S->vtop--;
- S->vtop->c.i = l2;
+ S->tccgen_vtop--;
+ S->tccgen_vtop->c.i = l2;
} else {
general_case:
/* call low level op generator */
@@ -2853,14 +2853,14 @@ static void gen_opic(TCCState *S, int op)
#if defined TCC_TARGET_X86_64 || defined TCC_TARGET_I386
# define gen_negf gen_opf
#elif defined TCC_TARGET_ARM
-void gen_negf(TCCState *S, int op)
+void gen_negf(TCCState* S, int op)
{
/* arm will detect 0-x and replace by vneg */
vpushi(S, 0), vswap(S), gen_op(S, '-');
}
#else
/* XXX: implement in gen_opf() for other backends too */
-void gen_negf(TCCState *S, int op)
+void gen_negf(TCCState* S, int op)
{
/* In IEEE negate(x) isn't subtract(0,x). Without NaNs it's
subtract(-0, x), but with them it's really a sign flip
@@ -2870,8 +2870,8 @@ void gen_negf(TCCState *S, int op)
int align, size, bt;
- size = type_size(&S->vtop->type, &align);
- bt = S->vtop->type.t & VT_BTYPE;
+ size = type_size(&S->tccgen_vtop->type, &align);
+ bt = S->tccgen_vtop->type.t & VT_BTYPE;
save_reg(S, gv(S, RC_TYPE(bt)));
vdup(S);
incr_bf_adr(S, size - 1);
@@ -2884,7 +2884,7 @@ void gen_negf(TCCState *S, int op)
#endif
/* generate a floating point operation with constant propagation */
-static void gen_opif(TCCState *S, int op)
+static void gen_opif(TCCState* S, int op)
{
int c1, c2;
SValue *v1, *v2;
@@ -2894,8 +2894,8 @@ static void gen_opif(TCCState *S, int op)
#endif
long double f1, f2;
- v1 = S->vtop - 1;
- v2 = S->vtop;
+ v1 = S->tccgen_vtop - 1;
+ v2 = S->tccgen_vtop;
if (op == TOK_NEG)
v1 = v2;
@@ -2948,7 +2948,7 @@ static void gen_opif(TCCState *S, int op)
default:
goto general_case;
}
- S->vtop--;
+ S->tccgen_vtop--;
unary_result:
/* XXX: overflow test ? */
if (v1->type.t == VT_FLOAT) {
@@ -2972,7 +2972,7 @@ static void gen_opif(TCCState *S, int op)
printed in the type */
/* XXX: union */
/* XXX: add array and function pointers */
-static void type_to_str(TCCState *S, char *buf, int buf_size,
+static void type_to_str(TCCState* S, char *buf, int buf_size,
CType *type, const char *varstr)
{
int bt, v, t;
@@ -3107,7 +3107,7 @@ static void type_to_str(TCCState *S, char *buf, int buf_size,
no_var: ;
}
-static void type_incompatibility_error(TCCState *S, CType* st, CType* dt, const char* fmt)
+static void type_incompatibility_error(TCCState* S, CType* st, CType* dt, const char* fmt)
{
char buf1[256], buf2[256];
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
tcc_error(S, fmt, buf1, buf2);
}
-static void type_incompatibility_warning(TCCState *S, CType* st, CType* dt, const char* fmt)
+static void type_incompatibility_warning(TCCState* S, CType* st, CType* dt, const char* fmt)
{
char buf1[256], buf2[256];
type_to_str(S, buf1, sizeof(buf1), st, NULL);
@@ -3129,7 +3129,7 @@ static int pointed_size(CType *type)
return type_size(pointed_type(type), &align);
}
-static void vla_runtime_pointed_size(TCCState *S, CType *type)
+static void vla_runtime_pointed_size(TCCState* S, CType *type)
{
int align;
vla_runtime_type_size(S, pointed_type(type), &align);
@@ -3226,7 +3226,7 @@ static int compare_types(CType *type1, CType *type2, int unqualified)
/* Check if OP1 and OP2 can be "combined" with operation OP, the combined
type is stored in DEST if non-null (except for pointer plus/minus) . */
-static int combine_types(TCCState *S, CType *dest, SValue *op1, SValue *op2, int op)
+static int combine_types(TCCState* S, CType *dest, SValue *op1, SValue *op2, int op)
{
CType *type1 = &op1->type, *type2 = &op2->type, type;
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
}
/* generic gen_op: handles types problems */
-ST_FUNC void gen_op(TCCState *S, int op)
+ST_FUNC void gen_op(TCCState* S, int op)
{
int u, t1, t2, bt1, bt2, t;
CType type1, combtype;
redo:
- t1 = S->vtop[-1].type.t;
- t2 = S->vtop[0].type.t;
+ t1 = S->tccgen_vtop[-1].type.t;
+ t2 = S->tccgen_vtop[0].type.t;
bt1 = t1 & VT_BTYPE;
bt2 = t2 & VT_BTYPE;
if (bt1 == VT_FUNC || bt2 == VT_FUNC) {
if (bt2 == VT_FUNC) {
- mk_pointer(S, &S->vtop->type);
+ mk_pointer(S, &S->tccgen_vtop->type);
gaddrof(S);
}
if (bt1 == VT_FUNC) {
vswap(S);
- mk_pointer(S, &S->vtop->type);
+ mk_pointer(S, &S->tccgen_vtop->type);
gaddrof(S);
vswap(S);
}
goto redo;
- } else if (!combine_types(S, &combtype, S->vtop - 1, S->vtop, op)) {
+ } else if (!combine_types(S, &combtype, S->tccgen_vtop - 1, S->tccgen_vtop, op)) {
tcc_error_noabort(S, "invalid operand types for binary operation");
vpop(S);
} else if (bt1 == VT_PTR || bt2 == VT_PTR) {
@@ -3378,14 +3378,14 @@ redo:
if (bt1 == VT_PTR && bt2 == VT_PTR) {
if (op != '-')
tcc_error(S, "cannot use pointers here");
- if (S->vtop[-1].type.t & VT_VLA) {
- vla_runtime_pointed_size(S, &S->vtop[-1].type);
+ if (S->tccgen_vtop[-1].type.t & VT_VLA) {
+ vla_runtime_pointed_size(S, &S->tccgen_vtop[-1].type);
} else {
- vpushi(S, pointed_size(&S->vtop[-1].type));
+ vpushi(S, pointed_size(&S->tccgen_vtop[-1].type));
}
vrott(S, 3);
gen_opic(S, op);
- S->vtop->type.t = VT_PTRDIFF_T;
+ S->tccgen_vtop->type.t = VT_PTRDIFF_T;
vswap(S);
gen_op(S, TOK_PDIV);
} else {
@@ -3398,15 +3398,15 @@ redo:
t = t1, t1 = t2, t2 = t;
}
#if PTR_SIZE == 4
- if ((S->vtop[0].type.t & VT_BTYPE) == VT_LLONG)
+ if ((S->tccgen_vtop[0].type.t & VT_BTYPE) == VT_LLONG)
/* XXX: truncate here because gen_opl can't handle ptr + long long */
gen_cast_s(S, VT_INT);
#endif
- type1 = S->vtop[-1].type;
- if (S->vtop[-1].type.t & VT_VLA)
- vla_runtime_pointed_size(S, &S->vtop[-1].type);
+ type1 = S->tccgen_vtop[-1].type;
+ if (S->tccgen_vtop[-1].type.t & VT_VLA)
+ vla_runtime_pointed_size(S, &S->tccgen_vtop[-1].type);
else {
- u = pointed_size(&S->vtop[-1].type);
+ u = pointed_size(&S->tccgen_vtop[-1].type);
if (u < 0)
tcc_error(S, "unknown array element size");
#if PTR_SIZE == 8
@@ -3434,7 +3434,7 @@ redo:
}
type1.t &= ~VT_ARRAY;
/* put again type if gen_opic() swaped operands */
- S->vtop->type = type1;
+ S->tccgen_vtop->type = type1;
}
} else {
/* floats can only be used for a few operations */
@@ -3483,23 +3483,23 @@ redo:
gen_opic(S, op);
if (TOK_ISCOND(op)) {
/* relational op: the result is an int */
- S->vtop->type.t = VT_INT;
+ S->tccgen_vtop->type.t = VT_INT;
} else {
- S->vtop->type.t = t;
+ S->tccgen_vtop->type.t = t;
}
}
// Make sure that we have converted to an rvalue:
- if (S->vtop->r & VT_LVAL)
- gv(S, is_float(S->vtop->type.t & VT_BTYPE) ? RC_FLOAT : RC_INT);
+ if (S->tccgen_vtop->r & VT_LVAL)
+ gv(S, is_float(S->tccgen_vtop->type.t & VT_BTYPE) ? RC_FLOAT : RC_INT);
}
#if defined TCC_TARGET_ARM64 || defined TCC_TARGET_RISCV64 || defined TCC_TARGET_ARM
#define gen_cvt_itof1 gen_cvt_itof
#else
/* generic itof for unsigned long long case */
-static void gen_cvt_itof1(TCCState *S, int t)
+static void gen_cvt_itof1(TCCState* S, int t)
{
- if ((S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
+ if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
(VT_LLONG | VT_UNSIGNED)) {
if (t == VT_FLOAT)
@@ -3513,7 +3513,7 @@ static void gen_cvt_itof1(TCCState *S, int t)
vrott(S, 2);
gfunc_call(S, 1);
vpushi(S, 0);
- PUT_R_RET(S->vtop, t);
+ PUT_R_RET(S->tccgen_vtop, t);
} else {
gen_cvt_itof(S, t);
}
@@ -3524,12 +3524,12 @@ static void gen_cvt_itof1(TCCState *S, int t)
#define gen_cvt_ftoi1 gen_cvt_ftoi
#else
/* generic ftoi for unsigned long long case */
-static void gen_cvt_ftoi1(TCCState *S, int t)
+static void gen_cvt_ftoi1(TCCState* S, int t)
{
int st;
if (t == (VT_LLONG | VT_UNSIGNED)) {
/* not handled natively */
- st = S->vtop->type.t & VT_BTYPE;
+ st = S->tccgen_vtop->type.t & VT_BTYPE;
if (st == VT_FLOAT)
vpush_helper_func(S, TOK___fixunssfdi);
#if LDOUBLE_SIZE != 8
@@ -3541,7 +3541,7 @@ static void gen_cvt_ftoi1(TCCState *S, int t)
vrott(S, 2);
gfunc_call(S, 1);
vpushi(S, 0);
- PUT_R_RET(S->vtop, t);
+ PUT_R_RET(S->tccgen_vtop, t);
} else {
gen_cvt_ftoi(S, t);
}
@@ -3549,17 +3549,17 @@ static void gen_cvt_ftoi1(TCCState *S, int t)
#endif
/* special delayed cast for char/short */
-static void force_charshort_cast(TCCState *S)
+static void force_charshort_cast(TCCState* S)
{
- int sbt = BFGET(S->vtop->r, VT_MUSTCAST) == 2 ? VT_LLONG : VT_INT;
- int dbt = S->vtop->type.t;
- S->vtop->r &= ~VT_MUSTCAST;
- S->vtop->type.t = sbt;
+ int sbt = BFGET(S->tccgen_vtop->r, VT_MUSTCAST) == 2 ? VT_LLONG : VT_INT;
+ int dbt = S->tccgen_vtop->type.t;
+ S->tccgen_vtop->r &= ~VT_MUSTCAST;
+ S->tccgen_vtop->type.t = sbt;
gen_cast_s(S, dbt == VT_BOOL ? VT_BYTE|VT_UNSIGNED : dbt);
- S->vtop->type.t = dbt;
+ S->tccgen_vtop->type.t = dbt;
}
-static void gen_cast_s(TCCState *S, int t)
+static void gen_cast_s(TCCState* S, int t)
{
CType type;
type.t = t;
@@ -3568,21 +3568,21 @@ static void gen_cast_s(TCCState *S, int t)
}
/* cast 'vtop' to 'type'. Casting to bitfields is forbidden. */
-static void gen_cast(TCCState *S, CType *type)
+static void gen_cast(TCCState* S, CType *type)
{
int sbt, dbt, sf, df, c;
int dbt_bt, sbt_bt, ds, ss, bits, trunc;
/* special delayed cast for char/short */
- if (S->vtop->r & VT_MUSTCAST)
+ if (S->tccgen_vtop->r & VT_MUSTCAST)
force_charshort_cast(S);
/* bitfields first get cast to ints */
- if (S->vtop->type.t & VT_BITFIELD)
+ if (S->tccgen_vtop->type.t & VT_BITFIELD)
gv(S, RC_INT);
dbt = type->t & (VT_BTYPE | VT_UNSIGNED);
- sbt = S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
+ sbt = S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
if (sbt == VT_FUNC)
sbt = VT_PTR;
@@ -3596,71 +3596,71 @@ again:
goto done;
if (sbt_bt == VT_VOID) {
error:
- cast_error(S, &S->vtop->type, type);
+ cast_error(S, &S->tccgen_vtop->type, type);
}
- c = (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+ c = (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
#if !defined TCC_IS_NATIVE && !defined TCC_IS_NATIVE_387
- c &= (dbt != VT_LDOUBLE) | !!S->nocode_wanted;
+ c &= (dbt != VT_LDOUBLE) | !!S->tccgen_nocode_wanted;
#endif
if (c) {
/* constant case: we can do it now */
/* XXX: in ISOC, cannot do it if error in convert */
if (sbt == VT_FLOAT)
- S->vtop->c.ld = S->vtop->c.f;
+ S->tccgen_vtop->c.ld = S->tccgen_vtop->c.f;
else if (sbt == VT_DOUBLE)
- S->vtop->c.ld = S->vtop->c.d;
+ S->tccgen_vtop->c.ld = S->tccgen_vtop->c.d;
if (df) {
if (sbt_bt == VT_LLONG) {
- if ((sbt & VT_UNSIGNED) || !(S->vtop->c.i >> 63))
- S->vtop->c.ld = S->vtop->c.i;
+ if ((sbt & VT_UNSIGNED) || !(S->tccgen_vtop->c.i >> 63))
+ S->tccgen_vtop->c.ld = S->tccgen_vtop->c.i;
else
- S->vtop->c.ld = -(long double)-S->vtop->c.i;
+ S->tccgen_vtop->c.ld = -(long double)-S->tccgen_vtop->c.i;
} else if(!sf) {
- if ((sbt & VT_UNSIGNED) || !(S->vtop->c.i >> 31))
- S->vtop->c.ld = (uint32_t)S->vtop->c.i;
+ if ((sbt & VT_UNSIGNED) || !(S->tccgen_vtop->c.i >> 31))
+ S->tccgen_vtop->c.ld = (uint32_t)S->tccgen_vtop->c.i;
else
- S->vtop->c.ld = -(long double)-(uint32_t)S->vtop->c.i;
+ S->tccgen_vtop->c.ld = -(long double)-(uint32_t)S->tccgen_vtop->c.i;
}
if (dbt == VT_FLOAT)
- S->vtop->c.f = (float)S->vtop->c.ld;
+ S->tccgen_vtop->c.f = (float)S->tccgen_vtop->c.ld;
else if (dbt == VT_DOUBLE)
- S->vtop->c.d = (double)S->vtop->c.ld;
+ S->tccgen_vtop->c.d = (double)S->tccgen_vtop->c.ld;
} else if (sf && dbt == VT_BOOL) {
- S->vtop->c.i = (S->vtop->c.ld != 0);
+ S->tccgen_vtop->c.i = (S->tccgen_vtop->c.ld != 0);
} else {
if(sf)
- S->vtop->c.i = S->vtop->c.ld;
+ S->tccgen_vtop->c.i = S->tccgen_vtop->c.ld;
else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR))
;
else if (sbt & VT_UNSIGNED)
- S->vtop->c.i = (uint32_t)S->vtop->c.i;
+ S->tccgen_vtop->c.i = (uint32_t)S->tccgen_vtop->c.i;
else
- S->vtop->c.i = ((uint32_t)S->vtop->c.i | -(S->vtop->c.i & 0x80000000));
+ S->tccgen_vtop->c.i = ((uint32_t)S->tccgen_vtop->c.i | -(S->tccgen_vtop->c.i & 0x80000000));
if (dbt_bt == VT_LLONG || (PTR_SIZE == 8 && dbt == VT_PTR))
;
else if (dbt == VT_BOOL)
- S->vtop->c.i = (S->vtop->c.i != 0);
+ S->tccgen_vtop->c.i = (S->tccgen_vtop->c.i != 0);
else {
uint32_t m = dbt_bt == VT_BYTE ? 0xff :
dbt_bt == VT_SHORT ? 0xffff :
0xffffffff;
- S->vtop->c.i &= m;
+ S->tccgen_vtop->c.i &= m;
if (!(dbt & VT_UNSIGNED))
- S->vtop->c.i |= -(S->vtop->c.i & ((m >> 1) + 1));
+ S->tccgen_vtop->c.i |= -(S->tccgen_vtop->c.i & ((m >> 1) + 1));
}
}
goto done;
} else if (dbt == VT_BOOL
- && (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM))
+ && (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM))
== (VT_CONST | VT_SYM)) {
/* addresses are considered non-zero (see tcctest.c:sinit23) */
- S->vtop->r = VT_CONST;
- S->vtop->c.i = 1;
+ S->tccgen_vtop->r = VT_CONST;
+ S->tccgen_vtop->c.i = 1;
goto done;
}
@@ -3707,7 +3707,7 @@ error:
tcc_warning(S, "cast between pointer and integer of different size");
if (sbt_bt == VT_PTR) {
/* put integer type to allow logical operations below */
- S->vtop->type.t = (PTR_SIZE == 8 ? VT_LLONG : VT_INT);
+ S->tccgen_vtop->type.t = (PTR_SIZE == 8 ? VT_LLONG : VT_INT);
}
}
@@ -3716,7 +3716,7 @@ error:
change the type and read it still later. */
#define ALLOW_SUBTYPE_ACCESS 1
- if (ALLOW_SUBTYPE_ACCESS && (S->vtop->r & VT_LVAL)) {
+ if (ALLOW_SUBTYPE_ACCESS && (S->tccgen_vtop->r & VT_LVAL)) {
/* value still in memory */
if (ds <= ss)
goto done;
@@ -3786,7 +3786,7 @@ error:
#endif
bits = (ss - ds) * 8;
/* for unsigned, gen_op will convert SAR to SHR */
- S->vtop->type.t = (ss == 8 ? VT_LLONG : VT_INT) | (dbt & VT_UNSIGNED);
+ S->tccgen_vtop->type.t = (ss == 8 ? VT_LLONG : VT_INT) | (dbt & VT_UNSIGNED);
vpushi(S, bits);
gen_op(S, TOK_SHL);
vpushi(S, bits - trunc);
@@ -3795,8 +3795,8 @@ error:
gen_op(S, TOK_SHR);
}
done:
- S->vtop->type = *type;
- S->vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY );
+ S->tccgen_vtop->type = *type;
+ S->tccgen_vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY );
}
/* 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)
/* push type size as known at runtime time on top of value stack. Put
alignment at 'a' */
-ST_FUNC void vla_runtime_type_size(TCCState *S, CType *type, int *a)
+ST_FUNC void vla_runtime_type_size(TCCState* S, CType *type, int *a)
{
if (type->t & VT_VLA) {
type_size(&type->ref->type, a);
@@ -3883,7 +3883,7 @@ static inline CType *pointed_type(CType *type)
}
/* modify type so that its it is a pointer to type. */
-ST_FUNC void mk_pointer(TCCState *S, CType *type)
+ST_FUNC void mk_pointer(TCCState* S, CType *type)
{
Sym *s;
s = sym_push(S, SYM_FIELD, type, 0, -1);
@@ -3906,18 +3906,18 @@ static int is_compatible_unqualified_types(CType *type1, CType *type2)
return compare_types(type1,type2,1);
}
-static void cast_error(TCCState *S, CType *st, CType *dt)
+static void cast_error(TCCState* S, CType *st, CType *dt)
{
type_incompatibility_error(S, st, dt, "cannot convert '%s' to '%s'");
}
/* verify type compatibility to store vtop in 'dt' type */
-static void verify_assign_cast(TCCState *S, CType *dt)
+static void verify_assign_cast(TCCState* S, CType *dt)
{
CType *st, *type1, *type2;
int dbt, sbt, qualwarn, lvl;
- st = &S->vtop->type; /* source type */
+ st = &S->tccgen_vtop->type; /* source type */
dbt = dt->t & VT_BTYPE;
sbt = st->t & VT_BTYPE;
if (dt->t & VT_CONSTANT)
@@ -3930,7 +3930,7 @@ static void verify_assign_cast(TCCState *S, CType *dt)
case VT_PTR:
/* special cases for pointers */
/* '0' can also be a pointer */
- if (is_null_pointer(S->vtop))
+ if (is_null_pointer(S->tccgen_vtop))
break;
/* accept implicit pointer to integer cast with warning */
if (is_integer_btype(sbt)) {
@@ -3997,36 +3997,36 @@ static void verify_assign_cast(TCCState *S, CType *dt)
}
}
-static void gen_assign_cast(TCCState *S, CType *dt)
+static void gen_assign_cast(TCCState* S, CType *dt)
{
verify_assign_cast(S, dt);
gen_cast(S, dt);
}
/* store vtop in lvalue pushed on stack */
-ST_FUNC void vstore(TCCState *S)
+ST_FUNC void vstore(TCCState* S)
{
int sbt, dbt, ft, r, size, align, bit_size, bit_pos, delayed_cast;
- ft = S->vtop[-1].type.t;
- sbt = S->vtop->type.t & VT_BTYPE;
+ ft = S->tccgen_vtop[-1].type.t;
+ sbt = S->tccgen_vtop->type.t & VT_BTYPE;
dbt = ft & VT_BTYPE;
- verify_assign_cast(S, &S->vtop[-1].type);
+ verify_assign_cast(S, &S->tccgen_vtop[-1].type);
if (sbt == VT_STRUCT) {
/* if structure, only generate pointer */
/* structure assignment : generate memcpy */
/* XXX: optimize if small size */
- size = type_size(&S->vtop->type, &align);
+ size = type_size(&S->tccgen_vtop->type, &align);
/* destination */
vswap(S);
#ifdef CONFIG_TCC_BCHECK
- if (S->vtop->r & VT_MUSTBOUND)
+ if (S->tccgen_vtop->r & VT_MUSTBOUND)
gbound(S); /* check would be wrong after gaddrof() */
#endif
- S->vtop->type.t = VT_PTR;
+ S->tccgen_vtop->type.t = VT_PTR;
gaddrof(S);
/* address of memcpy() */
@@ -4042,12 +4042,12 @@ ST_FUNC void vstore(TCCState *S)
vswap(S);
/* source */
- vpushv(S, S->vtop - 2);
+ vpushv(S, S->tccgen_vtop - 2);
#ifdef CONFIG_TCC_BCHECK
- if (S->vtop->r & VT_MUSTBOUND)
+ if (S->tccgen_vtop->r & VT_MUSTBOUND)
gbound(S);
#endif
- S->vtop->type.t = VT_PTR;
+ S->tccgen_vtop->type.t = VT_PTR;
gaddrof(S);
/* type size */
vpushi(S, size);
@@ -4058,21 +4058,21 @@ ST_FUNC void vstore(TCCState *S)
/* bitfield store handling */
/* save lvalue as expression result (example: s.b = s.a = n;) */
- vdup(S), S->vtop[-1] = S->vtop[-2];
+ vdup(S), S->tccgen_vtop[-1] = S->tccgen_vtop[-2];
bit_pos = BIT_POS(ft);
bit_size = BIT_SIZE(ft);
/* remove bit field info to avoid loops */
- S->vtop[-1].type.t = ft & ~VT_STRUCT_MASK;
+ S->tccgen_vtop[-1].type.t = ft & ~VT_STRUCT_MASK;
if (dbt == VT_BOOL) {
- gen_cast(S, &S->vtop[-1].type);
- S->vtop[-1].type.t = (S->vtop[-1].type.t & ~VT_BTYPE) | (VT_BYTE | VT_UNSIGNED);
+ gen_cast(S, &S->tccgen_vtop[-1].type);
+ S->tccgen_vtop[-1].type.t = (S->tccgen_vtop[-1].type.t & ~VT_BTYPE) | (VT_BYTE | VT_UNSIGNED);
}
- r = adjust_bf(S->vtop - 1, bit_pos, bit_size);
+ r = adjust_bf(S->tccgen_vtop - 1, bit_pos, bit_size);
if (dbt != VT_BOOL) {
- gen_cast(S, &S->vtop[-1].type);
- dbt = S->vtop[-1].type.t & VT_BTYPE;
+ gen_cast(S, &S->tccgen_vtop[-1].type);
+ dbt = S->tccgen_vtop[-1].type.t & VT_BTYPE;
}
if (r == VT_STRUCT) {
store_packed_bf(S, bit_pos, bit_size);
@@ -4106,25 +4106,25 @@ ST_FUNC void vstore(TCCState *S)
vpop(S);
}
} else if (dbt == VT_VOID) {
- --S->vtop;
+ --S->tccgen_vtop;
} else {
/* optimize char/short casts */
delayed_cast = 0;
if ((dbt == VT_BYTE || dbt == VT_SHORT)
&& is_integer_btype(sbt)
) {
- if ((S->vtop->r & VT_MUSTCAST)
+ if ((S->tccgen_vtop->r & VT_MUSTCAST)
&& btype_size(dbt) > btype_size(sbt)
)
force_charshort_cast(S);
delayed_cast = 1;
} else {
- gen_cast(S, &S->vtop[-1].type);
+ gen_cast(S, &S->tccgen_vtop[-1].type);
}
#ifdef CONFIG_TCC_BCHECK
/* bound check case */
- if (S->vtop[-1].r & VT_MUSTBOUND) {
+ if (S->tccgen_vtop[-1].r & VT_MUSTBOUND) {
vswap(S);
gbound(S);
vswap(S);
@@ -4133,51 +4133,51 @@ ST_FUNC void vstore(TCCState *S)
gv(S, RC_TYPE(dbt)); /* generate value */
if (delayed_cast) {
- S->vtop->r |= BFVAL(VT_MUSTCAST, (sbt == VT_LLONG) + 1);
+ S->tccgen_vtop->r |= BFVAL(VT_MUSTCAST, (sbt == VT_LLONG) + 1);
//tcc_warning(S, "deley cast %x -> %x", sbt, dbt);
- S->vtop->type.t = ft & VT_TYPE;
+ S->tccgen_vtop->type.t = ft & VT_TYPE;
}
/* if lvalue was saved on stack, must read it */
- if ((S->vtop[-1].r & VT_VALMASK) == VT_LLOCAL) {
+ if ((S->tccgen_vtop[-1].r & VT_VALMASK) == VT_LLOCAL) {
SValue sv;
r = get_reg(S, RC_INT);
sv.type.t = VT_PTRDIFF_T;
sv.r = VT_LOCAL | VT_LVAL;
- sv.c.i = S->vtop[-1].c.i;
+ sv.c.i = S->tccgen_vtop[-1].c.i;
load(S, r, &sv);
- S->vtop[-1].r = r | VT_LVAL;
+ S->tccgen_vtop[-1].r = r | VT_LVAL;
}
- r = S->vtop->r & VT_VALMASK;
+ r = S->tccgen_vtop->r & VT_VALMASK;
/* two word case handling :
store second register at word + 4 (or +8 for x86-64) */
if (USING_TWO_WORDS(dbt)) {
int load_type = (dbt == VT_QFLOAT) ? VT_DOUBLE : VT_PTRDIFF_T;
- S->vtop[-1].type.t = load_type;
- store(S, r, S->vtop - 1);
+ S->tccgen_vtop[-1].type.t = load_type;
+ store(S, r, S->tccgen_vtop - 1);
vswap(S);
/* convert to int to increment easily */
- S->vtop->type.t = VT_PTRDIFF_T;
+ S->tccgen_vtop->type.t = VT_PTRDIFF_T;
gaddrof(S);
vpushs(S, PTR_SIZE);
gen_op(S, '+');
- S->vtop->r |= VT_LVAL;
+ S->tccgen_vtop->r |= VT_LVAL;
vswap(S);
- S->vtop[-1].type.t = load_type;
+ S->tccgen_vtop[-1].type.t = load_type;
/* XXX: it works because r2 is spilled last ! */
- store(S, S->vtop->r2, S->vtop - 1);
+ store(S, S->tccgen_vtop->r2, S->tccgen_vtop - 1);
} else {
/* single word */
- store(S, r, S->vtop - 1);
+ store(S, r, S->tccgen_vtop - 1);
}
vswap(S);
- S->vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
+ S->tccgen_vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
}
}
/* post defines POST/PRE add. c is the token ++ or -- */
-ST_FUNC void inc(TCCState *S, int post, int c)
+ST_FUNC void inc(TCCState* S, int post, int c)
{
test_lvalue(S);
vdup(S); /* save lvalue */
@@ -4194,15 +4194,15 @@ ST_FUNC void inc(TCCState *S, int post, int c)
vpop(S); /* if post op, return saved value */
}
-ST_FUNC void parse_mult_str (TCCState *S, CString *astr, const char *msg)
+ST_FUNC void parse_mult_str (TCCState* S, CString *astr, const char *msg)
{
/* read the string */
- if (S->tok != TOK_STR)
+ if (S->tccpp_tok != TOK_STR)
expect(S, msg);
cstr_new(S, astr);
- while (S->tok == TOK_STR) {
+ while (S->tccpp_tok == TOK_STR) {
/* XXX: add \0 handling too ? */
- cstr_cat(S, astr, S->tokc.str.data, -1);
+ cstr_cat(S, astr, S->tccpp_tokc.str.data, -1);
next(S);
}
cstr_ccat(S, astr, '\0');
@@ -4227,21 +4227,21 @@ ST_FUNC int exact_log2p1(int i)
}
/* Parse __attribute__((...)) GNUC extension. */
-static void parse_attribute(TCCState *S, AttributeDef *ad)
+static void parse_attribute(TCCState* S, AttributeDef *ad)
{
int t, n;
CString astr;
redo:
- if (S->tok != TOK_ATTRIBUTE1 && S->tok != TOK_ATTRIBUTE2)
+ if (S->tccpp_tok != TOK_ATTRIBUTE1 && S->tccpp_tok != TOK_ATTRIBUTE2)
return;
next(S);
skip(S, '(');
skip(S, '(');
- while (S->tok != ')') {
- if (S->tok < TOK_IDENT)
+ while (S->tccpp_tok != ')') {
+ if (S->tccpp_tok < TOK_IDENT)
expect(S, "attribute name");
- t = S->tok;
+ t = S->tccpp_tok;
next(S);
switch(t) {
case TOK_CLEANUP1:
@@ -4250,13 +4250,13 @@ redo:
Sym *s;
skip(S, '(');
- s = sym_find(S, S->tok);
+ s = sym_find(S, S->tccpp_tok);
if (!s) {
tcc_warning_c(warn_implicit_function_declaration)(S,
- "implicit declaration of function '%s'", get_tok_str(S, S->tok, &S->tokc));
- s = external_global_sym(S, S->tok, &S->tccgen_func_old_type);
+ "implicit declaration of function '%s'", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
+ s = external_global_sym(S, S->tccpp_tok, &S->tccgen_func_old_type);
} else if ((s->type.t & VT_BTYPE) != VT_FUNC)
- tcc_error(S, "'%s' is not declared as function", get_tok_str(S, S->tok, &S->tokc));
+ tcc_error(S, "'%s' is not declared as function", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
ad->cleanup_func = s;
next(S);
skip(S, ')');
@@ -4311,7 +4311,7 @@ redo:
break;
case TOK_ALIGNED1:
case TOK_ALIGNED2:
- if (S->tok == '(') {
+ if (S->tccpp_tok == '(') {
next(S);
n = expr_const(S);
if (n <= 0 || (n & (n - 1)) != 0)
@@ -4372,7 +4372,7 @@ redo:
#endif
case TOK_MODE:
skip(S, '(');
- switch(S->tok) {
+ switch(S->tccpp_tok) {
case TOK_MODE_DI:
ad->attr_mode = VT_LLONG + 1;
break;
@@ -4387,7 +4387,7 @@ redo:
ad->attr_mode = VT_INT + 1;
break;
default:
- tcc_warning(S, "__mode__(%s) not supported\n", get_tok_str(S, S->tok, NULL));
+ tcc_warning(S, "__mode__(%s) not supported\n", get_tok_str(S, S->tccpp_tok, NULL));
break;
}
next(S);
@@ -4405,19 +4405,19 @@ redo:
default:
tcc_warning_c(warn_unsupported)(S, "'%s' attribute ignored", get_tok_str(S, t, NULL));
/* skip parameters */
- if (S->tok == '(') {
+ if (S->tccpp_tok == '(') {
int parenthesis = 0;
do {
- if (S->tok == '(')
+ if (S->tccpp_tok == '(')
parenthesis++;
- else if (S->tok == ')')
+ else if (S->tccpp_tok == ')')
parenthesis--;
next(S);
- } while (parenthesis && S->tok != -1);
+ } while (parenthesis && S->tccpp_tok != -1);
}
break;
}
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
break;
next(S);
}
@@ -4446,7 +4446,7 @@ static Sym * find_field (CType *type, int v, int *cumofs)
return s;
}
-static void check_fields (TCCState *S, CType *type, int check)
+static void check_fields (TCCState* S, CType *type, int check)
{
Sym *s = type->ref;
@@ -4462,7 +4462,7 @@ static void check_fields (TCCState *S, CType *type, int check)
}
}
-static void struct_layout(TCCState *S, CType *type, AttributeDef *ad)
+static void struct_layout(TCCState* S, CType *type, AttributeDef *ad)
{
int size, align, maxalign, offset, c, bit_pos, bit_size;
int packed, a, bt, prevbt, prev_bit_size;
@@ -4712,7 +4712,7 @@ static void struct_layout(TCCState *S, CType *type, AttributeDef *ad)
}
/* enum/struct/union declaration. u is VT_ENUM/VT_STRUCT/VT_UNION */
-static void struct_decl(TCCState *S, CType *type, int u)
+static void struct_decl(TCCState* S, CType *type, int u)
{
int v, c, size, align, flexible;
int bit_size, bsize, bt;
@@ -4723,14 +4723,14 @@ static void struct_decl(TCCState *S, CType *type, int u)
memset(&ad, 0, sizeof ad);
next(S);
parse_attribute(S, &ad);
- if (S->tok != '{') {
- v = S->tok;
+ if (S->tccpp_tok != '{') {
+ v = S->tccpp_tok;
next(S);
/* struct already defined ? return it */
if (v < TOK_IDENT)
expect(S, "struct/union/enum name");
s = struct_find(S, v);
- if (s && (s->sym_scope == S->local_scope || S->tok != '{')) {
+ if (s && (s->sym_scope == S->tccgen_local_scope || S->tccpp_tok != '{')) {
if (u == s->type.t)
goto do_decl;
if (u == VT_ENUM && IS_ENUM(s->type.t))
@@ -4750,7 +4750,7 @@ do_decl:
type->t = s->type.t;
type->ref = s;
- if (S->tok == '{') {
+ if (S->tccpp_tok == '{') {
next(S);
if (s->c != -1)
tcc_error(S, "struct/union/enum already defined");
@@ -4765,15 +4765,15 @@ do_decl:
/* enum symbols have static storage */
t.t = VT_INT|VT_STATIC|VT_ENUM_VAL;
for(;;) {
- v = S->tok;
+ v = S->tccpp_tok;
if (v < TOK_UIDENT)
expect(S, "identifier");
ss = sym_find(S, v);
- if (ss && !S->local_stack)
+ if (ss && !S->tccgen_local_stack)
tcc_error(S, "redefinition of enumerator '%s'",
get_tok_str(S, v, NULL));
next(S);
- if (S->tok == '=') {
+ if (S->tccpp_tok == '=') {
next(S);
ll = expr_const64(S);
}
@@ -4784,12 +4784,12 @@ do_decl:
nl = ll;
if (ll > pl)
pl = ll;
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
break;
next(S);
ll++;
/* NOTE: we accept a trailing comma */
- if (S->tok == '}')
+ if (S->tccpp_tok == '}')
break;
}
skip(S, '}');
@@ -4819,7 +4819,7 @@ do_decl:
} else {
c = 0;
flexible = 0;
- while (S->tok != '}') {
+ while (S->tccpp_tok != '}') {
if (!parse_btype(S, &btype, &ad1)) {
skip(S, ';');
continue;
@@ -4831,8 +4831,8 @@ do_decl:
bit_size = -1;
v = 0;
type1 = btype;
- if (S->tok != ':') {
- if (S->tok != ';')
+ if (S->tccpp_tok != ':') {
+ if (S->tccpp_tok != ';')
type_decl(S, &type1, &ad1, &v, TYPE_DIRECT);
if (v == 0) {
if ((type1.t & VT_BTYPE) != VT_STRUCT)
@@ -4858,7 +4858,7 @@ do_decl:
tcc_error(S, "invalid type for '%s'",
get_tok_str(S, v, NULL));
}
- if (S->tok == ':') {
+ if (S->tccpp_tok == ':') {
next(S);
bit_size = expr_const(S);
/* XXX: handle v = 0 case for messages */
@@ -4913,7 +4913,7 @@ do_decl:
*ps = ss;
ps = &ss->next;
}
- if (S->tok == ';' || S->tok == TOK_EOF)
+ if (S->tccpp_tok == ';' || S->tccpp_tok == TOK_EOF)
break;
skip(S, ',');
}
@@ -4939,7 +4939,7 @@ static void sym_to_attr(AttributeDef *ad, Sym *s)
/* Add type qualifiers to a type. If the type is an array then the qualifiers
are added to the element type, copied because it could be a typedef. */
-static void parse_btype_qualify(TCCState *S, CType *type, int qualifiers)
+static void parse_btype_qualify(TCCState* S, CType *type, int qualifiers)
{
while (type->t & VT_ARRAY) {
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)
/* return 0 if no type declaration. otherwise, return the basic type
and skip it.
*/
-static int parse_btype(TCCState *S, CType *type, AttributeDef *ad)
+static int parse_btype(TCCState* S, CType *type, AttributeDef *ad)
{
int t, u, bt, st, type_found, typespec_found, g, n;
Sym *s;
@@ -4965,7 +4965,7 @@ static int parse_btype(TCCState *S, CType *type, AttributeDef *ad)
type->ref = NULL;
while(1) {
- switch(S->tok) {
+ switch(S->tccpp_tok) {
case TOK_EXTENSION:
/* currently, we really ignore extension */
next(S);
@@ -5072,7 +5072,7 @@ static int parse_btype(TCCState *S, CType *type, AttributeDef *ad)
type->t = t;
parse_btype_qualify(S, type, VT_ATOMIC);
t = type->t;
- if (S->tok == '(') {
+ if (S->tccpp_tok == '(') {
parse_expr_type(S, &type1);
/* remove all storage modifiers except typedef */
type1.t &= ~(VT_STORAGE&~VT_TYPEDEF);
@@ -5170,12 +5170,12 @@ static int parse_btype(TCCState *S, CType *type, AttributeDef *ad)
default:
if (typespec_found)
goto the_end;
- s = sym_find(S, S->tok);
+ s = sym_find(S, S->tccpp_tok);
if (!s || !(s->type.t & VT_TYPEDEF))
goto the_end;
- n = S->tok, next(S);
- if (S->tok == ':' && !S->tccgen_in_generic) {
+ n = S->tccpp_tok, next(S);
+ if (S->tccpp_tok == ':' && !S->tccgen_in_generic) {
/* ignore if it's a label */
unget_tok(S, n);
goto the_end;
@@ -5215,7 +5215,7 @@ the_end:
/* convert a function parameter type (array to pointer and function to
function pointer) */
-static inline void convert_parameter_type(TCCState *S, CType *pt)
+static inline void convert_parameter_type(TCCState* S, CType *pt)
{
/* remove const and volatile qualifiers (XXX: const could be used
to indicate a const function parameter */
@@ -5227,14 +5227,14 @@ static inline void convert_parameter_type(TCCState *S, CType *pt)
}
}
-ST_FUNC void parse_asm_str(TCCState *S, CString *astr)
+ST_FUNC void parse_asm_str(TCCState* S, CString *astr)
{
skip(S, '(');
parse_mult_str(S, astr, "string constant");
}
/* Parse an asm label and return the token */
-static int asm_label_instr(TCCState *S)
+static int asm_label_instr(TCCState* S)
{
int v;
CString astr;
@@ -5250,19 +5250,19 @@ static int asm_label_instr(TCCState *S)
return v;
}
-static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, int td)
+static int post_type(TCCState* S, CType *type, AttributeDef *ad, int storage, int td)
{
int n, l, t1, arg_size, align, unused_align;
Sym **plast, *s, *first;
AttributeDef ad1;
CType pt;
- if (S->tok == '(') {
+ if (S->tccpp_tok == '(') {
/* function type, or recursive declarator (return if so) */
next(S);
if (td && !(td & TYPE_ABSTRACT))
return 0;
- if (S->tok == ')')
+ if (S->tccpp_tok == ')')
l = 0;
else if (parse_btype(S, &pt, &ad1))
l = FUNC_NEW;
@@ -5278,13 +5278,13 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in
for(;;) {
/* read param name and compute offset */
if (l != FUNC_OLD) {
- if ((pt.t & VT_BTYPE) == VT_VOID && S->tok == ')')
+ if ((pt.t & VT_BTYPE) == VT_VOID && S->tccpp_tok == ')')
break;
type_decl(S, &pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT);
if ((pt.t & VT_BTYPE) == VT_VOID)
tcc_error(S, "parameter declared as void");
} else {
- n = S->tok;
+ n = S->tccpp_tok;
if (n < TOK_UIDENT)
expect(S, "identifier");
pt.t = VT_VOID; /* invalid type */
@@ -5296,10 +5296,10 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in
s = sym_push(S, n | SYM_FIELD, &pt, 0, 0);
*plast = s;
plast = &s->next;
- if (S->tok == ')')
+ if (S->tccpp_tok == ')')
break;
skip(S, ',');
- if (l == FUNC_NEW && S->tok == TOK_DOTS) {
+ if (l == FUNC_NEW && S->tccpp_tok == TOK_DOTS) {
l = FUNC_ELLIPSIS;
next(S);
break;
@@ -5317,7 +5317,7 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in
/* some ancient pre-K&R C allows a function to return an array
and the array brackets to be put after the arguments, such
that "int c()[]" means something like "int[] c()" */
- if (S->tok == '[') {
+ if (S->tccpp_tok == '[') {
next(S);
skip(S, ']'); /* only handle simple "[]" */
mk_pointer(S, type);
@@ -5331,15 +5331,15 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in
s->next = first;
type->t = VT_FUNC;
type->ref = s;
- } else if (S->tok == '[') {
- int saved_nocode_wanted = S->nocode_wanted;
+ } else if (S->tccpp_tok == '[') {
+ int saved_nocode_wanted = S->tccgen_nocode_wanted;
/* array definition */
next(S);
while (1) {
/* XXX The optional type-quals and static should only be accepted
in parameter decls. The '*' as well, and then even only
in prototypes (not function defs). */
- switch (S->tok) {
+ switch (S->tccpp_tok) {
case TOK_RESTRICT1: case TOK_RESTRICT2: case TOK_RESTRICT3:
case TOK_CONST1:
case TOK_VOLATILE1:
@@ -5354,23 +5354,23 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in
}
n = -1;
t1 = 0;
- if (S->tok != ']') {
- if (!S->local_stack || (storage & VT_STATIC))
+ if (S->tccpp_tok != ']') {
+ if (!S->tccgen_local_stack || (storage & VT_STATIC))
vpushi(S, expr_const(S));
else {
/* VLAs (which can only happen with local_stack && !VT_STATIC)
length must always be evaluated, even under nocode_wanted,
so that its size slot is initialized (e.g. under sizeof
or typeof). */
- S->nocode_wanted = 0;
+ S->tccgen_nocode_wanted = 0;
gexpr(S);
}
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
- n = S->vtop->c.i;
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ n = S->tccgen_vtop->c.i;
if (n < 0)
tcc_error(S, "invalid array size");
} else {
- if (!is_integer_btype(S->vtop->type.t & VT_BTYPE))
+ if (!is_integer_btype(S->tccgen_vtop->type.t & VT_BTYPE))
tcc_error(S, "size of variable length array should be an integer");
n = 0;
t1 = VT_VLA;
@@ -5391,9 +5391,9 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in
if (t1 & VT_VLA) {
if (n < 0)
tcc_error(S, "need explicit inner array size in VLAs");
- S->loc -= type_size(&S->tccgen_int_type, &align);
- S->loc &= -align;
- n = S->loc;
+ S->tccgen_loc -= type_size(&S->tccgen_int_type, &align);
+ S->tccgen_loc &= -align;
+ n = S->tccgen_loc;
vla_runtime_type_size(S, type, &align);
gen_op(S, '*');
@@ -5403,7 +5403,7 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in
}
if (n != -1)
vpop(S);
- S->nocode_wanted = saved_nocode_wanted;
+ S->tccgen_nocode_wanted = saved_nocode_wanted;
/* we push an anonymous symbol which will contain the array
element type */
@@ -5421,7 +5421,7 @@ static int post_type(TCCState *S, CType *type, AttributeDef *ad, int storage, in
type_decl(). If this (possibly abstract) declarator is a pointer chain
it returns the innermost pointed to type (equals *type, but is a different
pointer), otherwise returns type itself, that's used for recursive calls. */
-static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int td)
+static CType *type_decl(TCCState* S, CType *type, AttributeDef *ad, int *v, int td)
{
CType *post, *ret;
int qualifiers, storage;
@@ -5431,11 +5431,11 @@ static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int
type->t &= ~VT_STORAGE;
post = ret = type;
- while (S->tok == '*') {
+ while (S->tccpp_tok == '*') {
qualifiers = 0;
redo:
next(S);
- switch(S->tok) {
+ switch(S->tccpp_tok) {
case TOK__Atomic:
qualifiers |= VT_ATOMIC;
goto redo;
@@ -5466,7 +5466,7 @@ static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int
ret = pointed_type(type);
}
- if (S->tok == '(') {
+ if (S->tccpp_tok == '(') {
/* This is possibly a parameter type list for abstract declarators
('int ()'), use post_type for testing this. */
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
skip(S, ')');
} else
goto abstract;
- } else if (S->tok >= TOK_IDENT && (td & TYPE_DIRECT)) {
+ } else if (S->tccpp_tok >= TOK_IDENT && (td & TYPE_DIRECT)) {
/* type identifier */
- *v = S->tok;
+ *v = S->tccpp_tok;
next(S);
} else {
abstract:
@@ -5496,30 +5496,30 @@ static CType *type_decl(TCCState *S, CType *type, AttributeDef *ad, int *v, int
}
/* indirection with full error checking and bound check */
-ST_FUNC void indir(TCCState *S)
+ST_FUNC void indir(TCCState* S)
{
- if ((S->vtop->type.t & VT_BTYPE) != VT_PTR) {
- if ((S->vtop->type.t & VT_BTYPE) == VT_FUNC)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_PTR) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FUNC)
return;
expect(S, "pointer");
}
- if (S->vtop->r & VT_LVAL)
+ if (S->tccgen_vtop->r & VT_LVAL)
gv(S, RC_INT);
- S->vtop->type = *pointed_type(&S->vtop->type);
+ S->tccgen_vtop->type = *pointed_type(&S->tccgen_vtop->type);
/* Arrays and functions are never lvalues */
- if (!(S->vtop->type.t & (VT_ARRAY | VT_VLA))
- && (S->vtop->type.t & VT_BTYPE) != VT_FUNC) {
- S->vtop->r |= VT_LVAL;
+ if (!(S->tccgen_vtop->type.t & (VT_ARRAY | VT_VLA))
+ && (S->tccgen_vtop->type.t & VT_BTYPE) != VT_FUNC) {
+ S->tccgen_vtop->r |= VT_LVAL;
/* if bound checking, the referenced pointer must be checked */
#ifdef CONFIG_TCC_BCHECK
if (S->do_bounds_check)
- S->vtop->r |= VT_MUSTBOUND;
+ S->tccgen_vtop->r |= VT_MUSTBOUND;
#endif
}
}
/* pass a parameter to a function and do type checking and casting */
-static void gfunc_param_typed(TCCState *S, Sym *func, Sym *arg)
+static void gfunc_param_typed(TCCState* S, Sym *func, Sym *arg)
{
int func_type;
CType type;
@@ -5528,13 +5528,13 @@ static void gfunc_param_typed(TCCState *S, Sym *func, Sym *arg)
if (func_type == FUNC_OLD ||
(func_type == FUNC_ELLIPSIS && arg == NULL)) {
/* default casting : only need to convert float to double */
- if ((S->vtop->type.t & VT_BTYPE) == VT_FLOAT) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FLOAT) {
gen_cast_s(S, VT_DOUBLE);
- } else if (S->vtop->type.t & VT_BITFIELD) {
- type.t = S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
- type.ref = S->vtop->type.ref;
+ } else if (S->tccgen_vtop->type.t & VT_BITFIELD) {
+ type.t = S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
+ type.ref = S->tccgen_vtop->type.ref;
gen_cast(S, &type);
- } else if (S->vtop->r & VT_MUSTCAST) {
+ } else if (S->tccgen_vtop->r & VT_MUSTCAST) {
force_charshort_cast(S);
}
} else if (arg == NULL) {
@@ -5547,18 +5547,18 @@ static void gfunc_param_typed(TCCState *S, Sym *func, Sym *arg)
}
/* parse an expression and return its type without any side effect. */
-static void expr_type(TCCState *S, CType *type, void (*expr_fn)(TCCState *S))
+static void expr_type(TCCState* S, CType *type, void (*expr_fn)(TCCState* S))
{
- S->nocode_wanted++;
+ S->tccgen_nocode_wanted++;
expr_fn(S);
- *type = S->vtop->type;
+ *type = S->tccgen_vtop->type;
vpop(S);
- S->nocode_wanted--;
+ S->tccgen_nocode_wanted--;
}
/* parse an expression of the form '(type)' or '(expr)' and return its
type */
-static void parse_expr_type(TCCState *S, CType *type)
+static void parse_expr_type(TCCState* S, CType *type)
{
int n;
AttributeDef ad;
@@ -5572,7 +5572,7 @@ static void parse_expr_type(TCCState *S, CType *type)
skip(S, ')');
}
-static void parse_type(TCCState *S, CType *type)
+static void parse_type(TCCState* S, CType *type)
{
AttributeDef ad;
int n;
@@ -5583,12 +5583,12 @@ static void parse_type(TCCState *S, CType *type)
type_decl(S, type, &ad, &n, TYPE_ABSTRACT);
}
-static void parse_builtin_params(TCCState *S, int nc, const char *args)
+static void parse_builtin_params(TCCState* S, int nc, const char *args)
{
char c, sep = '(';
CType type;
if (nc)
- S->nocode_wanted++;
+ S->tccgen_nocode_wanted++;
next(S);
if (*args == 0)
skip(S, sep);
@@ -5631,10 +5631,10 @@ static void parse_builtin_params(TCCState *S, int nc, const char *args)
}
skip(S, ')');
if (nc)
- S->nocode_wanted--;
+ S->tccgen_nocode_wanted--;
}
-static void parse_atomic(TCCState *S, int atok)
+static void parse_atomic(TCCState* S, int atok)
{
int size, align, arg;
CType *atom, *atom_ptr, ct = {0};
@@ -5675,7 +5675,7 @@ static void parse_atomic(TCCState *S, int atok)
switch (template[arg]) {
case 'a':
case 'A':
- atom_ptr = &S->vtop->type;
+ atom_ptr = &S->tccgen_vtop->type;
if ((atom_ptr->t & VT_BTYPE) != VT_PTR)
expect(S, "pointer");
atom = pointed_type(atom_ptr);
@@ -5692,8 +5692,8 @@ static void parse_atomic(TCCState *S, int atok)
break;
case 'p':
- if ((S->vtop->type.t & VT_BTYPE) != VT_PTR
- || type_size(pointed_type(&S->vtop->type), &align) != size)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_PTR
+ || type_size(pointed_type(&S->tccgen_vtop->type), &align) != size)
tcc_error(S, "pointer target type mismatch in argument %d", arg + 1);
gen_assign_cast(S, atom_ptr);
break;
@@ -5730,17 +5730,17 @@ static void parse_atomic(TCCState *S, int atok)
gfunc_call(S, arg);
vpush(S, &ct);
- PUT_R_RET(S->vtop, ct.t);
+ PUT_R_RET(S->tccgen_vtop, ct.t);
if (ct.t == VT_BOOL) {
#ifdef PROMOTE_RET
- S->vtop->r |= BFVAL(VT_MUSTCAST, 1);
+ S->tccgen_vtop->r |= BFVAL(VT_MUSTCAST, 1);
#else
- S->vtop->type.t = VT_INT;
+ S->tccgen_vtop->type.t = VT_INT;
#endif
}
}
-ST_FUNC void unary(TCCState *S)
+ST_FUNC void unary(TCCState* S)
{
int n, t, align, size, r, sizeof_caller;
CType type;
@@ -5757,7 +5757,7 @@ ST_FUNC void unary(TCCState *S)
/* XXX: GCC 2.95.3 does not generate a table although it should be
better here */
tok_next:
- switch(S->tok) {
+ switch(S->tccpp_tok) {
case TOK_EXTENSION:
next(S);
goto tok_next;
@@ -5771,7 +5771,7 @@ ST_FUNC void unary(TCCState *S)
t = VT_INT;
push_tokc:
type.t = t;
- vsetc(S, &type, VT_CONST, &S->tokc);
+ vsetc(S, &type, VT_CONST, &S->tccpp_tokc);
next(S);
break;
case TOK_CUINT:
@@ -5849,7 +5849,7 @@ ST_FUNC void unary(TCCState *S)
type_decl(S, &type, &ad, &n, TYPE_ABSTRACT);
skip(S, ')');
/* check ISOC99 compound literal */
- if (S->tok == '{') {
+ if (S->tccpp_tok == '{') {
/* data is allocated locally by default */
if (S->tccgen_global_expr)
r = VT_CONST;
@@ -5868,11 +5868,11 @@ ST_FUNC void unary(TCCState *S)
unary(S);
gen_cast(S, &type);
}
- } else if (S->tok == '{') {
- int saved_nocode_wanted = S->nocode_wanted;
- if (S->tccgen_const_wanted && !(S->nocode_wanted & unevalmask))
+ } else if (S->tccpp_tok == '{') {
+ int saved_nocode_wanted = S->tccgen_nocode_wanted;
+ if (S->tccgen_const_wanted && !(S->tccgen_nocode_wanted & unevalmask))
expect(S, "constant");
- if (0 == S->local_scope)
+ if (0 == S->tccgen_local_scope)
tcc_error(S, "statement expression outside of function");
/* save all registers */
save_regs(S, 0);
@@ -5882,7 +5882,7 @@ ST_FUNC void unary(TCCState *S)
outside, so any reactivation of code emission (from labels
or loop heads) can be disabled again after the end of it. */
block(S, 1);
- S->nocode_wanted = saved_nocode_wanted;
+ S->tccgen_nocode_wanted = saved_nocode_wanted;
skip(S, ')');
} else {
gexpr(S);
@@ -5902,12 +5902,12 @@ ST_FUNC void unary(TCCState *S)
functions are not lvalues, we only have to handle it
there and in function calls. */
/* arrays can also be used although they are not lvalues */
- if ((S->vtop->type.t & VT_BTYPE) != VT_FUNC &&
- !(S->vtop->type.t & VT_ARRAY))
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FUNC &&
+ !(S->tccgen_vtop->type.t & VT_ARRAY))
test_lvalue(S);
- if (S->vtop->sym)
- S->vtop->sym->a.addrtaken = 1;
- mk_pointer(S, &S->vtop->type);
+ if (S->tccgen_vtop->sym)
+ S->tccgen_vtop->sym->a.addrtaken = 1;
+ mk_pointer(S, &S->tccgen_vtop->type);
gaddrof(S);
break;
case '!':
@@ -5924,12 +5924,12 @@ ST_FUNC void unary(TCCState *S)
case '+':
next(S);
unary(S);
- if ((S->vtop->type.t & VT_BTYPE) == VT_PTR)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_PTR)
tcc_error(S, "pointer not accepted for unary plus");
/* In order to force cast, we add zero, except for floating point
where we really need an noop (otherwise -0.0 will be transformed
into +0.0). */
- if (!is_float(S->vtop->type.t)) {
+ if (!is_float(S->tccgen_vtop->type.t)) {
vpushi(S, 0);
gen_op(S, '+');
}
@@ -5938,13 +5938,13 @@ ST_FUNC void unary(TCCState *S)
case TOK_ALIGNOF1:
case TOK_ALIGNOF2:
case TOK_ALIGNOF3:
- t = S->tok;
+ t = S->tccpp_tok;
next(S);
S->tccgen_in_sizeof++;
expr_type(S, &type, unary); /* Perform a in_sizeof = 0; */
s = NULL;
- if (S->vtop[1].r & VT_SYM)
- s = S->vtop[1].sym; /* hack: accessing previous vtop */
+ if (S->tccgen_vtop[1].r & VT_SYM)
+ s = S->tccgen_vtop[1].sym; /* hack: accessing previous vtop */
size = type_size(&type, &align);
if (s && s->a.aligned)
align = 1 << (s->a.aligned - 1);
@@ -5959,7 +5959,7 @@ ST_FUNC void unary(TCCState *S)
} else {
vpushs(S, align);
}
- S->vtop->type.t |= VT_UNSIGNED;
+ S->tccgen_vtop->type.t |= VT_UNSIGNED;
break;
case TOK_builtin_expect:
@@ -5969,10 +5969,10 @@ ST_FUNC void unary(TCCState *S)
break;
case TOK_builtin_types_compatible_p:
parse_builtin_params(S, 0, "tt");
- S->vtop[-1].type.t &= ~(VT_CONSTANT | VT_VOLATILE);
- S->vtop[0].type.t &= ~(VT_CONSTANT | VT_VOLATILE);
- n = is_compatible_types(&S->vtop[-1].type, &S->vtop[0].type);
- S->vtop -= 2;
+ S->tccgen_vtop[-1].type.t &= ~(VT_CONSTANT | VT_VOLATILE);
+ S->tccgen_vtop[0].type.t &= ~(VT_CONSTANT | VT_VOLATILE);
+ n = is_compatible_types(&S->tccgen_vtop[-1].type, &S->tccgen_vtop[0].type);
+ S->tccgen_vtop -= 2;
vpushi(S, n);
break;
case TOK_builtin_choose_expr:
@@ -5983,46 +5983,46 @@ ST_FUNC void unary(TCCState *S)
c = expr_const64(S);
skip(S, ',');
if (!c) {
- S->nocode_wanted++;
+ S->tccgen_nocode_wanted++;
}
expr_eq(S);
if (!c) {
vpop(S);
- S->nocode_wanted--;
+ S->tccgen_nocode_wanted--;
}
skip(S, ',');
if (c) {
- S->nocode_wanted++;
+ S->tccgen_nocode_wanted++;
}
expr_eq(S);
if (c) {
vpop(S);
- S->nocode_wanted--;
+ S->tccgen_nocode_wanted--;
}
skip(S, ')');
}
break;
case TOK_builtin_constant_p:
parse_builtin_params(S, 1, "e");
- n = (S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
- !((S->vtop->r & VT_SYM) && S->vtop->sym->a.addrtaken);
- S->vtop--;
+ n = (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
+ !((S->tccgen_vtop->r & VT_SYM) && S->tccgen_vtop->sym->a.addrtaken);
+ S->tccgen_vtop--;
vpushi(S, n);
break;
case TOK_builtin_frame_address:
case TOK_builtin_return_address:
{
- int tok1 = S->tok;
+ int tok1 = S->tccpp_tok;
int level;
next(S);
skip(S, '(');
- if (S->tok != TOK_CINT) {
+ if (S->tccpp_tok != TOK_CINT) {
tcc_error(S, "%s only takes positive integers",
tok1 == TOK_builtin_return_address ?
"__builtin_return_address" :
"__builtin_frame_address");
}
- level = (uint32_t)S->tokc.i;
+ level = (uint32_t)S->tccpp_tokc.i;
next(S);
skip(S, ')');
type.t = VT_VOID;
@@ -6033,7 +6033,7 @@ ST_FUNC void unary(TCCState *S)
vpushi(S, 2*PTR_SIZE);
gen_op(S, '-');
#endif
- mk_pointer(S, &S->vtop->type);
+ mk_pointer(S, &S->tccgen_vtop->type);
indir(S); /* -> parent frame */
}
if (tok1 == TOK_builtin_return_address) {
@@ -6048,7 +6048,7 @@ ST_FUNC void unary(TCCState *S)
vpushi(S, PTR_SIZE);
gen_op(S, '+');
#endif
- mk_pointer(S, &S->vtop->type);
+ mk_pointer(S, &S->tccgen_vtop->type);
indir(S);
}
}
@@ -6056,7 +6056,7 @@ ST_FUNC void unary(TCCState *S)
#ifdef TCC_TARGET_RISCV64
case TOK_builtin_va_start:
parse_builtin_params(S, 0, "ee");
- r = S->vtop->r & VT_VALMASK;
+ r = S->tccgen_vtop->r & VT_VALMASK;
if (r == VT_LLOCAL)
r = VT_LOCAL;
if (r != VT_LOCAL)
@@ -6069,20 +6069,20 @@ ST_FUNC void unary(TCCState *S)
#ifdef TCC_TARGET_PE
case TOK_builtin_va_start:
parse_builtin_params(S, 0, "ee");
- r = S->vtop->r & VT_VALMASK;
+ r = S->tccgen_vtop->r & VT_VALMASK;
if (r == VT_LLOCAL)
r = VT_LOCAL;
if (r != VT_LOCAL)
tcc_error(S, "__builtin_va_start expects a local variable");
- S->vtop->r = r;
- S->vtop->type = S->char_pointer_type;
- S->vtop->c.i += 8;
+ S->tccgen_vtop->r = r;
+ S->tccgen_vtop->type = S->tccgen_char_pointer_type;
+ S->tccgen_vtop->c.i += 8;
vstore(S);
break;
#else
case TOK_builtin_va_arg_types:
parse_builtin_params(S, 0, "t");
- vpushi(S, classify_x86_64_va_arg(&S->vtop->type));
+ vpushi(S, classify_x86_64_va_arg(&S->tccgen_vtop->type));
vswap(S);
vpop(S);
break;
@@ -6095,23 +6095,23 @@ ST_FUNC void unary(TCCState *S)
//xx check types
gen_va_start(S);
vpushi(S, 0);
- S->vtop->type.t = VT_VOID;
+ S->tccgen_vtop->type.t = VT_VOID;
break;
}
case TOK_builtin_va_arg: {
parse_builtin_params(S, 0, "et");
- type = S->vtop->type;
+ type = S->tccgen_vtop->type;
vpop(S);
//xx check types
gen_va_arg(S, &type);
- S->vtop->type = type;
+ S->tccgen_vtop->type = type;
break;
}
case TOK___arm64_clear_cache: {
parse_builtin_params(S, 0, "ee");
gen_clear_cache(S);
vpushi(S, 0);
- S->vtop->type.t = VT_VOID;
+ S->tccgen_vtop->type.t = VT_VOID;
break;
}
#endif
@@ -6126,13 +6126,13 @@ ST_FUNC void unary(TCCState *S)
case TOK___atomic_fetch_or:
case TOK___atomic_fetch_xor:
case TOK___atomic_fetch_and:
- parse_atomic(S, S->tok);
+ parse_atomic(S, S->tccpp_tok);
break;
/* pre operations */
case TOK_INC:
case TOK_DEC:
- t = S->tok;
+ t = S->tccpp_tok;
next(S);
unary(S);
inc(S, 0, t);
@@ -6140,7 +6140,7 @@ ST_FUNC void unary(TCCState *S)
case '-':
next(S);
unary(S);
- if (is_float(S->vtop->type.t)) {
+ if (is_float(S->tccgen_vtop->type.t)) {
gen_opif(S, TOK_NEG);
} else {
vpushi(S, 0);
@@ -6153,11 +6153,11 @@ ST_FUNC void unary(TCCState *S)
goto tok_identifier;
next(S);
/* allow to take the address of a label */
- if (S->tok < TOK_UIDENT)
+ if (S->tccpp_tok < TOK_UIDENT)
expect(S, "label identifier");
- s = label_find(S, S->tok);
+ s = label_find(S, S->tccpp_tok);
if (!s) {
- s = label_push(S, &S->tccgen_global_label_stack, S->tok, LABEL_FORWARD);
+ s = label_push(S, &S->tccgen_global_label_stack, S->tccpp_tok, LABEL_FORWARD);
} else {
if (s->r == LABEL_DECLARED)
s->r = LABEL_FORWARD;
@@ -6191,7 +6191,7 @@ ST_FUNC void unary(TCCState *S)
for (;;) {
learn = 0;
skip(S, ',');
- if (S->tok == TOK_DEFAULT) {
+ if (S->tccpp_tok == TOK_DEFAULT) {
if (has_default)
tcc_error(S, "too many 'default'");
has_default = 1;
@@ -6224,7 +6224,7 @@ ST_FUNC void unary(TCCState *S)
} else {
skip_or_save_block(S, NULL);
}
- if (S->tok == ')')
+ if (S->tccpp_tok == ')')
break;
}
if (!str) {
@@ -6235,7 +6235,7 @@ ST_FUNC void unary(TCCState *S)
begin_macro(S, str, 1);
next(S);
expr_eq(S);
- if (S->tok != TOK_EOF)
+ if (S->tccpp_tok != TOK_EOF)
expect(S, ",");
end_macro(S);
next(S);
@@ -6246,7 +6246,7 @@ ST_FUNC void unary(TCCState *S)
n = 0x7fc00000;
special_math_val:
vpushi(S, n);
- S->vtop->type.t = VT_FLOAT;
+ S->tccgen_vtop->type.t = VT_FLOAT;
next(S);
break;
case TOK___SNAN__:
@@ -6258,14 +6258,14 @@ special_math_val:
default:
tok_identifier:
- t = S->tok;
+ t = S->tccpp_tok;
next(S);
if (t < TOK_UIDENT)
expect(S, "identifier");
s = sym_find(S, t);
if (!s || IS_ASM_SYM(s)) {
const char *name = get_tok_str(S, t, NULL);
- if (S->tok != '(')
+ if (S->tccpp_tok != '(')
tcc_error(S, "'%s' undeclared", name);
/* for simple function calls, we tolerate undeclared
external reference to int() function */
@@ -6284,84 +6284,84 @@ special_math_val:
/* Point to s as backpointer (even without r&VT_SYM).
Will be used by at least the x86 inline asm parser for
regvars. */
- S->vtop->sym = s;
+ S->tccgen_vtop->sym = s;
if (r & VT_SYM) {
- S->vtop->c.i = 0;
+ S->tccgen_vtop->c.i = 0;
} else if (r == VT_CONST && IS_ENUM_VAL(s->type.t)) {
- S->vtop->c.i = s->enum_val;
+ S->tccgen_vtop->c.i = s->enum_val;
}
break;
}
/* post operations */
while (1) {
- if (S->tok == TOK_INC || S->tok == TOK_DEC) {
- inc(S, 1, S->tok);
+ if (S->tccpp_tok == TOK_INC || S->tccpp_tok == TOK_DEC) {
+ inc(S, 1, S->tccpp_tok);
next(S);
- } else if (S->tok == '.' || S->tok == TOK_ARROW || S->tok == TOK_CDOUBLE) {
+ } else if (S->tccpp_tok == '.' || S->tccpp_tok == TOK_ARROW || S->tccpp_tok == TOK_CDOUBLE) {
int qualifiers, cumofs = 0;
/* field */
- if (S->tok == TOK_ARROW)
+ if (S->tccpp_tok == TOK_ARROW)
indir(S);
- qualifiers = S->vtop->type.t & (VT_CONSTANT | VT_VOLATILE);
+ qualifiers = S->tccgen_vtop->type.t & (VT_CONSTANT | VT_VOLATILE);
test_lvalue(S);
gaddrof(S);
/* expect pointer on structure */
- if ((S->vtop->type.t & VT_BTYPE) != VT_STRUCT)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_STRUCT)
expect(S, "struct or union");
- if (S->tok == TOK_CDOUBLE)
+ if (S->tccpp_tok == TOK_CDOUBLE)
expect(S, "field name");
next(S);
- if (S->tok == TOK_CINT || S->tok == TOK_CUINT)
+ if (S->tccpp_tok == TOK_CINT || S->tccpp_tok == TOK_CUINT)
expect(S, "field name");
- s = find_field(&S->vtop->type, S->tok, &cumofs);
+ s = find_field(&S->tccgen_vtop->type, S->tccpp_tok, &cumofs);
if (!s)
- tcc_error(S, "field not found: %s", get_tok_str(S, S->tok & ~SYM_FIELD, &S->tokc));
+ tcc_error(S, "field not found: %s", get_tok_str(S, S->tccpp_tok & ~SYM_FIELD, &S->tccpp_tokc));
/* add field offset to pointer */
- S->vtop->type = S->char_pointer_type; /* change type to 'char *' */
+ S->tccgen_vtop->type = S->tccgen_char_pointer_type; /* change type to 'char *' */
vpushi(S, cumofs + s->c);
gen_op(S, '+');
/* change type to field type, and set to lvalue */
- S->vtop->type = s->type;
- S->vtop->type.t |= qualifiers;
+ S->tccgen_vtop->type = s->type;
+ S->tccgen_vtop->type.t |= qualifiers;
/* an array is never an lvalue */
- if (!(S->vtop->type.t & VT_ARRAY)) {
- S->vtop->r |= VT_LVAL;
+ if (!(S->tccgen_vtop->type.t & VT_ARRAY)) {
+ S->tccgen_vtop->r |= VT_LVAL;
#ifdef CONFIG_TCC_BCHECK
/* if bound checking, the referenced pointer must be checked */
if (S->do_bounds_check)
- S->vtop->r |= VT_MUSTBOUND;
+ S->tccgen_vtop->r |= VT_MUSTBOUND;
#endif
}
next(S);
- } else if (S->tok == '[') {
+ } else if (S->tccpp_tok == '[') {
next(S);
gexpr(S);
gen_op(S, '+');
indir(S);
skip(S, ']');
- } else if (S->tok == '(') {
+ } else if (S->tccpp_tok == '(') {
SValue ret;
Sym *sa;
int nb_args, ret_nregs, ret_align, regsize, variadic;
/* function call */
- if ((S->vtop->type.t & VT_BTYPE) != VT_FUNC) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FUNC) {
/* pointer test (no array accepted) */
- if ((S->vtop->type.t & (VT_BTYPE | VT_ARRAY)) == VT_PTR) {
- S->vtop->type = *pointed_type(&S->vtop->type);
- if ((S->vtop->type.t & VT_BTYPE) != VT_FUNC)
+ if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_ARRAY)) == VT_PTR) {
+ S->tccgen_vtop->type = *pointed_type(&S->tccgen_vtop->type);
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_FUNC)
goto error_func;
} else {
error_func:
expect(S, "function pointer");
}
} else {
- S->vtop->r &= ~VT_LVAL; /* no lvalue */
+ S->tccgen_vtop->r &= ~VT_LVAL; /* no lvalue */
}
/* get return type */
- s = S->vtop->type.ref;
+ s = S->tccgen_vtop->type.ref;
next(S);
sa = s->next; /* first parameter */
nb_args = regsize = 0;
@@ -6383,19 +6383,19 @@ special_math_val:
while (size & (size - 1))
size = (size | (size - 1)) + 1;
#endif
- S->loc = (S->loc - size) & -align;
+ S->tccgen_loc = (S->tccgen_loc - size) & -align;
ret.type = s->type;
ret.r = VT_LOCAL | VT_LVAL;
/* pass it as 'int' to avoid structure arg passing
problems */
- vseti(S, VT_LOCAL, S->loc);
+ vseti(S, VT_LOCAL, S->tccgen_loc);
#ifdef CONFIG_TCC_BCHECK
if (S->do_bounds_check)
- --S->loc;
+ --S->tccgen_loc;
#endif
- ret.c = S->vtop->c;
+ ret.c = S->tccgen_vtop->c;
if (ret_nregs < 0)
- S->vtop--;
+ S->tccgen_vtop--;
else
nb_args++;
}
@@ -6409,14 +6409,14 @@ special_math_val:
ret.c.i = 0;
PUT_R_RET(&ret, ret.type.t);
}
- if (S->tok != ')') {
+ if (S->tccpp_tok != ')') {
for(;;) {
expr_eq(S);
gfunc_param_typed(S, s, sa);
nb_args++;
if (sa)
sa = sa->next;
- if (S->tok == ')')
+ if (S->tccpp_tok == ')')
break;
skip(S, ',');
}
@@ -6435,7 +6435,7 @@ special_math_val:
/* return value */
for (r = ret.r + ret_nregs + !ret_nregs; r-- > ret.r;) {
vsetc(S, &ret.type, r, &ret.c);
- S->vtop->r2 = ret.r2; /* Loop only happens when r2 is VT_CONST */
+ S->tccgen_vtop->r2 = ret.r2; /* Loop only happens when r2 is VT_CONST */
}
/* handle packed struct return */
@@ -6447,14 +6447,14 @@ special_math_val:
space. Assume register size is power of 2. */
if (regsize > align)
align = regsize;
- S->loc = (S->loc - size) & -align;
- addr = S->loc;
+ S->tccgen_loc = (S->tccgen_loc - size) & -align;
+ addr = S->tccgen_loc;
offset = 0;
for (;;) {
vset(S, &ret.type, VT_LOCAL | VT_LVAL, addr + offset);
vswap(S);
vstore(S);
- S->vtop--;
+ S->tccgen_vtop--;
if (--ret_nregs == 0)
break;
offset += regsize;
@@ -6470,9 +6470,9 @@ special_math_val:
t = s->type.t & VT_BTYPE;
if (t == VT_BYTE || t == VT_SHORT || t == VT_BOOL) {
#ifdef PROMOTE_RET
- S->vtop->r |= BFVAL(VT_MUSTCAST, 1);
+ S->tccgen_vtop->r |= BFVAL(VT_MUSTCAST, 1);
#else
- S->vtop->type.t = VT_INT;
+ S->tccgen_vtop->type.t = VT_INT;
#endif
}
}
@@ -6494,7 +6494,7 @@ static void expr_prod(void)
int t;
unary(S);
- while ((t = Stok) == '*' || t == '/' || t == '%') {
+ while ((t = Stccpp_tok) == '*' || t == '/' || t == '%') {
next(S);
unary(S);
gen_op(S, t);
@@ -6506,7 +6506,7 @@ static void expr_sum(void)
int t;
expr_prod();
- while ((t = Stok) == '+' || t == '-') {
+ while ((t = Stccpp_tok) == '+' || t == '-') {
next(S);
expr_prod();
gen_op(S, t);
@@ -6518,7 +6518,7 @@ static void expr_shift(void)
int t;
expr_sum();
- while ((t = Stok) == TOK_SHL || t == TOK_SAR) {
+ while ((t = Stccpp_tok) == TOK_SHL || t == TOK_SAR) {
next(S);
expr_sum();
gen_op(S, t);
@@ -6530,7 +6530,7 @@ static void expr_cmp(void)
int t;
expr_shift();
- while (((t = Stok) >= TOK_ULE && t <= TOK_GT) ||
+ while (((t = Stccpp_tok) >= TOK_ULE && t <= TOK_GT) ||
t == TOK_ULT || t == TOK_UGE) {
next(S);
expr_shift();
@@ -6543,7 +6543,7 @@ static void expr_cmpeq(void)
int t;
expr_cmp();
- while ((t = Stok) == TOK_EQ || t == TOK_NE) {
+ while ((t = Stccpp_tok) == TOK_EQ || t == TOK_NE) {
next(S);
expr_cmp();
gen_op(S, t);
@@ -6553,7 +6553,7 @@ static void expr_cmpeq(void)
static void expr_and(void)
{
expr_cmpeq();
- while (Stok == '&') {
+ while (Stccpp_tok == '&') {
next(S);
expr_cmpeq();
gen_op(S, '&');
@@ -6563,7 +6563,7 @@ static void expr_and(void)
static void expr_xor(void)
{
expr_and();
- while (Stok == '^') {
+ while (Stccpp_tok == '^') {
next(S);
expr_and();
gen_op(S, '^');
@@ -6573,7 +6573,7 @@ static void expr_xor(void)
static void expr_or(void)
{
expr_xor();
- while (Stok == '|') {
+ while (Stccpp_tok == '|') {
next(S);
expr_xor();
gen_op(S, '|');
@@ -6585,15 +6585,15 @@ static void expr_landor(S, int op);
static void expr_land(void)
{
expr_or();
- if (Stok == TOK_LAND)
- expr_landor(S, Stok);
+ if (Stccpp_tok == TOK_LAND)
+ expr_landor(S, Stccpp_tok);
}
static void expr_lor(void)
{
expr_land();
- if (Stok == TOK_LOR)
- expr_landor(S, Stok);
+ if (Stccpp_tok == TOK_LOR)
+ expr_landor(S, Stccpp_tok);
}
# define expr_landor_next(op) op == TOK_LAND ? expr_or() : expr_land()
@@ -6620,7 +6620,7 @@ static int precedence(int tok)
return 0;
}
}
-static void init_prec(TCCState *S)
+static void init_prec(TCCState* S)
{
int i;
for (i = 0; i < 256; i++)
@@ -6628,22 +6628,22 @@ static void init_prec(TCCState *S)
}
#define precedence(i) ((unsigned)i < 256 ? S->tccgen_prec[i] : 0)
-static void expr_landor(TCCState *S, int op);
+static void expr_landor(TCCState* S, int op);
-static void expr_infix(TCCState *S, int p)
+static void expr_infix(TCCState* S, int p)
{
- int t = S->tok, p2;
+ int t = S->tccpp_tok, p2;
while ((p2 = precedence(t)) >= p) {
if (t == TOK_LOR || t == TOK_LAND) {
expr_landor(S, t);
} else {
next(S);
unary(S);
- if (precedence(S->tok) > p2)
+ if (precedence(S->tccpp_tok) > p2)
expr_infix(S, p2 + 1);
gen_op(S, t);
}
- t = S->tok;
+ t = S->tccpp_tok;
}
}
#endif
@@ -6651,20 +6651,20 @@ static void expr_infix(TCCState *S, int p)
/* Assuming vtop is a value used in a conditional context
(i.e. compared with zero) return 0 if it's false, 1 if
true and -1 if it can't be statically determined. */
-static int condition_3way(TCCState *S)
+static int condition_3way(TCCState* S)
{
int c = -1;
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
- (!(S->vtop->r & VT_SYM) || !S->vtop->sym->a.weak)) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
+ (!(S->tccgen_vtop->r & VT_SYM) || !S->tccgen_vtop->sym->a.weak)) {
vdup(S);
gen_cast_s(S, VT_BOOL);
- c = S->vtop->c.i;
+ c = S->tccgen_vtop->c.i;
vpop(S);
}
return c;
}
-static void expr_landor(TCCState *S, int op)
+static void expr_landor(TCCState* S, int op)
{
int t = 0, cc = 1, f = 0, i = op == TOK_LAND, c;
for(;;) {
@@ -6672,8 +6672,8 @@ static void expr_landor(TCCState *S, int op)
if (c < 0)
save_regs(S, 1), cc = 0;
else if (c != i)
- S->nocode_wanted++, f = 1;
- if (S->tok != op)
+ S->tccgen_nocode_wanted++, f = 1;
+ if (S->tccpp_tok != op)
break;
if (c < 0)
t = gvtst(S, i, t);
@@ -6686,7 +6686,7 @@ static void expr_landor(TCCState *S, int op)
vpop(S);
vpushi(S, i ^ f);
gsym(S, t);
- S->nocode_wanted -= f;
+ S->tccgen_nocode_wanted -= f;
} else {
gvtst_set(S, i, t);
}
@@ -6702,7 +6702,7 @@ static int is_cond_bool(SValue *sv)
return 0;
}
-static void expr_cond(TCCState *S)
+static void expr_cond(TCCState* S)
{
int tt, u, r1, r2, rc, t1, t2, islv, c, g;
SValue sv;
@@ -6710,10 +6710,10 @@ static void expr_cond(TCCState *S)
int ncw_prev;
expr_lor();
- if (S->tok == '?') {
+ if (S->tccpp_tok == '?') {
next(S);
c = condition_3way(S);
- g = (S->tok == ':' && gnu_ext);
+ g = (S->tccpp_tok == ':' && gnu_ext);
tt = 0;
if (!g) {
if (c < 0) {
@@ -6730,16 +6730,16 @@ static void expr_cond(TCCState *S)
tt = gvtst(S, 0, 0);
}
- ncw_prev = S->nocode_wanted;
+ ncw_prev = S->tccgen_nocode_wanted;
if (c == 0)
- S->nocode_wanted++;
+ S->tccgen_nocode_wanted++;
if (!g)
gexpr(S);
- if ((S->vtop->type.t & VT_BTYPE) == VT_FUNC)
- mk_pointer(S, &S->vtop->type);
- sv = *S->vtop; /* save value to handle it later */
- S->vtop--; /* no vpop so that FP stack is not flushed */
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FUNC)
+ mk_pointer(S, &S->tccgen_vtop->type);
+ sv = *S->tccgen_vtop; /* save value to handle it later */
+ S->tccgen_vtop--; /* no vpop so that FP stack is not flushed */
if (g) {
u = tt;
@@ -6749,13 +6749,13 @@ static void expr_cond(TCCState *S)
} else
u = 0;
- S->nocode_wanted = ncw_prev;
+ S->tccgen_nocode_wanted = ncw_prev;
if (c == 1)
- S->nocode_wanted++;
+ S->tccgen_nocode_wanted++;
skip(S, ':');
expr_cond(S);
- if (c < 0 && is_cond_bool(S->vtop) && is_cond_bool(&sv)) {
+ if (c < 0 && is_cond_bool(S->tccgen_vtop) && is_cond_bool(&sv)) {
/* optimize "if (f ? a > b : c || d) ..." for example, where normally
"a < b" and "c || d" would be forced to "(int)0/1" first, whereas
this code jumps directly to the if's then/else branches. */
@@ -6766,29 +6766,29 @@ static void expr_cond(TCCState *S)
/* combine jump targets of 2nd op with VT_CMP of 1st op */
gvtst_set(S, 0, t1);
gvtst_set(S, 1, t2);
- S->nocode_wanted = ncw_prev;
+ S->tccgen_nocode_wanted = ncw_prev;
// tcc_warning(S, "two conditions expr_cond");
return;
}
- if ((S->vtop->type.t & VT_BTYPE) == VT_FUNC)
- mk_pointer(S, &S->vtop->type);
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_FUNC)
+ mk_pointer(S, &S->tccgen_vtop->type);
/* cast operands to correct type according to ISOC rules */
- if (!combine_types(S, &type, &sv, S->vtop, '?'))
- type_incompatibility_error(S, &sv.type, &S->vtop->type,
+ if (!combine_types(S, &type, &sv, S->tccgen_vtop, '?'))
+ type_incompatibility_error(S, &sv.type, &S->tccgen_vtop->type,
"type mismatch in conditional expression (have '%s' and '%s')");
/* keep structs lvalue by transforming `(expr ? a : b)` to `*(expr ? &a : &b)` so
that `(expr ? a : b).mem` does not error with "lvalue expected" */
- islv = (S->vtop->r & VT_LVAL) && (sv.r & VT_LVAL) && VT_STRUCT == (type.t & VT_BTYPE);
+ islv = (S->tccgen_vtop->r & VT_LVAL) && (sv.r & VT_LVAL) && VT_STRUCT == (type.t & VT_BTYPE);
/* now we convert second operand */
if (c != 1) {
gen_cast(S, &type);
if (islv) {
- mk_pointer(S, &S->vtop->type);
+ mk_pointer(S, &S->tccgen_vtop->type);
gaddrof(S);
- } else if (VT_STRUCT == (S->vtop->type.t & VT_BTYPE))
+ } else if (VT_STRUCT == (S->tccgen_vtop->type.t & VT_BTYPE))
gaddrof(S);
}
@@ -6804,24 +6804,24 @@ static void expr_cond(TCCState *S)
tt = gjmp(S, 0);
}
gsym(S, u);
- S->nocode_wanted = ncw_prev;
+ S->tccgen_nocode_wanted = ncw_prev;
/* this is horrible, but we must also convert first
operand */
if (c != 0) {
- *S->vtop = sv;
+ *S->tccgen_vtop = sv;
gen_cast(S, &type);
if (islv) {
- mk_pointer(S, &S->vtop->type);
+ mk_pointer(S, &S->tccgen_vtop->type);
gaddrof(S);
- } else if (VT_STRUCT == (S->vtop->type.t & VT_BTYPE))
+ } else if (VT_STRUCT == (S->tccgen_vtop->type.t & VT_BTYPE))
gaddrof(S);
}
if (c < 0) {
r1 = gv(S, rc);
move_reg(S, r2, r1, islv ? VT_PTR : type.t);
- S->vtop->r = r2;
+ S->tccgen_vtop->r = r2;
gsym(S, tt);
}
@@ -6830,12 +6830,12 @@ static void expr_cond(TCCState *S)
}
}
-static void expr_eq(TCCState *S)
+static void expr_eq(TCCState* S)
{
int t;
expr_cond(S);
- if ((t = S->tok) == '=' || TOK_ASSIGN(t)) {
+ if ((t = S->tccpp_tok) == '=' || TOK_ASSIGN(t)) {
test_lvalue(S);
next(S);
if (t == '=') {
@@ -6849,11 +6849,11 @@ static void expr_eq(TCCState *S)
}
}
-ST_FUNC void gexpr(TCCState *S)
+ST_FUNC void gexpr(TCCState* S)
{
while (1) {
expr_eq(S);
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
break;
vpop(S);
next(S);
@@ -6861,30 +6861,30 @@ ST_FUNC void gexpr(TCCState *S)
}
/* parse a constant expression and return value in vtop. */
-static void expr_const1(TCCState *S)
+static void expr_const1(TCCState* S)
{
S->tccgen_const_wanted++;
- S->nocode_wanted += unevalmask + 1;
+ S->tccgen_nocode_wanted += unevalmask + 1;
expr_cond(S);
- S->nocode_wanted -= unevalmask + 1;
+ S->tccgen_nocode_wanted -= unevalmask + 1;
S->tccgen_const_wanted--;
}
/* parse an integer constant and return its value. */
-static inline int64_t expr_const64(TCCState *S)
+static inline int64_t expr_const64(TCCState* S)
{
int64_t c;
expr_const1(S);
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
expect(S, "constant expression");
- c = S->vtop->c.i;
+ c = S->tccgen_vtop->c.i;
vpop(S);
return c;
}
/* parse an integer constant and return its value.
Complain if it doesn't fit 32bit (signed or unsigned). */
-ST_FUNC int expr_const(TCCState *S)
+ST_FUNC int expr_const(TCCState* S)
{
int c;
int64_t wc = expr_const64(S);
@@ -6898,7 +6898,7 @@ ST_FUNC int expr_const(TCCState *S)
/* return from function */
#ifndef TCC_TARGET_ARM64
-static void gfunc_return(TCCState *S, CType *func_type)
+static void gfunc_return(TCCState* S, CType *func_type)
{
if ((func_type->t & VT_BTYPE) == VT_STRUCT) {
CType type, ret_type;
@@ -6923,11 +6923,11 @@ static void gfunc_return(TCCState *S, CType *func_type)
/* returning structure packed into registers */
int size, addr, align, rc;
size = type_size(func_type,&align);
- if ((S->vtop->r != (VT_LOCAL | VT_LVAL) ||
- (S->vtop->c.i & (ret_align-1)))
+ if ((S->tccgen_vtop->r != (VT_LOCAL | VT_LVAL) ||
+ (S->tccgen_vtop->c.i & (ret_align-1)))
&& (align & (ret_align-1))) {
- S->loc = (S->loc - size) & -ret_align;
- addr = S->loc;
+ S->tccgen_loc = (S->tccgen_loc - size) & -ret_align;
+ addr = S->tccgen_loc;
type = *func_type;
vset(S, &type, VT_LOCAL | VT_LVAL, addr);
vswap(S);
@@ -6935,7 +6935,7 @@ static void gfunc_return(TCCState *S, CType *func_type)
vpop(S);
vset(S, &ret_type, VT_LOCAL | VT_LVAL, addr);
}
- S->vtop->type = ret_type;
+ S->tccgen_vtop->type = ret_type;
rc = RC_RET(ret_type.t);
if (ret_nregs == 1)
gv(S, rc);
@@ -6950,18 +6950,18 @@ static void gfunc_return(TCCState *S, CType *func_type)
registers, their classes are consecutive values of the
suite s(n) = 2^n */
rc <<= 1;
- S->vtop->c.i += regsize;
+ S->tccgen_vtop->c.i += regsize;
}
}
}
} else {
gv(S, RC_RET(func_type->t));
}
- S->vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
+ S->tccgen_vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
}
#endif
-static void check_func_return(TCCState *S)
+static void check_func_return(TCCState* S)
{
if ((S->tccgen_func_vt.t & VT_BTYPE) == VT_VOID)
return;
@@ -6993,16 +6993,16 @@ static int case_cmpu(const void *pa, const void *pb)
return a < b ? -1 : a > b;
}
-static void gtst_addr(TCCState *S, int t, int a)
+static void gtst_addr(TCCState* S, int t, int a)
{
gsym_addr(S, gvtst(S, 0, t), a);
}
-static void gcase(TCCState *S, struct case_t **base, int len, int *bsym)
+static void gcase(TCCState* S, struct case_t **base, int len, int *bsym)
{
struct case_t *p;
int e;
- int ll = (S->vtop->type.t & VT_BTYPE) == VT_LLONG;
+ int ll = (S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG;
while (len > 8) {
/* binary search */
p = base[len/2];
@@ -7057,7 +7057,7 @@ static void gcase(TCCState *S, struct case_t **base, int len, int *bsym)
/* ------------------------------------------------------------------------- */
/* __attribute__((cleanup(fn))) */
-static void try_call_scope_cleanup(TCCState *S, Sym *stop)
+static void try_call_scope_cleanup(TCCState* S, Sym *stop)
{
Sym *cls = S->tccgen_cur_scope->cl.s;
@@ -7067,14 +7067,14 @@ static void try_call_scope_cleanup(TCCState *S, Sym *stop)
vpushsym(S, &fs->type, fs);
vset(S, &vs->type, vs->r, vs->c);
- S->vtop->sym = vs;
- mk_pointer(S, &S->vtop->type);
+ S->tccgen_vtop->sym = vs;
+ mk_pointer(S, &S->tccgen_vtop->type);
gaddrof(S);
gfunc_call(S, 1);
}
}
-static void try_call_cleanup_goto(TCCState *S, Sym *cleanupstate)
+static void try_call_cleanup_goto(TCCState* S, Sym *cleanupstate)
{
Sym *oc, *cc;
int ocd, ccd;
@@ -7095,7 +7095,7 @@ static void try_call_cleanup_goto(TCCState *S, Sym *cleanupstate)
}
/* call 'func' for each __attribute__((cleanup(func))) */
-static void block_cleanup(TCCState *S, scope_t *o)
+static void block_cleanup(TCCState* S, scope_t *o)
{
int jmp = 0;
Sym *g, **pg;
@@ -7143,7 +7143,7 @@ static void vla_leave(TCCState * S, scope_t *o)
/* ------------------------------------------------------------------------- */
/* local scopes */
-static void new_scope(TCCState *S, scope_t *o)
+static void new_scope(TCCState* S, scope_t *o)
{
/* copy and link previous scope */
*o = *S->tccgen_cur_scope;
@@ -7152,15 +7152,15 @@ static void new_scope(TCCState *S, scope_t *o)
S->tccgen_cur_scope->vla.num = 0;
/* record local declaration stack position */
- o->lstk = S->local_stack;
- o->llstk = S->local_label_stack;
- ++S->local_scope;
+ o->lstk = S->tccgen_local_stack;
+ o->llstk = S->tccgen_local_label_stack;
+ ++S->tccgen_local_scope;
if (S->tccgen_debug_modes)
- tcc_debug_stabn(S, N_LBRAC, S->ind - S->tccgen_func_ind);
+ tcc_debug_stabn(S, N_LBRAC, S->tccgen_ind - S->tccgen_func_ind);
}
-static void prev_scope(TCCState *S, scope_t *o, int is_expr)
+static void prev_scope(TCCState* S, scope_t *o, int is_expr)
{
vla_leave(S, o->prev);
@@ -7168,7 +7168,7 @@ static void prev_scope(TCCState *S, scope_t *o, int is_expr)
block_cleanup(S, o->prev);
/* pop locally defined labels */
- label_pop(S, &S->local_label_stack, o->llstk, is_expr);
+ label_pop(S, &S->tccgen_local_label_stack, o->llstk, is_expr);
/* In the is_expr case (a statement expression is finished here),
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)
/* pop locally defined symbols */
pop_local_syms(S, o->lstk, is_expr);
S->tccgen_cur_scope = o->prev;
- --S->local_scope;
+ --S->tccgen_local_scope;
if (S->tccgen_debug_modes)
- tcc_debug_stabn(S, N_RBRAC, S->ind - S->tccgen_func_ind);
+ tcc_debug_stabn(S, N_RBRAC, S->tccgen_ind - S->tccgen_func_ind);
}
/* leave a scope via break/continue(/goto) */
-static void leave_scope(TCCState *S, scope_t *o)
+static void leave_scope(TCCState* S, scope_t *o)
{
if (!o)
return;
@@ -7199,7 +7199,7 @@ static void leave_scope(TCCState *S, scope_t *o)
/* ------------------------------------------------------------------------- */
/* call block from 'for do while' loops */
-static void lblock(TCCState *S, int *bsym, int *csym)
+static void lblock(TCCState* S, int *bsym, int *csym)
{
scope_t *lo = S->tccgen_loop_scope, *co = S->tccgen_cur_scope;
int *b = co->bsym, *c = co->csym;
@@ -7216,7 +7216,7 @@ static void lblock(TCCState *S, int *bsym, int *csym)
}
}
-static void block(TCCState *S, int is_expr)
+static void block(TCCState* S, int is_expr)
{
int a, b, c, d, e, t;
scope_t o;
@@ -7225,11 +7225,11 @@ static void block(TCCState *S, int is_expr)
if (is_expr) {
/* default return value is (void) */
vpushi(S, 0);
- S->vtop->type.t = VT_VOID;
+ S->tccgen_vtop->type.t = VT_VOID;
}
again:
- t = S->tok;
+ t = S->tccpp_tok;
/* If the token carries a value, next() might destroy it. Only with
invalid code such as f(){"123"4;} */
if (TOK_HAS_VALUE(t))
@@ -7245,7 +7245,7 @@ again:
skip(S, ')');
a = gvtst(S, 1, 0);
block(S, 0);
- if (S->tok == TOK_ELSE) {
+ if (S->tccpp_tok == TOK_ELSE) {
d = gjmp(S, 0);
gsym(S, a);
next(S);
@@ -7271,20 +7271,20 @@ again:
new_scope(S, &o);
/* handle local labels declarations */
- while (S->tok == TOK_LABEL) {
+ while (S->tccpp_tok == TOK_LABEL) {
do {
next(S);
- if (S->tok < TOK_UIDENT)
+ if (S->tccpp_tok < TOK_UIDENT)
expect(S, "label identifier");
- label_push(S, &S->local_label_stack, S->tok, LABEL_DECLARED);
+ label_push(S, &S->tccgen_local_label_stack, S->tccpp_tok, LABEL_DECLARED);
next(S);
- } while (S->tok == ',');
+ } while (S->tccpp_tok == ',');
skip(S, ';');
}
- while (S->tok != '}') {
+ while (S->tccpp_tok != '}') {
decl(S, VT_LOCAL);
- if (S->tok != '}') {
+ if (S->tccpp_tok != '}') {
if (is_expr)
vpop(S);
block(S, is_expr);
@@ -7292,21 +7292,21 @@ again:
}
prev_scope(S, &o, is_expr);
- if (S->local_scope)
+ if (S->tccgen_local_scope)
next(S);
- else if (!S->nocode_wanted)
+ else if (!S->tccgen_nocode_wanted)
check_func_return(S);
} else if (t == TOK_RETURN) {
b = (S->tccgen_func_vt.t & VT_BTYPE) != VT_VOID;
- if (S->tok != ';') {
+ if (S->tccpp_tok != ';') {
gexpr(S);
if (b) {
gen_assign_cast(S, &S->tccgen_func_vt);
} else {
- if (S->vtop->type.t != VT_VOID)
+ if (S->tccgen_vtop->type.t != VT_VOID)
tcc_warning(S, "void function returns a value");
- S->vtop--;
+ S->tccgen_vtop--;
}
} else if (b) {
tcc_warning(S, "'return' with no value");
@@ -7317,7 +7317,7 @@ again:
gfunc_return(S, &S->tccgen_func_vt);
skip(S, ';');
/* jump unless last stmt in top-level block */
- if (S->tok != '}' || S->local_scope != 1)
+ if (S->tccpp_tok != '}' || S->tccgen_local_scope != 1)
S->tccgen_rsym = gjmp(S, S->tccgen_rsym);
if (S->tccgen_debug_modes)
tcc_tcov_block_end (S, S->tccgen_tcov_data.line);
@@ -7346,7 +7346,7 @@ again:
new_scope(S, &o);
skip(S, '(');
- if (S->tok != ';') {
+ if (S->tccpp_tok != ';') {
/* c99 for-loop init decl? */
if (!decl0(S, VT_LOCAL, 1, NULL)) {
/* no, regular for-loop init expr */
@@ -7357,12 +7357,12 @@ again:
skip(S, ';');
a = b = 0;
c = d = gind(S);
- if (S->tok != ';') {
+ if (S->tccpp_tok != ';') {
gexpr(S);
a = gvtst(S, 1, 0);
}
skip(S, ';');
- if (S->tok != ')') {
+ if (S->tccpp_tok != ')') {
e = gjmp(S, 0);
d = gind(S);
gexpr(S);
@@ -7403,7 +7403,7 @@ again:
skip(S, '(');
gexpr(S);
skip(S, ')');
- sw->sv = *S->vtop--; /* save switch value */
+ sw->sv = *S->tccgen_vtop--; /* save switch value */
a = 0;
b = gjmp(S, 0); /* jump to first case */
@@ -7443,7 +7443,7 @@ again:
if (!S->tccgen_cur_switch)
expect(S, "switch");
cr->v1 = cr->v2 = expr_const64(S);
- if (gnu_ext && S->tok == TOK_DOTS) {
+ if (gnu_ext && S->tccpp_tok == TOK_DOTS) {
next(S);
cr->v2 = expr_const64(S);
if ((!(S->tccgen_cur_switch->sv.type.t & VT_UNSIGNED) && cr->v2 < cr->v1)
@@ -7471,25 +7471,25 @@ again:
} else if (t == TOK_GOTO) {
if (S->tccgen_cur_scope->vla.num)
vla_restore(S, S->tccgen_cur_scope->vla.locorig);
- if (S->tok == '*' && gnu_ext) {
+ if (S->tccpp_tok == '*' && gnu_ext) {
/* computed goto */
next(S);
gexpr(S);
- if ((S->vtop->type.t & VT_BTYPE) != VT_PTR)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) != VT_PTR)
expect(S, "pointer");
ggoto(S);
- } else if (S->tok >= TOK_UIDENT) {
- s = label_find(S, S->tok);
+ } else if (S->tccpp_tok >= TOK_UIDENT) {
+ s = label_find(S, S->tccpp_tok);
/* put forward definition if needed */
if (!s)
- s = label_push(S, &S->tccgen_global_label_stack, S->tok, LABEL_FORWARD);
+ s = label_push(S, &S->tccgen_global_label_stack, S->tccpp_tok, LABEL_FORWARD);
else if (s->r == LABEL_DECLARED)
s->r = LABEL_FORWARD;
if (s->r & LABEL_FORWARD) {
/* start new goto chain for cleanups, linked via label->next */
- if (S->tccgen_cur_scope->cl.s && !S->nocode_wanted) {
+ if (S->tccgen_cur_scope->cl.s && !S->tccgen_nocode_wanted) {
sym_push2(S, &S->tccgen_pending_gotos, SYM_FIELD, 0, S->tccgen_cur_scope->cl.n);
S->tccgen_pending_gotos->prev_tok = s;
s = sym_push2(S, &s->next, SYM_FIELD, 0, 0);
@@ -7511,7 +7511,7 @@ again:
asm_instr(S);
} else {
- if (S->tok == ':' && t >= TOK_UIDENT) {
+ if (S->tccpp_tok == ':' && t >= TOK_UIDENT) {
/* label case */
next(S);
s = label_find(S, t);
@@ -7534,7 +7534,7 @@ again:
block_after_label:
vla_restore(S, S->tccgen_cur_scope->vla.loc);
- if (S->tok != '}')
+ if (S->tccpp_tok != '}')
goto again;
/* we accept this, but it is a mistake */
tcc_warning_c(warn_all)(S, "deprecated use of label at end of compound statement");
@@ -7565,16 +7565,16 @@ again:
with a '{'). If STR then allocates and stores the skipped tokens
in *STR. This doesn't check if () and {} are nested correctly,
i.e. "({)}" is accepted. */
-static void skip_or_save_block(TCCState *S, TokenString **str)
+static void skip_or_save_block(TCCState* S, TokenString **str)
{
- int braces = S->tok == '{';
+ int braces = S->tccpp_tok == '{';
int level = 0;
if (str)
*str = tok_str_alloc(S);
- while ((level > 0 || (S->tok != '}' && S->tok != ',' && S->tok != ';' && S->tok != ')'))) {
+ while ((level > 0 || (S->tccpp_tok != '}' && S->tccpp_tok != ',' && S->tccpp_tok != ';' && S->tccpp_tok != ')'))) {
int t;
- if (S->tok == TOK_EOF) {
+ if (S->tccpp_tok == TOK_EOF) {
if (str || level > 0)
tcc_error(S, "unexpected end of file");
else
@@ -7582,7 +7582,7 @@ static void skip_or_save_block(TCCState *S, TokenString **str)
}
if (str)
tok_str_add_tok(S, *str);
- t = S->tok;
+ t = S->tccpp_tok;
next(S);
if (t == '{' || t == '(') {
level++;
@@ -7601,7 +7601,7 @@ static void skip_or_save_block(TCCState *S, TokenString **str)
#define EXPR_CONST 1
#define EXPR_ANY 2
-static void parse_init_elem(TCCState *S, int expr_type)
+static void parse_init_elem(TCCState* S, int expr_type)
{
int saved_global_expr;
switch(expr_type) {
@@ -7613,11 +7613,11 @@ static void parse_init_elem(TCCState *S, int expr_type)
S->tccgen_global_expr = saved_global_expr;
/* NOTE: symbols are accepted, as well as lvalue for anon symbols
(compound literals). */
- if (((S->vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST
- && ((S->vtop->r & (VT_SYM|VT_LVAL)) != (VT_SYM|VT_LVAL)
- || S->vtop->sym->v < SYM_FIRST_ANOM))
+ if (((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST
+ && ((S->tccgen_vtop->r & (VT_SYM|VT_LVAL)) != (VT_SYM|VT_LVAL)
+ || S->tccgen_vtop->sym->v < SYM_FIRST_ANOM))
#ifdef TCC_TARGET_PE
- || ((S->vtop->r & VT_SYM) && S->vtop->sym->a.dllimport)
+ || ((S->tccgen_vtop->r & VT_SYM) && S->tccgen_vtop->sym->a.dllimport)
#endif
)
tcc_error(S, "initializer element is not constant");
@@ -7629,10 +7629,10 @@ static void parse_init_elem(TCCState *S, int expr_type)
}
#if 1
-static void init_assert(TCCState *S, init_params *p, int offset)
+static void init_assert(TCCState* S, init_params *p, int offset)
{
if (p->sec ? !NODATA_WANTED && offset > p->sec->data_offset
- : !S->nocode_wanted && offset > p->local_offset)
+ : !S->tccgen_nocode_wanted && offset > p->local_offset)
tcc_internal_error(S, "initializer overflow");
}
#else
@@ -7640,7 +7640,7 @@ static void init_assert(TCCState *S, init_params *p, int offset)
#endif
/* put zeros for variable based init */
-static void init_putz(TCCState *S, init_params *p, unsigned long c, int size)
+static void init_putz(TCCState* S, init_params *p, unsigned long c, int size)
{
init_assert(S, p, c + size);
if (p->sec) {
@@ -7685,7 +7685,7 @@ static void decl_design_delrels(Section *sec, int c, int size)
}
}
-static void decl_design_flex(TCCState *S, init_params *p, Sym *ref, int index)
+static void decl_design_flex(TCCState* S, init_params *p, Sym *ref, int index)
{
if (ref == p->flex_array_ref) {
if (index >= ref->c)
@@ -7700,7 +7700,7 @@ static void decl_design_flex(TCCState *S, init_params *p, Sym *ref, int index)
index. 'flags' is as in decl_initializer.
'al' contains the already initialized length of the
current container (starting at c). This returns the new length of that. */
-static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned long c,
+static int decl_designator(TCCState* S, init_params *p, CType *type, unsigned long c,
Sym **cur_field, int flags, int al)
{
Sym *s, *f;
@@ -7713,21 +7713,21 @@ static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned lo
if (flags & DIF_HAVE_ELEM)
goto no_designator;
- if (gnu_ext && S->tok >= TOK_UIDENT) {
- l = S->tok, next(S);
- if (S->tok == ':')
+ if (gnu_ext && S->tccpp_tok >= TOK_UIDENT) {
+ l = S->tccpp_tok, next(S);
+ if (S->tccpp_tok == ':')
goto struct_field;
unget_tok(S, l);
}
/* NOTE: we only support ranges for last designator */
- while (nb_elems == 1 && (S->tok == '[' || S->tok == '.')) {
- if (S->tok == '[') {
+ while (nb_elems == 1 && (S->tccpp_tok == '[' || S->tccpp_tok == '.')) {
+ if (S->tccpp_tok == '[') {
if (!(type->t & VT_ARRAY))
expect(S, "array type");
next(S);
index = index_last = expr_const(S);
- if (S->tok == TOK_DOTS && gnu_ext) {
+ if (S->tccpp_tok == TOK_DOTS && gnu_ext) {
next(S);
index_last = expr_const(S);
}
@@ -7745,7 +7745,7 @@ static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned lo
} else {
int cumofs;
next(S);
- l = S->tok;
+ l = S->tccpp_tok;
struct_field:
next(S);
if ((type->t & VT_BTYPE) != VT_STRUCT)
@@ -7762,7 +7762,7 @@ static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned lo
cur_field = NULL;
}
if (!cur_field) {
- if (S->tok == '=') {
+ if (S->tccpp_tok == '=') {
next(S);
} else if (!gnu_ext) {
expect(S, "=");
@@ -7830,7 +7830,7 @@ static int decl_designator(TCCState *S, init_params *p, CType *type, unsigned lo
}
/* store a value or an expression directly in global data or in local array */
-static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c)
+static void init_putv(TCCState* S, init_params *p, CType *type, unsigned long c)
{
int bt;
void *ptr;
@@ -7853,25 +7853,25 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c)
gen_assign_cast(S, &dtype);
bt = type->t & VT_BTYPE;
- if ((S->vtop->r & VT_SYM)
+ if ((S->tccgen_vtop->r & VT_SYM)
&& bt != VT_PTR
&& (bt != (PTR_SIZE == 8 ? VT_LLONG : VT_INT)
|| (type->t & VT_BITFIELD))
- && !((S->vtop->r & VT_CONST) && S->vtop->sym->v >= SYM_FIRST_ANOM)
+ && !((S->tccgen_vtop->r & VT_CONST) && S->tccgen_vtop->sym->v >= SYM_FIRST_ANOM)
)
tcc_error(S, "initializer element is not computable at load time");
if (NODATA_WANTED) {
- S->vtop--;
+ S->tccgen_vtop--;
return;
}
ptr = sec->data + c;
- val = S->vtop->c.i;
+ val = S->tccgen_vtop->c.i;
/* XXX: make code faster ? */
- if ((S->vtop->r & (VT_SYM|VT_CONST)) == (VT_SYM|VT_CONST) &&
- S->vtop->sym->v >= SYM_FIRST_ANOM &&
+ if ((S->tccgen_vtop->r & (VT_SYM|VT_CONST)) == (VT_SYM|VT_CONST) &&
+ S->tccgen_vtop->sym->v >= SYM_FIRST_ANOM &&
/* XXX This rejects compound literals like
'(void *){ptr}'. The problem is that '&sym' is
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)
between '(void *){x}' and '&(void *){x}'. Ignore
pointer typed entities here. Hopefully no real code
will ever use compound literals with scalar type. */
- (S->vtop->type.t & VT_BTYPE) != VT_PTR) {
+ (S->tccgen_vtop->type.t & VT_BTYPE) != VT_PTR) {
/* These come from compound literals, memcpy stuff over. */
Section *ssec;
ElfSym *esym;
ElfW_Rel *rel;
- esym = elfsym(S, S->vtop->sym);
+ esym = elfsym(S, S->tccgen_vtop->sym);
ssec = S->sections[esym->st_shndx];
- memmove (ptr, ssec->data + esym->st_value + (int)S->vtop->c.i, size);
+ memmove (ptr, ssec->data + esym->st_value + (int)S->tccgen_vtop->c.i, size);
if (ssec->reloc) {
/* We need to copy over all memory contents, and that
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)
if (type->t & VT_BITFIELD) {
int bit_pos, bit_size, bits, n;
unsigned char *p, v, m;
- bit_pos = BIT_POS(S->vtop->type.t);
- bit_size = BIT_SIZE(S->vtop->type.t);
+ bit_pos = BIT_POS(S->tccgen_vtop->type.t);
+ bit_size = BIT_SIZE(S->tccgen_vtop->type.t);
p = (unsigned char*)ptr + (bit_pos >> 3);
bit_pos &= 7, bits = 0;
while (bit_size) {
@@ -7959,21 +7959,21 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c)
In any case we avoid possibly random bytes 11 and 12.
*/
if (sizeof (long double) >= 10)
- memcpy(ptr, &S->vtop->c.ld, 10);
+ memcpy(ptr, &S->tccgen_vtop->c.ld, 10);
#ifdef __TINYC__
else if (sizeof (long double) == sizeof (double))
- __asm__("fldl %1\nfstpt %0\n" : "=m" (*ptr) : "m" (S->vtop->c.ld));
+ __asm__("fldl %1\nfstpt %0\n" : "=m" (*ptr) : "m" (S->tccgen_vtop->c.ld));
#endif
- else if (S->vtop->c.ld == 0.0)
+ else if (S->tccgen_vtop->c.ld == 0.0)
;
else
#endif
/* For other platforms it should work natively, but may not work
for cross compilers */
if (sizeof(long double) == LDOUBLE_SIZE)
- memcpy(ptr, &S->vtop->c.ld, LDOUBLE_SIZE);
+ memcpy(ptr, &S->tccgen_vtop->c.ld, LDOUBLE_SIZE);
else if (sizeof(double) == LDOUBLE_SIZE)
- memcpy(ptr, &S->vtop->c.ld, LDOUBLE_SIZE);
+ memcpy(ptr, &S->tccgen_vtop->c.ld, LDOUBLE_SIZE);
#ifndef TCC_CROSS_TEST
else
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)
/* intptr_t may need a reloc too, see tcctest.c:relocation_test() */
case VT_LLONG:
case VT_PTR:
- if (S->vtop->r & VT_SYM)
- greloca(S, sec, S->vtop->sym, c, R_DATA_PTR, val);
+ if (S->tccgen_vtop->r & VT_SYM)
+ greloca(S, sec, S->tccgen_vtop->sym, c, R_DATA_PTR, val);
else
write64le(ptr, val);
break;
@@ -7998,8 +7998,8 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c)
break;
case VT_PTR:
case VT_INT:
- if (S->vtop->r & VT_SYM)
- greloc(S, sec, S->vtop->sym, c, R_DATA_PTR);
+ if (S->tccgen_vtop->r & VT_SYM)
+ greloc(S, sec, S->tccgen_vtop->sym, c, R_DATA_PTR);
write32le(ptr, val);
break;
#endif
@@ -8008,7 +8008,7 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c)
break;
}
}
- S->vtop--;
+ S->tccgen_vtop--;
} else {
vset(S, &dtype, VT_LOCAL|VT_LVAL, c);
vswap(S);
@@ -8022,7 +8022,7 @@ static void init_putv(TCCState *S, init_params *p, CType *type, unsigned long c)
allocation. 'flags & DIF_FIRST' is true if array '{' must be read (multi
dimension implicit array init handling). 'flags & DIF_SIZE_ONLY' is true if
size only evaluation is wanted (only for arrays). */
-static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned long c, int flags)
+static void decl_initializer(TCCState* S, init_params *p, CType *type, unsigned long c, int flags)
{
int len, n, no_oblock, i;
int size1, align1;
@@ -8034,11 +8034,11 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
if (S->tccgen_debug_modes && !p->sec)
tcc_debug_line(S), tcc_tcov_check_line (S, 1);
- if (!(flags & DIF_HAVE_ELEM) && S->tok != '{' &&
+ if (!(flags & DIF_HAVE_ELEM) && S->tccpp_tok != '{' &&
/* In case of strings we have special handling for arrays, so
don't consume them as initializer value (which would commit them
to some anonymous symbol). */
- S->tok != TOK_LSTR && S->tok != TOK_STR &&
+ S->tccpp_tok != TOK_LSTR && S->tccpp_tok != TOK_STR &&
!(flags & DIF_SIZE_ONLY)) {
parse_init_elem(S, !p->sec ? EXPR_ANY : EXPR_CONST);
flags |= DIF_HAVE_ELEM;
@@ -8049,13 +8049,13 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
/* Use i_c_parameter_t, to strip toplevel qualifiers.
The source type might have VT_CONSTANT set, which is
of course assignable to non-const elements. */
- is_compatible_unqualified_types(type, &S->vtop->type)) {
+ is_compatible_unqualified_types(type, &S->tccgen_vtop->type)) {
goto init_putv;
} else if (type->t & VT_ARRAY) {
no_oblock = 1;
- if (((flags & DIF_FIRST) && S->tok != TOK_LSTR && S->tok != TOK_STR) ||
- S->tok == '{') {
+ if (((flags & DIF_FIRST) && S->tccpp_tok != TOK_LSTR && S->tccpp_tok != TOK_STR) ||
+ S->tccpp_tok == '{') {
skip(S, '{');
no_oblock = 0;
}
@@ -8067,34 +8067,34 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
/* only parse strings here if correct type (otherwise: handle
them as ((w)char *) expressions */
- if ((S->tok == TOK_LSTR &&
+ if ((S->tccpp_tok == TOK_LSTR &&
#ifdef TCC_TARGET_PE
(t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED)
#else
(t1->t & VT_BTYPE) == VT_INT
#endif
- ) || (S->tok == TOK_STR && (t1->t & VT_BTYPE) == VT_BYTE)) {
+ ) || (S->tccpp_tok == TOK_STR && (t1->t & VT_BTYPE) == VT_BYTE)) {
len = 0;
cstr_reset(&S->tccgen_initstr);
- if (size1 != (S->tok == TOK_STR ? 1 : sizeof(nwchar_t)))
+ if (size1 != (S->tccpp_tok == TOK_STR ? 1 : sizeof(nwchar_t)))
tcc_error(S, "unhandled string literal merging");
- while (S->tok == TOK_STR || S->tok == TOK_LSTR) {
+ while (S->tccpp_tok == TOK_STR || S->tccpp_tok == TOK_LSTR) {
if (S->tccgen_initstr.size)
S->tccgen_initstr.size -= size1;
- if (S->tok == TOK_STR)
- len += S->tokc.str.size;
+ if (S->tccpp_tok == TOK_STR)
+ len += S->tccpp_tokc.str.size;
else
- len += S->tokc.str.size / sizeof(nwchar_t);
+ len += S->tccpp_tokc.str.size / sizeof(nwchar_t);
len--;
- cstr_cat(S, &S->tccgen_initstr, S->tokc.str.data, S->tokc.str.size);
+ cstr_cat(S, &S->tccgen_initstr, S->tccpp_tokc.str.data, S->tccpp_tokc.str.size);
next(S);
}
- if (S->tok != ')' && S->tok != '}' && S->tok != ',' && S->tok != ';'
- && S->tok != TOK_EOF) {
+ if (S->tccpp_tok != ')' && S->tccpp_tok != '}' && S->tccpp_tok != ',' && S->tccpp_tok != ';'
+ && S->tccpp_tok != TOK_EOF) {
/* Not a lone literal but part of a bigger expression. */
unget_tok(S, size1 == 1 ? TOK_STR : TOK_LSTR);
- S->tokc.str.size = S->tccgen_initstr.size;
- S->tokc.str.data = S->tccgen_initstr.data;
+ S->tccpp_tokc.str.size = S->tccgen_initstr.size;
+ S->tccpp_tokc.str.data = S->tccgen_initstr.data;
goto do_init_array;
}
@@ -8147,7 +8147,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
}
len = 0;
- while (S->tok != '}' || (flags & DIF_HAVE_ELEM)) {
+ while (S->tccpp_tok != '}' || (flags & DIF_HAVE_ELEM)) {
len = decl_designator(S, p, type, c, &f, flags, len);
flags &= ~DIF_HAVE_ELEM;
if (type->t & VT_ARRAY) {
@@ -8166,7 +8166,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
break;
}
- if (S->tok == '}')
+ if (S->tccpp_tok == '}')
break;
skip(S, ',');
}
@@ -8175,7 +8175,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
skip(S, '}');
} else if ((type->t & VT_BTYPE) == VT_STRUCT) {
no_oblock = 1;
- if ((flags & DIF_FIRST) || S->tok == '{') {
+ if ((flags & DIF_FIRST) || S->tccpp_tok == '{') {
skip(S, '{');
no_oblock = 0;
}
@@ -8184,7 +8184,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
n = s->c;
size1 = 1;
goto do_init_list;
- } else if (S->tok == '{') {
+ } else if (S->tccpp_tok == '{') {
if (flags & DIF_HAVE_ELEM)
skip(S, ';');
next(S);
@@ -8204,14 +8204,14 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
/* This should happen only when we haven't parsed
the init element above for fear of committing a
string constant to memory too early. */
- if (S->tok != TOK_STR && S->tok != TOK_LSTR)
+ if (S->tccpp_tok != TOK_STR && S->tccpp_tok != TOK_LSTR)
expect(S, "string constant");
parse_init_elem(S, !p->sec ? EXPR_ANY : EXPR_CONST);
}
init_putv:
if (!p->sec && (flags & DIF_CLEAR) /* container was already zero'd */
- && (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST
- && S->vtop->c.i == 0
+ && (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST
+ && S->tccgen_vtop->c.i == 0
&& btype_size(type->t & VT_BTYPE) /* not for fp constants */
)
vpop(S);
@@ -8227,7 +8227,7 @@ static void decl_initializer(TCCState *S, init_params *p, CType *type, unsigned
are parsed. If 'v' is zero, then a reference to the new object
is put in the value stack. If 'has_init' is 2, a special parsing
is done to handle string constants. */
-static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, int r,
+static void decl_initializer_alloc(TCCState* S, CType *type, AttributeDef *ad, int r,
int has_init, int v, int scope)
{
int size, align, addr;
@@ -8236,7 +8236,7 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i
Section *sec;
Sym *flexible_array;
Sym *sym;
- int saved_nocode_wanted = S->nocode_wanted;
+ int saved_nocode_wanted = S->tccgen_nocode_wanted;
#ifdef CONFIG_TCC_BCHECK
int bcheck = S->do_bounds_check && !NODATA_WANTED;
#endif
@@ -8244,7 +8244,7 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i
/* Always allocate static or global variables */
if (v && (r & VT_VALMASK) == VT_CONST)
- S->nocode_wanted |= 0x80000000;
+ S->tccgen_nocode_wanted |= 0x80000000;
flexible_array = NULL;
size = type_size(type, &align);
@@ -8280,7 +8280,7 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i
if (has_init == 2) {
/* only get strings */
init_str = tok_str_alloc(S);
- while (S->tok == TOK_STR || S->tok == TOK_LSTR) {
+ while (S->tccpp_tok == TOK_STR || S->tccpp_tok == TOK_LSTR) {
tok_str_add_tok(S, init_str);
next(S);
}
@@ -8327,16 +8327,16 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i
#ifdef CONFIG_TCC_BCHECK
if (bcheck && v) {
/* add padding between stack variables for bound checking */
- S->loc -= align;
+ S->tccgen_loc -= align;
}
#endif
- S->loc = (S->loc - size) & -align;
- addr = S->loc;
+ S->tccgen_loc = (S->tccgen_loc - size) & -align;
+ addr = S->tccgen_loc;
p.local_offset = addr + size;
#ifdef CONFIG_TCC_BCHECK
if (bcheck && v) {
/* add padding between stack variables for bound checking */
- S->loc -= align;
+ S->tccgen_loc -= align;
}
#endif
if (v) {
@@ -8422,8 +8422,8 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i
} else {
/* push global reference */
vpush_ref(S, type, sec, addr, size);
- sym = S->vtop->sym;
- S->vtop->r |= r;
+ sym = S->tccgen_vtop->sym;
+ S->tccgen_vtop->r |= r;
}
#ifdef CONFIG_TCC_BCHECK
@@ -8452,8 +8452,8 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i
if (S->tccgen_cur_scope->prev && S->tccgen_cur_scope->prev->vla.num) {
S->tccgen_cur_scope->vla.locorig = S->tccgen_cur_scope->prev->vla.loc;
} else {
- gen_vla_sp_save(S, S->loc -= PTR_SIZE);
- S->tccgen_cur_scope->vla.locorig = S->loc;
+ gen_vla_sp_save(S, S->tccgen_loc -= PTR_SIZE);
+ S->tccgen_cur_scope->vla.locorig = S->tccgen_loc;
}
}
@@ -8462,7 +8462,7 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i
#if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64
/* on _WIN64, because of the function args scratch area, the
result of alloca differs from RSP and is returned in RAX. */
- gen_vla_result(S, addr), addr = (S->loc -= PTR_SIZE);
+ gen_vla_result(S, addr), addr = (S->tccgen_loc -= PTR_SIZE);
#endif
gen_vla_sp_save(S, addr);
S->tccgen_cur_scope->vla.loc = addr;
@@ -8483,64 +8483,64 @@ static void decl_initializer_alloc(TCCState *S, CType *type, AttributeDef *ad, i
next(S);
}
- S->nocode_wanted = saved_nocode_wanted;
+ S->tccgen_nocode_wanted = saved_nocode_wanted;
}
/* parse a function defined by symbol 'sym' and generate its code in
'cur_text_section' */
-static void gen_function(TCCState *S, Sym *sym)
+static void gen_function(TCCState* S, Sym *sym)
{
scope_t f = { 0 };
S->tccgen_cur_scope = S->tccgen_root_scope = &f;
- S->nocode_wanted = 0;
- S->ind = cur_text_section->data_offset;
+ S->tccgen_nocode_wanted = 0;
+ S->tccgen_ind = cur_text_section->data_offset;
if (sym->a.aligned) {
size_t newoff = section_add(S, cur_text_section, 0,
1 << (sym->a.aligned - 1));
- gen_fill_nops(S, newoff - S->ind);
+ gen_fill_nops(S, newoff - S->tccgen_ind);
}
/* NOTE: we patch the symbol size later */
- put_extern_sym(S, sym, cur_text_section, S->ind, 0);
+ put_extern_sym(S, sym, cur_text_section, S->tccgen_ind, 0);
if (sym->type.ref->f.func_ctor)
add_array (S, ".init_array", sym->c);
if (sym->type.ref->f.func_dtor)
add_array (S, ".fini_array", sym->c);
S->tccgen_funcname = get_tok_str(S, sym->v, NULL);
- S->tccgen_func_ind = S->ind;
+ S->tccgen_func_ind = S->tccgen_ind;
S->tccgen_func_vt = sym->type.ref->type;
S->tccgen_func_var = sym->type.ref->f.func_type == FUNC_ELLIPSIS;
/* put debug symbol */
tcc_debug_funcstart(S, sym);
/* push a dummy symbol to enable local sym storage */
- sym_push2(S, &S->local_stack, SYM_FIELD, 0, 0);
- S->local_scope = 1; /* for function parameters */
+ sym_push2(S, &S->tccgen_local_stack, SYM_FIELD, 0, 0);
+ S->tccgen_local_scope = 1; /* for function parameters */
gfunc_prolog(S, sym);
- S->local_scope = 0;
+ S->tccgen_local_scope = 0;
S->tccgen_rsym = 0;
clear_temp_local_var_list(S);
block(S, 0);
gsym(S, S->tccgen_rsym);
- S->nocode_wanted = 0;
+ S->tccgen_nocode_wanted = 0;
/* reset local stack */
pop_local_syms(S, NULL, 0);
gfunc_epilog(S);
- cur_text_section->data_offset = S->ind;
- S->local_scope = 0;
+ cur_text_section->data_offset = S->tccgen_ind;
+ S->tccgen_local_scope = 0;
label_pop(S, &S->tccgen_global_label_stack, NULL, 0);
sym_pop(S, &S->tccgen_all_cleanups, NULL, 0);
/* patch symbol size */
- elfsym(S, sym)->st_size = S->ind - S->tccgen_func_ind;
+ elfsym(S, sym)->st_size = S->tccgen_ind - S->tccgen_func_ind;
/* end of function */
- tcc_debug_funcend(S, S->ind - S->tccgen_func_ind);
+ tcc_debug_funcend(S, S->tccgen_ind - S->tccgen_func_ind);
/* It's better to crash than to generate wrong code */
cur_text_section = NULL;
S->tccgen_funcname = ""; /* for safety */
S->tccgen_func_vt.t = VT_VOID; /* for safety */
S->tccgen_func_var = 0; /* for safety */
- S->ind = 0; /* for safety */
- S->nocode_wanted = 0x80000000;
+ S->tccgen_ind = 0; /* for safety */
+ S->tccgen_nocode_wanted = 0x80000000;
check_vstack(S);
/* do this after funcend debug info */
next(S);
@@ -8591,7 +8591,7 @@ static void free_inline_functions(TCCState *S)
/* 'l' is VT_LOCAL or VT_CONST to define default storage type, or VT_CMP
if parsing old style parameter decl list (and FUNC_SYM is set then) */
-static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym)
+static int decl0(TCCState* S, int l, int is_for_loop_init, Sym *func_sym)
{
int v, has_init, r, oldint;
CType type, btype;
@@ -8599,7 +8599,7 @@ static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym)
AttributeDef ad, adbase;
while (1) {
- if (S->tok == TOK_STATIC_ASSERT) {
+ if (S->tccpp_tok == TOK_STATIC_ASSERT) {
CString error_str;
int c;
@@ -8607,7 +8607,7 @@ static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym)
skip(S, '(');
c = expr_const(S);
- if (S->tok == ')') {
+ if (S->tccpp_tok == ')') {
if (!c)
tcc_error(S, "_Static_assert fail");
next(S);
@@ -8630,30 +8630,30 @@ static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym)
if (is_for_loop_init)
return 0;
/* skip redundant ';' if not in old parameter decl scope */
- if (S->tok == ';' && l != VT_CMP) {
+ if (S->tccpp_tok == ';' && l != VT_CMP) {
next(S);
continue;
}
if (l != VT_CONST)
break;
- if (S->tok == TOK_ASM1 || S->tok == TOK_ASM2 || S->tok == TOK_ASM3) {
+ if (S->tccpp_tok == TOK_ASM1 || S->tccpp_tok == TOK_ASM2 || S->tccpp_tok == TOK_ASM3) {
/* global asm block */
asm_global_instr(S);
continue;
}
- if (S->tok >= TOK_UIDENT) {
+ if (S->tccpp_tok >= TOK_UIDENT) {
/* special test for old K&R protos without explicit int
type. Only accepted when defining global data */
btype.t = VT_INT;
oldint = 1;
} else {
- if (S->tok != TOK_EOF)
+ if (S->tccpp_tok != TOK_EOF)
expect(S, "declaration");
break;
}
}
- if (S->tok == ';') {
+ if (S->tccpp_tok == ';') {
if ((btype.t & VT_BTYPE) == VT_STRUCT) {
v = btype.ref->v;
if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM)
@@ -8706,14 +8706,14 @@ static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym)
tcc_warning(S, "type defaults to int");
}
- if (gnu_ext && (S->tok == TOK_ASM1 || S->tok == TOK_ASM2 || S->tok == TOK_ASM3)) {
+ if (gnu_ext && (S->tccpp_tok == TOK_ASM1 || S->tccpp_tok == TOK_ASM2 || S->tccpp_tok == TOK_ASM3)) {
ad.asm_label = asm_label_instr(S);
/* parse one last attribute list, after asm label */
parse_attribute(S, &ad);
#if 0
/* gcc does not allow __asm__("label") with function definition,
but why not ... */
- if (Stok == '{')
+ if (Stccpp_tok == '{')
expect(S, ";");
#endif
}
@@ -8734,7 +8734,7 @@ static int decl0(TCCState *S, int l, int is_for_loop_init, Sym *func_sym)
}
}
#endif
- if (S->tok == '{') {
+ if (S->tccpp_tok == '{') {
if (l != VT_CONST)
tcc_error(S, "cannot use local functions");
if ((type.t & VT_BTYPE) != VT_FUNC)
@@ -8797,7 +8797,7 @@ found:
/* save typedefed type */
/* XXX: test storage specifiers ? */
sym = sym_find(S, v);
- if (sym && sym->sym_scope == S->local_scope) {
+ if (sym && sym->sym_scope == S->tccgen_local_scope) {
if (!is_compatible_types(&sym->type, &type)
|| !(sym->type.t & VT_TYPEDEF))
tcc_error(S, "incompatible redefinition of '%s'",
@@ -8823,7 +8823,7 @@ found:
/* not lvalue if array */
r |= VT_LVAL;
}
- has_init = (S->tok == '=');
+ has_init = (S->tccpp_tok == '=');
if (has_init && (type.t & VT_VLA))
tcc_error(S, "variable length array cannot be initialized");
if (((type.t & VT_EXTERN) && (!has_init || l != VT_CONST))
@@ -8863,7 +8863,7 @@ found:
decl_initializer_alloc(S, &type, &ad, r, has_init, v, l);
}
}
- if (S->tok != ',') {
+ if (S->tccpp_tok != ',') {
if (is_for_loop_init)
return 1;
skip(S, ';');
@@ -8876,7 +8876,7 @@ found:
return 0;
}
-static void decl(TCCState *S, int l)
+static void decl(TCCState* S, int l)
{
decl0(S, l, 0, NULL);
}
diff --git a/tccmacho.c b/tccmacho.c
index 011559a..3f41a7a 100644
--- a/tccmacho.c
+++ b/tccmacho.c
@@ -249,7 +249,7 @@ struct macho {
#define SHT_LINKEDIT (SHT_LOOS + 42)
#define SHN_FROMDLL (SHN_LOOS + 2) /* Symbol is undefined, comes from a DLL */
-static void * add_lc(TCCState *S, struct macho *mo, uint32_t cmd, uint32_t cmdsize)
+static void * add_lc(TCCState* S, struct macho *mo, uint32_t cmd, uint32_t cmdsize)
{
struct load_command *lc = tcc_mallocz(S, cmdsize);
lc->cmd = cmd;
@@ -259,7 +259,7 @@ static void * add_lc(TCCState *S, struct macho *mo, uint32_t cmd, uint32_t cmdsi
return lc;
}
-static struct segment_command_64 * add_segment(TCCState *S, struct macho *mo, const char *name)
+static struct segment_command_64 * add_segment(TCCState* S, struct macho *mo, const char *name)
{
struct segment_command_64 *sc = add_lc(S, mo, LC_SEGMENT_64, sizeof(*sc));
strncpy(sc->segname, name, 16);
@@ -272,7 +272,7 @@ static struct segment_command_64 * get_segment(struct macho *mo, int i)
return (struct segment_command_64 *) (mo->lc[mo->seg2lc[i]]);
}
-static int add_section(TCCState *S, struct macho *mo, struct segment_command_64 **_seg, const char *name)
+static int add_section(TCCState* S, struct macho *mo, struct segment_command_64 **_seg, const char *name)
{
struct segment_command_64 *seg = *_seg;
int ret = seg->nsects;
@@ -293,7 +293,7 @@ static struct section_64 *get_section(struct segment_command_64 *seg, int i)
return (struct section_64*)((char*)seg + sizeof(*seg)) + i;
}
-static void * add_dylib(TCCState *S, struct macho *mo, char *name)
+static void * add_dylib(TCCState* S, struct macho *mo, char *name)
{
struct dylib_command *lc;
int sz = (sizeof(*lc) + strlen(name) + 1 + 7) & -8;
@@ -836,7 +836,7 @@ static uint32_t macho_swap32(uint32_t x)
}
#define SWAP(x) (swap ? macho_swap32(x) : (x))
-ST_FUNC int macho_add_dllref(TCCState *S, int lev, const char* soname)
+ST_FUNC int macho_add_dllref(TCCState* S, int lev, const char* soname)
{
/* if the dll is already loaded, do not load it */
DLLReference *dllref;
@@ -865,7 +865,7 @@ ST_FUNC int macho_add_dllref(TCCState *S, int lev, const char* soname)
#ifdef TCC_IS_NATIVE
/* Looks for the active developer SDK set by xcode-select (or the default
one set during installation.) */
-ST_FUNC void tcc_add_macos_sdkpath(TCCState *S)
+ST_FUNC void tcc_add_macos_sdkpath(TCCState* s)
{
char *sdkroot = NULL, *pos = NULL;
void* xcs = dlopen("libxcselect.dylib", RTLD_GLOBAL | RTLD_LAZY);
@@ -912,7 +912,7 @@ the_end:
}
#endif /* TCC_IS_NATIVE */
-ST_FUNC int macho_load_tbd(TCCState *S, int fd, const char* filename, int lev)
+ST_FUNC int macho_load_tbd(TCCState* S, int fd, const char* filename, int lev)
{
char *soname, *data, *pos;
int ret = -1;
diff --git a/tccpe.c b/tccpe.c
index 7d35524..6eb9ef3 100644
--- a/tccpe.c
+++ b/tccpe.c
@@ -1492,7 +1492,7 @@ static void pe_print_sections(TCCState *S, const char *fname)
/* helper function for load/store to insert one more indirection */
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
-ST_FUNC SValue *pe_getimport(TCCState *S, SValue *sv, SValue *v2)
+ST_FUNC SValue *pe_getimport(TCCState* S, SValue *sv, SValue *v2)
{
int r2;
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)
vpushv(S, v2);
vpushi(S, sv->c.i);
gen_opi(S, '+');
- *v2 = *S->vtop--;
+ *v2 = *S->tccgen_vtop--;
}
v2->type.t = sv->type.t;
v2->r |= sv->r & VT_LVAL;
@@ -1551,7 +1551,7 @@ static int read_mem(int fd, unsigned offset, void *buffer, unsigned len)
/* ------------------------------------------------------------- */
-static int get_dllexports(TCCState *S, int fd, char **pp)
+static int get_dllexports(TCCState* S, int fd, char **pp)
{
int l, i, n, n0, ret;
char *p;
diff --git a/tccpp.c b/tccpp.c
index 3b6ba64..4a73f95 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -26,7 +26,7 @@
/* ------------------------------------------------------------------------- */
-static void tok_print(TCCState *S, const char *msg, const int *str);
+static void tok_print(TCCState* S, const char *msg, const int *str);
static const char tcc_keywords[] =
#define DEF(id, str) str "\0"
@@ -65,16 +65,16 @@ static const unsigned char tok_two_chars[] =
0
};
-static void next_nomacro(TCCState *S);
+static void next_nomacro(TCCState* S);
-ST_FUNC void skip(TCCState *S, int c)
+ST_FUNC void skip(TCCState* S, int c)
{
- if (S->tok != c)
- tcc_error(S, "'%c' expected (got \"%s\")", c, get_tok_str(S, S->tok, &S->tokc));
+ if (S->tccpp_tok != c)
+ tcc_error(S, "'%c' expected (got \"%s\")", c, get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
next(S);
}
-ST_FUNC void expect(TCCState *S, const char *msg)
+ST_FUNC void expect(TCCState* S, const char *msg)
{
tcc_error(S, "%s expected", msg);
}
@@ -120,7 +120,7 @@ typedef struct tal_header_t {
/* ------------------------------------------------------------------------- */
-static TinyAlloc *tal_new(TCCState *S, TinyAlloc **pal, unsigned limit, unsigned size)
+static TinyAlloc *tal_new(TCCState* S, TinyAlloc **pal, unsigned limit, unsigned size)
{
TinyAlloc *al = tcc_mallocz(S, sizeof(TinyAlloc));
al->p = al->buffer = tcc_malloc(S, size);
@@ -130,7 +130,7 @@ static TinyAlloc *tal_new(TCCState *S, TinyAlloc **pal, unsigned limit, unsigned
return al;
}
-static void tal_delete(TCCState *S, TinyAlloc *al)
+static void tal_delete(TCCState* S, TinyAlloc *al)
{
TinyAlloc *next;
@@ -168,7 +168,7 @@ tail_call:
goto tail_call;
}
-static void tal_free_impl(TCCState *S, TinyAlloc *al, void *p TAL_DEBUG_PARAMS)
+static void tal_free_impl(TCCState* S, TinyAlloc *al, void *p TAL_DEBUG_PARAMS)
{
if (!p)
return;
@@ -195,7 +195,7 @@ tail_call:
tcc_free(S, p);
}
-static void *tal_realloc_impl(TCCState *S, TinyAlloc **pal, void *p, unsigned size TAL_DEBUG_PARAMS)
+static void *tal_realloc_impl(TCCState* S, TinyAlloc **pal, void *p, unsigned size TAL_DEBUG_PARAMS)
{
tal_header_t *header;
void *ret;
@@ -278,7 +278,7 @@ tail_call:
/* ------------------------------------------------------------------------- */
/* CString handling */
-static void cstr_realloc(TCCState *S, CString *cstr, int new_size)
+static void cstr_realloc(TCCState* S, CString *cstr, int new_size)
{
int size;
@@ -292,7 +292,7 @@ static void cstr_realloc(TCCState *S, CString *cstr, int new_size)
}
/* add a byte */
-ST_INLN void cstr_ccat(TCCState *S, CString *cstr, int ch)
+ST_INLN void cstr_ccat(TCCState* S, CString *cstr, int ch)
{
int size;
size = cstr->size + 1;
@@ -313,14 +313,14 @@ ST_INLN char *unicode_to_utf8 (char *b, uint32_t Uc)
}
/* add a unicode character expanded into utf8 */
-ST_INLN void cstr_u8cat(TCCState *S, CString *cstr, int ch)
+ST_INLN void cstr_u8cat(TCCState* S, CString *cstr, int ch)
{
char buf[4], *e;
e = unicode_to_utf8(buf, (uint32_t)ch);
cstr_cat(S, cstr, buf, e - buf);
}
-ST_FUNC void cstr_cat(TCCState *S, CString *cstr, const char *str, int len)
+ST_FUNC void cstr_cat(TCCState* S, CString *cstr, const char *str, int len)
{
int size;
if (len <= 0)
@@ -333,7 +333,7 @@ ST_FUNC void cstr_cat(TCCState *S, CString *cstr, const char *str, int len)
}
/* add a wide char */
-ST_FUNC void cstr_wccat(TCCState *S, CString *cstr, int ch)
+ST_FUNC void cstr_wccat(TCCState* S, CString *cstr, int ch)
{
int size;
size = cstr->size + sizeof(nwchar_t);
@@ -343,13 +343,13 @@ ST_FUNC void cstr_wccat(TCCState *S, CString *cstr, int ch)
cstr->size = size;
}
-ST_FUNC void cstr_new(TCCState *S, CString *cstr)
+ST_FUNC void cstr_new(TCCState* S, CString *cstr)
{
memset(cstr, 0, sizeof(CString));
}
/* free string and reset it to NULL */
-ST_FUNC void cstr_free(TCCState *S, CString *cstr)
+ST_FUNC void cstr_free(TCCState* S, CString *cstr)
{
tcc_free(S, cstr->data);
cstr_new(S, cstr);
@@ -361,7 +361,7 @@ ST_FUNC void cstr_reset(CString *cstr)
cstr->size = 0;
}
-ST_FUNC int cstr_vprintf(TCCState *S, CString *cstr, const char *fmt, va_list ap)
+ST_FUNC int cstr_vprintf(TCCState* S, CString *cstr, const char *fmt, va_list ap)
{
va_list v;
int len, size = 80;
@@ -381,7 +381,7 @@ ST_FUNC int cstr_vprintf(TCCState *S, CString *cstr, const char *fmt, va_list ap
return len;
}
-ST_FUNC int cstr_printf(TCCState *S, CString *cstr, const char *fmt, ...)
+ST_FUNC int cstr_printf(TCCState* S, CString *cstr, const char *fmt, ...)
{
va_list ap; int len;
va_start(ap, fmt);
@@ -391,7 +391,7 @@ ST_FUNC int cstr_printf(TCCState *S, CString *cstr, const char *fmt, ...)
}
/* XXX: unicode ? */
-static void add_char(TCCState *S, CString *cstr, int c)
+static void add_char(TCCState* S, CString *cstr, int c)
{
if (c == '\'' || c == '\"' || c == '\\') {
/* XXX: could be more precise if char or string */
@@ -413,24 +413,24 @@ static void add_char(TCCState *S, CString *cstr, int c)
/* ------------------------------------------------------------------------- */
/* allocate a new token */
-static TokenSym *tok_alloc_new(TCCState *S, TokenSym **pts, const char *str, int len)
+static TokenSym *tok_alloc_new(TCCState* S, TokenSym **pts, const char *str, int len)
{
TokenSym *ts, **ptable;
int i;
- if (S->tok_ident >= SYM_FIRST_ANOM)
+ if (S->tccpp_tok_ident >= SYM_FIRST_ANOM)
tcc_error(S, "memory full (symbols)");
/* expand token table if needed */
- i = S->tok_ident - TOK_IDENT;
+ i = S->tccpp_tok_ident - TOK_IDENT;
if ((i % TOK_ALLOC_INCR) == 0) {
ptable = tcc_realloc(S, S->tccpp_table_ident, (i + TOK_ALLOC_INCR) * sizeof(TokenSym *));
S->tccpp_table_ident = ptable;
}
- ts = tal_realloc(S, S->toksym_alloc, 0, sizeof(TokenSym) + len);
+ ts = tal_realloc(S, S->tccpp_toksym_alloc, 0, sizeof(TokenSym) + len);
S->tccpp_table_ident[i] = ts;
- ts->tok = S->tok_ident++;
+ ts->tok = S->tccpp_tok_ident++;
ts->sym_define = NULL;
ts->sym_label = NULL;
ts->sym_struct = NULL;
@@ -448,7 +448,7 @@ static TokenSym *tok_alloc_new(TCCState *S, TokenSym **pts, const char *str, int
/* find a token and add it if not found */
-ST_FUNC TokenSym *tok_alloc(TCCState *S, const char *str, int len)
+ST_FUNC TokenSym *tok_alloc(TCCState* S, const char *str, int len)
{
TokenSym *ts, **pts;
int i;
@@ -471,7 +471,7 @@ ST_FUNC TokenSym *tok_alloc(TCCState *S, const char *str, int len)
return tok_alloc_new(S, pts, str, len);
}
-ST_FUNC int tok_alloc_const(TCCState *S, const char *str)
+ST_FUNC int tok_alloc_const(TCCState* S, const char *str)
{
return tok_alloc(S, str, strlen(str))->tok;
}
@@ -479,7 +479,7 @@ ST_FUNC int tok_alloc_const(TCCState *S, const char *str)
/* XXX: buffer overflow */
/* XXX: float tokens */
-ST_FUNC const char *get_tok_str(TCCState *S, int v, CValue *cv)
+ST_FUNC const char *get_tok_str(TCCState* S, int v, CValue *cv)
{
char *p;
int i, len;
@@ -578,7 +578,7 @@ ST_FUNC const char *get_tok_str(TCCState *S, int v, CValue *cv)
*p++ = v;
case 0: /* nameless anonymous symbol */
*p = '\0';
- } else if (v < S->tok_ident) {
+ } else if (v < S->tccpp_tok_ident) {
return S->tccpp_table_ident[v - TOK_IDENT]->str;
} else if (v >= SYM_FIRST_ANOM) {
/* special name for anonymous symbol */
@@ -594,7 +594,7 @@ ST_FUNC const char *get_tok_str(TCCState *S, int v, CValue *cv)
/* return the current character, handling end of block if necessary
(but not stray) */
-static int handle_eob(TCCState *S)
+static int handle_eob(TCCState* S)
{
BufferedFile *bf = S->tccpp_file;
int len;
@@ -627,7 +627,7 @@ static int handle_eob(TCCState *S)
}
/* read next char from current input file and handle end of input buffer */
-static inline void inp(TCCState *S)
+static inline void inp(TCCState* S)
{
S->tccpp_ch = *(++(S->tccpp_file->buf_ptr));
/* end of buffer/file handling */
@@ -636,7 +636,7 @@ static inline void inp(TCCState *S)
}
/* handle '\[\r]\n' */
-static int handle_stray_noerror(TCCState *S)
+static int handle_stray_noerror(TCCState* S)
{
while (S->tccpp_ch == '\\') {
inp(S);
@@ -657,7 +657,7 @@ static int handle_stray_noerror(TCCState *S)
return 0;
}
-static void handle_stray(TCCState *S)
+static void handle_stray(TCCState* S)
{
if (handle_stray_noerror(S))
tcc_error(S, "stray '\\' in program");
@@ -665,7 +665,7 @@ static void handle_stray(TCCState *S)
/* skip the stray and handle the \\n case. Output an error if
incorrect char after the stray */
-static int handle_stray1(TCCState *S, uint8_t *p)
+static int handle_stray1(TCCState* S, uint8_t *p)
{
int c;
@@ -713,7 +713,7 @@ static int handle_stray1(TCCState *S, uint8_t *p)
/* input with '\[\r]\n' handling. Note that this function cannot
handle other characters after '\', so you cannot call it inside
strings or comments */
-static void minp(TCCState *S)
+static void minp(TCCState* S)
{
inp(S);
if (S->tccpp_ch == '\\')
@@ -721,7 +721,7 @@ static void minp(TCCState *S)
}
/* single line C++ comments */
-static uint8_t *parse_line_comment(TCCState *S, uint8_t *p)
+static uint8_t *parse_line_comment(TCCState* S, uint8_t *p)
{
int c;
@@ -758,7 +758,7 @@ static uint8_t *parse_line_comment(TCCState *S, uint8_t *p)
}
/* C comments */
-static uint8_t *parse_comment(TCCState *S, uint8_t *p)
+static uint8_t *parse_comment(TCCState* S, uint8_t *p)
{
int c;
@@ -833,7 +833,7 @@ static uint8_t *parse_comment(TCCState *S, uint8_t *p)
return p;
}
-ST_FUNC int set_idnum(TCCState *S, int c, int val)
+ST_FUNC int set_idnum(TCCState* S, int c, int val)
{
int prev = S->tccpp_isidnum_table[c - CH_EOF];
S->tccpp_isidnum_table[c - CH_EOF] = val;
@@ -842,13 +842,13 @@ ST_FUNC int set_idnum(TCCState *S, int c, int val)
#define cinp minp
-static inline void skip_spaces(TCCState *S)
+static inline void skip_spaces(TCCState* S)
{
while (S->tccpp_isidnum_table[S->tccpp_ch - CH_EOF] & IS_SPC)
cinp(S);
}
-static inline int check_space(TCCState *S, int t, int *spc)
+static inline int check_space(TCCState* S, int t, int *spc)
{
if (t < 256 && (S->tccpp_isidnum_table[t - CH_EOF] & IS_SPC)) {
if (*spc)
@@ -860,7 +860,7 @@ static inline int check_space(TCCState *S, int t, int *spc)
}
/* parse a string without interpreting escapes */
-static uint8_t *parse_pp_string(TCCState *S, uint8_t *p,
+static uint8_t *parse_pp_string(TCCState* S, uint8_t *p,
int sep, CString *str)
{
int c;
@@ -924,7 +924,7 @@ static uint8_t *parse_pp_string(TCCState *S, uint8_t *p,
/* skip block of text until #else, #elif or #endif. skip also pairs of
#if/#endif */
-static void preprocess_skip(TCCState *S)
+static void preprocess_skip(TCCState* S)
{
int a, start_of_line, c, in_warn_or_error;
uint8_t *p;
@@ -988,15 +988,15 @@ redo_start:
next_nomacro(S);
p = S->tccpp_file->buf_ptr;
if (a == 0 &&
- (S->tok == TOK_ELSE || S->tok == TOK_ELIF || S->tok == TOK_ENDIF))
+ (S->tccpp_tok == TOK_ELSE || S->tccpp_tok == TOK_ELIF || S->tccpp_tok == TOK_ENDIF))
goto the_end;
- if (S->tok == TOK_IF || S->tok == TOK_IFDEF || S->tok == TOK_IFNDEF)
+ if (S->tccpp_tok == TOK_IF || S->tccpp_tok == TOK_IFDEF || S->tccpp_tok == TOK_IFNDEF)
a++;
- else if (S->tok == TOK_ENDIF)
+ else if (S->tccpp_tok == TOK_ENDIF)
a--;
- else if( S->tok == TOK_ERROR || S->tok == TOK_WARNING)
+ else if( S->tccpp_tok == TOK_ERROR || S->tccpp_tok == TOK_WARNING)
in_warn_or_error = 1;
- else if (S->tok == TOK_LINEFEED)
+ else if (S->tccpp_tok == TOK_LINEFEED)
goto redo_start;
else if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE)
p = parse_line_comment(S, p - 1);
@@ -1062,34 +1062,34 @@ ST_INLN void tok_str_new(TokenString *s)
s->last_line_num = -1;
}
-ST_FUNC TokenString *tok_str_alloc(TCCState *S)
+ST_FUNC TokenString *tok_str_alloc(TCCState* S)
{
- TokenString *str = tal_realloc(S, S->tokstr_alloc, 0, sizeof *str);
+ TokenString *str = tal_realloc(S, S->tccpp_tokstr_alloc, 0, sizeof *str);
tok_str_new(str);
return str;
}
-ST_FUNC int *tok_str_dup(TCCState *S, TokenString *s)
+ST_FUNC int *tok_str_dup(TCCState* S, TokenString *s)
{
int *str;
- str = tal_realloc(S, S->tokstr_alloc, 0, s->len * sizeof(int));
+ str = tal_realloc(S, S->tccpp_tokstr_alloc, 0, s->len * sizeof(int));
memcpy(str, s->str, s->len * sizeof(int));
return str;
}
-ST_FUNC void tok_str_free_str(TCCState *S, int *str)
+ST_FUNC void tok_str_free_str(TCCState* S, int *str)
{
- tal_free(S, S->tokstr_alloc, str);
+ tal_free(S, S->tccpp_tokstr_alloc, str);
}
-ST_FUNC void tok_str_free(TCCState *S, TokenString *str)
+ST_FUNC void tok_str_free(TCCState* S, TokenString *str)
{
tok_str_free_str(S, str->str);
- tal_free(S, S->tokstr_alloc, str);
+ tal_free(S, S->tccpp_tokstr_alloc, str);
}
-ST_FUNC int *tok_str_realloc(TCCState *S, TokenString *s, int new_size)
+ST_FUNC int *tok_str_realloc(TCCState* S, TokenString *s, int new_size)
{
int *str, size;
@@ -1099,14 +1099,14 @@ ST_FUNC int *tok_str_realloc(TCCState *S, TokenString *s, int new_size)
while (size < new_size)
size = size * 2;
if (size > s->allocated_len) {
- str = tal_realloc(S, S->tokstr_alloc, s->str, size * sizeof(int));
+ str = tal_realloc(S, S->tccpp_tokstr_alloc, s->str, size * sizeof(int));
s->allocated_len = size;
s->str = str;
}
return s->str;
}
-ST_FUNC void tok_str_add(TCCState *S, TokenString *s, int t)
+ST_FUNC void tok_str_add(TCCState* S, TokenString *s, int t)
{
int len, *str;
@@ -1118,7 +1118,7 @@ ST_FUNC void tok_str_add(TCCState *S, TokenString *s, int t)
s->len = len;
}
-ST_FUNC void begin_macro(TCCState *S, TokenString *str, int alloc)
+ST_FUNC void begin_macro(TCCState* S, TokenString *str, int alloc)
{
str->alloc = alloc;
str->prev = S->tccpp_macro_stack;
@@ -1128,7 +1128,7 @@ ST_FUNC void begin_macro(TCCState *S, TokenString *str, int alloc)
S->tccpp_macro_stack = str;
}
-ST_FUNC void end_macro(TCCState *S)
+ST_FUNC void end_macro(TCCState* S)
{
TokenString *str = S->tccpp_macro_stack;
S->tccpp_macro_stack = str->prev;
@@ -1141,7 +1141,7 @@ ST_FUNC void end_macro(TCCState *S)
}
}
-static void tok_str_add2(TCCState *S, TokenString *s, int t, CValue *cv)
+static void tok_str_add2(TCCState* S, TokenString *s, int t, CValue *cv)
{
int len, *str;
@@ -1215,7 +1215,7 @@ static void tok_str_add2(TCCState *S, TokenString *s, int t, CValue *cv)
}
/* add the current parse token in token string 's' */
-ST_FUNC void tok_str_add_tok(TCCState *S, TokenString *s)
+ST_FUNC void tok_str_add_tok(TCCState* S, TokenString *s)
{
CValue cval;
@@ -1225,7 +1225,7 @@ ST_FUNC void tok_str_add_tok(TCCState *S, TokenString *s)
cval.i = s->last_line_num;
tok_str_add2(S, s, TOK_LINENUM, &cval);
}
- tok_str_add2(S, s, S->tok, &S->tokc);
+ tok_str_add2(S, s, S->tccpp_tok, &S->tccpp_tokc);
}
/* 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)
} while (0)
#endif
-static int macro_is_equal(TCCState *S, const int *a, const int *b)
+static int macro_is_equal(TCCState* S, const int *a, const int *b)
{
CValue cv;
int t;
@@ -1325,7 +1325,7 @@ static int macro_is_equal(TCCState *S, const int *a, const int *b)
}
/* defines handling */
-ST_INLN void define_push(TCCState *S, int v, int macro_type, int *str, Sym *first_arg)
+ST_INLN void define_push(TCCState* S, int v, int macro_type, int *str, Sym *first_arg)
{
Sym *s, *o;
@@ -1340,23 +1340,23 @@ ST_INLN void define_push(TCCState *S, int v, int macro_type, int *str, Sym *firs
}
/* undefined a define symbol. Its name is just set to zero */
-ST_FUNC void define_undef(TCCState *S, Sym *s)
+ST_FUNC void define_undef(TCCState* S, Sym *s)
{
int v = s->v;
- if (v >= TOK_IDENT && v < S->tok_ident)
+ if (v >= TOK_IDENT && v < S->tccpp_tok_ident)
S->tccpp_table_ident[v - TOK_IDENT]->sym_define = NULL;
}
-ST_INLN Sym *define_find(TCCState *S, int v)
+ST_INLN Sym *define_find(TCCState* S, int v)
{
v -= TOK_IDENT;
- if ((unsigned)v >= (unsigned)(S->tok_ident - TOK_IDENT))
+ if ((unsigned)v >= (unsigned)(S->tccpp_tok_ident - TOK_IDENT))
return NULL;
return S->tccpp_table_ident[v]->sym_define;
}
/* free define stack until top reaches 'b' */
-ST_FUNC void free_defines(TCCState *S, Sym *b)
+ST_FUNC void free_defines(TCCState* S, Sym *b)
{
while (S->tccgen_define_stack != b) {
Sym *top = S->tccgen_define_stack;
@@ -1368,15 +1368,15 @@ ST_FUNC void free_defines(TCCState *S, Sym *b)
}
/* label lookup */
-ST_FUNC Sym *label_find(TCCState *S, int v)
+ST_FUNC Sym *label_find(TCCState* S, int v)
{
v -= TOK_IDENT;
- if ((unsigned)v >= (unsigned)(S->tok_ident - TOK_IDENT))
+ if ((unsigned)v >= (unsigned)(S->tccpp_tok_ident - TOK_IDENT))
return NULL;
return S->tccpp_table_ident[v]->sym_label;
}
-ST_FUNC Sym *label_push(TCCState *S, Sym **ptop, int v, int flags)
+ST_FUNC Sym *label_push(TCCState* S, Sym **ptop, int v, int flags)
{
Sym *s, **ps;
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)
/* pop labels until element last is reached. Look if any labels are
undefined. Define symbols if '&&label' was used. */
-ST_FUNC void label_pop(TCCState *S, Sym **ptop, Sym *slast, int keep)
+ST_FUNC void label_pop(TCCState* S, Sym **ptop, Sym *slast, int keep)
{
Sym *s, *s1;
for(s = *ptop; s != slast; s = s1) {
@@ -1430,60 +1430,60 @@ static void maybe_run_test(TCCState *S)
const char *p;
if (S->include_stack_ptr != S->include_stack)
return;
- p = get_tok_str(S, S->tok, NULL);
+ p = get_tok_str(S, S->tccpp_tok, NULL);
if (0 != memcmp(p, "test_", 5))
return;
if (0 != --S->run_test)
return;
fprintf(S->ppfp, &"\n[%s]\n"[!(S->dflag & TCC_OPTION_d_32)], p), fflush(S->ppfp);
- define_push(S, S->tok, MACRO_OBJ, NULL, NULL);
+ define_push(S, S->tccpp_tok, MACRO_OBJ, NULL, NULL);
}
/* eval an expression for #if/#elif */
-static int expr_preprocess(TCCState *S)
+static int expr_preprocess(TCCState* S)
{
int c, t;
TokenString *str;
str = tok_str_alloc(S);
S->tccpp_pp_expr = 1;
- while (S->tok != TOK_LINEFEED && S->tok != TOK_EOF) {
+ while (S->tccpp_tok != TOK_LINEFEED && S->tccpp_tok != TOK_EOF) {
next(S); /* do macro subst */
redo:
- if (S->tok == TOK_DEFINED) {
+ if (S->tccpp_tok == TOK_DEFINED) {
next_nomacro(S);
- t = S->tok;
+ t = S->tccpp_tok;
if (t == '(')
next_nomacro(S);
- if (S->tok < TOK_IDENT)
+ if (S->tccpp_tok < TOK_IDENT)
expect(S, "identifier");
if (S->run_test)
maybe_run_test(S);
- c = define_find(S, S->tok) != 0;
+ c = define_find(S, S->tccpp_tok) != 0;
if (t == '(') {
next_nomacro(S);
- if (S->tok != ')')
+ if (S->tccpp_tok != ')')
expect(S, "')'");
}
- S->tok = TOK_CINT;
- S->tokc.i = c;
- } else if (1 && S->tok == TOK___HAS_INCLUDE) {
+ S->tccpp_tok = TOK_CINT;
+ S->tccpp_tokc.i = c;
+ } else if (1 && S->tccpp_tok == TOK___HAS_INCLUDE) {
next(S); /* XXX check if correct to use expansion */
skip(S, '(');
- while (S->tok != ')' && S->tok != TOK_EOF)
+ while (S->tccpp_tok != ')' && S->tccpp_tok != TOK_EOF)
next(S);
- if (S->tok != ')')
+ if (S->tccpp_tok != ')')
expect(S, "')'");
- S->tok = TOK_CINT;
- S->tokc.i = 0;
- } else if (S->tok >= TOK_IDENT) {
+ S->tccpp_tok = TOK_CINT;
+ S->tccpp_tokc.i = 0;
+ } else if (S->tccpp_tok >= TOK_IDENT) {
/* if undefined macro, replace with zero, check for func-like */
- t = S->tok;
- S->tok = TOK_CINT;
- S->tokc.i = 0;
+ t = S->tccpp_tok;
+ S->tccpp_tok = TOK_CINT;
+ S->tccpp_tokc.i = 0;
tok_str_add_tok(S, str);
next(S);
- if (S->tok == '(')
+ if (S->tccpp_tok == '(')
tcc_error(S, "function-like macro '%s' is not defined",
get_tok_str(S, t, NULL));
goto redo;
@@ -1503,15 +1503,15 @@ static int expr_preprocess(TCCState *S)
/* parse after #define */
-ST_FUNC void parse_define(TCCState *S)
+ST_FUNC void parse_define(TCCState* S)
{
Sym *s, *first, **ps;
int v, t, varg, is_vaargs, spc;
int saved_parse_flags = S->tccpp_parse_flags;
- v = S->tok;
+ v = S->tccpp_tok;
if (v < TOK_IDENT || v == TOK_DEFINED)
- tcc_error(S, "invalid macro name '%s'", get_tok_str(S, S->tok, &S->tokc));
+ tcc_error(S, "invalid macro name '%s'", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
/* XXX: should check if same macro (ANSI) */
first = NULL;
t = MACRO_OBJ;
@@ -1523,18 +1523,18 @@ ST_FUNC void parse_define(TCCState *S)
/* '(' must be just after macro definition for MACRO_FUNC */
next_nomacro(S);
S->tccpp_parse_flags &= ~PARSE_FLAG_SPACES;
- if (S->tok == '(') {
+ if (S->tccpp_tok == '(') {
int dotid = set_idnum(S, '.', 0);
next_nomacro(S);
ps = &first;
- if (S->tok != ')') for (;;) {
- varg = S->tok;
+ if (S->tccpp_tok != ')') for (;;) {
+ varg = S->tccpp_tok;
next_nomacro(S);
is_vaargs = 0;
if (varg == TOK_DOTS) {
varg = TOK___VA_ARGS__;
is_vaargs = 1;
- } else if (S->tok == TOK_DOTS && gnu_ext) {
+ } else if (S->tccpp_tok == TOK_DOTS && gnu_ext) {
is_vaargs = 1;
next_nomacro(S);
}
@@ -1544,9 +1544,9 @@ ST_FUNC void parse_define(TCCState *S)
s = sym_push2(S, &S->tccgen_define_stack, varg | SYM_FIELD, is_vaargs, 0);
*ps = s;
ps = &s->next;
- if (S->tok == ')')
+ if (S->tccpp_tok == ')')
break;
- if (S->tok != ',' || is_vaargs)
+ if (S->tccpp_tok != ',' || is_vaargs)
goto bad_list;
next_nomacro(S);
}
@@ -1556,7 +1556,7 @@ ST_FUNC void parse_define(TCCState *S)
set_idnum(S, '.', dotid);
}
- S->tokstr_buf.len = 0;
+ S->tccpp_tokstr_buf.len = 0;
spc = 2;
S->tccpp_parse_flags |= PARSE_FLAG_ACCEPT_STRAYS | PARSE_FLAG_SPACES | PARSE_FLAG_LINEFEED;
/* The body of a macro definition should be parsed such that identifiers
@@ -1564,33 +1564,33 @@ ST_FUNC void parse_define(TCCState *S)
ID character in asm mode). But '#' should be retained instead of
regarded as line comment leader, so still don't set ASM_FILE
in parse_flags. */
- while (S->tok != TOK_LINEFEED && S->tok != TOK_EOF) {
+ while (S->tccpp_tok != TOK_LINEFEED && S->tccpp_tok != TOK_EOF) {
/* remove spaces around ## and after '#' */
- if (TOK_TWOSHARPS == S->tok) {
+ if (TOK_TWOSHARPS == S->tccpp_tok) {
if (2 == spc)
goto bad_twosharp;
if (1 == spc)
- --S->tokstr_buf.len;
+ --S->tccpp_tokstr_buf.len;
spc = 3;
- S->tok = TOK_PPJOIN;
- } else if ('#' == S->tok) {
+ S->tccpp_tok = TOK_PPJOIN;
+ } else if ('#' == S->tccpp_tok) {
spc = 4;
- } else if (check_space(S, S->tok, &spc)) {
+ } else if (check_space(S, S->tccpp_tok, &spc)) {
goto skip;
}
- tok_str_add2(S, &S->tokstr_buf, S->tok, &S->tokc);
+ tok_str_add2(S, &S->tccpp_tokstr_buf, S->tccpp_tok, &S->tccpp_tokc);
skip:
next_nomacro(S);
}
S->tccpp_parse_flags = saved_parse_flags;
if (spc == 1)
- --S->tokstr_buf.len; /* remove trailing space */
- tok_str_add(S, &S->tokstr_buf, 0);
+ --S->tccpp_tokstr_buf.len; /* remove trailing space */
+ tok_str_add(S, &S->tccpp_tokstr_buf, 0);
if (3 == spc)
bad_twosharp:
tcc_error(S, "'##' cannot appear at either end of macro");
- define_push(S, v, t, tok_str_dup(S, &S->tokstr_buf), first);
+ define_push(S, v, t, tok_str_dup(S, &S->tccpp_tokstr_buf), first);
}
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
static void pragma_parse(TCCState *S)
{
next_nomacro(S);
- if (S->tok == TOK_push_macro || S->tok == TOK_pop_macro) {
- int t = S->tok, v;
+ if (S->tccpp_tok == TOK_push_macro || S->tccpp_tok == TOK_pop_macro) {
+ int t = S->tccpp_tok, v;
Sym *s;
- if (next(S), S->tok != '(')
+ if (next(S), S->tccpp_tok != '(')
goto pragma_err;
- if (next(S), S->tok != TOK_STR)
+ if (next(S), S->tccpp_tok != TOK_STR)
goto pragma_err;
- v = tok_alloc(S, S->tokc.str.data, S->tokc.str.size - 1)->tok;
- if (next(S), S->tok != ')')
+ v = tok_alloc(S, S->tccpp_tokc.str.data, S->tccpp_tokc.str.size - 1)->tok;
+ if (next(S), S->tccpp_tok != ')')
goto pragma_err;
if (t == TOK_push_macro) {
while (NULL == (s = define_find(S, v)))
@@ -1668,7 +1668,7 @@ static void pragma_parse(TCCState *S)
tcc_warning(S, "unbalanced #pragma pop_macro");
S->tccpp_pp_debug_tok = t, S->tccpp_pp_debug_symv = v;
- } else if (S->tok == TOK_once) {
+ } else if (S->tccpp_tok == TOK_once) {
search_cached_include(S, S->tccpp_file->filename, 1)->once = S->tccpp_pp_once;
} else if (S->output_type == TCC_OUTPUT_PREPROCESS) {
@@ -1678,7 +1678,7 @@ static void pragma_parse(TCCState *S)
unget_tok(S, '#');
unget_tok(S, TOK_LINEFEED);
- } else if (S->tok == TOK_pack) {
+ } else if (S->tccpp_tok == TOK_pack) {
/* This may be:
#pragma pack(1) // set
#pragma pack() // reset to default
@@ -1687,7 +1687,7 @@ static void pragma_parse(TCCState *S)
#pragma pack(pop) // restore previous */
next(S);
skip(S, '(');
- if (S->tok == TOK_ASM_pop) {
+ if (S->tccpp_tok == TOK_ASM_pop) {
next(S);
if (S->pack_stack_ptr <= S->pack_stack) {
stk_error:
@@ -1696,19 +1696,19 @@ static void pragma_parse(TCCState *S)
S->pack_stack_ptr--;
} else {
int val = 0;
- if (S->tok != ')') {
- if (S->tok == TOK_ASM_push) {
+ if (S->tccpp_tok != ')') {
+ if (S->tccpp_tok == TOK_ASM_push) {
next(S);
if (S->pack_stack_ptr >= S->pack_stack + PACK_STACK_SIZE - 1)
goto stk_error;
val = *S->pack_stack_ptr++;
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
goto pack_set;
next(S);
}
- if (S->tok != TOK_CINT)
+ if (S->tccpp_tok != TOK_CINT)
goto pragma_err;
- val = S->tokc.i;
+ val = S->tccpp_tokc.i;
if (val < 1 || val > 16 || (val & (val - 1)) != 0)
goto pragma_err;
next(S);
@@ -1716,21 +1716,21 @@ static void pragma_parse(TCCState *S)
pack_set:
*S->pack_stack_ptr = val;
}
- if (S->tok != ')')
+ if (S->tccpp_tok != ')')
goto pragma_err;
- } else if (S->tok == TOK_comment) {
+ } else if (S->tccpp_tok == TOK_comment) {
char *p; int t;
next(S);
skip(S, '(');
- t = S->tok;
+ t = S->tccpp_tok;
next(S);
skip(S, ',');
- if (S->tok != TOK_STR)
+ if (S->tccpp_tok != TOK_STR)
goto pragma_err;
- p = tcc_strdup(S, (char *)S->tokc.str.data);
+ p = tcc_strdup(S, (char *)S->tccpp_tokc.str.data);
next(S);
- if (S->tok != ')')
+ if (S->tccpp_tok != ')')
goto pragma_err;
if (t == TOK_lib) {
dynarray_add(S, &S->pragma_libs, &S->nb_pragma_libs, p);
@@ -1741,7 +1741,7 @@ static void pragma_parse(TCCState *S)
}
} else
- tcc_warning_c(warn_unsupported)(S, "#pragma %s ignored", get_tok_str(S, S->tok, &S->tokc));
+ tcc_warning_c(warn_unsupported)(S, "#pragma %s ignored", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
return;
pragma_err:
@@ -1750,7 +1750,7 @@ pragma_err:
}
/* is_bof is true if first non space token at beginning of file */
-ST_FUNC void preprocess(TCCState *S, int is_bof)
+ST_FUNC void preprocess(TCCState* S, int is_bof)
{
int i, c, n, saved_parse_flags;
char buf[1024], *q;
@@ -1766,18 +1766,18 @@ ST_FUNC void preprocess(TCCState *S, int is_bof)
next_nomacro(S);
redo:
- switch(S->tok) {
+ switch(S->tccpp_tok) {
case TOK_DEFINE:
- S->tccpp_pp_debug_tok = S->tok;
+ S->tccpp_pp_debug_tok = S->tccpp_tok;
next_nomacro(S);
- S->tccpp_pp_debug_symv = S->tok;
+ S->tccpp_pp_debug_symv = S->tccpp_tok;
parse_define(S);
break;
case TOK_UNDEF:
- S->tccpp_pp_debug_tok = S->tok;
+ S->tccpp_pp_debug_tok = S->tccpp_tok;
next_nomacro(S);
- S->tccpp_pp_debug_symv = S->tok;
- s = define_find(S, S->tok);
+ S->tccpp_pp_debug_symv = S->tccpp_tok;
+ s = define_find(S, S->tccpp_tok);
/* undefine symbol by putting an invalid name */
if (s)
define_undef(S, s);
@@ -1822,8 +1822,8 @@ ST_FUNC void preprocess(TCCState *S, int is_bof)
| (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE));
next(S);
buf[0] = '\0';
- while (S->tok != TOK_LINEFEED) {
- pstrcat(buf, sizeof(buf), get_tok_str(S, S->tok, &S->tokc));
+ while (S->tccpp_tok != TOK_LINEFEED) {
+ pstrcat(buf, sizeof(buf), get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
next(S);
}
len = strlen(buf);
@@ -1838,7 +1838,7 @@ ST_FUNC void preprocess(TCCState *S, int is_bof)
if (S->include_stack_ptr >= S->include_stack + INCLUDE_STACK_SIZE)
tcc_error(S,"#include recursion too deep");
- i = S->tok == TOK_INCLUDE_NEXT ? S->tccpp_file->include_next_index + 1 : 0;
+ i = S->tccpp_tok == TOK_INCLUDE_NEXT ? S->tccpp_file->include_next_index + 1 : 0;
n = 2 + S->nb_include_paths + S->nb_sysinclude_paths;
for (; i < n; ++i) {
char buf1[sizeof S->tccpp_file->filename];
@@ -1898,7 +1898,7 @@ ST_FUNC void preprocess(TCCState *S, int is_bof)
}
/* add include file debug info */
tcc_debug_bincl(S);
- S->tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL;
+ S->tccpp_tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL;
S->tccpp_ch = S->tccpp_file->buf_ptr[0];
goto the_end;
}
@@ -1915,17 +1915,17 @@ include_done:
c = 0;
do_ifdef:
next_nomacro(S);
- if (S->tok < TOK_IDENT)
+ if (S->tccpp_tok < TOK_IDENT)
tcc_error(S,"invalid argument for '#if%sdef'", c ? "n" : "");
if (is_bof) {
if (c) {
#ifdef INC_DEBUG
- printf("#ifndef %s\n", get_tok_str(S, S->tok, NULL));
+ printf("#ifndef %s\n", get_tok_str(S, S->tccpp_tok, NULL));
#endif
- S->tccpp_file->ifndef_macro = S->tok;
+ S->tccpp_file->ifndef_macro = S->tccpp_tok;
}
}
- c = (define_find(S, S->tok) != 0) ^ c;
+ c = (define_find(S, S->tccpp_tok) != 0) ^ c;
do_if:
if (S->ifdef_stack_ptr >= S->ifdef_stack + IFDEF_STACK_SIZE)
tcc_error(S,"memory full (ifdef)");
@@ -1973,31 +1973,31 @@ include_done:
/* need to set to zero to avoid false matches if another
#ifndef at middle of file */
S->tccpp_file->ifndef_macro = 0;
- while (S->tok != TOK_LINEFEED)
+ while (S->tccpp_tok != TOK_LINEFEED)
next_nomacro(S);
- S->tok_flags |= TOK_FLAG_ENDIF;
+ S->tccpp_tok_flags |= TOK_FLAG_ENDIF;
goto the_end;
}
break;
case TOK_PPNUM:
- n = strtoul((char*)S->tokc.str.data, &q, 10);
+ n = strtoul((char*)S->tccpp_tokc.str.data, &q, 10);
goto _line_num;
case TOK_LINE:
next(S);
- if (S->tok != TOK_CINT)
+ if (S->tccpp_tok != TOK_CINT)
_line_err:
tcc_error(S,"wrong #line format");
- n = S->tokc.i;
+ n = S->tccpp_tokc.i;
_line_num:
next(S);
- if (S->tok != TOK_LINEFEED) {
- if (S->tok == TOK_STR) {
+ if (S->tccpp_tok != TOK_LINEFEED) {
+ if (S->tccpp_tok == TOK_STR) {
if (S->tccpp_file->true_filename == S->tccpp_file->filename)
S->tccpp_file->true_filename = tcc_strdup(S, S->tccpp_file->filename);
/* prepend directory from real file */
pstrcpy(buf, sizeof buf, S->tccpp_file->true_filename);
*tcc_basename(buf) = 0;
- pstrcat(buf, sizeof buf, (char *)S->tokc.str.data);
+ pstrcat(buf, sizeof buf, (char *)S->tccpp_tokc.str.data);
tcc_debug_putfile(S, buf);
} else if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE)
break;
@@ -2011,7 +2011,7 @@ include_done:
break;
case TOK_ERROR:
case TOK_WARNING:
- c = S->tok;
+ c = S->tccpp_tok;
S->tccpp_ch = S->tccpp_file->buf_ptr[0];
skip_spaces(S);
q = buf;
@@ -2039,23 +2039,23 @@ include_done:
/* ignore gas line comment in an 'S' file. */
if (saved_parse_flags & PARSE_FLAG_ASM_FILE)
goto ignore;
- if (S->tok == '!' && is_bof)
+ if (S->tccpp_tok == '!' && is_bof)
/* '!' is ignored at beginning to allow C scripts. */
goto ignore;
- tcc_warning(S,"Ignoring unknown preprocessing directive #%s", get_tok_str(S, S->tok, &S->tokc));
+ tcc_warning(S,"Ignoring unknown preprocessing directive #%s", get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
ignore:
S->tccpp_file->buf_ptr = parse_line_comment(S, S->tccpp_file->buf_ptr - 1);
goto the_end;
}
/* ignore other preprocess commands or #! for C scripts */
- while (S->tok != TOK_LINEFEED)
+ while (S->tccpp_tok != TOK_LINEFEED)
next_nomacro(S);
the_end:
S->tccpp_parse_flags = saved_parse_flags;
}
/* evaluate escape codes in a string. */
-static void parse_escape_string(TCCState *S, CString *outstr, const uint8_t *buf, int is_long)
+static void parse_escape_string(TCCState* S, CString *outstr, const uint8_t *buf, int is_long)
{
int c, n, i;
const uint8_t *p;
@@ -2232,7 +2232,7 @@ static void parse_escape_string(TCCState *S, CString *outstr, const uint8_t *buf
cstr_wccat(S, outstr, '\0');
}
-static void parse_string(TCCState *S, const char *s, int len)
+static void parse_string(TCCState* S, const char *s, int len)
{
uint8_t buf[1000], *p = buf;
int is_long, sep;
@@ -2246,8 +2246,8 @@ static void parse_string(TCCState *S, const char *s, int len)
memcpy(p, s, len);
p[len] = 0;
- cstr_reset(&S->tokcstr);
- parse_escape_string(S, &S->tokcstr, p, is_long);
+ cstr_reset(&S->tccpp_tokcstr);
+ parse_escape_string(S, &S->tccpp_tokcstr, p, is_long);
if (p != buf)
tcc_free(S, p);
@@ -2255,28 +2255,28 @@ static void parse_string(TCCState *S, const char *s, int len)
int char_size, i, n, c;
/* XXX: make it portable */
if (!is_long)
- S->tok = TOK_CCHAR, char_size = 1;
+ S->tccpp_tok = TOK_CCHAR, char_size = 1;
else
- S->tok = TOK_LCHAR, char_size = sizeof(nwchar_t);
- n = S->tokcstr.size / char_size - 1;
+ S->tccpp_tok = TOK_LCHAR, char_size = sizeof(nwchar_t);
+ n = S->tccpp_tokcstr.size / char_size - 1;
if (n < 1)
tcc_error(S,"empty character constant");
if (n > 1)
tcc_warning_c(warn_all)(S,"multi-character character constant");
for (c = i = 0; i < n; ++i) {
if (is_long)
- c = ((nwchar_t *)S->tokcstr.data)[i];
+ c = ((nwchar_t *)S->tccpp_tokcstr.data)[i];
else
- c = (c << 8) | ((char *)S->tokcstr.data)[i];
+ c = (c << 8) | ((char *)S->tccpp_tokcstr.data)[i];
}
- S->tokc.i = c;
+ S->tccpp_tokc.i = c;
} else {
- S->tokc.str.size = S->tokcstr.size;
- S->tokc.str.data = S->tokcstr.data;
+ S->tccpp_tokc.str.size = S->tccpp_tokcstr.size;
+ S->tccpp_tokc.str.data = S->tccpp_tokcstr.data;
if (!is_long)
- S->tok = TOK_STR;
+ S->tccpp_tok = TOK_STR;
else
- S->tok = TOK_LSTR;
+ S->tccpp_tok = TOK_LSTR;
}
}
@@ -2305,7 +2305,7 @@ static void bn_zero(unsigned int *bn)
/* parse number in null terminated string 'p' and return it in the
current token */
-static void parse_number(TCCState *S, const char *p)
+static void parse_number(TCCState* S, const char *p)
{
int b, t, shift, frac_bits, s, exp_val, ch;
char *q;
@@ -2313,7 +2313,7 @@ static void parse_number(TCCState *S, const char *p)
double d;
/* number */
- q = S->token_buf;
+ q = S->tccpp_token_buf;
ch = *p++;
t = ch;
ch = *p++;
@@ -2345,7 +2345,7 @@ static void parse_number(TCCState *S, const char *p)
break;
if (t >= b)
break;
- if (q >= S->token_buf + STRING_MAX_SIZE) {
+ if (q >= S->tccpp_token_buf + STRING_MAX_SIZE) {
num_too_long:
tcc_error(S,"number too long");
}
@@ -2367,7 +2367,7 @@ static void parse_number(TCCState *S, const char *p)
else
shift = 1;
bn_zero(bn);
- q = S->token_buf;
+ q = S->tccpp_token_buf;
while (1) {
t = *q++;
if (t == '\0') {
@@ -2428,45 +2428,45 @@ static void parse_number(TCCState *S, const char *p)
t = toup(ch);
if (t == 'F') {
ch = *p++;
- S->tok = TOK_CFLOAT;
+ S->tccpp_tok = TOK_CFLOAT;
/* float : should handle overflow */
- S->tokc.f = (float)d;
+ S->tccpp_tokc.f = (float)d;
} else if (t == 'L') {
ch = *p++;
#ifdef TCC_USING_DOUBLE_FOR_LDOUBLE
- S->tok = TOK_CDOUBLE;
- S->tokc.d = d;
+ S->tccpp_tok = TOK_CDOUBLE;
+ S->tccpp_tokc.d = d;
#else
- S->tok = TOK_CLDOUBLE;
+ S->tccpp_tok = TOK_CLDOUBLE;
/* XXX: not large enough */
- S->tokc.ld = (long double)d;
+ S->tccpp_tokc.ld = (long double)d;
#endif
} else {
- S->tok = TOK_CDOUBLE;
- S->tokc.d = d;
+ S->tccpp_tok = TOK_CDOUBLE;
+ S->tccpp_tokc.d = d;
}
} else {
/* decimal floats */
if (ch == '.') {
- if (q >= S->token_buf + STRING_MAX_SIZE)
+ if (q >= S->tccpp_token_buf + STRING_MAX_SIZE)
goto num_too_long;
*q++ = ch;
ch = *p++;
float_frac_parse:
while (ch >= '0' && ch <= '9') {
- if (q >= S->token_buf + STRING_MAX_SIZE)
+ if (q >= S->tccpp_token_buf + STRING_MAX_SIZE)
goto num_too_long;
*q++ = ch;
ch = *p++;
}
}
if (ch == 'e' || ch == 'E') {
- if (q >= S->token_buf + STRING_MAX_SIZE)
+ if (q >= S->tccpp_token_buf + STRING_MAX_SIZE)
goto num_too_long;
*q++ = ch;
ch = *p++;
if (ch == '-' || ch == '+') {
- if (q >= S->token_buf + STRING_MAX_SIZE)
+ if (q >= S->tccpp_token_buf + STRING_MAX_SIZE)
goto num_too_long;
*q++ = ch;
ch = *p++;
@@ -2474,7 +2474,7 @@ static void parse_number(TCCState *S, const char *p)
if (ch < '0' || ch > '9')
expect(S, "exponent digits");
while (ch >= '0' && ch <= '9') {
- if (q >= S->token_buf + STRING_MAX_SIZE)
+ if (q >= S->tccpp_token_buf + STRING_MAX_SIZE)
goto num_too_long;
*q++ = ch;
ch = *p++;
@@ -2485,20 +2485,20 @@ static void parse_number(TCCState *S, const char *p)
errno = 0;
if (t == 'F') {
ch = *p++;
- S->tok = TOK_CFLOAT;
- S->tokc.f = strtof(S->token_buf, NULL);
+ S->tccpp_tok = TOK_CFLOAT;
+ S->tccpp_tokc.f = strtof(S->tccpp_token_buf, NULL);
} else if (t == 'L') {
ch = *p++;
#ifdef TCC_USING_DOUBLE_FOR_LDOUBLE
- S->tok = TOK_CDOUBLE;
- S->tokc.d = strtod(S->token_buf, NULL);
+ S->tccpp_tok = TOK_CDOUBLE;
+ S->tccpp_tokc.d = strtod(S->tccpp_token_buf, NULL);
#else
- S->tok = TOK_CLDOUBLE;
- S->tokc.ld = strtold(S->token_buf, NULL);
+ S->tccpp_tok = TOK_CLDOUBLE;
+ S->tccpp_tokc.ld = strtold(S->tccpp_token_buf, NULL);
#endif
} else {
- S->tok = TOK_CDOUBLE;
- S->tokc.d = strtod(S->token_buf, NULL);
+ S->tccpp_tok = TOK_CDOUBLE;
+ S->tccpp_tokc.d = strtod(S->tccpp_token_buf, NULL);
}
}
} else {
@@ -2508,7 +2508,7 @@ static void parse_number(TCCState *S, const char *p)
/* integer number */
*q = '\0';
- q = S->token_buf;
+ q = S->tccpp_token_buf;
if (b == 10 && *q == '0') {
b = 8;
q++;
@@ -2579,15 +2579,15 @@ static void parse_number(TCCState *S, const char *p)
if (ov)
tcc_warning(S, "integer constant overflow");
- S->tok = TOK_CINT;
+ S->tccpp_tok = TOK_CINT;
if (lcount) {
- S->tok = TOK_CLONG;
+ S->tccpp_tok = TOK_CLONG;
if (lcount == 2)
- S->tok = TOK_CLLONG;
+ S->tccpp_tok = TOK_CLLONG;
}
if (ucount)
- ++S->tok; /* TOK_CU... */
- S->tokc.i = n;
+ ++S->tccpp_tok; /* TOK_CU... */
+ S->tccpp_tokc.i = n;
}
if (ch)
tcc_error(S,"invalid number");
@@ -2599,14 +2599,14 @@ static void parse_number(TCCState *S, const char *p)
PEEKC(c, p); \
if (c == c2) { \
p++; \
- S->tok = tok2; \
+ S->tccpp_tok = tok2; \
} else { \
- S->tok = tok1; \
+ S->tccpp_tok = tok1; \
} \
break;
/* return next token without macro substitution */
-static inline void next_nomacro1(TCCState *S)
+static inline void next_nomacro1(TCCState* S)
{
int t, c, is_long, len;
TokenSym *ts;
@@ -2619,7 +2619,7 @@ static inline void next_nomacro1(TCCState *S)
switch(c) {
case ' ':
case '\t':
- S->tok = c;
+ S->tccpp_tok = c;
p++;
maybe_space:
if (S->tccpp_parse_flags & PARSE_FLAG_SPACES)
@@ -2642,30 +2642,30 @@ static inline void next_nomacro1(TCCState *S)
goto redo_no_start;
{
if ((S->tccpp_parse_flags & PARSE_FLAG_LINEFEED)
- && !(S->tok_flags & TOK_FLAG_EOF)) {
- S->tok_flags |= TOK_FLAG_EOF;
- S->tok = TOK_LINEFEED;
+ && !(S->tccpp_tok_flags & TOK_FLAG_EOF)) {
+ S->tccpp_tok_flags |= TOK_FLAG_EOF;
+ S->tccpp_tok = TOK_LINEFEED;
goto keep_tok_flags;
} else if (!(S->tccpp_parse_flags & PARSE_FLAG_PREPROCESS)) {
- S->tok = TOK_EOF;
+ S->tccpp_tok = TOK_EOF;
} else if (S->ifdef_stack_ptr != S->tccpp_file->ifdef_stack_ptr) {
tcc_error(S,"missing #endif");
} else if (S->include_stack_ptr == S->include_stack) {
/* no include left : end of file. */
- S->tok = TOK_EOF;
+ S->tccpp_tok = TOK_EOF;
} else {
- S->tok_flags &= ~TOK_FLAG_EOF;
+ S->tccpp_tok_flags &= ~TOK_FLAG_EOF;
/* pop include file */
/* test if previous '#endif' was after a #ifdef at
start of file */
- if (S->tok_flags & TOK_FLAG_ENDIF) {
+ if (S->tccpp_tok_flags & TOK_FLAG_ENDIF) {
#ifdef INC_DEBUG
printf("#endif %s\n", get_tok_str(S, S->tccpp_file->ifndef_macro_saved, NULL));
#endif
search_cached_include(S, S->tccpp_file->filename, 1)
->ifndef_macro = S->tccpp_file->ifndef_macro_saved;
- S->tok_flags &= ~TOK_FLAG_ENDIF;
+ S->tccpp_tok_flags &= ~TOK_FLAG_ENDIF;
}
/* add end of include file debug info */
@@ -2675,7 +2675,7 @@ static inline void next_nomacro1(TCCState *S)
S->include_stack_ptr--;
p = S->tccpp_file->buf_ptr;
if (p == S->tccpp_file->buffer)
- S->tok_flags = TOK_FLAG_BOF|TOK_FLAG_BOL;
+ S->tccpp_tok_flags = TOK_FLAG_BOF|TOK_FLAG_BOL;
goto redo_no_start;
}
}
@@ -2683,27 +2683,27 @@ static inline void next_nomacro1(TCCState *S)
case '\n':
S->tccpp_file->line_num++;
- S->tok_flags |= TOK_FLAG_BOL;
+ S->tccpp_tok_flags |= TOK_FLAG_BOL;
p++;
maybe_newline:
if (0 == (S->tccpp_parse_flags & PARSE_FLAG_LINEFEED))
goto redo_no_start;
- S->tok = TOK_LINEFEED;
+ S->tccpp_tok = TOK_LINEFEED;
goto keep_tok_flags;
case '#':
/* XXX: simplify */
PEEKC(c, p);
- if ((S->tok_flags & TOK_FLAG_BOL) &&
+ if ((S->tccpp_tok_flags & TOK_FLAG_BOL) &&
(S->tccpp_parse_flags & PARSE_FLAG_PREPROCESS)) {
S->tccpp_file->buf_ptr = p;
- preprocess(S, S->tok_flags & TOK_FLAG_BOF);
+ preprocess(S, S->tccpp_tok_flags & TOK_FLAG_BOF);
p = S->tccpp_file->buf_ptr;
goto maybe_newline;
} else {
if (c == '#') {
p++;
- S->tok = TOK_TWOSHARPS;
+ S->tccpp_tok = TOK_TWOSHARPS;
} else {
#if !defined(TCC_TARGET_ARM)
if (S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE) {
@@ -2712,7 +2712,7 @@ maybe_newline:
} else
#endif
{
- S->tok = '#';
+ S->tccpp_tok = '#';
}
}
}
@@ -2765,19 +2765,19 @@ maybe_newline:
token_found: ;
} else {
/* slower case */
- cstr_reset(&S->tokcstr);
- cstr_cat(S, &S->tokcstr, (char *) p1, len);
+ cstr_reset(&S->tccpp_tokcstr);
+ cstr_cat(S, &S->tccpp_tokcstr, (char *) p1, len);
p--;
PEEKC(c, p);
parse_ident_slow:
while (S->tccpp_isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
{
- cstr_ccat(S, &S->tokcstr, c);
+ cstr_ccat(S, &S->tccpp_tokcstr, c);
PEEKC(c, p);
}
- ts = tok_alloc(S, S->tokcstr.data, S->tokcstr.size);
+ ts = tok_alloc(S, S->tccpp_tokcstr.data, S->tccpp_tokcstr.size);
}
- S->tok = ts->tok;
+ S->tccpp_tok = ts->tok;
break;
case 'L':
t = p[1];
@@ -2790,8 +2790,8 @@ maybe_newline:
is_long = 1;
goto str_const;
} else {
- cstr_reset(&S->tokcstr);
- cstr_ccat(S, &S->tokcstr, 'L');
+ cstr_reset(&S->tccpp_tokcstr);
+ cstr_ccat(S, &S->tccpp_tokcstr, 'L');
goto parse_ident_slow;
}
}
@@ -2805,27 +2805,27 @@ maybe_newline:
/* after the first digit, accept digits, alpha, '.' or sign if
prefixed by 'eEpP' */
parse_num:
- cstr_reset(&S->tokcstr);
+ cstr_reset(&S->tccpp_tokcstr);
for(;;) {
- cstr_ccat(S, &S->tokcstr, t);
+ cstr_ccat(S, &S->tccpp_tokcstr, t);
if (!((S->tccpp_isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
|| c == '.'
|| ((c == '+' || c == '-')
&& (((t == 'e' || t == 'E')
&& !(S->tccpp_parse_flags & PARSE_FLAG_ASM_FILE
/* 0xe+1 is 3 tokens in asm */
- && ((char*)S->tokcstr.data)[0] == '0'
- && toup(((char*)S->tokcstr.data)[1]) == 'X'))
+ && ((char*)S->tccpp_tokcstr.data)[0] == '0'
+ && toup(((char*)S->tccpp_tokcstr.data)[1]) == 'X'))
|| t == 'p' || t == 'P'))))
break;
t = c;
PEEKC(c, p);
}
/* We add a trailing '\0' to ease parsing */
- cstr_ccat(S, &S->tokcstr, '\0');
- S->tokc.str.size = S->tokcstr.size;
- S->tokc.str.data = S->tokcstr.data;
- S->tok = TOK_PPNUM;
+ cstr_ccat(S, &S->tccpp_tokcstr, '\0');
+ S->tccpp_tokc.str.size = S->tccpp_tokcstr.size;
+ S->tccpp_tokc.str.data = S->tccpp_tokcstr.data;
+ S->tccpp_tok = TOK_PPNUM;
break;
case '.':
@@ -2842,63 +2842,63 @@ maybe_newline:
PEEKC(c, p);
if (c == '.') {
p++;
- S->tok = TOK_DOTS;
+ S->tccpp_tok = TOK_DOTS;
} else {
*--p = '.'; /* may underflow into file->unget[] */
- S->tok = '.';
+ S->tccpp_tok = '.';
}
} else {
- S->tok = '.';
+ S->tccpp_tok = '.';
}
break;
case '\'':
case '\"':
is_long = 0;
str_const:
- cstr_reset(&S->tokcstr);
+ cstr_reset(&S->tccpp_tokcstr);
if (is_long)
- cstr_ccat(S, &S->tokcstr, 'L');
- cstr_ccat(S, &S->tokcstr, c);
- p = parse_pp_string(S, p, c, &S->tokcstr);
- cstr_ccat(S, &S->tokcstr, c);
- cstr_ccat(S, &S->tokcstr, '\0');
- S->tokc.str.size = S->tokcstr.size;
- S->tokc.str.data = S->tokcstr.data;
- S->tok = TOK_PPSTR;
+ cstr_ccat(S, &S->tccpp_tokcstr, 'L');
+ cstr_ccat(S, &S->tccpp_tokcstr, c);
+ p = parse_pp_string(S, p, c, &S->tccpp_tokcstr);
+ cstr_ccat(S, &S->tccpp_tokcstr, c);
+ cstr_ccat(S, &S->tccpp_tokcstr, '\0');
+ S->tccpp_tokc.str.size = S->tccpp_tokcstr.size;
+ S->tccpp_tokc.str.data = S->tccpp_tokcstr.data;
+ S->tccpp_tok = TOK_PPSTR;
break;
case '<':
PEEKC(c, p);
if (c == '=') {
p++;
- S->tok = TOK_LE;
+ S->tccpp_tok = TOK_LE;
} else if (c == '<') {
PEEKC(c, p);
if (c == '=') {
p++;
- S->tok = TOK_A_SHL;
+ S->tccpp_tok = TOK_A_SHL;
} else {
- S->tok = TOK_SHL;
+ S->tccpp_tok = TOK_SHL;
}
} else {
- S->tok = TOK_LT;
+ S->tccpp_tok = TOK_LT;
}
break;
case '>':
PEEKC(c, p);
if (c == '=') {
p++;
- S->tok = TOK_GE;
+ S->tccpp_tok = TOK_GE;
} else if (c == '>') {
PEEKC(c, p);
if (c == '=') {
p++;
- S->tok = TOK_A_SAR;
+ S->tccpp_tok = TOK_A_SAR;
} else {
- S->tok = TOK_SAR;
+ S->tccpp_tok = TOK_SAR;
}
} else {
- S->tok = TOK_GT;
+ S->tccpp_tok = TOK_GT;
}
break;
@@ -2906,12 +2906,12 @@ maybe_newline:
PEEKC(c, p);
if (c == '&') {
p++;
- S->tok = TOK_LAND;
+ S->tccpp_tok = TOK_LAND;
} else if (c == '=') {
p++;
- S->tok = TOK_A_AND;
+ S->tccpp_tok = TOK_A_AND;
} else {
- S->tok = '&';
+ S->tccpp_tok = '&';
}
break;
@@ -2919,12 +2919,12 @@ maybe_newline:
PEEKC(c, p);
if (c == '|') {
p++;
- S->tok = TOK_LOR;
+ S->tccpp_tok = TOK_LOR;
} else if (c == '=') {
p++;
- S->tok = TOK_A_OR;
+ S->tccpp_tok = TOK_A_OR;
} else {
- S->tok = '|';
+ S->tccpp_tok = '|';
}
break;
@@ -2932,12 +2932,12 @@ maybe_newline:
PEEKC(c, p);
if (c == '+') {
p++;
- S->tok = TOK_INC;
+ S->tccpp_tok = TOK_INC;
} else if (c == '=') {
p++;
- S->tok = TOK_A_ADD;
+ S->tccpp_tok = TOK_A_ADD;
} else {
- S->tok = '+';
+ S->tccpp_tok = '+';
}
break;
@@ -2945,15 +2945,15 @@ maybe_newline:
PEEKC(c, p);
if (c == '-') {
p++;
- S->tok = TOK_DEC;
+ S->tccpp_tok = TOK_DEC;
} else if (c == '=') {
p++;
- S->tok = TOK_A_SUB;
+ S->tccpp_tok = TOK_A_SUB;
} else if (c == '>') {
p++;
- S->tok = TOK_ARROW;
+ S->tccpp_tok = TOK_ARROW;
} else {
- S->tok = '-';
+ S->tccpp_tok = '-';
}
break;
@@ -2969,17 +2969,17 @@ maybe_newline:
if (c == '*') {
p = parse_comment(S, p);
/* comments replaced by a blank */
- S->tok = ' ';
+ S->tccpp_tok = ' ';
goto maybe_space;
} else if (c == '/') {
p = parse_line_comment(S, p);
- S->tok = ' ';
+ S->tccpp_tok = ' ';
goto maybe_space;
} else if (c == '=') {
p++;
- S->tok = TOK_A_DIV;
+ S->tccpp_tok = TOK_A_DIV;
} else {
- S->tok = '/';
+ S->tccpp_tok = '/';
}
break;
@@ -2997,7 +2997,7 @@ maybe_newline:
case '~':
case '@': /* only used in assembler */
parse_simple:
- S->tok = c;
+ S->tccpp_tok = c;
p++;
break;
default:
@@ -3008,15 +3008,15 @@ maybe_newline:
tcc_error(S,"unrecognized character \\x%02x", c);
break;
}
- S->tok_flags = 0;
+ S->tccpp_tok_flags = 0;
keep_tok_flags:
S->tccpp_file->buf_ptr = p;
#if defined(PARSE_DEBUG)
- printf("token = %d %s\n", S->tok, get_tok_str(S, S->tok, &S->tokc));
+ printf("token = %d %s\n", S->tccpp_tok, get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc));
#endif
}
-static void macro_subst(TCCState *S,
+static void macro_subst(TCCState* S,
TokenString *tok_str,
Sym **nested_list,
const int *macro_str
@@ -3024,7 +3024,7 @@ static void macro_subst(TCCState *S,
/* substitute arguments in replacement lists in macro_str by the values in
args (field d) and return allocated string */
-static int *macro_arg_subst(TCCState *S, Sym **nested_list, const int *macro_str, Sym *args)
+static int *macro_arg_subst(TCCState* S, Sym **nested_list, const int *macro_str, Sym *args)
{
int t, t0, t1, spc;
const int *st;
@@ -3142,7 +3142,7 @@ static char const ab_month_name[12][4] =
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
-static int paste_tokens(TCCState *S, int t1, CValue *v1, int t2, CValue *v2)
+static int paste_tokens(TCCState* S, int t1, CValue *v1, int t2, CValue *v2)
{
CString cstr;
int n, ret = 1;
@@ -3157,12 +3157,12 @@ static int paste_tokens(TCCState *S, int t1, CValue *v1, int t2, CValue *v2)
tcc_open_bf(S, ":paste:", cstr.size);
memcpy(S->tccpp_file->buffer, cstr.data, cstr.size);
- S->tok_flags = 0;
+ S->tccpp_tok_flags = 0;
for (;;) {
next_nomacro1(S);
if (0 == *S->tccpp_file->buf_ptr)
break;
- if (is_space(S->tok))
+ if (is_space(S->tccpp_tok))
continue;
tcc_warning(S, "pasting \"%.*s\" and \"%s\" does not give a valid"
" 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)
/* handle the '##' operator. Return NULL if no '##' seen. Otherwise
return the resulting string (which must be freed). */
-static inline int *macro_twosharps(TCCState *S, const int *ptr0)
+static inline int *macro_twosharps(TCCState* S, const int *ptr0)
{
int t;
CValue cval;
@@ -3215,7 +3215,7 @@ static inline int *macro_twosharps(TCCState *S, const int *ptr0)
TOK_GET(&t1, &ptr, &cv1);
if (t != TOK_PLCHLDR || t1 != TOK_PLCHLDR) {
if (paste_tokens(S, t, &cval, t1, &cv1)) {
- t = S->tok, cval = S->tokc;
+ t = S->tccpp_tok, cval = S->tccpp_tokc;
} else {
tok_str_add2(S, &macro_str1, t, &cval);
t = t1, cval = cv1;
@@ -3238,7 +3238,7 @@ static inline int *macro_twosharps(TCCState *S, const int *ptr0)
/* peek or read [ws_str == NULL] next token from function macro call,
walking up macro levels up to the file if necessary */
-static int next_argstream(TCCState *S, Sym **nested_list, TokenString *ws_str)
+static int next_argstream(TCCState* S, Sym **nested_list, TokenString *ws_str)
{
int t;
const int *p;
@@ -3292,7 +3292,7 @@ static int next_argstream(TCCState *S, Sym **nested_list, TokenString *ws_str)
if (ws_str)
return t;
next_nomacro(S);
- return S->tok;
+ return S->tccpp_tok;
}
}
@@ -3300,7 +3300,7 @@ static int next_argstream(TCCState *S, Sym **nested_list, TokenString *ws_str)
result to (tok_str,tok_len). 'nested_list' is the list of all
macros we got inside to avoid recursing. Return non zero if no
substitution needs to be done */
-static int macro_subst_tok(TCCState *S,
+static int macro_subst_tok(TCCState* S,
TokenString *tok_str,
Sym **nested_list,
Sym *s)
@@ -3315,22 +3315,22 @@ static int macro_subst_tok(TCCState *S,
/* if symbol is a macro, prepare substitution */
/* special macros */
- if (S->tok == TOK___LINE__ || S->tok == TOK___COUNTER__) {
- t = S->tok == TOK___LINE__ ? S->tccpp_file->line_num : S->tccpp_pp_counter++;
+ if (S->tccpp_tok == TOK___LINE__ || S->tccpp_tok == TOK___COUNTER__) {
+ t = S->tccpp_tok == TOK___LINE__ ? S->tccpp_file->line_num : S->tccpp_pp_counter++;
snprintf(buf, sizeof(buf), "%d", t);
cstrval = buf;
t1 = TOK_PPNUM;
goto add_cstr1;
- } else if (S->tok == TOK___FILE__) {
+ } else if (S->tccpp_tok == TOK___FILE__) {
cstrval = S->tccpp_file->filename;
goto add_cstr;
- } else if (S->tok == TOK___DATE__ || S->tok == TOK___TIME__) {
+ } else if (S->tccpp_tok == TOK___DATE__ || S->tccpp_tok == TOK___TIME__) {
time_t ti;
struct tm *tm;
time(&ti);
tm = localtime(&ti);
- if (S->tok == TOK___DATE__) {
+ if (S->tccpp_tok == TOK___DATE__) {
snprintf(buf, sizeof(buf), "%s %2d %d",
ab_month_name[tm->tm_mon], tm->tm_mday, tm->tm_year + 1900);
} else {
@@ -3369,7 +3369,7 @@ static int macro_subst_tok(TCCState *S,
* whitespace is intentionally not merged to preserve
* newlines. */
S->tccpp_parse_flags = saved_parse_flags;
- tok_str_add(S, tok_str, S->tok);
+ tok_str_add(S, tok_str, S->tccpp_tok);
if (S->tccpp_parse_flags & PARSE_FLAG_SPACES) {
int i;
for (i = 0; i < ws_str.len; i++)
@@ -3382,7 +3382,7 @@ static int macro_subst_tok(TCCState *S,
}
do {
next_nomacro(S); /* eat '(' */
- } while (S->tok == TOK_PLCHLDR || is_space(S->tok));
+ } while (S->tccpp_tok == TOK_PLCHLDR || is_space(S->tccpp_tok));
/* argument macro */
args = NULL;
@@ -3391,11 +3391,11 @@ static int macro_subst_tok(TCCState *S,
for(;;) {
do {
next_argstream(S, nested_list, NULL);
- } while (S->tok == TOK_PLCHLDR || is_space(S->tok) ||
- TOK_LINEFEED == S->tok);
+ } while (S->tccpp_tok == TOK_PLCHLDR || is_space(S->tccpp_tok) ||
+ TOK_LINEFEED == S->tccpp_tok);
empty_arg:
/* handle '()' case */
- if (!args && !sa && S->tok == ')')
+ if (!args && !sa && S->tccpp_tok == ')')
break;
if (!sa)
tcc_error(S,"macro '%s' used with too many args",
@@ -3404,18 +3404,18 @@ static int macro_subst_tok(TCCState *S,
parlevel = spc = 0;
/* NOTE: non zero sa->t indicates VA_ARGS */
while ((parlevel > 0 ||
- (S->tok != ')' &&
- (S->tok != ',' || sa->type.t)))) {
- if (S->tok == TOK_EOF || S->tok == 0)
+ (S->tccpp_tok != ')' &&
+ (S->tccpp_tok != ',' || sa->type.t)))) {
+ if (S->tccpp_tok == TOK_EOF || S->tccpp_tok == 0)
break;
- if (S->tok == '(')
+ if (S->tccpp_tok == '(')
parlevel++;
- else if (S->tok == ')')
+ else if (S->tccpp_tok == ')')
parlevel--;
- if (S->tok == TOK_LINEFEED)
- S->tok = ' ';
- if (!check_space(S, S->tok, &spc))
- tok_str_add2(S, &str, S->tok, &S->tokc);
+ if (S->tccpp_tok == TOK_LINEFEED)
+ S->tccpp_tok = ' ';
+ if (!check_space(S, S->tccpp_tok, &spc))
+ tok_str_add2(S, &str, S->tccpp_tok, &S->tccpp_tokc);
next_argstream(S, nested_list, NULL);
}
if (parlevel)
@@ -3426,14 +3426,14 @@ static int macro_subst_tok(TCCState *S,
sa1 = sym_push2(S, &args, sa->v & ~SYM_FIELD, sa->type.t, 0);
sa1->d = str.str;
sa = sa->next;
- if (S->tok == ')') {
+ if (S->tccpp_tok == ')') {
/* special case for gcc var args: add an empty
var arg argument if it is omitted */
if (sa && sa->type.t && gnu_ext)
goto empty_arg;
break;
}
- if (S->tok != ',')
+ if (S->tccpp_tok != ',')
expect(S, ",");
}
if (sa) {
@@ -3478,7 +3478,7 @@ static int macro_subst_tok(TCCState *S,
/* do macro substitution of macro_str and add result to
(tok_str,tok_len). 'nested_list' is the list of all macros we got
inside to avoid recursing. */
-static void macro_subst(TCCState *S,
+static void macro_subst(TCCState* S,
TokenString *tok_str,
Sym **nested_list,
const int *macro_str
@@ -3512,7 +3512,7 @@ static void macro_subst(TCCState *S,
str->str = (int*)macro_str;
begin_macro(S, str, 2);
- S->tok = t;
+ S->tccpp_tok = t;
macro_subst_tok(S, tok_str, nested_list, s);
if (S->tccpp_macro_stack != str) {
@@ -3546,16 +3546,16 @@ no_subst:
/* return next token without macro substitution. Can read input from
macro_ptr buffer */
-static void next_nomacro(TCCState *S)
+static void next_nomacro(TCCState* S)
{
int t;
if (S->tccpp_macro_ptr) {
redo:
t = *S->tccpp_macro_ptr;
if (TOK_HAS_VALUE(t)) {
- tok_get(&S->tok, &S->tccpp_macro_ptr, &S->tokc);
+ tok_get(&S->tccpp_tok, &S->tccpp_macro_ptr, &S->tccpp_tokc);
if (t == TOK_LINENUM) {
- S->tccpp_file->line_num = S->tokc.i;
+ S->tccpp_file->line_num = S->tccpp_tokc.i;
goto redo;
}
} else {
@@ -3565,7 +3565,7 @@ static void next_nomacro(TCCState *S)
&& (S->tccpp_isidnum_table[t - CH_EOF] & IS_SPC))
goto redo;
}
- S->tok = t;
+ S->tccpp_tok = t;
}
} else {
next_nomacro1(S);
@@ -3573,12 +3573,12 @@ static void next_nomacro(TCCState *S)
}
/* return next token with macro substitution */
-ST_FUNC void next(TCCState *S)
+ST_FUNC void next(TCCState* S)
{
int t;
redo:
next_nomacro(S);
- t = S->tok;
+ t = S->tccpp_tok;
if (S->tccpp_macro_ptr) {
if (!TOK_HAS_VALUE(t)) {
if (t == TOK_NOSUBST || t == TOK_PLCHLDR) {
@@ -3599,10 +3599,10 @@ ST_FUNC void next(TCCState *S)
Sym *s = define_find(S, t);
if (s) {
Sym *nested_list = NULL;
- S->tokstr_buf.len = 0;
- macro_subst_tok(S, &S->tokstr_buf, &nested_list, s);
- tok_str_add(S, &S->tokstr_buf, 0);
- begin_macro(S, &S->tokstr_buf, 0);
+ S->tccpp_tokstr_buf.len = 0;
+ macro_subst_tok(S, &S->tccpp_tokstr_buf, &nested_list, s);
+ tok_str_add(S, &S->tccpp_tokstr_buf, 0);
+ begin_macro(S, &S->tccpp_tokstr_buf, 0);
goto redo;
}
return;
@@ -3610,23 +3610,23 @@ ST_FUNC void next(TCCState *S)
/* convert preprocessor tokens into C tokens */
if (t == TOK_PPNUM) {
if (S->tccpp_parse_flags & PARSE_FLAG_TOK_NUM)
- parse_number(S, (char *)S->tokc.str.data);
+ parse_number(S, (char *)S->tccpp_tokc.str.data);
} else if (t == TOK_PPSTR) {
if (S->tccpp_parse_flags & PARSE_FLAG_TOK_STR)
- parse_string(S, (char *)S->tokc.str.data, S->tokc.str.size - 1);
+ parse_string(S, (char *)S->tccpp_tokc.str.data, S->tccpp_tokc.str.size - 1);
}
}
/* push back current token and set current token to 'last_tok'. Only
identifier case handled for labels. */
-ST_INLN void unget_tok(TCCState *S, int last_tok)
+ST_INLN void unget_tok(TCCState* S, int last_tok)
{
TokenString *str = tok_str_alloc(S);
- tok_str_add2(S, str, S->tok, &S->tokc);
+ tok_str_add2(S, str, S->tccpp_tok, &S->tccpp_tokc);
tok_str_add(S, str, 0);
begin_macro(S, str, 1);
- S->tok = last_tok;
+ S->tccpp_tok = last_tok;
}
/* ------------------------------------------------------------------------- */
@@ -3658,7 +3658,7 @@ static const char * const target_os_defs =
#endif
;
-static void putdef(TCCState *S, CString *cs, const char *p)
+static void putdef(TCCState* S, CString *cs, const char *p)
{
cstr_printf(S, cs, "#define %s%s\n", p, &" 1"[!!strchr(p, ' ')*2]);
}
@@ -3748,7 +3748,7 @@ ST_FUNC void preprocess_start(TCCState *S, int filetype)
}
S->tccpp_parse_flags = is_asm ? PARSE_FLAG_ASM_FILE : 0;
- S->tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
+ S->tccpp_tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
}
/* cleanup from error/setjmp */
@@ -3779,18 +3779,18 @@ ST_FUNC void tccpp_new(TCCState *S)
set_idnum(S, i, IS_ID);
/* init allocators */
- tal_new(S, &S->toksym_alloc, TOKSYM_TAL_LIMIT, TOKSYM_TAL_SIZE);
- tal_new(S, &S->tokstr_alloc, TOKSTR_TAL_LIMIT, TOKSTR_TAL_SIZE);
+ tal_new(S, &S->tccpp_toksym_alloc, TOKSYM_TAL_LIMIT, TOKSYM_TAL_SIZE);
+ tal_new(S, &S->tccpp_tokstr_alloc, TOKSTR_TAL_LIMIT, TOKSTR_TAL_SIZE);
memset(S->tccpp_hash_ident, 0, TOK_HASH_SIZE * sizeof(TokenSym *));
memset(S->cached_includes_hash, 0, sizeof S->cached_includes_hash);
cstr_new(S, &S->tccpp_cstr_buf);
cstr_realloc(S, &S->tccpp_cstr_buf, STRING_MAX_SIZE);
- tok_str_new(&S->tokstr_buf);
- tok_str_realloc(S, &S->tokstr_buf, TOKSTR_MAX_SIZE);
+ tok_str_new(&S->tccpp_tokstr_buf);
+ tok_str_realloc(S, &S->tccpp_tokstr_buf, TOKSTR_MAX_SIZE);
- S->tok_ident = TOK_IDENT;
+ S->tccpp_tok_ident = TOK_IDENT;
p = tcc_keywords;
while (*p) {
r = p;
@@ -3819,31 +3819,31 @@ ST_FUNC void tccpp_delete(TCCState *S)
dynarray_reset(S, &S->cached_includes, &S->nb_cached_includes);
/* free tokens */
- n = S->tok_ident - TOK_IDENT;
+ n = S->tccpp_tok_ident - TOK_IDENT;
if (n > total_idents)
total_idents = n;
for(i = 0; i < n; i++)
- tal_free(S, S->toksym_alloc, S->tccpp_table_ident[i]);
+ tal_free(S, S->tccpp_toksym_alloc, S->tccpp_table_ident[i]);
tcc_free(S, S->tccpp_table_ident);
S->tccpp_table_ident = NULL;
/* free static buffers */
- cstr_free(S, &S->tokcstr);
+ cstr_free(S, &S->tccpp_tokcstr);
cstr_free(S, &S->tccpp_cstr_buf);
cstr_free(S, &S->tccpp_macro_equal_buf);
- tok_str_free_str(S, S->tokstr_buf.str);
+ tok_str_free_str(S, S->tccpp_tokstr_buf.str);
/* free allocators */
- tal_delete(S, S->toksym_alloc);
- S->toksym_alloc = NULL;
- tal_delete(S, S->tokstr_alloc);
- S->tokstr_alloc = NULL;
+ tal_delete(S, S->tccpp_toksym_alloc);
+ S->tccpp_toksym_alloc = NULL;
+ tal_delete(S, S->tccpp_tokstr_alloc);
+ S->tccpp_tokstr_alloc = NULL;
}
/* ------------------------------------------------------------------------- */
/* tcc -E [-P[1]] [-dD} support */
-static void tok_print(TCCState *S, const char *msg, const int *str)
+static void tok_print(TCCState* S, const char *msg, const int *str)
{
FILE *fp;
int t, s = 0;
@@ -3939,7 +3939,7 @@ static void pp_debug_defines(TCCState *S)
static void pp_debug_builtins(TCCState *S)
{
int v;
- for (v = TOK_IDENT; v < S->tok_ident; ++v)
+ for (v = TOK_IDENT; v < S->tccpp_tok_ident; ++v)
define_print(S, v);
}
@@ -3984,7 +3984,7 @@ ST_FUNC int tcc_preprocess(TCCState *S)
if (S->do_bench) {
/* for PP benchmarks */
- do next(S); while (S->tok != TOK_EOF);
+ do next(S); while (S->tccpp_tok != TOK_EOF);
return 0;
}
@@ -4000,7 +4000,7 @@ ST_FUNC int tcc_preprocess(TCCState *S)
for (;;) {
iptr = S->include_stack_ptr;
next(S);
- if (S->tok == TOK_EOF)
+ if (S->tccpp_tok == TOK_EOF)
break;
level = S->include_stack_ptr - iptr;
@@ -4015,24 +4015,24 @@ ST_FUNC int tcc_preprocess(TCCState *S)
continue;
}
- if (is_space(S->tok)) {
+ if (is_space(S->tccpp_tok)) {
if (spcs < sizeof white - 1)
- white[spcs++] = S->tok;
+ white[spcs++] = S->tccpp_tok;
continue;
- } else if (S->tok == TOK_LINEFEED) {
+ } else if (S->tccpp_tok == TOK_LINEFEED) {
spcs = 0;
if (token_seen == TOK_LINEFEED)
continue;
++S->tccpp_file->line_ref;
} else if (token_seen == TOK_LINEFEED) {
pp_line(S, S->tccpp_file, 0);
- } else if (spcs == 0 && pp_need_space(token_seen, S->tok)) {
+ } else if (spcs == 0 && pp_need_space(token_seen, S->tccpp_tok)) {
white[spcs++] = ' ';
}
white[spcs] = 0, fputs(white, S->ppfp), spcs = 0;
- fputs(p = get_tok_str(S, S->tok, &S->tokc), S->ppfp);
- token_seen = pp_check_he0xE(S->tok, p);
+ fputs(p = get_tok_str(S, S->tccpp_tok, &S->tccpp_tokc), S->ppfp);
+ token_seen = pp_check_he0xE(S->tccpp_tok, p);
}
return 0;
}
diff --git a/x86_64-gen.c b/x86_64-gen.c
index d14954e..07704fd 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -149,19 +149,19 @@ ST_DATA const int reg_classes[NB_REGS] = {
};
/* XXX: make it faster ? */
-ST_FUNC void g(TCCState *S, int c)
+ST_FUNC void g(TCCState* S, int c)
{
int ind1;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return;
- ind1 = S->ind + 1;
+ ind1 = S->tccgen_ind + 1;
if (ind1 > cur_text_section->data_allocated)
section_realloc(S, cur_text_section, ind1);
- cur_text_section->data[S->ind] = c;
- S->ind = ind1;
+ cur_text_section->data[S->tccgen_ind] = c;
+ S->tccgen_ind = ind1;
}
-ST_FUNC void o(TCCState *S, unsigned int c)
+ST_FUNC void o(TCCState* S, unsigned int c)
{
while (c) {
g(S, c);
@@ -169,13 +169,13 @@ ST_FUNC void o(TCCState *S, unsigned int c)
}
}
-ST_FUNC void gen_le16(TCCState *S, int v)
+ST_FUNC void gen_le16(TCCState* S, int v)
{
g(S, v);
g(S, v >> 8);
}
-ST_FUNC void gen_le32(TCCState *S, int c)
+ST_FUNC void gen_le32(TCCState* S, int c)
{
g(S, c);
g(S, c >> 8);
@@ -183,7 +183,7 @@ ST_FUNC void gen_le32(TCCState *S, int c)
g(S, c >> 24);
}
-ST_FUNC void gen_le64(TCCState *S, int64_t c)
+ST_FUNC void gen_le64(TCCState* S, int64_t c)
{
g(S, c);
g(S, c >> 8);
@@ -195,7 +195,7 @@ ST_FUNC void gen_le64(TCCState *S, int64_t c)
g(S, c >> 56);
}
-static void orex(TCCState *S, int ll, int r, int r2, int b)
+static void orex(TCCState* S, int ll, int r, int r2, int b)
{
if ((r & VT_VALMASK) >= VT_CONST)
r = 0;
@@ -207,7 +207,7 @@ static void orex(TCCState *S, int ll, int r, int r2, int b)
}
/* output a symbol and patch all calls to it */
-ST_FUNC void gsym_addr(TCCState *S, int t, int a)
+ST_FUNC void gsym_addr(TCCState* S, int t, int a)
{
while (t) {
unsigned char *ptr = cur_text_section->data + t;
@@ -228,10 +228,10 @@ static int is64_type(int t)
static int oad(TCCState *S, int c, int s)
{
int t;
- if (S->nocode_wanted)
+ if (S->tccgen_nocode_wanted)
return s;
o(S, c);
- t = S->ind;
+ t = S->tccgen_ind;
gen_le32(S, s);
return t;
}
@@ -242,7 +242,7 @@ static int oad(TCCState *S, int c, int s)
ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c)
{
if (r & VT_SYM)
- greloca(S, cur_text_section, sym, S->ind, R_X86_64_32S, c), c=0;
+ greloca(S, cur_text_section, sym, S->tccgen_ind, R_X86_64_32S, c), c=0;
gen_le32(S, c);
}
@@ -250,7 +250,7 @@ ST_FUNC void gen_addr32(TCCState *S, int r, Sym *sym, int c)
ST_FUNC void gen_addr64(TCCState *S, int r, Sym *sym, int64_t c)
{
if (r & VT_SYM)
- greloca(S, cur_text_section, sym, S->ind, R_X86_64_64, c), c=0;
+ greloca(S, cur_text_section, sym, S->tccgen_ind, R_X86_64_64, c), c=0;
gen_le64(S, c);
}
@@ -258,7 +258,7 @@ ST_FUNC void gen_addr64(TCCState *S, int r, Sym *sym, int64_t c)
ST_FUNC void gen_addrpc32(TCCState *S, int r, Sym *sym, int c)
{
if (r & VT_SYM)
- greloca(S, cur_text_section, sym, S->ind, R_X86_64_PC32, c-4), c=4;
+ greloca(S, cur_text_section, sym, S->tccgen_ind, R_X86_64_PC32, c-4), c=4;
gen_le32(S, c-4);
}
@@ -268,12 +268,12 @@ static void gen_gotpcrel(TCCState *S, int r, Sym *sym, int c)
#ifdef TCC_TARGET_PE
tcc_error(S, "internal error: no GOT on PE: %s %x %x | %02x %02x %02x\n",
get_tok_str(S, sym->v, NULL), c, r,
- cur_text_section->data[S->ind-3],
- cur_text_section->data[S->ind-2],
- cur_text_section->data[S->ind-1]
+ cur_text_section->data[S->tccgen_ind-3],
+ cur_text_section->data[S->tccgen_ind-2],
+ cur_text_section->data[S->tccgen_ind-1]
);
#endif
- greloca(S, cur_text_section, sym, S->ind, R_X86_64_GOTPCREL, -4);
+ greloca(S, cur_text_section, sym, S->tccgen_ind, R_X86_64_GOTPCREL, -4);
gen_le32(S, 0);
if (c) {
/* we use add c, %xxx for displacement */
@@ -482,7 +482,7 @@ void load(TCCState *S, int r, SValue *sv)
} else if (v == VT_CMP) {
if (fc & 0x100)
{
- v = S->vtop->cmp_r;
+ v = S->tccgen_vtop->cmp_r;
fc &= ~0x100;
/* This was a float compare. If the parity bit is
set the result was unordered, meaning false for everything
@@ -624,19 +624,19 @@ void store(TCCState *S, int r, SValue *v)
static void gcall_or_jmp(TCCState *S, int is_jmp)
{
int r;
- if ((S->vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
- ((S->vtop->r & VT_SYM) && (S->vtop->c.i-4) == (int)(S->vtop->c.i-4))) {
+ if ((S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
+ ((S->tccgen_vtop->r & VT_SYM) && (S->tccgen_vtop->c.i-4) == (int)(S->tccgen_vtop->c.i-4))) {
/* constant symbolic case -> simple relocation */
#ifdef TCC_TARGET_PE
- greloca(S, cur_text_section, S->vtop->sym, S->ind + 1, R_X86_64_PC32, (int)(S->vtop->c.i-4));
+ greloca(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind + 1, R_X86_64_PC32, (int)(S->tccgen_vtop->c.i-4));
#else
- greloca(S, cur_text_section, S->vtop->sym, S->ind + 1, R_X86_64_PLT32, (int)(S->vtop->c.i-4));
+ greloca(S, cur_text_section, S->tccgen_vtop->sym, S->tccgen_ind + 1, R_X86_64_PLT32, (int)(S->tccgen_vtop->c.i-4));
#endif
oad(S, 0xe8 + is_jmp, 0); /* call/jmp im */
} else {
/* otherwise, indirect call */
r = TREG_R11;
- load(S, r, S->vtop);
+ load(S, r, S->tccgen_vtop);
o(S, 0x41); /* REX */
o(S, 0xff); /* call/jmp *r */
o(S, 0xd0 + REG_VALUE(r) + (is_jmp << 4));
@@ -650,9 +650,9 @@ static void gen_bounds_call(TCCState *S, int v)
Sym *sym = external_helper_sym(S, v);
oad(S, 0xe8, 0);
#ifdef TCC_TARGET_PE
- greloca(S, cur_text_section, sym, S->ind-4, R_X86_64_PC32, -4);
+ greloca(S, cur_text_section, sym, S->tccgen_ind-4, R_X86_64_PC32, -4);
#else
- greloca(S, cur_text_section, sym, S->ind-4, R_X86_64_PLT32, -4);
+ greloca(S, cur_text_section, sym, S->tccgen_ind-4, R_X86_64_PLT32, -4);
#endif
}
@@ -666,7 +666,7 @@ static void gen_bounds_prolog(TCCState *S)
{
/* leave some room for bound checking code */
S->func_bound_offset = lbounds_section->data_offset;
- S->func_bound_ind = S->ind;
+ S->func_bound_ind = S->tccgen_ind;
S->func_bound_add_epilog = 0;
o(S, 0x0d8d48 + ((TREG_FASTCALL_1 == TREG_RDI) * 0x300000)); /*lbound section pointer */
gen_le32(S, 0);
@@ -687,22 +687,22 @@ static void gen_bounds_epilog(TCCState *S)
bounds_ptr = section_ptr_add(S, lbounds_section, sizeof(addr_t));
*bounds_ptr = 0;
- sym_data = get_sym_ref(S, &S->char_pointer_type, lbounds_section,
+ sym_data = get_sym_ref(S, &S->tccgen_char_pointer_type, lbounds_section,
S->func_bound_offset, lbounds_section->data_offset);
/* generate bound local allocation */
if (offset_modified) {
- saved_ind = S->ind;
- S->ind = S->func_bound_ind;
- greloca(S, cur_text_section, sym_data, S->ind + 3, R_X86_64_PC32, -4);
- S->ind = S->ind + 7;
+ saved_ind = S->tccgen_ind;
+ S->tccgen_ind = S->func_bound_ind;
+ greloca(S, cur_text_section, sym_data, S->tccgen_ind + 3, R_X86_64_PC32, -4);
+ S->tccgen_ind = S->tccgen_ind + 7;
gen_bounds_call(S, TOK___bound_local_new);
- S->ind = saved_ind;
+ S->tccgen_ind = saved_ind;
}
/* generate bound check local freeing */
o(S, 0x5250); /* save returned value, if any */
- greloca(S, cur_text_section, sym_data, S->ind + 3, R_X86_64_PC32, -4);
+ greloca(S, cur_text_section, sym_data, S->tccgen_ind + 3, R_X86_64_PC32, -4);
o(S, 0x0d8d48 + ((TREG_FASTCALL_1 == TREG_RDI) * 0x300000)); /* lea xxx(%rip), %rcx/rdi */
gen_le32(S, 0);
gen_bounds_call(S, TOK___bound_local_delete);
@@ -731,7 +731,7 @@ static int arg_prepare_reg(int idx) {
all the parameters in call order. This functions pops all the
parameters and the function address. */
-static void gen_offs_sp(TCCState *S, int b, int r, int d)
+static void gen_offs_sp(TCCState* S, int b, int r, int d)
{
orex(S, 1,0,r & 0x100 ? 0 : r, b);
if (d == (char)d) {
@@ -783,7 +783,7 @@ static int gfunc_arg_size(CType *type) {
return type_size(type, &align);
}
-void gfunc_call(TCCState *S, int nb_args)
+void gfunc_call(TCCState* S, int nb_args)
{
int size, r, args_size, i, d, bt, struct_size;
int arg;
@@ -804,7 +804,7 @@ void gfunc_call(TCCState *S, int nb_args)
SValue *sv;
--arg;
- sv = &S->vtop[-i];
+ sv = &S->tccgen_vtop[-i];
bt = (sv->type.t & VT_BTYPE);
size = gfunc_arg_size(&sv->type);
@@ -823,7 +823,7 @@ void gfunc_call(TCCState *S, int nb_args)
vset(S, &sv->type, r | VT_LVAL, 0);
vpushv(S, sv);
vstore(S);
- --S->vtop;
+ --S->tccgen_vtop;
} else if (bt == VT_LDOUBLE) {
gv(S, RC_ST0);
gen_offs_sp(S, 0xdb, 0x107, struct_size);
@@ -839,9 +839,9 @@ void gfunc_call(TCCState *S, int nb_args)
for(i = 0; i < nb_args; i++) {
--arg;
- bt = (S->vtop->type.t & VT_BTYPE);
+ bt = (S->tccgen_vtop->type.t & VT_BTYPE);
- size = gfunc_arg_size(&S->vtop->type);
+ size = gfunc_arg_size(&S->tccgen_vtop->type);
if (!using_regs(size)) {
/* align to stack align size */
size = (size + 15) & ~15;
@@ -855,7 +855,7 @@ void gfunc_call(TCCState *S, int nb_args)
}
struct_size += size;
} else {
- if (is_sse_float(S->vtop->type.t)) {
+ if (is_sse_float(S->tccgen_vtop->type.t)) {
if (S->nosse)
tcc_error(S, "SSE disabled");
if (arg >= REGN) {
@@ -873,8 +873,8 @@ void gfunc_call(TCCState *S, int nb_args)
}
} else {
if (bt == VT_STRUCT) {
- S->vtop->type.ref = NULL;
- S->vtop->type.t = size > 4 ? VT_LLONG : size > 2 ? VT_INT
+ S->tccgen_vtop->type.ref = NULL;
+ S->tccgen_vtop->type.t = size > 4 ? VT_LLONG : size > 2 ? VT_INT
: size > 1 ? VT_SHORT : VT_BYTE;
}
@@ -888,7 +888,7 @@ void gfunc_call(TCCState *S, int nb_args)
}
}
}
- S->vtop--;
+ S->tccgen_vtop--;
}
save_regs(S, 0);
/* Copy R10 and R11 into RCX and RDX, respectively */
@@ -901,7 +901,7 @@ void gfunc_call(TCCState *S, int nb_args)
gcall_or_jmp(S, 0);
- if ((S->vtop->r & VT_SYM) && S->vtop->sym->v == TOK_alloca) {
+ if ((S->tccgen_vtop->r & VT_SYM) && S->tccgen_vtop->sym->v == TOK_alloca) {
/* need to add the "func_scratch" area after alloca */
o(S, 0x48); S->x86_64_gen_func_alloca = oad(S, 0x05, S->x86_64_gen_func_alloca); /* add $NN, %rax */
#ifdef CONFIG_TCC_BCHECK
@@ -909,14 +909,14 @@ void gfunc_call(TCCState *S, int nb_args)
gen_bounds_call(S, TOK___bound_alloca_nr); /* new region */
#endif
}
- S->vtop--;
+ S->tccgen_vtop--;
}
#define FUNC_PROLOG_SIZE 11
/* generate function prolog of type 't' */
-void gfunc_prolog(TCCState *S, Sym *func_sym)
+void gfunc_prolog(TCCState* S, Sym *func_sym)
{
CType *func_type = &func_sym->type;
int addr, reg_param_index, bt, size;
@@ -926,11 +926,11 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
S->x86_64_gen_func_ret_sub = 0;
S->x86_64_gen_func_scratch = 32;
S->x86_64_gen_func_alloca = 0;
- S->loc = 0;
+ S->tccgen_loc = 0;
addr = PTR_SIZE * 2;
- S->ind += FUNC_PROLOG_SIZE;
- S->x86_64_gen_func_sub_sp_offset = S->ind;
+ S->tccgen_ind += FUNC_PROLOG_SIZE;
+ S->x86_64_gen_func_sub_sp_offset = S->tccgen_ind;
reg_param_index = 0;
sym = func_type->ref;
@@ -989,13 +989,13 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
}
/* generate function epilog */
-void gfunc_epilog(TCCState *S)
+void gfunc_epilog(TCCState* S)
{
int v, saved_ind;
/* align local size to word & save local variables */
S->x86_64_gen_func_scratch = (S->x86_64_gen_func_scratch + 15) & -16;
- S->loc = (S->loc & -16) - S->x86_64_gen_func_scratch;
+ S->tccgen_loc = (S->tccgen_loc & -16) - S->x86_64_gen_func_scratch;
#ifdef CONFIG_TCC_BCHECK
if (S->do_bounds_check)
@@ -1011,15 +1011,15 @@ void gfunc_epilog(TCCState *S)
g(S, S->x86_64_gen_func_ret_sub >> 8);
}
- saved_ind = S->ind;
- S->ind = S->x86_64_gen_func_sub_sp_offset - FUNC_PROLOG_SIZE;
- v = -S->loc;
+ saved_ind = S->tccgen_ind;
+ S->tccgen_ind = S->x86_64_gen_func_sub_sp_offset - FUNC_PROLOG_SIZE;
+ v = -S->tccgen_loc;
if (v >= 4096) {
Sym *sym = external_helper_sym(S, TOK___chkstk);
oad(S, 0xb8, v); /* mov stacksize, %eax */
oad(S, 0xe8, 0); /* call __chkstk, (does the stackframe too) */
- greloca(S, cur_text_section, sym, S->ind-4, R_X86_64_PC32, -4);
+ greloca(S, cur_text_section, sym, S->tccgen_ind-4, R_X86_64_PC32, -4);
o(S, 0x90); /* fill for FUNC_PROLOG_SIZE = 11 bytes */
} else {
o(S, 0xe5894855); /* push %rbp, mov %rsp, %rbp */
@@ -1031,13 +1031,13 @@ void gfunc_epilog(TCCState *S)
gsym_addr(S, S->x86_64_gen_func_alloca, -S->x86_64_gen_func_scratch);
cur_text_section->data_offset = saved_ind;
- pe_add_unwind_data(S, S->ind, saved_ind, v);
- S->ind = cur_text_section->data_offset;
+ pe_add_unwind_data(S, S->tccgen_ind, saved_ind, v);
+ S->tccgen_ind = cur_text_section->data_offset;
}
#else
-static void gadd_sp(TCCState *S, int val)
+static void gadd_sp(TCCState* S, int val)
{
if (val == (char)val) {
o(S, 0xc48348);
@@ -1216,7 +1216,7 @@ static int arg_prepare_reg(int idx) {
/* Generate function call. The function address is pushed first, then
all the parameters in call order. This functions pops all the
parameters and the function address. */
-void gfunc_call(TCCState *S, int nb_args)
+void gfunc_call(TCCState* S, int nb_args)
{
X86_64_Mode mode;
CType type;
@@ -1237,7 +1237,7 @@ void gfunc_call(TCCState *S, int nb_args)
to be done in a left-to-right pass over arguments. */
stack_adjust = 0;
for(i = nb_args - 1; i >= 0; i--) {
- mode = classify_x86_64_arg(&S->vtop[-i].type, NULL, &size, &align, &reg_count);
+ mode = classify_x86_64_arg(&S->tccgen_vtop[-i].type, NULL, &size, &align, &reg_count);
if (size == 0) continue;
if (mode == x86_64_mode_sse && nb_sse_args + reg_count <= 8) {
nb_sse_args += reg_count;
@@ -1261,7 +1261,7 @@ void gfunc_call(TCCState *S, int nb_args)
tcc_error(S, "SSE disabled but floating point arguments passed");
/* fetch cpu flag before generating any code */
- if ((S->vtop->r & VT_VALMASK) == VT_CMP)
+ if ((S->tccgen_vtop->r & VT_VALMASK) == VT_CMP)
gv(S, RC_INT);
/* for struct arguments, we need to call memcpy and the function
@@ -1272,7 +1272,7 @@ void gfunc_call(TCCState *S, int nb_args)
args_size = 0;
stack_adjust &= 15;
for (i = k = 0; i < nb_args;) {
- mode = classify_x86_64_arg(&S->vtop[-i].type, NULL, &size, &align, &reg_count);
+ mode = classify_x86_64_arg(&S->tccgen_vtop[-i].type, NULL, &size, &align, &reg_count);
if (size) {
if (!onstack[i + k]) {
++i;
@@ -1293,7 +1293,7 @@ void gfunc_call(TCCState *S, int nb_args)
vrotb(S, i+1);
- switch (S->vtop->type.t & VT_BTYPE) {
+ switch (S->tccgen_vtop->type.t & VT_BTYPE) {
case VT_STRUCT:
/* allocate the necessary size on stack */
o(S, 0x48);
@@ -1302,7 +1302,7 @@ void gfunc_call(TCCState *S, int nb_args)
r = get_reg(S, RC_INT);
orex(S, 1, r, 0, 0x89); /* mov %rsp, r */
o(S, 0xe0 + REG_VALUE(r));
- vset(S, &S->vtop->type, r | VT_LVAL, 0);
+ vset(S, &S->tccgen_vtop->type, r | VT_LVAL, 0);
vswap(S);
vstore(S);
break;
@@ -1353,10 +1353,10 @@ void gfunc_call(TCCState *S, int nb_args)
assert(gen_reg <= REGN);
assert(sse_reg <= 8);
for(i = 0; i < nb_args; i++) {
- mode = classify_x86_64_arg(&S->vtop->type, &type, &size, &align, &reg_count);
+ mode = classify_x86_64_arg(&S->tccgen_vtop->type, &type, &size, &align, &reg_count);
if (size == 0) continue;
/* Alter stack entry type so that gv() knows how to treat it */
- S->vtop->type = type;
+ S->tccgen_vtop->type = type;
if (mode == x86_64_mode_sse) {
if (reg_count == 2) {
sse_reg -= 2;
@@ -1386,11 +1386,11 @@ void gfunc_call(TCCState *S, int nb_args)
o(S, 0xc0 + REG_VALUE(r) * 8 + REG_VALUE(d));
if (reg_count == 2) {
d = arg_prepare_reg(gen_reg+1);
- orex(S, 1,d,S->vtop->r2,0x89); /* mov */
- o(S, 0xc0 + REG_VALUE(S->vtop->r2) * 8 + REG_VALUE(d));
+ orex(S, 1,d,S->tccgen_vtop->r2,0x89); /* mov */
+ o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r2) * 8 + REG_VALUE(d));
}
}
- S->vtop--;
+ S->tccgen_vtop--;
}
assert(gen_reg == 0);
assert(sse_reg == 0);
@@ -1409,23 +1409,23 @@ void gfunc_call(TCCState *S, int nb_args)
}
}
- if (S->vtop->type.ref->f.func_type != FUNC_NEW) /* implies FUNC_OLD or FUNC_ELLIPSIS */
+ if (S->tccgen_vtop->type.ref->f.func_type != FUNC_NEW) /* implies FUNC_OLD or FUNC_ELLIPSIS */
oad(S, 0xb8, nb_sse_args < 8 ? nb_sse_args : 8); /* mov nb_sse_args, %eax */
gcall_or_jmp(S, 0);
if (args_size)
gadd_sp(S, args_size);
- S->vtop--;
+ S->tccgen_vtop--;
}
#define FUNC_PROLOG_SIZE 11
-static void push_arg_reg(TCCState *S, int i) {
- S->loc -= 8;
- gen_modrm64(S, 0x89, arg_regs[i], VT_LOCAL, NULL, S->loc);
+static void push_arg_reg(TCCState* S, int i) {
+ S->tccgen_loc -= 8;
+ gen_modrm64(S, 0x89, arg_regs[i], VT_LOCAL, NULL, S->tccgen_loc);
}
/* generate function prolog of type 't' */
-void gfunc_prolog(TCCState *S, Sym *func_sym)
+void gfunc_prolog(TCCState* S, Sym *func_sym)
{
CType *func_type = &func_sym->type;
X86_64_Mode mode, ret_mode;
@@ -1436,9 +1436,9 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
sym = func_type->ref;
addr = PTR_SIZE * 2;
- S->loc = 0;
- S->ind += FUNC_PROLOG_SIZE;
- S->x86_64_gen_func_sub_sp_offset = S->ind;
+ S->tccgen_loc = 0;
+ S->tccgen_ind += FUNC_PROLOG_SIZE;
+ S->x86_64_gen_func_sub_sp_offset = S->tccgen_ind;
S->x86_64_gen_func_ret_sub = 0;
ret_mode = classify_x86_64_arg(&S->tccgen_func_vt, NULL, &size, &align, &reg_count);
@@ -1473,7 +1473,7 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
}
}
- S->loc -= 24;
+ S->tccgen_loc -= 24;
/* movl $0x????????, -0x18(%rbp) */
o(S, 0xe845c7);
gen_le32(S, seen_reg_num * 8);
@@ -1493,14 +1493,14 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
/* save all register passing arguments */
for (i = 0; i < 8; i++) {
- S->loc -= 16;
+ S->tccgen_loc -= 16;
if (!S->nosse) {
o(S, 0xd60f66); /* movq */
- gen_modrm(S, 7 - i, VT_LOCAL, NULL, S->loc);
+ gen_modrm(S, 7 - i, VT_LOCAL, NULL, S->tccgen_loc);
}
/* movq $0, loc+8(%rbp) */
o(S, 0x85c748);
- gen_le32(S, S->loc + 8);
+ gen_le32(S, S->tccgen_loc + 8);
gen_le32(S, 0);
}
for (i = 0; i < REGN; i++) {
@@ -1516,7 +1516,7 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
implicit pointer parameter */
if (ret_mode == x86_64_mode_memory) {
push_arg_reg(S, reg_param_index);
- S->tccgen_func_vc = S->loc;
+ S->tccgen_func_vc = S->tccgen_loc;
reg_param_index++;
}
/* define parameters */
@@ -1529,8 +1529,8 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
tcc_error(S, "SSE disabled but floating point arguments used");
if (sse_param_index + reg_count <= 8) {
/* save arguments passed by register */
- S->loc -= reg_count * 8;
- param_addr = S->loc;
+ S->tccgen_loc -= reg_count * 8;
+ param_addr = S->tccgen_loc;
for (i = 0; i < reg_count; ++i) {
o(S, 0xd60f66); /* movq */
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)
case x86_64_mode_integer: {
if (reg_param_index + reg_count <= REGN) {
/* save arguments passed by register */
- S->loc -= reg_count * 8;
- param_addr = S->loc;
+ S->tccgen_loc -= reg_count * 8;
+ param_addr = S->tccgen_loc;
for (i = 0; i < reg_count; ++i) {
gen_modrm64(S, 0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, param_addr + i*8);
++reg_param_index;
@@ -1579,7 +1579,7 @@ void gfunc_prolog(TCCState *S, Sym *func_sym)
}
/* generate function epilog */
-void gfunc_epilog(TCCState *S)
+void gfunc_epilog(TCCState* S)
{
int v, saved_ind;
@@ -1596,39 +1596,39 @@ void gfunc_epilog(TCCState *S)
g(S, S->x86_64_gen_func_ret_sub >> 8);
}
/* align local size to word & save local variables */
- v = (-S->loc + 15) & -16;
- saved_ind = S->ind;
- S->ind = S->x86_64_gen_func_sub_sp_offset - FUNC_PROLOG_SIZE;
+ v = (-S->tccgen_loc + 15) & -16;
+ saved_ind = S->tccgen_ind;
+ S->tccgen_ind = S->x86_64_gen_func_sub_sp_offset - FUNC_PROLOG_SIZE;
o(S, 0xe5894855); /* push %rbp, mov %rsp, %rbp */
o(S, 0xec8148); /* sub rsp, stacksize */
gen_le32(S, v);
- S->ind = saved_ind;
+ S->tccgen_ind = saved_ind;
}
#endif /* not PE */
-ST_FUNC void gen_fill_nops(TCCState *S, int bytes)
+ST_FUNC void gen_fill_nops(TCCState* S, int bytes)
{
while (bytes--)
g(S, 0x90);
}
/* generate a jump to a label */
-int gjmp(TCCState *S, int t)
+int gjmp(TCCState* S, int t)
{
return gjmp2(S, 0xe9, t);
}
/* generate a jump to a fixed address */
-void gjmp_addr(TCCState *S, int a)
+void gjmp_addr(TCCState* S, int a)
{
int r;
- r = a - S->ind - 2;
+ r = a - S->tccgen_ind - 2;
if (r == (char)r) {
g(S, 0xeb);
g(S, r);
} else {
- oad(S, 0xe9, a - S->ind - 5);
+ oad(S, 0xe9, a - S->tccgen_ind - 5);
}
}
@@ -1646,7 +1646,7 @@ ST_FUNC int gjmp_append(TCCState *S, int n, int t)
return t;
}
-ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
+ST_FUNC int gjmp_cond(TCCState* S, int op, int t)
{
if (op & 0x100)
{
@@ -1657,7 +1657,7 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
Take care about inverting the test. We need to jump
to our target if the result was unordered and test wasn't NE,
otherwise if unordered we don't want to jump. */
- int v = S->vtop->cmp_r;
+ int v = S->tccgen_vtop->cmp_r;
op &= ~0x100;
if (op ^ v ^ (v != TOK_NE))
o(S, 0x067a); /* jp +6 */
@@ -1673,26 +1673,26 @@ ST_FUNC int gjmp_cond(TCCState *S, int op, int t)
}
/* generate an integer binary operation */
-void gen_opi(TCCState *S, int op)
+void gen_opi(TCCState* S, int op)
{
int r, fr, opc, c;
int ll, uu, cc;
- ll = is64_type(S->vtop[-1].type.t);
- uu = (S->vtop[-1].type.t & VT_UNSIGNED) != 0;
- cc = (S->vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+ ll = is64_type(S->tccgen_vtop[-1].type.t);
+ uu = (S->tccgen_vtop[-1].type.t & VT_UNSIGNED) != 0;
+ cc = (S->tccgen_vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
switch(op) {
case '+':
case TOK_ADDC1: /* add with carry generation */
opc = 0;
gen_op8:
- if (cc && (!ll || (int)S->vtop->c.i == S->vtop->c.i)) {
+ if (cc && (!ll || (int)S->tccgen_vtop->c.i == S->tccgen_vtop->c.i)) {
/* constant case */
vswap(S);
r = gv(S, RC_INT);
vswap(S);
- c = S->vtop->c.i;
+ c = S->tccgen_vtop->c.i;
if (c == (char)c) {
/* XXX: generate inc and dec for smaller code ? */
orex(S, ll, r, 0, 0x83);
@@ -1704,12 +1704,12 @@ void gen_opi(TCCState *S, int op)
}
} else {
gv2(S, RC_INT, RC_INT);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
orex(S, ll, r, fr, (opc << 3) | 0x01);
o(S, 0xc0 + REG_VALUE(r) + REG_VALUE(fr) * 8);
}
- S->vtop--;
+ S->tccgen_vtop--;
if (op >= TOK_ULT && op <= TOK_GT)
vset_VT_CMP(S, op);
break;
@@ -1734,11 +1734,11 @@ void gen_opi(TCCState *S, int op)
goto gen_op8;
case '*':
gv2(S, RC_INT, RC_INT);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
orex(S, ll, fr, r, 0xaf0f); /* imul fr, r */
o(S, 0xc0 + REG_VALUE(fr) + REG_VALUE(r) * 8);
- S->vtop--;
+ S->tccgen_vtop--;
break;
case TOK_SHL:
opc = 4;
@@ -1757,15 +1757,15 @@ void gen_opi(TCCState *S, int op)
vswap(S);
orex(S, ll, r, 0, 0xc1); /* shl/shr/sar $xxx, r */
o(S, opc | REG_VALUE(r));
- g(S, S->vtop->c.i & (ll ? 63 : 31));
+ g(S, S->tccgen_vtop->c.i & (ll ? 63 : 31));
} else {
/* we generate the shift in ecx */
gv2(S, RC_INT, RC_RCX);
- r = S->vtop[-1].r;
+ r = S->tccgen_vtop[-1].r;
orex(S, ll, r, 0, 0xd3); /* shl/shr/sar %cl, r */
o(S, opc | REG_VALUE(r));
}
- S->vtop--;
+ S->tccgen_vtop--;
break;
case TOK_UDIV:
case TOK_UMOD:
@@ -1779,9 +1779,9 @@ void gen_opi(TCCState *S, int op)
/* first operand must be in eax */
/* XXX: need better constraint for second operand */
gv2(S, RC_RAX, RC_RCX);
- r = S->vtop[-1].r;
- fr = S->vtop[0].r;
- S->vtop--;
+ r = S->tccgen_vtop[-1].r;
+ fr = S->tccgen_vtop[0].r;
+ S->tccgen_vtop--;
save_reg(S, TREG_RDX);
orex(S, ll, 0, 0, uu ? 0xd231 : 0x99); /* xor %edx,%edx : cqto */
orex(S, ll, fr, 0, 0xf7); /* div fr, %eax */
@@ -1790,7 +1790,7 @@ void gen_opi(TCCState *S, int op)
r = TREG_RDX;
else
r = TREG_RAX;
- S->vtop->r = r;
+ S->tccgen_vtop->r = r;
break;
default:
opc = 7;
@@ -1798,25 +1798,25 @@ void gen_opi(TCCState *S, int op)
}
}
-void gen_opl(TCCState *S, int op)
+void gen_opl(TCCState* S, int op)
{
gen_opi(S, op);
}
-void vpush_const(TCCState *S, int t, int v)
+void vpush_const(TCCState* S, int t, int v)
{
CType ctype = { t | VT_CONSTANT, 0 };
vpushsym(S, &ctype, external_global_sym(S, v, &ctype));
- S->vtop->r |= VT_LVAL;
+ S->tccgen_vtop->r |= VT_LVAL;
}
/* generate a floating point operation 'v = t1 op t2' instruction. The
two operands are guaranteed to have the same floating point type */
/* XXX: need to use ST1 too */
-void gen_opf(TCCState *S, int op)
+void gen_opf(TCCState* S, int op)
{
int a, ft, fc, swapped, r;
- int bt = S->vtop->type.t & VT_BTYPE;
+ int bt = S->tccgen_vtop->type.t & VT_BTYPE;
int float_type = bt == VT_LDOUBLE ? RC_ST0 : RC_FLOAT;
if (op == TOK_NEG) { /* unary minus */
@@ -1830,24 +1830,24 @@ void gen_opf(TCCState *S, int op)
if (bt == VT_DOUBLE)
o(S, 0x66);
/* xorp[sd] %xmm1, %xmm0 */
- o(S, 0xc0570f | (REG_VALUE(S->vtop[0].r) + REG_VALUE(S->vtop[-1].r)*8) << 16);
- S->vtop--;
+ o(S, 0xc0570f | (REG_VALUE(S->tccgen_vtop[0].r) + REG_VALUE(S->tccgen_vtop[-1].r)*8) << 16);
+ S->tccgen_vtop--;
}
return;
}
/* convert constants to memory references */
- if ((S->vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+ if ((S->tccgen_vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
vswap(S);
gv(S, float_type);
vswap(S);
}
- if ((S->vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST)
+ if ((S->tccgen_vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST)
gv(S, float_type);
/* must put at least one value in the floating point register */
- if ((S->vtop[-1].r & VT_LVAL) &&
- (S->vtop[0].r & VT_LVAL)) {
+ if ((S->tccgen_vtop[-1].r & VT_LVAL) &&
+ (S->tccgen_vtop[0].r & VT_LVAL)) {
vswap(S);
gv(S, float_type);
vswap(S);
@@ -1855,14 +1855,14 @@ void gen_opf(TCCState *S, int op)
swapped = 0;
/* swap the stack if needed so that t1 is the register and t2 is
the memory reference */
- if (S->vtop[-1].r & VT_LVAL) {
+ if (S->tccgen_vtop[-1].r & VT_LVAL) {
vswap(S);
swapped = 1;
}
- if ((S->vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
if (op >= TOK_ULT && op <= TOK_GT) {
/* load on stack second operand */
- load(S, TREG_ST0, S->vtop);
+ load(S, TREG_ST0, S->tccgen_vtop);
save_reg(S, TREG_RAX); /* eax is used by FP comparison code */
if (op == TOK_GE || op == TOK_GT)
swapped = !swapped;
@@ -1889,11 +1889,11 @@ void gen_opf(TCCState *S, int op)
o(S, 0x45c4f6); /* test $0x45, %ah */
op = TOK_EQ;
}
- S->vtop--;
+ S->tccgen_vtop--;
vset_VT_CMP(S, op);
} else {
/* no memory reference possible for long double operations */
- load(S, TREG_ST0, S->vtop);
+ load(S, TREG_ST0, S->tccgen_vtop);
swapped = !swapped;
switch(op) {
@@ -1915,17 +1915,17 @@ void gen_opf(TCCState *S, int op)
a++;
break;
}
- ft = S->vtop->type.t;
- fc = S->vtop->c.i;
+ ft = S->tccgen_vtop->type.t;
+ fc = S->tccgen_vtop->c.i;
o(S, 0xde); /* fxxxp %st, %st(1) */
o(S, 0xc1 + (a << 3));
- S->vtop--;
+ S->tccgen_vtop--;
}
} else {
if (op >= TOK_ULT && op <= TOK_GT) {
/* if saved lvalue, then we must reload it */
- r = S->vtop->r;
- fc = S->vtop->c.i;
+ r = S->tccgen_vtop->r;
+ fc = S->tccgen_vtop->c.i;
if ((r & VT_VALMASK) == VT_LLOCAL) {
SValue v1;
r = get_reg(S, RC_INT);
@@ -1934,7 +1934,7 @@ void gen_opf(TCCState *S, int op)
v1.c.i = fc;
load(S, r, &v1);
fc = 0;
- S->vtop->r = r = r | VT_LVAL;
+ S->tccgen_vtop->r = r = r | VT_LVAL;
}
if (op == TOK_EQ || op == TOK_NE) {
@@ -1953,26 +1953,26 @@ void gen_opf(TCCState *S, int op)
gv(S, RC_FLOAT);
vswap(S);
}
- assert(!(S->vtop[-1].r & VT_LVAL));
+ assert(!(S->tccgen_vtop[-1].r & VT_LVAL));
- if ((S->vtop->type.t & VT_BTYPE) == VT_DOUBLE)
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_DOUBLE)
o(S, 0x66);
if (op == TOK_EQ || op == TOK_NE)
o(S, 0x2e0f); /* ucomisd */
else
o(S, 0x2f0f); /* comisd */
- if (S->vtop->r & VT_LVAL) {
- gen_modrm(S, S->vtop[-1].r, r, S->vtop->sym, fc);
+ if (S->tccgen_vtop->r & VT_LVAL) {
+ gen_modrm(S, S->tccgen_vtop[-1].r, r, S->tccgen_vtop->sym, fc);
} else {
- o(S, 0xc0 + REG_VALUE(S->vtop[0].r) + REG_VALUE(S->vtop[-1].r)*8);
+ o(S, 0xc0 + REG_VALUE(S->tccgen_vtop[0].r) + REG_VALUE(S->tccgen_vtop[-1].r)*8);
}
- S->vtop--;
+ S->tccgen_vtop--;
vset_VT_CMP(S, op | 0x100);
- S->vtop->cmp_r = op;
+ S->tccgen_vtop->cmp_r = op;
} else {
- assert((S->vtop->type.t & VT_BTYPE) != VT_LDOUBLE);
+ assert((S->tccgen_vtop->type.t & VT_BTYPE) != VT_LDOUBLE);
switch(op) {
default:
case '+':
@@ -1988,13 +1988,13 @@ void gen_opf(TCCState *S, int op)
a = 6;
break;
}
- ft = S->vtop->type.t;
- fc = S->vtop->c.i;
+ ft = S->tccgen_vtop->type.t;
+ fc = S->tccgen_vtop->c.i;
assert((ft & VT_BTYPE) != VT_LDOUBLE);
- r = S->vtop->r;
+ r = S->tccgen_vtop->r;
/* if saved lvalue, then we must reload it */
- if ((S->vtop->r & VT_VALMASK) == VT_LLOCAL) {
+ if ((S->tccgen_vtop->r & VT_VALMASK) == VT_LLOCAL) {
SValue v1;
r = get_reg(S, RC_INT);
v1.type.t = VT_PTR;
@@ -2002,12 +2002,12 @@ void gen_opf(TCCState *S, int op)
v1.c.i = fc;
load(S, r, &v1);
fc = 0;
- S->vtop->r = r = r | VT_LVAL;
+ S->tccgen_vtop->r = r = r | VT_LVAL;
}
- assert(!(S->vtop[-1].r & VT_LVAL));
+ assert(!(S->tccgen_vtop[-1].r & VT_LVAL));
if (swapped) {
- assert(S->vtop->r & VT_LVAL);
+ assert(S->tccgen_vtop->r & VT_LVAL);
gv(S, RC_FLOAT);
vswap(S);
}
@@ -2020,66 +2020,66 @@ void gen_opf(TCCState *S, int op)
o(S, 0x0f);
o(S, 0x58 + a);
- if (S->vtop->r & VT_LVAL) {
- gen_modrm(S, S->vtop[-1].r, r, S->vtop->sym, fc);
+ if (S->tccgen_vtop->r & VT_LVAL) {
+ gen_modrm(S, S->tccgen_vtop[-1].r, r, S->tccgen_vtop->sym, fc);
} else {
- o(S, 0xc0 + REG_VALUE(S->vtop[0].r) + REG_VALUE(S->vtop[-1].r)*8);
+ o(S, 0xc0 + REG_VALUE(S->tccgen_vtop[0].r) + REG_VALUE(S->tccgen_vtop[-1].r)*8);
}
- S->vtop--;
+ S->tccgen_vtop--;
}
}
}
/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
and 'long long' cases. */
-void gen_cvt_itof(TCCState *S, int t)
+void gen_cvt_itof(TCCState* S, int t)
{
if ((t & VT_BTYPE) == VT_LDOUBLE) {
save_reg(S, TREG_ST0);
gv(S, RC_INT);
- if ((S->vtop->type.t & VT_BTYPE) == VT_LLONG) {
+ if ((S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) {
/* signed long long to float/double/long double (unsigned case
is handled generically) */
- o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */
+ o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */
o(S, 0x242cdf); /* fildll (%rsp) */
o(S, 0x08c48348); /* add $8, %rsp */
- } else if ((S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
+ } else if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
(VT_INT | VT_UNSIGNED)) {
/* unsigned int to float/double/long double */
o(S, 0x6a); /* push $0 */
g(S, 0x00);
- o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */
+ o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */
o(S, 0x242cdf); /* fildll (%rsp) */
o(S, 0x10c48348); /* add $16, %rsp */
} else {
/* int to float/double/long double */
- o(S, 0x50 + (S->vtop->r & VT_VALMASK)); /* push r */
+ o(S, 0x50 + (S->tccgen_vtop->r & VT_VALMASK)); /* push r */
o(S, 0x2404db); /* fildl (%rsp) */
o(S, 0x08c48348); /* add $8, %rsp */
}
- S->vtop->r = TREG_ST0;
+ S->tccgen_vtop->r = TREG_ST0;
} else {
int r = get_reg(S, RC_FLOAT);
gv(S, RC_INT);
o(S, 0xf2 + ((t & VT_BTYPE) == VT_FLOAT?1:0));
- if ((S->vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
+ if ((S->tccgen_vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
(VT_INT | VT_UNSIGNED) ||
- (S->vtop->type.t & VT_BTYPE) == VT_LLONG) {
+ (S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG) {
o(S, 0x48); /* REX */
}
o(S, 0x2a0f);
- o(S, 0xc0 + (S->vtop->r & VT_VALMASK) + REG_VALUE(r)*8); /* cvtsi2sd */
- S->vtop->r = r;
+ o(S, 0xc0 + (S->tccgen_vtop->r & VT_VALMASK) + REG_VALUE(r)*8); /* cvtsi2sd */
+ S->tccgen_vtop->r = r;
}
}
/* convert from one floating point type to another */
-void gen_cvt_ftof(TCCState *S, int t)
+void gen_cvt_ftof(TCCState* S, int t)
{
int ft, bt, tbt;
- ft = S->vtop->type.t;
+ ft = S->tccgen_vtop->type.t;
bt = ft & VT_BTYPE;
tbt = t & VT_BTYPE;
@@ -2087,33 +2087,33 @@ void gen_cvt_ftof(TCCState *S, int t)
gv(S, RC_FLOAT);
if (tbt == VT_DOUBLE) {
o(S, 0x140f); /* unpcklps */
- o(S, 0xc0 + REG_VALUE(S->vtop->r)*9);
+ o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r)*9);
o(S, 0x5a0f); /* cvtps2pd */
- o(S, 0xc0 + REG_VALUE(S->vtop->r)*9);
+ o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r)*9);
} else if (tbt == VT_LDOUBLE) {
save_reg(S, RC_ST0);
/* movss %xmm0,-0x10(%rsp) */
o(S, 0x110ff3);
- o(S, 0x44 + REG_VALUE(S->vtop->r)*8);
+ o(S, 0x44 + REG_VALUE(S->tccgen_vtop->r)*8);
o(S, 0xf024);
o(S, 0xf02444d9); /* flds -0x10(%rsp) */
- S->vtop->r = TREG_ST0;
+ S->tccgen_vtop->r = TREG_ST0;
}
} else if (bt == VT_DOUBLE) {
gv(S, RC_FLOAT);
if (tbt == VT_FLOAT) {
o(S, 0x140f66); /* unpcklpd */
- o(S, 0xc0 + REG_VALUE(S->vtop->r)*9);
+ o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r)*9);
o(S, 0x5a0f66); /* cvtpd2ps */
- o(S, 0xc0 + REG_VALUE(S->vtop->r)*9);
+ o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r)*9);
} else if (tbt == VT_LDOUBLE) {
save_reg(S, RC_ST0);
/* movsd %xmm0,-0x10(%rsp) */
o(S, 0x110ff2);
- o(S, 0x44 + REG_VALUE(S->vtop->r)*8);
+ o(S, 0x44 + REG_VALUE(S->tccgen_vtop->r)*8);
o(S, 0xf024);
o(S, 0xf02444dd); /* fldl -0x10(%rsp) */
- S->vtop->r = TREG_ST0;
+ S->tccgen_vtop->r = TREG_ST0;
}
} else {
int r;
@@ -2125,23 +2125,23 @@ void gen_cvt_ftof(TCCState *S, int t)
o(S, 0x100ff2);
o(S, 0x44 + REG_VALUE(r)*8);
o(S, 0xf024);
- S->vtop->r = r;
+ S->tccgen_vtop->r = r;
} else if (tbt == VT_FLOAT) {
o(S, 0xf0245cd9); /* fstps -0x10(%rsp) */
/* movss -0x10(%rsp),%xmm0 */
o(S, 0x100ff3);
o(S, 0x44 + REG_VALUE(r)*8);
o(S, 0xf024);
- S->vtop->r = r;
+ S->tccgen_vtop->r = r;
}
}
}
/* convert fp to int 't' type */
-void gen_cvt_ftoi(TCCState *S, int t)
+void gen_cvt_ftoi(TCCState* S, int t)
{
int ft, bt, size, r;
- ft = S->vtop->type.t;
+ ft = S->tccgen_vtop->type.t;
bt = ft & VT_BTYPE;
if (bt == VT_LDOUBLE) {
gen_cvt_ftof(S, VT_DOUBLE);
@@ -2163,12 +2163,12 @@ void gen_cvt_ftoi(TCCState *S, int t)
assert(0);
}
orex(S, size == 8, r, 0, 0x2c0f); /* cvttss2si or cvttsd2si */
- o(S, 0xc0 + REG_VALUE(S->vtop->r) + REG_VALUE(r)*8);
- S->vtop->r = r;
+ o(S, 0xc0 + REG_VALUE(S->tccgen_vtop->r) + REG_VALUE(r)*8);
+ S->tccgen_vtop->r = r;
}
// Generate sign extension from 32 to 64 bits:
-ST_FUNC void gen_cvt_sxtw(TCCState *S)
+ST_FUNC void gen_cvt_sxtw(TCCState* S)
{
int r = gv(S, RC_INT);
/* x86_64 specific: movslq */
@@ -2177,13 +2177,13 @@ ST_FUNC void gen_cvt_sxtw(TCCState *S)
}
/* char/short to int conversion */
-ST_FUNC void gen_cvt_csti(TCCState *S, int t)
+ST_FUNC void gen_cvt_csti(TCCState* S, int t)
{
int r, sz, xl, ll;
r = gv(S, RC_INT);
sz = !(t & VT_UNSIGNED);
xl = (t & VT_BTYPE) == VT_SHORT;
- ll = (S->vtop->type.t & VT_BTYPE) == VT_LLONG;
+ ll = (S->tccgen_vtop->type.t & VT_BTYPE) == VT_LLONG;
orex(S, ll, r, 0, 0xc0b60f /* mov[sz] %a[xl], %eax */
| (sz << 3 | xl) << 8
| (REG_VALUE(r) << 3 | REG_VALUE(r)) << 16
@@ -2191,42 +2191,42 @@ ST_FUNC void gen_cvt_csti(TCCState *S, int t)
}
/* increment tcov counter */
-ST_FUNC void gen_increment_tcov (TCCState *S, SValue *sv)
+ST_FUNC void gen_increment_tcov (TCCState* S, SValue *sv)
{
o(S, 0x058348); /* addq $1, xxx(%rip) */
- greloca(S, cur_text_section, sv->sym, S->ind, R_X86_64_PC32, -5);
+ greloca(S, cur_text_section, sv->sym, S->tccgen_ind, R_X86_64_PC32, -5);
gen_le32(S, 0);
o(S, 1);
}
/* computed goto support */
-void ggoto(TCCState *S)
+void ggoto(TCCState* S)
{
gcall_or_jmp(S, 1);
- S->vtop--;
+ S->tccgen_vtop--;
}
/* Save the stack pointer onto the stack and return the location of its address */
-ST_FUNC void gen_vla_sp_save(TCCState *S, int addr) {
+ST_FUNC void gen_vla_sp_save(TCCState* S, int addr) {
/* mov %rsp,addr(%rbp)*/
gen_modrm64(S, 0x89, TREG_RSP, VT_LOCAL, NULL, addr);
}
/* Restore the SP from a location on the stack */
-ST_FUNC void gen_vla_sp_restore(TCCState *S, int addr) {
+ST_FUNC void gen_vla_sp_restore(TCCState* S, int addr) {
gen_modrm64(S, 0x8b, TREG_RSP, VT_LOCAL, NULL, addr);
}
#ifdef TCC_TARGET_PE
/* Save result of gen_vla_alloc onto the stack */
-ST_FUNC void gen_vla_result(TCCState *S, int addr) {
+ST_FUNC void gen_vla_result(TCCState* S, int addr) {
/* mov %rax,addr(%rbp)*/
gen_modrm64(S, 0x89, TREG_RAX, VT_LOCAL, NULL, addr);
}
#endif
/* Subtract from the stack pointer, and push the resulting value onto the stack */
-ST_FUNC void gen_vla_alloc(TCCState *S, CType *type, int align) {
+ST_FUNC void gen_vla_alloc(TCCState* S, CType *type, int align) {
int use_call = 0;
#if defined(CONFIG_TCC_BCHECK)