static void p_compile(Filter *f) { if(f->op == '='){ compile_cmp(aoe.name, f, p_fields); return; } sysfatal("unknown aoe field: %s", f->s); }
static void p_compile(Filter *f) { Mux *m; if(f->op == '='){ compile_cmp(ip6.name, f, p_fields); return; } for(m = p_mux; m->name != nil; m++) if(strcmp(f->s, m->name) == 0){ f->pr = m->pr; f->ulv = m->val; f->subop = Ot; return; } sysfatal("unknown ip6 field or protocol: %s", f->s); }
static void p_compile(Filter *f) { Mux *m; if(f->op == '='){ compile_cmp(aoerr.name, f, p_fields); return; } for(m = p_mux; m->name; m++) if(strcmp(f->s, m->name) == 0){ f->pr = m->pr; f->ulv = m->val; f->subop = Ocmd; return; } sysfatal("unknown aoemask field: %s", f->s); }
bool assembler::compile_next(asmgen & asg, const func_binary & fb) { command cmd = GET_CMD(fb, m_pos); int type = COMMAND_TYPE(cmd); int code = COMMAND_CODE(cmd); USE(type); FKLOG("[assembler] compile_next cmd %d %d %s", type, code, OpCodeStr(code)); assert (type == COMMAND_OPCODE); m_pos++; m_conposnum = 0; memset(m_conpos, 0, sizeof(m_conpos)); bool ret = false; USE(ret); // 执行对应命令,放一起switch效率更高,cpu有缓存 switch (code) { case OPCODE_ASSIGN: { ret = compile_assign(asg, fb, cmd); } break; case OPCODE_RETURN: { ret = compile_return(asg, fb, cmd); } break; case OPCODE_PLUS: case OPCODE_MINUS: case OPCODE_MULTIPLY: case OPCODE_DIVIDE: case OPCODE_DIVIDE_MOD: { ret = compile_math(asg, fb, cmd); } break; case OPCODE_PLUS_ASSIGN: case OPCODE_MINUS_ASSIGN: case OPCODE_MULTIPLY_ASSIGN: case OPCODE_DIVIDE_ASSIGN: case OPCODE_DIVIDE_MOD_ASSIGN: { ret = compile_math_assign(asg, fb, cmd); } break; case OPCODE_AND: case OPCODE_OR: case OPCODE_LESS: case OPCODE_MORE: case OPCODE_EQUAL: case OPCODE_MOREEQUAL: case OPCODE_LESSEQUAL: case OPCODE_NOTEQUAL: { ret = compile_cmp(asg, fb, cmd); } break; case OPCODE_AND_JNE: case OPCODE_OR_JNE: case OPCODE_LESS_JNE: case OPCODE_MORE_JNE: case OPCODE_EQUAL_JNE: case OPCODE_MOREEQUAL_JNE: case OPCODE_LESSEQUAL_JNE: case OPCODE_NOTEQUAL_JNE: { ret = compile_cmp_jne(asg, fb, cmd); } break; case OPCODE_NOT: { ret = compile_single(asg, fb, cmd); } break; case OPCODE_NOT_JNE: { ret = compile_single_jne(asg, fb, cmd); } break; case OPCODE_JNE: { ret = compile_jne(asg, fb, cmd); } break; case OPCODE_JMP: { ret = compile_jmp(asg, fb, cmd); } break; case OPCODE_CALL: { ret = compile_call(asg, fb, cmd); } break; case OPCODE_SLEEP: case OPCODE_YIELD: { setwarn(m_fk, "assembler only support SLEEP or YIELD, skip code"); ret = true; m_pos++; } break; case OPCODE_FORBEGIN: case OPCODE_FORLOOP: { FKERR("assembler dont support for i -> n, j"); compile_seterror(fb, cmd, efk_jit_error, "assembler dont support for i -> n, j"); return false; } break; default: assert(0); FKERR("[assembler] compile_next err code %d %s", code, OpCodeStr(code)); compile_seterror(fb, cmd, efk_jit_error, "compile_next err code %d %s", code, OpCodeStr(code)); return false; } return ret; }