diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-10-31 13:51:06 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-10-31 13:51:06 +0100 |
| commit | 4dbcfc991a4fb203ec2b50d950f59adb1ad61922 (patch) | |
| tree | 474dbf6fbf510f19f613b3357f20052f17239436 /src/prc1/cgen/qbe | |
| parent | 803e95a883a5d3881f662d60cd1a24309bafd4de (diff) | |
| download | prc-4dbcfc991a4fb203ec2b50d950f59adb1ad61922.tar.gz | |
Setup scaffolding for statics section
Diffstat (limited to 'src/prc1/cgen/qbe')
| -rw-r--r-- | src/prc1/cgen/qbe/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/prc1/cgen/qbe/fn.c | 4 | ||||
| -rw-r--r-- | src/prc1/cgen/qbe/qbe.c | 1 | ||||
| -rw-r--r-- | src/prc1/cgen/qbe/qbe.h | 1 | ||||
| -rw-r--r-- | src/prc1/cgen/qbe/st.c | 20 |
5 files changed, 27 insertions, 0 deletions
diff --git a/src/prc1/cgen/qbe/CMakeLists.txt b/src/prc1/cgen/qbe/CMakeLists.txt index a9e7155..0a71cb7 100644 --- a/src/prc1/cgen/qbe/CMakeLists.txt +++ b/src/prc1/cgen/qbe/CMakeLists.txt @@ -6,6 +6,7 @@ target_sources(prc1 PRIVATE gl.c print.c set.c + st.c qbe.c ws.c ) diff --git a/src/prc1/cgen/qbe/fn.c b/src/prc1/cgen/qbe/fn.c index 61b0bf0..d13695c 100644 --- a/src/prc1/cgen/qbe/fn.c +++ b/src/prc1/cgen/qbe/fn.c @@ -3,6 +3,7 @@ #include "gl.h" #include "stmt.h" #include "qbe.h" +#include "st.h" #include "ws.h" #include <stdio.h> @@ -67,6 +68,9 @@ int qbe_fn(const struct fn *fn, struct cgen *c) if (fn->ws && ws_cgen(fn->ws, c)) return -1; + if (fn->st && st_cgen(fn->st, c)) + return -1; + for (const struct tmp *tmp = fn->tmps; tmp; tmp = tmp->next) { const struct stentry *e = &tmp->e; diff --git a/src/prc1/cgen/qbe/qbe.c b/src/prc1/cgen/qbe/qbe.c index d727bc0..95e6f1f 100644 --- a/src/prc1/cgen/qbe/qbe.c +++ b/src/prc1/cgen/qbe/qbe.c @@ -158,6 +158,7 @@ int cgen_qbe(const struct ast *ast, struct cgen *c) .set = qbe_set, .gl = qbe_gl, .ws = qbe_ws, + .st = qbe_st, .fn = qbe_fn }; diff --git a/src/prc1/cgen/qbe/qbe.h b/src/prc1/cgen/qbe/qbe.h index 206cf32..f50b242 100644 --- a/src/prc1/cgen/qbe/qbe.h +++ b/src/prc1/cgen/qbe/qbe.h @@ -21,6 +21,7 @@ int qbe_call(const struct call *m, struct cgen *c); int qbe_set(const struct set *m, struct cgen *c); int qbe_gl(const struct storage *gl, struct cgen *c); int qbe_ws(const struct storage *s, struct cgen *c); +int qbe_st(const struct storage *s, struct cgen *c); int qbe_from(const struct from *fn, struct cgen *c); int qbe_fn(const struct fn *fn, struct cgen *c); void qbe_free(struct cgen_prv *p); diff --git a/src/prc1/cgen/qbe/st.c b/src/prc1/cgen/qbe/st.c new file mode 100644 index 0000000..d736497 --- /dev/null +++ b/src/prc1/cgen/qbe/st.c @@ -0,0 +1,20 @@ +#include "cgen.h" +#include "storage.h" +#include "qbe.h" +#include <stddef.h> +#include <stdio.h> + +static int stpush(const struct stentry *e, struct cgen *c) +{ + fprintf(stderr, "%s: TODO\n", __func__); + return -1; +} + +int qbe_st(const struct storage *s, struct cgen *c) +{ + for (size_t i = 0; i < s->nentries; i++) + if (stpush(&s->entries[i], c)) + return -1; + + return 0; +} |
