summaryrefslogtreecommitdiff
path: root/sys/src/cmd/5c/machcap.c
blob: e68142d33eb252c7e09a8cc8871db3d238da8a0d (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
#include "gc.h"

int
machcap(Node *n)
{
	if(n == Z)
		return 0;	/* test */
	switch(n->op) {
	case OASADD:
	case OASSUB:
	case OASAND:
	case OASXOR:
	case OASOR:
	case OADD:
	case OSUB:
	case OAND:
	case OXOR:
	case OOR:
		if(typev[n->type->etype] && typev[n->left->type->etype] && typev[n->right->type->etype])
			return 1;
		break;

	case OMUL:
	case OLMUL:
		if(typev[n->type->etype] && typeil[n->left->type->etype] && typeil[n->right->type->etype]
		&& typeu[n->type->etype] == typeu[n->left->type->etype]
		&& typeu[n->type->etype] == typeu[n->right->type->etype])
			return 1;
		break;

	case OASASHL:
	case OASASHR:
	case OASLSHR:
	case OASHL:
	case OASHR:
	case OLSHR:
		if(typev[n->type->etype] && typev[n->left->type->etype] && n->right->op == OCONST)
			return 1;
		break;

	case OCAST:
		if(typeilp[n->type->etype] && typev[n->left->type->etype])
			return 1;
		if(typev[n->type->etype] && typeilp[n->left->type->etype])
			return 1;
		break;
	}
	return 0;
}