commit 05e0c12594aa00c972ab8a241ff6d02e6d9b4329 Author: sam Date: Wed Jul 24 20:46:03 2024 +1200 first commit diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7e4fb37 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "libqbe"] + path = libqbe + url = https://git.samahh.dev/sam/libqbe +[submodule "slibs"] + path = slibs + url = https://git.samahh.dev/sam/slibs diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..9a0a2f5 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,19 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "macFrameworkPath": [ + "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "macos-clang-arm64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..091f376 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +BINARY=test + +CC=gcc +CFLAGS=-I. +LDFLAGS=-Llibqbe -lqbe + +CFILES=$(shell find -L src -type f -name '*.c') +OBJ=$(CFILES:.c=.o) + +$(BINARY): libqbe/libqbe.a $(OBJ) Makefile + $(CC) $(OBJ) $(LDFLAGS) -o $@ + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +run: $(BINARY) + ./$(BINARY) + +libqbe/libqbe.a: + make -C libqbe + +clean: + rm -rf $(OBJ) $(BINARY) \ No newline at end of file diff --git a/file.ssa b/file.ssa new file mode 100644 index 0000000..92ca480 --- /dev/null +++ b/file.ssa @@ -0,0 +1,12 @@ +function w $add(w %a, w %b) { # Define a function add +@start + %c =w add %a, %b # Adds the 2 arguments + ret %c # Return the result +} +export function w $main() { # Main function +@start + %r =w call $add(w 1, w 1) # Call add(1, 1) + call $printf(l $fmt, ..., w %r) # Show the result + ret 0 +} +data $fmt = { b "One and one make %d!\n", b 0 } \ No newline at end of file diff --git a/libqbe b/libqbe new file mode 160000 index 0000000..e154997 --- /dev/null +++ b/libqbe @@ -0,0 +1 @@ +Subproject commit e15499786214d7cd7f9a6151f99ea660c9b498bd diff --git a/slibs b/slibs new file mode 160000 index 0000000..9860064 --- /dev/null +++ b/slibs @@ -0,0 +1 @@ +Subproject commit 986006449d1586d9ae55e5696015aa67b0e33f4f diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..60fc1ae --- /dev/null +++ b/src/main.c @@ -0,0 +1,8 @@ +#include +#define SL_IMPLEMENTATION +#include +#include + +int main() { + printf("%s\n^ output\n", qbe_emit(Deftgt, sl_c_str(*sl_read_file("file.ssa")))); +} \ No newline at end of file diff --git a/src/main.o b/src/main.o new file mode 100644 index 0000000..0dbe378 Binary files /dev/null and b/src/main.o differ diff --git a/test b/test new file mode 100755 index 0000000..3fc07b1 Binary files /dev/null and b/test differ