mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
4f9907e752
When FixedLenDecoder matches an input bitpattern of form [01]+ with an instruction bitpattern of form [01?]+ (where 0/1 are static bits and ? are mixed/variable bits) it passes the input bitpattern to a specific instruction decoder method which then makes a final decision whether the bitpattern is a valid instruction or not. This means the decoder must handle all possible values of the variable bits which sometimes leads to opcode rewrites in the decoder method when the instructions are not fully orthogonal. The patch provides a way for the decoder method to say that when it returns Fail it does not necessarily mean the bitpattern is invalid, but rather that the bitpattern is definitely not an instruction that is recognized by the decoder method. The decoder can then try to match the input bitpattern with other possible instruction bitpatterns. For example, this allows to solve a situation on AArch64 where the `MSR (immediate)` instruction has form: 1101 0101 0000 0??? 0100 ???? ???1 1111 but not all values of the ? bits are allowed. The rejected values should be handled by the `extended MSR (register)` instruction: 1101 0101 000? ???? ???? ???? ???? ???? The decoder will first try to decode an input bitpattern that matches both bitpatterns as `MSR (immediate)` but currently this puts the decoder method of `MSR (immediate)` into a situation when it must be able to decode all possible values of the ? bits, i.e. it would need to rewrite the instruction to `MSR (register)` when it is not `MSR (immediate)`. The patch allows to specify that the decoder method cannot determine if the instruction is valid for all variable values. The decoder method can simply return Fail when it knows it is definitely not `MSR (immediate)`. The decoder will then backtrack the decoding and find that it can match the input bitpattern with the more generic `MSR (register)` bitpattern too. Differential Revision: http://reviews.llvm.org/D7174 llvm-svn: 242274
35 lines
1.4 KiB
C++
35 lines
1.4 KiB
C++
//===-- llvm/MC/MCFixedLenDisassembler.h - Decoder driver -------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
// Fixed length disassembler decoder state machine driver.
|
|
//===----------------------------------------------------------------------===//
|
|
#ifndef LLVM_MC_MCFIXEDLENDISASSEMBLER_H
|
|
#define LLVM_MC_MCFIXEDLENDISASSEMBLER_H
|
|
|
|
namespace llvm {
|
|
|
|
namespace MCD {
|
|
// Disassembler state machine opcodes.
|
|
enum DecoderOps {
|
|
OPC_ExtractField = 1, // OPC_ExtractField(uint8_t Start, uint8_t Len)
|
|
OPC_FilterValue, // OPC_FilterValue(uleb128 Val, uint16_t NumToSkip)
|
|
OPC_CheckField, // OPC_CheckField(uint8_t Start, uint8_t Len,
|
|
// uleb128 Val, uint16_t NumToSkip)
|
|
OPC_CheckPredicate, // OPC_CheckPredicate(uleb128 PIdx, uint16_t NumToSkip)
|
|
OPC_Decode, // OPC_Decode(uleb128 Opcode, uleb128 DIdx)
|
|
OPC_TryDecode, // OPC_TryDecode(uleb128 Opcode, uleb128 DIdx,
|
|
// uint16_t NumToSkip)
|
|
OPC_SoftFail, // OPC_SoftFail(uleb128 PMask, uleb128 NMask)
|
|
OPC_Fail // OPC_Fail()
|
|
};
|
|
|
|
} // namespace MCDecode
|
|
} // namespace llvm
|
|
|
|
#endif
|