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


C++ emit_label函数代码示例

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


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

示例1: emit_format

void emit_format(){
	emit_label(".DEC");//emit format of integer.
	emit_ascii("%d\\n");
	
	//fprintf(fp,"    .ascii \"%%d\\n\\0\"\n");
	emit_label(".HEX");
	emit_ascii("0x%X\\n");
	//fprintf(fp,"    .ascii \"%%X\\n\\0\"\n");
}
开发者ID:noppadet008,项目名称:noobPrinterLangCompiler,代码行数:9,代码来源:asmX86emiter.c

示例2: emitstmt

void emitstmt(void* stmt){
	Syntax *st = (Syntax*) stmt;
	if(st->type == IF_STATEMENT){
		int label = labelconditionid++;
		char c[10];
		emit_condition(st->if_statement->condition,label);
		emitblock(st->if_statement->then);
		sprintf(c,".LC%d",label);
		emit_label(c);
	}else if(st->type == WHILE_SYNTAX){
		int labelcondition,labelblock;
		labelcondition = labelconditionid++;
		labelblock = labelconditionid++;
		char c[10];
		emit_instr_format("jmp",".LC%d",labelcondition);//to check condition
		sprintf(c,".LC%d",labelblock);
		emit_label(c);
		emitblock(st->while_statement->body);
		sprintf(c,".LC%d",labelcondition);
		emit_label(c);
		emit_condition(st->while_statement->condition,labelblock);
	}else if(st->type == PRINT_STATEMENT){
		emit_instr_format("leaq","%s(%%rip), %%rcx",st->printstmt->tag);
		emit_ins("call","printf");
	}else if(st->type == PRINTDEC_STATEMENT){
		emit_expression(st->printexp->exp);
		emit_ins("movq","%%rax, %%rdx");
		emit_ins("leaq",".DEC(%%rip), %%rcx");//.DEC print dec format
		emit_ins("call","printf");
	}else if(st->type == PRINTHEX_STATEMENT){
		emit_expression(st->printexp->exp);
		emit_ins("movq","%%rax, %%rdx");
		emit_ins("leaq",".HEX(%%rip), %%rcx");//.HEX print hex format
		emit_ins("call","printf");
	}else if(st->type == ASSIGNMENT){
		int tempoffset = findOffsetVar(st->assignment->var_name);//not found is -1
		if(tempoffset == -1){
			OffsetVarmap* temp = (OffsetVarmap*)malloc(sizeof(OffsetVarmap));
			temp->varname = st->assignment->var_name;
			temp->offset = offset;
			tempoffset = offset;
			//printf("offset %d \n",offset);
			offset = offset+8;
			list_push(tablevar,temp);
		}
		emit_expression(st->assignment->expression);
		emit_instr_format("movq","%%rax, -%d(%%rbp)",tempoffset);//result to variable.
	}else if(st->type == VARIABLE){
		OffsetVarmap *temp = (OffsetVarmap*)malloc(sizeof(OffsetVarmap));
		temp->varname = st->variable->var_name;
		temp->offset = offset;
		offset = offset+8;
		list_push(tablevar,temp);
	}else{
		fprintf(fp,"statement error");
	}
}
开发者ID:noppadet008,项目名称:noobPrinterLangCompiler,代码行数:57,代码来源:asmX86emiter.c

示例3: emit_literal

static void emit_literal(Node *node) {
    SAVE;
    switch (node->ty->kind) {
    case KIND_BOOL:
    case KIND_CHAR:
    case KIND_SHORT:
        emit("mov $%u, #rax", node->ival);
        break;
    case KIND_INT:
        emit("mov $%u, #rax", node->ival);
        break;
    case KIND_LONG:
    case KIND_LLONG: {
        emit("mov $%lu, #rax", node->ival);
        break;
    }
    case KIND_FLOAT: {
        if (!node->flabel) {
            node->flabel = make_label();
            float fval = node->fval;
            emit_noindent(".data");
            emit_label(node->flabel);
            emit(".long %d", *(uint32_t *)&fval);
            emit_noindent(".text");
        }
        emit("movss %s(#rip), #xmm0", node->flabel);
        break;
    }
    case KIND_DOUBLE:
    case KIND_LDOUBLE: {
        if (!node->flabel) {
            node->flabel = make_label();
            emit_noindent(".data");
            emit_label(node->flabel);
            emit(".quad %lu", *(uint64_t *)&node->fval);
            emit_noindent(".text");
        }
        emit("movsd %s(#rip), #xmm0", node->flabel);
        break;
    }
    case KIND_ARRAY: {
        if (!node->slabel) {
            node->slabel = make_label();
            emit_noindent(".data");
            emit_label(node->slabel);
            emit(".string \"%s\"", quote_cstring_len(node->sval, node->ty->size));
            emit_noindent(".text");
        }
        emit("lea %s(#rip), #rax", node->slabel);
        break;
    }
    default:
        error("internal error");
    }
}
开发者ID:4ker,项目名称:8cc,代码行数:55,代码来源:gen.c

示例4: gen_mod_pow2

