예제 #1
0
파일: FooBarTest.cpp 프로젝트: dinogun/omr
void
FooBarTest::compileTestMethods()
   {
   int32_t rc = 0;

   TR::TypeDictionary types;

   //_bar = &FooBarTest::bar;
   BarIlInjector barIlInjector(&types, this);
   int32_t numberOfArguments = 1;
   TR::IlType *Int32 = types.PrimitiveType(TR::Int32);
   TR::IlType **argTypes = new TR::IlType*[numberOfArguments];
   argTypes[0] = Int32;
   bool argIsArray[1] = { false };
   TR::ResolvedMethod barCompilee(__FILE__, LINETOSTR(__LINE__), "bar", numberOfArguments, argTypes, Int32, 0, &barIlInjector);
   _barCompilee = &barCompilee;
   TR::IlGeneratorMethodDetails barDetails(&barCompilee);

   _bar = (BarMethodType *) (compileMethod(barDetails, warm, rc));
   barCompilee.setEntryPoint((void *)_bar);

   FooIlInjector fooIlInjector(&types, this);
   TR::ResolvedMethod fooCompilee(__FILE__, LINETOSTR(__LINE__), "foo", numberOfArguments, argTypes, Int32, 0, &fooIlInjector);
   TR::IlGeneratorMethodDetails fooDetails(&fooCompilee);
   _foo = (FooMethodType *) (compileMethod(fooDetails, warm, rc));

   }
예제 #2
0
void
SimplifierFoldAndTest::compileTestMethods()
   {
   int32_t rc = 0;

   TR::TypeDictionary types;

   TR::IlType* Int32 = types.PrimitiveType(TR::Int32);
   TR::IlType* Int64 = types.PrimitiveType(TR::Int64);

   int32_t numberOfArguments = 1;

   TR::IlType** argTypes = new TR::IlType*[numberOfArguments]
   {
      Int32
   };

   SimplifierFoldAndIlInjector ilInjector(&types, this);

   TR::ResolvedMethod compilee(__FILE__, LINETOSTR(__LINE__), "simplifierFoldAnd", numberOfArguments, argTypes, Int64, 0, &ilInjector);

   TR::IlGeneratorMethodDetails details(&compilee);

   testCompiledMethod = reinterpret_cast<SimplifierFoldAndTest::TestCompiledMethodType>(compileMethod(details, warm, rc));
   }
예제 #3
0
void
InliningRecursiveFibonacciMethod::defineStuff()
   {
   DefineLine(LINETOSTR(__LINE__));
   DefineFile(__FILE__);

   DefineName("fib");
   DefineParameter("n", Int32);
   DefineReturnType(Int32);

   DefineFunction((char *)"printString",
                  (char *)__FILE__,
                  (char *)PRINTSTRING_LINE,
                  (void *)&printString,
                  NoType,
                  1,
                  Int64);
   DefineFunction((char *)"printInt32",
                  (char *)__FILE__,
                  (char *)PRINTINT32_LINE,
                  (void *)&printInt32,
                  NoType,
                  1,
                  Int32);
   }
예제 #4
0
파일: Union.cpp 프로젝트: bjornvar/omr
GetUnionStrBuilder::GetUnionStrBuilder(TR::TypeDictionary *d)
   : MethodBuilder(d)
   {
   DefineFile(__FILE__);
   DefineLine(LINETOSTR(__LINE__));

   DefineName("getUnionStr");
   DefineParameter("u", d->PointerTo(d->LookupUnion("TestUnionInt8pChar")));
   DefineReturnType(d->toIlType<char*>());
   }
예제 #5
0
파일: Union.cpp 프로젝트: bjornvar/omr
SetUnionByteBuilder::SetUnionByteBuilder(TR::TypeDictionary *d)
   : MethodBuilder(d)
   {
   DefineFile(__FILE__);
   DefineLine(LINETOSTR(__LINE__));

   DefineName("setUnionByte");
   DefineParameter("u", d->PointerTo(d->LookupUnion("TestUnionInt8pChar")));
   DefineParameter("v", Int8);
   DefineReturnType(NoType);
   }
예제 #6
0
ThunkBuilder::ThunkBuilder(TR::TypeDictionary *types, const char *name, TR::IlType *returnType,
                           uint32_t numCalleeParams, TR::IlType **calleeParamTypes)
   : TR::MethodBuilder(types),
   _numCalleeParams(numCalleeParams),
   _calleeParamTypes(calleeParamTypes)
   {
   DefineLine(__FILE__);
   DefineFile(LINETOSTR(__LINE__));
   DefineName(name);
   DefineReturnType(returnType);
   DefineParameter("target", Address); // target
   DefineParameter("args", types->PointerTo(Word));     // array of arguments

   DefineFunction("thunkCallee",
                  __FILE__,
                  LINETOSTR(__LINE__),
                  0, // entry will be a computed value
                  returnType,
                  numCalleeParams,
                  calleeParamTypes);
   }
예제 #7
0
파일: Union.cpp 프로젝트: bjornvar/omr
TypePunInt16DoubleBuilder::TypePunInt16DoubleBuilder(TR::TypeDictionary *d)
   : MethodBuilder(d)
   {
   DefineLine(LINETOSTR(__LINE__));
   DefineFile(__FILE__);

   DefineName("typePunInt16Double");
   DefineParameter("u", d->PointerTo(d->LookupUnion("TestUnionInt16Double")));
   DefineParameter("v1", Int16);
   DefineParameter("v2", Double);
   DefineReturnType(Int16);
   }
