[PATCH] D120476: [LoongArch] Add basic support to AsmParser

WÁNG Xuěruì via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 8 22:38:47 PST 2022


xen0n accepted this revision.
xen0n added a comment.

Although I only randomly verified one instruction's encoding (by hand and cross-checking with binutils), as the testcases seem to be auto-generated, I feel the rest should be okay as well (or you probably would not get very far in real world usage).



================
Comment at: llvm/lib/Target/LoongArch/LoongArchInstrInfo.td:65
+
+def simm12 : Operand<GRLenVT>, ImmLeaf<GRLenVT, [{return isInt<12>(Imm);}]> {
+  let ParserMatchClass = SImmAsmOperand<12>;
----------------
SixWeining wrote:
> xen0n wrote:
> > I may have missed this in the previous patches, but why does only this kind of imm get the `ImmLeaf` treatment? I briefly looked at the other targets and they seem to mark most of their commonly used immediate kinds as such.
> The `ImmLeaf` is used in instruction selection stage to match the immediate. Yes, all immediate kinds that could be used in instruction selection should be defined with `ImmLeaf`. They will added when we implement the `codegen`.
> 
> The reason why only `simm12` is defined with `ImmLeaf` is that in line 491 we defined a few instruction selection `Pat`s: 
> ```
> ...
> def : PatGprImm<add, ADDI_W, simm12>;
> ...
> ```
> 
> These `Pat`s here are just to demonstrate layout of this `.td` file and the way to define `Pat`. Of course, more `Pat`s will be defined later to support `codegen`.
> 
> Sorry for the confusion. I hope I make it clear now.
Okay, understood. It's generally better to only add things when absolutely needed though, this way you don't have to explain every time that these are "to be used later".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120476/new/

https://reviews.llvm.org/D120476



More information about the llvm-commits mailing list