void main_tick()
{
  SDL_Event event;
  while (SDL_PollEvent(&event)) {
    switch(event.type) {
      case SDL_MOUSEWHEEL:
        printf("SDL_MOUSEWHEEL: timestamp: %u, windowID: %u, which: %u, x: %d, y: %d\n", event.wheel.timestamp, event.wheel.windowID, event.wheel.which, event.wheel.x, event.wheel.y);
        if (!gotWheelUp)
        {
          if (event.wheel.y > 0) { gotWheelUp = 1; instruction(); }
          else if (event.wheel.y < 0) { printf("You scrolled to the wrong direction (downwards)!\n"); report_result(1); }
        }
        else if (!gotWheelDown)
        {
          if (event.wheel.y < 0) { gotWheelDown = 1; instruction(); }
        }
        break;
      case SDL_MOUSEBUTTONDOWN:
        printf("SDL_MOUSEBUTTONDOWN: button: %d\n", event.button.button);
        if (event.button.button == SDL_BUTTON_WHEELDOWN) { printf("SDL_BUTTON_WHEELDOWN\n"); gotWheelButtonDown = 1; instruction(); }
        else if (event.button.button == SDL_BUTTON_WHEELUP) { printf("SDL_BUTTON_WHEELUP\n"); gotWheelButtonUp = 1; instruction(); }
        else if (event.button.button == SDL_BUTTON_MIDDLE) { printf("SDL_BUTTON_MIDDLE\n"); gotWheelClick = 1; instruction(); }
        break;
    }
  }
}
Beispiel #2
0
bool DivergenceAnalysis::_promoteDivergentBranchesToConvergent(
	branch_set& branches)
{
	bool removedDivergences = false;
	
	// Remove non-divergent branches from the set
	for (auto branch = branches.begin(); branch != branches.end(); ) {
		if (!isDivBranch(branch->instruction())) {
			
			report("  promoting " << branch->instruction().i->toString()
				<< " to convergent.");
			
			const DataflowGraph::PhiInstructionVector&
				phis = branch->postDominator()->phis();

			for (auto phi = phis.begin(); phi != phis.end(); ++phi) {
				DataflowGraph::RegisterVector::const_iterator
					source = phi->s.begin();
				DataflowGraph::RegisterVector::const_iterator
					endSource = phi->s.end();

				for (; source != endSource; source++) {
					if (branch->isTainted(source->id)) {
						report("   removing dependence r" << phi->d.id
							<< " <- r" << branch->predicate());
						_removePredicate(*phi, branch->predicate());
						
					}
				}
			}
			
			_divergGraph.forceConvergent(branch->predicate());
			removedDivergences = true;
			
			auto temp = branch++;
			
			branches.erase(temp);
		}
		else {
			++branch;
		}
	}
	
	if (removedDivergences) {
		_divergGraph.computeDivergence();
	}
	
	return removedDivergences;
}
Beispiel #3
0
void Environment::execute(const Expression *expr, bool verbose) {
	try {
		double result = expr->execute(*this);
		if (verbose) {
			instruction(result);
		}
	}
	catch (const ExpressionException &e) {
		error( e.what() );
	}
	catch (EscapeException &e) {
		if (verbose) {
			instruction(e.getValue());
		}
	}
}
Beispiel #4
0
luna::Function * RandomFunction()
{
    auto f = g_gc.NewFunction();

    auto s = RandomString();
    f->SetModuleName(s);
    f->SetLine(RandomNum(1000));

    int instruction_count = RandomRange(10, 1000);
    for (int i = 0; i < instruction_count; ++i)
    {
        unsigned int op_min = luna::OpType_LoadNil;
        unsigned int op_max = luna::OpType_GetGlobal;
        luna::OpType op = static_cast<luna::OpType>(RandomRange(op_min, op_max));
        luna::Instruction instruction(op, RandomNum(128), RandomNum(128), RandomNum(128));
        f->AddInstruction(instruction, i);
    }

    int const_num = RandomNum(5);
    for (int i = 0; i < const_num; ++i)
        f->AddConstNumber(RandomNum(100000));

    int const_str = RandomNum(5);
    for (int i = 0; i < const_str; ++i)
        f->AddConstString(RandomString());

    CHECK_BARRIER(g_gc, f);

    return f;
}
Beispiel #5
0
		void emitter::current_function(local_address destination)
		{
			push_instruction(instruction(
				instruction_type::current_function,
				destination
				));
		}
	void ConvertPredicationToSelectPass::_replacePredicate( 
		DataflowGraph::iterator block, unsigned int id )
	{
		typedef DataflowGraph::Block::RegisterSet RegisterSet;

		DataflowGraph::InstructionVector::const_iterator 
			instruction( block->instructions().begin() );
		std::advance( instruction, id );

		report( "  Converting instruction " << instruction->i->toString() );
		
		ir::PTXInstruction select( ir::PTXInstruction::SelP );

		ir::PTXInstruction& ptx = static_cast< ir::PTXInstruction& >( 
			*instruction->i );

		select.d = ptx.d;
		select.b = select.d;
		select.a = select.b;
		select.a.reg = _tempRegister();
		select.c = ptx.pg;
		
		ptx.pg.condition = ir::PTXOperand::PT;
		ptx.d.reg = select.a.reg;
			
		_kernel->dfg()->insert( block, select, id + 1 );
	}
