Skip to contentSkip to conversation

ARM aarch64 disas output libvixl support

RFC In review Claudio Fontana 5 participants 14 messages Sep 11, 2013 – Sep 16, 2013

lore
Share & tools
lore
#0 lore raw

cover ARM aarch64 disas output libvixl support

This is the aarch64 libvixl support patchset in the current state. It provides (limited) support for disassembly output on aarch64. Only host disassembly is enabled, since target for aarch64 is not in yet.

An external objdump solution as exemplified before by R.H. seems preferable to me, even if it means giving up the monitor support.
I'd rather have correct output from -d.
The run time need for debugging assembly is already fulfilled by gdb better than the monitor.

libvixl does not support many opcodes right now, is C++, and it is documented as working only for a 64bit host with a LP64 memory model.

Claudio Fontana (4):
configure: add c++ compiler support rules.mak: support C++ compiling and linking
disas: add libvixl source code for aarch64
disas: implement host disassembly output for aarch64

 configure                                    |   21 +
 disas.c                                      |    2 +
 disas/Makefile.objs                          |    7 +
 disas/aarch64-cxx.cc                         |   53 +
 disas/aarch64.c                              |   45 +
 disas/libvixl/LICENCE                        |   30 +
 disas/libvixl/Makefile.objs                  |    6 +
 disas/libvixl/README.md                      |  128 ++
 disas/libvixl/doc/changelog.md               |   12 +
 disas/libvixl/doc/supported-instructions.md  | 1133 ++++++++++++++
 disas/libvixl/src/a64/assembler-a64.cc       | 2172 ++++++++++++++++++++++++++
 disas/libvixl/src/a64/assembler-a64.h        | 1784 +++++++++++++++++++++
 disas/libvixl/src/a64/constants-a64.h        | 1104 +++++++++++++
 disas/libvixl/src/a64/cpu-a64.cc             |  148 ++
 disas/libvixl/src/a64/cpu-a64.h              |   56 +
 disas/libvixl/src/a64/debugger-a64.cc        | 1511 ++++++++++++++++++
 disas/libvixl/src/a64/debugger-a64.h         |  188 +++
 disas/libvixl/src/a64/decoder-a64.cc         |  712 +++++++++
 disas/libvixl/src/a64/decoder-a64.h          |  198 +++
 disas/libvixl/src/a64/disasm-a64.cc          | 1678 ++++++++++++++++++++
 disas/libvixl/src/a64/disasm-a64.h           |  109 ++
 disas/libvixl/src/a64/instructions-a64.cc    |  238 +++
 disas/libvixl/src/a64/instructions-a64.h     |  344 ++++
 disas/libvixl/src/a64/instrument-a64.cc      |  638 ++++++++
 disas/libvixl/src/a64/instrument-a64.h       |  108 ++
 disas/libvixl/src/a64/macro-assembler-a64.cc | 1108 +++++++++++++
 disas/libvixl/src/a64/macro-assembler-a64.h  | 1175 ++++++++++++++
 disas/libvixl/src/a64/simulator-a64.cc       | 2077 ++++++++++++++++++++++++
 disas/libvixl/src/a64/simulator-a64.h        |  576 +++++++
 disas/libvixl/src/globals.h                  |   66 +
 disas/libvixl/src/platform.h                 |   43 +
 disas/libvixl/src/utils.cc                   |  120 ++
 disas/libvixl/src/utils.h                    |  126 ++
 include/disas/bfd.h                          |    1 +
 rules.mak                                    |   24 +-
 35 files changed, 17737 insertions(+), 4 deletions(-)
 create mode 100644 disas/aarch64-cxx.cc
 create mode 100644 disas/aarch64.c
 create mode 100644 disas/libvixl/LICENCE
 create mode 100644 disas/libvixl/Makefile.objs
 create mode 100644 disas/libvixl/README.md
 create mode 100644 disas/libvixl/doc/changelog.md
 create mode 100644 disas/libvixl/doc/supported-instructions.md
 create mode 100644 disas/libvixl/src/a64/assembler-a64.cc
 create mode 100644 disas/libvixl/src/a64/assembler-a64.h
 create mode 100644 disas/libvixl/src/a64/constants-a64.h
 create mode 100644 disas/libvixl/src/a64/cpu-a64.cc
 create mode 100644 disas/libvixl/src/a64/cpu-a64.h
 create mode 100644 disas/libvixl/src/a64/debugger-a64.cc
 create mode 100644 disas/libvixl/src/a64/debugger-a64.h
 create mode 100644 disas/libvixl/src/a64/decoder-a64.cc
 create mode 100644 disas/libvixl/src/a64/decoder-a64.h
 create mode 100644 disas/libvixl/src/a64/disasm-a64.cc
 create mode 100644 disas/libvixl/src/a64/disasm-a64.h
 create mode 100644 disas/libvixl/src/a64/instructions-a64.cc
 create mode 100644 disas/libvixl/src/a64/instructions-a64.h
 create mode 100644 disas/libvixl/src/a64/instrument-a64.cc
 create mode 100644 disas/libvixl/src/a64/instrument-a64.h
 create mode 100644 disas/libvixl/src/a64/macro-assembler-a64.cc
 create mode 100644 disas/libvixl/src/a64/macro-assembler-a64.h
 create mode 100644 disas/libvixl/src/a64/simulator-a64.cc
 create mode 100644 disas/libvixl/src/a64/simulator-a64.h
 create mode 100644 disas/libvixl/src/globals.h
 create mode 100644 disas/libvixl/src/platform.h
 create mode 100644 disas/libvixl/src/utils.cc
 create mode 100644 disas/libvixl/src/utils.h
Signature · 1 line
1.8.1
#1 lore raw

RFC 1/4 configure: add c++ compiler support

This patch is similar to Tomoki Sekiyama's
[PATCH v9 01/10] configure: Support configuring C++ compile, with the main differences being:

not using "c++" as default compiler, instead do not enable by default (requires explicit CXX env, --cxx option or cross-compilation prefix)