/* Generate code for transformation 2 (with MODE and OPERATION, operands OP1
   and OP2, result TARGET and probability of taking the optimal path PROB).  */
static rtx
gen_mod_pow2 (enum machine_mode mode, enum rtx_code operation, rtx target,
	      rtx op1, rtx op2, int prob)
{
  rtx tmp, tmp1, tmp2, tmp3, jump;
  rtx neq_label = gen_label_rtx ();
  rtx end_label = gen_label_rtx ();
  rtx sequence;

  start_sequence ();
  
  if (!REG_P (op2))
    {
      tmp = gen_reg_rtx (mode);
      emit_move_insn (tmp, copy_rtx (op2));
    }
  else
    tmp = op2;

  tmp1 = expand_simple_binop (mode, PLUS, tmp, constm1_rtx, NULL_RTX,
			      0, OPTAB_WIDEN);
  tmp2 = expand_simple_binop (mode, AND, tmp, tmp1, NULL_RTX,
			      0, OPTAB_WIDEN);
  do_compare_rtx_and_jump (tmp2, const0_rtx, NE, 0, mode, NULL_RTX,
			   NULL_RTX, neq_label);

  /* Add branch probability to jump we just created.  */
  jump = get_last_insn ();
  REG_NOTES (jump) = gen_rtx_EXPR_LIST (REG_BR_PROB,
					GEN_INT (REG_BR_PROB_BASE - prob),
					REG_NOTES (jump));

  tmp3 = expand_simple_binop (mode, AND, op1, tmp1, target,
			      0, OPTAB_WIDEN);
  if (tmp3 != target)
    emit_move_insn (copy_rtx (target), tmp3);
  emit_jump_insn (gen_jump (end_label));
  emit_barrier ();

  emit_label (neq_label);
  tmp1 = simplify_gen_binary (operation, mode, copy_rtx (op1), copy_rtx (tmp));
  tmp1 = force_operand (tmp1, target);
  if (tmp1 != target)
    emit_move_insn (target, tmp1);
  
  emit_label (end_label);

  sequence = get_insns ();
  end_sequence ();
  rebuild_jump_labels (sequence);
  return sequence;
}
开发者ID:DJHartley,项目名称:iphone-dev,代码行数:54,代码来源:value-prof.c

示例5: gen_divmod_fixed_value

/* Generate code for transformation 1 (with MODE and OPERATION, operands OP1
   and OP2, whose value is expected to be VALUE, result TARGET and
   probability of taking the optimal path PROB).  */
static rtx
gen_divmod_fixed_value (enum machine_mode mode, enum rtx_code operation,
			rtx target, rtx op1, rtx op2, gcov_type value,
			int prob)
{
  rtx tmp, tmp1, jump;
  rtx neq_label = gen_label_rtx ();
  rtx end_label = gen_label_rtx ();
  rtx sequence;

  start_sequence ();
  
  if (!REG_P (op2))
    {
      tmp = gen_reg_rtx (mode);
      emit_move_insn (tmp, copy_rtx (op2));
    }
  else
    tmp = op2;

  do_compare_rtx_and_jump (tmp, GEN_INT (value), NE, 0, mode, NULL_RTX,
			   NULL_RTX, neq_label);

  /* Add branch probability to jump we just created.  */
  jump = get_last_insn ();
  REG_NOTES (jump) = gen_rtx_EXPR_LIST (REG_BR_PROB,
					GEN_INT (REG_BR_PROB_BASE - prob),
					REG_NOTES (jump));

  tmp1 = simplify_gen_binary (operation, mode,
			      copy_rtx (op1), GEN_INT (value));
  tmp1 = force_operand (tmp1, target);
  if (tmp1 != target)
    emit_move_insn (copy_rtx (target), copy_rtx (tmp1));

  emit_jump_insn (gen_jump (end_label));
  emit_barrier ();

  emit_label (neq_label);
  tmp1 = simplify_gen_binary (operation, mode,
			      copy_rtx (op1), copy_rtx (tmp));
  tmp1 = force_operand (tmp1, target);
  if (tmp1 != target)
    emit_move_insn (copy_rtx (target), copy_rtx (tmp1));
  
  emit_label (end_label);

  sequence = get_insns ();
  end_sequence ();
  rebuild_jump_labels (sequence);
  return sequence;
}
开发者ID:DJHartley,项目名称:iphone-dev,代码行数:55,代码来源:value-prof.c

示例6: while_stmt

static
while_stmt(stream, node, brk, cont, ret) {
    cont = new_label();
    emit_label( stream, cont );

    expr_code( stream, node[3], 0 );
    brk = new_label();
    branch_ifz( stream, brk );

    stmt_code( stream, node[4], brk, cont, ret );
    branch( stream, cont );
    emit_label( stream, brk );
}
开发者ID:ras52,项目名称:bootstrap,代码行数:13,代码来源:codegen.c

示例7: emit_do

