issue #169 Update MIR sources - includes a memory leak bug fix

pull/212/head
Dibyendu Majumdar 3 years ago
parent def4d76ac9
commit 773ebd9d32

@ -3,3 +3,5 @@ project. Following changes have been made:
* A CMake build script added to create a library * A CMake build script added to create a library
* Unused files / tests have been removed to avoid clutter * Unused files / tests have been removed to avoid clutter
Last update: 7th Jan 2021

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
aarch64 call ABI target specific code. aarch64 call ABI target specific code.
*/ */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include "../mirc.h" #include "../mirc.h"

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include <stdint.h> #include <stdint.h>

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 5.2.4.2.2 */ /* See C11 5.2.4.2.2 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See 5.2.4.2 */ /* See 5.2.4.2 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static char aarch64_mirc[] static char aarch64_mirc[]

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static char stdarg_str[] static char stdarg_str[]

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.19 */ /* See C11 7.19 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.20 */ /* See C11 7.20 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* C to MIR compiler. It is a four pass compiler: /* C to MIR compiler. It is a four pass compiler:

@ -1,3 +1,7 @@
/* This file is a part of MIR project.
Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/
#ifndef C2MIR_H #ifndef C2MIR_H
#define C2MIR_H #define C2MIR_H

@ -1,3 +1,7 @@
/* This file is a part of MIR project.
Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/
static const char mirc[] static const char mirc[]
= "#define __mirc__ 1\n" = "#define __mirc__ 1\n"
"#define __MIRC__ 1\n" "#define __MIRC__ 1\n"

@ -1,3 +1,7 @@
/* This file is a part of MIR project.
Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/
/* See C11 7.9 */ /* See C11 7.9 */
static char iso646_str[] static char iso646_str[]
= "#ifndef __ISO646_H\n" = "#ifndef __ISO646_H\n"

@ -1,3 +1,7 @@
/* This file is a part of MIR project.
Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/
/* See C11 7.15 */ /* See C11 7.15 */
static char stdalign_str[] static char stdalign_str[]
= "#ifndef __STDALIGN_H\n" = "#ifndef __STDALIGN_H\n"

@ -1,3 +1,7 @@
/* This file is a part of MIR project.
Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/
/* See C11 7.18 */ /* See C11 7.18 */
static char stdbool_str[] static char stdbool_str[]
= "#ifndef __STDBOOL_H\n" = "#ifndef __STDBOOL_H\n"