separate CFLAGS and CXXFLAGS in the default way.

---
 configure | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
configure +15 -0
index 0a55c20..6b73d99 100755
@@ -252,6 +252,8 @@ for opt do
   ;;
   --cc=*) CC="$optarg"
   ;;
+  --cxx=*) CXX="$optarg"
+  ;;
   --source-path=*) source_path="$optarg"
   ;;
   --cpu=*) cpu="$optarg"
@@ -282,6 +284,12 @@ else
   cc="${CC-${cross_prefix}gcc}"
 fi
 
+if test -z "${CXX}${cross_prefix}"; then
+  cxx=""
+else
+  cxx="${CXX-${cross_prefix}g++}"
+fi
+
 ar="${AR-${cross_prefix}ar}"
 as="${AS-${cross_prefix}as}"
 cpp="${CPP-$cc -E}"
@@ -305,6 +313,7 @@ QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLA
 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
 if test "$debug_info" = "yes"; then
     CFLAGS="-g $CFLAGS"
+    CXXFLAGS="-g $CXXFLAGS"
     LDFLAGS="-g $LDFLAGS"
 fi
 
@@ -622,6 +631,8 @@ for opt do
   ;;
   --host-cc=*) host_cc="$optarg"
   ;;
+  --cxx=*)
+  ;;
   --objcc=*) objcc="$optarg"
   ;;
   --make=*) make="$optarg"
@@ -1023,6 +1034,7 @@ echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
 echo "  --cc=CC                  use C compiler CC [$cc]"
 echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
 echo "                           build time"
+echo "  --cxx=CXX                use C++ compiler CXX [$cxx]"
 echo "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
 echo "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
@@ -3553,6 +3565,7 @@ fi
 echo "Source path       $source_path"
 echo "C compiler        $cc"
 echo "Host C compiler   $host_cc"
+echo "C++ compiler      $cxx"
 echo "Objective-C compiler $objcc"
 echo "CFLAGS            $CFLAGS"
 echo "QEMU_CFLAGS       $QEMU_CFLAGS"
@@ -4140,6 +4153,7 @@ echo "PYTHON=$python" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
 echo "CC_I386=$cc_i386" >> $config_host_mak
 echo "HOST_CC=$host_cc" >> $config_host_mak
+echo "CXX=$cxx" >> $config_host_mak
 echo "OBJCC=$objcc" >> $config_host_mak
 echo "AR=$ar" >> $config_host_mak
 echo "AS=$as" >> $config_host_mak
@@ -4149,6 +4163,7 @@ echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
 echo "LIBTOOL=$libtool" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
+echo "CXXFLAGS=$CXXFLAGS" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
 if test "$sparse" = "yes" ; then
Signature · 1 line
1.8.1
#2 lore raw

RFC 2/4 rules.mak: support C++ compiling and linking

In reply to Claudio Fontana

support compilation of .cc and .cpp files,
and if C++ is enabled always link with C++ in the non-libtool case.

---
 rules.mak | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
rules.mak +20 -4
index 4499745..d2f1b1f 100644
@@ -8,9 +8,14 @@ MAKEFLAGS += -rR
 %.d:
 %.h:
 %.c:
+%.cc:
+%.cpp:
 %.m:
 %.mak:
 
+# Flags for C++ compilation
+QEMU_CXXFLAGS = -D__STDC_LIMIT_MACROS $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls, $(QEMU_CFLAGS))
+
 # Flags for dependency generation
 QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 
@@ -21,11 +26,21 @@ QEMU_INCLUDES += -I$(<D) -I$(@D)
 	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
 %.o: %.rc
 	$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC    $(TARGET_DIR)$@")
+%.o: %.cc
+	$(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CXXFLAGS) -c -o $@ $<, "  CXX    $(TARGET_DIR)$@")
+%.o: %.cpp
+	$(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CXXFLAGS) -c -o $@ $<, "  CXX    $(TARGET_DIR)$@")
 
 ifeq ($(LIBTOOL),)
-LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
-       $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
-       $(LIBS),"  LINK  $(TARGET_DIR)$@")
+  ifeq ($(CXX),)
+  LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
+         $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
+         $(LIBS),"  LINK  $(TARGET_DIR)$@")
+  else
+  LINK = $(call quiet-command,$(CXX) $(QEMU_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ \
+         $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
+         $(LIBS),"  LINK  $(TARGET_DIR)$@")
+  endif
 else
 LIBTOOL += $(if $(V),,--quiet)
 %.lo: %.c
@@ -70,7 +85,8 @@ quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
 cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
               >/dev/null 2>&1 && echo OK), $2, $3)
 
-VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh %.rc
+VPATH_SUFFIXES = %.c %.h %.S %.cpp %.cc %.m %.mak %.texi %.sh %.rc
+
 set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
 
 # find-in-path
Signature · 1 line
1.8.1
#3 lore raw

RFC 3/4 disas: add libvixl source code for aarch64

In reply to Claudio Fontana

this just adds the libvixl source code verbatim from ARM, including the source code itself (src/), license and readmes. Examples, the scons build system etc, are excluded. Not yet bound to QEMU's build system.

