当前位置: 首页>>代码示例>>C++>>正文


C++ GET_OPCODE函数代码示例

本文整理汇总了C++中GET_OPCODE函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_OPCODE函数的具体用法?C++ GET_OPCODE怎么用?C++ GET_OPCODE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GET_OPCODE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: check_an_msg

//-1 error
//1  tc
//0 normal
//2 retry
int
check_an_msg(ushort flag, uchar * domain, int *bk)
{
    uint get = 0;
    flag = ntohs(flag);
    //printf("flag is 0x%x\n",flag);
    get = GET_QR(flag);
    if (get == QR_Q)            //query
    {
        printf("answer set Q sign\n");
        return -1;
    }
    get = GET_OPCODE(flag);     //ignore.
    get = GET_AA(flag);         //ignore
    get = GET_TC(flag);
    if (get == 1)
        return 1;               //tc
    get = GET_RD(flag);         //ignore
    get = GET_ERROR(flag);
    if ((get != 0) && (get != NAME_ERROR))      //soa
    {
        switch (get) {
        case SERVER_FAIL:
            //printf("2server fail\n");
            break;
            //case NAME_ERROR: SOA
            //*bk = 1;
            //printf("3name error\n");
            //break;
        case FORMAT_ERROR:
            //*bk = 1;
            //printf("1format error\n");
            break;
        case NOT_IMPL:
            //printf("4not implation\n");
            break;
        case REFUSED:
            //printf("5server refused\n");
            break;
        }
        return 2;
    }
    return 0;
}
开发者ID:han4235,项目名称:dnspod-sr,代码行数:48,代码来源:dns.c

示例2: findsetreg

/*
** try to find last instruction before 'lastpc' that modified register 'reg'
*/
static int findsetreg (Proto *p, int lastpc, int reg) {
  int pc;
  int setreg = -1;  /* keep last instruction that changed 'reg' */
  int jmptarget = 0;  /* any code before this address is conditional */
  for (pc = 0; pc < lastpc; pc++) {
    Instruction i = p->code[pc];
    OpCode op = GET_OPCODE(i);
    int a = GETARG_A(i);
    switch (op) {
      case OP_LOADNIL: {
        int b = GETARG_B(i);
        if (a <= reg && reg <= a + b)  /* set registers from 'a' to 'a+b' */
          setreg = filterpc(pc, jmptarget);
        break;
      }
      case OP_TFORCALL: {
        if (reg >= a + 2)  /* affect all regs above its base */
          setreg = filterpc(pc, jmptarget);
        break;
      }
      case OP_CALL:
      case OP_TAILCALL: {
        if (reg >= a)  /* affect all registers above base */
          setreg = filterpc(pc, jmptarget);
        break;
      }
      case OP_JMP: {
        int b = GETARG_sBx(i);
        int dest = pc + 1 + b;
        /* jump is forward and do not skip 'lastpc'? */
        if (pc < dest && dest <= lastpc) {
          if (dest > jmptarget)
            jmptarget = dest;  /* update 'jmptarget' */
        }
        break;
      }
      default:
        if (testAMode(op) && reg == a)  /* any instruction that set A */
          setreg = filterpc(pc, jmptarget);
        break;
    }
  }
  return setreg;
}
开发者ID:Ardakaniz,项目名称:NazaraEngine,代码行数:47,代码来源:ldebug.cpp

示例3: switch

