1 /* mach.c file for ARM backend */
4 #define MAXREGVARS 4 /* Max num of register variables*/
11 reg [MAXREGVARS]; /* array of reg var details */
13 char regnames[6*MAXREGVARS]; /* comma-delimited list of regs */
14 int n_regs; /* current number of reg vars */
27 while (part_size % sz) part_size++;
29 if (part_size == TEM_WSIZE)
31 if (sz == 1 || sz == 2) {
32 w &= (sz == 1 ? 0xFF : 0xFFFF);
46 fatal("bad icon/ucon size");
47 fprintf(codefile,".long\t%s\n",str);
51 regscore (offset, size, type, score, totype)
54 if (size > 4) /* only consider register-sized */
55 return -1; /* variables */
57 if (score < 2) return -1;
59 /* give greater preference to locals */
60 if (offset >= 0) score *= 4; else score *= 8;
73 regsave(name, offset, size)
78 if (n_regs > 0) /* if its not the first item */
79 strcat(regnames, ","); /* prefix it with a comma */
80 strcat(regnames, name); /* add to list of names to save */
82 reg[n_regs].name = name; /* and add to array of reg vars */
83 reg[n_regs++].offset = offset;
94 fprintf(codefile, "STMFD R12<,{%s}\n", regnames);
96 for (i = 0; i < n_regs; i++) { /* load their new values */
99 if (n > 0) /* only proc parameters */
100 fprintf(codefile, "LDR %s,[R13,#%ld]\n", q, n);
108 fprintf(codefile, "LDMFD R12<,{%s}\n", regnames);
111 mes(type) word type ; {
114 switch ( (int)type ) {
117 switch ( argt=getarg(
118 ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
123 fprintf(codefile,".define %s\n",argstr) ;
128 while ( getarg(any_ptyp) != sp_cend ) ;
133 prolog(nlocals) full nlocals;
135 fprintf(codefile, "STMFD R12<,{R13,R14}\n");
136 fprintf(codefile, "MOV R13,R12\n");
138 fprintf(codefile, "SUB R12,R12,#%d\n", nlocals);
142 #define CODE_GENERATOR
144 #define FL_MSL_AT_LOW_ADDRESS 0
145 #define FL_MSW_AT_LOW_ADDRESS 0
146 #define FL_MSB_AT_LOW_ADDRESS 0