---
 disas/libvixl/LICENCE                        |   30 +
 disas/libvixl/README.md                      |  128 ++
 disas/libvixl/doc/changelog.md               |   12 +
 disas/libvixl/doc/supported-instructions.md  | 1133 ++++++++++++++
 disas/libvixl/src/a64/assembler-a64.cc       | 2172 ++++++++++++++++++++++++++
 disas/libvixl/src/a64/assembler-a64.h        | 1784 +++++++++++++++++++++
 disas/libvixl/src/a64/constants-a64.h        | 1104 +++++++++++++
 disas/libvixl/src/a64/cpu-a64.cc             |  148 ++
 disas/libvixl/src/a64/cpu-a64.h              |   56 +
 disas/libvixl/src/a64/debugger-a64.cc        | 1511 ++++++++++++++++++
 disas/libvixl/src/a64/debugger-a64.h         |  188 +++
 disas/libvixl/src/a64/decoder-a64.cc         |  712 +++++++++
 disas/libvixl/src/a64/decoder-a64.h          |  198 +++
 disas/libvixl/src/a64/disasm-a64.cc          | 1678 ++++++++++++++++++++
 disas/libvixl/src/a64/disasm-a64.h           |  109 ++
 disas/libvixl/src/a64/instructions-a64.cc    |  238 +++
 disas/libvixl/src/a64/instructions-a64.h     |  344 ++++
 disas/libvixl/src/a64/instrument-a64.cc      |  638 ++++++++
 disas/libvixl/src/a64/instrument-a64.h       |  108 ++
 disas/libvixl/src/a64/macro-assembler-a64.cc | 1108 +++++++++++++
 disas/libvixl/src/a64/macro-assembler-a64.h  | 1175 ++++++++++++++
 disas/libvixl/src/a64/simulator-a64.cc       | 2077 ++++++++++++++++++++++++
 disas/libvixl/src/a64/simulator-a64.h        |  576 +++++++
 disas/libvixl/src/globals.h                  |   66 +
 disas/libvixl/src/platform.h                 |   43 +
 disas/libvixl/src/utils.cc                   |  120 ++
 disas/libvixl/src/utils.h                    |  126 ++
 27 files changed, 17582 insertions(+)
 create mode 100644 disas/libvixl/LICENCE
 create mode 100644 disas/libvixl/README.md
 create mode 100644 disas/libvixl/doc/changelog.md
 create mode 100644 disas/libvixl/doc/supported-instructions.md
 create mode 100644 disas/libvixl/src/a64/assembler-a64.cc
 create mode 100644 disas/libvixl/src/a64/assembler-a64.h
 create mode 100644 disas/libvixl/src/a64/constants-a64.h
 create mode 100644 disas/libvixl/src/a64/cpu-a64.cc
 create mode 100644 disas/libvixl/src/a64/cpu-a64.h
 create mode 100644 disas/libvixl/src/a64/debugger-a64.cc
 create mode 100644 disas/libvixl/src/a64/debugger-a64.h
 create mode 100644 disas/libvixl/src/a64/decoder-a64.cc
 create mode 100644 disas/libvixl/src/a64/decoder-a64.h
 create mode 100644 disas/libvixl/src/a64/disasm-a64.cc
 create mode 100644 disas/libvixl/src/a64/disasm-a64.h
 create mode 100644 disas/libvixl/src/a64/instructions-a64.cc
 create mode 100644 disas/libvixl/src/a64/instructions-a64.h
 create mode 100644 disas/libvixl/src/a64/instrument-a64.cc
 create mode 100644 disas/libvixl/src/a64/instrument-a64.h
 create mode 100644 disas/libvixl/src/a64/macro-assembler-a64.cc
 create mode 100644 disas/libvixl/src/a64/macro-assembler-a64.h
 create mode 100644 disas/libvixl/src/a64/simulator-a64.cc
 create mode 100644 disas/libvixl/src/a64/simulator-a64.h
 create mode 100644 disas/libvixl/src/globals.h
 create mode 100644 disas/libvixl/src/platform.h
 create mode 100644 disas/libvixl/src/utils.cc
 create mode 100644 disas/libvixl/src/utils.h
disas/libvixl/LICENCE new file +30 -0
new file mode 100644
index 0000000..b7e160a
@@ -0,0 +1,30 @@
+LICENCE
+=======
+
+The software in this repository is covered by the following licence.
+
+// Copyright 2013, ARM Limited
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//   * Redistributions of source code must retain the above copyright notice,
+//     this list of conditions and the following disclaimer.
+//   * Redistributions in binary form must reproduce the above copyright notice,
+//     this list of conditions and the following disclaimer in the documentation
+//     and/or other materials provided with the distribution.
+//   * Neither the name of ARM Limited nor the names of its contributors may be
+//     used to endorse or promote products derived from this software without
+//     specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
disas/libvixl/README.md new file +128 -0

128 lines not on this page · raw message

disas/libvixl/doc/changelog.md new file +12 -0
new file mode 100644
index 0000000..8bab932
@@ -0,0 +1,12 @@
+VIXL Change Log
+===============
+
+* 1.1
+    + Improved robustness of instruction decoder and disassembler.
+    + Added support for double-to-float conversions using `fcvt`.
+    + Added support for more fixed-point to floating-point conversions (`ucvtf`
+      and `scvtf`).
+    + Added instruction statistics collection class `instrument-a64.cc`.
+
+* 1.0
+    + Initial release.
disas/libvixl/doc/supported-instructions.md new file +1133 -0

1,133 lines not on this page · raw message

disas/libvixl/src/a64/assembler-a64.cc new file +2172 -0

1,697 lines not on this page · raw message

disas/libvixl/src/a64/assembler-a64.h new file +1784 -0

1,784 lines not on this page · raw message

disas/libvixl/src/a64/constants-a64.h new file +1104 -0

1,104 lines not on this page · raw message

disas/libvixl/src/a64/cpu-a64.cc new file +148 -0

148 lines not on this page · raw message

disas/libvixl/src/a64/cpu-a64.h new file +56 -0

56 lines not on this page · raw message

disas/libvixl/src/a64/debugger-a64.cc new file +1511 -0

1,511 lines not on this page · raw message

disas/libvixl/src/a64/debugger-a64.h new file +188 -0

188 lines not on this page · raw message

disas/libvixl/src/a64/decoder-a64.cc new file +712 -0

712 lines not on this page · raw message

disas/libvixl/src/a64/decoder-a64.h new file +198 -0

198 lines not on this page · raw message

disas/libvixl/src/a64/disasm-a64.cc new file +1678 -0

1,678 lines not on this page · raw message

disas/libvixl/src/a64/disasm-a64.h new file +109 -0

109 lines not on this page · raw message

disas/libvixl/src/a64/instructions-a64.cc new file +238 -0

238 lines not on this page · raw message

