diff --git a/build.sh b/build.sh index 2595e81..7e58c3e 100755 --- a/build.sh +++ b/build.sh @@ -70,7 +70,10 @@ function prepare() { else SERIAL_ARGS="-lpthread" fi - $BUILD_CC build.c $SERIAL_ARGS $CFLAGS -DVERBOSE=1 -DCC="\"$CC\"" -DCC_ARGS="\"$CFLAGS\"" -DLD_ARGS="\"$EX_LDFLAGS $SERIAL_ARGS\"" -DAR="\"$AR\"" -o build.exe + cd build_c/slowdb + ./build.sh + cd ../../ + $BUILD_CC build.c build_c/slowdb/build/slowdb.a $SERIAL_ARGS $CFLAGS -DVERBOSE=1 -DCC="\"$CC\"" -DCC_ARGS="\"$CFLAGS\"" -DLD_ARGS="\"$EX_LDFLAGS $SERIAL_ARGS\"" -DAR="\"$AR\"" -o build.exe echo "# build.exe compiled" echo "# gen cdef files" ./build.exe gen diff --git a/build_c b/build_c index fea71b3..6cb2f77 160000 --- a/build_c +++ b/build_c @@ -1 +1 @@ -Subproject commit fea71b3b30f11158e6337ee7d5307ed0b74874c6 +Subproject commit 6cb2f77d546c5f0432be3da9a84e4dad923b8f9f diff --git a/targets/etca/etca.c b/targets/etca/etca.c index 8de228f..e6825da 100644 --- a/targets/etca/etca.c +++ b/targets/etca/etca.c @@ -11,7 +11,7 @@ static bool etca_need_move_ret_to_arg(vx_CU* cu, vx_IrBlock* block, size_t ret_i return ret_id >= 1; } -void vx_Target_X86__info(vx_TargetInfo* dest, vx_Target const* target) +void vx_Target_ETCA__info(vx_TargetInfo* dest, vx_Target const* target) { set_tg(etca); dest->cmov_opt = target->flags.etca[vx_Target_ETCA_condExec]; diff --git a/targets/targets.c b/targets/targets.c index 9543dc8..dcb2ee3 100644 --- a/targets/targets.c +++ b/targets/targets.c @@ -91,7 +91,7 @@ TARGET_FLAGS_GEN(X86) #undef TARGET_FLAGS_GEN -#include "x86/cg.h" +#include "x86/x86.h" // add target void vx_llir_emit_asm(vx_CU* cu, vx_IrBlock* llirblock, FILE* out) diff --git a/targets/x86/cg.c b/targets/x86/cg.c index ac0d32e..c72c1c6 100644 --- a/targets/x86/cg.c +++ b/targets/x86/cg.c @@ -650,7 +650,6 @@ static size_t XMM_SCRATCH_REG2; typedef struct { vx_IrType* type; Location* location; - size_t heat; // if heat == 2 then one producer and one consumer } VarData; VarData* varData = NULL; @@ -1439,35 +1438,11 @@ void vx_cg_x86stupid_gen(vx_CU* _cu, vx_IrBlock* _block, FILE* out) { availableRegistersCount += extraAv; } - // TODO: count heat in SSA instead (bc of loops) - varData = block->as_root.vars_len == 0 ? NULL : calloc(block->as_root.vars_len, sizeof(VarData)); for (size_t i = 0; i < block->ins_len; i ++) { assert(varData); varData[block->ins[i].var].type = block->ins[i].type; } - for (vx_IrOp *op = block->first; op != NULL; op = op->next) { - for (size_t i = 0; i < op->outs_len; i ++) { - assert(varData); - vx_IrVar v = op->outs[i].var; - varData[v].type = op->outs[i].type; - varData[v].heat ++; - } - for (size_t i = 0; i < op->args_len; i ++) { - vx_IrValue val = op->args[i]; - if (val.type == VX_IR_VAL_VAR) { - assert(varData); - varData[val.var].heat ++; - } - } - for (size_t i = 0; i < op->params_len; i ++) { - vx_IrValue val = op->params[i].val; - if (val.type == VX_IR_VAL_VAR) { - assert(varData); - varData[val.var].heat ++; - } - } - } size_t stackOff = 0; @@ -1475,7 +1450,9 @@ void vx_cg_x86stupid_gen(vx_CU* _cu, vx_IrBlock* _block, FILE* out) { signed long long highestHeat = 0; for (vx_IrVar var = 0; var < block->as_root.vars_len; var ++) { assert(varData); - size_t heat = varData[var].heat; + size_t heat = block->as_root.vars[var].heat; + if (heat == 0) + fprintf(stderr, "warning: variable %%%zu has no heat\n", var); if (heat > highestHeat) { highestHeat = heat; } @@ -1496,7 +1473,7 @@ void vx_cg_x86stupid_gen(vx_CU* _cu, vx_IrBlock* _block, FILE* out) { for (vx_IrVar var = 0; var < block->as_root.vars_len; var ++) { if (varsSorted[var]) continue; - if (varData[var].heat == highestHeat) { + if (block->as_root.vars[var].heat == highestHeat) { varsHotFirst[varsHotFirstLen ++] = var; varsSorted[var] = true; } @@ -1514,7 +1491,7 @@ void vx_cg_x86stupid_gen(vx_CU* _cu, vx_IrBlock* _block, FILE* out) { vx_IrVar var = varsHotFirst[varId]; assert(varData); - if (varData[var].heat == 0) { + if (block->as_root.vars[var].heat == 0) { varData[var].location = NULL; continue; } @@ -1632,7 +1609,7 @@ void vx_cg_x86stupid_gen(vx_CU* _cu, vx_IrBlock* _block, FILE* out) { free(varsHotFirst); for (vx_IrVar var = 0; var < block->as_root.vars_len; var ++) { - if (varData[var].heat == 0) { + if (block->as_root.vars[var].heat == 0) { varData[var].location = NULL; continue; }