-
Notifications
You must be signed in to change notification settings - Fork 0
/
targ.c
61 lines (57 loc) · 1.17 KB
/
targ.c
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
#include <stdbool.h>
#include <string.h>
#include "util.h"
#include "cc.h"
const struct target *targ;
static const struct target alltargs[] = {
{
.name = "x86_64-sysv",
.typewchar = &typeint,
.typevalist = &(struct type){
.kind = TYPEARRAY,
.align = 8, .size = 24,
.base = &(struct type){
.kind = TYPESTRUCT,
.align = 8, .size = 24,
},
},
.signedchar = 1,
},
{
.name = "aarch64",
.typevalist = &(struct type){
.kind = TYPESTRUCT,
.align = 8, .size = 32,
.u.structunion.tag = "va_list",
},
.typewchar = &typeuint,
},
{
.name = "riscv64",
.typevalist = &(struct type){
.kind = TYPEPOINTER, .prop = PROPSCALAR,
.align = 8, .size = 8,
.base = &typevoid,
},
.typewchar = &typeint,
},
};
void
targinit(const char *name)
{
size_t i;
enum typequal qual;
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.u.basic.issigned = targ->signedchar;
qual = QUALNONE;
typeadjvalist = typeadjust(targ->typevalist, &qual);
}