ref: 19e8c2323baa2d8d79ef6854367c30185fda99c8
parent: 281b5ee6bc9aea9e061a792aff6f3fc72bca98fa
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 5 18:44:09 EDT 2021
cc2: Implement blit() Blit() is used to do arbitrary transfers from one memory location to other memory location.
--- a/src/cmd/cc/cc2/target/qbe/cgen.c
+++ b/src/cmd/cc/cc2/target/qbe/cgen.c
@@ -421,6 +421,11 @@
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 @@
case 8:
return (tp->flags & FLOATF) ? ASSTD : ASSTL;
default:
- return ASSTM;
+ abort();
}
}
--- 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 @@
[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 @@
}
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 @@
static void
call(void)
{
- struct opdata *p = &optbl[pc->op];
char to[ADDR_LEN], from[ADDR_LEN];
Symbol *sym = pc->to.u.sym;