コード例 #1
0
void CMemAccessRefTest::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		//Read ref test
		{
			jitter.PushRelRef(offsetof(CONTEXT, memory));
			jitter.PushCst(LOAD_IDX * sizeof(void*));
			jitter.AddRef();
			jitter.LoadRefFromRef();

			jitter.LoadFromRef();
			jitter.PullRel(offsetof(CONTEXT, readValueResult));
		}

		EmitNullTest(jitter, NULLCHECK_IDX, offsetof(CONTEXT, nullCheck0));
		EmitNullTest(jitter, LOAD_IDX, offsetof(CONTEXT, nullCheck1));
		EmitNullComparison(jitter, NULLCHECK_IDX, offsetof(CONTEXT, nullCheck2));
		EmitNullComparison(jitter, LOAD_IDX, offsetof(CONTEXT, nullCheck3));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #2
0
void CMemAccessRefTest::EmitNullComparison(Jitter::CJitter& jitter, uint32 index, size_t resultOffset)
{
	jitter.PushRelRef(offsetof(CONTEXT, memory));
	jitter.PushCst(index * sizeof(void*));
	jitter.AddRef();
	jitter.LoadRefFromRef();

	jitter.PushCst(0);
	jitter.BeginIf(Jitter::CONDITION_EQ);
	{
		jitter.PushCst(1);
		jitter.PullRel(resultOffset);
	}
	jitter.EndIf();
}
コード例 #3
0
void CMemAccessRefTest::EmitNullTest(Jitter::CJitter& jitter, uint32 index, size_t resultOffset)
{
	jitter.PushRelRef(offsetof(CONTEXT, memory));
	jitter.PushCst(index * sizeof(void*));
	jitter.AddRef();
	jitter.LoadRefFromRef();

	jitter.IsRefNull();
	jitter.PullRel(resultOffset);
}
コード例 #4
0
void CSimpleMdTest::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		jitter.MD_PushRel(offsetof(CONTEXT, op1));
		jitter.MD_PushRel(offsetof(CONTEXT, op2));
		jitter.MD_AddW();
		jitter.MD_PullRel(offsetof(CONTEXT, result));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #5
