Lines Matching refs:D
52 #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) argument
90 dasm_State *D; in dasm_init() local
95 D = Dst_REF; in dasm_init()
96 D->psize = psz; in dasm_init()
97 D->lglabels = NULL; in dasm_init()
98 D->lgsize = 0; in dasm_init()
99 D->pclabels = NULL; in dasm_init()
100 D->pcsize = 0; in dasm_init()
101 D->globals = NULL; in dasm_init()
102 D->maxsection = maxsection; in dasm_init()
104 D->sections[i].buf = NULL; /* Need this for pass3. */ in dasm_init()
105 D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); in dasm_init()
106 D->sections[i].bsize = 0; in dasm_init()
107 D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ in dasm_init()
114 dasm_State *D = Dst_REF; in dasm_free() local
116 for (i = 0; i < D->maxsection; i++) in dasm_free()
117 if (D->sections[i].buf) in dasm_free()
118 DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); in dasm_free()
119 if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); in dasm_free()
120 if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); in dasm_free()
121 DASM_M_FREE(Dst, D, D->psize); in dasm_free()
127 dasm_State *D = Dst_REF; in dasm_setupglobal() local
128 D->globals = gl - 10; /* Negative bias to compensate for locals. */ in dasm_setupglobal()
129 DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); in dasm_setupglobal()
135 dasm_State *D = Dst_REF; in dasm_growpc() local
136 size_t osz = D->pcsize; in dasm_growpc()
137 DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); in dasm_growpc()
138 memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); in dasm_growpc()
144 dasm_State *D = Dst_REF; in dasm_setup() local
146 D->actionlist = (dasm_ActList)actionlist; in dasm_setup()
147 D->status = DASM_S_OK; in dasm_setup()
148 D->section = &D->sections[0]; in dasm_setup()
149 memset((void *)D->lglabels, 0, D->lgsize); in dasm_setup()
150 if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); in dasm_setup()
151 for (i = 0; i < D->maxsection; i++) { in dasm_setup()
152 D->sections[i].pos = DASM_SEC2POS(i); in dasm_setup()
153 D->sections[i].ofs = 0; in dasm_setup()
161 D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0)
163 do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
164 D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0)
222 dasm_State *D = Dst_REF; in dasm_put() local
223 dasm_ActList p = D->actionlist + start; in dasm_put()
224 dasm_Section *sec = D->section; in dasm_put()
249 n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); in dasm_put()
250 D->section = &D->sections[n]; goto stop; in dasm_put()
255 n = (ins & 2047) - 10; pl = D->lglabels + n; in dasm_put()
262 pl = D->pclabels + n; CKPL(pc, PC); in dasm_put()
280 pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; in dasm_put()
282 pl = D->pclabels + n; CKPL(pc, PC); in dasm_put()
285 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; in dasm_put()
350 dasm_State *D = Dst_REF; in dasm_link() local
356 if (D->status != DASM_S_OK) return D->status; in dasm_link()
359 for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) in dasm_link()
360 if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; in dasm_link()
366 for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) { in dasm_link()
367 int n = D->lglabels[idx]; in dasm_link()
369 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } in dasm_link()
374 for (secnum = 0; secnum < D->maxsection; secnum++) { in dasm_link()
375 dasm_Section *sec = D->sections + secnum; in dasm_link()
381 dasm_ActList p = D->actionlist + b[pos++]; in dasm_link()
402 D->codesize = ofs; /* Total size of all code sections */ in dasm_link()
409 do { if (!(x) && !(n = DASM_ADD_VENEER(D, buffer, ins, b, cp, o))) \
410 return DASM_S_RANGE_REL|(p-D->actionlist-1); \
418 do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0)
426 dasm_State *D = Dst_REF; in dasm_encode() local
432 for (secnum = 0; secnum < D->maxsection; secnum++) { in dasm_encode()
433 dasm_Section *sec = D->sections + secnum; in dasm_encode()
438 dasm_ActList p = D->actionlist + *b++; in dasm_encode()
454 ptrdiff_t na = (ptrdiff_t)D->globals[-n] - (ptrdiff_t)cp + 4; in dasm_encode()
462 n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) + 4; in dasm_encode()
497 ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); in dasm_encode()
534 if (base + D->codesize != (char *)cp) /* Check for phase errors. */ in dasm_encode()
543 dasm_State *D = Dst_REF; in dasm_getpclabel() local
544 if (pc*sizeof(int) < D->pcsize) { in dasm_getpclabel()
545 int pos = D->pclabels[pc]; in dasm_getpclabel()
546 if (pos < 0) return *DASM_POS2PTR(D, -pos); in dasm_getpclabel()
556 dasm_State *D = Dst_REF; in dasm_checkstep() local
557 if (D->status == DASM_S_OK) { in dasm_checkstep()
560 if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } in dasm_checkstep()
561 D->lglabels[i] = 0; in dasm_checkstep()
564 if (D->status == DASM_S_OK && secmatch >= 0 && in dasm_checkstep()
565 D->section != &D->sections[secmatch]) in dasm_checkstep()
566 D->status = DASM_S_MATCH_SEC|(D->section-D->sections); in dasm_checkstep()
567 return D->status; in dasm_checkstep()