1#include <string.h>2#include <stdio.h>3#include <stdlib.h>45#include <scc/scc.h>6#include "cc1.h"78Type *voidtype, *pvoidtype, *booltype,9 *uchartype, *chartype, *schartype,10 *uinttype, *inttype,11 *sizettype, *pdifftype,12 *ushorttype, *shorttype,13 *longtype, *ulongtype,14 *ullongtype, *llongtype,15 *floattype, *doubletype, *ldoubletype,16 *ellipsistype, *va_list_type, *va_type,17 *wchartype;1819Symbol *one, *zero;20char *architecture = "amd64-sysv";2122static Arch *arch;23static Symbol zerodata = {.u.i = 0};24static Symbol onedata = {.u.i = 1};2526static Arch *27getarch(void)28{29 static struct archdef {30 char *arch;31 Arch *(*fun)(void);32 } *bp, defs[] = {33 "amd64-sysv", amd64_sysv,34 "arm64-sysv", arm64_sysv,35 "riscv64-sysv", riscv64_sysv,36 "i386-sysv", i386_sysv,37 "z80-scc", z80_scc,38 NULL, NULL,39 };4041 for (bp = defs; bp->arch; ++bp) {42 if (strcmp(bp->arch, architecture) == 0)43 return (*bp->fun)();44 }4546 return NULL;47}4849int50valid_va_list(Type *tp)51{52 return (*arch->valid_va_list)(tp);53}5455void56iarch(void)57{58 if ((arch = getarch()) == NULL) {59 fprintf(stderr, "cc1: wrong architecture '%s'\n", architecture);60 exit(EXIT_FAILURE);61 }6263 voidtype = &arch->voidtype;64 pvoidtype = &arch->pvoidtype;65 booltype = &arch->booltype;66 uchartype = &arch->uchartype;67 chartype = &arch->chartype;68 schartype = &arch->schartype;69 uinttype = &arch->uinttype;70 inttype = &arch->inttype;71 sizettype = &arch->sizettype;72 pdifftype = &arch->pdifftype;73 ushorttype = &arch->ushorttype;74 shorttype = &arch->shorttype;75 longtype = &arch->longtype;76 ulongtype = &arch->ulongtype;77 ullongtype = &arch->ullongtype;78 llongtype = &arch->llongtype;79 floattype = &arch->floattype;80 doubletype = &arch->doubletype;81 ldoubletype = &arch->ldoubletype;82 ellipsistype = &arch->ellipsistype;83 va_list_type = &arch->va_list_type;84 va_type = &arch->va_type;85 wchartype = &arch->wchartype;86 zero = &zerodata;87 one = &onedata;8889 zero->type = inttype;90 one->type = inttype;91}