disas/libvixl/src/a64/instructions-a64.h new file +344 -0

344 lines not on this page · raw message

disas/libvixl/src/a64/instrument-a64.cc new file +638 -0

638 lines not on this page · raw message

disas/libvixl/src/a64/instrument-a64.h new file +108 -0

108 lines not on this page · raw message

disas/libvixl/src/a64/macro-assembler-a64.cc new file +1108 -0

1,108 lines not on this page · raw message

disas/libvixl/src/a64/macro-assembler-a64.h new file +1175 -0

1,175 lines not on this page · raw message

disas/libvixl/src/a64/simulator-a64.cc new file +2077 -0

2,077 lines not on this page · raw message

disas/libvixl/src/a64/simulator-a64.h new file +576 -0

576 lines not on this page · raw message

disas/libvixl/src/globals.h new file +66 -0

66 lines not on this page · raw message

disas/libvixl/src/platform.h new file +43 -0

43 lines not on this page · raw message

disas/libvixl/src/utils.cc new file +120 -0

120 lines not on this page · raw message

disas/libvixl/src/utils.h new file +126 -0

126 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.8.1

Part of the diff is not shown here. View the raw message.

#8 lore raw

RFC 4/4 disas: implement host disassembly output for aarch64

In reply to Claudio Fontana

use C++ libvixl to implement output, for now only enabled for the host output disasm, since we don't have the aarch64 target yet.

---
 configure                   |  6 +++++
 disas.c                     |  2 ++
 disas/Makefile.objs         |  7 ++++++
 disas/aarch64-cxx.cc        | 53 +++++++++++++++++++++++++++++++++++++++++++++
 disas/aarch64.c             | 45 ++++++++++++++++++++++++++++++++++++++
 disas/libvixl/Makefile.objs |  6 +++++
 include/disas/bfd.h         |  1 +
 7 files changed, 120 insertions(+)
 create mode 100644 disas/aarch64-cxx.cc
 create mode 100644 disas/aarch64.c
 create mode 100644 disas/libvixl/Makefile.objs
configure +6 -0
index 6b73d99..1a2648a 100755
@@ -4443,6 +4443,12 @@ ldflags=""
 
 for i in $ARCH $TARGET_BASE_ARCH ; do
   case "$i" in
+  aarch64)
+    if test "x${cxx}" != "x"; then
+      echo "CONFIG_AARCH64_DIS=y"  >> $config_target_mak
+      echo "CONFIG_AARCH64_DIS=y"  >> config-all-disas.mak
+    fi
+  ;;
   alpha)
     echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
     echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
disas.c +2 -0
index 0203ef2..cc20c4a 100644
@@ -356,6 +356,8 @@ void disas(FILE *out, void *code, unsigned long size)
 #elif defined(_ARCH_PPC)
     s.info.disassembler_options = (char *)"any";
     print_insn = print_insn_ppc;
+#elif defined(__aarch64__)
+    print_insn = print_insn_aarch64;
 #elif defined(__alpha__)
     print_insn = print_insn_alpha;
 #elif defined(__sparc__)
disas/Makefile.objs +7 -0
index 3b1e77a..f468c22 100644
@@ -1,3 +1,10 @@
+ifeq ($(CONFIG_AARCH64_DIS),y)
+libvixldir = $(SRC_PATH)/disas/libvixl/src
+QEMU_CFLAGS += -I$(libvixldir) -Wno-undef
+common-obj-$(CONFIG_AARCH64_DIS) += libvixl/
+common-obj-$(CONFIG_AARCH64_DIS) += aarch64.o aarch64-cxx.o
+endif
+
 common-obj-$(CONFIG_ALPHA_DIS) += alpha.o
 common-obj-$(CONFIG_ARM_DIS) += arm.o
 common-obj-$(CONFIG_CRIS_DIS) += cris.o
disas/aarch64-cxx.cc new file +53 -0

53 lines not on this page · raw message

disas/aarch64.c new file +45 -0

45 lines not on this page · raw message

disas/libvixl/Makefile.objs new file +6 -0
new file mode 100644
index 0000000..43ba29c
@@ -0,0 +1,6 @@
+libvixl_OBJS = src/utils.o \
+               src/a64/instructions-a64.o \
+               src/a64/decoder-a64.o \
+               src/a64/disasm-a64.o
+
+common-obj-$(CONFIG_AARCH64_DIS) += $(libvixl_OBJS)
include/disas/bfd.h +1 -0
index 803b6ef..73017da 100644
@@ -379,6 +379,7 @@ int print_insn_h8300            (bfd_vma, disassemble_info*);
 int print_insn_h8300h           (bfd_vma, disassemble_info*);
 int print_insn_h8300s           (bfd_vma, disassemble_info*);
 int print_insn_h8500            (bfd_vma, disassemble_info*);
+int print_insn_aarch64          (bfd_vma, disassemble_info*);
 int print_insn_alpha            (bfd_vma, disassemble_info*);
 disassembler_ftype arc_get_disassembler (int, int);
 int print_insn_arm              (bfd_vma, disassemble_info*);
Signature · 1 line
1.8.1
#5 lore raw
In reply to Claudio Fontana

Hi Claudio,

Am 11.09.2013 14:54, schrieb Claudio Fontana:

Quoted 7 lines

This is the aarch64 libvixl support patchset in the current state. It provides (limited) support for disassembly output on aarch64. Only host disassembly is enabled, since target for aarch64 is not in yet.

An external objdump solution as exemplified before by R.H. seems preferable to me, even if it means giving up the monitor support.

[snip]

That has been committed August 24th, hasn't it?

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#6 lore raw
Quoted 10 lines · Andreas Färber

Am 11.09.2013 14:54, schrieb Claudio Fontana:

Quoted 6 lines

This is the aarch64 libvixl support patchset in the current state. It provides (limited) support for disassembly output on aarch64. Only host disassembly is enabled, since target for aarch64 is not in yet.

An external objdump solution as exemplified before by R.H. seems preferable to me, even if it means giving up the monitor support.

