aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-10-19 08:09:09 +0200
committerlemon <lsof@mailbox.org>2025-10-19 08:09:09 +0200
commitdea8fd171acb54b6d9685422d5e391fb55074008 (patch)
tree2c149892f35c5183c9b2a1da4ab437228dc432ef
parent3437945692f2b87883a4f066473c9deed50f25f5 (diff)
Organize source files into directories
-rw-r--r--.gitignore2
-rw-r--r--Makefile12
-rw-r--r--amd64/all.h2
-rw-r--r--amd64/emit.c2
-rw-r--r--c/c.c (renamed from c.c)6
-rw-r--r--c/c.h (renamed from c.h)2
-rw-r--r--c/eval.c (renamed from eval.c)0
-rw-r--r--c/keywords.def (renamed from keywords.def)0
-rw-r--r--c/lex.c (renamed from lex.c)0
-rw-r--r--c/lex.h (renamed from lex.h)2
-rw-r--r--io.c4
-rw-r--r--ir/abi0.c (renamed from abi0.c)0
-rw-r--r--ir/cfg.c (renamed from cfg.c)0
-rw-r--r--ir/dump.c (renamed from irdump.c)2
-rw-r--r--ir/intrin.c (renamed from intrin.c)1
-rw-r--r--ir/intrin.def (renamed from intrin.def)0
-rw-r--r--ir/ir.c (renamed from ir.c)2
-rw-r--r--ir/ir.h (renamed from ir.h)2
-rw-r--r--ir/op.def (renamed from op.def)0
-rw-r--r--ir/optmem.c (renamed from optmem.c)0
-rw-r--r--ir/regalloc.c (renamed from regalloc.c)0
-rw-r--r--ir/ssa.c (renamed from ssa.c)1
-rw-r--r--main.c2
-rw-r--r--obj/elf.c (renamed from elf.c)5
-rw-r--r--obj/elf.h (renamed from elf.h)2
-rw-r--r--obj/obj.c (renamed from obj.c)3
-rw-r--r--obj/obj.h (renamed from obj.h)2
27 files changed, 25 insertions, 29 deletions
diff --git a/.gitignore b/.gitignore
index ac09e84..7d028ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
antcc
-obj/
+build/
compile_commands.json
.cache/
.gdb_history
diff --git a/Makefile b/Makefile
index 123409d..3d8f411 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
-SRC=main.c io.c mem.c c.c lex.c type.c targ.c eval.c ir.c irdump.c ssa.c cfg.c \
- intrin.c abi0.c optmem.c regalloc.c amd64/sysv.c amd64/isel.c amd64/emit.c obj.c elf.c\
+SRC=main.c io.c mem.c c/c.c c/lex.c c/eval.c type.c targ.c ir/ir.c ir/dump.c ir/ssa.c ir/cfg.c \
+ ir/intrin.c ir/abi0.c ir/optmem.c ir/regalloc.c amd64/sysv.c amd64/isel.c amd64/emit.c obj/obj.c obj/elf.c \
embedfilesdir.c
CFLAGS=-Wall -std=c11 -pedantic
-OBJ=$(patsubst %.c,obj/%.o,$(SRC))
+OBJ=$(patsubst %.c,build/%.o,$(SRC))
DEP=$(OBJ:.o=.d)
OUT=antcc
@@ -18,12 +18,12 @@ dbg: $(OUT)
$(OUT): $(OBJ)
$(CC) $(CFLAGS) -o $@ $(OBJ)
-obj/%.o: %.c common.h
+build/%.o: %.c common.h
@mkdir -p `dirname $@`
- $(CC) $(CFLAGS) -MMD -MP -MT $@ -MF obj/$*.d -c -o $@ $<
+ $(CC) $(CFLAGS) -MMD -MP -MT $@ -MF build/$*.d -c -o $@ $<
clean:
- $(RM) -r obj/ $(OUT) *.o a.out
+ $(RM) -r build// $(OUT) *.o a.out
.PHONY: clean
diff --git a/amd64/all.h b/amd64/all.h
index 42f4d23..992d47e 100644
--- a/amd64/all.h
+++ b/amd64/all.h
@@ -1,4 +1,4 @@
-#include "../ir.h"
+#include "../ir/ir.h"
#define LIST_REGS(_) \
_(RAX) _(RCX) _(RDX) _(RBX) _(RSP) _(RBP) _(RSI) _(RDI) \
diff --git a/amd64/emit.c b/amd64/emit.c
index a6ce774..1db5093 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -1,5 +1,5 @@
#include "all.h"
-#include "../obj.h"
+#include "../obj/obj.h"
#include "../endian.h"
/** Instruction operands **
diff --git a/c.c b/c/c.c
index ac3b863..518a719 100644
--- a/c.c
+++ b/c/c.c
@@ -1,8 +1,8 @@
#include "c.h"
#include "lex.h"
-#include "ir.h"
-#include "endian.h"
-#include "obj.h"
+#include "../endian.h"
+#include "../ir/ir.h"
+#include "../obj/obj.h"
/** C compiler state **/
struct comp {
diff --git a/c.h b/c/c.h
index fa47bca..6a26455 100644
--- a/c.h
+++ b/c/c.h
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "../common.h"
/*************/
/* EXPR TREE */
diff --git a/eval.c b/c/eval.c
index d32cd6e..d32cd6e 100644
--- a/eval.c
+++ b/c/eval.c
diff --git a/keywords.def b/c/keywords.def
index 258a396..258a396 100644
--- a/keywords.def
+++ b/c/keywords.def
diff --git a/lex.c b/c/lex.c
index 951bb5a..951bb5a 100644
--- a/lex.c
+++ b/c/lex.c
diff --git a/lex.h b/c/lex.h
index 20fb2ee..4ea7327 100644
--- a/lex.h
+++ b/c/lex.h
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "../common.h"
static inline bool
joinspan(struct span0 *dst, struct span0 snd)
diff --git a/io.c b/io.c
index f28499d..b6729ee 100644
--- a/io.c
+++ b/io.c
@@ -1,4 +1,4 @@
-#include "lex.h"
+#include "c/lex.h"
#include <limits.h>
#include <stdlib.h>
#include <string.h>
@@ -576,7 +576,7 @@ vbfmt(struct wbuf *out, const char *fmt, va_list ap)
if (tok->t >= TKWBEGIN_ && tok->t <= TKWEND_) {
static const char *tab[] = {
#define _(kw, c) #kw,
- #include "keywords.def"
+ #include "c/keywords.def"
#undef _
};
n += bfmt(buf, "%s", tab[tok->t - TKWBEGIN_]);
diff --git a/abi0.c b/ir/abi0.c
index 82d10a5..82d10a5 100644
--- a/abi0.c
+++ b/ir/abi0.c
diff --git a/cfg.c b/ir/cfg.c
index d9aa409..d9aa409 100644
--- a/cfg.c
+++ b/ir/cfg.c
diff --git a/irdump.c b/ir/dump.c
index 1dd19fb..ddde7a3 100644
--- a/irdump.c
+++ b/ir/dump.c
@@ -1,5 +1,5 @@
#include "ir.h"
-#include "obj.h"
+#include "../obj/obj.h"
static int nextdat;
diff --git a/intrin.c b/ir/intrin.c
index b7fefec..9bb0bcb 100644
--- a/intrin.c
+++ b/ir/intrin.c
@@ -1,4 +1,3 @@
-#include "common.h"
#include "ir.h"
struct arg { union ref *arg, *ty; };
diff --git a/intrin.def b/ir/intrin.def
index 2ccc3b5..2ccc3b5 100644
--- a/intrin.def
+++ b/ir/intrin.def
diff --git a/ir.c b/ir/ir.c
index a196aa1..0132a97 100644
--- a/ir.c
+++ b/ir/ir.c
@@ -1,5 +1,5 @@
#include "ir.h"
-#include "obj.h"
+#include "../obj/obj.h"
uchar type2cls[NTYPETAG];
uchar cls2siz[KF8+1];
diff --git a/ir.h b/ir/ir.h
index 08e1ddc..2c8a55d 100644
--- a/ir.h
+++ b/ir/ir.h
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "../common.h"
enum irclass {
KXXX,
diff --git a/op.def b/ir/op.def
index 9e18fe7..9e18fe7 100644
--- a/op.def
+++ b/ir/op.def
diff --git a/optmem.c b/ir/optmem.c
index 1c137b7..1c137b7 100644
--- a/optmem.c
+++ b/ir/optmem.c
diff --git a/regalloc.c b/ir/regalloc.c
index 64dcfac..64dcfac 100644
--- a/regalloc.c
+++ b/ir/regalloc.c
diff --git a/ssa.c b/ir/ssa.c
index 6c1255a..9b89878 100644
--- a/ssa.c
+++ b/ir/ssa.c
@@ -1,4 +1,3 @@
-#include "common.h"
#include "ir.h"
/* require use, keeps use */
diff --git a/main.c b/main.c
index 8020653..07ccd58 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
#include "common.h"
-#include "obj.h"
+#include "obj/obj.h"
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
diff --git a/elf.c b/obj/elf.c
index be83118..d889fdd 100644
--- a/elf.c
+++ b/obj/elf.c
@@ -1,8 +1,7 @@
#include "elf.h"
-#include "common.h"
#include "obj.h"
-#include "ir.h"
-#include "endian.h"
+#include "../ir/ir.h" /* mctarg */
+#include "../endian.h"
#include <unistd.h>
#include <stdlib.h> /* qsort */
diff --git a/elf.h b/obj/elf.h
index 4328e01..c96ae8b 100644
--- a/elf.h
+++ b/obj/elf.h
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "../common.h"
#define ELFMAG "\177ELF"
enum {
diff --git a/obj.c b/obj/obj.c
index 93a0a50..b9e2c79 100644
--- a/obj.c
+++ b/obj/obj.c
@@ -1,6 +1,5 @@
#include "obj.h"
-#include "common.h"
-#include "ir.h"
+#include "../ir/ir.h"
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
diff --git a/obj.h b/obj/obj.h
index fffc54c..235ab4d 100644
--- a/obj.h
+++ b/obj/obj.h
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "../common.h"
extern struct objfile {
const char *infile, *outfile;