rocmlite/test/test_rocmlite_functions.cpp
TEST(TEST_BASE, test_compile_module_to_BRIG)
{
    ROC_Initialize();
    std::string ir = read_ir_from_file("demo_ir.ll");
    ModuleRef* dst = ROC_ParseModule(ir.c_str());

    int ret;

    for (auto& bitcode : _bitcodes)
    {

        std::string builtins_bc = read_bc_from_file(bitcode.c_str());
        ModuleRef* bc_src = ROC_ParseBitcode(builtins_bc.c_str(),
                                             builtins_bc.size());

        // link the builtins into the module
        ret = ROC_ModuleLinkIn(dst, bc_src);
        EXPECT_TRUE(ret != 0);

        ROC_ModuleDestroy(bc_src);
    }

    const char * cpu = "fiji";

    // run an optimisation pass over the module
    ret = ROC_ModuleOptimize(dst, 3, 0, 1, cpu);
    ASSERT_TRUE(ret == 1);

    char * output;
    ret = ROC_ModuleEmitBRIG(dst, 2, cpu, &output);
    EXPECT_TRUE(ret > 0);

    char elf_string[] = "\x7f\x45\x4c\x46";

    // check this is an ELF object
    for (size_t i = 0; i < 4; i++)
    {
        EXPECT_TRUE(output[i]==elf_string[i]);
    }

    free(output);

    ROC_ModuleDestroy(dst);
}
// Test compilation call to BRIG works
Test compilation call to BRIG works
Test compilation call to BRIG works
TEST(TEST_BASE, test_compile_module_to_BRIG)
{
    ROC_Initialize();
    std::string ir = read_ir_from_file("demo_ir.ll");
    ModuleRef* dst = ROC_ParseModule(ir.c_str());
    int ret;
    for (auto& bitcode : _bitcodes)
    {
        std::string builtins_bc = read_bc_from_file(bitcode.c_str());
        ModuleRef* bc_src = ROC_ParseBitcode(builtins_bc.c_str(),
                                             builtins_bc.size());
        ret = ROC_ModuleLinkIn(dst, bc_src);
        EXPECT_TRUE(ret != 0);
        ROC_ModuleDestroy(bc_src);
    }
    const char * cpu = "fiji";
    ret = ROC_ModuleOptimize(dst, 3, 0, 1, cpu);
    ASSERT_TRUE(ret == 1);
    char * output;
    ret = ROC_ModuleEmitBRIG(dst, 2, cpu, &output);
    EXPECT_TRUE(ret > 0);
    char elf_string[] = "\x7f\x45\x4c\x46";
    for (size_t i = 0; i < 4; i++)
    {
        EXPECT_TRUE(output[i]==elf_string[i]);
    }
    free(output);
    ROC_ModuleDestroy(dst);
}
TEST ( TEST_BASE , test_compile_module_to_BRIG ) { ROC_Initialize ( ) ; std :: string ir = read_ir_from_file ( " " ) ; ModuleRef * dst = ROC_ParseModule ( ir . c_str ( ) ) ; int ret ; for ( auto & bitcode : _bitcodes ) { std :: string builtins_bc = read_bc_from_file ( bitcode . c_str ( ) ) ; ModuleRef * bc_src = ROC_ParseBitcode ( builtins_bc . c_str ( ) , builtins_bc . size ( ) ) ; ret = ROC_ModuleLinkIn ( dst , bc_src ) ; EXPECT_TRUE ( ret != 0 ) ; ROC_ModuleDestroy ( bc_src ) ; } const char * cpu = " " ; ret = ROC_ModuleOptimize ( dst , 3 , 0 , 1 , cpu ) ; ASSERT_TRUE ( ret == 1 ) ; char * output ; ret = ROC_ModuleEmitBRIG ( dst , 2 , cpu , & output ) ; EXPECT_TRUE ( ret > 0 ) ; char elf_string [ ] = " \x7f \x45 \x4c \x46 " ; for ( size_t i = 0 ; i < 4 ; i ++ ) { EXPECT_TRUE ( output [ i ] == elf_string [ i ] ) ; } free ( output ) ; ROC_ModuleDestroy ( dst ) ; }
Test compilation call to BRIG works
Test compilation call to BRIG works
// link the builtins into the module // run an optimisation pass over the module // check this is an ELF object