[hackers] [scc] [cc2-qbe] Add load() and store() to code.c || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 16 Apr 2016 09:42:19 +0200 (CEST)

commit 2922dbe23dbf8ac30c6bed8ade83865abe0450a5
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
AuthorDate: Fri Apr 15 14:45:44 2016 +0200
Commit: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
CommitDate: Fri Apr 15 14:45:44 2016 +0200

    [cc2-qbe] Add load() and store() to code.c
    
    These functions emit the actual text needed in
    QBE for loading and storing symbols.

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 5455fcc..3ee9478 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -6,28 +6,30 @@
 #include "../../cc2.h"
 #include "../../../inc/sizes.h"
 
-static void inst3(void);
+static void binary(void), load(void), store(void);
 
 static struct opdata {
         void (*fun)(void);
         char *txt;
 } optbl [] = {
- [OADD] = {.fun = inst3, .txt = "add"},
- [OSUB] = {.fun = inst3, .txt = "sub"},
- [OMUL] = {.fun = inst3, .txt = "mul"},
- [OMOD] = {.fun = inst3, .txt = "rem"},
- [ODIV] = {.fun = inst3, .txt = "div"},
- [OSHL] = {.fun = inst3, .txt = "shl"},
- [OSHR] = {.fun = inst3, .txt = "shr"},
- [OLT] = {.fun = inst3, .txt = "clt"},
- [OGT] = {.fun = inst3, .txt = "cgt"},
- [OLE] = {.fun = inst3, .txt = "cle"},
- [OGE] = {.fun = inst3, .txt = "cge"},
- [OEQ] = {.fun = inst3, .txt = "ceq"},
- [ONE] = {.fun = inst3, .txt = "cne"},
- [OBAND] = {.fun = inst3, .txt = "and"},
- [OBOR] = {.fun = inst3, .txt = "or"},
- [OBXOR] = {.fun = inst3, .txt = "xor"}
+ [OADD] = {.fun = binary, .txt = "add"},
+ [OSUB] = {.fun = binary, .txt = "sub"},
+ [OMUL] = {.fun = binary, .txt = "mul"},
+ [OMOD] = {.fun = binary, .txt = "rem"},
+ [ODIV] = {.fun = binary, .txt = "div"},
+ [OSHL] = {.fun = binary, .txt = "shl"},
+ [OSHR] = {.fun = binary, .txt = "shr"},
+ [OLT] = {.fun = binary, .txt = "clt"},
+ [OGT] = {.fun = binary, .txt = "cgt"},
+ [OLE] = {.fun = binary, .txt = "cle"},
+ [OGE] = {.fun = binary, .txt = "cge"},
+ [OEQ] = {.fun = binary, .txt = "ceq"},
+ [ONE] = {.fun = binary, .txt = "cne"},
+ [OBAND] = {.fun = binary, .txt = "and"},
+ [OBOR] = {.fun = binary, .txt = "or"},
+ [OBXOR] = {.fun = binary, .txt = "xor"},
+ [OLOAD] = {.fun = load, .txt = "load"},
+ [OASSIG] = {.fun = store, .txt = "store"}
 };
 
 /*
_AT_@ -231,13 +233,31 @@ addr2txt(Addr *a)
 }
 
 static void
-inst3(void)
+binary(void)
 {
- printf("\t%s %c= %s\t%s,%s\n",
- addr2txt(&pc->to),
- 'w', /* FIXME */
- optbl[pc->op].txt,
- addr2txt(&pc->from1), addr2txt(&pc->from2));
+ printf("\t%s %c=\t%s\t",
+ addr2txt(&pc->to), 'w', optbl[pc->op].txt);
+ fputs(addr2txt(&pc->from1), stdout);
+ putchar(',');
+ fputs(addr2txt(&pc->from2), stdout);
+ putchar('\n');
+}
+
+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');
+}
+
+static void
+load(void)
+{
+ printf("\t%s %c=\t", addr2txt(&pc->to), 'w');
+ printf("%s\t%s\n", optbl[pc->op].txt, addr2txt(&pc->from1));
 }
 
 void
Received on Sat Apr 16 2016 - 09:42:19 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 16 2016 - 09:48:37 CEST