[snip]

That has been committed August 24th, hasn't it?

Yes, but at the moment it's only for targets without a builtin disassembler. If we're going to have it be the standard setup we use for every target that's one thing. But otherwise I'd rather aarch64 not be a second class citizen in this regard.

-- PMM

#7 lore raw
In reply to Claudio Fontana
Quoted 3 lines · Claudio Fontana

This is the aarch64 libvixl support patchset in the current state. It provides (limited) support for disassembly output on aarch64. Only host disassembly is enabled, since target for aarch64 is not in yet.

Incidentally, people interested in aarch64 might like to know that the first public beta release of the ARMv8-A ARM ARM is now available on infocenter:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0487a/index.html
(needs an account on infocenter, which is a 'just fill in a webform' sort of process).

-- PMM

#4 lore raw

RFC 3/4 disas: add libvixl source code for aarch64

In reply to Claudio Fontana

this just adds the libvixl source code verbatim from ARM, including the source code itself (src/), license and readmes. Examples, the scons build system etc, are excluded. Not yet bound to QEMU's build system.

---
 disas/libvixl/LICENCE                        |   30 +
 disas/libvixl/README.md                      |  128 ++
 disas/libvixl/doc/changelog.md               |   12 +
 disas/libvixl/doc/supported-instructions.md  | 1133 ++++++++++++++
 disas/libvixl/src/a64/assembler-a64.cc       | 2172 ++++++++++++++++++++++++++
 disas/libvixl/src/a64/assembler-a64.h        | 1784 +++++++++++++++++++++
 disas/libvixl/src/a64/constants-a64.h        | 1104 +++++++++++++
 disas/libvixl/src/a64/cpu-a64.cc             |  148 ++
 disas/libvixl/src/a64/cpu-a64.h              |   56 +
 disas/libvixl/src/a64/debugger-a64.cc        | 1511 ++++++++++++++++++
 disas/libvixl/src/a64/debugger-a64.h         |  188 +++
 disas/libvixl/src/a64/decoder-a64.cc         |  712 +++++++++
 disas/libvixl/src/a64/decoder-a64.h          |  198 +++
 disas/libvixl/src/a64/disasm-a64.cc          | 1678 ++++++++++++++++++++
 disas/libvixl/src/a64/disasm-a64.h           |  109 ++
 disas/libvixl/src/a64/instructions-a64.cc    |  238 +++
 disas/libvixl/src/a64/instructions-a64.h     |  344 ++++
 disas/libvixl/src/a64/instrument-a64.cc      |  638 ++++++++
 disas/libvixl/src/a64/instrument-a64.h       |  108 ++
 disas/libvixl/src/a64/macro-assembler-a64.cc | 1108 +++++++++++++
 disas/libvixl/src/a64/macro-assembler-a64.h  | 1175 ++++++++++++++
 disas/libvixl/src/a64/simulator-a64.cc       | 2077 ++++++++++++++++++++++++
 disas/libvixl/src/a64/simulator-a64.h        |  576 +++++++
 disas/libvixl/src/globals.h                  |   66 +
 disas/libvixl/src/platform.h                 |   43 +
 disas/libvixl/src/utils.cc                   |  120 ++
 disas/libvixl/src/utils.h                    |  126 ++
 27 files changed, 17582 insertions(+)
 create mode 100644 disas/libvixl/LICENCE
 create mode 100644 disas/libvixl/README.md
 create mode 100644 disas/libvixl/doc/changelog.md
 create mode 100644 disas/libvixl/doc/supported-instructions.md
 create mode 100644 disas/libvixl/src/a64/assembler-a64.cc
 create mode 100644 disas/libvixl/src/a64/assembler-a64.h
 create mode 100644 disas/libvixl/src/a64/constants-a64.h
 create mode 100644 disas/libvixl/src/a64/cpu-a64.cc
 create mode 100644 disas/libvixl/src/a64/cpu-a64.h
 create mode 100644 disas/libvixl/src/a64/debugger-a64.cc
 create mode 100644 disas/libvixl/src/a64/debugger-a64.h
 create mode 100644 disas/libvixl/src/a64/decoder-a64.cc
 create mode 100644 disas/libvixl/src/a64/decoder-a64.h
 create mode 100644 disas/libvixl/src/a64/disasm-a64.cc
 create mode 100644 disas/libvixl/src/a64/disasm-a64.h
 create mode 100644 disas/libvixl/src/a64/instructions-a64.cc
 create mode 100644 disas/libvixl/src/a64/instructions-a64.h
 create mode 100644 disas/libvixl/src/a64/instrument-a64.cc
 create mode 100644 disas/libvixl/src/a64/instrument-a64.h
 create mode 100644 disas/libvixl/src/a64/macro-assembler-a64.cc
 create mode 100644 disas/libvixl/src/a64/macro-assembler-a64.h
 create mode 100644 disas/libvixl/src/a64/simulator-a64.cc
 create mode 100644 disas/libvixl/src/a64/simulator-a64.h
 create mode 100644 disas/libvixl/src/globals.h
 create mode 100644 disas/libvixl/src/platform.h
 create mode 100644 disas/libvixl/src/utils.cc
 create mode 100644 disas/libvixl/src/utils.h
disas/libvixl/LICENCE new file +30 -0
new file mode 100644
index 0000000..b7e160a
@@ -0,0 +1,30 @@
+LICENCE
+=======
+
+The software in this repository is covered by the following licence.
+
+// Copyright 2013, ARM Limited
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//   * Redistributions of source code must retain the above copyright notice,
+//     this list of conditions and the following disclaimer.
+//   * Redistributions in binary form must reproduce the above copyright notice,
+//     this list of conditions and the following disclaimer in the documentation
+//     and/or other materials provided with the distribution.
+//   * Neither the name of ARM Limited nor the names of its contributors may be
+//     used to endorse or promote products derived from this software without
+//     specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
disas/libvixl/README.md new file +128 -0

128 lines not on this page · raw message

