Example #1
0
Real SphericalBesselGenerator::j(UnsignedInteger n, Real z) const
{
    if(n <= 3)
    {
        return _j_smalln(n, z);
    }

    if(n > getMaxNJ())
    {
        return _j(n, z);
    }
    
    const sb_table::Table* table(getSJTable(n));
    assert(table != 0);

    const Real minz(table->x_start + table->delta_x * 3);
    const Real maxz(table->x_start + table->delta_x * (table->N-3));
    
    if(z >= minz && z < maxz)
    {
        return _j_table(n, z);
    }
    else
    {
        return _j(n, z);
    }
}
Example #2
0
int
main(int argc, char **argv)
{
    int		errflag = 0;
    int		sts;
    int		c;

    __pmSetProgname(argv[0]);

    indomp = (__pmInDom_int *)&indom;

    while ((c = getopt(argc, argv, "D:")) != EOF) {
	switch (c) {

#ifdef PCP_DEBUG
	case 'D':	/* debug flag */
	    sts = __pmParseDebug(optarg);
	    if (sts < 0) {
		fprintf(stderr, "%s: unrecognized debug flag specification (%s)\n",
		    pmProgname, optarg);
		errflag++;
	    }
	    else
		pmDebug |= sts;
	    break;
#endif

	case '?':
	default:
	    errflag++;
	    break;
	}
    }

    if (errflag) {
	fprintf(stderr, "Usage: %s [-D...] [a|b|c|d|...|i 1|2|3}\n", pmProgname);
	exit(1);
    }

    while (optind < argc) {
	if (strcmp(argv[optind], "a") == 0) _a(0, 1, 1);
	else if (strcmp(argv[optind], "b") == 0) _b();
	else if (strcmp(argv[optind], "c") == 0) _c();
	else if (strcmp(argv[optind], "d") == 0) _a(1, 0, 1);
	else if (strcmp(argv[optind], "e") == 0) _e(0);
	else if (strcmp(argv[optind], "f") == 0) _e(3600);
	else if (strcmp(argv[optind], "g") == 0) _g();
	else if (strcmp(argv[optind], "h") == 0) _h();
	else if (strcmp(argv[optind], "i") == 0) {
	    optind++;
	    _i(atoi(argv[optind]));
	}
	else if (strcmp(argv[optind], "j") == 0) _j();
	else
	    fprintf(stderr, "torture_cache: no idea what to do with option \"%s\"\n", argv[optind]);
	optind++;
    }

    exit(0);
}
Example #3
0
//-----------------------------------------------------------------------------
//
// 命令コマンドを解釈してバイナリに変換
//
//-----------------------------------------------------------------------------
bool encode(char* instName, char* buffer, map<uint32_t, string>& labelNames, uint32_t currentLine, uint32_t& code, bool& useLabel)
{
	uint32_t rs = 0;
	uint32_t rt = 0;
	uint32_t rd = 0;
	uint32_t imm = 0;
	double d = 0;
	char label[MAX_LINE_SIZE];
	char dummy[MAX_LINE_SIZE];

	if (eq(instName, "add"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _add(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "sub"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _sub(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "mul"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _mul(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "and"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _and(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "or"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _or(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "nor"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _nor(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "xor"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _xor(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "addi"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _addi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "subi"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _subi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "muli"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _muli(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "slli"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _slli(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "srai"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _srai(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "andi"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _andi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "ori"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _ori(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "nori"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _nori(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "xori"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _xori(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fadd"))
	{
		int n = sscanf(buffer, formFFF, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fadd(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fsub"))
	{
		int n = sscanf(buffer, formFFF, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fsub(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fmul"))
	{
		int n = sscanf(buffer, formFFF, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fmul(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fmuln"))
	{
		int n = sscanf(buffer, formFFF, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fmuln(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "finv"))
	{
		int n = sscanf(buffer, formFF, dummy, &rd, &rs);
		if (n == 3)
		{
			code = _finv(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fsqrt"))
	{
		int n = sscanf(buffer, formFF, dummy, &rd, &rs);
		if (n == 3)
		{
			code = _fsqrt(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fmov"))
	{
		int n = sscanf(buffer, formFF, dummy, &rd, &rs);
		if (n == 3)
		{
			code = _fmov(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fneg"))
	{
		int n = sscanf(buffer, formFF, dummy, &rd, &rs);
		if (n == 3)
		{
			code = _fneg(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "imovf"))
	{
		int n = sscanf(buffer, formFR, dummy, &rt, &rs);
		if (n == 3)
		{
			code = _imovf(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fmovi"))
	{
		int n = sscanf(buffer, formRF, dummy, &rt, &rs);
		if (n == 3)
		{
			code = _fmovi(rs, rt, rd);
			return true;
		}
	}
	// to use ALU
	if (eq(instName, "mvlo"))
	{
		int n = sscanf(buffer, formRI, dummy, &rt, &imm);
		if (n == 3)
		{
			code = _mvlo(rt, rt, imm);
			return true;
		}
	}
	if (eq(instName, "mvhi"))
	{
		int n = sscanf(buffer, formRI, dummy, &rt, &imm);
		if (n == 3)
		{
			code = _mvhi(rt, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fmvlo"))
	{
		int n = sscanf(buffer, formFI, dummy, &rt, &imm);
		if (n == 3)
		{
			code = _fmvlo(rt, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fmvhi"))
	{
		int n = sscanf(buffer, formFI, dummy, &rt, &imm);
		if (n == 3)
		{
			code = _fmvhi(rt, rt, imm);
			return true;
		}
	}
	if (eq(instName, "j"))
	{
		int n = sscanf(buffer, formL, dummy, label);
		if (n == 2)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _j(0);
			return true;
		}
	}
	if (eq(instName, "beq"))
	{
		int n = sscanf(buffer, formRRL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _beq(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "blt"))
	{
		int n = sscanf(buffer, formRRL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _blt(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "ble"))
	{
		int n = sscanf(buffer, formRRL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _ble(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fbeq"))
	{
		int n = sscanf(buffer, formFFL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _fbeq(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fblt"))
	{
		int n = sscanf(buffer, formFFL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _fblt(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fble"))
	{
		int n = sscanf(buffer, formFFL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _fble(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "jr"))
	{
		int n = sscanf(buffer, formR, dummy, &rs);
		if (n == 2)
		{
			code = _jr(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "call"))
	{
		int n = sscanf(buffer, formL, dummy, label);
		if (n == 2)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _call(0);
			return true;
		}
	}
	if (eq(instName, "callr"))
	{
		int n = sscanf(buffer, formR, dummy, &rs);
		if (n == 2)
		{
			code = _callr(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "return"))
	{
		int n = sscanf(buffer, form, dummy);
		if (n == 1)
		{
			code = _return(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "ldr"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _ldr(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fldr"))
	{
		int n = sscanf(buffer, formFRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fldr(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "sti"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _sti(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "ldi"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _ldi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fsti"))
	{
		int n = sscanf(buffer, formFRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _fsti(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fldi"))
	{
		int n = sscanf(buffer, formFRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _fldi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "inputb"))
	{
		int n = sscanf(buffer, formR, dummy, &rt);
		if (n == 2)
		{
			code = _inputb(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "outputb"))
	{
		int n = sscanf(buffer, formR, dummy, &rt);
		if (n == 2)
		{
			code = _outputb(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "halt"))
	{
		int n = sscanf(buffer, form, dummy);
		if (n == 1)
		{
			code = _halt(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "dump"))
	{
		int n = sscanf(buffer, form, dummy);
		if (n == 1)
		{
			code = _dump(rs, rt, rd);
			return true;
		}
	}
	
	return false;
}