It seems that patterns are matched in the order that they appear in the td file. Is this something we can rely on? def: ArithLogicI16_pat<add, immSExt8, AddiuRxRxImm16>; def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>; the immSExt8 will only match a 8 bit signed value. I want it to try the first pattern and then the second, if it fails. AddiuRxRxImm16 --- 16 bit instruction AddiuRxRxXImm16 -- 32 bit instruction
On Feb 8, 2013, at 9:38 AM, Reed Kotler <rkotler at mips.com> wrote:> It seems that patterns are matched in the order that they appear in the td file. > > Is this something we can rely on?It is by design but it is the last resort for ordering, and it is very fragile to depend on that. It is better to use AddedComplexity to control pattern ordering when required. /jakob
Jakob Stoklund Olesen <stoklund at 2pi.dk> writes:> On Feb 8, 2013, at 9:38 AM, Reed Kotler <rkotler at mips.com> wrote: > >> It seems that patterns are matched in the order that they appear in the td file. >> Is this something we can rely on? > > It is by design but it is the last resort for ordering, and it is very fragile to depend on that. > > It is better to use AddedComplexity to control pattern ordering when required.This matches my experience. BTW, why is it called "AddedComplexity?" That's a quite misleading name. Should we rename it to something else, maybe, "SelectionWeight?" "SelectionPriority" would be better still but that's also misleading since larger numbers => higher priority. -David