summaryrefslogtreecommitdiff
path: root/sys/src/cmd/qc/machcap.c
blob: e9f9a988199a08f84f616d37a91353e655ca1f8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include	"gc.h"

int
machcap(Node *n)
{
	if(n == Z)
		return 1;	/* test */
	switch(n->op){

	case OADD:
	case OAND:
	case OOR:
	case OSUB:
	case OXOR:
		if(typev[n->left->type->etype])
			return 1;
		break;

	case OMUL:
	case OLMUL:
	case OASMUL:
	case OASLMUL:
		return 1;

	case OLSHR:
	case OASHR:
	case OASHL:
	case OASASHL:
	case OASASHR:
	case OASLSHR:
		return 1;

	case OCAST:
		if(typev[n->type->etype]) {
			if(!typefd[n->left->type->etype])
				return 1;
		} else if(!typefd[n->type->etype]) {
			if(typev[n->left->type->etype])
				return 1;
		}
		break;

	case OCOMMA:
	case OCOND:
	case OLIST:
	case OANDAND:
	case OOROR:
	case ONOT:
		return 1;

	case OCOM:
	case ONEG:
		if(typechl[n->left->type->etype])
			return 1;
		if(typev[n->left->type->etype])
			return 1;
		return 0;

	case OASADD:
	case OASSUB:
	case OASAND:
	case OASOR:
	case OASXOR:
		return 1;

	case OPOSTINC:
	case OPOSTDEC:
	case OPREINC:
	case OPREDEC:
		return 1;

	case OEQ:
	case ONE:
	case OLE:
	case OGT:
	case OLT:
	case OGE:
	case OHI:
	case OHS:
	case OLO:
	case OLS:
		return 1;

	case ODIV:
	case OLDIV:
	case OLMOD:
	case OMOD:
		return 0;

	case OASDIV:
	case OASLDIV:
	case OASLMOD:
	case OASMOD:
		return 0;

	}
	return 0;
}