[llvm-dev] how to set BaseOpcode when using multiclass for relation model in td file

Björn Pettersson A via llvm-dev llvm-dev at lists.llvm.org
Tue May 25 12:50:04 PDT 2021


(just some additional info related to my earlier answer)

And if you have a ColFields named “PredSense” (as in the example in the document you linked),
and aa is maps to PredSense being “true” and bb maps to PredSense being “false”,
then a more complete example would be

multiclass MFORM<string BaseName, …> {
  let BaseOpcode = BaseName in {
    let PredSense = “true” in
    def BaseName#_aa : VFORM<…>;
    let PredSense = “false” in
    def BaseName#_bb : VFORM<…>;
  }
}
defm “” : MFORM<”MOV”, …>;
defm “” : MFORM<”P_MOV”, …>;

(unless you wrap those PredSense settings into the VFORM class somehow)

/Björn

From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Björn Pettersson A via llvm-dev
Sent: den 25 maj 2021 21:40
To: 林政宗 <jackie_linzz at 126.com>; llvm-dev <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] how to set BaseOpcode when using multiclass for relation model in td file

I think that you for example should be able to do something like this:

multiclass MFORM<string BaseName, …> {
  let BaseOpcode = BaseName in {
    def BaseName#_aa : VFORM<…>;
    def BaseName#_bb : VFORM<…>;
  }
}
defm “” : MFORM<”MOV”, …>;
defm “” : MFORM<”P_MOV”, …>;

/Björn

From: llvm-dev <llvm-dev-bounces at lists.llvm.org<mailto:llvm-dev-bounces at lists.llvm.org>> On Behalf Of ??? via llvm-dev
Sent: den 24 maj 2021 17:03
To: llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
Subject: [llvm-dev] how to set BaseOpcode when using multiclass for relation model in td file

Hi,

I am trying to relate normal instructions with predicate instructions. I have read the document How To Use Instruction Mappings — LLVM 12 documentation<https://protect2.fireeye.com/v1/url?k=93a78a7d-cc3cb330-93a7cae6-86b568293eb5-73720be28813bde3&q=1&e=3e653e85-9f00-4403-9d18-ece444e45ae9&u=https%3A%2F%2Fllvm.org%2Fdocs%2FHowToUseInstrMappings.html>.
If normal instruction and the corresponding instruction are related, they should have the same BaseOpcode.
The document covers class/def only. It doesn't cover multiclass/defm.
for example:
class VFORM<...> {...}
multiclass MFORM<...> {
def _aa: VFORM<...>;
def _bb: VFORM<...>;
}
defm MOV: MFORM<...>;
defm P_MOV: MFORM<...>;

P_MOV_aa and P_MOV_bb are the corresponding predicate instruction of MOV_aa and MOV_bb.
when relating P_MOV_aa with MOV_aa and P_MOV_bb with MOV_bb, they should have the same BaseOpcode.
I think the normal instruction definition name is the best option for BaseOpcode, such as "MOV_aa" and "MOV_bb".
Could I get the instruction definition name automatically and assign it to BaseOpcode in td file?
Or is there a convenint way to set BaseOpcode for normal/predicate instruction when using multiclass/defm?




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210525/28514e51/attachment.html>


More information about the llvm-dev mailing list