[hackers] [scc] [cc2-qbe] Add all the possibilities to store || Roberto E. Vargas Caballero
commit db5ea284e2d99a5aa3aa5fcb8242eda7c2bd9904
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Apr 22 14:13:46 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Apr 22 14:13:46 2016 +0200
[cc2-qbe] Add all the possibilities to store
Store can store integer of 1,2,4 or 8 bytes, or floats
of 4 or 8 bytes.
diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h
index 78f058b..6984765 100644
--- a/cc2/arch/qbe/arch.h
+++ b/cc2/arch/qbe/arch.h
_AT_@ -6,7 +6,12 @@
enum asmop {
ASLOAD,
- ASASSIG,
+ ASSTB,
+ ASSTH,
+ ASSTW,
+ ASSTL,
+ ASSTS,
+ ASSTD,
ASADDW,
ASSUBW,
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 7961178..8a7b5ad 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -198,7 +198,23 @@ cgen(Node *np)
case ODEC:
abort();
case OASSIG:
- code(ASASSIG, l, r, NULL);
+ switch (tp->size) {
+ case 1:
+ op = ASSTB;
+ break;
+ case 2:
+ op = ASSTH;
+ break;
+ case 4:
+ op = (tp->flags & INTF) ? ASSTW : ASSTS;
+ break;
+ case 8:
+ op = (tp->flags & INTF) ? ASSTL : ASSTD;
+ break;
+ default:
+ abort();
+ }
+ code(op, l, r, NULL);
return r;
case OCALL:
case OFIELD:
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 0900add..3e3bc91 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -17,7 +17,12 @@ static struct opdata {
char letter;
} optbl [] = {
[ASLOAD] = {.fun = load, .txt = "load", .letter = 'w'},
- [ASASSIG] = {.fun = store, .txt = "store", .letter = 'w'},
+ [ASSTB] = {.fun = store, .txt = "store", .letter = 'b'},
+ [ASSTH] = {.fun = store, .txt = "store", .letter = 'h'},
+ [ASSTW] = {.fun = store, .txt = "store", .letter = 'w'},
+ [ASSTL] = {.fun = store, .txt = "store", .letter = 'l'},
+ [ASSTS] = {.fun = store, .txt = "store", .letter = 's'},
+ [ASSTD] = {.fun = store, .txt = "store", .letter = 'd'},
[ASADDW] = {.fun = binary, .txt = "add", .letter = 'w'},
[ASSUBW] = {.fun = binary, .txt = "sub", .letter = 'w'},
_AT_@ -330,11 +335,12 @@ binary(void)
static void
store(void)
{
- printf("\t\t%s%c\t", optbl[pc->op].txt, 'w'),
- fputs(addr2txt(&pc->from1), stdout);
- putchar(',');
- fputs(addr2txt(&pc->to), stdout);
- putchar('\n');
+ struct opdata *p = &optbl[pc->op];
+ char to[ADDR_LEN], from[ADDR_LEN];
+
+ strcpy(to, addr2txt(&pc->to));
+ strcpy(from, addr2txt(&pc->from1));
+ printf("\t\t%s%c\t%s,%s\n", p->txt, p->letter, from, to);
}
static void
Received on Fri Apr 22 2016 - 14:15:59 CEST
This archive was generated by hypermail 2.3.0
: Fri Apr 22 2016 - 14:24:15 CEST