From b9b8490dd47b0cef290e045cdb662bef49818bb8 Mon Sep 17 00:00:00 2001 From: Alexander Nutz Date: Wed, 25 Sep 2024 15:11:48 +0200 Subject: [PATCH] c --- build.sh | 6 ++++-- cg/x86_stupid/cg.c | 2 -- ir/opt/constant_eval.c | 2 +- ir/opt/inline_vars.c | 2 +- ir/opt/ll_sched.c | 5 ----- ir/transform/ssair_llir_lower.c | 3 --- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/build.sh b/build.sh index 46872e9..5b49bed 100755 --- a/build.sh +++ b/build.sh @@ -8,11 +8,13 @@ if [ -z $EMPATH ]; then : ${CC:=clang} : ${BUILD_CC:=$CC} : ${EX_CFLAGS:=""} + : ${EX_LDFLAGS:=""} : ${AR:="ar"} else : ${CC:=$EMPATH/emcc} : ${BUILD_CC:=clang} : ${EX_CFLAGS:="-O3"} + : ${EX_LDFLAGS:=""} : ${AR:=$EMPATH/emar} fi @@ -59,7 +61,7 @@ function prepare() { echo "# found python at: $python" $python -m pip install generic-lexer &>/dev/null echo "# pip generic-lexer installed" - $BUILD_CC build.c -lpthread -DVERBOSE=1 -DPYTHON="\"$python\"" -DCC="\"$CC\"" -DCC_ARGS="\"$CFLAGS\"" -DAR="\"$AR\"" -o build.exe + $BUILD_CC build.c -lpthread -DVERBOSE=1 -DPYTHON="\"$python\"" -DCC="\"$CC\"" -DCC_ARGS="\"$CFLAGS\"" -DLD_ARGS="\"$EX_LDFLAGS\"" -DAR="\"$AR\"" -o build.exe echo "# build.exe compiled" echo "# gen cdef files" ./build.exe gen @@ -91,7 +93,7 @@ elif [[ $1 == "build" ]]; then ./build.exe lib.a else echo "invalid arguments; usage: ./build.sh [ganalyze|analyze|build]" - echo "you can set CC, CFLAGS, BUILD_CC, python, EX_CFLAGS, AR" + echo "you can set CC, CFLAGS, BUILD_CC, python, EX_CFLAGS, AR, EX_LDFLAGS" echo "if you set EMPATH, these flags get added automatically (you can overwrite them manually): CC=\$EMPATH/emcc BUILD_CC=clang EX_CFLAGS="-O3" AR=\$EMPATH/emar" fi diff --git a/cg/x86_stupid/cg.c b/cg/x86_stupid/cg.c index 33d5e72..ddbd6e2 100644 --- a/cg/x86_stupid/cg.c +++ b/cg/x86_stupid/cg.c @@ -1330,8 +1330,6 @@ vx_cg_x86stupid vx_cg_x86stupid_options = (vx_cg_x86stupid) { }; void vx_cg_x86stupid_gen(vx_IrBlock* block, FILE* out) { - vx_IrBlock_dump(block, stdout, 0); - fprintf(out, "%s:\n", block->name); assert(block->is_root); diff --git a/ir/opt/constant_eval.c b/ir/opt/constant_eval.c index 29aaf3c..cc4f6d7 100644 --- a/ir/opt/constant_eval.c +++ b/ir/opt/constant_eval.c @@ -23,7 +23,7 @@ void vx_opt_constant_eval(vx_IrBlock *block) vx_IrOp_removeParams(op); \ vx_IrOp_addParam_s(op, VX_IR_NAME_VALUE, (vx_IrValue) { \ .type = VX_IR_VAL_IMM_FLT, \ - .imm_flt = ((typedest) a->imm_flt) + ((typedest) b->imm_flt) \ + .imm_flt = ((typedest) a->imm_flt) what ((typedest) b->imm_flt) \ }); \ } \ } diff --git a/ir/opt/inline_vars.c b/ir/opt/inline_vars.c index fae718e..6c684f9 100644 --- a/ir/opt/inline_vars.c +++ b/ir/opt/inline_vars.c @@ -32,7 +32,7 @@ static bool vx_IrView_substitute_var__trav(vx_IrOp *op, void *dataIn) { } } - if (op->id != VX_IR_OP_PLACE) + if (op->id != VX_IR_OP_PLACE && op->id != VX_IR_OP_RETURN) for (size_t i = 0; i < op->params_len; i ++) if (op->params[i].val.type == VX_IR_VAL_VAR && op->params[i].val.var == data->old) op->params[i].val = data->new; diff --git a/ir/opt/ll_sched.c b/ir/opt/ll_sched.c index 8b559dc..72de819 100644 --- a/ir/opt/ll_sched.c +++ b/ir/opt/ll_sched.c @@ -57,8 +57,6 @@ static void runSched(vx_IrBlock* block, struct Move **to_move, size_t *to_move_l void vx_opt_ll_sched(vx_IrBlock *block) { assert(block->is_root); - vx_IrBlock_dump(block, stdout, 0); - struct Move* to_move = NULL; size_t to_move_len = 0; @@ -87,7 +85,4 @@ void vx_opt_ll_sched(vx_IrBlock *block) { } free(to_move); - - vx_IrBlock_dump(block, stdout, 0); - } diff --git a/ir/transform/ssair_llir_lower.c b/ir/transform/ssair_llir_lower.c index 0ea3b6b..8a59e3b 100644 --- a/ir/transform/ssair_llir_lower.c +++ b/ir/transform/ssair_llir_lower.c @@ -72,9 +72,6 @@ static void into(vx_IrBlock *src, vx_IrOp *parent, vx_IrBlock *dest, size_t cont } static void lower_into(vx_IrBlock *old, vx_IrBlock *dest, vx_IrBlock *newParent, size_t continueLabel, size_t breakLabel, vx_IrOp* loopOP) { - // TODO: remove - vx_IrBlock_dump(old, stdout, 0); - for (vx_IrOp *op = old->first; op; op = op->next) { op->parent = newParent;