0
void CMdMemAccessTest::Compile(Jitter::CJitter& jitter)
{
    Framework::CMemStream codeStream;
    jitter.SetStream(&codeStream);

    jitter.Begin();
    {
        jitter.PushRelRef(offsetof(CONTEXT, array));
        jitter.MD_LoadFromRef();
        jitter.MD_PullRel(offsetof(CONTEXT, result));

        jitter.PushRelRef(offsetof(CONTEXT, array));
        jitter.PushCst(0x10);
        jitter.AddRef();
        jitter.MD_PushRel(offsetof(CONTEXT, op));
        jitter.MD_StoreAtRef();
    }
    jitter.End();

    m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #6
0
void CMdTest::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.MD_PullRel(offsetof(CONTEXT, dstMov));

		//Shifts
		jitter.MD_PushRel(offsetof(CONTEXT, src0));
		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.PushCst(48);
		jitter.MD_Srl256();
		jitter.MD_PullRel(offsetof(CONTEXT, dstSrl256_1));

		jitter.MD_PushRel(offsetof(CONTEXT, src0));
		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.PushRel(offsetof(CONTEXT, shiftAmount));
		jitter.MD_Srl256();
		jitter.MD_PullRel(offsetof(CONTEXT, dstSrl256_2));

		//Packs
		jitter.MD_PushRel(offsetof(CONTEXT, src0));
		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.MD_PackHB();
		jitter.MD_PullRel(offsetof(CONTEXT, dstPackHB));

		jitter.MD_PushRel(offsetof(CONTEXT, src0));
		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.MD_PackWH();
		jitter.MD_PullRel(offsetof(CONTEXT, dstPackWH));

		//Aliased packs
		jitter.MD_PushRel(offsetof(CONTEXT, dstPackHBAlias));
		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.MD_PackHB();
		jitter.MD_PullRel(offsetof(CONTEXT, dstPackHBAlias));

		jitter.MD_PushRel(offsetof(CONTEXT, dstPackWHAlias));
		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.MD_PackWH();
		jitter.MD_PullRel(offsetof(CONTEXT, dstPackWHAlias));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #7
0
void CMdFpFlagTest::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		//0
		jitter.MD_PushRel(offsetof(CONTEXT, src0));
		jitter.MD_IsNegative();
		jitter.PullRel(offsetof(CONTEXT, dstIsNegative0));

		jitter.MD_PushRel(offsetof(CONTEXT, src0));
		jitter.MD_IsZero();
		jitter.PullRel(offsetof(CONTEXT, dstIsZero0));

		//1
		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.MD_IsNegative();
		jitter.PullRel(offsetof(CONTEXT, dstIsNegative1));

		jitter.MD_PushRel(offsetof(CONTEXT, src1));
		jitter.MD_IsZero();
		jitter.PullRel(offsetof(CONTEXT, dstIsZero1));

		//2
		jitter.MD_PushRel(offsetof(CONTEXT, src2));
		jitter.MD_IsNegative();
		jitter.PullRel(offsetof(CONTEXT, dstIsNegative2));

		jitter.MD_PushRel(offsetof(CONTEXT, src2));
		jitter.MD_IsZero();
		jitter.PullRel(offsetof(CONTEXT, dstIsZero2));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #8
0
void CFpIntMixTest::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		//number1 = 100.f
		jitter.PushCst(0x42C80000);
		jitter.PullRel(offsetof(CONTEXT, number1));

		//number2 = toFloat(multiplier)
		jitter.FP_PushWord(offsetof(CONTEXT, multiplier));
		jitter.FP_PullSingle(offsetof(CONTEXT, number2));

		//number1 = number1 * number2
		jitter.FP_PushSingle(offsetof(CONTEXT, number1));
		jitter.FP_PushSingle(offsetof(CONTEXT, number2));
		jitter.FP_Mul();
		jitter.FP_PullSingle(offsetof(CONTEXT, number1));

		//number1 = toInt(number1)
		jitter.FP_PushSingle(offsetof(CONTEXT, number1));
		jitter.FP_PullWordTruncate(offsetof(CONTEXT, number1));

		//result = number1
		jitter.PushRel(offsetof(CONTEXT, number1));
		jitter.PullRel(offsetof(CONTEXT, result));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #9
0
ファイル: AliasTest2.cpp プロジェクト: bigianb/Play--CodeGen
void CAliasTest2::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		jitter.PushCst(CONSTANT_1);
		jitter.PullRel(offsetof(CONTEXT, value1[0]));

		jitter.PushCst(CONSTANT_2);
		jitter.PullRel(offsetof(CONTEXT, value1[1]));

		jitter.PushCst(CONSTANT_3);
		jitter.PullRel(offsetof(CONTEXT, value1[2]));

		jitter.PushCst(CONSTANT_4);
		jitter.PullRel(offsetof(CONTEXT, value1[3]));

		jitter.MD_PushRel(offsetof(CONTEXT, value2));
		jitter.MD_PushRelExpand(offsetof(CONTEXT, value1[2]));
		jitter.MD_AddS();
		jitter.MD_PullRel(offsetof(CONTEXT, value1), true, true, true, false);
		//Here value1 should be (3, 3, 3, 4)

		jitter.MD_PushRel(offsetof(CONTEXT, value2));
		jitter.MD_PushRelExpand(offsetof(CONTEXT, value1[2]));
		jitter.MD_AddS();
		jitter.MD_PullRel(offsetof(CONTEXT, value3));
		//Here value3 should be (4, 4, 4, 4)
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #10
0
void CMemAccessTest::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		//Store test
		jitter.PushRelRef(offsetof(CONTEXT, memory));
		jitter.PushRel(offsetof(CONTEXT, offset));
		jitter.AddRef();

		jitter.PushCst(CONSTANT_1);
		jitter.StoreAtRef();

		//Read test
		jitter.PushRelRef(offsetof(CONTEXT, memory));
		jitter.PushCst(0x08);
		jitter.AddRef();

		jitter.LoadFromRef();
		jitter.PullRel(offsetof(CONTEXT, result0));

		//Write array test
		jitter.PushRelAddrRef(offsetof(CONTEXT, array0));
		jitter.PushCst(ARRAY_IDX_0 * 4);
		jitter.AddRef();

		jitter.PushCst(CONSTANT_2);
		jitter.StoreAtRef();

		//Read array test
		jitter.PushRelAddrRef(offsetof(CONTEXT, array0));
		jitter.PushCst(ARRAY_IDX_1 * 4);
		jitter.AddRef();

		jitter.LoadFromRef();
		jitter.PullRel(offsetof(CONTEXT, result1));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #11
0
ファイル: Alu64Test.cpp プロジェクト: Thunder07/Play--CodeGen
void CAlu64Test::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		jitter.PushRel64(offsetof(CONTEXT, value0));
		jitter.PushRel64(offsetof(CONTEXT, value1));
		jitter.Add64();
		jitter.PullRel64(offsetof(CONTEXT, resultAdd0));

		jitter.PushRel64(offsetof(CONTEXT, value2));
		jitter.PushRel64(offsetof(CONTEXT, value3));
		jitter.Add64();
		jitter.PullRel64(offsetof(CONTEXT, resultAdd1));

		jitter.PushRel64(offsetof(CONTEXT, value0));
		jitter.PushCst64(CONSTANT_5);
		jitter.Add64();
		jitter.PullRel64(offsetof(CONTEXT, resultAddCst));

		jitter.PushRel64(offsetof(CONTEXT, value0));
		jitter.PushRel64(offsetof(CONTEXT, value1));
		jitter.Sub64();
		jitter.PullRel64(offsetof(CONTEXT, resultSub0));

		jitter.PushRel64(offsetof(CONTEXT, value2));
		jitter.PushRel64(offsetof(CONTEXT, value3));
		jitter.Sub64();
		jitter.PullRel64(offsetof(CONTEXT, resultSub1));

		jitter.PushCst64(CONSTANT_5);
		jitter.PushRel64(offsetof(CONTEXT, value0));
		jitter.Sub64();
		jitter.PullRel64(offsetof(CONTEXT, resultSubCst));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #12
0
void CRandomAluTest3::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		//a = b ^ a
		if(m_useConstant)
		{
			jitter.PushCst(TEST_NUMBER1);
		}
		else
		{
			jitter.PushRel(offsetof(CONTEXT, number1));
		}

		if(m_useConstant)
		{
			jitter.PushCst(TEST_NUMBER2);
		}
		else
		{
			jitter.PushRel(offsetof(CONTEXT, number2));
		}

		jitter.Xor();

		//b = a

		jitter.PullRel(offsetof(CONTEXT, number1));

		jitter.PushRel(offsetof(CONTEXT, number1));
		jitter.PullRel(offsetof(CONTEXT, number2));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #13
0
void CAliasTest::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		jitter.PushCst64(0);
		jitter.PullRel64(offsetof(CONTEXT, value0));

		jitter.PushCst(CONSTANT_1);
		jitter.PullRel(offsetof(CONTEXT, value0[0]));

		jitter.PushCst(CONSTANT_2);
		jitter.PullRel(offsetof(CONTEXT, value0[1]));

		jitter.PushRel64(offsetof(CONTEXT, value0));
		jitter.PushRel64(offsetof(CONTEXT, value1));
		jitter.Cmp64(Jitter::CONDITION_EQ);
		jitter.PullRel(offsetof(CONTEXT, result));

		for(unsigned int i = 0; i < 4; i++)
		{
			jitter.PushCst(0);
			jitter.PullRel(offsetof(CONTEXT, value4[i]));
		}

		jitter.MD_PushRel(offsetof(CONTEXT, value2));
		jitter.MD_PushRel(offsetof(CONTEXT, value3));
		jitter.MD_AddWSS();
		jitter.MD_PullRel(offsetof(CONTEXT, value4), true, false, false, true);
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
コード例 #14
0
ファイル: Cmp64Test.cpp プロジェクト: Thunder07/Play--CodeGen
void CCmp64Test::Compile(Jitter::CJitter& jitter)
{
	Framework::CMemStream codeStream;
	jitter.SetStream(&codeStream);

	jitter.Begin();
	{
		//Equal
		//---------------------------------
		jitter.PushRel64(offsetof(CONTEXT, value0));
		if(m_useConstant)
		{
			jitter.PushCst64(m_value1);
		}
		else
		{
			jitter.PushRel64(offsetof(CONTEXT, value1));
		}
		jitter.Cmp64(Jitter::CONDITION_EQ);
		jitter.PullRel(offsetof(CONTEXT, resultEq));

		//Not Equal
		//---------------------------------
		jitter.PushRel64(offsetof(CONTEXT, value0));
		if(m_useConstant)
		{
			jitter.PushCst64(m_value1);
		}
		else
		{
			jitter.PushRel64(offsetof(CONTEXT, value1));
		}
		jitter.Cmp64(Jitter::CONDITION_NE);
		jitter.PullRel(offsetof(CONTEXT, resultNe));

		//Less Than (unsigned)
		//---------------------------------
		jitter.PushRel64(offsetof(CONTEXT, value0));
		if(m_useConstant)
		{
			jitter.PushCst64(m_value1);
		}
		else
		{
			jitter.PushRel64(offsetof(CONTEXT, value1));
		}
		jitter.Cmp64(Jitter::CONDITION_BL);
		jitter.PullRel(offsetof(CONTEXT, resultBl));

		//Less Than (signed)
		//---------------------------------
		jitter.PushRel64(offsetof(CONTEXT, value0));
		if(m_useConstant)
		{
			jitter.PushCst64(m_value1);
		}
		else
		{
			jitter.PushRel64(offsetof(CONTEXT, value1));
		}
		jitter.Cmp64(Jitter::CONDITION_LT);
		jitter.PullRel(offsetof(CONTEXT, resultLt));

		//Less Equal (signed)
		//---------------------------------
		jitter.PushRel64(offsetof(CONTEXT, value0));
		if(m_useConstant)
		{
			jitter.PushCst64(m_value1);
		}
		else
		{
			jitter.PushRel64(offsetof(CONTEXT, value1));
		}
		jitter.Cmp64(Jitter::CONDITION_LE);
		jitter.PullRel(offsetof(CONTEXT, resultLe));

		//Greater Than (unsigned)
		//---------------------------------
		jitter.PushRel64(offsetof(CONTEXT, value0));
		if(m_useConstant)
		{
			jitter.PushCst64(m_value1);
		}
		else
		{
			jitter.PushRel64(offsetof(CONTEXT, value1));
		}
		jitter.Cmp64(Jitter::CONDITION_AB);
		jitter.PullRel(offsetof(CONTEXT, resultAb));

		//Greater Than (signed)
		//---------------------------------
		jitter.PushRel64(offsetof(CONTEXT, value0));
		if(m_useConstant)
		{
			jitter.PushCst64(m_value1);
		}
		else
		{
			jitter.PushRel64(offsetof(CONTEXT, value1));
		}
		jitter.Cmp64(Jitter::CONDITION_GT);
		jitter.PullRel(offsetof(CONTEXT, resultGt));
	}
	jitter.End();

	m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}