qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 52/66] Hexagon build infrastructure


From: Philippe Mathieu-Daudé
Subject: Re: [RFC PATCH 52/66] Hexagon build infrastructure
Date: Tue, 11 Feb 2020 08:15:26 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 2/11/20 1:40 AM, Taylor Simpson wrote:
Add file to default-configs
Change configure
Add target/hexagon/Makefile.objs
Change scripts/qemu-binfmt-conf.sh
Modify tests/tcg/configure.sh
Add reference files to tests/tcg/hexagon

At this point in the patch series, you can build a hexagon-linux-user target
and run programs on the Hexagon scalar core.  With hexagon-linux-clang
installed, "make check-tcg TIMEOUT=60" will pass.

Signed-off-by: Taylor Simpson <address@hidden>
---
  configure                              |   9 +
  default-configs/hexagon-linux-user.mak |   1 +
  scripts/qemu-binfmt-conf.sh            |   6 +-
  target/hexagon/Makefile.objs           | 103 +++++
  tests/tcg/configure.sh                 |   4 +-
  tests/tcg/hexagon/float_convs.ref      | 748 ++++++++++++++++++++++++++++++++
  tests/tcg/hexagon/float_madds.ref      | 768 +++++++++++++++++++++++++++++++++
  7 files changed, 1637 insertions(+), 2 deletions(-)
  create mode 100644 default-configs/hexagon-linux-user.mak
  create mode 100644 target/hexagon/Makefile.objs
  create mode 100644 tests/tcg/hexagon/float_convs.ref
  create mode 100644 tests/tcg/hexagon/float_madds.ref

diff --git a/configure b/configure
index 115dc38..84841be 100755
--- a/configure
+++ b/configure
@@ -7774,6 +7774,12 @@ case "$target_name" in
      bflt="yes"
      mttcg="yes"
    ;;
+  hexagon)
+    TARGET_BASE_ARCH=hexagon
+    TARGET_ABI_DIR=hexagon
+    mttcg=yes
+    target_compiler=$cross_cc_hexagon
+  ;;
    *)
      error_exit "Unsupported target CPU"
    ;;
@@ -7937,6 +7943,9 @@ for i in $ARCH $TARGET_BASE_ARCH ; do
    xtensa*)
      disas_config "XTENSA"
    ;;
+  hexagon)
+    disas_config "HEXAGON"
+  ;;
    esac
  done
  if test "$tcg_interpreter" = "yes" ; then
diff --git a/default-configs/hexagon-linux-user.mak 
b/default-configs/hexagon-linux-user.mak
new file mode 100644
index 0000000..ad55af0
--- /dev/null
+++ b/default-configs/hexagon-linux-user.mak
@@ -0,0 +1 @@
+# Default configuration for hexagon-linux-user
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index 9f1580a..7b5d54b 100755
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -4,7 +4,7 @@
  qemu_target_list="i386 i486 alpha arm armeb sparc sparc32plus sparc64 \
  ppc ppc64 ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \
  sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \
-microblaze microblazeel or1k x86_64"
+microblaze microblazeel or1k x86_64 hexagon"
i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
  
i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
@@ -136,6 +136,10 @@ 
or1k_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\
  
