Sky Flyer via llvm-dev
2015-Sep-15 14:15 UTC
[llvm-dev] Parsing Operands at TableGen Level
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150915/9a6c3c73/attachment-0001.html>
Tom Stellard via llvm-dev
2015-Sep-15 14:51 UTC
[llvm-dev] Parsing Operands at TableGen Level
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-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Sky Flyer via llvm-dev
2015-Sep-16 10:07 UTC
[llvm-dev] Parsing Operands at TableGen Level
That really helped! Thanks a lot. On Tue, Sep 15, 2015 at 4:51 PM, Tom Stellard <tom at stellard.net> wrote:> 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-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150916/b8656276/attachment.html>