Hi *
For my educational project (MC6809 backend), I’m trying to write a Pat<>
to match a compare/branch combination.
I’m aiming for 100% pattern importing by GlobalISel, as I’ve discovered it does a much better job than my manual lowering efforts.
The TableGen GlobalISel pattern importer is objecting to this (simplified a bit):
def : Pat<(brcond (i8 (setcc ACC8:$src, (i8 imm:$val), SETEQ)), bb:$tgt),
(ConditionalBranchRelative (i8 12), bb:$tgt, (Compare_i8_Imm ACC8:$src, i8imm:$val))>;
… where ConditionalBranchRelative
and Compare_i8_Imm
are pseudo-instructions that I lower further once the register allocator is done The (i8 12)
is how I’m passing the SETEQ
condition to the condtional branch instruction. The i1
bit returned by the comparison and consumed by the branch is thrown away shortly after this, and the condition register bits carry the results of the comparison.
The objection is:
Type set is empty for each HW mode:
possible type contradiction in the pattern below (use -print-records with llvm-tblgen to see all expanded records).
CompBraPat_i8_Imm: (ConditionalBranchRelative 12:{ *:[] }, (bb:{}):$tgt, (Compare_i8_Imm:{} ACC8:{}:$src, i8imm:{}:$val))
Generated from record:
CompBraPat_i8_Imm { // Pattern Pat
dag PatternToMatch = (brcond (i8 (setcc ACC8:$src, (i8 imm:$val), SETEQ)), bb:$tgt);
list<dag> ResultInstrs = [(ConditionalBranchRelative (i8 12), bb:$tgt, (Compare_i8_Imm ACC8:$src, i8imm:$val))];
list<Predicate> Predicates = [];
int AddedComplexity = 0;
}
I have little idea how to even read this. What is it objecting to? The usual web searches have given me hints about operand size incompatibilities, but I can’t see what it doesn’t like.
I’ve been able to make similar problems go away before by fiddling, but I don’t really know what I did to fix it. In this case, the usual frobs are not helping.
Could some kind soul please explain how I can find where the error lies? I’ve tried peeking inside TableGen with a debugger, but not knowing what to look for is making my confusion worse, and there is a lot of detail in the above report.
Thanks!
M