Hi, I’m just little bit confusing of how to use PatFrags
, let me present my understanding of PatFrags
:
- The first parameter is the accepting format, it has a form of
(ops node:$name1, node:$name2, ...)
- The second parameter, which is a list of DAGs, is the “replacement possibilities”, within these DAGs any use of
node:$name#i
will be replaced by the instantiated accepting format
Now I’m going to use an example to illustrate my question, suppose we have the PatFrags
defined as follow:
def test_add_frag : PatFrags<
(ops node:$a, node:$b),
[
(add node:$a, node$:b),
(mul node:$a, (div (add node:$a, node:$b), node:$a))
]
>;
We use that as patterns of an instruction:
def ADD : Instruction {
...
let Pattern = [(set Reg:$dst, (test_add_frag reg_or_imm:$src0, reg_or_imm:$src1))];;
...
};
Now my questions is since the PatFrags
is inside of one DAG, how to show that it is matching a list, is it equivalent to the following so that it is matching both pattern generated from the divergent of PatFrags
?
def ADD : Instruction {
...
let Pattern = [
(set Reg:$dst, (add reg_or_imm:$src0, reg_or_imm:$src1)),
(set Reg:$dst, (mul reg_or_imm:$src0, (div (add reg_or_imm:$src0, reg_or_imm:$src1), reg_or_imm:$src0)))
];;
...
};
Thanks!