llvm::Value* Logical::PerformIntOp(llvm::Value* a, llvm::Value* b) {
    auto name = "result";
    switch (GET_OPCODE(cs_.instr_)) {
        case OP_BAND:
            return cs_.B_.CreateAnd(a, b, name);
        case OP_BOR:
            return cs_.B_.CreateOr(a, b, name);
        case OP_BXOR:
            return cs_.B_.CreateXor(a, b, name);
        case OP_SHL:
            return cs_.CreateCall("luaV_shiftl", {a, b}, name);
        case OP_SHR:
            return cs_.CreateCall("luaV_shiftl", {a, cs_.B_.CreateNeg(b)}, name);
        default:
            break;
    }
    assert(false);
    return nullptr;
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:19,代码来源:llllogical.cpp

示例4: PrintCode

static void PrintCode(const Proto* tf)
{
 const Instruction* code=tf->code;
 const Instruction* p=code;
 for (;;)
 {
  int at=p-code+1;
  Instruction i=*p;
  int line=luaG_getline(tf->lineinfo,at-1,1,NULL);
  printf("%6d\t",at);
  if (line>=0) printf("[%d]\t",line); else printf("[-]\t");
  switch (GET_OPCODE(i)) {
#include "print.h"
  }
  printf("\n");
  if (i==OP_END) break;
  p++;
 }
}
开发者ID:jessicah,项目名称:Vision,代码行数:19,代码来源:print.c

示例5: luaK_patchlistaux

static void luaK_patchlistaux (FuncState *fs, int list, int target,
                               OpCode special, int special_target) {
  Instruction *code = fs->f->code;
  while (list != NO_JUMP) {
    int next = luaK_getjump(fs, list);
    Instruction *i = &code[list];
    OpCode op = GET_OPCODE(*i);
    if (op == special)  /* this `op' already has a value */
      luaK_fixjump(fs, list, special_target);
    else {
      luaK_fixjump(fs, list, target);  /* do the patch */
      if (op == OP_JMPONT)  /* remove eventual values */
        SET_OPCODE(*i, OP_JMPT);
      else if (op == OP_JMPONF)
        SET_OPCODE(*i, OP_JMPF);
    }
    list = next;
  }
}
开发者ID:xiaobinshe,项目名称:multitv,代码行数:19,代码来源:lcode.c

示例6: tws_dmamap_data_load_cbfn

static void
tws_dmamap_data_load_cbfn(void *arg, bus_dma_segment_t *segs,
                            int nseg, int error)
{

    struct tws_request *req = (struct tws_request *)arg;
    struct tws_softc *sc = req->sc;
    u_int16_t sgls = nseg;
    void *sgl_ptr;
    struct tws_cmd_generic *gcmd;

    if ( error == EFBIG )
        TWS_TRACE(sc, "not enough data segs", 0, nseg);


    if ( req->flags & TWS_DIR_IN )
        bus_dmamap_sync(req->sc->data_tag, req->dma_map,
                                            BUS_DMASYNC_PREREAD);
    if ( req->flags & TWS_DIR_OUT )
        bus_dmamap_sync(req->sc->data_tag, req->dma_map,
                                        BUS_DMASYNC_PREWRITE);
    if ( segs ) {
        if ( (req->type == TWS_PASSTHRU_REQ &&
             GET_OPCODE(req->cmd_pkt->cmd.pkt_a.res__opcode) !=
                            TWS_FW_CMD_EXECUTE_SCSI) ||
              req->type == TWS_GETSET_PARAM_REQ) {
            gcmd = &req->cmd_pkt->cmd.pkt_g.generic;
            sgl_ptr = (u_int32_t *)(gcmd) + gcmd->size;
            gcmd->size += sgls *
                          ((req->sc->is64bit && !tws_use_32bit_sgls) ? 4 :2 );
            tws_fill_sg_list(req->sc, segs, sgl_ptr, sgls);

        } else {
            tws_fill_sg_list(req->sc, segs,
                      (void *)req->cmd_pkt->cmd.pkt_a.sg_list, sgls);
            req->cmd_pkt->cmd.pkt_a.lun_h4__sgl_entries |= sgls ;
        }
    }


    req->error_code = tws_submit_command(req->sc, req);

}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:43,代码来源:tws_cam.c

示例7: findsetreg

/*
** try to find last instruction before 'lastpc' that modified register 'reg'
*/
static int findsetreg (Proto *p, int lastpc, int reg) {
  int pc;
  int setreg = -1;  /* keep last instruction that changed 'reg' */
  for (pc = 0; pc < lastpc; pc++) {
    Instruction i = p->code[pc];
    OpCode op = GET_OPCODE(i);
    int a = GETARG_A(i);
    switch (op) {
      case OP_LOADNIL: {
        int b = GETARG_B(i);
        if (a <= reg && reg <= a + b)  /* set registers from 'a' to 'a+b' */
          setreg = pc;
        break;
      }
      case OP_TFORCALL: {
        if (reg >= a + 2) setreg = pc;  /* affect all regs above its base */
        break;
      }
      case OP_CALL:
      case OP_TAILCALL: {
        if (reg >= a) setreg = pc;  /* affect all registers above base */
        break;
      }
      case OP_JMP: {
        int b = GETARG_sBx(i);
        int dest = pc + 1 + b;
        /* jump is forward and do not skip `lastpc'? */
        if (pc < dest && dest <= lastpc)
          pc += b;  /* do the jump */
        break;
      }
      case OP_TEST: {
        if (reg == a) setreg = pc;  /* jumped code can change 'a' */
        break;
      }
      default:
        if (testAMode(op) && reg == a)  /* any instruction that set A */
          setreg = pc;
        break;
    }
  }
  return setreg;
}
开发者ID:shitfSign,项目名称:lua4cn,代码行数:46,代码来源:ldebug.c

示例8: luaK_nil

/*
** Create a OP_LOADNIL instruction, but try to optimize: if the previous
** instruction is also OP_LOADNIL and ranges are compatible, adjust
** range of previous instruction instead of emitting a new one. (For
** instance, 'local a; local b' will generate a single opcode.)
*/
void luaK_nil (FuncState *fs, int from, int n) {
  Instruction *previous;
  int l = from + n - 1;  /* last register to set nil */
  if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
    previous = &fs->f->code[fs->pc-1];
    if (GET_OPCODE(*previous) == OP_LOADNIL) {  /* previous is LOADNIL? */
      int pfrom = GETARG_A(*previous);  /* get previous range */
      int pl = pfrom + GETARG_B(*previous);
      if ((pfrom <= from && from <= pl + 1) ||
          (from <= pfrom && pfrom <= l + 1)) {  /* can connect both? */
        if (pfrom < from) from = pfrom;  /* from = min(from, pfrom) */
        if (pl > l) l = pl;  /* l = max(l, pl) */
        SETARG_A(*previous, from);
        SETARG_B(*previous, l - from);
        return;
      }
    }  /* else go through */
  }
  luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0);  /* else no optimization */
}
开发者ID:celskeggs,项目名称:selkie,代码行数:26,代码来源:lcode.c

