ferrandi / PandA-bambu

PandA-bambu public repository

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What I should obey to input LLVM IR into bambu?

hushanjushi opened this issue · comments

I want to input LLVM IR code into bambu, so I try to transfer the first C function of DATE tutorial into tutorial:

unsigned short icrc1(unsigned short crc, unsigned char onech)
{
    int i;
    unsigned short ans=(crc^onech << 8);
    
    for (i=0;i<8;i++) {
        if (ans & 0x8000)
            ans = (ans <<= 1) ^ 4129;
        else
            ans <<= 1;
    }
    return ans;
}

I use:

clang-12 -emit-llvm -S /home/test/workspace/content/bambu-tutorial/01-introduction/Exercise1/icrc.c -o /home/test/workspace/content/bambu-tutorial/01-introduction/Exercise1/icrc.ll
bambu icrc.ll --top-fname=icrc1 --simulate --simulator=VERILATOR --compiler=I386_CLANG12
bambu icrc.ll --top-fname=icrc1 --simulate --simulator=VERILATOR --compiler=I386_CLANG12

But I get:

error -> Missing input value for parameter: P0

error -> Error parsing the test vectors file /home/test/workspace/content/bambu-tutorial/01-introduction/Exercise1/test.xml

Please report bugs to <panda-info@polimi.it>

Is something I should change rather than default LLVM IR, like a front MLIR? Where should I find them?

You should check your test.xml file. It should report a test input value for each one of the top function arguments naming them P0, P1, ... based on their position in the signature.
The different naming with respect to the C example is due to LLVM renaming.
An example test.xml which you may use for the above could be the following:

<?xml version="1.0"?>
<function>
  <testbench P0="23" P1="10" />
</function>

The P0 value corresponds to crc argument, while P1 corresponds to onech.
Finally, if you need to initialise pointers or array values the above still stands and you can use standard C syntax inside the attribute values. As an example, if the top function signature is int my_top(int* arr) you may write something like P0="{1,2,3,4}" in your test.xml.

Ok, Thank you.