Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(415)

Unified Diff: src/cmd/8g/ggen.c

Issue 6819123: code review 6819123: cmd/gc: add division rewrite to walk pass. (Closed)
Patch Set: diff -r 538f0e9733bc https://go.googlecode.com/hg/ Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cmd/8g/gg.h ('k') | src/cmd/8g/gsubr.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cmd/8g/ggen.c
===================================================================
--- a/src/cmd/8g/ggen.c
+++ b/src/cmd/8g/ggen.c
@@ -776,3 +776,39 @@
regfree(&n1);
}
+/*
+ * generate high multiply:
+ * res = (nl*nr) >> width
+ */
+void
+cgen_hmul(Node *nl, Node *nr, Node *res)
+{
+ Type *t;
+ int a;
+ Node n1, n2, ax, dx;
+
+ t = nl->type;
+ a = optoas(OHMUL, t);
+ // gen nl in n1.
+ tempname(&n1, t);
+ cgen(nl, &n1);
+ // gen nr in n2.
+ regalloc(&n2, t, res);
+ cgen(nr, &n2);
+
+ // multiply.
+ nodreg(&ax, t, D_AX);
+ gmove(&n2, &ax);
+ gins(a, &n1, N);
+ regfree(&n2);
+
+ if(t->width == 1) {
+ // byte multiply behaves differently.
+ nodreg(&ax, t, D_AH);
+ nodreg(&dx, t, D_DL);
+ gmove(&ax, &dx);
+ }
+ nodreg(&dx, t, D_DX);
+ gmove(&dx, res);
+}
+
« no previous file with comments | « src/cmd/8g/gg.h ('k') | src/cmd/8g/gsubr.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b