示例9: switch

llvm::Value* Arith::PerformIntOp(llvm::Value* lhs, llvm::Value* rhs) {
    auto name = "result";
    switch (GET_OPCODE(cs_.instr_)) {
        case OP_ADD:
            return cs_.B_.CreateAdd(lhs, rhs, name);
        case OP_SUB:
            return cs_.B_.CreateSub(lhs, rhs, name);
        case OP_MUL:
            return cs_.B_.CreateMul(lhs, rhs, name);
        case OP_MOD:
            return cs_.CreateCall("luaV_mod", {cs_.values_.state, lhs, rhs},
                    name);
        case OP_IDIV:
            return cs_.CreateCall("luaV_div", {cs_.values_.state, lhs, rhs},
                    name);
        default:
            break;
    }
    assert(false);
    return nullptr;
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:21,代码来源:lllarith.cpp

示例10: tgVM_exec

void tgVM_exec(tgState* T) {
  tgOpcode op;
  tgValue *base = T->stack;
  for (;;) {
    op = GET_OPCODE(T);
    switch (op) {
      case OP_ADDRR:
        arith_op(T, tgAdd);
        break;
      case OP_SUBRR:
        arith_op(T, tgSub);
        break;
      case OP_MULRR:
        arith_op(T, tgMul);
        break;
      case OP_DIVRR:
        arith_op(T, tgDiv);
        break;
    }
  }
}
开发者ID:smorimura,项目名称:tiger,代码行数:21,代码来源:tvm.c

示例11: luaK_nil

void luaK_nil (FuncState *fs, int from, int n) {
    Instruction *previous;
    if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
        if (fs->pc == 0) {  /* function start? */
            if (from >= fs->nactvar)
                return;  /* positions are already clean */
        } else {
            previous = &fs->f->code[fs->pc - 1];
            if (GET_OPCODE(*previous) == OP_LOADNIL) {
                int pfrom = GETARG_A(*previous);
                int pto = GETARG_B(*previous);
                if (pfrom <= from && from <= pto + 1) { /* can connect both? */
                    if (from + n - 1 > pto)
                        SETARG_B(*previous, from + n - 1);
                    return;
                }
            }
        }
    }
    luaK_codeABC(fs, OP_LOADNIL, from, from + n - 1, 0); /* else no optimization */
}
开发者ID:xiqingping,项目名称:embedded_template,代码行数:21,代码来源:lcode.c

示例12: OptConstants

static void OptConstants(Proto* tf)
{
 Instruction* p;
 int n=tf->nknum+tf->nkstr;
 Hash* map=luaH_new(L,n);
 int m=MapConstants(tf,map);
#ifdef DEBUG
 printf("%p n=%d m=%d %s\n",tf,n,m,(m==n)?"nothing to optimize":"yes!");
#endif
 if (m==n) return;
 for (p=tf->code;; p++)
 {
  Instruction i=*p;
  int op=GET_OPCODE(i);
  switch (op)
  {
   TObject o;
   int j,k;
   case OP_PUSHNUM: case OP_PUSHNEGNUM:
    j=GETARG_U(i);
    ttype(&o)=LUA_TNUMBER; nvalue(&o)=tf->knum[j];
    k=MapConstant(map,-1,&o);
    if (k!=j) *p=CREATE_U(op,k);
    break;
   case OP_PUSHSTRING: case OP_GETGLOBAL: case OP_GETDOTTED:
   case OP_PUSHSELF:   case OP_SETGLOBAL:
    j=GETARG_U(i);
    ttype(&o)=LUA_TSTRING; tsvalue(&o)=tf->kstr[j];
    k=MapConstant(map,-1,&o);
    if (k!=j) *p=CREATE_U(op,k);
    break;
   case OP_END:
    PackConstants(tf,map);
    luaH_free(L,map);
    return;
   default:
    break;
  }
 }
}
开发者ID:jessicah,项目名称:Vision,代码行数:40,代码来源:opt.c

