shithub: scc

Download patch

ref: 3ee77ddba4ad86c4f8d0357a90d5dd855e8c619e
parent: 2d6e3a3b4fd4aa72d7de54633f737c532405f1ae
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Jun 23 12:20:52 EDT 2016

[cc2-qbe] Add support for OCPL and ONEG in sethi()

This operators are implemented using another operators,
so the best place for doing this operation is in sethi().

--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -59,7 +59,24 @@
 	case OCONST:
 		np->address = 11;
 		break;
+	case OCPL:
+		np->op = OAND;
+		rp = newnode(OCONST);
+		rp->type = np->type;
+		rp->u.i = 0;
+		rp->u.i = ~np->u.i;
+		goto binary;
+	case ONEG:
+		np->op = OSUB;
+		rp = lp;
+		lp = newnode(OCONST);
+		lp->type = np->type;
+		if (np->type.flags & INTF)
+			lp->u.i = 0;
+		else
+			lp->u.f = 0.0;
 	default:
+	binary:
 		lp = sethi(lp);
 		rp = sethi(rp);
 		break;