static void emit_do(Node *node) {
    SAVE;
    char *begin = make_label();
    char *end = make_label();
    SET_JUMP_LABELS(end, begin);
    emit_label(begin);
    if (node->forbody)
        emit_expr(node->forbody);
    emit_expr(node->forcond);
    emit_je(end);
    emit_jmp(begin);
    emit_label(end);
    RESTORE_JUMP_LABELS();
}
开发者ID:irori,项目名称:8cc,代码行数:14,代码来源:gen.c

示例8: emit_switch

static void emit_switch(Node *node) {
    SAVE;
    char *oswitch = lswitch, *obreak = lbreak;
    emit_expr(node->switchexpr);
    lswitch = make_label();
    lbreak = make_label();
    emit_jmp(lswitch);
    if (node->switchbody)
        emit_expr(node->switchbody);
    emit_label(lswitch);
    emit_label(lbreak);
    lswitch = oswitch;
    lbreak = obreak;
}
开发者ID:irori,项目名称:8cc,代码行数:14,代码来源:gen.c

示例9: conditional

static
conditional(stream, node) {
    auto l1 = new_label(), l2 = new_label();

    expr_code( stream, node[3], 0 );

    branch_ifz( stream, l1 );
    expr_code( stream, node[4], 0 );
    branch( stream, l2 );
    
    emit_label( stream, l1 );
    expr_code( stream, node[5], 0 );
    emit_label( stream, l2 );
}
开发者ID:ras52,项目名称:bootstrap,代码行数:14,代码来源:codegen.c

示例10: do_stmt

static
do_stmt(stream, node, brk, cont, ret) {
    auto start = new_label();
    emit_label( stream, start );

    cont = new_label();
    brk = new_label();
    
    stmt_code( stream, node[3], brk, cont, ret );

    emit_label( stream, cont );
    expr_code( stream, node[4], 0 );
    branch_ifnz( stream, start );
    emit_label( stream, brk );
}
开发者ID:ras52,项目名称:bootstrap,代码行数:15,代码来源:codegen.c

示例11: switch_stmt

static
switch_stmt(stream, node, brk, cont, ret) {
    auto i = 0, def;
    expr_code( stream, node[3], 0 );
    def = brk = new_label();

    if (node[5][0] != 'swtb')
        int_error("No table for switch statement");

    while ( i < node[5][1] ) {
        auto c = node[5][3 + i++];

        /* Make asm labels for each case label.  We store these as integers 
         * in the unused 3rd operator slot of the case node. */
        c[5] = new_label();

        if (c[0] == 'case')
            /* Case labels have to be integers */
            branch_eq_n( stream, c[3][3], c[5] );
        else 
            def = c[5];
    }
    
    branch( stream, def ); 
    stmt_code( stream, node[4], brk, cont, ret );
    emit_label( stream, brk );
}
开发者ID:ras52,项目名称:bootstrap,代码行数:27,代码来源:codegen.c

示例12: case_stmt

static
case_stmt(stream, node, brk, cont, ret) {
    /* The case labels were written into the unused 3rd operator slot of 
     * the case node by switch_stmt(), below. */
    emit_label( stream, node[5] );
    stmt_code( stream, node[4], brk, cont, ret );
}
开发者ID:ras52,项目名称:bootstrap,代码行数:7,代码来源:codegen.c

示例13: do_jump_by_parts_equality_rtx

static void
do_jump_by_parts_equality_rtx (enum machine_mode mode, rtx op0, rtx op1,
			       rtx if_false_label, rtx if_true_label, int prob)
{
  int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  rtx drop_through_label = 0;
  int i;

  if (op1 == const0_rtx)
    {
      do_jump_by_parts_zero_rtx (mode, op0, if_false_label, if_true_label,
				 prob);
      return;
    }
  else if (op0 == const0_rtx)
    {
      do_jump_by_parts_zero_rtx (mode, op1, if_false_label, if_true_label,
				 prob);
      return;
    }

  if (! if_false_label)
    drop_through_label = if_false_label = gen_label_rtx ();

  for (i = 0; i < nwords; i++)
    do_compare_rtx_and_jump (operand_subword_force (op0, i, mode),
                             operand_subword_force (op1, i, mode),
                             EQ, 0, word_mode, NULL_RTX,
			     if_false_label, NULL_RTX, prob);

  if (if_true_label)
    emit_jump (if_true_label);
  if (drop_through_label)
    emit_label (drop_through_label);
}
开发者ID:FilipinOTech,项目名称:gcc,代码行数:35,代码来源:dojump.c

示例14: emit_default

static void emit_default(Node *node) {
    SAVE;
    if (!lswitch)
        error("stray case label");
    emit_label(lswitch);
    lswitch = make_label();
}
开发者ID:irori,项目名称:8cc,代码行数:7,代码来源:gen.c

示例15: emit_str

void emit_str(Stack* string_stack){
	while(!stack_empty(string_stack)){
		Syntax *syntax = (Syntax*)stack_pop(string_stack);
		emit_label(syntax->printstmt->tag);
		emit_ascii(syntax->printstmt->value);
	}
}
开发者ID:noppadet008,项目名称:noobPrinterLangCompiler,代码行数:7,代码来源:asmX86emiter.c


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