Beispiel #7
0
Display::Display(int e_pin, int rs_pin, int data_pins_start) {
    this->e_pin = e_pin;
    this->rs_pin = rs_pin;
    for (int i = 0; i < 8; i++) {
        data_pins[i] = data_pins_start + i;
    }
    mode = ROW;
    bar_text_status = 0x00;

    leds = new Leds();

    // Initialization of Display
    instruction(0x38);
    instruction(0x0C);
    instruction(0x06);
    instruction(0x01);
}
Beispiel #8
0
void Display::write(char* line1, char* line2) {
    char i = 0;
    instruction(SET_DDRAM);
    do {
        dataCommand(line1[0]);
    } while (line1[i] != '\0');
    //instruction(SET_DDRAM | )
}
Beispiel #9
0
		void emitter::jump(
			jump_offset destination
			)
		{
			push_instruction(instruction(
				instruction_type::jump,
				destination
				));
		}
Beispiel #10
0
		void emitter::invert(
			local_address destination
			)
		{
			push_instruction(instruction(
				instruction_type::invert,
				destination
				));
		}
Beispiel #11
0
		void emitter::not_(
			local_address destination
			)
		{
			push_instruction(instruction(
				instruction_type::not_,
				destination
				));
		}
Beispiel #12
0
		void emitter::new_table(
			local_address destination
			)
		{
			push_instruction(instruction(
				instruction_type::new_table,
				destination
				));
		}
Beispiel #13
0
		void emitter::set_null(
			local_address destination
			)
		{
			push_instruction(instruction(
				instruction_type::set_null,
				destination
				));
		}
Beispiel #14
0
		void emitter::load_module(
			local_address name_and_result
			)
		{
			push_instruction(instruction(
				instruction_type::load_module,
				name_and_result
				));
		}
Beispiel #15
0
		void emitter::less(
			local_address left,
			local_address right)
		{
			push_instruction(instruction(
				instruction_type::less,
				left,
				right
				));
		}
Beispiel #16
0
		void emitter::not_equal(
			local_address left,
			local_address right)
		{
			push_instruction(instruction(
				instruction_type::not_equal,
				left,
				right
				));
		}
Beispiel #17
0
 instruction return_()
 {
   if(!scope::current_function().return_type()->isVoidTy())
   {
     throw type_error(
         "A return value must be supplied for functions not returning void."
       );
   }
   return instruction(SPRITE_APICALL(current_builder().CreateRetVoid()));
 }
Beispiel #18
0
		void emitter::add(
			local_address destination,
			local_address summand
			)
		{
			push_instruction(instruction(
				instruction_type::add,
				destination,
				summand
				));
		}
Beispiel #19
0
 /// Appends an indirect branch instruction to the active label scope.
 instruction goto_(value const & target, array_ref<label> const & labels)
 {
   // Note: no update to the current label.
   llvm::IRBuilder<> & bldr = current_builder();
   llvm::IndirectBrInst * rv = SPRITE_APICALL(
       bldr.CreateIndirectBr(target.ptr(), labels.size())
     );
   for(label const & l : labels)
     rv->addDestination(l.ptr());
   return instruction(rv);
 }
Beispiel #20
0
// Function to put instructions on the screen.
NodePath World::add_instructions(float pos, const string& msg)
{
    COnscreenText instruction("instruction");
    instruction.set_text(msg);
    instruction.set_fg(Colorf(1, 1, 1, 1));
    instruction.set_pos(LVecBase2f(-1.3, pos));
    instruction.set_align(TextNode::A_left);
    instruction.set_scale(0.05);
    instruction.reparent_to(m_windowFramework->get_aspect_2d());
    return instruction.generate();
}
Beispiel #21
0
		void emitter::call(
			local_address arguments_address,
			instruction_argument argument_count
			)
		{
			push_instruction(instruction(
				instruction_type::call,
				arguments_address,
				argument_count
				));
		}