@ -1,3 +1,7 @@
/* This file is a part of MIR project.
Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/
/* See C11 7.23 */ /* See C11 7.23 */
static char stdnoreturn_str[] static char stdnoreturn_str[]
= "#ifndef __STDNORETURN_H\n" = "#ifndef __STDNORETURN_H\n"

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
ppc64 call ABI target specific code. ppc64 call ABI target specific code.
*/ */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include "../mirc.h" #include "../mirc.h"

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include <stdint.h> #include <stdint.h>

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 5.2.4.2.2 */ /* See C11 5.2.4.2.2 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See 5.2.4.2 */ /* See 5.2.4.2 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static char ppc64_mirc[] static char ppc64_mirc[]
@ -15,7 +15,7 @@ static char ppc64_mirc[]
"#define _CALL_ELF 2\n" "#define _CALL_ELF 2\n"
#endif #endif
"\n" "\n"
"#define __LONG_DOUBLE_128__ 1\n" // ??? "#define __LONG_DOUBLE_128__ 1\n" // ???
"#define __SIZEOF_DOUBLE__ 8\n" "#define __SIZEOF_DOUBLE__ 8\n"
"#define __SIZEOF_FLOAT__ 4\n" "#define __SIZEOF_FLOAT__ 4\n"
"#define __SIZEOF_INT__ 4\n" "#define __SIZEOF_INT__ 4\n"

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static char stdarg_str[] static char stdarg_str[]

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.19 */ /* See C11 7.19 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.20 */ /* See C11 7.20 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
s390x call ABI target specific code. s390x call ABI target specific code.
*/ */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include "../mirc.h" #include "../mirc.h"

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include <stdint.h> #include <stdint.h>

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 5.2.4.2.2 */ /* See C11 5.2.4.2.2 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See 5.2.4.2 */ /* See 5.2.4.2 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static char s390x_mirc[] static char s390x_mirc[]
@ -11,7 +11,7 @@ static char s390x_mirc[]
"#define __ELF__ 1\n" "#define __ELF__ 1\n"
"\n" "\n"
#if __SIZEOF_LONG_DOUBLE__ == 16 #if __SIZEOF_LONG_DOUBLE__ == 16
"#define __LONG_DOUBLE_128__ 1\n" // ??? "#define __LONG_DOUBLE_128__ 1\n" // ???
"#define __SIZEOF_LONG_DOUBLE__ 16\n" "#define __SIZEOF_LONG_DOUBLE__ 16\n"
#else #else
"#define __SIZEOF_LONG_DOUBLE__ 8\n" "#define __SIZEOF_LONG_DOUBLE__ 8\n"

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static char stdarg_str[] static char stdarg_str[]

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.19 */ /* See C11 7.19 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.20 */ /* See C11 7.20 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
x86_64 ABI target specific code. x86_64 ABI target specific code.
*/ */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include "../mirc.h" #include "../mirc.h"

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include <stdint.h> #include <stdint.h>

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2019-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2019-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 5.2.4.2.2 */ /* See C11 5.2.4.2.2 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2019-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2019-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See 5.2.4.2 */ /* See 5.2.4.2 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2019-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2019-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static char x86_64_mirc[] static char x86_64_mirc[]

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2019-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2019-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.16 and https://www.uclibc.org/docs/psABI-x86_64.pdf */ /* See C11 7.16 and https://www.uclibc.org/docs/psABI-x86_64.pdf */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2019-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2019-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.19 */ /* See C11 7.19 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2019-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2019-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* See C11 7.20 */ /* See C11 7.20 */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2019-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2019-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static char x86_64_mirc[] static char x86_64_mirc[]

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#define VA_LIST_IS_ARRAY_P 0 #define VA_LIST_IS_ARRAY_P 0

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#ifndef MIR_BITMAP_H #ifndef MIR_BITMAP_H

