From f36430dab04c6c45a193b595a3a0160ee4a3f1f7 Mon Sep 17 00:00:00 2001 From: dibyendumajumdar Date: Fri, 13 Jan 2023 17:13:19 +0000 Subject: [PATCH] #169 sync with latest v0.1.2 version of MIR --- mir/c2mir/aarch64/caarch64-ABI-code.c | 2 +- mir/c2mir/aarch64/caarch64-code.c | 2 +- mir/c2mir/aarch64/caarch64.h | 2 +- mir/c2mir/aarch64/mirc_aarch64_float.h | 2 +- mir/c2mir/aarch64/mirc_aarch64_limits.h | 2 +- mir/c2mir/aarch64/mirc_aarch64_linux.h | 13 ++++- mir/c2mir/aarch64/mirc_aarch64_stdarg.h | 4 +- mir/c2mir/aarch64/mirc_aarch64_stddef.h | 2 +- mir/c2mir/aarch64/mirc_aarch64_stdint.h | 2 +- mir/c2mir/c2mir.c | 45 +++++++++++------- mir/c2mir/c2mir.h | 2 +- mir/c2mir/mirc.h | 2 +- mir/c2mir/mirc_iso646.h | 2 +- mir/c2mir/mirc_stdalign.h | 2 +- mir/c2mir/mirc_stdbool.h | 2 +- mir/c2mir/mirc_stdnoreturn.h | 2 +- mir/c2mir/ppc64/cppc64-ABI-code.c | 2 +- mir/c2mir/ppc64/cppc64-code.c | 2 +- mir/c2mir/ppc64/cppc64.h | 2 +- mir/c2mir/ppc64/mirc_ppc64_float.h | 2 +- mir/c2mir/ppc64/mirc_ppc64_limits.h | 2 +- mir/c2mir/ppc64/mirc_ppc64_linux.h | 7 ++- mir/c2mir/ppc64/mirc_ppc64_stdarg.h | 4 +- mir/c2mir/ppc64/mirc_ppc64_stddef.h | 2 +- mir/c2mir/ppc64/mirc_ppc64_stdint.h | 2 +- mir/c2mir/riscv64/criscv64-ABI-code.c | 2 +- mir/c2mir/riscv64/criscv64-code.c | 2 +- mir/c2mir/riscv64/criscv64.h | 2 +- mir/c2mir/riscv64/mirc_riscv64_float.h | 2 +- mir/c2mir/riscv64/mirc_riscv64_limits.h | 2 +- mir/c2mir/riscv64/mirc_riscv64_linux.h | 9 +++- mir/c2mir/riscv64/mirc_riscv64_stdarg.h | 4 +- mir/c2mir/riscv64/mirc_riscv64_stddef.h | 2 +- mir/c2mir/riscv64/mirc_riscv64_stdint.h | 2 +- mir/c2mir/s390x/cs390x-ABI-code.c | 2 +- mir/c2mir/s390x/cs390x-code.c | 2 +- mir/c2mir/s390x/cs390x.h | 4 +- mir/c2mir/s390x/mirc_s390x_float.h | 2 +- mir/c2mir/s390x/mirc_s390x_limits.h | 2 +- mir/c2mir/s390x/mirc_s390x_linux.h | 11 ++++- mir/c2mir/s390x/mirc_s390x_stdarg.h | 4 +- mir/c2mir/s390x/mirc_s390x_stddef.h | 2 +- mir/c2mir/s390x/mirc_s390x_stdint.h | 2 +- mir/c2mir/x86_64/cx86_64-ABI-code.c | 2 +- mir/c2mir/x86_64/cx86_64-code.c | 2 +- mir/c2mir/x86_64/cx86_64.h | 2 +- mir/c2mir/x86_64/mirc_x86_64_float.h | 2 +- mir/c2mir/x86_64/mirc_x86_64_limits.h | 2 +- mir/c2mir/x86_64/mirc_x86_64_linux.h | 12 ++++- mir/c2mir/x86_64/mirc_x86_64_stdarg.h | 4 +- mir/c2mir/x86_64/mirc_x86_64_stddef.h | 2 +- mir/c2mir/x86_64/mirc_x86_64_stdint.h | 2 +- mir/c2mir/x86_64/mirc_x86_64_win.h | 2 +- mir/mir-aarch64.c | 7 +-- mir/mir-bitmap.h | 2 +- mir/mir-dlist.h | 2 +- mir/mir-gen-aarch64.c | 55 +++++++++++---------- mir/mir-gen-ppc64.c | 2 +- mir/mir-gen-riscv64.c | 2 +- mir/mir-gen-s390x.c | 4 +- mir/mir-gen-stub.c | 2 +- mir/mir-gen-x86_64.c | 2 +- mir/mir-gen.c | 13 ++++- mir/mir-gen.h | 2 +- mir/mir-hash.h | 2 +- mir/mir-htab.h | 2 +- mir/mir-interp.c | 2 +- mir/mir-ppc64.c | 2 +- mir/mir-reduce.h | 2 +- mir/mir-riscv64.c | 2 +- mir/mir-s390x.c | 2 +- mir/mir-varr.h | 2 +- mir/mir-x86_64.c | 2 +- mir/mir.c | 63 +++++++++++++++---------- mir/mir.h | 2 +- mir/real-time.h | 2 +- 76 files changed, 234 insertions(+), 147 deletions(-) diff --git a/mir/c2mir/aarch64/caarch64-ABI-code.c b/mir/c2mir/aarch64/caarch64-ABI-code.c index 5b98fcfe..687c7292 100644 --- a/mir/c2mir/aarch64/caarch64-ABI-code.c +++ b/mir/c2mir/aarch64/caarch64-ABI-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . aarch64 call ABI target specific code. */ diff --git a/mir/c2mir/aarch64/caarch64-code.c b/mir/c2mir/aarch64/caarch64-code.c index 8ebea7fe..a273b86f 100644 --- a/mir/c2mir/aarch64/caarch64-code.c +++ b/mir/c2mir/aarch64/caarch64-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #include "../mirc.h" diff --git a/mir/c2mir/aarch64/caarch64.h b/mir/c2mir/aarch64/caarch64.h index e9b62cec..945a2ecd 100644 --- a/mir/c2mir/aarch64/caarch64.h +++ b/mir/c2mir/aarch64/caarch64.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #include diff --git a/mir/c2mir/aarch64/mirc_aarch64_float.h b/mir/c2mir/aarch64/mirc_aarch64_float.h index 0144879a..36ca51f7 100644 --- a/mir/c2mir/aarch64/mirc_aarch64_float.h +++ b/mir/c2mir/aarch64/mirc_aarch64_float.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 5.2.4.2.2 */ diff --git a/mir/c2mir/aarch64/mirc_aarch64_limits.h b/mir/c2mir/aarch64/mirc_aarch64_limits.h index 258a19e1..68a71ed9 100644 --- a/mir/c2mir/aarch64/mirc_aarch64_limits.h +++ b/mir/c2mir/aarch64/mirc_aarch64_limits.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See 5.2.4.2 */ diff --git a/mir/c2mir/aarch64/mirc_aarch64_linux.h b/mir/c2mir/aarch64/mirc_aarch64_linux.h index 1b79cd53..e2295a31 100644 --- a/mir/c2mir/aarch64/mirc_aarch64_linux.h +++ b/mir/c2mir/aarch64/mirc_aarch64_linux.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static char aarch64_mirc[] @@ -117,6 +117,17 @@ static char aarch64_mirc[] "#define linux 1\n" "#define __unix 1\n" "#define __unix__ 1\n" +#ifndef __GNU_LIBRARY__ + "typedef struct {\n" + " void *__stack;\n" + " void *__gr_top;\n" + " void *__vr_top;\n" + " int __gr_offs;\n" + " int __vr_offs;\n" + "} __builtin_va_list[1];\n" + "typedef __builtin_va_list va_list;\n" + "#define __DEFINED_va_list\n" +#endif #elif defined(__APPLE__) "#define __APPLE__ 1\n" "#define __arm64__\n" diff --git a/mir/c2mir/aarch64/mirc_aarch64_stdarg.h b/mir/c2mir/aarch64/mirc_aarch64_stdarg.h index 1e42d1a9..fab5e508 100644 --- a/mir/c2mir/aarch64/mirc_aarch64_stdarg.h +++ b/mir/c2mir/aarch64/mirc_aarch64_stdarg.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static char stdarg_str[] @@ -8,7 +8,7 @@ static char stdarg_str[] "\n" #if defined(__APPLE__) "typedef __darwin_va_list va_list;\n" -#else +#elif defined(__GNU_LIBRARY__) "typedef struct {\n" " void *__stack;\n" " void *__gr_top;\n" diff --git a/mir/c2mir/aarch64/mirc_aarch64_stddef.h b/mir/c2mir/aarch64/mirc_aarch64_stddef.h index 85275b1c..05d63c78 100644 --- a/mir/c2mir/aarch64/mirc_aarch64_stddef.h +++ b/mir/c2mir/aarch64/mirc_aarch64_stddef.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.19 */ diff --git a/mir/c2mir/aarch64/mirc_aarch64_stdint.h b/mir/c2mir/aarch64/mirc_aarch64_stdint.h index 2f21f678..4bda3749 100644 --- a/mir/c2mir/aarch64/mirc_aarch64_stdint.h +++ b/mir/c2mir/aarch64/mirc_aarch64_stdint.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.20 */ diff --git a/mir/c2mir/c2mir.c b/mir/c2mir/c2mir.c index 818d5261..6a3b8ca0 100644 --- a/mir/c2mir/c2mir.c +++ b/mir/c2mir/c2mir.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* C to MIR compiler. It is a four pass compiler: @@ -1702,7 +1702,7 @@ static token_t get_next_pptoken_1 (c2m_ctx_t c2m_ctx, int header_p) { } else { VARR_PUSH (char, symbol_text, curr_c); VARR_PUSH (char, symbol_text, '\0'); - return new_token_wo_uniq_repr (c2m_ctx, pos, VARR_ADDR (char, symbol_text), curr_c, + return new_token_wo_uniq_repr (c2m_ctx, cs->pos, VARR_ADDR (char, symbol_text), curr_c, N_IGNORE); } } @@ -5914,7 +5914,12 @@ static int basic_type_size (enum basic_type bt) { } } -static int basic_type_align (enum basic_type bt) { return basic_type_size (bt); } +static int basic_type_align (enum basic_type bt) { +#ifdef MIR_LDOUBLE_ALIGN + if (bt == TP_LDOUBLE) return MIR_LDOUBLE_ALIGN; +#endif + return basic_type_size (bt); +} static int type_align (struct type *type) { assert (type->align >= 0); @@ -8250,9 +8255,15 @@ static void process_func_decls_for_allocation (c2m_ctx_t c2m_ctx) { } } -#define BUILTIN_VA_START "__builtin_va_start" -#define BUILTIN_VA_ARG "__builtin_va_arg" -#define ALLOCA "alloca" +#define BUILTIN_VA_START (const char *[]){"__builtin_va_start", NULL} +#define BUILTIN_VA_ARG (const char *[]){"__builtin_va_arg", NULL} +#define ALLOCA (const char *[]){"alloca", "__builtin_alloca", NULL} + +static int str_eq_p (const char *str, const char *v[]) { + for (int i = 0; v[i] != NULL; i++) + if (strcmp (v[i], str) == 0) return TRUE; + return FALSE; +} static void check (c2m_ctx_t c2m_ctx, node_t r, node_t context) { check_ctx_t check_ctx = c2m_ctx->check_ctx; @@ -8969,10 +8980,10 @@ static void check (c2m_ctx_t c2m_ctx, node_t r, node_t context) { int builtin_call_p, alloca_p, va_arg_p = FALSE, va_start_p = FALSE; op1 = NL_HEAD (r->u.ops); - alloca_p = op1->code == N_ID && strcmp (op1->u.s.s, ALLOCA) == 0; + alloca_p = op1->code == N_ID && str_eq_p (op1->u.s.s, ALLOCA); if (op1->code == N_ID && find_def (c2m_ctx, S_REGULAR, op1, curr_scope, NULL) == NULL) { - va_arg_p = strcmp (op1->u.s.s, BUILTIN_VA_ARG) == 0; - va_start_p = strcmp (op1->u.s.s, BUILTIN_VA_START) == 0; + va_arg_p = str_eq_p (op1->u.s.s, BUILTIN_VA_ARG); + va_start_p = str_eq_p (op1->u.s.s, BUILTIN_VA_START); if (!va_arg_p && !va_start_p && !alloca_p) { /* N_SPEC_DECL (N_SHARE (N_LIST (N_INT)), N_DECL (N_ID, N_FUNC (N_LIST)), N_IGNORE) */ spec_list = new_node (c2m_ctx, N_LIST); @@ -9010,11 +9021,11 @@ static void check (c2m_ctx_t c2m_ctx, node_t r, node_t context) { } ret_type = &res_type; if (va_start_p && NL_LENGTH (arg_list->u.ops) != 1) { - error (c2m_ctx, POS (op1), "wrong number of arguments in %s call", BUILTIN_VA_START); + error (c2m_ctx, POS (op1), "wrong number of arguments in %s call", op1->u.s.s); } else if (alloca_p && NL_LENGTH (arg_list->u.ops) != 1) { - error (c2m_ctx, POS (op1), "wrong number of arguments in %s call", ALLOCA); + error (c2m_ctx, POS (op1), "wrong number of arguments in %s call", op1->u.s.s); } else if (va_arg_p && NL_LENGTH (arg_list->u.ops) != 2) { - error (c2m_ctx, POS (op1), "wrong number of arguments in %s call", BUILTIN_VA_ARG); + error (c2m_ctx, POS (op1), "wrong number of arguments in %s call", op1->u.s.s); } else { /* first argument type ??? */ if (va_arg_p) { @@ -9258,8 +9269,8 @@ static void check (c2m_ctx_t c2m_ctx, node_t r, node_t context) { symbol_t sym; struct node_scope *ns; - if (strcmp (id->u.s.s, ALLOCA) == 0 || strcmp (id->u.s.s, BUILTIN_VA_START) == 0 - || strcmp (id->u.s.s, BUILTIN_VA_ARG) == 0) { + if (str_eq_p (id->u.s.s, ALLOCA) || str_eq_p (id->u.s.s, BUILTIN_VA_START) + || str_eq_p (id->u.s.s, BUILTIN_VA_ARG)) { error (c2m_ctx, POS (id), "%s is a builtin function", id->u.s.s); break; } @@ -12129,9 +12140,9 @@ static op_t gen (c2m_ctx_t c2m_ctx, node_t r, MIR_label_t true_label, MIR_label_ MIR_item_t proto_item; MIR_insn_t call_insn; mir_size_t saved_call_arg_area_offset_before_args, arg_area_offset; - int va_arg_p = call_expr->builtin_call_p && strcmp (func->u.s.s, BUILTIN_VA_ARG) == 0; - int va_start_p = call_expr->builtin_call_p && strcmp (func->u.s.s, BUILTIN_VA_START) == 0; - int alloca_p = call_expr->builtin_call_p && strcmp (func->u.s.s, ALLOCA) == 0; + int va_arg_p = call_expr->builtin_call_p && str_eq_p (func->u.s.s, BUILTIN_VA_ARG); + int va_start_p = call_expr->builtin_call_p && str_eq_p (func->u.s.s, BUILTIN_VA_START); + int alloca_p = call_expr->builtin_call_p && str_eq_p (func->u.s.s, ALLOCA); int builtin_call_p = alloca_p || va_arg_p || va_start_p, inline_p = FALSE; node_t block = NL_EL (curr_func_def->u.ops, 3); struct node_scope *ns = block->attr; diff --git a/mir/c2mir/c2mir.h b/mir/c2mir/c2mir.h index 45997d8e..c90e2be9 100644 --- a/mir/c2mir/c2mir.h +++ b/mir/c2mir/c2mir.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #ifndef C2MIR_H diff --git a/mir/c2mir/mirc.h b/mir/c2mir/mirc.h index d301540e..34eecb1d 100644 --- a/mir/c2mir/mirc.h +++ b/mir/c2mir/mirc.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static const char mirc[] diff --git a/mir/c2mir/mirc_iso646.h b/mir/c2mir/mirc_iso646.h index 6e4a2caa..e42438a5 100644 --- a/mir/c2mir/mirc_iso646.h +++ b/mir/c2mir/mirc_iso646.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.9 */ diff --git a/mir/c2mir/mirc_stdalign.h b/mir/c2mir/mirc_stdalign.h index d33c5f63..99d48bef 100644 --- a/mir/c2mir/mirc_stdalign.h +++ b/mir/c2mir/mirc_stdalign.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.15 */ diff --git a/mir/c2mir/mirc_stdbool.h b/mir/c2mir/mirc_stdbool.h index 076bb772..2621a05d 100644 --- a/mir/c2mir/mirc_stdbool.h +++ b/mir/c2mir/mirc_stdbool.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.18 */ diff --git a/mir/c2mir/mirc_stdnoreturn.h b/mir/c2mir/mirc_stdnoreturn.h index 7ec280bd..7782eed0 100644 --- a/mir/c2mir/mirc_stdnoreturn.h +++ b/mir/c2mir/mirc_stdnoreturn.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.23 */ diff --git a/mir/c2mir/ppc64/cppc64-ABI-code.c b/mir/c2mir/ppc64/cppc64-ABI-code.c index 0f6762d9..5833d814 100644 --- a/mir/c2mir/ppc64/cppc64-ABI-code.c +++ b/mir/c2mir/ppc64/cppc64-ABI-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . ppc64 call ABI target specific code. */ diff --git a/mir/c2mir/ppc64/cppc64-code.c b/mir/c2mir/ppc64/cppc64-code.c index 28602e35..0c8813c4 100644 --- a/mir/c2mir/ppc64/cppc64-code.c +++ b/mir/c2mir/ppc64/cppc64-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #include "../mirc.h" diff --git a/mir/c2mir/ppc64/cppc64.h b/mir/c2mir/ppc64/cppc64.h index e9b62cec..945a2ecd 100644 --- a/mir/c2mir/ppc64/cppc64.h +++ b/mir/c2mir/ppc64/cppc64.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #include diff --git a/mir/c2mir/ppc64/mirc_ppc64_float.h b/mir/c2mir/ppc64/mirc_ppc64_float.h index 1764813b..bdcab189 100644 --- a/mir/c2mir/ppc64/mirc_ppc64_float.h +++ b/mir/c2mir/ppc64/mirc_ppc64_float.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 5.2.4.2.2 */ diff --git a/mir/c2mir/ppc64/mirc_ppc64_limits.h b/mir/c2mir/ppc64/mirc_ppc64_limits.h index 00ce4e17..c0e0d9a1 100644 --- a/mir/c2mir/ppc64/mirc_ppc64_limits.h +++ b/mir/c2mir/ppc64/mirc_ppc64_limits.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See 5.2.4.2 */ diff --git a/mir/c2mir/ppc64/mirc_ppc64_linux.h b/mir/c2mir/ppc64/mirc_ppc64_linux.h index 6202854a..be5b8313 100644 --- a/mir/c2mir/ppc64/mirc_ppc64_linux.h +++ b/mir/c2mir/ppc64/mirc_ppc64_linux.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static char ppc64_mirc[] @@ -113,6 +113,11 @@ static char ppc64_mirc[] "#define linux 1\n" "#define __unix 1\n" "#define __unix__ 1\n" +#ifndef __GNU_LIBRARY__ + "typedef void *__builtin_va_list[1];\n" + "typedef __builtin_va_list va_list;\n" + "#define __DEFINED_va_list\n" +#endif #endif "\n" "void *alloca (unsigned long);\n"; diff --git a/mir/c2mir/ppc64/mirc_ppc64_stdarg.h b/mir/c2mir/ppc64/mirc_ppc64_stdarg.h index 741e482b..3ac20829 100644 --- a/mir/c2mir/ppc64/mirc_ppc64_stdarg.h +++ b/mir/c2mir/ppc64/mirc_ppc64_stdarg.h @@ -1,13 +1,15 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static char stdarg_str[] = "#ifndef __STDARG_H\n" "#define __STDARG_H\n" "\n" +#if defined(__GNU_LIBRARY__) "typedef void *va_list[1];\n" "\n" +#endif "#define va_start(ap, param) __builtin_va_start (ap)\n" "#define va_arg(ap, type) __builtin_va_arg(ap, (type *) 0)\n" "#define va_end(ap) 0\n" diff --git a/mir/c2mir/ppc64/mirc_ppc64_stddef.h b/mir/c2mir/ppc64/mirc_ppc64_stddef.h index 85275b1c..05d63c78 100644 --- a/mir/c2mir/ppc64/mirc_ppc64_stddef.h +++ b/mir/c2mir/ppc64/mirc_ppc64_stddef.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.19 */ diff --git a/mir/c2mir/ppc64/mirc_ppc64_stdint.h b/mir/c2mir/ppc64/mirc_ppc64_stdint.h index ec968c34..aa06f822 100644 --- a/mir/c2mir/ppc64/mirc_ppc64_stdint.h +++ b/mir/c2mir/ppc64/mirc_ppc64_stdint.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.20 */ diff --git a/mir/c2mir/riscv64/criscv64-ABI-code.c b/mir/c2mir/riscv64/criscv64-ABI-code.c index bd9b69b6..b381750e 100644 --- a/mir/c2mir/riscv64/criscv64-ABI-code.c +++ b/mir/c2mir/riscv64/criscv64-ABI-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . riscv64 call ABI target specific code. */ diff --git a/mir/c2mir/riscv64/criscv64-code.c b/mir/c2mir/riscv64/criscv64-code.c index 61e83381..d5deb7f1 100644 --- a/mir/c2mir/riscv64/criscv64-code.c +++ b/mir/c2mir/riscv64/criscv64-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #include "../mirc.h" diff --git a/mir/c2mir/riscv64/criscv64.h b/mir/c2mir/riscv64/criscv64.h index e9b62cec..945a2ecd 100644 --- a/mir/c2mir/riscv64/criscv64.h +++ b/mir/c2mir/riscv64/criscv64.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #include diff --git a/mir/c2mir/riscv64/mirc_riscv64_float.h b/mir/c2mir/riscv64/mirc_riscv64_float.h index 9faabe8c..25872578 100644 --- a/mir/c2mir/riscv64/mirc_riscv64_float.h +++ b/mir/c2mir/riscv64/mirc_riscv64_float.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 5.2.4.2.2 */ diff --git a/mir/c2mir/riscv64/mirc_riscv64_limits.h b/mir/c2mir/riscv64/mirc_riscv64_limits.h index 258a19e1..68a71ed9 100644 --- a/mir/c2mir/riscv64/mirc_riscv64_limits.h +++ b/mir/c2mir/riscv64/mirc_riscv64_limits.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See 5.2.4.2 */ diff --git a/mir/c2mir/riscv64/mirc_riscv64_linux.h b/mir/c2mir/riscv64/mirc_riscv64_linux.h index 81e46935..8a296a96 100644 --- a/mir/c2mir/riscv64/mirc_riscv64_linux.h +++ b/mir/c2mir/riscv64/mirc_riscv64_linux.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static char riscv64_mirc[] @@ -109,5 +109,12 @@ static char riscv64_mirc[] "#define linux 1\n" "#define __unix 1\n" "#define __unix__ 1\n" +#ifndef __GNU_LIBRARY__ + "typedef struct {\n" + " void *arg_area;\n" + "} __builtin_va_list;\n" + "typedef __builtin_va_list va_list;\n" + "#define __DEFINED_va_list\n" +#endif "\n" "void *alloca (unsigned long);\n"; diff --git a/mir/c2mir/riscv64/mirc_riscv64_stdarg.h b/mir/c2mir/riscv64/mirc_riscv64_stdarg.h index 23431861..ac8b045a 100644 --- a/mir/c2mir/riscv64/mirc_riscv64_stdarg.h +++ b/mir/c2mir/riscv64/mirc_riscv64_stdarg.h @@ -1,15 +1,17 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static char stdarg_str[] = "#ifndef __STDARG_H\n" "#define __STDARG_H\n" "\n" +#if defined(__GNU_LIBRARY__) "typedef struct {\n" " void *arg_area;\n" "} va_list;\n" "\n" +#endif "#define va_start(ap, param) __builtin_va_start (ap)\n" "#define va_arg(ap, type) __builtin_va_arg(ap, (type *) 0)\n" "#define va_end(ap) 0\n" diff --git a/mir/c2mir/riscv64/mirc_riscv64_stddef.h b/mir/c2mir/riscv64/mirc_riscv64_stddef.h index 85275b1c..05d63c78 100644 --- a/mir/c2mir/riscv64/mirc_riscv64_stddef.h +++ b/mir/c2mir/riscv64/mirc_riscv64_stddef.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.19 */ diff --git a/mir/c2mir/riscv64/mirc_riscv64_stdint.h b/mir/c2mir/riscv64/mirc_riscv64_stdint.h index ec968c34..aa06f822 100644 --- a/mir/c2mir/riscv64/mirc_riscv64_stdint.h +++ b/mir/c2mir/riscv64/mirc_riscv64_stdint.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.20 */ diff --git a/mir/c2mir/s390x/cs390x-ABI-code.c b/mir/c2mir/s390x/cs390x-ABI-code.c index b10963ff..8d580534 100644 --- a/mir/c2mir/s390x/cs390x-ABI-code.c +++ b/mir/c2mir/s390x/cs390x-ABI-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . s390x call ABI target specific code. */ diff --git a/mir/c2mir/s390x/cs390x-code.c b/mir/c2mir/s390x/cs390x-code.c index f3291f35..6544431b 100644 --- a/mir/c2mir/s390x/cs390x-code.c +++ b/mir/c2mir/s390x/cs390x-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #include "../mirc.h" diff --git a/mir/c2mir/s390x/cs390x.h b/mir/c2mir/s390x/cs390x.h index e9b62cec..dfa031e9 100644 --- a/mir/c2mir/s390x/cs390x.h +++ b/mir/c2mir/s390x/cs390x.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ #include @@ -53,3 +53,5 @@ typedef int64_t mir_ptrdiff_t; typedef uint64_t mir_size_t; #define MIR_SIZE_MAX UINT64_MAX + +#define MIR_LDOUBLE_ALIGN 8 diff --git a/mir/c2mir/s390x/mirc_s390x_float.h b/mir/c2mir/s390x/mirc_s390x_float.h index 0144879a..36ca51f7 100644 --- a/mir/c2mir/s390x/mirc_s390x_float.h +++ b/mir/c2mir/s390x/mirc_s390x_float.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 5.2.4.2.2 */ diff --git a/mir/c2mir/s390x/mirc_s390x_limits.h b/mir/c2mir/s390x/mirc_s390x_limits.h index 00ce4e17..c0e0d9a1 100644 --- a/mir/c2mir/s390x/mirc_s390x_limits.h +++ b/mir/c2mir/s390x/mirc_s390x_limits.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See 5.2.4.2 */ diff --git a/mir/c2mir/s390x/mirc_s390x_linux.h b/mir/c2mir/s390x/mirc_s390x_linux.h index 41f5a33d..c4ca2db0 100644 --- a/mir/c2mir/s390x/mirc_s390x_linux.h +++ b/mir/c2mir/s390x/mirc_s390x_linux.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static char s390x_mirc[] @@ -108,6 +108,15 @@ static char s390x_mirc[] "#define unix 1\n" "#define __unix 1\n" "#define __unix__ 1\n" +#ifndef __GNU_LIBRARY__ + "typedef struct {\n" + " long __gpr, __fpr;\n" + " void *__overflow_arg_area;\n" + " void *__reg_save_area;\n" + "} __builtin_va_list[1];\n" + "typedef __builtin_va_list va_list;\n" + "#define __DEFINED_va_list\n" +#endif #endif "\n" "void *alloca (unsigned long);\n"; diff --git a/mir/c2mir/s390x/mirc_s390x_stdarg.h b/mir/c2mir/s390x/mirc_s390x_stdarg.h index e65f19e0..e7aca7b4 100644 --- a/mir/c2mir/s390x/mirc_s390x_stdarg.h +++ b/mir/c2mir/s390x/mirc_s390x_stdarg.h @@ -1,17 +1,19 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static char stdarg_str[] = "#ifndef __STDARG_H\n" "#define __STDARG_H\n" "\n" +#if defined(__GNU_LIBRARY__) "typedef struct {\n" " long __gpr, __fpr;\n" " void *__overflow_arg_area;\n" " void *__reg_save_area;\n" "} va_list[1];\n" "\n" +#endif "#define va_start(ap, param) __builtin_va_start (ap)\n" "#define va_arg(ap, type) __builtin_va_arg(ap, (type *) 0)\n" "#define va_end(ap) 0\n" diff --git a/mir/c2mir/s390x/mirc_s390x_stddef.h b/mir/c2mir/s390x/mirc_s390x_stddef.h index 85275b1c..05d63c78 100644 --- a/mir/c2mir/s390x/mirc_s390x_stddef.h +++ b/mir/c2mir/s390x/mirc_s390x_stddef.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.19 */ diff --git a/mir/c2mir/s390x/mirc_s390x_stdint.h b/mir/c2mir/s390x/mirc_s390x_stdint.h index ec968c34..aa06f822 100644 --- a/mir/c2mir/s390x/mirc_s390x_stdint.h +++ b/mir/c2mir/s390x/mirc_s390x_stdint.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* See C11 7.20 */ diff --git a/mir/c2mir/x86_64/cx86_64-ABI-code.c b/mir/c2mir/x86_64/cx86_64-ABI-code.c index 2c75af30..78de581e 100644 --- a/mir/c2mir/x86_64/cx86_64-ABI-code.c +++ b/mir/c2mir/x86_64/cx86_64-ABI-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . x86_64 ABI target specific code. */ diff --git a/mir/c2mir/x86_64/cx86_64-code.c b/mir/c2mir/x86_64/cx86_64-code.c index e0f1997f..682fef05 100644 --- a/mir/c2mir/x86_64/cx86_64-code.c +++ b/mir/c2mir/x86_64/cx86_64-code.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #include "../mirc.h" diff --git a/mir/c2mir/x86_64/cx86_64.h b/mir/c2mir/x86_64/cx86_64.h index 925a3fad..83a912ef 100644 --- a/mir/c2mir/x86_64/cx86_64.h +++ b/mir/c2mir/x86_64/cx86_64.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #include diff --git a/mir/c2mir/x86_64/mirc_x86_64_float.h b/mir/c2mir/x86_64/mirc_x86_64_float.h index 5132ba07..90d4675c 100644 --- a/mir/c2mir/x86_64/mirc_x86_64_float.h +++ b/mir/c2mir/x86_64/mirc_x86_64_float.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2019-2021 Vladimir Makarov . + Copyright (C) 2019-2023 Vladimir Makarov . */ /* See C11 5.2.4.2.2 */ diff --git a/mir/c2mir/x86_64/mirc_x86_64_limits.h b/mir/c2mir/x86_64/mirc_x86_64_limits.h index d8e9697d..19efff4f 100644 --- a/mir/c2mir/x86_64/mirc_x86_64_limits.h +++ b/mir/c2mir/x86_64/mirc_x86_64_limits.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2019-2021 Vladimir Makarov . + Copyright (C) 2019-2023 Vladimir Makarov . */ /* See 5.2.4.2 */ diff --git a/mir/c2mir/x86_64/mirc_x86_64_linux.h b/mir/c2mir/x86_64/mirc_x86_64_linux.h index 63e05c90..85eeb0d3 100644 --- a/mir/c2mir/x86_64/mirc_x86_64_linux.h +++ b/mir/c2mir/x86_64/mirc_x86_64_linux.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2019-2021 Vladimir Makarov . + Copyright (C) 2019-2023 Vladimir Makarov . */ static char x86_64_mirc[] @@ -105,6 +105,16 @@ static char x86_64_mirc[] "#define linux 1\n" "#define __unix 1\n" "#define __unix__ 1\n" +#ifndef __GNU_LIBRARY__ + "typedef struct {\n" + " unsigned int gp_offset;\n" + " unsigned int fp_offset;\n" + " void *overflow_arg_area;\n" + " void *reg_save_area;\n" + "} __builtin_va_list[1];\n" + "typedef __builtin_va_list va_list;\n" + "#define __DEFINED_va_list\n" +#endif #elif defined(__APPLE__) "#define __APPLE__ 1\n" "#define __DARWIN_OS_INLINE static inline\n" diff --git a/mir/c2mir/x86_64/mirc_x86_64_stdarg.h b/mir/c2mir/x86_64/mirc_x86_64_stdarg.h index 71173f3c..c15feb37 100644 --- a/mir/c2mir/x86_64/mirc_x86_64_stdarg.h +++ b/mir/c2mir/x86_64/mirc_x86_64_stdarg.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2019-2021 Vladimir Makarov . + Copyright (C) 2019-2023 Vladimir Makarov . */ /* See C11 7.16 and https://www.uclibc.org/docs/psABI-x86_64.pdf */ @@ -11,7 +11,7 @@ static char stdarg_str[] "typedef __darwin_va_list va_list;\n" #elif defined(__WIN32) "typedef char *va_list;\n" -#else +#elif defined(__GNU_LIBRARY__) "typedef struct {\n" " unsigned int gp_offset;\n" " unsigned int fp_offset;\n" diff --git a/mir/c2mir/x86_64/mirc_x86_64_stddef.h b/mir/c2mir/x86_64/mirc_x86_64_stddef.h index c365f8b2..0b84adf6 100644 --- a/mir/c2mir/x86_64/mirc_x86_64_stddef.h +++ b/mir/c2mir/x86_64/mirc_x86_64_stddef.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2019-2021 Vladimir Makarov . + Copyright (C) 2019-2023 Vladimir Makarov . */ /* See C11 7.19 */ diff --git a/mir/c2mir/x86_64/mirc_x86_64_stdint.h b/mir/c2mir/x86_64/mirc_x86_64_stdint.h index 25e6520a..9ccbf61a 100644 --- a/mir/c2mir/x86_64/mirc_x86_64_stdint.h +++ b/mir/c2mir/x86_64/mirc_x86_64_stdint.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2019-2021 Vladimir Makarov . + Copyright (C) 2019-2023 Vladimir Makarov . */ /* See C11 7.20 */ diff --git a/mir/c2mir/x86_64/mirc_x86_64_win.h b/mir/c2mir/x86_64/mirc_x86_64_win.h index d947d8dd..6b0c998c 100644 --- a/mir/c2mir/x86_64/mirc_x86_64_win.h +++ b/mir/c2mir/x86_64/mirc_x86_64_win.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2019-2021 Vladimir Makarov . + Copyright (C) 2019-2023 Vladimir Makarov . */ static char x86_64_mirc[] diff --git a/mir/mir-aarch64.c b/mir/mir-aarch64.c index 95d1dfea..a9372598 100644 --- a/mir/mir-aarch64.c +++ b/mir/mir-aarch64.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* x31 - sp; x30 - link reg; x29 - fp; x0-x7, v0-v7 - arg/result regs; @@ -480,7 +480,7 @@ void *_MIR_get_interp_shim (MIR_context_t ctx, MIR_item_t func_item, void *handl #if defined(__APPLE__) 0x910023e3, /* add x3, sp, 8 # results arg */ #else - 0x910043e3, /* add x3, sp, 16 # results arg */ + 0x910043e3, /* add x3, sp, 16 # results arg */ #endif 0xaa0303f3, /* mov x19, x3 # results */ 0xf90003fe, /* str x30, [sp] # save lr */ @@ -569,7 +569,8 @@ void *_MIR_get_interp_shim (MIR_context_t ctx, MIR_item_t func_item, void *handl } else if (n_xregs < 8) { /* str xreg, sp_offset[sp] */ pat = st_pat | ((sp_offset >> scale) << 10) | n_xregs++ | (sp << 5); } else { /* ldr t, stack_arg_offset[x9]; st t, sp_offset[sp]: */ - pat = (ld_pat & base_reg_mask) | stack_arg_sp_offset | temp_reg | (9 << 5); + pat + = (ld_pat & base_reg_mask) | ((stack_arg_sp_offset >> scale) << 10) | temp_reg | (9 << 5); push_insns (code, &pat, sizeof (pat)); pat = st_pat | ((sp_offset >> scale) << 10) | temp_reg | (sp << 5); stack_arg_sp_offset += 8; diff --git a/mir/mir-bitmap.h b/mir/mir-bitmap.h index 8849e2ca..aab22622 100644 --- a/mir/mir-bitmap.h +++ b/mir/mir-bitmap.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #ifndef MIR_BITMAP_H diff --git a/mir/mir-dlist.h b/mir/mir-dlist.h index 0e8373a4..f34d1365 100644 --- a/mir/mir-dlist.h +++ b/mir/mir-dlist.h @@ -1,5 +1,5 @@ /* This file is part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* Typed doubly linked lists. */ diff --git a/mir/mir-gen-aarch64.c b/mir/mir-gen-aarch64.c index f34419de..f123f601 100644 --- a/mir/mir-gen-aarch64.c +++ b/mir/mir-gen-aarch64.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ static void fancy_abort (int code) { @@ -430,9 +430,10 @@ static void machinize_call (gen_ctx_t gen_ctx, MIR_insn_t call_insn) { if (type == MIR_T_LD && __SIZEOF_LONG_DOUBLE__ == 16 && mem_size % 16 != 0) mem_size = (mem_size + 15) / 16 * 16; mem_type = type == MIR_T_F || type == MIR_T_D || type == MIR_T_LD ? type : MIR_T_I64; - new_insn_code - = (type == MIR_T_F ? MIR_FMOV - : type == MIR_T_D ? MIR_DMOV : type == MIR_T_LD ? MIR_LDMOV : MIR_MOV); + new_insn_code = (type == MIR_T_F ? MIR_FMOV + : type == MIR_T_D ? MIR_DMOV + : type == MIR_T_LD ? MIR_LDMOV + : MIR_MOV); mem_op = get_new_hard_reg_mem_op (gen_ctx, mem_type, mem_size, SP_HARD_REG, &insn1, &insn2); if (type != MIR_T_RBLK) { new_insn = MIR_new_insn (ctx, new_insn_code, mem_op, arg_op); @@ -466,9 +467,11 @@ static void machinize_call (gen_ctx_t gen_ctx, MIR_insn_t call_insn) { type = proto->res_types[i]; float_p = type == MIR_T_F || type == MIR_T_D || type == MIR_T_LD; if (float_p && n_vregs < 8) { - new_insn - = MIR_new_insn (ctx, type == MIR_T_F ? MIR_FMOV : type == MIR_T_D ? MIR_DMOV : MIR_LDMOV, - ret_reg_op, _MIR_new_hard_reg_op (ctx, V0_HARD_REG + n_vregs)); + new_insn = MIR_new_insn (ctx, + type == MIR_T_F ? MIR_FMOV + : type == MIR_T_D ? MIR_DMOV + : MIR_LDMOV, + ret_reg_op, _MIR_new_hard_reg_op (ctx, V0_HARD_REG + n_vregs)); n_vregs++; } else if (!float_p && n_iregs < 8) { new_insn = MIR_new_insn (ctx, MIR_MOV, ret_reg_op, @@ -857,9 +860,10 @@ static void target_machinize (gen_ctx_t gen_ctx) { } mem_type = type == MIR_T_F || type == MIR_T_D || type == MIR_T_LD ? type : MIR_T_I64; if (type == MIR_T_LD) mem_size = (mem_size + 15) / 16 * 16; - new_insn_code - = (type == MIR_T_F ? MIR_FMOV - : type == MIR_T_D ? MIR_DMOV : type == MIR_T_LD ? MIR_LDMOV : MIR_MOV); + new_insn_code = (type == MIR_T_F ? MIR_FMOV + : type == MIR_T_D ? MIR_DMOV + : type == MIR_T_LD ? MIR_LDMOV + : MIR_MOV); mem_op = new_hard_reg_mem_op (gen_ctx, anchor, mem_type, mem_size, R8_HARD_REG); gen_mov (gen_ctx, anchor, new_insn_code, MIR_new_reg_op (ctx, i + 1), mem_op); mem_size += type == MIR_T_LD ? 16 : 8; @@ -876,13 +880,12 @@ static void target_machinize (gen_ctx_t gen_ctx) { if (code == MIR_LDBEQ || code == MIR_LDBNE || code == MIR_LDBLT || code == MIR_LDBGE || code == MIR_LDBGT || code == MIR_LDBLE) { temp_op = MIR_new_reg_op (ctx, gen_new_temp_reg (gen_ctx, MIR_T_I64, func)); - code = (code == MIR_LDBEQ - ? MIR_LDEQ - : code == MIR_LDBNE - ? MIR_LDNE - : code == MIR_LDBLT - ? MIR_LDLT - : code == MIR_LDBGE ? MIR_LDGE : code == MIR_LDBGT ? MIR_LDGT : MIR_LDLE); + code = (code == MIR_LDBEQ ? MIR_LDEQ + : code == MIR_LDBNE ? MIR_LDNE + : code == MIR_LDBLT ? MIR_LDLT + : code == MIR_LDBGE ? MIR_LDGE + : code == MIR_LDBGT ? MIR_LDGT + : MIR_LDLE); new_insn = MIR_new_insn (ctx, code, temp_op, insn->ops[1], insn->ops[2]); gen_add_insn_before (gen_ctx, insn, new_insn); next_insn = MIR_new_insn (ctx, MIR_BT, insn->ops[0], temp_op); @@ -1008,8 +1011,9 @@ static void target_machinize (gen_ctx_t gen_ctx) { assert (insn->ops[i].mode == MIR_OP_REG); res_type = func->res_types[i]; if ((res_type == MIR_T_F || res_type == MIR_T_D || res_type == MIR_T_LD) && n_vregs < 8) { - new_insn_code - = res_type == MIR_T_F ? MIR_FMOV : res_type == MIR_T_D ? MIR_DMOV : MIR_LDMOV; + new_insn_code = res_type == MIR_T_F ? MIR_FMOV + : res_type == MIR_T_D ? MIR_DMOV + : MIR_LDMOV; ret_reg = V0_HARD_REG + n_vregs++; } else if (n_iregs < 8) { new_insn_code = MIR_MOV; @@ -2066,9 +2070,10 @@ static void patterns_finish (gen_ctx_t gen_ctx) { } static int hex_value (int ch) { - return ('0' <= ch && ch <= '9' - ? ch - '0' - : 'A' <= ch && ch <= 'F' ? ch - 'A' + 10 : 'a' <= ch && ch <= 'f' ? ch - 'a' + 10 : -1); + return ('0' <= ch && ch <= '9' ? ch - '0' + : 'A' <= ch && ch <= 'F' ? ch - 'A' + 10 + : 'a' <= ch && ch <= 'f' ? ch - 'a' + 10 + : -1); } static uint64_t read_hex (const char **ptr) { @@ -2361,10 +2366,8 @@ static void out_insn (gen_ctx_t gen_ctx, MIR_insn_t insn, const char *replacemen opcode |= imm12_shift << 22; opcode_mask = check_and_set_mask (opcode_mask, 0x3 << 22); } - if (label_ref_num >= 0) - VARR_ADDR (label_ref_t, label_refs) - [label_ref_num].label_val_disp - = VARR_LENGTH (uint8_t, result_code); + if (label_ref_num >= 0) VARR_ADDR (label_ref_t, label_refs) + [label_ref_num].label_val_disp = VARR_LENGTH (uint8_t, result_code); if (switch_table_addr_p) switch_table_adr_insn_start = VARR_LENGTH (uint8_t, result_code); put_uint64 (gen_ctx, opcode, 4); /* output the machine insn */ diff --git a/mir/mir-gen-ppc64.c b/mir/mir-gen-ppc64.c index 049d67f9..4454cbdf 100644 --- a/mir/mir-gen-ppc64.c +++ b/mir/mir-gen-ppc64.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* We don't use TOC. So r2 is not necessary for the generated code. */ diff --git a/mir/mir-gen-riscv64.c b/mir/mir-gen-riscv64.c index 8e386674..53321533 100644 --- a/mir/mir-gen-riscv64.c +++ b/mir/mir-gen-riscv64.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ /* In MIR generated code unsigned 32-bit values are zero extended but diff --git a/mir/mir-gen-s390x.c b/mir/mir-gen-s390x.c index 0fb5efdf..66a22c6d 100644 --- a/mir/mir-gen-s390x.c +++ b/mir/mir-gen-s390x.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2020-2021 Vladimir Makarov . + Copyright (C) 2020-2023 Vladimir Makarov . */ // ??? More patterns (ult, ugt, ule, uge w/o branches, multi-insn combining). @@ -316,7 +316,7 @@ static void machinize_call (gen_ctx_t gen_ctx, MIR_insn_t call_insn) { if (param_save_area_size < param_mem_size) param_save_area_size = param_mem_size; if (blk_ld_value_save_area_size < call_blk_ld_value_area_size) blk_ld_value_save_area_size = call_blk_ld_value_area_size; - blk_ld_value_disp = param_mem_size; + blk_ld_value_disp = param_save_area_size; param_mem_size = n_fregs = n_iregs = 0; for (size_t i = 2; i < nops; i++) { /* process args and ???long double results: */ arg_op = call_insn->ops[i]; diff --git a/mir/mir-gen-stub.c b/mir/mir-gen-stub.c index f4d767f4..d4c82510 100644 --- a/mir/mir-gen-stub.c +++ b/mir/mir-gen-stub.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . Stub for MIR generator machine dependent file. It contains definitions used by MIR generator. You can use this file for diff --git a/mir/mir-gen-x86_64.c b/mir/mir-gen-x86_64.c index f338f56e..d70e8e62 100644 --- a/mir/mir-gen-x86_64.c +++ b/mir/mir-gen-x86_64.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #include diff --git a/mir/mir-gen.c b/mir/mir-gen.c index b5272bc1..022bacdd 100644 --- a/mir/mir-gen.c +++ b/mir/mir-gen.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* Optimization pipeline: @@ -2172,6 +2172,12 @@ static int op_eq (gen_ctx_t gen_ctx, MIR_op_t op1, MIR_op_t op2) { return MIR_op_eq_p (gen_ctx->ctx, op1, op2); } +static int multi_out_insn_p (MIR_insn_t insn) { + if (!MIR_call_code_p (insn->code)) return FALSE; + gen_assert (insn->ops[0].u.ref->item_type == MIR_proto_item); + return insn->ops[0].u.ref->u.proto->nres > 1; +} + static int expr_eq (expr_t e1, expr_t e2, void *arg) { gen_ctx_t gen_ctx = arg; MIR_context_t ctx = gen_ctx->ctx; @@ -2191,7 +2197,10 @@ static int expr_eq (expr_t e1, expr_t e2, void *arg) { ssa_edge1 = insn1->ops[i].data; ssa_edge2 = insn2->ops[i].data; if (ssa_edge1 != NULL && ssa_edge2 != NULL - && ssa_edge1->def->gvn_val != ssa_edge2->def->gvn_val) + && (ssa_edge1->def->gvn_val != ssa_edge2->def->gvn_val + /* we can not be sure what defition we use in multi-output insn: */ + || multi_out_insn_p (ssa_edge1->def->insn) + || multi_out_insn_p (ssa_edge2->def->insn))) return FALSE; } return TRUE; diff --git a/mir/mir-gen.h b/mir/mir-gen.h index 77b251d1..a1fca94b 100644 --- a/mir/mir-gen.h +++ b/mir/mir-gen.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #ifndef MIR_GEN_H diff --git a/mir/mir-hash.h b/mir/mir-hash.h index aebd5cc2..6ce7d97f 100644 --- a/mir/mir-hash.h +++ b/mir/mir-hash.h @@ -1,6 +1,6 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* Simple high-quality multiplicative hash passing demerphq-smhasher, diff --git a/mir/mir-htab.h b/mir/mir-htab.h index 62587228..abd914a1 100644 --- a/mir/mir-htab.h +++ b/mir/mir-htab.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #ifndef MIR_HTAB_H diff --git a/mir/mir-interp.c b/mir/mir-interp.c index d3860515..7b5a38e4 100644 --- a/mir/mir-interp.c +++ b/mir/mir-interp.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . File contains MIR interpreter which is an obligatory part of MIR API. */ diff --git a/mir/mir-ppc64.c b/mir/mir-ppc64.c index 6f74a904..b601686d 100644 --- a/mir/mir-ppc64.c +++ b/mir/mir-ppc64.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* All BLK type values is passed in int regs, and if the regs are not enough, the rest is passed on diff --git a/mir/mir-reduce.h b/mir/mir-reduce.h index df07da46..fe7daa03 100644 --- a/mir/mir-reduce.h +++ b/mir/mir-reduce.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #ifndef MIR_REDUCE_H diff --git a/mir/mir-riscv64.c b/mir/mir-riscv64.c index e3b08f50..df328bd8 100644 --- a/mir/mir-riscv64.c +++ b/mir/mir-riscv64.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* x0 (zero) - always zero; x1 (ra) - link reg; x2 (sp) - sp, x3 (gp) - global pointer, x4 (tp) - diff --git a/mir/mir-s390x.c b/mir/mir-s390x.c index 7c5f547d..6230cfaf 100644 --- a/mir/mir-s390x.c +++ b/mir/mir-s390x.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* Long doubles (-mlong-double=128) are always passed by its address (for args and results) */ diff --git a/mir/mir-varr.h b/mir/mir-varr.h index 0402d818..051a09fd 100644 --- a/mir/mir-varr.h +++ b/mir/mir-varr.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #ifndef MIR_VARR_H diff --git a/mir/mir-x86_64.c b/mir/mir-x86_64.c index 951d95ce..86664ec0 100644 --- a/mir/mir-x86_64.c +++ b/mir/mir-x86_64.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ /* RBLK args are always passed by address. diff --git a/mir/mir.c b/mir/mir.c index 39f078ec..033f7dd8 100644 --- a/mir/mir.c +++ b/mir/mir.c @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #include "mir.h" @@ -415,7 +415,7 @@ typedef struct func_regs { VARR (reg_desc_t) * reg_descs; HTAB (size_t) * name2rdn_tab; HTAB (size_t) * reg2rdn_tab; -} * func_regs_t; +} *func_regs_t; static int name2rdn_eq (size_t rdn1, size_t rdn2, void *arg) { func_regs_t func_regs = arg; @@ -2014,7 +2014,7 @@ static MIR_insn_t create_label (MIR_context_t ctx, int64_t label_num) { MIR_insn_t MIR_new_label (MIR_context_t ctx) { return create_label (ctx, ++curr_label_num); } -MIR_reg_t _MIR_new_temp_reg (MIR_context_t ctx, MIR_type_t type, MIR_func_t func) { +static MIR_reg_t new_temp_reg (MIR_context_t ctx, MIR_type_t type, MIR_func_t func) { char reg_name[30]; if (type != MIR_T_I64 && type != MIR_T_F && type != MIR_T_D && type != MIR_T_LD) @@ -2026,11 +2026,24 @@ MIR_reg_t _MIR_new_temp_reg (MIR_context_t ctx, MIR_type_t type, MIR_func_t func if (func->last_temp_num == 0) MIR_get_error_func (ctx) (MIR_unique_reg_error, "out of unique regs"); sprintf (reg_name, "%s%d", TEMP_REG_NAME_PREFIX, func->last_temp_num); + if (find_rd_by_name (ctx, reg_name, func) == NULL) return MIR_new_func_reg (ctx, func, type, reg_name); } } +MIR_reg_t _MIR_new_temp_reg (MIR_context_t ctx, MIR_type_t type, MIR_func_t func) { + MIR_reg_t temp; + + /* It can be used by generator in parallel from different processed + funcs in the same ctx and uses data, e.g. string tab, common for + ctx. So it should be thread safe. */ + if (mir_mutex_lock (&ctx_mutex)) parallel_error (ctx, "error in mutex lock"); + temp = new_temp_reg (ctx, type, func); + if (mir_mutex_unlock (&ctx_mutex)) parallel_error (ctx, "error in mutex unlock"); + return temp; +} + static reg_desc_t *get_func_rd_by_name (MIR_context_t ctx, const char *reg_name, MIR_func_t func) { reg_desc_t *rd; @@ -2784,7 +2797,7 @@ static MIR_reg_t vn_add_val (MIR_context_t ctx, MIR_func_t func, MIR_type_t type val.op1 = op1; val.op2 = op2; if (HTAB_DO (val_t, val_tab, val, HTAB_FIND, tab_val)) return tab_val.reg; - val.reg = _MIR_new_temp_reg (ctx, type, func); + val.reg = new_temp_reg (ctx, type, func); HTAB_DO (val_t, val_tab, val, HTAB_INSERT, tab_val); return val.reg; } @@ -3027,7 +3040,7 @@ static void make_one_ret (MIR_context_t ctx, MIR_item_t func_item) { : res_types[i] == MIR_T_D ? MIR_DMOV : res_types[i] == MIR_T_LD ? MIR_LDMOV : MIR_MOV); - ret_reg = _MIR_new_temp_reg (ctx, mov_code == MIR_MOV ? MIR_T_I64 : res_types[i], func); + ret_reg = new_temp_reg (ctx, mov_code == MIR_MOV ? MIR_T_I64 : res_types[i], func); ret_reg_op = MIR_new_reg_op (ctx, ret_reg); VARR_PUSH (MIR_op_t, ret_ops, ret_reg_op); } @@ -3183,12 +3196,12 @@ static int simplify_func (MIR_context_t ctx, MIR_item_t func_item, int mem_float if ((code == MIR_MOV || code == MIR_FMOV || code == MIR_DMOV || code == MIR_LDMOV) && insn->ops[0].mode == MIR_OP_MEM && insn->ops[1].mode == MIR_OP_MEM) { - temp_op = MIR_new_reg_op (ctx, _MIR_new_temp_reg (ctx, - code == MIR_MOV ? MIR_T_I64 - : code == MIR_FMOV ? MIR_T_F - : code == MIR_DMOV ? MIR_T_D - : MIR_T_LD, - func)); + temp_op = MIR_new_reg_op (ctx, new_temp_reg (ctx, + code == MIR_MOV ? MIR_T_I64 + : code == MIR_FMOV ? MIR_T_F + : code == MIR_DMOV ? MIR_T_D + : MIR_T_LD, + func)); MIR_insert_insn_after (ctx, func_item, insn, MIR_new_insn (ctx, code, insn->ops[0], temp_op)); insn->ops[0] = temp_op; } @@ -3361,18 +3374,18 @@ static long add_blk_move (MIR_context_t ctx, MIR_item_t func_item, MIR_insn_t be MIR_func_t func = func_item->u.func; size_t blk_size = (src_size + 7) / 8 * 8; MIR_insn_t insn; - MIR_op_t size = MIR_new_reg_op (ctx, _MIR_new_temp_reg (ctx, MIR_T_I64, func)); + MIR_op_t size = MIR_new_reg_op (ctx, new_temp_reg (ctx, MIR_T_I64, func)); insn = MIR_new_insn (ctx, MIR_MOV, size, MIR_new_int_op (ctx, blk_size)); MIR_insert_insn_before (ctx, func_item, before, insn); insn = MIR_new_insn (ctx, MIR_ALLOCA, dest, size); MIR_insert_insn_before (ctx, func_item, before, insn); if (blk_size != 0) { - MIR_reg_t addr_reg = _MIR_new_temp_reg (ctx, MIR_T_I64, func); + MIR_reg_t addr_reg = new_temp_reg (ctx, MIR_T_I64, func); MIR_op_t addr = MIR_new_reg_op (ctx, addr_reg); - MIR_op_t disp = MIR_new_reg_op (ctx, _MIR_new_temp_reg (ctx, MIR_T_I64, func)); - MIR_op_t step = MIR_new_reg_op (ctx, _MIR_new_temp_reg (ctx, MIR_T_I64, func)); - MIR_op_t temp = MIR_new_reg_op (ctx, _MIR_new_temp_reg (ctx, MIR_T_I64, func)); + MIR_op_t disp = MIR_new_reg_op (ctx, new_temp_reg (ctx, MIR_T_I64, func)); + MIR_op_t step = MIR_new_reg_op (ctx, new_temp_reg (ctx, MIR_T_I64, func)); + MIR_op_t temp = MIR_new_reg_op (ctx, new_temp_reg (ctx, MIR_T_I64, func)); MIR_label_t loop = create_label (ctx, label_num++), skip = create_label (ctx, label_num++); insn = MIR_new_insn (ctx, MIR_MOV, disp, MIR_new_int_op (ctx, 0)); @@ -3403,13 +3416,13 @@ static long add_blk_move (MIR_context_t ctx, MIR_item_t func_item, MIR_insn_t be extensions and one return. */ static void process_inlines (MIR_context_t ctx, MIR_item_t func_item) { int non_top_alloca_p; - int64_t alloca_size, alloca_align, max_func_top_alloca_align; + int64_t alloca_size = 0, alloca_align, max_func_top_alloca_align; int64_t init_func_top_alloca_size, curr_func_top_alloca_size, max_func_top_alloca_size; size_t i, actual_nops, nargs, nvars; MIR_type_t type, *res_types; MIR_var_t var; MIR_reg_t ret_reg, old_reg, new_reg, temp_reg; - MIR_insn_t func_top_alloca, called_func_top_alloca, new_called_func_top_alloca; + MIR_insn_t func_top_alloca, called_func_top_alloca, new_called_func_top_alloca = NULL; MIR_insn_t func_insn, head_func_insn, next_func_insn; MIR_insn_t call, insn, prev_insn, new_insn, ret_insn, anchor; MIR_item_t called_func_item; @@ -3570,7 +3583,7 @@ static void process_inlines (MIR_context_t ctx, MIR_item_t func_item) { } redirect_duplicated_labels (ctx, labels, temp_insns); if (non_top_alloca_p) { - temp_reg = _MIR_new_temp_reg (ctx, MIR_T_I64, func); + temp_reg = new_temp_reg (ctx, MIR_T_I64, func); new_insn = MIR_new_insn (ctx, MIR_BSTART, MIR_new_reg_op (ctx, temp_reg)); MIR_insert_insn_after (ctx, func_item, call, new_insn); new_insn = MIR_new_insn (ctx, MIR_BEND, MIR_new_reg_op (ctx, temp_reg)); @@ -3579,7 +3592,7 @@ static void process_inlines (MIR_context_t ctx, MIR_item_t func_item) { if (called_func_top_alloca != NULL) { // ???? at the ret: curr_func_top_alloca_size -= alloca_size; if (func_top_alloca == NULL) { - temp_reg = _MIR_new_temp_reg (ctx, MIR_T_I64, func); + temp_reg = new_temp_reg (ctx, MIR_T_I64, func); func_top_alloca = MIR_new_insn (ctx, MIR_ALLOCA, new_called_func_top_alloca->ops[0], MIR_new_reg_op (ctx, temp_reg)); if (head_func_insn->code != MIR_LABEL) @@ -3591,7 +3604,7 @@ static void process_inlines (MIR_context_t ctx, MIR_item_t func_item) { = MIR_new_insn (ctx, MIR_MOV, MIR_new_reg_op (ctx, temp_reg), MIR_new_int_op (ctx, 0)); MIR_insert_insn_before (ctx, func_item, func_top_alloca, new_insn); } - temp_reg = _MIR_new_temp_reg (ctx, MIR_T_I64, func); + temp_reg = new_temp_reg (ctx, MIR_T_I64, func); new_insn = MIR_new_insn (ctx, MIR_PTR32 ? MIR_ADDS : MIR_ADD, new_called_func_top_alloca->ops[0], func_top_alloca->ops[0], MIR_new_reg_op (ctx, temp_reg)); @@ -3606,7 +3619,7 @@ static void process_inlines (MIR_context_t ctx, MIR_item_t func_item) { : DLIST_NEXT (MIR_insn_t, prev_insn)); } if (func_top_alloca != NULL && max_func_top_alloca_size != init_func_top_alloca_size) { - temp_reg = _MIR_new_temp_reg (ctx, MIR_T_I64, func); + temp_reg = new_temp_reg (ctx, MIR_T_I64, func); new_insn = MIR_new_insn (ctx, MIR_MOV, MIR_new_reg_op (ctx, temp_reg), MIR_new_int_op (ctx, max_func_top_alloca_size)); func_top_alloca->ops[1] = MIR_new_reg_op (ctx, temp_reg); @@ -4476,7 +4489,8 @@ static size_t reduce_writer (const void *start, size_t len, void *aux_data) { void MIR_write_module_with_func (MIR_context_t ctx, int (*const writer) (MIR_context_t, uint8_t), MIR_module_t module) { - size_t len, str_len; + size_t MIR_UNUSED len; + size_t str_len; io_writer = writer; #ifndef MIR_NO_BIN_COMPRESSION @@ -4986,7 +5000,6 @@ void MIR_read_with_func (MIR_context_t ctx, int (*const reader) (MIR_context_t)) MIR_new_expr_data (ctx, name, item); } else if (strcmp (name, "ndata") == 0 || strcmp (name, "data") == 0) { MIR_type_t type; - size_t nel; union { uint8_t u8; uint16_t u16; @@ -5007,7 +5020,7 @@ void MIR_read_with_func (MIR_context_t ctx, int (*const reader) (MIR_context_t)) MIR_get_error_func (ctx) (MIR_binary_io_error, "wrong data type tag %d", tag); type = tag_type (tag); VARR_TRUNC (uint8_t, temp_data, 0); - for (nel = 0;; nel++) { + for (;;) { tag = read_token (ctx, &attr); if (tag == TAG_EOI) break; switch (tag) { diff --git a/mir/mir.h b/mir/mir.h index f1f57c0c..820397b0 100644 --- a/mir/mir.h +++ b/mir/mir.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov . + Copyright (C) 2018-2023 Vladimir Makarov . */ #ifndef MIR_H diff --git a/mir/real-time.h b/mir/real-time.h index aefb64ce..620a196f 100644 --- a/mir/real-time.h +++ b/mir/real-time.h @@ -1,5 +1,5 @@ /* This file is a part of MIR project. - Copyright (C) 2018-2021 Vladimir Makarov and logzero + Copyright (C) 2018-2023 Vladimir Makarov and logzero */ #ifndef _WIN32