xref: /inferno-os/utils/qc/machcap.c (revision 7ef44d652ae9e5e1f5b3465d73684e4a54de73c0)
1 #include	"gc.h"
2 
3 int
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 OASMUL:
22 	case OASLMUL:
23 		return 1;
24 
25 	case OLSHR:
26 	case OASHR:
27 	case OASHL:
28 	case OASASHL:
29 	case OASASHR:
30 	case OASLSHR:
31 		return 1;
32 
33 	case OCAST:
34 		if(typev[n->type->etype]) {
35 			if(!typefd[n->left->type->etype])
36 				return 1;
37 		} else if(!typefd[n->type->etype]) {
38 			if(typev[n->left->type->etype])
39 				return 1;
40 		}
41 		break;
42 
43 	case OCOMMA:
44 	case OCOND:
45 	case OLIST:
46 	case OANDAND:
47 	case OOROR:
48 	case ONOT:
49 		return 1;
50 
51 	case OCOM:
52 	case ONEG:
53 		if(typechl[n->left->type->etype])
54 			return 1;
55 		if(typev[n->left->type->etype])
56 			return 1;
57 		return 0;
58 
59 	case OASADD:
60 	case OASSUB:
61 	case OASAND:
62 	case OASOR:
63 	case OASXOR:
64 		return 1;
65 
66 	case OPOSTINC:
67 	case OPOSTDEC:
68 	case OPREINC:
69 	case OPREDEC:
70 		return 1;
71 
72 	case OEQ:
73 	case ONE:
74 	case OLE:
75 	case OGT:
76 	case OLT:
77 	case OGE:
78 	case OHI:
79 	case OHS:
80 	case OLO:
81 	case OLS:
82 		return 1;
83 
84 	case ODIV:
85 	case OLDIV:
86 	case OLMOD:
87 	case OMOD:
88 		return 0;
89 
90 	case OASDIV:
91 	case OASLDIV:
92 	case OASLMOD:
93 	case OASMOD:
94 		return 0;
95 
96 	}
97 	return 0;
98 }
99