scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 4693a350fcf4a519db4ed75e07a8b56b567cdbfa
parent 51d1794ed0df9a480bde7cf346ad443ec4b8c58d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Nov 2021 22:44:09 +0100

cc2: Implement blit()

Blit() is used to do arbitrary transfers from one memory
location to other memory location.

Diffstat:
Msrc/cmd/cc/cc2/target/qbe/cgen.c | 7++++++-
Msrc/cmd/cc/cc2/target/qbe/code.c | 14+++++++-------
2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/cmd/cc/cc2/target/qbe/cgen.c b/src/cmd/cc/cc2/target/qbe/cgen.c @@ -421,6 +421,11 @@ swtch_if(Node *idx) static int assignop(Type *tp) { + int flags = tp->flags; + + if (flags & (AGGRF|FUNF|ARRF)) + return ASSTM; + switch (tp->size) { case 1: return ASSTB; @@ -431,7 +436,7 @@ assignop(Type *tp) case 8: return (tp->flags & FLOATF) ? ASSTD : ASSTL; default: - return ASSTM; + abort(); } } diff --git a/src/cmd/cc/cc2/target/qbe/code.c b/src/cmd/cc/cc2/target/qbe/code.c @@ -12,7 +12,7 @@ static void binary(void), unary(void), store(void), jmp(void), ret(void), branch(void), call(void), ecall(void), param(void), - asalloc(void), form2local(void), ldir(void), vastart(void), + asalloc(void), form2local(void), blit(void), vastart(void), vaarg(void); static struct opdata { @@ -41,7 +41,7 @@ static struct opdata { [ASSTH] = {.fun = store, .txt = "store", .letter = 'h'}, [ASSTW] = {.fun = store, .txt = "store", .letter = 'w'}, [ASSTL] = {.fun = store, .txt = "store", .letter = 'l'}, - [ASSTM] = {.fun = ldir}, + [ASSTM] = {.fun = blit}, [ASSTS] = {.fun = store, .txt = "store", .letter = 's'}, [ASSTD] = {.fun = store, .txt = "store", .letter = 'd'}, @@ -416,13 +416,14 @@ binary(void) } static void -ldir(void) +blit(void) { - struct opdata *p = &optbl[pc->op]; + Type *tp = &pc->to.u.sym->type; char to[ADDR_LEN], from[ADDR_LEN]; - /* TODO: what type do we use for the size? */ - /* TODO: it is pending */ + strcpy(to, addr2txt(&pc->to)); + strcpy(from, addr2txt(&pc->from1)); + printf("\t\tblit\t(%s,%s,%lu,%lu)\n", to, from, tp->size, tp->align); } static void @@ -450,7 +451,6 @@ unary(void) static void call(void) { - struct opdata *p = &optbl[pc->op]; char to[ADDR_LEN], from[ADDR_LEN]; Symbol *sym = pc->to.u.sym;