disas/libvixl/doc/changelog.md new file +12 -0
new file mode 100644
index 0000000..8bab932
@@ -0,0 +1,12 @@
+VIXL Change Log
+===============
+
+* 1.1
+    + Improved robustness of instruction decoder and disassembler.
+    + Added support for double-to-float conversions using `fcvt`.
+    + Added support for more fixed-point to floating-point conversions (`ucvtf`
+      and `scvtf`).
+    + Added instruction statistics collection class `instrument-a64.cc`.
+
+* 1.0
+    + Initial release.
disas/libvixl/doc/supported-instructions.md new file +1133 -0

1,133 lines not on this page · raw message

disas/libvixl/src/a64/assembler-a64.cc new file +2172 -0

1,697 lines not on this page · raw message

disas/libvixl/src/a64/assembler-a64.h new file +1784 -0

1,784 lines not on this page · raw message

disas/libvixl/src/a64/constants-a64.h new file +1104 -0

1,104 lines not on this page · raw message

disas/libvixl/src/a64/cpu-a64.cc new file +148 -0

148 lines not on this page · raw message

disas/libvixl/src/a64/cpu-a64.h new file +56 -0

56 lines not on this page · raw message

disas/libvixl/src/a64/debugger-a64.cc new file +1511 -0

1,511 lines not on this page · raw message

disas/libvixl/src/a64/debugger-a64.h new file +188 -0

188 lines not on this page · raw message

disas/libvixl/src/a64/decoder-a64.cc new file +712 -0

712 lines not on this page · raw message

disas/libvixl/src/a64/decoder-a64.h new file +198 -0

198 lines not on this page · raw message

disas/libvixl/src/a64/disasm-a64.cc new file +1678 -0

1,678 lines not on this page · raw message

disas/libvixl/src/a64/disasm-a64.h new file +109 -0

109 lines not on this page · raw message

disas/libvixl/src/a64/instructions-a64.cc new file +238 -0

238 lines not on this page · raw message

disas/libvixl/src/a64/instructions-a64.h new file +344 -0

344 lines not on this page · raw message

disas/libvixl/src/a64/instrument-a64.cc new file +638 -0

638 lines not on this page · raw message

disas/libvixl/src/a64/instrument-a64.h new file +108 -0

108 lines not on this page · raw message

disas/libvixl/src/a64/macro-assembler-a64.cc new file +1108 -0

1,108 lines not on this page · raw message

disas/libvixl/src/a64/macro-assembler-a64.h new file +1175 -0

1,175 lines not on this page · raw message

disas/libvixl/src/a64/simulator-a64.cc new file +2077 -0

2,077 lines not on this page · raw message

disas/libvixl/src/a64/simulator-a64.h new file +576 -0

576 lines not on this page · raw message

disas/libvixl/src/globals.h new file +66 -0

66 lines not on this page · raw message

disas/libvixl/src/platform.h new file +43 -0

43 lines not on this page · raw message

disas/libvixl/src/utils.cc new file +120 -0

120 lines not on this page · raw message

disas/libvixl/src/utils.h new file +126 -0

126 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.8.1

Part of the diff is not shown here. View the raw message.

#11 lore raw
In reply to Claudio Fontana
Quoted 5 lines · Claudio Fontana

This is the aarch64 libvixl support patchset in the current state. It provides (limited) support for disassembly output on aarch64. Only host disassembly is enabled, since target for aarch64 is not in yet.

Quoted 8 lines

An external objdump solution as exemplified before by R.H. seems preferable to me, even if it means giving up the monitor support.
I'd rather have correct output from -d.
The run time need for debugging assembly is already fulfilled by gdb better than the monitor.

libvixl does not support many opcodes right now, is C++, and it is documented as working only for a 64bit host with a LP64 memory model.

Wait, incorporating C++ code into qemu was considered the _good_ solution?

What was the bad solution?

Rob

#12 lore raw
Quoted 3 lines · Rob Landley

Wait, incorporating C++ code into qemu was considered the _good_ solution?

What was the bad solution?

Not supporting disassembly at all, and/or having a runtime dependency on finding an objdump that works for the target.

-- PMM

#13 lore raw
Quoted 7 lines · Peter Maydell
Quoted 3 lines · Rob Landley

Wait, incorporating C++ code into qemu was considered the _good_ solution?

What was the bad solution?

Not supporting disassembly at all, and/or having a runtime dependency on finding an objdump that works for the target.

Now that documentation is out, perhaps someone will write a disassembler in C with an acceptable license? I would happily review it.

Laurent

#9 lore raw

Re: [Qemu-devel] [RFC 4/4] disas: implement host disassembly output for aarch64

In reply to Claudio Fontana

Am 11.09.2013 15:08, schrieb Claudio Fontana:

Quoted 162 lines

use C++ libvixl to implement output, for now only enabled for the host output disasm, since we don't have the aarch64 target yet.

---
 configure                   |  6 +++++
 disas.c                     |  2 ++
 disas/Makefile.objs         |  7 ++++++
 disas/aarch64-cxx.cc        | 53 +++++++++++++++++++++++++++++++++++++++++++++
 disas/aarch64.c             | 45 ++++++++++++++++++++++++++++++++++++++
 disas/libvixl/Makefile.objs |  6 +++++
 include/disas/bfd.h         |  1 +
 7 files changed, 120 insertions(+)
 create mode 100644 disas/aarch64-cxx.cc
 create mode 100644 disas/aarch64.c
 create mode 100644 disas/libvixl/Makefile.objs
configure +6 -0
index 6b73d99..1a2648a 100755
@@ -4443,6 +4443,12 @@ ldflags=""
 
 for i in $ARCH $TARGET_BASE_ARCH ; do
   case "$i" in
+  aarch64)
+    if test "x${cxx}" != "x"; then
+      echo "CONFIG_AARCH64_DIS=y"  >> $config_target_mak
+      echo "CONFIG_AARCH64_DIS=y"  >> config-all-disas.mak
+    fi
+  ;;
   alpha)
     echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
     echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
