[llvm] [DecoderEmitter] Support for DecodeOrder and `resolve-conflicts-try-all` (PR #157948)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 10:30:07 PDT 2025


================
@@ -1598,6 +1726,19 @@ void FilterChooser::doFilter() {
     return;
   }
 
+  // If we were unable to find a useful filter and there are multiple decode
+  // orders involved, split the candidates by decode order and create per decode
+  // order choosers.
+  if (hasMultipleDecodeOrders()) {
----------------
jurahul wrote:

Thanks.  I am working on the first step here, which is to eliminate `DecodeComplete`. Essentially, for TryDecode, a return status of Fail can be interpreted as incomplete decoding. This keeps the interpretation as simple as if decoding is not successful and the decoder is not complete; we need to try more. Testing with `check-llvm-mc-aarch64` (the only target that uses this feature) shows all tests pass. See https://github.com/llvm/llvm-project/pull/159130.

step 2 then could be to lift the restriction that `hasCompleteDecoder` cannot apply to generated decoders. It just means that the decoding failure for this op (from either generated or custom decoders) is not a terminal failure but a signal to attempt more (i.e., how to interpret the result of decodeToMCInst). [This is not strictly necessary but seems reasonable to me].

In general, we would expect that an instruction with hasCompleteDecoder = 0 is in a scope so that it can be popped to try another inst, unless this instruction is the last in the list of attempted ones. When we have a filter with both FilteredIDs and VariableIDs, we first insert a scope around FilteredIDs, and that seems correct, since based on the filtered bits, only of the encodings in FilteredIDs is expected to match, else fail. But if `VariableFC` has multiple entries and some have hasCompleteDecoder = 0, we need to try them all I'd think, but today we don't (need to concretize this more).

Next is to then address case #3. For example, before declaring a conflict and failing, we check if among the set of instructions remaining, if they all have hasCompleteDecoder = false, we can attempt them one by one. 

Anyway, just some thoughts that probably need more validation.

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


More information about the llvm-commits mailing list