xref: /plan9-contrib/sys/src/cmd/qc/machcap.c (revision 40d015479ed36701ae6dcfd8814f849fc6285e8d)
1 #include	"gc.h"
2 
3 int
machcap(Node * n)4 machcap(Node *n)
5 {
6 	if(n == Z)
7 		return 1;	/* test */
8 	switch(n->op){
9 
10 	case OADD:
11 	case OAND:
12 	case OOR:
13 	case OSUB:
14 	case OXOR:
15 		if(typev[n->left->type->etype])
16 			return 1;
17 		break;
18 
19 	case OMUL:
20 	case OLMUL:
21 	case OASLMUL:
22 		return 1;
23 
24 	case OASMUL:
25 		return !mixedasop(n->type, n->right->type);
26 
27 	case OLSHR:
28 	case OASHR:
29 	case OASHL:
30 	case OASASHL:
31 	case OASASHR:
32 	case OASLSHR:
33 		return 1;
34 
35 	case OCAST:
36 		if(typev[n->type->etype]) {
37 			if(!typefd[n->left->type->etype])
38 				return 1;
39 		} else if(!typefd[n->type->etype]) {
40 			if(typev[n->left->type->etype])
41 				return 1;
42 		}
43 		break;
44 
45 	case OCOMMA:
46 	case OCOND:
47 	case OLIST:
48 	case OANDAND:
49 	case OOROR:
50 	case ONOT:
51 		return 1;
52 
53 	case OCOM:
54 	case ONEG:
55 		if(typechl[n->left->type->etype])
56 			return 1;
57 		if(typev[n->left->type->etype])
58 			return 1;
59 		return 0;
60 
61 	case OASADD:
62 	case OASSUB:
63 		return !mixedasop(n->type, n->right->type);
64 
65 	case OASAND:
66 	case OASOR:
67 	case OASXOR:
68 		return 1;
69 
70 	case OPOSTINC:
71 	case OPOSTDEC:
72 	case OPREINC:
73 	case OPREDEC:
74 		return 1;
75 
76 	case OEQ:
77 	case ONE:
78 	case OLE:
79 	case OGT:
80 	case OLT:
81 	case OGE:
82 	case OHI:
83 	case OHS:
84 	case OLO:
85 	case OLS:
86 		return 1;
87 
88 	case ODIV:
89 	case OLDIV:
90 	case OLMOD:
91 	case OMOD:
92 		return 0;
93 
94 	case OASDIV:
95 	case OASLDIV:
96 	case OASLMOD:
97 	case OASMOD:
98 		return 0;
99 
100 	}
101 	return 0;
102 }
103