[llvm-dev] Parsing Operands at TableGen Level

9 views
Skip to first unread message

Sky Flyer via llvm-dev

unread,
Sep 15, 2015, 10:15:45 AM9/15/15
to llvm...@lists.llvm.org
Hi all,

is it possible in TableGen to set value to instruction bits based on the operands?
In other words, parsing the instruction at the TableGen level.

for instance:

"add $Rd, $Rn, $imm"

I want to have something like this:

Inst{8} = ($Rn == Test::A0)  1 : 0;

Is there any way to do that in TableGen? If not is there any example in the provided example codes?

Cheers,
ES

Tom Stellard via llvm-dev

unread,
Sep 15, 2015, 10:52:07 AM9/15/15
to Sky Flyer, llvm...@lists.llvm.org
On Tue, Sep 15, 2015 at 04:15:32PM +0200, Sky Flyer via llvm-dev wrote:
> Hi all,
>
> is it possible in TableGen to set value to instruction bits based on the
> operands?
> In other words, parsing the instruction at the TableGen level.
>
> for instance:
>
> "add $Rd, $Rn, $imm"
>
> I want to have something like this:
>
> *Inst{8} = ($Rn == Test::A0) 1 : 0;*
>

One solution to this is to add extra bits to the register encoding. Here is
a pseudo code example if you have 8-bit register encoding:

class ARegister : Register <string Name, bits<16> enc> : Register <name> {
let HWEncoding = enc;
}

def A0 : ARegister <"A0", 0x100>
def A1 : ARegister <"A1", 0x001>
def A2 : ARegister <"A2", 0x002>

...

class InstFormat {

bits<9> Rn;

Inst{7-0} = Rn{7-0};
Inst{8} = Rn{8}

}

-Tom


> Is there any way to do that in TableGen? If not is there any example in the
> provided example codes?
>
> Cheers,
> ES

> _______________________________________________
> LLVM Developers mailing list
> llvm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Sky Flyer via llvm-dev

unread,
Sep 16, 2015, 6:08:02 AM9/16/15
to Tom Stellard, llvm...@lists.llvm.org
That really helped!
Thanks a lot.
Reply all
Reply to author
Forward
0 new messages