disas.c +2 -0
index 0203ef2..cc20c4a 100644
@@ -356,6 +356,8 @@ void disas(FILE *out, void *code, unsigned long size)
 #elif defined(_ARCH_PPC)
     s.info.disassembler_options = (char *)"any";
     print_insn = print_insn_ppc;
+#elif defined(__aarch64__)
+    print_insn = print_insn_aarch64;
 #elif defined(__alpha__)
     print_insn = print_insn_alpha;
 #elif defined(__sparc__)
disas/Makefile.objs +7 -0
index 3b1e77a..f468c22 100644
@@ -1,3 +1,10 @@
+ifeq ($(CONFIG_AARCH64_DIS),y)
+libvixldir = $(SRC_PATH)/disas/libvixl/src
+QEMU_CFLAGS += -I$(libvixldir) -Wno-undef
+common-obj-$(CONFIG_AARCH64_DIS) += libvixl/
+common-obj-$(CONFIG_AARCH64_DIS) += aarch64.o aarch64-cxx.o
+endif
+
 common-obj-$(CONFIG_ALPHA_DIS) += alpha.o
 common-obj-$(CONFIG_ARM_DIS) += arm.o
 common-obj-$(CONFIG_CRIS_DIS) += cris.o
disas/aarch64-cxx.cc new file +53 -0
new file mode 100644
index 0000000..524f5ae
@@ -0,0 +1,53 @@
+/*
+ * Aarch64 disassembly output wrapper to libvixl - C++ part
+ * Copyright (c) 2013 Linaro Limited
+ * Written by Claudio Fontana
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "a64/simulator-a64.h"
+#include "a64/macro-assembler-a64.h"
+
+extern "C" {
+    int vixl_is_initialized(int);
+    int vixl_init(FILE *f);
+    int vixl_decode_insn(uint8_t *bytes);
+}
+
+using namespace vixl;
+
+static Decoder *vixl_decoder = NULL;
+static Disassembler *vixl_disasm = NULL;
+
+int vixl_is_initialized(int unused)
+{
+    return vixl_decoder != NULL;
+}
+
+/* Disassemble Aarch64 bytecode - wrappers */
+int vixl_init(FILE *f) {
+    vixl_decoder = new Decoder();
+    vixl_disasm = new PrintDisassembler(f);
+    vixl_decoder->AppendVisitor(vixl_disasm);
+    return 1;
+}
+
+int vixl_decode_insn(uint8_t *bytes)
+{
+    Instr instr;
+    instr = bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24;
+    vixl_decoder->Decode(reinterpret_cast<Instruction*>(&instr));
+    return 1;
+}
disas/aarch64.c new file +35 -0
new file mode 100644
index 0000000..7e44837
@@ -0,0 +1,45 @@
+/*
+ * Aarch64 disassembly output wrapper to libvixl - C part
+ * Copyright (c) 2013 Linaro Limited
+ * Written by Claudio Fontana
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "disas/bfd.h"
+#define INSN_SIZE 4
+
+extern int vixl_is_initialized(int);
+extern int vixl_init(FILE *);
+extern int vixl_decode_insn(uint8_t *);
+
+/* Disassemble Aarch64 bytecode. */
+int print_insn_aarch64(uint64_t addr, disassemble_info *info)
+{
+    uint8_t bytes[INSN_SIZE];
+    int status;
+
+    if (!vixl_is_initialized(0)) {
+        vixl_init(info->stream);
+    }

disas/aarch64.c line 45

Quoted 10 lines
disas/aarch64.c new file +10 -0
+
+    status = info->read_memory_func(addr, bytes, INSN_SIZE, info);
+    if (status != 0) {
+        info->memory_error_func(status, addr, info);
+        return -1;
+    }
+
+    vixl_decode_insn(bytes);
+    return INSN_SIZE;
+}

Why split this into two mini files? You're already using extern "C" { ... } in the C++ file for the prototypes anyway.

Apart from that the library integration looks surprisingly clean. :)

Cheers,
Andreas

Quoted 25 lines
disas/libvixl/Makefile.objs new file +6 -0
new file mode 100644
index 0000000..43ba29c
@@ -0,0 +1,6 @@
+libvixl_OBJS = src/utils.o \
+               src/a64/instructions-a64.o \
+               src/a64/decoder-a64.o \
+               src/a64/disasm-a64.o
+
+common-obj-$(CONFIG_AARCH64_DIS) += $(libvixl_OBJS)
include/disas/bfd.h +1 -0
index 803b6ef..73017da 100644
@@ -379,6 +379,7 @@ int print_insn_h8300            (bfd_vma, disassemble_info*);
 int print_insn_h8300h           (bfd_vma, disassemble_info*);
 int print_insn_h8300s           (bfd_vma, disassemble_info*);
 int print_insn_h8500            (bfd_vma, disassemble_info*);
+int print_insn_aarch64          (bfd_vma, disassemble_info*);
 int print_insn_alpha            (bfd_vma, disassemble_info*);
 disassembler_ftype arc_get_disassembler (int, int);
 int print_insn_arm              (bfd_vma, disassemble_info*);
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#10 lore raw

Re: [Qemu-devel] [RFC 4/4] disas: implement host disassembly output for aarch64

Hallo Andreas,

Quoted 177 lines · Andreas Färber

Am 11.09.2013 15:08, schrieb Claudio Fontana:

Quoted 162 lines

use C++ libvixl to implement output, for now only enabled for the host output disasm, since we don't have the aarch64 target yet.

---
 configure                   |  6 +++++
 disas.c                     |  2 ++
 disas/Makefile.objs         |  7 ++++++
 disas/aarch64-cxx.cc        | 53 +++++++++++++++++++++++++++++++++++++++++++++
 disas/aarch64.c             | 45 ++++++++++++++++++++++++++++++++++++++
 disas/libvixl/Makefile.objs |  6 +++++
 include/disas/bfd.h         |  1 +
 7 files changed, 120 insertions(+)
 create mode 100644 disas/aarch64-cxx.cc
 create mode 100644 disas/aarch64.c
 create mode 100644 disas/libvixl/Makefile.objs
