LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #undef EXTERN | 5 #undef EXTERN |
6 #define EXTERN | 6 #define EXTERN |
7 #include <u.h> | 7 #include <u.h> |
8 #include <libc.h> | 8 #include <libc.h> |
9 #include "gg.h" | 9 #include "gg.h" |
10 #include "opt.h" | 10 #include "opt.h" |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 cgen(nl, &n1); | 769 cgen(nl, &n1); |
770 regalloc(&n2, t, N); | 770 regalloc(&n2, t, N); |
771 cgen(nr, &n2); | 771 cgen(nr, &n2); |
772 a = optoas(op, t); | 772 a = optoas(op, t); |
773 gins(a, &n2, &n1); | 773 gins(a, &n2, &n1); |
774 regfree(&n2); | 774 regfree(&n2); |
775 gmove(&n1, res); | 775 gmove(&n1, res); |
776 regfree(&n1); | 776 regfree(&n1); |
777 } | 777 } |
778 | 778 |
| 779 /* |
| 780 * generate high multiply: |
| 781 * res = (nl*nr) >> width |
| 782 */ |
| 783 void |
| 784 cgen_hmul(Node *nl, Node *nr, Node *res) |
| 785 { |
| 786 Type *t; |
| 787 int a; |
| 788 Node n1, n2, ax, dx; |
| 789 |
| 790 t = nl->type; |
| 791 a = optoas(OHMUL, t); |
| 792 // gen nl in n1. |
| 793 tempname(&n1, t); |
| 794 cgen(nl, &n1); |
| 795 // gen nr in n2. |
| 796 regalloc(&n2, t, res); |
| 797 cgen(nr, &n2); |
| 798 |
| 799 // multiply. |
| 800 nodreg(&ax, t, D_AX); |
| 801 gmove(&n2, &ax); |
| 802 gins(a, &n1, N); |
| 803 regfree(&n2); |
| 804 |
| 805 if(t->width == 1) { |
| 806 // byte multiply behaves differently. |
| 807 nodreg(&ax, t, D_AH); |
| 808 nodreg(&dx, t, D_DL); |
| 809 gmove(&ax, &dx); |
| 810 } |
| 811 nodreg(&dx, t, D_DX); |
| 812 gmove(&dx, res); |
| 813 } |
| 814 |
LEFT | RIGHT |