Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
Signed-off-by: Shaw Summa <[email protected]>
  • Loading branch information
ShawSumma committed Mar 5, 2024
1 parent c0e5e5d commit a1af7b6
Show file tree
Hide file tree
Showing 29 changed files with 35,298 additions and 26,644 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=lf
33 changes: 0 additions & 33 deletions main/env.lua

This file was deleted.

23 changes: 21 additions & 2 deletions main/minivm.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main(int argc, char **argv) {
.target = VM_TARGET_TB_EMCC,
#else
.use_tb_opt = false,
.use_num = VM_USE_NUM_I64,
.use_num = VM_USE_NUM_F64,
.target = VM_TARGET_TB,
#endif
};
Expand Down Expand Up @@ -90,6 +90,25 @@ int main(int argc, char **argv) {
} else if (!strcmp(arg, "--repl")) {
vm_lang_lua_repl(config, std, blocks);
isrepl = false;
} else if (!strncmp(arg, "--tb-", 5)) {
arg += 5;
bool enable = true;
if (!strncmp(arg, "no-", 3)) {
arg += 3;
enable = false;
}
if (!strcmp(arg, "recompile")) {
config->tb_recompile = enable;
} else if (!strcmp(arg, "cast-regs")) {
config->tb_regs_cast = enable;
} else if (!strcmp(arg, "raw-regs")) {
config->tb_regs_node = enable;
} else if (!strcmp(arg, "force-bitcast")) {
config->tb_force_bitcast = enable;
} else {
fprintf(stderr, "error: unknown flag --tb-%s want --tb-recompile, --tb-cast-regs, or --tb-raw-regs", arg);
return 1;
}
} else if (!strncmp(arg, "--number=", 9)) {
arg += 9;
if (!strcmp(arg, "i8")) {
Expand All @@ -105,7 +124,7 @@ int main(int argc, char **argv) {
} else if (!strcmp(arg, "f64")) {
config->use_num = VM_USE_NUM_F64;
} else {
fprintf(stderr, "cannot use have as a number type: %s\n", arg);
fprintf(stderr, "error: cannot use have as a number type: %s\n", arg);
return 1;
}
} else if (!strncmp(arg, "--target-", 9) || !strncmp(arg, "--target=", 9)) {
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ VM_SRCS = vm/ir/ir.c vm/lib.c vm/ir/type.c vm/ast/build.c vm/ast/ast.c vm/ast/co
ALL_SRCS = $(VM_SRCS) $(STD_SRCS) $(EXTRA_SRCS) $(TREES_SRCS)
ALL_OBJS = $(ALL_SRCS:%.c=$(OBJ_DIR)/%.o)

TCC_SRCS ?= vendor/tcc/libtcc.c
TCC_SRCS ?= vendor/tcc/libtcc.c vendor/tcc/lib/libtcc1.c
TCC_OBJS = $(TCC_SRCS:%.c=$(OBJ_DIR)/%.o)

TB_SRCS = vendor/common/common.c vendor/common/perf.c vendor/tb/src/libtb.c vendor/tb/src/x64/x64_target.c
Expand Down
2 changes: 1 addition & 1 deletion test/loop/primes5.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

local count = 1
local max = 1000000
local max = 10000000
local pprime = 3
while pprime < max do
local check = 3
Expand Down
32 changes: 32 additions & 0 deletions test/tables/trees_no_loop.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local function BottomUpTree(item, depth)
if depth > 0 then
local i = item + item
depth = depth - 1
local left = BottomUpTree(i - 1, depth)
local right = BottomUpTree(i, depth)
return {item, left, right}
else
return {item}
end
end

local function ItemCheck(tree)
if #tree == 3 then
return tree[1] + ItemCheck(tree[2]) - ItemCheck(tree[3])
else
return tree[1]
end
end

local function more(pow)
if pow == 0 then
return ItemCheck(BottomUpTree(0, 12))
else
local next = pow - 1
local a = more(next)
local b = more(next)
return a + b
end
end

print(more(1))
Loading

0 comments on commit a1af7b6

Please sign in to comment.