void StartBBlock(BBlock bb) { IRInst lasti; CurrentBB->next = bb; bb->prev = CurrentBB; lasti = CurrentBB->insth.prev; if (lasti->opcode != JMP && lasti->opcode != IJMP) { DrawCFGEdge(CurrentBB, bb); } CurrentBB = bb; }
void GenerateJump(BBlock dstBB) { IRInst inst; ALLOC(inst); dstBB->ref++; DrawCFGEdge(CurrentBB, dstBB); inst->ty = T(VOID); inst->opcode = JMP; inst->opds[0] = (Symbol)dstBB; inst->opds[1] = inst->opds[2] = NULL; AppendInst(inst); }
void GenerateBranch(Type ty, BBlock dstBB, int opcode, Symbol src1, Symbol src2) { IRInst inst; ALLOC(inst); dstBB->ref++; src1->ref++; if (src2) src2->ref++; DrawCFGEdge(CurrentBB, dstBB); inst->ty = ty; inst->opcode = opcode; inst->opds[0] = (Symbol)dstBB; inst->opds[1] = src1; inst->opds[2] = src2; AppendInst(inst); }
/* 将bb 设置成当前块 */ void StartBBlock (BBlock bb) { IRInst lasti; /* 链接到基本块 */ CurrentBB->next = bb; bb->prev = CurrentBB; /* 当前基本块的上一条指令 */ lasti = CurrentBB->insth.prev; if (lasti->opcode != JMP && lasti->opcode != IJMP) { DrawCFGEdge (CurrentBB, bb); } /* 改变当前块的位置 */ CurrentBB = bb; }
void GenerateIndirectJump(BBlock *dstBBs, int len, Symbol index) { IRInst inst; int i; ALLOC(inst); index->ref++; for (i = 0; i < len; ++i) { dstBBs[i]->ref++; DrawCFGEdge(CurrentBB, dstBBs[i]); } inst->ty = T(VOID); inst->opcode = IJMP; inst->opds[0] = (Symbol)dstBBs; inst->opds[1] = index; inst->opds[2] = NULL; AppendInst(inst); }