[llvm] [RISCV][GISel] Add ISel supports for SHXADD from Zba extension (PR #67863)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 11:06:58 PDT 2023


================
@@ -235,10 +235,7 @@ def SimmShiftRightBy3XForm : SDNodeXForm<imm, [{
 }]>;
 
 // Pattern to exclude simm12 immediates from matching.
-def non_imm12 : PatLeaf<(XLenVT GPR:$a), [{
-  auto *C = dyn_cast<ConstantSDNode>(N);
-  return !C || !isInt<12>(C->getSExtValue());
-}]>;
+def non_imm12 : ComplexPattern<XLenVT, 1, "selectNonImm12", [], [], 0>;
----------------
mshockwave wrote:

> Would add GISelPredicateCode to something like this work [topperc at 01205c1](https://github.com/topperc/llvm-project/commit/01205c136d77f682063a1218790f7cf0b3760fdc)

This works, though I'm a little concerned that this might create too many boilerplate code in the future, since there needs to be a Predicate TG record for every opcode that goes with non_imm12 (even we abstract the real predicate logics into a function or something). What do you think? 

Also, interestingly `GISelPredicateCode` doesn't dance well with `PredicateCodeUsesOperands`: it SEGFAULT llvm-tblgen in our case, despite the fact that there are tests for this exact combination (in `test/TableGen/GlobalISelEmitterCustomPredicate.td`).  I can't find an obvious fix for llvm-tblgen but writing a non-`PredicateCodeUsesOperands` predicate code also works.

https://github.com/llvm/llvm-project/pull/67863


More information about the llvm-commits mailing list