[LLVMdev] Using patterns inside patterns
clattner at apple.com
Thu Oct 30 10:28:43 PDT 2008
On Oct 30, 2008, at 9:18 AM, Villmow, Micah wrote:
> I do not have access to a subtraction routine, as it is considered
> add with negation on the second parameter, so I have this pattern:
> // integer subtraction
> // a - b ==> a + (-b)
> def ISUB : Pat<(sub GPRI32:$src0, GPRI32:$src1),
> (IADD GPRI32:$src0, (INEGATE GPRI32:$src1))>;
The best way to find answers to these types of questions is to look
for examples in other targets. For example, PPC has this Pat pattern
which synthesizes an immediate with two instructions:
// Arbitrary immediate support. Implement in terms of LIS/ORI.
def : Pat<(i32 imm:$imm),
(ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
It also has stuff like this:
// Implement the 'not' operation with the NOR instruction.
def NOT : Pat<(not GPRC:$in),
(NOR GPRC:$in, GPRC:$in)>;
For more information, please see the powerpc .td files. In answer to
your question, you can't map target-independent nodes to target-
independent nodes, you have to map them to target specific
instructions: ORI/LIS/NOR in these examples.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev