diff options
Diffstat (limited to 'Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h')
-rw-r--r-- | Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h | 94 |
1 files changed, 83 insertions, 11 deletions
diff --git a/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h b/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h index ed18d30df..89c00477d 100644 --- a/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h +++ b/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Apple Inc. All rights reserved. + * Copyright (C) 2012, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,8 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef A64DOpcode_h -#define A64DOpcode_h +#pragma once #include <wtf/Assertions.h> #include <stdint.h> @@ -165,19 +164,29 @@ protected: bufferPrintf("#%d", immediate); } + void appendSignedImmediate64(int64_t immediate) + { + bufferPrintf("#%" PRIi64, immediate); + } + void appendUnsignedImmediate(unsigned immediate) { bufferPrintf("#%u", immediate); } + void appendUnsignedHexImmediate(unsigned immediate) + { + bufferPrintf("#0x%x", immediate); + } + void appendUnsignedImmediate64(uint64_t immediate) { - bufferPrintf("#0x%llx", immediate); + bufferPrintf("#0x%" PRIx64, immediate); } void appendPCRelativeOffset(uint32_t* pc, int32_t immediate) { - bufferPrintf("0x%llx", reinterpret_cast<uint64_t>(pc + immediate)); + bufferPrintf("0x%" PRIx64, reinterpret_cast<uint64_t>(pc + immediate)); } void appendShiftAmount(unsigned amount) @@ -313,7 +322,7 @@ private: static const char* const s_opNames[4]; public: - static const uint32_t mask = 0x1fe00010; + static const uint32_t mask = 0x1fe00000; static const uint32_t pattern = 0x1a800000; DEFINE_STATIC_FORMAT(A64DOpcodeConditionalSelect, thisObj); @@ -328,6 +337,25 @@ public: unsigned op2() { return (m_opcode >> 10) & 0x3; } }; +class A64DOpcodeDataProcessing1Source : public A64DOpcode { +private: + static const char* const s_opNames[8]; + +public: + static const uint32_t mask = 0x5fe00000; + static const uint32_t pattern = 0x5ac00000; + + DEFINE_STATIC_FORMAT(A64DOpcodeDataProcessing1Source, thisObj); + + const char* format(); + + const char* opName() { return s_opNames[opNameIndex()]; } + unsigned sBit() { return (m_opcode >> 29) & 0x1; } + unsigned opCode() { return (m_opcode >> 10) & 0x3f; } + unsigned opCode2() { return (m_opcode >> 16) & 0x1f; } + unsigned opNameIndex() { return (opCode() & 0x7); } +}; + class A64DOpcodeDataProcessing2Source : public A64DOpcode { private: static const char* const s_opNames[8]; @@ -359,7 +387,7 @@ public: const char* format(); - const char* opName() { return ra() == 31 ? s_opNames[opNum() & 0xf] : s_pseudoOpNames[opNum() & 0xf]; } + const char* opName() { return ra() == 31 ? s_pseudoOpNames[opNum() & 0xf] : s_opNames[opNum() & 0xf]; } unsigned ra() { return (m_opcode >> 10) & 0x1f; } unsigned op54() { return (m_opcode >> 29) & 0x3; } unsigned op31() { return (m_opcode >> 21) & 0x7; } @@ -369,7 +397,7 @@ public: class A64OpcodeExceptionGeneration : public A64DOpcode { public: - static const uint32_t mask = 0xff000010; + static const uint32_t mask = 0xff000000; static const uint32_t pattern = 0xd4000000; DEFINE_STATIC_FORMAT(A64OpcodeExceptionGeneration, thisObj); @@ -423,6 +451,20 @@ public: unsigned opNum() { return (m_opcode >> 3) & 0x3; } }; +class A64DOpcodeFloatingPointConditionalSelect : public A64DOpcodeFloatingPointOps { +public: + static const uint32_t mask = 0x5f200c00; + static const uint32_t pattern = 0x1e200c00; + + DEFINE_STATIC_FORMAT(A64DOpcodeFloatingPointConditionalSelect, thisObj); + + const char* format(); + + const char* opName() { return "fcsel"; } + + unsigned condition() { return (m_opcode >> 12) & 0xf; } +}; + class A64DOpcodeFloatingPointDataProcessing1Source : public A64DOpcodeFloatingPointOps { private: static const char* const s_opNames[16]; @@ -510,6 +552,22 @@ public: unsigned immediate7() { return (m_opcode >> 5) & 0x7f; } }; +class A64DOpcodeDmb : public A64DOpcode { + static const char* const s_optionNames[16]; + +public: + static const uint32_t mask = 0xfffff0ff; + static const uint32_t pattern = 0xd50330bf; + + DEFINE_STATIC_FORMAT(A64DOpcodeDmb, thisObj); + + const char* format(); + + const char* opName() { return "dmb"; } + const char* option() { return s_optionNames[crM()]; } + unsigned crM() { return (m_opcode >> 8) & 0xf; } +}; + class A64DOpcodeLoadStore : public A64DOpcode { private: static const char* const s_opNames[32]; @@ -565,6 +623,22 @@ public: int sBit() { return (m_opcode >> 12) & 0x1; } }; +class A64DOpcodeLoadStoreRegisterPair : public A64DOpcodeLoadStore { +public: + static const uint32_t mask = 0x3a000000; + static const uint32_t pattern = 0x28000000; + + DEFINE_STATIC_FORMAT(A64DOpcodeLoadStoreRegisterPair, thisObj); + + const char* format(); + const char* opName(); + + unsigned rt2() { return (m_opcode >> 10) & 0x1f; } + int immediate7() { return (static_cast<int>((m_opcode >> 15) & 0x7f) << 25) >> 25; } + unsigned offsetMode() { return (m_opcode >> 23) & 0x7; } + int lBit() { return (m_opcode >> 22) & 0x1; } +}; + class A64DOpcodeLoadStoreUnsignedImmediate : public A64DOpcodeLoadStore { public: static const uint32_t mask = 0x3b000000; @@ -618,7 +692,7 @@ public: const char* format(); bool isTst() { return ((opNumber() == 6) && (rd() == 31)); } - bool isMov() { return ((opNumber() == 2) && (rn() == 31)); } + bool isMov() { return ((opc() == 1) && (rn() == 31)); } unsigned opNumber() { return (opc() << 1) | nBit(); } unsigned shift() { return (m_opcode >> 22) & 0x3; } int immediate6() { return (static_cast<int>((m_opcode >> 10) & 0x3f) << 26) >> 26; } @@ -688,5 +762,3 @@ public: } } // namespace JSC::ARM64Disassembler using JSC::ARM64Disassembler::A64DOpcode; - -#endif // A64DOpcode_h |