Beispiel #22
0
		void emitter::set_string(
			local_address destination,
			instruction_argument string_id
			)
		{
			push_instruction(instruction(
				instruction_type::set_string,
				destination,
				string_id
				));
		}
Beispiel #23
0
		void emitter::set_constant(
			local_address destination,
			instruction_argument constant
			)
		{
			push_instruction(instruction(
				instruction_type::set_from_constant,
				destination,
				constant
				));
		}
Beispiel #24
0
		void emitter::set_function(
			local_address destination,
			instruction_argument function_id
			)
		{
			push_instruction(instruction(
				instruction_type::set_function,
				destination,
				function_id
				));
		}
Beispiel #25
0
		void emitter::mod(
			local_address destination,
			local_address source
			)
		{
			push_instruction(instruction(
				instruction_type::mod,
				destination,
				source
				));
		}
Beispiel #26
0
		void emitter::jump_if_not(
			jump_offset destination,
			local_address condition_address
			)
		{
			push_instruction(instruction(
				instruction_type::jump_if_not,
				destination,
				condition_address
				));
		}
Beispiel #27
0
int main(void) {
    char Choice;
    short int a,b;
    unsigned short int x,q;
    unsigned char y,r;
    long int c;

    instruction();

    printf("\nChoice:");
    Choice=getchar();
    getchar();
    while(Choice!='0') {
        switch(Choice) {
        case '5':
            printf("Input two 16-bit short ints:\n");
            scanf("%d%d",&a,&b);
            c=cmul(a,b);
            printf("%d * %d = %d\n",a,b,c);
            break;
        case '6':
            printf("Input a 16-bit unsigned short int and a 8-bit unsigned int:\n");
            scanf("%d%d",&x,&y);
            if(!y)
                printf("Divisor should be positive.\n");
            else {
                cdiv(x,y,&q,&r);
                printf("%d / %d = %d remains %d\n",x,y,q,r);
            }
            break;
        default:
            printf("Wrong choice number!\n\n");
            instruction();
        }

        printf("\nChoice:");
        do {
            Choice=getchar();
        } while(Choice>'9'||Choice<'0');
    }
}
Beispiel #28
0
/**
 *  tests instruction()
 */
static char * test_instruction() {
    Logo fd, lt, rt, set, dologo, bad1, bad2, bad3;
    int ret;
    printf("Testing %s\n", __FUNCTION__);
    
    /* create Logo handles for all 5 instructions */
    fd = setup(1, "FD 30");
    lt = setup(1, "LT 30");
    rt = setup(1, "RT 30");
    set = setup(1, "SET A := 30 ;");
    dologo = setup(3, "DO A FROM 1 TO 5 {");
    insert_line(dologo, "FD 20");
    insert_line(dologo, "}");
    
    /* test them all */
    ret = instruction(fd);
    mu_assert("error, ret != 0", ret == 0);
    ret = instruction(rt);
    mu_assert("error, ret != 0", ret == 0);
    ret = instruction(lt);
    mu_assert("error, ret != 0", ret == 0);
    ret = instruction(set);
    mu_assert("error, ret != 0", ret == 0);
    ret = instruction(dologo);
    mu_assert("error, ret != 0", ret == 0);
    
    bad1 = setup(1, "DOESNOTEXIST 123");
    ret = instruction(bad1);
    mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR);
    
    /* test that if any of the <INSTRUCTION> such as fd are malformed, ret == PARSE_ERR
     */
    bad2 = setup(1, "FD abc990");
    ret = instruction(bad2);
    mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR);
    
    /* tests empty string */
    bad3 = setup(1, "");
    ret = instruction(bad3);
    mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR);
    
    tear_down(fd);
    tear_down(lt);
    tear_down(rt);
    tear_down(set);
    tear_down(dologo);
    tear_down(bad1);
    tear_down(bad2);
    tear_down(bad3);
    return 0;
}
Beispiel #29
0
		void emitter::binary_operation(
			instruction_type::Enum operation,
			local_address destination,
			local_address source)
		{
			assert(is_binary_arithmetic(operation));

			push_instruction(instruction(
				operation,
				destination,
				source));
		}
Beispiel #30
0
 instruction if_(branch_condition const & cond, labeldescr const & true_)
 {
   label next;
   llvm::IRBuilder<> & bldr = current_builder();
   auto rv = SPRITE_APICALL(
       bldr.CreateCondBr(cond.get().ptr(), true_.ptr(), next.ptr())
     );
   scope::update_current_label_after_branch(next);
   scope::set_continuation(true_, next);
   // Perform codegen only after the continuations are set.
   true_.codegen();
   return instruction(rv);
 }