A64: Add ExceptionRaised IR instruction

The purpose of this instruction is to raise exceptions when certain decode-time
issues happen, instead of asserting at translate time. This allows us to
use the translator for code analysis without worrying about unnecessary asserts,
but also provides flexibility for the library user to perform custom behaviour
when one of these states are raised.
This commit is contained in:
MerryMage
2018-01-13 17:54:29 +00:00
parent 71a1851ee6
commit 0992987c98
7 changed files with 41 additions and 4 deletions

View File

@@ -16,6 +16,17 @@ namespace A64 {
using VAddr = std::uint64_t;
enum class Exception {
/// An UndefinedFault occured due to executing instruction with an unallocated encoding
UnallocatedEncoding,
/// An UndefinedFault occured due to executing instruction containing a reserved value
ReservedValue,
/// An unpredictable instruction is to be executed. Implementation-defined behaviour should now happen.
/// This behaviour is up to the user of this library to define.
/// Note: Constraints on unpredictable behaviour are specified in the ARMv8 ARM.
UnpredictableInstruction,
};
struct UserCallbacks {
virtual ~UserCallbacks() = default;
@@ -47,6 +58,8 @@ struct UserCallbacks {
// This callback is called whenever a SVC instruction is executed.
virtual void CallSVC(std::uint32_t swi) = 0;
virtual void ExceptionRaised(VAddr pc, Exception exception) = 0;
// Timing-related callbacks
// ticks ticks have passed
virtual void AddTicks(std::uint64_t ticks) = 0;