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()
233 case DASM_IMM_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); in dasm_put()
251 case DASM_LABEL_LG: pl = D->lglabels + *p++; CKPL(lg, LG); goto putlabel; in dasm_put()
252 case DASM_LABEL_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); in dasm_put()
255 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } in dasm_put()
267 n = *p; CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; in dasm_put()
282 dasm_State *D = Dst_REF; in dasm_link() local
288 if (D->status != DASM_S_OK) return D->status; in dasm_link()
291 for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) in dasm_link()
292 if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; in dasm_link()
298 for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) { in dasm_link()
299 int n = D->lglabels[idx]; in dasm_link()
301 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } in dasm_link()
306 for (secnum = 0; secnum < D->maxsection; secnum++) { in dasm_link()
307 dasm_Section *sec = D->sections + secnum; in dasm_link()
313 dasm_ActList p = D->actionlist + b[pos++]; in dasm_link()
325 lofs = *DASM_POS2PTR(D, lpos); in dasm_link()
329 lofs += D->sections[i].ofs; in dasm_link()
362 D->codesize = ofs; /* Total size of all code sections */ in dasm_link()
396 dasm_State *D = Dst_REF; in dasm_encode() local
402 for (secnum = 0; secnum < D->maxsection; secnum++) { in dasm_encode()
403 dasm_Section *sec = D->sections + secnum; in dasm_encode()
408 dasm_ActList p = D->actionlist + *b++; in dasm_encode()
453 b++; n = (int)(ptrdiff_t)D->globals[-n]; in dasm_encode()
459 int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; } in dasm_encode()
467 if (n < 0) { dasma((ptrdiff_t)D->globals[-n]); break; } in dasm_encode()
470 int *pb = DASM_POS2PTR(D, n); in dasm_encode()
477 D->globals[idx] = (void *)(base + (*p == DASM_SETLABEL ? *b : n)); in dasm_encode()
498 if (base + D->codesize != cp) /* Check for phase errors. */ in dasm_encode()
506 dasm_State *D = Dst_REF; in dasm_getpclabel() local
507 if (pc*sizeof(int) < D->pcsize) { in dasm_getpclabel()
508 int pos = D->pclabels[pc]; in dasm_getpclabel()
509 if (pos < 0) return *DASM_POS2PTR(D, -pos); in dasm_getpclabel()
519 dasm_State *D = Dst_REF; in dasm_checkstep() local
520 if (D->status == DASM_S_OK) { in dasm_checkstep()
523 if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_L|i; break; } in dasm_checkstep()
524 D->lglabels[i] = 0; in dasm_checkstep()
527 if (D->status == DASM_S_OK && secmatch >= 0 && in dasm_checkstep()
528 D->section != &D->sections[secmatch]) in dasm_checkstep()
529 D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections); in dasm_checkstep()
530 return D->status; in dasm_checkstep()