1706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers/*
2706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * Copyright (C) 2012 The Android Open Source Project
3706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers *
4706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * Licensed under the Apache License, Version 2.0 (the "License");
5706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * you may not use this file except in compliance with the License.
6706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * You may obtain a copy of the License at
7706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers *
8706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers *      http://www.apache.org/licenses/LICENSE-2.0
9706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers *
10706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * Unless required by applicable law or agreed to in writing, software
11706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * distributed under the License is distributed on an "AS IS" BASIS,
12706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * See the License for the specific language governing permissions and
14706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers * limitations under the License.
15706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers */
16706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers
1702ed4c04468ca5f5540c5b704ac3e2f30eb9e8f4Ian Rogers#ifndef ART_DISASSEMBLER_DISASSEMBLER_X86_H_
1802ed4c04468ca5f5540c5b704ac3e2f30eb9e8f4Ian Rogers#define ART_DISASSEMBLER_DISASSEMBLER_X86_H_
19706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers
20706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers#include "disassembler.h"
21706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers
22706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogersnamespace art {
23706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogersnamespace x86 {
24706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers
25e5eb7060dbacfd7c768692a8fcc4a6017d0bd1ccAndreas Gampeenum RegFile { GPR, MMX, SSE };
26e5eb7060dbacfd7c768692a8fcc4a6017d0bd1ccAndreas Gampe
2738e12034f1ef2b32e98b6e49cb36b7cc37a7f1beIan Rogersclass DisassemblerX86 FINAL : public Disassembler {
28706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers public:
292cbaccb67e22c0b313a9785bfc65bcb4b25d0676Brian Carlstrom  DisassemblerX86(DisassemblerOptions* options, bool supports_rex)
302cbaccb67e22c0b313a9785bfc65bcb4b25d0676Brian Carlstrom      : Disassembler(options), supports_rex_(supports_rex) {}
3138e12034f1ef2b32e98b6e49cb36b7cc37a7f1beIan Rogers
3238e12034f1ef2b32e98b6e49cb36b7cc37a7f1beIan Rogers  size_t Dump(std::ostream& os, const uint8_t* begin) OVERRIDE;
3338e12034f1ef2b32e98b6e49cb36b7cc37a7f1beIan Rogers  void Dump(std::ostream& os, const uint8_t* begin, const uint8_t* end) OVERRIDE;
34706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers
35706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers private:
36706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers  size_t DumpInstruction(std::ostream& os, const uint8_t* instr);
3738e12034f1ef2b32e98b6e49cb36b7cc37a7f1beIan Rogers
38e5eb7060dbacfd7c768692a8fcc4a6017d0bd1ccAndreas Gampe  std::string DumpAddress(uint8_t mod, uint8_t rm, uint8_t rex64, uint8_t rex_w, bool no_ops,
39e5eb7060dbacfd7c768692a8fcc4a6017d0bd1ccAndreas Gampe                          bool byte_operand, bool byte_second_operand, uint8_t* prefix, bool load,
40e5eb7060dbacfd7c768692a8fcc4a6017d0bd1ccAndreas Gampe                          RegFile src_reg_file, RegFile dst_reg_file, const uint8_t** instr,
41e5eb7060dbacfd7c768692a8fcc4a6017d0bd1ccAndreas Gampe                          uint32_t* address_bits);
42e5eb7060dbacfd7c768692a8fcc4a6017d0bd1ccAndreas Gampe
4338e12034f1ef2b32e98b6e49cb36b7cc37a7f1beIan Rogers  const bool supports_rex_;
4438e12034f1ef2b32e98b6e49cb36b7cc37a7f1beIan Rogers
4538e12034f1ef2b32e98b6e49cb36b7cc37a7f1beIan Rogers  DISALLOW_COPY_AND_ASSIGN(DisassemblerX86);
46706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers};
47706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers
48706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers}  // namespace x86
49706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers}  // namespace art
50706a10ea53a32455c6b3ffc5e5e0e1f6f191ec2aIan Rogers
5102ed4c04468ca5f5540c5b704ac3e2f30eb9e8f4Ian Rogers#endif  // ART_DISASSEMBLER_DISASSEMBLER_X86_H_
52