예제 #8
0
GetUnionFieldAddressBuilder::GetUnionFieldAddressBuilder(TR::TypeDictionary *d)
   : MethodBuilder(d)
   {
   DefineLine(LINETOSTR(__LINE__));
   DefineFile(__FILE__);

   pUnionType = d->PointerTo(d->LookupUnion("Union"));

   DefineName("getUnionFieldAddress");
   DefineParameter("u", pUnionType);
   DefineReturnType(d->toIlType<uint8_t *>());
   }
예제 #9
0
GetStructFieldAddressBuilder::GetStructFieldAddressBuilder(TR::TypeDictionary *d)
   : MethodBuilder(d)
   {
   DefineLine(LINETOSTR(__LINE__));
   DefineFile(__FILE__);

   pStructType = d->PointerTo(d->LookupStruct("Struct"));

   DefineName("getStructFieldAddress");
   DefineParameter("s", pStructType);
   DefineReturnType(d->PointerTo(d->GetFieldType("Struct", "f2")));
   }
예제 #10
0
파일: Qux2Test.cpp 프로젝트: LinHu2016/omr
void
Qux2Test::compileTestMethods()
   {
   int32_t rc = 0;

   TR::TypeDictionary types;
   Qux2IlInjector quxIlInjector(&types, this);
   int32_t numberOfArguments = 1;
   TR::IlType ** argTypes = new TR::IlType*[numberOfArguments];
   TR::IlType *Int32 = types.PrimitiveType(TR::Int32);
   argTypes[0]= Int32;
   TR::ResolvedMethod qux2Compilee(__FILE__, LINETOSTR(__LINE__), "qux2", numberOfArguments, argTypes, Int32, 0, &quxIlInjector);
   TR::IlGeneratorMethodDetails qux2Details(&qux2Compilee);
   _qux2 = (testMethodType *) (compileMethod(qux2Details, warm, rc));
   }
예제 #11
0
파일: DotProduct.cpp 프로젝트: lmaisons/omr
DotProduct::DotProduct(TR::TypeDictionary *types)
   : MethodBuilder(types)

   {
   DefineLine(LINETOSTR(__LINE__));
   DefineFile(__FILE__);

   DefineName("dotproduct");

   pDouble = types->PointerTo(Double);

   DefineParameter("result", pDouble);
   DefineParameter("vector1", pDouble);
   DefineParameter("vector2", pDouble);
   DefineParameter("length", Int32);

   DefineReturnType(NoType);

   DefineFunction((char *)"printString", 
                  (char *)__FILE__,
                  (char *)PRINTSTRING_LINE,
                  (void *)&printString,
                  NoType,
                  1,
                  Int64);
   DefineFunction((char *)"printInt32", 
                  (char *)__FILE__,
                  (char *)PRINTINT32_LINE,
                  (void *)&printInt32,
                  NoType,
                  1,
                  Int32);
   DefineFunction((char *)"printDouble", 
                  (char *)__FILE__,
                  (char *)PRINTDOUBLE_LINE,
                  (void *)&printDouble,
                  NoType,
                  1,
                  Double);
   DefineFunction((char *)"printPointer", 
                  (char *)__FILE__,
                  (char *)PRINTPOINTER_LINE,
                  (void *)&printPointer,
                  NoType,
                  1,
                  Int64);
   }
예제 #12
0
파일: IlGenTest.cpp 프로젝트: bjornvar/omr
TEST_F(IlGenTest, Return3) {
    auto trees = parseString("(block (ireturn (iconst 3)))");

    TR::TypeDictionary types;
    auto Int32 = types.PrimitiveType(TR::Int32);
    TR::IlType* argTypes[] = {Int32};

    auto injector = Tril::TRLangBuilder{trees, &types};
    TR::ResolvedMethod compilee{__FILE__, LINETOSTR(__LINE__), "Return3InIL", sizeof(argTypes)/sizeof(TR::IlType*), argTypes, Int32, 0, &injector};
    TR::IlGeneratorMethodDetails methodDetails{&compilee};
    int32_t rc = 0;
    auto entry_point = compileMethodFromDetails(NULL, methodDetails, warm, rc);

    ASSERT_EQ(0, rc) << "Compilation failed";
    ASSERT_NOTNULL(entry_point) << "Entry point of compiled body cannot be null";

    auto entry = reinterpret_cast<int32_t(*)(void)>(entry_point);
    ASSERT_EQ(3, entry()) << "Compiled body did not return expected value";
}
예제 #13
0
파일: MatMult.cpp 프로젝트: LinHu2016/omr
MatMult::MatMult(OMR::JitBuilder::TypeDictionary *types)
   : OMR::JitBuilder::MethodBuilder(types)
   {
   DefineLine(LINETOSTR(__LINE__));
   DefineFile(__FILE__);

   DefineName("matmult");

   pDouble = types->PointerTo(Double);

   // C = A * B, all NxN matrices
   DefineParameter("C", pDouble);
   DefineParameter("A", pDouble);
   DefineParameter("B", pDouble);
   DefineParameter("N", Int32);

   DefineReturnType(NoType);

   DefineLocal("sum", Double);
   }