📄 sparc.c
字号:
#include "c.h"
#define NODEPTR_TYPE Node
#define OP_LABEL(p) ((p)->op)
#define LEFT_CHILD(p) ((p)->kids[0])
#define RIGHT_CHILD(p) ((p)->kids[1])
#define STATE_LABEL(p) ((p)->x.state)
static void address(Symbol, Symbol, long);
static void blkfetch(int, int, int, int);
static void blkloop(int, int, int, int, int, int[]);
static void blkstore(int, int, int, int);
static void defaddress(Symbol);
static void defconst(int, int, Value);
static void defstring(int, char *);
static void defsymbol(Symbol);
static void doarg(Node);
static void emit2(Node);
static void export(Symbol);
static void clobber(Node);
static void function(Symbol, Symbol [], Symbol [], int);
static void global(Symbol);
static void import(Symbol);
static void local(Symbol);
static void progbeg(int, char **);
static void progend(void);
static void segment(int);
static void space(int);
static void target(Node);
static int imm(Node);
static void renameregs(void);
extern Interface sparcIR, solarisIR;
static void defsymbol2(Symbol);
static void export2(Symbol);
static void globalend(void);
static void global2(Symbol);
static void segment2(int);
static void progend2(void);
extern char *stabprefix;
extern void stabblock(int, int, Symbol*);
extern void stabend(Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *);
extern void stabfend(Symbol, int);
extern void stabinit(char *, int, char *[]);
extern void stabline(Coordinate *);
extern void stabsym(Symbol);
extern void stabtype(Symbol);
static Symbol greg[32], gregw;
static Symbol *oreg = &greg[8], *ireg = &greg[24];
static Symbol freg[32], freg2[32];
static Symbol fregw, freg2w;
static int regvars;
static int retstruct;
static int pflag = 0;
static int cseg;
/*
generated at Fri Aug 19 09:46:25 2005
by $Id: lburg.c,v 2.10 2002/03/08 18:45:21 drh Exp $
*/
static void _kids(NODEPTR_TYPE, int, NODEPTR_TYPE[]);
static void _label(NODEPTR_TYPE);
static int _rule(void*, int);
#define _stmt_NT 1
#define _reg_NT 2
#define _con_NT 3
#define _stk13_NT 4
#define _stk_NT 5
#define _con13_NT 6
#define _base_NT 7
#define _addr_NT 8
#define _addrl_NT 9
#define _spill_NT 10
#define _rc_NT 11
#define _rc5_NT 12
#define _addrg_NT 13
#define _call_NT 14
#define _rel_NT 15
static char *_ntname[] = {
0,
"stmt",
"reg",
"con",
"stk13",
"stk",
"con13",
"base",
"addr",
"addrl",
"spill",
"rc",
"rc5",
"addrg",
"call",
"rel",
0
};
struct _state {
short cost[16];
struct {
unsigned int _stmt:6;
unsigned int _reg:7;
unsigned int _con:4;
unsigned int _stk13:2;
unsigned int _stk:2;
unsigned int _con13:3;
unsigned int _base:3;
unsigned int _addr:3;
unsigned int _addrl:1;
unsigned int _spill:1;
unsigned int _rc:2;
unsigned int _rc5:2;
unsigned int _addrg:1;
unsigned int _call:2;
unsigned int _rel:4;
} rule;
};
static short _nts_0[] = { 0 };
static short _nts_1[] = { _reg_NT, 0 };
static short _nts_2[] = { _stk13_NT, 0 };
static short _nts_3[] = { _reg_NT, _con13_NT, 0 };
static short _nts_4[] = { _con13_NT, 0 };
static short _nts_5[] = { _base_NT, 0 };
static short _nts_6[] = { _reg_NT, _reg_NT, 0 };
static short _nts_7[] = { _stk_NT, 0 };
static short _nts_8[] = { _addr_NT, 0 };
static short _nts_9[] = { _addr_NT, _reg_NT, 0 };
static short _nts_10[] = { _addrl_NT, 0 };
static short _nts_11[] = { _addrl_NT, _reg_NT, 0 };
static short _nts_12[] = { _base_NT, _reg_NT, 0 };
static short _nts_13[] = { _spill_NT, _reg_NT, 0 };
static short _nts_14[] = { _con_NT, 0 };
static short _nts_15[] = { _reg_NT, _rc_NT, 0 };
static short _nts_16[] = { _reg_NT, _rc5_NT, 0 };
static short _nts_17[] = { _addrg_NT, 0 };
static short _nts_18[] = { _call_NT, 0 };
static short _nts_19[] = { _call_NT, _reg_NT, 0 };
static short _nts_20[] = { _rc_NT, _reg_NT, 0 };
static short _nts_21[] = { _rel_NT, 0 };
static short *_nts[] = {
0, /* 0 */
_nts_0, /* 1 */
_nts_0, /* 2 */
_nts_0, /* 3 */
_nts_0, /* 4 */
_nts_0, /* 5 */
_nts_0, /* 6 */
_nts_0, /* 7 */
_nts_0, /* 8 */
_nts_0, /* 9 */
_nts_0, /* 10 */
_nts_0, /* 11 */
_nts_0, /* 12 */
_nts_1, /* 13 */
_nts_1, /* 14 */
_nts_1, /* 15 */
_nts_1, /* 16 */
_nts_1, /* 17 */
_nts_1, /* 18 */
_nts_1, /* 19 */
_nts_1, /* 20 */
_nts_1, /* 21 */
_nts_1, /* 22 */
_nts_1, /* 23 */
_nts_1, /* 24 */
_nts_0, /* 25 */
_nts_0, /* 26 */
_nts_0, /* 27 */
_nts_0, /* 28 */
_nts_0, /* 29 */
_nts_0, /* 30 */
_nts_0, /* 31 */
_nts_0, /* 32 */
_nts_0, /* 33 */
_nts_0, /* 34 */
_nts_1, /* 35 */
_nts_0, /* 36 */
_nts_0, /* 37 */
_nts_0, /* 38 */
_nts_2, /* 39 */
_nts_0, /* 40 */
_nts_0, /* 41 */
_nts_0, /* 42 */
_nts_0, /* 43 */
_nts_0, /* 44 */
_nts_0, /* 45 */
_nts_0, /* 46 */
_nts_0, /* 47 */
_nts_0, /* 48 */
_nts_0, /* 49 */
_nts_0, /* 50 */
_nts_3, /* 51 */
_nts_3, /* 52 */
_nts_3, /* 53 */
_nts_1, /* 54 */
_nts_4, /* 55 */
_nts_2, /* 56 */
_nts_5, /* 57 */
_nts_6, /* 58 */
_nts_6, /* 59 */
_nts_6, /* 60 */
_nts_7, /* 61 */
_nts_8, /* 62 */
_nts_8, /* 63 */
_nts_8, /* 64 */
_nts_8, /* 65 */
_nts_8, /* 66 */
_nts_8, /* 67 */
_nts_8, /* 68 */
_nts_8, /* 69 */
_nts_9, /* 70 */
_nts_9, /* 71 */
_nts_9, /* 72 */
_nts_9, /* 73 */
_nts_9, /* 74 */
_nts_9, /* 75 */
_nts_9, /* 76 */
_nts_9, /* 77 */
_nts_0, /* 78 */
_nts_10, /* 79 */
_nts_11, /* 80 */
_nts_5, /* 81 */
_nts_12, /* 82 */
_nts_0, /* 83 */
_nts_13, /* 84 */
_nts_13, /* 85 */
_nts_13, /* 86 */
_nts_13, /* 87 */
_nts_13, /* 88 */
_nts_13, /* 89 */
_nts_13, /* 90 */
_nts_13, /* 91 */
_nts_13, /* 92 */
_nts_8, /* 93 */
_nts_8, /* 94 */
_nts_8, /* 95 */
_nts_8, /* 96 */
_nts_8, /* 97 */
_nts_8, /* 98 */
_nts_1, /* 99 */
_nts_1, /* 100 */
_nts_1, /* 101 */
_nts_1, /* 102 */
_nts_1, /* 103 */
_nts_1, /* 104 */
_nts_1, /* 105 */
_nts_0, /* 106 */
_nts_0, /* 107 */
_nts_0, /* 108 */
_nts_0, /* 109 */
_nts_0, /* 110 */
_nts_0, /* 111 */
_nts_0, /* 112 */
_nts_14, /* 113 */
_nts_4, /* 114 */
_nts_1, /* 115 */
_nts_15, /* 116 */
_nts_15, /* 117 */
_nts_15, /* 118 */
_nts_15, /* 119 */
_nts_15, /* 120 */
_nts_15, /* 121 */
_nts_15, /* 122 */
_nts_15, /* 123 */
_nts_15, /* 124 */
_nts_15, /* 125 */
_nts_15, /* 126 */
_nts_15, /* 127 */
_nts_0, /* 128 */
_nts_1, /* 129 */
_nts_16, /* 130 */
_nts_16, /* 131 */
_nts_16, /* 132 */
_nts_16, /* 133 */
_nts_15, /* 134 */
_nts_15, /* 135 */
_nts_15, /* 136 */
_nts_15, /* 137 */
_nts_15, /* 138 */
_nts_15, /* 139 */
_nts_1, /* 140 */
_nts_1, /* 141 */
_nts_1, /* 142 */
_nts_1, /* 143 */
_nts_1, /* 144 */
_nts_1, /* 145 */
_nts_1, /* 146 */
_nts_1, /* 147 */
_nts_1, /* 148 */
_nts_0, /* 149 */
_nts_17, /* 150 */
_nts_8, /* 151 */
_nts_0, /* 152 */
_nts_15, /* 153 */
_nts_15, /* 154 */
_nts_15, /* 155 */
_nts_15, /* 156 */
_nts_15, /* 157 */
_nts_15, /* 158 */
_nts_15, /* 159 */
_nts_15, /* 160 */
_nts_15, /* 161 */
_nts_15, /* 162 */
_nts_15, /* 163 */
_nts_15, /* 164 */
_nts_0, /* 165 */
_nts_8, /* 166 */
_nts_18, /* 167 */
_nts_18, /* 168 */
_nts_18, /* 169 */
_nts_18, /* 170 */
_nts_18, /* 171 */
_nts_18, /* 172 */
_nts_19, /* 173 */
_nts_1, /* 174 */
_nts_1, /* 175 */
_nts_1, /* 176 */
_nts_1, /* 177 */
_nts_1, /* 178 */
_nts_1, /* 179 */
_nts_1, /* 180 */
_nts_1, /* 181 */
_nts_1, /* 182 */
_nts_1, /* 183 */
_nts_15, /* 184 */
_nts_15, /* 185 */
_nts_15, /* 186 */
_nts_15, /* 187 */
_nts_20, /* 188 */
_nts_20, /* 189 */
_nts_6, /* 190 */
_nts_6, /* 191 */
_nts_6, /* 192 */
_nts_6, /* 193 */
_nts_6, /* 194 */
_nts_6, /* 195 */
_nts_6, /* 196 */
_nts_6, /* 197 */
_nts_1, /* 198 */
_nts_1, /* 199 */
_nts_1, /* 200 */
_nts_1, /* 201 */
_nts_1, /* 202 */
_nts_1, /* 203 */
_nts_1, /* 204 */
_nts_1, /* 205 */
_nts_6, /* 206 */
_nts_6, /* 207 */
_nts_6, /* 208 */
_nts_6, /* 209 */
_nts_6, /* 210 */
_nts_6, /* 211 */
_nts_6, /* 212 */
_nts_6, /* 213 */
_nts_6, /* 214 */
_nts_6, /* 215 */
_nts_6, /* 216 */
_nts_6, /* 217 */
_nts_21, /* 218 */
_nts_1, /* 219 */
_nts_1, /* 220 */
_nts_6, /* 221 */
};
static char *_templates[] = {
/* 0 */ 0,
/* 1 */ "# read register\n", /* reg: INDIRI1(VREGP) */
/* 2 */ "# read register\n", /* reg: INDIRU1(VREGP) */
/* 3 */ "# read register\n", /* reg: INDIRI2(VREGP) */
/* 4 */ "# read register\n", /* reg: INDIRU2(VREGP) */
/* 5 */ "# read register\n", /* reg: INDIRF4(VREGP) */
/* 6 */ "# read register\n", /* reg: INDIRI4(VREGP) */
/* 7 */ "# read register\n", /* reg: INDIRP4(VREGP) */
/* 8 */ "# read register\n", /* reg: INDIRU4(VREGP) */
/* 9 */ "# read register\n", /* reg: INDIRF8(VREGP) */
/* 10 */ "# read register\n", /* reg: INDIRI8(VREGP) */
/* 11 */ "# read register\n", /* reg: INDIRP8(VREGP) */
/* 12 */ "# read register\n", /* reg: INDIRU8(VREGP) */
/* 13 */ "# write register\n", /* stmt: ASGNI1(VREGP,reg) */
/* 14 */ "# write register\n", /* stmt: ASGNU1(VREGP,reg) */
/* 15 */ "# write register\n", /* stmt: ASGNI2(VREGP,reg) */
/* 16 */ "# write register\n", /* stmt: ASGNU2(VREGP,reg) */
/* 17 */ "# write register\n", /* stmt: ASGNF4(VREGP,reg) */
/* 18 */ "# write register\n", /* stmt: ASGNI4(VREGP,reg) */
/* 19 */ "# write register\n", /* stmt: ASGNP4(VREGP,reg) */
/* 20 */ "# write register\n", /* stmt: ASGNU4(VREGP,reg) */
/* 21 */ "# write register\n", /* stmt: ASGNF8(VREGP,reg) */
/* 22 */ "# write register\n", /* stmt: ASGNI8(VREGP,reg) */
/* 23 */ "# write register\n", /* stmt: ASGNP8(VREGP,reg) */
/* 24 */ "# write register\n", /* stmt: ASGNU8(VREGP,reg) */
/* 25 */ "%a", /* con: CNSTI1 */
/* 26 */ "%a", /* con: CNSTU1 */
/* 27 */ "%a", /* con: CNSTI2 */
/* 28 */ "%a", /* con: CNSTU2 */
/* 29 */ "%a", /* con: CNSTI4 */
/* 30 */ "%a", /* con: CNSTU4 */
/* 31 */ "%a", /* con: CNSTP4 */
/* 32 */ "%a", /* con: CNSTI8 */
/* 33 */ "%a", /* con: CNSTU8 */
/* 34 */ "%a", /* con: CNSTP8 */
/* 35 */ "", /* stmt: reg */
/* 36 */ "set %a,%%%c\n", /* reg: ADDRGP4 */
/* 37 */ "%a", /* stk13: ADDRFP4 */
/* 38 */ "%a", /* stk13: ADDRLP4 */
/* 39 */ "add %0,%%fp,%%%c\n", /* reg: stk13 */
/* 40 */ "set %a,%%%c\n", /* stk: ADDRFP4 */
/* 41 */ "set %a,%%%c\n", /* stk: ADDRLP4 */
/* 42 */ "set %a,%%%c\nadd %%%c,%%fp,%%%c\n", /* reg: ADDRFP4 */
/* 43 */ "set %a,%%%c\nadd %%%c,%%fp,%%%c\n", /* reg: ADDRLP4 */
/* 44 */ "%a", /* con13: CNSTI1 */
/* 45 */ "%a", /* con13: CNSTI2 */
/* 46 */ "%a", /* con13: CNSTI4 */
/* 47 */ "%a", /* con13: CNSTU1 */
/* 48 */ "%a", /* con13: CNSTU2 */
/* 49 */ "%a", /* con13: CNSTU4 */
/* 50 */ "%a", /* con13: CNSTP4 */
/* 51 */ "%%%0+%1", /* base: ADDI4(reg,con13) */
/* 52 */ "%%%0+%1", /* base: ADDP4(reg,con13) */
/* 53 */ "%%%0+%1", /* base: ADDU4(reg,con13) */
/* 54 */ "%%%0", /* base: reg */
/* 55 */ "%0", /* base: con13 */
/* 56 */ "%%fp+%0", /* base: stk13 */
/* 57 */ "%0", /* addr: base */
/* 58 */ "%%%0+%%%1", /* addr: ADDI4(reg,reg) */
/* 59 */ "%%%0+%%%1", /* addr: ADDP4(reg,reg) */
/* 60 */ "%%%0+%%%1", /* addr: ADDU4(reg,reg) */
/* 61 */ "%%fp+%%%0", /* addr: stk */
/* 62 */ "ldsb [%0],%%%c\n", /* reg: INDIRI1(addr) */
/* 63 */ "ldsh [%0],%%%c\n", /* reg: INDIRI2(addr) */
/* 64 */ "ld [%0],%%%c\n", /* reg: INDIRI4(addr) */
/* 65 */ "ldub [%0],%%%c\n", /* reg: INDIRU1(addr) */
/* 66 */ "lduh [%0],%%%c\n", /* reg: INDIRU2(addr) */
/* 67 */ "ld [%0],%%%c\n", /* reg: INDIRU4(addr) */
/* 68 */ "ld [%0],%%%c\n", /* reg: INDIRP4(addr) */
/* 69 */ "ld [%0],%%f%c\n", /* reg: INDIRF4(addr) */
/* 70 */ "stb %%%1,[%0]\n", /* stmt: ASGNI1(addr,reg) */
/* 71 */ "sth %%%1,[%0]\n", /* stmt: ASGNI2(addr,reg) */
/* 72 */ "st %%%1,[%0]\n", /* stmt: ASGNI4(addr,reg) */
/* 73 */ "stb %%%1,[%0]\n", /* stmt: ASGNU1(addr,reg) */
/* 74 */ "sth %%%1,[%0]\n", /* stmt: ASGNU2(addr,reg) */
/* 75 */ "st %%%1,[%0]\n", /* stmt: ASGNU4(addr,reg) */
/* 76 */ "st %%%1,[%0]\n", /* stmt: ASGNP4(addr,reg) */
/* 77 */ "st %%f%1,[%0]\n", /* stmt: ASGNF4(addr,reg) */
/* 78 */ "%%%fp+%a", /* addrl: ADDRLP4 */
/* 79 */ "ldd [%0],%%f%c\n", /* reg: INDIRF8(addrl) */
/* 80 */ "std %%f%1,[%0]\n", /* stmt: ASGNF8(addrl,reg) */
/* 81 */ "# ld2 [%0],%%f%c\n", /* reg: INDIRF8(base) */
/* 82 */ "# st2 %%f%1,[%0]\n", /* stmt: ASGNF8(base,reg) */
/* 83 */ "%a", /* spill: ADDRLP4 */
/* 84 */ "set %0,%%g1\nstb %%%1,[%%fp+%%g1]\n", /* stmt: ASGNI1(spill,reg) */
/* 85 */ "set %0,%%g1\nsth %%%1,[%%fp+%%g1]\n", /* stmt: ASGNI2(spill,reg) */
/* 86 */ "set %0,%%g1\nst %%%1,[%%fp+%%g1]\n", /* stmt: ASGNI4(spill,reg) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -