Lines Matching refs:D
48 #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) argument
89 dasm_State *D; in dasm_init() local
94 D = Dst_REF; in dasm_init()
95 D->psize = psz; in dasm_init()
96 D->lglabels = NULL; in dasm_init()
97 D->lgsize = 0; in dasm_init()
98 D->pclabels = NULL; in dasm_init()
99 D->pcsize = 0; in dasm_init()
100 D->globals = NULL; in dasm_init()
101 D->maxsection = maxsection; in dasm_init()
103 D->sections[i].buf = NULL; /* Need this for pass3. */ in dasm_init()
104 D->sections[i].rbuf = DASM_PTR_SUB(D->sections[i].buf, DASM_SEC2POS(i)); in dasm_init()
105 D->sections[i].bsize = 0; in dasm_init()
106 D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ in dasm_init()
113 dasm_State *D = Dst_REF; in dasm_free() local
115 for (i = 0; i < D->maxsection; i++) in dasm_free()
116 if (D->sections[i].buf) in dasm_free()
117 DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); in dasm_free()
118 if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); in dasm_free()
119 if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); in dasm_free()
120 DASM_M_FREE(Dst, D, D->psize); in dasm_free()
126 dasm_State *D = Dst_REF; in dasm_setupglobal() local
127 D->globals = gl - 10; /* Negative bias to compensate for locals. */ in dasm_setupglobal()
128 DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); in dasm_setupglobal()
134 dasm_State *D = Dst_REF; in dasm_growpc() local
135 size_t osz = D->pcsize; in dasm_growpc()
136 DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); in dasm_growpc()
137 memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); in dasm_growpc()
143 dasm_State *D = Dst_REF; in dasm_setup() local
145 D->actionlist = (dasm_ActList)actionlist; in dasm_setup()
146 D->status = DASM_S_OK; in dasm_setup()
147 D->section = &D->sections[0]; in dasm_setup()
148 memset((void *)D->lglabels, 0, D->lgsize); in dasm_setup()
149 if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); in dasm_setup()
150 for (i = 0; i < D->maxsection; i++) { in dasm_setup()
151 D->sections[i].pos = DASM_SEC2POS(i); in dasm_setup()
152 D->sections[i].ofs = 0; in dasm_setup()
160 D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0)
162 do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
163 D->status=DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0)
173 dasm_State *D = Dst_REF; in dasm_put() local
174 dasm_ActList p = D->actionlist + start; in dasm_put()
175 dasm_Section *sec = D->section; in dasm_put()
226 n = *p++; pl = D->lglabels + n; in dasm_put()
234 case DASM_IMM_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); in dasm_put()
249 case DASM_LABEL_LG: pl = D->lglabels + *p++; CKPL(lg, LG); goto putlabel; in dasm_put()
250 case DASM_LABEL_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); in dasm_put()
253 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } in dasm_put()
265 n = *p; CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; in dasm_put()
280 dasm_State *D = Dst_REF; in dasm_link() local
286 if (D->status != DASM_S_OK) return D->status; in dasm_link()
289 for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) in dasm_link()
290 if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; in dasm_link()
296 for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) { in dasm_link()
297 int n = D->lglabels[idx]; in dasm_link()
299 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } in dasm_link()
304 for (secnum = 0; secnum < D->maxsection; secnum++) { in dasm_link()
305 dasm_Section *sec = D->sections + secnum; in dasm_link()
311 dasm_ActList p = D->actionlist + b[pos++]; in dasm_link()
321 lofs = *DASM_POS2PTR(D, lpos); in dasm_link()
325 lofs += D->sections[i].ofs; in dasm_link()
356 D->codesize = ofs; /* Total size of all code sections */ in dasm_link()
380 dasm_State *D = Dst_REF; in dasm_encode() local
386 for (secnum = 0; secnum < D->maxsection; secnum++) { in dasm_encode()
387 dasm_Section *sec = D->sections + secnum; in dasm_encode()
392 dasm_ActList p = D->actionlist + *b++; in dasm_encode()
434 b++; n = (int)(ptrdiff_t)D->globals[-n]; in dasm_encode()
438 int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; } in dasm_encode()
445 p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; } in dasm_encode()
447 int *pb = DASM_POS2PTR(D, n); in dasm_encode()
454 dasmq((ptrdiff_t)D->globals[-n]); in dasm_encode()
457 int *pb = DASM_POS2PTR(D, n); in dasm_encode()
464 D->globals[idx] = (void *)(base + (*p == DASM_SETLABEL ? *b : n)); in dasm_encode()
484 if (base + D->codesize != cp) /* Check for phase errors. */ in dasm_encode()
492 dasm_State *D = Dst_REF; in dasm_getpclabel() local
493 if (pc*sizeof(int) < D->pcsize) { in dasm_getpclabel()
494 int pos = D->pclabels[pc]; in dasm_getpclabel()
495 if (pos < 0) return *DASM_POS2PTR(D, -pos); in dasm_getpclabel()
505 dasm_State *D = Dst_REF; in dasm_checkstep() local
506 if (D->status == DASM_S_OK) { in dasm_checkstep()
509 if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_L|i; break; } in dasm_checkstep()
510 D->lglabels[i] = 0; in dasm_checkstep()
513 if (D->status == DASM_S_OK && secmatch >= 0 && in dasm_checkstep()
514 D->section != &D->sections[secmatch]) in dasm_checkstep()
515 D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections); in dasm_checkstep()
516 return D->status; in dasm_checkstep()