Home
       arch.c - scc - simple c99 compiler
  HTML git clone git://git.simple-cc.org/scc
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       arch.c (1950B)
       ---
            1 #include <string.h>
            2 #include <stdio.h>
            3 #include <stdlib.h>
            4 
            5 #include <scc/scc.h>
            6 #include "cc1.h"
            7 
            8 Type *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;
           18 
           19 Symbol *one, *zero;
           20 char *architecture = "amd64-sysv";
           21 
           22 static Arch *arch;
           23 static Symbol zerodata = {.u.i = 0};
           24 static Symbol onedata = {.u.i = 1};
           25 
           26 static Arch *
           27 getarch(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                 "i386-sysv", i386_sysv,
           36                 "z80-scc", z80_scc,
           37                 NULL, NULL,
           38         };
           39 
           40         for (bp = defs; bp->arch; ++bp) {
           41                 if (strcmp(bp->arch, architecture) == 0)
           42                         return (*bp->fun)();
           43         }
           44 
           45         return NULL;
           46 }
           47 
           48 int
           49 valid_va_list(Type *tp)
           50 {
           51         return (*arch->valid_va_list)(tp);
           52 }
           53 
           54 void
           55 iarch(void)
           56 {
           57         if ((arch = getarch()) == NULL) {
           58                 fprintf(stderr, "cc1: wrong architecture '%s'\n", architecture);
           59                 exit(EXIT_FAILURE);
           60         }
           61 
           62         voidtype = &arch->voidtype;
           63         pvoidtype = &arch->pvoidtype;
           64         booltype = &arch->booltype;
           65         uchartype = &arch->uchartype;
           66         chartype = &arch->chartype;
           67         schartype = &arch->schartype;
           68         uinttype = &arch->uinttype;
           69         inttype = &arch->inttype;
           70         sizettype = &arch->sizettype;
           71         pdifftype = &arch->pdifftype;
           72         ushorttype = &arch->ushorttype;
           73         shorttype = &arch->shorttype;
           74         longtype = &arch->longtype;
           75         ulongtype = &arch->ulongtype;
           76         ullongtype = &arch->ullongtype;
           77         llongtype = &arch->llongtype;
           78         floattype = &arch->floattype;
           79         doubletype = &arch->doubletype;
           80         ldoubletype = &arch->ldoubletype;
           81         ellipsistype = &arch->ellipsistype;
           82         va_list_type = &arch->va_list_type;
           83         va_type = &arch->va_type;
           84         wchartype = &arch->wchartype;
           85         zero = &zerodata;
           86         one = &onedata;
           87 
           88         zero->type = inttype;
           89         one->type = inttype;
           90 }