configure +6 -0
index 6b73d99..1a2648a 100755
@@ -4443,6 +4443,12 @@ ldflags=""
 
 for i in $ARCH $TARGET_BASE_ARCH ; do
   case "$i" in
+  aarch64)
+    if test "x${cxx}" != "x"; then
+      echo "CONFIG_AARCH64_DIS=y"  >> $config_target_mak
+      echo "CONFIG_AARCH64_DIS=y"  >> config-all-disas.mak
+    fi
+  ;;
   alpha)
     echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
     echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
disas.c +2 -0
index 0203ef2..cc20c4a 100644
@@ -356,6 +356,8 @@ void disas(FILE *out, void *code, unsigned long size)
 #elif defined(_ARCH_PPC)
     s.info.disassembler_options = (char *)"any";
     print_insn = print_insn_ppc;
+#elif defined(__aarch64__)
+    print_insn = print_insn_aarch64;
 #elif defined(__alpha__)
     print_insn = print_insn_alpha;
 #elif defined(__sparc__)
disas/Makefile.objs +7 -0
index 3b1e77a..f468c22 100644
@@ -1,3 +1,10 @@
+ifeq ($(CONFIG_AARCH64_DIS),y)
+libvixldir = $(SRC_PATH)/disas/libvixl/src
+QEMU_CFLAGS += -I$(libvixldir) -Wno-undef
+common-obj-$(CONFIG_AARCH64_DIS) += libvixl/
+common-obj-$(CONFIG_AARCH64_DIS) += aarch64.o aarch64-cxx.o
+endif
+
 common-obj-$(CONFIG_ALPHA_DIS) += alpha.o
 common-obj-$(CONFIG_ARM_DIS) += arm.o
 common-obj-$(CONFIG_CRIS_DIS) += cris.o
disas/aarch64-cxx.cc new file +53 -0
new file mode 100644
index 0000000..524f5ae
@@ -0,0 +1,53 @@
+/*
+ * Aarch64 disassembly output wrapper to libvixl - C++ part
+ * Copyright (c) 2013 Linaro Limited
+ * Written by Claudio Fontana
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "a64/simulator-a64.h"
+#include "a64/macro-assembler-a64.h"
+
+extern "C" {
+    int vixl_is_initialized(int);
+    int vixl_init(FILE *f);
+    int vixl_decode_insn(uint8_t *bytes);
+}
+
+using namespace vixl;
+
+static Decoder *vixl_decoder = NULL;
+static Disassembler *vixl_disasm = NULL;
+
+int vixl_is_initialized(int unused)
+{
+    return vixl_decoder != NULL;
+}
+
+/* Disassemble Aarch64 bytecode - wrappers */
+int vixl_init(FILE *f) {
+    vixl_decoder = new Decoder();
+    vixl_disasm = new PrintDisassembler(f);
+    vixl_decoder->AppendVisitor(vixl_disasm);
+    return 1;
+}
+
+int vixl_decode_insn(uint8_t *bytes)
+{
+    Instr instr;
+    instr = bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24;
+    vixl_decoder->Decode(reinterpret_cast<Instruction*>(&instr));
+    return 1;
+}
disas/aarch64.c new file +35 -0
new file mode 100644
index 0000000..7e44837
@@ -0,0 +1,45 @@
+/*
+ * Aarch64 disassembly output wrapper to libvixl - C part
+ * Copyright (c) 2013 Linaro Limited
+ * Written by Claudio Fontana
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "disas/bfd.h"
+#define INSN_SIZE 4
+
+extern int vixl_is_initialized(int);
+extern int vixl_init(FILE *);
+extern int vixl_decode_insn(uint8_t *);
+
+/* Disassemble Aarch64 bytecode. */
+int print_insn_aarch64(uint64_t addr, disassemble_info *info)
+{
+    uint8_t bytes[INSN_SIZE];
+    int status;
+
+    if (!vixl_is_initialized(0)) {
+        vixl_init(info->stream);
+    }

disas/aarch64.c line 45

Quoted 10 lines
disas/aarch64.c new file +10 -0
+
+    status = info->read_memory_func(addr, bytes, INSN_SIZE, info);
+    if (status != 0) {
+        info->memory_error_func(status, addr, info);
+        return -1;
+    }
+
+    vixl_decode_insn(bytes);
+    return INSN_SIZE;
+}

Why split this into two mini files? You're already using extern "C" { ... } in the C++ file for the prototypes anyway.

Quoted 4 lines

Apart from that the library integration looks surprisingly clean. :)

Cheers,
Andreas

The reason I split this into two files is that the c++ compiler did not digest the bfd.h include.

So I thought to have a .cc file which does not actually need anything from QEMU at all, and a .c file which deals with the QEMU dependencies and provides the final symbol.

Ciao,

Claudio

Quoted 25 lines
Quoted 25 lines
disas/libvixl/Makefile.objs new file +6 -0
new file mode 100644
index 0000000..43ba29c
@@ -0,0 +1,6 @@
+libvixl_OBJS = src/utils.o \
+               src/a64/instructions-a64.o \
+               src/a64/decoder-a64.o \
+               src/a64/disasm-a64.o
+
+common-obj-$(CONFIG_AARCH64_DIS) += $(libvixl_OBJS)
include/disas/bfd.h +1 -0
index 803b6ef..73017da 100644
@@ -379,6 +379,7 @@ int print_insn_h8300            (bfd_vma, disassemble_info*);
 int print_insn_h8300h           (bfd_vma, disassemble_info*);
 int print_insn_h8300s           (bfd_vma, disassemble_info*);
 int print_insn_h8500            (bfd_vma, disassemble_info*);
+int print_insn_aarch64          (bfd_vma, disassemble_info*);
 int print_insn_alpha            (bfd_vma, disassemble_info*);
 disassembler_ftype arc_get_disassembler (int, int);
 int print_insn_arm              (bfd_vma, disassemble_info*);