~mcf/cproc

ref: 16c718729adfaf40cf22aa4efeafb0d92ef5ee3c cproc/targ.c -rw-r--r-- 676 bytes
16c71872Michael Forney Prepare for supporting architecture-specific va_list type 4 months ago
                                                                                
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
#include <stdint.h>
#include <string.h>
#include "util.h"
#include "cc.h"

const struct target *targ;

static const struct target alltargs[] = {
	{
		.name = "x86_64",
		.typewchar = &typeint,
		.signedchar = 1,
	},
	{
		.name = "aarch64",
		.typewchar = &typeuint,
	},
	{
		.name = "riscv64",
		.typewchar = &typeint,
	},
};

void
targinit(const char *name)
{
	size_t i;

	if (!name) {
		/* TODO: provide a way to set this default */
		targ = &alltargs[0];
	}
	for (i = 0; i < LEN(alltargs) && !targ; ++i) {
		if (strcmp(alltargs[i].name, name) == 0)
			targ = &alltargs[i];
	}
	if (!targ)
		fatal("unknown target '%s'", name);
	typechar.basic.issigned = targ->signedchar;
}