[hackers] [scc] [cc2-qbe] Do not use node ops in Inst || Roberto E. Vargas Caballero
commit 2caa6847c311d53c4a3666659e9798cbd5d3bce2
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
AuthorDate: Tue Apr 19 05:10:05 2016 +0200
Commit: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
CommitDate: Tue Apr 19 05:10:05 2016 +0200
[cc2-qbe] Do not use node ops in Inst
Until this moment we were using the same opcodes in nodes
and in instructions, but in instructions we have a lose of
semantic, so we need a different set of opcodes in instructions.
This patch adds a new enumeration for the instruction opcodes,
but it has direct relation with the node opcodes enumeration.
It will be fixed soon.
diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h
index 439e3b7..7ee9af4 100644
--- a/cc2/arch/qbe/arch.h
+++ b/cc2/arch/qbe/arch.h
_AT_@ -4,3 +4,24 @@
#define TFLOAT double
#define TSIZE unsigned long
+enum asmop {
+ ASLOAD,
+ ASADD,
+ ASSUB,
+ ASMUL,
+ ASMOD,
+ ASDIV,
+ ASSHL,
+ ASSHR,
+ ASLT,
+ ASGT,
+ ASLE,
+ ASGE,
+ ASEQ,
+ ASNE,
+ ASBAND,
+ ASBOR,
+ ASBXOR,
+ ASCPL,
+ ASASSIG
+};
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 5b1e246..23045c2 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -9,6 +9,26 @@ enum sflags {
ISCONS = 2
};
+static char opasm[] = {
+ [OADD] = ASADD,
+ [OSUB] = ASSUB,
+ [OMUL] = ASMUL,
+ [OMOD] = ASMOD,
+ [ODIV] = ASDIV,
+ [OSHL] = ASSHL,
+ [OSHR] = ASSHR,
+ [OLT] = ASLT,
+ [OGT] = ASGT,
+ [OLE] = ASLE,
+ [OGE] = ASGE,
+ [OEQ] = ASEQ,
+ [ONE] = ASNE,
+ [OBAND] = ASBAND,
+ [OBOR] = ASBOR,
+ [OBXOR] = ASBXOR,
+ [OCPL] = ASCPL
+};
+
static Node *
tmpnode(Node *np)
{
_AT_@ -31,7 +51,7 @@ load(Node *np)
new = tmpnode(newnode());
new->left = np;
new->type = np->type;
- code(OLOAD, new, np, NULL);
+ code(ASLOAD, new, np, NULL);
return new;
}
_AT_@ -81,7 +101,7 @@ cgen(Node *np)
if ((r->flags & (ISTMP|ISCONS)) == 0)
r = np->right = load(r);
tmpnode(np);
- code(op, np, l, r);
+ code(opasm[op], np, l, r);
return np;
case ONOP:
case OBLOOP:
_AT_@ -96,7 +116,7 @@ cgen(Node *np)
case ODEC:
abort();
case OASSIG:
- code(op, l, r, NULL);
+ code(ASASSIG, l, r, NULL);
return r;
case OCALL:
case OFIELD:
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 5b6c03f..3f4dc07 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -12,24 +12,24 @@ static struct opdata {
void (*fun)(void);
char *txt;
} optbl [] = {
- [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"}
+ [ASADD] = {.fun = binary, .txt = "add"},
+ [ASSUB] = {.fun = binary, .txt = "sub"},
+ [ASMUL] = {.fun = binary, .txt = "mul"},
+ [ASMOD] = {.fun = binary, .txt = "rem"},
+ [ASDIV] = {.fun = binary, .txt = "div"},
+ [ASSHL] = {.fun = binary, .txt = "shl"},
+ [ASSHR] = {.fun = binary, .txt = "shr"},
+ [ASLT] = {.fun = binary, .txt = "clt"},
+ [ASGT] = {.fun = binary, .txt = "cgt"},
+ [ASLE] = {.fun = binary, .txt = "cle"},
+ [ASGE] = {.fun = binary, .txt = "cge"},
+ [ASEQ] = {.fun = binary, .txt = "ceq"},
+ [ASNE] = {.fun = binary, .txt = "cne"},
+ [ASBAND] = {.fun = binary, .txt = "and"},
+ [ASBOR] = {.fun = binary, .txt = "or"},
+ [ASBXOR] = {.fun = binary, .txt = "xor"},
+ [ASLOAD] = {.fun = load, .txt = "load"},
+ [ASASSIG] = {.fun = store, .txt = "store"}
};
/*
Received on Tue Apr 19 2016 - 23:32:50 CEST
This archive was generated by hypermail 2.3.0
: Tue Apr 19 2016 - 23:36:18 CEST