示例13: ci_func

static const char *getobjname (CallInfo *ci, int stackpos, const char **name) {
    if (isLua(ci)) {  /* a Lua function? */
        Proto *p = ci_func(ci)->l.p;
        int pc = currentpc(ci);
        Instruction i;
        *name = luaF_getlocalname(p, stackpos+1, pc);
        if (*name)  /* is a local? */
            return "local";
        i = luaG_symbexec(p, pc, stackpos);  /* try symbolic execution */
        lua_assert(pc != -1);
        switch (GET_OPCODE(i)) {
        case OP_GETGLOBAL: {
            int g = GETARG_Bx(i);  /* global index */
            lua_assert(ttisstring(&p->k[g]));
            *name = svalue(&p->k[g]);
            return "global";
        }
        case OP_MOVE: {
            int a = GETARG_A(i);
            int b = GETARG_B(i);  /* move from `b' to `a' */
            if (b < a)
                return getobjname(ci, b, name);  /* get name for `b' */
            break;
        }
        case OP_GETTABLE: {
            int k = GETARG_C(i);  /* key index */
            *name = kname(p, k);
            return "field";
        }
        case OP_SELF: {
            int k = GETARG_C(i);  /* key index */
            *name = kname(p, k);
            return "method";
        }
        default:
            break;
        }
    }
    return NULL;  /* no useful name found */
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:40,代码来源:ldebug.c

示例14: TrObject_method

TrCallSite *TrVM::lookup(TrBlock *b, OBJ receiver, OBJ msg, TrInst *ip)
{
   TrVM *vm = this;
   
   OBJ method = TrObject_method(this, receiver, msg);
   
   TrInst *boing = (ip - 1);
   /* TODO: do not prealloc TrCallSite here, every one is a memory leak and a new
    one is created on polymorphic calls. */
   b->sites.emplace_back();
   TrCallSite *s = &b->sites.back();
   s->klass = TR_CLASS(receiver);
   s->miss = 0;
   s->method = method;
   s->message = msg;
   if (unlikely(method == TR_NIL))
   {
      s->method = TrObject_method(this, receiver, tr_intern("method_missing"));
      s->method_missing = 1;
   }
   
   /* Implement Monomorphic method cache by replacing the previous instruction (BOING)
    w/ CACHE that uses the CallSite to find the method instead of doing a full lookup. */
   if (GET_OPCODE(*boing) == TR_OP_CACHE)
   {
      /* Existing call site */
      /* TODO: maybe take existing call site hit miss into consideration to replace it with this one.
       For now, we just don't replace it, the first one is always the cached one. */
   }
   else
   {
      /* New call site, we cache it fo shizzly! */
      SET_OPCODE(*boing, TR_OP_CACHE);
      SETARG_A(*boing, GETARG_A(*ip)); /* receiver register */
      SETARG_B(*boing, 1); /* jmp */
      SETARG_C(*boing, b->sites.size()-1); /* CallSite index */
   }
   
   return s;
}
开发者ID:jtomschroeder,项目名称:tinyrb,代码行数:40,代码来源:vm.cpp

示例15: luaK_nil

/* Emit bytecode to set a range of registers to nil. */
void luaK_nil (FuncState *fs, int from, int n) {
  Instruction *previous;
  int l = from + n - 1;  /* last register to set nil */
  if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
    previous = &fs->f->code[fs->pc-1];
    if (GET_OPCODE(*previous) == OP_LOADNIL) { /* Try to merge with the previous instruction. */
      int pfrom = GETARG_A(*previous);
      int pl = pfrom + GETARG_B(*previous);
      if ((pfrom <= from && from <= pl + 1) ||
          (from <= pfrom && pfrom <= l + 1)) {  /* can connect both? */
        if (pfrom < from) from = pfrom;  /* from = min(from, pfrom) */
        if (pl > l) l = pl;  /* l = max(l, pl) */
        SETARG_A(*previous, from);
        DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set A to %d\n", fs->pc - 1, *previous, from));
        SETARG_B(*previous, l - from);
        DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set B to %d\n", fs->pc - 1, *previous, (l - from)));
        return;
      }
    }  /* else go through */
  }
  luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0);  /* else no optimization */
}
开发者ID:galek,项目名称:ravi,代码行数:23,代码来源:lcode.c


注:本文中的GET_OPCODE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。