or1k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  or1k_family=or1k
+hexagon_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xa4\x00'
+hexagon_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+hexagon_family=hexagon
+
  qemu_get_family() {
      cpu=${HOST_ARCH:-$(uname -m)}
      case "$cpu" in
diff --git a/target/hexagon/Makefile.objs b/target/hexagon/Makefile.objs
new file mode 100644
index 0000000..efcf510
--- /dev/null
+++ b/target/hexagon/Makefile.objs
@@ -0,0 +1,103 @@
+obj-y += \
+    cpu.o \
+    translate.o \
+    op_helper.o \
+    gdbstub.o \
+    genptr.o \
+    reg_fields.o \
+    decode.o \
+    iclass.o \
+    opcodes.o \
+    printinsn.o \
+    arch.o \
+    fma_emu.o \
+    conv_emu.o
+
+#
+#  Step 1
+#  We use a C program to create semantics_generated.pyinc
+#
+GEN_SEMANTICS = gen_semantics
+GEN_SEMANTICS_SRC = $(SRC_PATH)/target/hexagon/gen_semantics.c
+
+IDEF_FILES = \
+    $(SRC_PATH)/target/hexagon/imported/alu.idef \
+    $(SRC_PATH)/target/hexagon/imported/branch.idef \
+    $(SRC_PATH)/target/hexagon/imported/compare.idef \
+    $(SRC_PATH)/target/hexagon/imported/float.idef \
+    $(SRC_PATH)/target/hexagon/imported/ldst.idef \
+    $(SRC_PATH)/target/hexagon/imported/mpy.idef \
+    $(SRC_PATH)/target/hexagon/imported/shift.idef \
+    $(SRC_PATH)/target/hexagon/imported/subinsns.idef \
+    $(SRC_PATH)/target/hexagon/imported/system.idef
+DEF_FILES = \
+    $(SRC_PATH)/target/hexagon/imported/allidefs.def \
+    $(SRC_PATH)/target/hexagon/imported/macros.def
+
+$(GEN_SEMANTICS): $(GEN_SEMANTICS_SRC) $(IDEF_FILES) $(DEF_FILES)
+       $(CC) $(CFLAGS) $(GEN_SEMANTICS_SRC) -o $(GEN_SEMANTICS)
+
+SEMANTICS=semantics_generated.pyinc
+$(SEMANTICS): $(GEN_SEMANTICS)
+       $(call quiet-command, \
+           $(GEN_SEMANTICS) $(SEMANTICS), \
+           "GEN", $(SEMANTICS))
+
+#
+# Step 2
+# We use the do_qemu.py script to generate the following files
+#
+QEMU_DEF_H = $(BUILD_DIR)/hexagon-linux-user/qemu_def_generated.h
+QEMU_WRAP_H = $(BUILD_DIR)/hexagon-linux-user/qemu_wrap_generated.h
+OPCODES_DEF_H = $(BUILD_DIR)/hexagon-linux-user/opcodes_def_generated.h
+OP_ATTRIBS_H = $(BUILD_DIR)/hexagon-linux-user/op_attribs_generated.h
+OP_REGS_H = $(BUILD_DIR)/hexagon-linux-user/op_regs_generated.h
+PRINTINSN_H = $(BUILD_DIR)/hexagon-linux-user/printinsn_generated.h
+
+GENERATED_HEXAGON_FILES = \
+    $(QEMU_DEF_H) \
+    $(QEMU_WRAP_H) \
+    $(OPCODES_DEF_H) \
+    $(OP_ATTRIBS_H) \
+    $(OP_REGS_H) \
+    $(PRINTINSN_H)
+
+$(GENERATED_HEXAGON_FILES): \
+    $(SRC_PATH)/target/hexagon/do_qemu.py \
+    $(SEMANTICS) \
+    $(SRC_PATH)/target/hexagon/attribs_def.h
+       $(call quiet-command, \
+           $(SRC_PATH)/target/hexagon/do_qemu.py \
+                $(SEMANTICS) \
+                $(SRC_PATH)/target/hexagon/attribs_def.h, \
+           "GEN", "Hexagon generated files")
+
+#
+# Step 3
+# We use a C program to create iset.py which is imported into dectree.py
+# to create the decode tree
+#
+GEN_DECTREE_IMPORT=gen_dectree_import
+GEN_DECTREE_IMPORT_SRC = $(SRC_PATH)/target/hexagon/gen_dectree_import.c
+
+$(GEN_DECTREE_IMPORT): $(GEN_DECTREE_IMPORT_SRC) $(GENERATED_HEXAGON_FILES)
+       $(CC) $(CFLAGS) -I$(BUILD_DIR)/hexagon-linux-user 
$(GEN_DECTREE_IMPORT_SRC) -o $(GEN_DECTREE_IMPORT)
+
+DECTREE_IMPORT=iset.py
+$(DECTREE_IMPORT): $(GEN_DECTREE_IMPORT)
+       $(call quiet-command, \
+           $(GEN_DECTREE_IMPORT) $(DECTREE_IMPORT), \
+           "GEN", $(DECTREE_IMPORT))
+
+#
+# Step 4
+# We use the dectree.py script to generate the decode tree header file
+#
+DECTREE_HEADER=dectree_generated.h
+$(DECTREE_HEADER): $(SRC_PATH)/target/hexagon/dectree.py $(DECTREE_IMPORT)
+       $(call quiet-command, \
+           $(SRC_PATH)/target/hexagon/dectree.py \
+                $(BUILD_DIR)/hexagon-linux-user, \
+           "GEN", "Hexagon decode tree")
+
+generated-files-y += $(GENERATED_HEXAGON_FILES) $(DECTREE_HEADER)

I had to make this change to get it work (I only build out-of-tree):

-- >8 --
--- a/target/hexagon/Makefile.objs
+++ b/target/hexagon/Makefile.objs
@@ -46,7 +46,7 @@ $(GEN_SEMANTICS): $(GEN_SEMANTICS_SRC) $(IDEF_FILES) $(DEF_FILES)
 SEMANTICS=semantics_generated.pyinc
 $(SEMANTICS): $(GEN_SEMANTICS)
        $(call quiet-command, \
-           $(GEN_SEMANTICS) $(SEMANTICS), \
+           $(BUILD_DIR)/hexagon-linux-user/$(GEN_SEMANTICS) $(SEMANTICS), \
            "GEN", $(SEMANTICS))

 #
@@ -92,7 +92,7 @@ $(GEN_DECTREE_IMPORT): $(GEN_DECTREE_IMPORT_SRC) $(GENERATED_HEXAGON_FILES)
 DECTREE_IMPORT=iset.py
 $(DECTREE_IMPORT): $(GEN_DECTREE_IMPORT)
        $(call quiet-command, \
-           $(GEN_DECTREE_IMPORT) $(DECTREE_IMPORT), \
+ $(BUILD_DIR)/hexagon-linux-user/$(GEN_DECTREE_IMPORT) $(DECTREE_IMPORT), \
            "GEN", $(DECTREE_IMPORT))

---

(You might declare BUILD_USER_DIR=$(BUILD_DIR)/hexagon-linux-user to make it shorter).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]