@ -1,5 +1,5 @@
/* This file is part of MIR project. /* This file is part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* Typed doubly linked lists. */ /* Typed doubly linked lists. */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
static void fancy_abort (int code) { static void fancy_abort (int code) {
@ -800,9 +800,9 @@ static void target_machinize (gen_ctx_t gen_ctx) {
} }
if ((nargs = get_builtin (gen_ctx, code, &proto_item, &func_import_item)) > 0) { if ((nargs = get_builtin (gen_ctx, code, &proto_item, &func_import_item)) > 0) {
if (code == MIR_VA_ARG || code == MIR_VA_BLOCK_ARG) { if (code == MIR_VA_ARG || code == MIR_VA_BLOCK_ARG) {
/* Use a builtin func call: /* Use a builtin func call:
mov func_reg, func ref; [mov reg3, type;] call proto, func_reg, res_reg, va_reg, mov func_reg, func ref; [mov reg3, type;] call proto, func_reg, res_reg, va_reg,
reg3 */ reg3 */
MIR_op_t ops[6], func_reg_op, reg_op3; MIR_op_t ops[6], func_reg_op, reg_op3;
MIR_op_t res_reg_op = insn->ops[0], va_reg_op = insn->ops[1], op3 = insn->ops[2]; MIR_op_t res_reg_op = insn->ops[0], va_reg_op = insn->ops[1], op3 = insn->ops[2];
@ -813,18 +813,18 @@ static void target_machinize (gen_ctx_t gen_ctx) {
next_insn = new_insn next_insn = new_insn
= MIR_new_insn (ctx, MIR_MOV, func_reg_op, MIR_new_ref_op (ctx, func_import_item)); = MIR_new_insn (ctx, MIR_MOV, func_reg_op, MIR_new_ref_op (ctx, func_import_item));
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
if (code == MIR_VA_ARG) { if (code == MIR_VA_ARG) {
new_insn = MIR_new_insn (ctx, MIR_MOV, reg_op3, new_insn
MIR_new_int_op (ctx, (int64_t) op3.u.mem.type)); = MIR_new_insn (ctx, MIR_MOV, reg_op3, MIR_new_int_op (ctx, (int64_t) op3.u.mem.type));
op3 = reg_op3; op3 = reg_op3;
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
} }
ops[0] = MIR_new_ref_op (ctx, proto_item); ops[0] = MIR_new_ref_op (ctx, proto_item);
ops[1] = func_reg_op; ops[1] = func_reg_op;
ops[2] = res_reg_op; ops[2] = res_reg_op;
ops[3] = va_reg_op; ops[3] = va_reg_op;
ops[4] = op3; ops[4] = op3;
if (code == MIR_VA_BLOCK_ARG) ops[5] = insn->ops[3]; if (code == MIR_VA_BLOCK_ARG) ops[5] = insn->ops[3];
new_insn = MIR_new_insn_arr (ctx, MIR_CALL, code == MIR_VA_ARG ? 5 : 6, ops); new_insn = MIR_new_insn_arr (ctx, MIR_CALL, code == MIR_VA_ARG ? 5 : 6, ops);
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
gen_delete_insn (gen_ctx, insn); gen_delete_insn (gen_ctx, insn);

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* We don't use TOC. So r2 is not necessary for the generated code. */ /* We don't use TOC. So r2 is not necessary for the generated code. */
@ -720,9 +720,9 @@ static void target_machinize (gen_ctx_t gen_ctx) {
} }
if ((nargs = get_builtin (gen_ctx, code, &proto_item, &func_import_item)) > 0) { if ((nargs = get_builtin (gen_ctx, code, &proto_item, &func_import_item)) > 0) {
if (code == MIR_VA_ARG || code == MIR_VA_BLOCK_ARG) { if (code == MIR_VA_ARG || code == MIR_VA_BLOCK_ARG) {
/* Use a builtin func call: /* Use a builtin func call:
mov func_reg, func ref; [mov reg3, type;] call proto, func_reg, res_reg, va_reg, mov func_reg, func ref; [mov reg3, type;] call proto, func_reg, res_reg, va_reg,
reg3 */ reg3 */
MIR_op_t ops[6], func_reg_op, reg_op3; MIR_op_t ops[6], func_reg_op, reg_op3;
MIR_op_t res_reg_op = insn->ops[0], va_reg_op = insn->ops[1], op3 = insn->ops[2]; MIR_op_t res_reg_op = insn->ops[0], va_reg_op = insn->ops[1], op3 = insn->ops[2];
@ -733,18 +733,18 @@ static void target_machinize (gen_ctx_t gen_ctx) {
next_insn = new_insn next_insn = new_insn
= MIR_new_insn (ctx, MIR_MOV, func_reg_op, MIR_new_ref_op (ctx, func_import_item)); = MIR_new_insn (ctx, MIR_MOV, func_reg_op, MIR_new_ref_op (ctx, func_import_item));
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
if (code == MIR_VA_ARG) { if (code == MIR_VA_ARG) {
new_insn = MIR_new_insn (ctx, MIR_MOV, reg_op3, new_insn
MIR_new_int_op (ctx, (int64_t) op3.u.mem.type)); = MIR_new_insn (ctx, MIR_MOV, reg_op3, MIR_new_int_op (ctx, (int64_t) op3.u.mem.type));
op3 = reg_op3; op3 = reg_op3;
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
} }
ops[0] = MIR_new_ref_op (ctx, proto_item); ops[0] = MIR_new_ref_op (ctx, proto_item);
ops[1] = func_reg_op; ops[1] = func_reg_op;
ops[2] = res_reg_op; ops[2] = res_reg_op;
ops[3] = va_reg_op; ops[3] = va_reg_op;
ops[4] = op3; ops[4] = op3;
if (code == MIR_VA_BLOCK_ARG) ops[5] = insn->ops[3]; if (code == MIR_VA_BLOCK_ARG) ops[5] = insn->ops[3];
new_insn = MIR_new_insn_arr (ctx, MIR_CALL, code == MIR_VA_ARG ? 5 : 6, ops); new_insn = MIR_new_insn_arr (ctx, MIR_CALL, code == MIR_VA_ARG ? 5 : 6, ops);
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
gen_delete_insn (gen_ctx, insn); gen_delete_insn (gen_ctx, insn);

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2020-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
// ??? More patterns (ult, ugt, ule, uge w/o branches, multi-insn combining). // ??? More patterns (ult, ugt, ule, uge w/o branches, multi-insn combining).
@ -766,9 +766,9 @@ static void target_machinize (gen_ctx_t gen_ctx) {
} }
if ((nargs = get_builtin (gen_ctx, code, &proto_item, &func_import_item)) > 0) { if ((nargs = get_builtin (gen_ctx, code, &proto_item, &func_import_item)) > 0) {
if (code == MIR_VA_ARG || code == MIR_VA_BLOCK_ARG) { if (code == MIR_VA_ARG || code == MIR_VA_BLOCK_ARG) {
/* Use a builtin func call: /* Use a builtin func call:
mov func_reg, func ref; [mov reg3, type;] call proto, func_reg, res_reg, va_reg, mov func_reg, func ref; [mov reg3, type;] call proto, func_reg, res_reg, va_reg,
reg3 */ reg3 */
MIR_op_t ops[6], func_reg_op, reg_op3; MIR_op_t ops[6], func_reg_op, reg_op3;
MIR_op_t res_reg_op = insn->ops[0], va_reg_op = insn->ops[1], op3 = insn->ops[2]; MIR_op_t res_reg_op = insn->ops[0], va_reg_op = insn->ops[1], op3 = insn->ops[2];
@ -779,18 +779,18 @@ static void target_machinize (gen_ctx_t gen_ctx) {
next_insn = new_insn next_insn = new_insn
= MIR_new_insn (ctx, MIR_MOV, func_reg_op, MIR_new_ref_op (ctx, func_import_item)); = MIR_new_insn (ctx, MIR_MOV, func_reg_op, MIR_new_ref_op (ctx, func_import_item));
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
if (code == MIR_VA_ARG) { if (code == MIR_VA_ARG) {
new_insn = MIR_new_insn (ctx, MIR_MOV, reg_op3, new_insn
MIR_new_int_op (ctx, (int64_t) op3.u.mem.type)); = MIR_new_insn (ctx, MIR_MOV, reg_op3, MIR_new_int_op (ctx, (int64_t) op3.u.mem.type));
op3 = reg_op3; op3 = reg_op3;
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
} }
ops[0] = MIR_new_ref_op (ctx, proto_item); ops[0] = MIR_new_ref_op (ctx, proto_item);
ops[1] = func_reg_op; ops[1] = func_reg_op;
ops[2] = res_reg_op; ops[2] = res_reg_op;
ops[3] = va_reg_op; ops[3] = va_reg_op;
ops[4] = op3; ops[4] = op3;
if (code == MIR_VA_BLOCK_ARG) ops[5] = insn->ops[3]; if (code == MIR_VA_BLOCK_ARG) ops[5] = insn->ops[3];
new_insn = MIR_new_insn_arr (ctx, MIR_CALL, code == MIR_VA_ARG ? 5 : 6, ops); new_insn = MIR_new_insn_arr (ctx, MIR_CALL, code == MIR_VA_ARG ? 5 : 6, ops);
gen_add_insn_before (gen_ctx, insn, new_insn); gen_add_insn_before (gen_ctx, insn, new_insn);
gen_delete_insn (gen_ctx, insn); gen_delete_insn (gen_ctx, insn);

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
Stub for MIR generator machine dependent file. It contains Stub for MIR generator machine dependent file. It contains
definitions used by MIR generator. You can use this file for definitions used by MIR generator. You can use this file for
@ -27,9 +27,9 @@ enum {
F7_HARD_REG F7_HARD_REG
}; };
static const MIR_reg_t MAX_HARD_REG = F7_HARD_REG; /* max value for the previous regs */ static const MIR_reg_t MAX_HARD_REG = F7_HARD_REG; /* max value for the previous regs */
static const MIR_reg_t FP_HARD_REG = R6_HARD_REG; /* stack frame pointer according ABI */ static const MIR_reg_t FP_HARD_REG = R6_HARD_REG; /* stack frame pointer according ABI */
static const MIR_reg_t SP_HARD_REG = R7_HARD_REG; /* stack pointer according ABI */ static const MIR_reg_t SP_HARD_REG = R7_HARD_REG; /* stack pointer according ABI */
const MIR_reg_t TEMP_INT_HARD_REG1 = R2_HARD_REG, TEMP_INT_HARD_REG2 = R3_HARD_REG; const MIR_reg_t TEMP_INT_HARD_REG1 = R2_HARD_REG, TEMP_INT_HARD_REG2 = R3_HARD_REG;
const MIR_reg_t TEMP_FLOAT_HARD_REG1 = F2_HARD_REG, TEMP_FLOAT_HARD_REG2 = F3_HARD_REG; const MIR_reg_t TEMP_FLOAT_HARD_REG1 = F2_HARD_REG, TEMP_FLOAT_HARD_REG2 = F3_HARD_REG;
@ -49,11 +49,11 @@ static inline int target_hard_reg_type_ok_p (MIR_reg_t hard_reg, MIR_type_t type
static inline int target_fixed_hard_reg_p (MIR_reg_t hard_reg) { static inline int target_fixed_hard_reg_p (MIR_reg_t hard_reg) {
assert (hard_reg <= MAX_HARD_REG); assert (hard_reg <= MAX_HARD_REG);
return (hard_reg == FP_HARD_REG || hard_reg == SP_HARD_REG return (hard_reg == FP_HARD_REG || hard_reg == SP_HARD_REG || hard_reg == TEMP_INT_HARD_REG1
|| hard_reg == TEMP_INT_HARD_REG1 || hard_reg == TEMP_INT_HARD_REG2 || hard_reg == TEMP_INT_HARD_REG2 || hard_reg == TEMP_FLOAT_HARD_REG1
|| hard_reg == TEMP_FLOAT_HARD_REG1 || hard_reg == TEMP_FLOAT_HARD_REG2 || hard_reg == TEMP_FLOAT_HARD_REG2 || hard_reg == TEMP_DOUBLE_HARD_REG1
|| hard_reg == TEMP_DOUBLE_HARD_REG1 || hard_reg == TEMP_DOUBLE_HARD_REG2 || hard_reg == TEMP_DOUBLE_HARD_REG2 || hard_reg == TEMP_LDOUBLE_HARD_REG1
|| hard_reg == TEMP_LDOUBLE_HARD_REG1 || hard_reg == TEMP_LDOUBLE_HARD_REG2); || hard_reg == TEMP_LDOUBLE_HARD_REG2);
} }
static inline int target_call_used_hard_reg_p (MIR_reg_t hard_reg) { static inline int target_call_used_hard_reg_p (MIR_reg_t hard_reg) {

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include <limits.h> #include <limits.h>

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* Optimization pipeline: /* Optimization pipeline:
@ -2433,6 +2433,7 @@ static ccp_val_t get_ccp_val (gen_ctx_t gen_ctx, bb_insn_t bb_insn) {
static void initiate_ccp_info (gen_ctx_t gen_ctx) { static void initiate_ccp_info (gen_ctx_t gen_ctx) {
bb_insn_t bb_insn; bb_insn_t bb_insn;
ccp_val_t ccp_val;
for (bb_t bb = DLIST_HEAD (bb_t, curr_cfg->bbs); bb != NULL; bb = DLIST_NEXT (bb_t, bb)) { for (bb_t bb = DLIST_HEAD (bb_t, curr_cfg->bbs); bb != NULL; bb = DLIST_NEXT (bb_t, bb)) {
if ((bb_insn = DLIST_TAIL (bb_insn_t, bb->bb_insns)) != NULL if ((bb_insn = DLIST_TAIL (bb_insn_t, bb->bb_insns)) != NULL
@ -2447,7 +2448,8 @@ static void initiate_ccp_info (gen_ctx_t gen_ctx) {
bitmap_clear (bb_visited); bitmap_clear (bb_visited);
VARR_TRUNC (bb_insn_t, ccp_insns, 0); VARR_TRUNC (bb_insn_t, ccp_insns, 0);
VARR_TRUNC (bb_t, ccp_bbs, 0); VARR_TRUNC (bb_t, ccp_bbs, 0);
VARR_TRUNC (ccp_val_t, ccp_vals, 0); while (VARR_LENGTH (ccp_val_t, ccp_vals) != 0)
if ((ccp_val = VARR_POP (ccp_val_t, ccp_vals)) != NULL) free (ccp_val);
VARR_PUSH (bb_t, ccp_bbs, DLIST_HEAD (bb_t, curr_cfg->bbs)); /* entry bb */ VARR_PUSH (bb_t, ccp_bbs, DLIST_HEAD (bb_t, curr_cfg->bbs)); /* entry bb */
} }

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#ifndef MIR_GEN_H #ifndef MIR_GEN_H

@ -1,6 +1,6 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* Simple high-quality multiplicative hash passing demerphq-smhsher, /* Simple high-quality multiplicative hash passing demerphq-smhsher,

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#ifndef MIR_HTAB_H #ifndef MIR_HTAB_H

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
File contains MIR interpreter which is an obligatory part of MIR API. File contains MIR interpreter which is an obligatory part of MIR API.
*/ */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* All BLK type values is passed in int regs, and if the regs are not enough, the rest is passed on /* All BLK type values is passed in int regs, and if the regs are not enough, the rest is passed on

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#ifndef MIR_REDUCE_H #ifndef MIR_REDUCE_H

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* Long doubles (-mlong-double=128) are always passed by its address (for args and results) */ /* Long doubles (-mlong-double=128) are always passed by its address (for args and results) */

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#ifndef MIR_VARR_H #ifndef MIR_VARR_H
@ -17,12 +17,12 @@
#define VARR_ASSERT(EXPR, OP, T) ((void) (EXPR)) #define VARR_ASSERT(EXPR, OP, T) ((void) (EXPR))
#else #else
static inline void mir_var_assert_fail (const char *op, const char *var) { static inline void mir_varr_assert_fail (const char *op, const char *var) {
fprintf (stderr, "wrong %s for %s", op, var); fprintf (stderr, "wrong %s for %s", op, var);
assert (0); assert (0);
} }
#define VARR_ASSERT(EXPR, OP, T) (void) ((EXPR) ? 0 : (mir_var_assert_fail (OP, #T), 0)) #define VARR_ASSERT(EXPR, OP, T) (void) ((EXPR) ? 0 : (mir_varr_assert_fail (OP, #T), 0))
#endif #endif
@ -102,12 +102,9 @@ static inline void MIR_VARR_NO_RETURN mir_varr_error (const char *message) {
return varr->varr[ix]; \ return varr->varr[ix]; \
} \ } \
\ \
static inline T VARR_OP_DEF (T, set) (const VARR (T) * varr, size_t ix, T obj) { \ static inline void VARR_OP_DEF (T, set) (const VARR (T) * varr, size_t ix, T obj) { \
T old_obj; \
VARR_ASSERT (varr && varr->varr && ix < varr->els_num, "set", T); \ VARR_ASSERT (varr && varr->varr && ix < varr->els_num, "set", T); \
old_obj = varr->varr[ix]; \
varr->varr[ix] = obj; \ varr->varr[ix] = obj; \
return old_obj; \
} \ } \
\ \
static inline void VARR_OP_DEF (T, trunc) (VARR (T) * varr, size_t size) { \ static inline void VARR_OP_DEF (T, trunc) (VARR (T) * varr, size_t size) { \

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
/* RBLK args are always passed by address. /* RBLK args are always passed by address.

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#include "mir.h" #include "mir.h"

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com>. Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/ */
#ifndef MIR_H #ifndef MIR_H

@ -1,5 +1,5 @@
/* This file is a part of MIR project. /* This file is a part of MIR project.
Copyright (C) 2018-2020 Vladimir Makarov <vmakarov.gcc@gmail.com> and logzero <core13@gmx.net> Copyright (C) 2018-2021 Vladimir Makarov <vmakarov.gcc@gmail.com> and logzero <core13@gmx.net>
*/ */
#ifndef _WIN32 #ifndef _WIN32

Loading…
Cancel
Save