hexagon queue
The following changes since commit e8d693e12af9cbb89d724baadfcc08559669e279:
tests/qtest: Do not use versioned pc-q35-5.2 machine anymore (2026-08-11 16:12:34 -0400)
are available in the Git repository at:
https://github.com/qualcomm/qemu tags/pull-hex-20260811
for you to fetch changes up to 87a03d3fb03d4450fdb7b4ef26e6185496555d1c:
tests/hexagon: add tests for HVX bfloat (2026-08-11 23:20:45 -0700)
----------------------------------------------------------------
Hexagon queue
Fixes:
* ssub32_saturate, ssub64_saturate fixes
Features:
* l2vic device
* qtimer device
* HVX-IEEE instructions (v68+)
* HVX GVec overrides for v{avg*,absdiff,sadd,*}
----------------------------------------------------------------
Brian Cain (24):
hw/hexagon: add hex-subsys
hw/hexagon: move VTCM to the common machine state hw/hexagon: move global registers to hex-subsys
hw/hexagon: move the TLB to hex-subsys
hw/hexagon: group the CPUs in a cluster
bitops.h: Add find_first_bit32()
hw/hexagon: extract get_reg_value/set_reg_value stubs in globalreg hw/hexagon: connect l2vic device
hw/hexagon/virt: instantiate virtio-mmio transports hw/hexagon/virt: add l2vic interrupt-controller and virtio-mmio FDT nodes hw/hexagon/virt: connect pl011 UART interrupt
tests/qtest: add L2VIC qtest
tests/functional/hexagon: add arch_tests functional test hw/timer: Add QCT QTimer device model
hw/hexagon: connect qtimer device
tests/qtest: add qct-qtimer qtest
tests/functional/hexagon: enable more arch_tests cases
host-utils: fix ssub32/64_saturate return type and clamp direction target/hexagon: add GVec overrides for HVX saturating add/sub target/hexagon: add GVec override for HVX vmpyih multiply target/hexagon: add GVec overrides for HVX absolute difference target/hexagon: add GVec overrides for HVX vector average tests/tcg/hexagon: add HVX test for V6_vsubwsat saturation tests/tcg/hexagon: add HVX tests for vabsdiff
Matheus Tavares Bernardino (15):
target/hexagon: fix incorrect/too-permissive HVX encodings target/hexagon/cpu: add HVX IEEE FP extension
hexagon: group cpu configurations in their own struct
hexagon: print info on "-d in_asm" for disabled IEEE FP instructions target/hexagon: add v68 HVX IEEE float arithmetic insns target/hexagon: add v68 HVX IEEE float min/max insns target/hexagon: add v68 HVX IEEE float misc insns target/hexagon: add v68 HVX IEEE float conversion insns target/hexagon: add v68 HVX IEEE float compare insns target/hexagon: add v73 HVX IEEE bfloat16 insns tests/hexagon: add tests for v68 HVX IEEE float arithmetics tests/hexagon: add tests for v68 HVX IEEE float min/max tests/hexagon: add tests for v68 HVX IEEE float conversions tests/hexagon: add tests for v68 HVX IEEE float comparisons tests/hexagon: add tests for HVX bfloat
Sid Manning (1):
hw/intc: Add l2vic interrupt controller
Taylor Simpson (1):
Hexagon (target/hexagon) Clean up disassembly of control and system regs
MAINTAINERS | 7 + docs/devel/hexagon-l2vic.rst | 55 +++ docs/devel/index-internals.rst | 1 + include/hw/hexagon/hex-subsys.h | 32 ++ include/hw/hexagon/hexagon.h | 6 + include/hw/hexagon/hexagon_globalreg.h | 8 + include/hw/hexagon/virt.h | 4 +- include/hw/intc/hex-l2vic.h | 61 +++ include/hw/timer/qct-qtimer.h | 43 ++ include/qemu/bitops.h | 30 +- include/qemu/host-utils.h | 24 +- target/hexagon/cpu.h | 12 +- target/hexagon/cpu_bits.h | 12 +- target/hexagon/gen_tcg_hvx.h | 170 +++++++ target/hexagon/genptr.h | 4 + target/hexagon/helper.h | 5 + target/hexagon/mmvec/hvx_ieee_fp.h | 69 +++ target/hexagon/mmvec/macros.h | 10 +- target/hexagon/mmvec/mmvec.h | 3 + target/hexagon/printinsn.h | 2 +- target/hexagon/translate.h | 1 + tests/tcg/hexagon/hex_test.h | 32 ++ tests/tcg/hexagon/hvx_misc.h | 73 +++ target/hexagon/attribs_def.h.inc | 9 + disas/hexagon.c | 4 +- hw/hexagon/hex-subsys.c | 175 +++++++ hw/hexagon/hexagon_dsp.c | 45 +- hw/hexagon/hexagon_globalreg.c | 65 ++- hw/hexagon/virt.c | 130 ++++-- hw/intc/hex-l2vic.c | 556 ++++++++++++++++++++++ hw/timer/qct-qtimer.c | 667 +++++++++++++++++++++++++++ target/hexagon/arch.c | 8 + target/hexagon/cpu.c | 23 +- target/hexagon/decode.c | 4 +- target/hexagon/genptr.c | 70 +++ target/hexagon/mmvec/hvx_ieee_fp.c | 137 ++++++ target/hexagon/op_helper.c | 37 +- target/hexagon/printinsn.c | 108 ++++- target/hexagon/translate.c | 5 +- tests/qtest/l2vic-test.c | 249 ++++++++++ tests/qtest/qct-qtimer-test.c | 385 ++++++++++++++++ tests/tcg/hexagon/fp_hvx.c | 226 +++++++++ tests/tcg/hexagon/fp_hvx_cmp.c | 275 +++++++++++ tests/tcg/hexagon/fp_hvx_cvt.c | 219 +++++++++ tests/tcg/hexagon/fp_hvx_disabled.c | 57 +++ tests/tcg/hexagon/hvx_misc.c | 77 ++++ hw/hexagon/Kconfig | 3 + hw/hexagon/meson.build | 1 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + hw/timer/Kconfig | 3 + hw/timer/meson.build | 2 + hw/timer/trace-events | 5 + target/hexagon/gen_printinsn.py | 14 +- target/hexagon/gen_tcg_funcs.py | 12 + target/hexagon/hex_common.py | 27 ++ target/hexagon/imported/mmvec/encode_ext.def | 126 ++++- target/hexagon/imported/mmvec/ext.idef | 369 ++++++++++++++- target/hexagon/meson.build | 1 + tests/functional/hexagon/test_arch_tests.py | 38 ++ tests/qtest/meson.build | 2 +- tests/tcg/hexagon/Makefile.target | 14 + 63 files changed, 4657 insertions(+), 164 deletions(-) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 include/hw/hexagon/hex-subsys.h create mode 100644 include/hw/intc/hex-l2vic.h create mode 100644 include/hw/timer/qct-qtimer.h create mode 100644 target/hexagon/mmvec/hvx_ieee_fp.h create mode 100644 hw/hexagon/hex-subsys.c create mode 100644 hw/intc/hex-l2vic.c create mode 100644 hw/timer/qct-qtimer.c create mode 100644 target/hexagon/mmvec/hvx_ieee_fp.c create mode 100644 tests/qtest/l2vic-test.c create mode 100644 tests/qtest/qct-qtimer-test.c create mode 100644 tests/tcg/hexagon/fp_hvx.c create mode 100644 tests/tcg/hexagon/fp_hvx_cmp.c create mode 100644 tests/tcg/hexagon/fp_hvx_cvt.c create mode 100644 tests/tcg/hexagon/fp_hvx_disabled.c
[PULL 01/41] hw/hexagon: add hex-subsys
The virt and DSP machine models build the same core subsystem, let's abstract out that part. Start with the DDR and config table ROM setup.
--- include/hw/hexagon/hex-subsys.h | 17 +++++++++++++++++ hw/hexagon/hex-subsys.c | 32 ++++++++++++++++++++++++++++++++ hw/hexagon/hexagon_dsp.c | 17 ++--------------- hw/hexagon/virt.c | 14 ++------------ hw/hexagon/meson.build | 1 + 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 include/hw/hexagon/hex-subsys.h create mode 100644 hw/hexagon/hex-subsys.c
include/hw/hexagon/hex-subsys.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Hexagon subsystem helpers shared between the machine models. +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_HEXAGON_HEX_SUBSYS_H +#define HW_HEXAGON_HEX_SUBSYS_H + +#include "hw/hexagon/hexagon.h" + +/* Create the subsystem shared by every Hexagon machine. */ +void hex_subsys_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg); + +#endif /* HW_HEXAGON_HEX_SUBSYS_H */
hw/hexagon/hex-subsys.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Hexagon subsystem helpers shared between the machine models. +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/hexagon/hex-subsys.h" +#include "hw/core/loader.h" +#include "system/address-spaces.h" + +void hex_subsys_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +MachineState *machine =MACHINE (hms); +MemoryRegion *sysmem =get_system_memory (); + +/* Main DDR at the reset vector. */ +memory_region_init_ram (&hms->ram,NULL ,"ddr.ram" , machine->ram_size, + &error_fatal); +memory_region_add_subregion (sysmem,0x0 , &hms->ram); + +/* Config-table ROM and the blob that backs it. */ +memory_region_init_rom (&hms->cfgtable_rom,NULL ,"config_table.rom" , +sizeof (m_cfg->cfgtable), &error_fatal); +memory_region_add_subregion (sysmem, m_cfg->cfgbase, &hms->cfgtable_rom); +rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, +sizeof (m_cfg->cfgtable), m_cfg->cfgbase, + &address_space_memory); +}
hw/hexagon/hexagon_dsp.c +2 -15
@@ -14,6 +14,7 @@#include "hw/core/boards.h" #include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h"
@@ -108,7 +109,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, {HexagonCommonMachineState *hms =HEXAGON_COMMON_MACHINE (machine);HexagonDspMachineState *dms =HEXAGON_DSP_MACHINE (machine); -MemoryRegion *address_space;DeviceState *glob_regs_dev;DeviceState *tlb_dev;
@@ -120,16 +120,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, machine->enable_graphics =0 ; - address_space =get_system_memory (); - -memory_region_init_rom (&hms->cfgtable_rom,NULL ,"config_table.rom" , -sizeof (m_cfg->cfgtable), &error_fatal); -memory_region_add_subregion (address_space, m_cfg->cfgbase, - &hms->cfgtable_rom); - -memory_region_init_ram (&hms->ram,NULL ,"ddr.ram" , - machine->ram_size, &error_fatal); -memory_region_add_subregion (address_space,0x0 , &hms->ram); +hex_subsys_create (hms, m_cfg); glob_regs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); object_property_add_child(OBJECT(machine), "global-regs",
@@ -162,10 +153,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, OBJECT(tlb_dev), &error_fatal);qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); } - -rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, -sizeof (m_cfg->cfgtable), m_cfg->cfgbase, - &address_space_memory); }static void init_mc (MachineClass *mc)
hw/hexagon/virt.c +2 -12
@@ -13,6 +13,7 @@#include "hw/core/clock.h" #include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h"
@@ -244,9 +245,7 @@ static void virt_init(MachineState *ms) vms->apb_clk =clock_new (OBJECT (ms),"apb-pclk" );clock_set_hz (vms->apb_clk,24000000 ); -memory_region_init_ram (&vms->parent_obj.ram,NULL ,"ddr.ram" , - ms->ram_size, &error_fatal); -memory_region_add_subregion (vms->sys,0x0 , &vms->parent_obj.ram); +hex_subsys_create (&vms->parent_obj, m_cfg);if (m_cfg->l2tcm_size) { memory_region_init_ram(&vms->tcm, NULL, "tcm.ram", m_cfg->l2tcm_size,
@@ -255,11 +254,6 @@ static void virt_init(MachineState *ms) &vms->tcm); } -memory_region_init_rom (&vms->parent_obj.cfgtable_rom,NULL , -"config_table.rom" ,sizeof (m_cfg->cfgtable), - &error_fatal); -memory_region_add_subregion (vms->sys, m_cfg->cfgbase, - &vms->parent_obj.cfgtable_rom);fdt_add_hvx (vms, m_cfg); gsregs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG );
@@ -302,10 +296,6 @@ static void virt_init(MachineState *ms) clk_phandle =fdt_add_clocks (vms);fdt_add_uart (vms,VIRT_UART0 , clk_phandle); -rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, -sizeof (m_cfg->cfgtable), m_cfg->cfgbase, - &address_space_memory); -hexagon_load_fdt (vms); }
hw/hexagon/meson.build +1 -0
@@ -1,6 +1,7 @@ hexagon_ss = ss.source_set() hexagon_ss.add(files('hexagon_tlb.c')) hexagon_ss.add(files('hexagon_globalreg.c')) +hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hex-subsys.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))
Signature · 1 line
2.34.1
[PULL 07/41] hw/intc: Add l2vic interrupt controller
In reply to Brian CainFrom: Sid Manning <[email protected]>
The Hexagon DSP requires an L2VIC to route up to 1024 external interrupt sources through 4 VID output groups into the core's 8 interrupt inputs. Add a device model for it.
--- MAINTAINERS | 3 + docs/devel/hexagon-l2vic.rst | 55 ++++ docs/devel/index-internals.rst | 1 + include/hw/intc/hex-l2vic.h | 61 ++++ target/hexagon/cpu.h | 2 + hw/intc/hex-l2vic.c | 556 +++++++++++++++++++++++++++++++++ target/hexagon/cpu.c | 2 + target/hexagon/op_helper.c | 16 +- hw/hexagon/Kconfig | 1 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 12 files changed, 705 insertions(+), 1 deletion(-) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 include/hw/intc/hex-l2vic.h create mode 100644 hw/intc/hex-l2vic.c
MAINTAINERS +3 -0
@@ -250,6 +250,8 @@ M: Brian Cain <[email protected]> R: Pierrick Bouvier <[email protected]> S: Supported F: target/hexagon/ +F: hw/intc/hex-l2vic.c +F: include/hw/intc/hex-l2vic.h X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
@@ -262,6 +264,7 @@ F: gdbstub/gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst F: docs/system/hexagon/ F: docs/devel/hexagon-sys.rst +F: docs/devel/hexagon-l2vic.rst T: git https://github.com/qualcomm/qemu.git hex-next Hexagon idef-parser
docs/devel/hexagon-l2vic.rst new file +55 -0
55 lines not on this page · raw message
docs/devel/index-internals.rst +1 -0
@@ -15,6 +15,7 @@ Details about QEMU's various subsystems including how to add features to them. clocks ebpf_rss hexagon-sys + hexagon-l2vic migration/index multi-process reset
include/hw/intc/hex-l2vic.h new file +61 -0
61 lines not on this page · raw message
target/hexagon/cpu.h +2 -0
@@ -39,6 +39,7 @@ typedef struct HexagonGlobalRegState HexagonGlobalRegState;#include "qemu/bitmap.h" #include "target/hexagon/reg_fields.h" +#include "hw/intc/hex-l2vic.h" #define NUM_PREGS 4#define TOTAL_PER_THREAD_REGS 64
@@ -198,6 +199,7 @@ struct ArchCPU {uint32_t boot_addr;HexagonGlobalRegState *globalregs;uint32_t htid; +HexL2VicInterface *l2vic;#endif };
hw/intc/hex-l2vic.c new file +556 -0
556 lines not on this page · raw message
target/hexagon/cpu.c +2 -0
@@ -65,6 +65,8 @@ static const Property hexagon_cpu_properties[] = {DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , HexagonTLBState *),DEFINE_PROP_UINT32 ("exec-start-addr" , HexagonCPU, boot_addr,0xffffffff ), +DEFINE_PROP_LINK ("l2vic" , HexagonCPU, l2vic, + TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *),DEFINE_PROP_LINK ("global-regs" , HexagonCPU, globalregs, TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *), DEFINE_PROP_UINT32("htid", HexagonCPU, htid, 0),
target/hexagon/op_helper.c +15 -1
@@ -40,6 +40,7 @@#include "hw/hexagon/hexagon_globalreg.h" #include "hex_mmu.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/intc/hex-l2vic.h" #include "hex_interrupts.h" #include "hexswi.h" #endif
@@ -1564,7 +1565,20 @@ void HELPER(raise_stack_overflow)(CPUHexagonState *env, uint32_t slot,void HELPER (ciad )(CPUHexagonState *env,uint32_t mask) { -g_assert_not_reached (); +uint32_t ipendad; +uint32_t iad; +HexagonCPU *cpu; + +BQL_LOCK_GUARD (); + cpu =env_archcpu (env); + ipendad =hexagon_globalreg_read (cpu->globalregs,HEX_SREG_IPENDAD , + env->threadId); + iad =fGET_FIELD (ipendad,IPENDAD_IAD ); +fSET_FIELD (ipendad,IPENDAD_IAD , iad & ~(mask)); +hexagon_globalreg_write (cpu->globalregs,HEX_SREG_IPENDAD , + ipendad, env->threadId); +l2vic_clear_interrupt (cpu->l2vic); +hex_interrupt_update (env); }void HELPER (siad )(CPUHexagonState *env,uint32_t mask)
hw/hexagon/Kconfig +1 -0
@@ -3,6 +3,7 @@ config HEX_DSP default y depends on HEXAGON select CPU_CLUSTER + select HEX_L2VIC config HEX_VIRT bool
hw/intc/Kconfig +3 -0
@@ -8,6 +8,9 @@ config I8259 config PL190 bool +config HEX_L2VIC + bool + config IOAPIC bool select I8259
hw/intc/meson.build +2 -0
@@ -74,6 +74,8 @@ specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('xics_spapr.c', 'spapr_xi specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) + +specific_ss.add(when: 'CONFIG_HEX_L2VIC', if_true: files('hex-l2vic.c')) specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI_COMMON', if_true: files('loongson_ipi_common.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI', if_true: files('loongson_ipi.c'))
hw/intc/trace-events +4 -0
@@ -337,6 +337,10 @@ sh_intc_register(const char *s, int id, unsigned short v, int c, int m) "%s %u - sh_intc_read(unsigned size, uint64_t offset, unsigned long val) "size %u 0x%" PRIx64 " -> 0x%lx" sh_intc_write(unsigned size, uint64_t offset, unsigned long val) "size %u 0x%" PRIx64 " <- 0x%lx" sh_intc_set(int id, int enable) "setting interrupt group %d to %d" +# hex-l2vic.c +hex_l2vic_reg_write(unsigned int addr, uint32_t value) "addr: 0x%03x value: 0x%08"PRIx32 +hex_l2vic_reg_read(unsigned int addr, uint32_t value) "addr: 0x%03x value: 0x%08"PRIx32 +hex_l2vic_delivered(int irq, int vid) "l2vic: delivered %d (vid %d)" # loongson_ipi.c loongson_ipi_read(unsigned size, uint64_t addr, uint64_t val) "size: %u addr: 0x%"PRIx64 "val: 0x%"PRIx64
Signature · 1 line
2.34.1
[PULL 04/41] hw/hexagon: move the TLB to hex-subsys
In reply to Brian CainThe TLB device is sized from the config table, so both machines create it identically.
--- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 16 ++++++++++++++++ hw/hexagon/hexagon_dsp.c | 10 ---------- hw/hexagon/virt.c | 10 ---------- 4 files changed, 17 insertions(+), 20 deletions(-)
include/hw/hexagon/hexagon.h +1 -0
@@ -158,6 +158,7 @@ struct HexagonCommonMachineState {MemoryRegion cfgtable_rom;MemoryRegion vtcm;DeviceState *glob_regs; + DeviceState *tlb; };#endif
hw/hexagon/hex-subsys.c +16 -0
@@ -9,6 +9,7 @@#include "qapi/error.h" #include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev.h"
@@ -29,6 +30,18 @@ static DeviceState *globalreg_create(HexagonCommonMachineState *hms,return glob_regs; } +static DeviceState *tlb_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +DeviceState *tlb =qdev_new (TYPE_HEXAGON_TLB ); + +object_property_add_child (OBJECT (hms),"tlb" ,OBJECT (tlb)); +qdev_prop_set_uint32 (tlb,"num-entries" , m_cfg->cfgtable.jtlb_size_entries); +sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb), &error_fatal); + +return tlb; +} +void hex_subsys_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev) {
@@ -57,11 +70,14 @@ void hex_subsys_create(HexagonCommonMachineState *hms, } hms->glob_regs =globalreg_create (hms, m_cfg, rev); + hms->tlb =tlb_create (hms, m_cfg); }void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) {object_property_set_link (OBJECT (cpu),"global-regs" ,OBJECT (hms->glob_regs), &error_fatal); +object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (hms->tlb), + &error_fatal);qdev_realize_and_unref (cpu,NULL , &error_fatal); }
hw/hexagon/hexagon_dsp.c +0 -10
@@ -15,7 +15,6 @@#include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "qapi/error.h" #include "qemu/error-report.h"
@@ -108,7 +107,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, {HexagonCommonMachineState *hms =HEXAGON_COMMON_MACHINE (machine);HexagonDspMachineState *dms =HEXAGON_DSP_MACHINE (machine); -DeviceState *tlb_dev;memset (&hexagon_binfo,0 ,sizeof (hexagon_binfo));if (machine->kernel_filename) {
@@ -120,12 +118,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,hex_subsys_create (hms, m_cfg, rev); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); -object_property_add_child (OBJECT (machine),"tlb" ,OBJECT (tlb_dev)); -qdev_prop_set_uint32 (tlb_dev,"num-entries" , - m_cfg->cfgtable.jtlb_size_entries); -sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb_dev), &error_fatal); -for (int i =0 ; i < machine->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (machine->cpu_type));qemu_register_reset (do_cpu_reset, cpu);
@@ -138,8 +130,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,if (i ==0 ) {hexagon_init_bootstrap (dms, cpu); } -object_property_set_link (OBJECT (cpu),"tlb" , -OBJECT (tlb_dev), &error_fatal);hex_subsys_realize_cpu (hms,DEVICE (cpu)); } }
hw/hexagon/virt.c +0 -10
@@ -14,7 +14,6 @@#include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev-clock.h"
@@ -225,7 +224,6 @@ static void virt_init(MachineState *ms) {HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms);const struct hexagon_machine_config *m_cfg = &v68n_1024; -DeviceState *tlb_dev;int32_t clk_phandle;create_fdt (vms);
@@ -248,12 +246,6 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); -object_property_add_child (OBJECT (ms),"tlb" ,OBJECT (tlb_dev)); -qdev_prop_set_uint32 (tlb_dev,"num-entries" , - m_cfg->cfgtable.jtlb_size_entries); -sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb_dev), &error_fatal); -for (int i =0 ; i < ms->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);
@@ -269,8 +261,6 @@ static void virt_init(MachineState *ms) }qdev_prop_set_uint32 (DEVICE (cpu),"htid" , i);qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 )); -object_property_set_link (OBJECT (cpu),"tlb" , -OBJECT (tlb_dev), &error_fatal);hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpu)); }
Signature · 1 line
2.34.1
[PULL 20/41] target/hexagon: add GVec overrides for HVX saturating add/sub
In reply to Brian Cain--- target/hexagon/gen_tcg_hvx.h | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+)
target/hexagon/gen_tcg_hvx.h +87 -0
@@ -234,6 +234,93 @@ static inline void assert_vhist_tmp(DisasContext *ctx)tcg_gen_gvec_sub (MO_32 , VddV_off, VuuV_off, VvvV_off, \ sizeof(MMVector) * 2, sizeof(MMVector) * 2) +#define fGEN_TCG_V6_vaddbsat (SHORTCODE ) \ + tcg_gen_gvec_ssadd(MO_8, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vaddhsat (SHORTCODE ) \ + tcg_gen_gvec_ssadd(MO_16, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vaddwsat (SHORTCODE ) \ + tcg_gen_gvec_ssadd(MO_32, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vaddubsat (SHORTCODE ) \ + tcg_gen_gvec_usadd(MO_8, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vadduhsat (SHORTCODE ) \ + tcg_gen_gvec_usadd(MO_16, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vadduwsat (SHORTCODE ) \ + tcg_gen_gvec_usadd(MO_32, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_PAIR_ADDSUB (OP ,VECE ,DST ,SRC_A ,SRC_B ) \ + tcg_gen_gvec_##OP(VECE, DST, SRC_A, SRC_B, \ + 2 * VECTOR_SIZE_BYTE, 2 * VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vaddbsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(ssadd, MO_8, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vaddhsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(ssadd, MO_16, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vaddwsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(ssadd, MO_32, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vaddubsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(usadd, MO_8, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vadduhsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(usadd, MO_16, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vadduwsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(usadd, MO_32, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vsubbsat (SHORTCODE ) \ + tcg_gen_gvec_sssub(MO_8, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vsubhsat (SHORTCODE ) \ + tcg_gen_gvec_sssub(MO_16, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vsubwsat (SHORTCODE ) \ + tcg_gen_gvec_sssub(MO_32, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vsububsat (SHORTCODE ) \ + tcg_gen_gvec_ussub(MO_8, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vsubuhsat (SHORTCODE ) \ + tcg_gen_gvec_ussub(MO_16, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vsubuwsat (SHORTCODE ) \ + tcg_gen_gvec_ussub(MO_32, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vsubbsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(sssub, MO_8, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vsubhsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(sssub, MO_16, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vsubwsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(sssub, MO_32, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vsububsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(ussub, MO_8, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vsubuhsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(ussub, MO_16, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vsubuwsat_dv (SHORTCODE ) \ + fGEN_TCG_PAIR_ADDSUB(ussub, MO_32, VddV_off, VuuV_off, VvvV_off)/* Vector shift right - various forms */ #define fGEN_TCG_V6_vasrh (SHORTCODE ) \ do { \
Signature · 1 line
2.34.1
[PULL 18/41] tests/functional/hexagon: enable more arch_tests cases
In reply to Brian CainAdd more tests from hexagon-arch-tests, enabled by QTimer device.
These exercise cache maintenance ops, l2vic, thread start/stop, tlb/mmu operations, and user-mode transitions.
--- tests/functional/hexagon/test_arch_tests.py | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+)
tests/functional/hexagon/test_arch_tests.py +32 -0
@@ -58,6 +58,38 @@ def test_int_steering(self) -> None: """ self.run_uart_test("test_int_steering") + def test_cache(self) -> None: + """Tests cache operations: dckill/ickill, l2kill, dczeroa, + dccleaninva, cache disable/enable, barriers, and dcinva/dccleana. + """ + self.run_uart_test("test_cache") + + def test_l2vic(self) -> None: + """Tests the L2VIC interrupt controller: enable readback, + interrupt type readback, VID capture, and the fast interface. + """ + self.run_uart_test("test_l2vic") + + def test_threads(self) -> None: + """Tests hardware thread management: start/stop, MODECTL state, + per-thread HTID, shared memory, wait/resume, STID priority, and + SCHEDCFG/BESTWAIT readback. + """ + self.run_uart_test("test_threads") + + def test_tlb_mmu(self) -> None: + """Tests TLB/MMU operations: write/read/probe/invalidate, + global entries, multiple entries, overwrite, ASID matching, + and permission checks. + """ + self.run_uart_test("test_tlb_mmu") + + def test_user_mode(self) -> None: + """Tests user mode / privilege transitions: supervisor mode, + SSR UM/IE/XE/CE/PE bits, and the trap0 user-mode exit handler. + """ + self.run_uart_test("test_user_mode") + if __name__ == "__main__": QemuSystemTest.main()
Signature · 1 line
2.34.1
[PULL 19/41] host-utils: fix ssub32/64_saturate return type and clamp direction
In reply to Brian Cainssub32_saturate() and ssub64_saturate() were declared to return bool instead of int32_t/int64_t, and clamped to the wrong bound on overflow.
--- include/qemu/host-utils.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
include/qemu/host-utils.h +12 -12
@@ -607,10 +607,10 @@ static inline bool umul64_overflow(uint64_t x, uint64_t y, uint64_t *ret) }/** -* sadd32_saturate - addition with saturation +* sadd32_saturate - 32-bit signed addition with saturation * @x, @y: addends * -* Computes @x + @y, and saturates rathern than truncating the result. +* Computes @x + @y, and saturates rather than truncating the result. */ static inline int32_t sadd32_saturate (int32_t x,int32_t y) {
@@ -622,10 +622,10 @@ static inline int32_t sadd32_saturate(int32_t x, int32_t y) }/** -* sadd64_saturate - addition with saturation +* sadd64_saturate - 64-bit signed addition with saturation * @x, @y: addends * -* Computes @x + @y, and saturates rathern than truncating the result. +* Computes @x + @y, and saturates rather than truncating the result. */ static inline int64_t sadd64_saturate (int64_t x,int64_t y) {
@@ -637,31 +637,31 @@ static inline int64_t sadd64_saturate(int64_t x, int64_t y) }/** -* ssub32_saturate - subtraction with saturation +* ssub32_saturate - 32-bit signed subtraction with saturation * @x, @y: addends * -* Computes @x + @y, and saturates rathern than truncating the result. +* Computes @x - @y, and saturates rather than truncating the result. */ -static inline bool ssub32_saturate (int32_t x,int32_t y) +static inline int32_t ssub32_saturate (int32_t x,int32_t y) {int32_t ret;if (ssub32_overflow (x, y, &ret)) { - ret = x <0 ?INT32_MAX :INT32_MIN ; + ret = x <0 ?INT32_MIN :INT32_MAX ; }return ret; }/** -* ssub64_saturate - subtraction with saturation +* ssub64_saturate - 64-bit signed subtraction with saturation * @x, @y: addends * -* Computes @x + @y, and saturates rathern than truncating the result. +* Computes @x - @y, and saturates rather than truncating the result. */ -static inline bool ssub64_saturate (int64_t x,int64_t y) +static inline int64_t ssub64_saturate (int64_t x,int64_t y) {int64_t ret;if (ssub64_overflow (x, y, &ret)) { - ret = x <0 ?INT64_MAX :INT64_MIN ; + ret = x <0 ?INT64_MIN :INT64_MAX ; }return ret; }
Signature · 1 line
2.34.1
[PULL 06/41] bitops.h: Add find_first_bit32()
In reply to Brian Cainset_bit32()/test_bit32()/etc already let devices operate on guest-visible uint32_t register arrays without depending on the host's 'unsigned long' size. Add find_first_bit32() so callers need not cast a uint32_t array to 'unsigned long *'.
--- include/qemu/bitops.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
include/qemu/bitops.h +26 -4
@@ -43,10 +43,9 @@* be some guest-visible register view of the bit array. * * We do not currently implement uint32_t versions of find_last_bit(), -* find_next_bit(), find_next_zero_bit(), find_first_bit() or -* find_first_zero_bit(), because we haven't yet needed them. If you -* need them you should implement them similarly to the 'unsigned long' -* versions. +* find_next_bit(), find_next_zero_bit() or find_first_zero_bit(), +* because we haven't yet needed them. If you need them you should +* implement them similarly to the 'unsigned long' versions. * * You can declare a bitmap to be used with these functions via the * DECLARE_BITMAP and DECLARE_BITMAP32 macros in bitmap.h.
@@ -382,6 +381,29 @@ static inline int test_bit32(long nr, const uint32_t *addr)return 1U & (addr[BIT32_WORD (nr)] >> (nr &31 )); } +/** +* find_first_bit32 - find the first set bit in a memory region +* @addr: The address to start the search at +* @size: The maximum size to search +* +* Returns the bit number of the first set bit, +* or @size if there is no set bit in the bitmap. +*/ +static inline uint32_t find_first_bit32 (const uint32_t *addr,uint32_t size) +{ +uint32_t result; + +for (result =0 ; result < size; result +=32 ) { +uint32_t tmp = *addr++; +if (tmp) { + result +=ctz32 (tmp); +return result < size ? result : size; + } + } +/* Not found */ +return size; +} +/** * DOC: Miscellaneous bit operations on single values *
Signature · 1 line
2.34.1
[PULL 10/41] hw/hexagon/virt: instantiate virtio-mmio transports
In reply to Brian CainAdd a VIRT_MMIO region and virtio-mmio transports, wired into l2vic.
--- include/hw/hexagon/virt.h | 3 +++ hw/hexagon/virt.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
include/hw/hexagon/virt.h +3 -0
@@ -11,6 +11,8 @@#include "hw/hexagon/hexagon.h" #include "target/hexagon/cpu.h" +#define VIRTIO_DEV_COUNT 8 +struct HexagonVirtMachineState {HexagonCommonMachineState parent_obj;
@@ -19,6 +21,7 @@ struct HexagonVirtMachineState {MemoryRegion tcm;MemoryRegion bios;Clock *apb_clk; +DeviceState *virtio_mmio[VIRTIO_DEV_COUNT ]; };void hexagon_load_fdt (const struct HexagonVirtMachineState *vms);
hw/hexagon/virt.c +28 -0
@@ -30,11 +30,19 @@enum {VIRT_UART0 , +VIRT_MMIO ,VIRT_FDT , }; +/* +* Virtio IRQs run from VIRTIO_IRQ_BASE to +* VIRTIO_IRQ_BASE + VIRTIO_DEV_COUNT - 1 +*/ +static const int VIRTIO_IRQ_BASE =16 ; +static const MemMapEntry base_memmap[] = { [VIRT_UART0 ] = {0x10000000 ,0x00000200 }, + [VIRT_MMIO ] = {0x11000000 ,0x00001000 }, [VIRT_FDT ] = {0x99800000 ,0x00400000 }, };
@@ -167,7 +175,25 @@ static void fdt_add_cpu_nodes(const HexagonVirtMachineState *vms) } } +static void create_virtio_devices (HexagonVirtMachineState *vms) +{ +hwaddr size = base_memmap[VIRT_MMIO ].size; +for (int i =0 ; i <VIRTIO_DEV_COUNT ; i++) { +int irq =VIRTIO_IRQ_BASE + i; +hwaddr base = base_memmap[VIRT_MMIO ].base + i * size; +DeviceState *dev =qdev_new ("virtio-mmio" ); +SysBusDevice *s =SYS_BUS_DEVICE (dev); + +object_property_add_child (OBJECT (MACHINE (vms)),"virtio-mmio[*]" , +OBJECT (dev)); +sysbus_realize_and_unref (s, &error_fatal); +sysbus_mmio_map (s,0 , base); +sysbus_connect_irq (s,0 , +qdev_get_gpio_in (vms->parent_obj.l2vic, irq)); + vms->virtio_mmio[i] = dev; + } +}void hexagon_load_fdt (const HexagonVirtMachineState *vms) {
@@ -246,6 +272,8 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); +create_virtio_devices (vms); + g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, ms->smp.cpus);for (int i =0 ; i < ms->smp.cpus; i++) {
Signature · 1 line
2.34.1
[PULL 30/41] hexagon: print info on "-d in_asm" for disabled IEEE FP instructions
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
When cpu->cfg.ieee_fp_extension is off, IEEE FP instructions don't get executed. Let's print that info on the "-d in_asm" output to help users. This will generate an output like the following:
0x00020e30: 0x1f82e1c0 { V0.sf = vadd(V1.sf,V2.sf) (disabled: no ieee_fp) }
--- target/hexagon/cpu_bits.h | 5 +++-- target/hexagon/printinsn.h | 2 +- disas/hexagon.c | 4 ++-- target/hexagon/cpu.c | 5 ++++- target/hexagon/decode.c | 4 ++-- target/hexagon/printinsn.c | 9 +++++++-- 6 files changed, 19 insertions(+), 10 deletions(-)
target/hexagon/cpu_bits.h +3 -2
@@ -26,6 +26,7 @@ typedef struct HexagonCPUConfig {uint32_t lldb_stack_adjust;bool short_circuit;bool ieee_fp_extension; +const HexagonCPUDef *hex_def; } HexagonCPUConfig;#define PCALIGN 4
@@ -130,7 +131,7 @@ static inline bool is_packet_end(uint32_t endocing) return ((bits == 0x3) || (bits == 0x0)); } -int disassemble_hexagon (uint32_t *words,int nwords,bfd_vma pc,GString *buf, -const HexagonCPUDef *hex_def); +int disassemble_hexagon (uint32_t *words,int nwords,bfd_vma pc, +GString *buf,const HexagonCPUConfig *cfg);#endif
target/hexagon/printinsn.h +1 -1
@@ -22,6 +22,6 @@#include "insn.h" void snprint_a_pkt_disas (GString *buf,Packet *pkt,uint32_t *words, -target_ulong pc,const HexagonCPUDef *hex_def); +target_ulong pc,const HexagonCPUConfig *cfg);#endif
disas/hexagon.c +2 -2
@@ -31,7 +31,6 @@int print_insn_hexagon (bfd_vma memaddr,struct disassemble_info *info) { -const HexagonCPUDef *hex_def = (const HexagonCPUDef *)info->target_info;uint32_t words[PACKET_WORDS_MAX ];bool found_end = false;GString *buf;
@@ -58,8 +57,9 @@ int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info)return PACKET_WORDS_MAX *sizeof (uint32_t ); } +const HexagonCPUConfig *cfg = info->target_info; buf =g_string_sized_new (PACKET_BUFFER_LEN ); - len =disassemble_hexagon (words, i, memaddr, buf, hex_def); + len =disassemble_hexagon (words, i, memaddr, buf, cfg); (*info->fprintf_func)(info->stream,"%s" , buf->str);g_string_free (buf, true);
target/hexagon/cpu.c +4 -1
@@ -444,12 +444,13 @@ static void hexagon_cpu_disas_set_info(const CPUState *cs,const HexagonCPU *cpu =HEXAGON_CPU (cs); info->print_insn = print_insn_hexagon; info->endian =BFD_ENDIAN_LITTLE ; - info->target_info =HEXAGON_CPU_GET_CLASS (cpu)->hex_def; + info->target_info = &cpu->cfg; }static void hexagon_cpu_realize (DeviceState *dev,Error **errp) {CPUState *cs =CPU (dev); +HexagonCPU *cpu =HEXAGON_CPU (dev);HexagonCPUClass *mcc =HEXAGON_CPU_GET_CLASS (dev);Error *local_err =NULL ;
@@ -459,6 +460,8 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp)return ; } + cpu->cfg.hex_def = mcc->hex_def; +gdb_register_coprocessor (cs, hexagon_hvx_gdb_read_register, hexagon_hvx_gdb_write_register,gdb_find_static_feature ("hexagon-hvx.xml" ));
target/hexagon/decode.c +2 -2
@@ -856,7 +856,7 @@ int decode_packet(DisasContext *ctx, int max_words, const uint32_t *words,/* Used for "-d in_asm" logging */ int disassemble_hexagon (uint32_t *words,int nwords,bfd_vma pc, -GString *buf,const HexagonCPUDef *hex_def) +GString *buf,const HexagonCPUConfig *cfg) {HexagonCPUDef any_def = { .hex_version =HEX_VER_ANY ,/* Allow decode to accept anything */
@@ -867,7 +867,7 @@ int disassemble_hexagon(uint32_t *words, int nwords, bfd_vma pc, ctx.hex_def = &any_def;if (decode_packet (&ctx, nwords, words, &ctx.pkt, true) >0 ) { -snprint_a_pkt_disas (buf, &ctx.pkt, words, pc, hex_def); +snprint_a_pkt_disas (buf, &ctx.pkt, words, pc, cfg);return ctx.pkt.encod_pkt_size_in_bytes; }else {for (int i =0 ; i < nwords; i++) {
target/hexagon/printinsn.c +7 -2
@@ -139,7 +139,7 @@ static void snprintinsn(GString *buf, Insn *insn) }void snprint_a_pkt_disas (GString *buf,Packet *pkt,uint32_t *words, -target_ulong pc,const HexagonCPUDef *hex_def) +target_ulong pc,const HexagonCPUConfig *cfg) {bool has_endloop0 = false;bool has_endloop1 = false;
@@ -171,12 +171,17 @@ void snprint_a_pkt_disas(GString *buf, Packet *pkt, uint32_t *words, }g_string_append (buf,"\t" ); -if (opcode_supported (pkt->insn[i].opcode, hex_def)) { +if (opcode_supported (pkt->insn[i].opcode, cfg->hex_def)) {snprintinsn (buf, &(pkt->insn[i])); }else {g_string_append (buf,"<invalid>" ); } +if (!cfg->ieee_fp_extension && +GET_ATTRIB (pkt->insn[i].opcode,A_HVX_IEEE_FP )) { +g_string_append (buf," (disabled: no ieee_fp)" ); + } +if (i < pkt->num_insns -1 ) {/* * Subinstructions are two instructions encoded
Signature · 1 line
2.34.1
[PULL 39/41] tests/hexagon: add tests for v68 HVX IEEE float conversions
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
--- tests/tcg/hexagon/hex_test.h | 14 +++ tests/tcg/hexagon/hvx_misc.h | 2 + tests/tcg/hexagon/fp_hvx_cvt.c | 188 ++++++++++++++++++++++++++++++ tests/tcg/hexagon/Makefile.target | 3 + 4 files changed, 207 insertions(+) create mode 100644 tests/tcg/hexagon/fp_hvx_cvt.c
tests/tcg/hexagon/hex_test.h +14 -0
@@ -111,6 +111,20 @@ static inline void __check64_ne(int line, uint64_t val, uint64_t expect)"usr = r2\n\t" /* Some useful floating point values */ +const uint16_t HF_INF = 0x7c00; +const uint16_t HF_INF_neg =0xfc00 ; +const uint16_t HF_QNaN =0x7e00 ; +const uint16_t HF_SNaN =0x7d00 ; +const uint16_t HF_QNaN_neg =0xfe00 ; +const uint16_t HF_zero =0x0000 ; +const uint16_t HF_zero_neg =0x8000 ; +const uint16_t HF_one =0x3c00 ; +const uint16_t HF_one_recip =0x3bf9 ; +const uint16_t HF_two =0x4000 ; +const uint16_t HF_small_neg =0x8010 ; +const uint16_t HF_any =0x3c00 ; +const uint16_t HF_neg_two =0xc000 ; +const uint32_t SF_INF =0x7f800000 ;const uint32_t SF_INF_neg =0xff800000 ;const uint32_t SF_QNaN =0x7fc00000 ;
tests/tcg/hexagon/hvx_misc.h +2 -0
@@ -69,7 +69,9 @@ CHECK_OUTPUT_FUNC(d, 8) CHECK_OUTPUT_FUNC(w, 4) CHECK_OUTPUT_FUNC(sf, 4) CHECK_OUTPUT_FUNC(h, 2) +CHECK_OUTPUT_FUNC(uh, 2) CHECK_OUTPUT_FUNC(hf, 2) +CHECK_OUTPUT_FUNC(ub, 1) CHECK_OUTPUT_FUNC(b, 1)static inline void init_buffers (void )
tests/tcg/hexagon/fp_hvx_cvt.c new file +188 -0
188 lines not on this page · raw message
tests/tcg/hexagon/Makefile.target +3 -0
@@ -51,6 +51,7 @@ HEX_TESTS += scatter_gather HEX_TESTS += hvx_misc HEX_TESTS += hvx_histogram HEX_TESTS += fp_hvx +HEX_TESTS += fp_hvx_cvt HEX_TESTS += fp_hvx_disabled HEX_TESTS += invalid-slots HEX_TESTS += valid-slots
@@ -142,6 +143,8 @@ fp_hvx: fp_hvx.c hvx_misc.h hex_test.h fp_hvx: CFLAGS += -mhvx -mhvx-ieee-fp fp_hvx_disabled: fp_hvx_disabled.c hvx_misc.h hex_test.h fp_hvx_disabled: CFLAGS += -mhvx -mhvx-ieee-fp +fp_hvx_cvt: fp_hvx_cvt.c hvx_misc.h hex_test.h +fp_hvx_cvt: CFLAGS += -mhvx -mhvx-ieee-fp run-fp_hvx_disabled: QEMU_OPTS += -cpu v73,ieee-fp=false
Signature · 1 line
2.34.1
[PULL 17/41] tests/qtest: add qct-qtimer qtest
In reply to Brian CainAdd a qtest exercising the QCT QTimer's register access, view-region frame addressing, and one-shot timer firing behavior.
--- MAINTAINERS | 1 + tests/qtest/qct-qtimer-test.c | 385 ++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 3 files changed, 387 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/qct-qtimer-test.c
MAINTAINERS +1 -0
@@ -255,6 +255,7 @@ F: include/hw/intc/hex-l2vic.h F: tests/qtest/l2vic-test.c F: hw/timer/qct-qtimer.c F: include/hw/timer/qct-qtimer.h +F: tests/qtest/qct-qtimer-test.c X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
tests/qtest/qct-qtimer-test.c new file +385 -0
385 lines not on this page · raw message
tests/qtest/meson.build +1 -1
@@ -299,7 +299,7 @@ qtests_riscv64 = ['riscv-csr-test'] + \ ['iommu-riscv-test'] : []) + \ (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) -qtests_hexagon = ['boot-serial-test', 'l2vic-test'] +qtests_hexagon = ['boot-serial-test', 'l2vic-test', 'qct-qtimer-test'] qos_test_ss = ss.source_set() qos_test_ss.add(
Signature · 1 line
2.34.1
[PULL 37/41] tests/hexagon: add tests for v68 HVX IEEE float arithmetics
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
--- tests/tcg/hexagon/hex_test.h | 4 + tests/tcg/hexagon/hvx_misc.h | 41 ++++++++ tests/tcg/hexagon/fp_hvx.c | 155 ++++++++++++++++++++++++++++ tests/tcg/hexagon/fp_hvx_disabled.c | 57 ++++++++++ tests/tcg/hexagon/Makefile.target | 8 ++ 5 files changed, 265 insertions(+) create mode 100644 tests/tcg/hexagon/fp_hvx.c create mode 100644 tests/tcg/hexagon/fp_hvx_disabled.c
tests/tcg/hexagon/hex_test.h +4 -0
@@ -19,6 +19,8 @@#ifndef HEX_TEST_H #define HEX_TEST_H +#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) +static inline void __check32 (int line,uint32_t val,uint32_t expect) {if (val != expect) {
@@ -110,6 +112,7 @@ static inline void __check64_ne(int line, uint64_t val, uint64_t expect)/* Some useful floating point values */ const uint32_t SF_INF =0x7f800000 ; +const uint32_t SF_INF_neg =0xff800000 ;const uint32_t SF_QNaN =0x7fc00000 ;const uint32_t SF_QNaN_special =0x7f800001 ;const uint32_t SF_SNaN =0x7fb00000 ;
@@ -128,6 +131,7 @@ const uint32_t SF_large_pos = 0x5afa572e;const uint32_t SF_any =0x3f800000 ;const uint32_t SF_denorm =0x00000001 ;const uint32_t SF_random =0x346001d6 ; +const uint32_t SF_neg_two =0xc0000000 ;const uint64_t DF_QNaN =0x7ff8000000000000ULL ;const uint64_t DF_SNaN =0x7ff7000000000000ULL ;
tests/tcg/hexagon/hvx_misc.h +41 -0
72 lines not on this page · raw message
tests/tcg/hexagon/fp_hvx.c new file +155 -0
155 lines not on this page · raw message
tests/tcg/hexagon/fp_hvx_disabled.c new file +57 -0
57 lines not on this page · raw message
tests/tcg/hexagon/Makefile.target +8 -0
@@ -50,6 +50,8 @@ HEX_TESTS += vector_add_int HEX_TESTS += scatter_gather HEX_TESTS += hvx_misc HEX_TESTS += hvx_histogram +HEX_TESTS += fp_hvx +HEX_TESTS += fp_hvx_disabled HEX_TESTS += invalid-slots HEX_TESTS += valid-slots HEX_TESTS += invalid-encoding
@@ -136,6 +138,12 @@ v68_hvx: CFLAGS += -mhvx -Wno-unused-function v69_hvx: v69_hvx.c hvx_misc.h v69_hvx: CFLAGS += -mhvx -Wno-unused-function v73_scalar: CFLAGS += -Wno-unused-function +fp_hvx: fp_hvx.c hvx_misc.h hex_test.h +fp_hvx: CFLAGS += -mhvx -mhvx-ieee-fp +fp_hvx_disabled: fp_hvx_disabled.c hvx_misc.h hex_test.h +fp_hvx_disabled: CFLAGS += -mhvx -mhvx-ieee-fp + +run-fp_hvx_disabled: QEMU_OPTS += -cpu v73,ieee-fp=false hvx_histogram: hvx_histogram.c hvx_histogram_row.S $(CC) $(CFLAGS) $(CROSS_CC_GUEST_CFLAGS) $^ -o $@ $(LDFLAGS)
Signature · 1 line
2.34.1
[PULL 26/41] Hexagon (target/hexagon) Clean up disassembly of control and system regs
In reply to Brian CainFrom: Taylor Simpson <[email protected]>
Change disassembly of control regs from C{num}/{name} to {name} Change disassembly of system regs from S{num}/r{num} to {name}
--- target/hexagon/printinsn.c | 99 +++++++++++++++++++++++++++++++-- target/hexagon/gen_printinsn.py | 14 +++-- 2 files changed, 101 insertions(+), 12 deletions(-)
target/hexagon/printinsn.c +93 -6
@@ -23,18 +23,105 @@#include "internal.h" #include "decode.h" -static const char *sreg2str (unsigned int reg) +/* +* Used when there is some sort of error and we can't figure out the real +* system register name +*/ +static const char *const generic_sreg_names[256 ] = { +"S000" ,"S001" ,"S002" ,"S003" ,"S004" ,"S005" ,"S006" ,"S007" , +"S008" ,"S009" ,"S010" ,"S011" ,"S012" ,"S013" ,"S014" ,"S015" , +"S016" ,"S017" ,"S018" ,"S019" ,"S020" ,"S021" ,"S022" ,"S023" , +"S024" ,"S025" ,"S026" ,"S027" ,"S028" ,"S029" ,"S030" ,"S031" , +"S032" ,"S033" ,"S034" ,"S035" ,"S036" ,"S037" ,"S038" ,"S039" , +"S040" ,"S041" ,"S042" ,"S043" ,"S044" ,"S045" ,"S046" ,"S047" , +"S048" ,"S049" ,"S050" ,"S051" ,"S052" ,"S053" ,"S054" ,"S055" , +"S056" ,"S057" ,"S058" ,"S059" ,"S060" ,"S061" ,"S062" ,"S063" , +"S064" ,"S065" ,"S066" ,"S067" ,"S068" ,"S069" ,"S070" ,"S071" , +"S072" ,"S073" ,"S074" ,"S075" ,"S076" ,"S077" ,"S078" ,"S079" , +"S080" ,"S081" ,"S082" ,"S083" ,"S084" ,"S085" ,"S086" ,"S087" , +"S088" ,"S089" ,"S090" ,"S091" ,"S092" ,"S093" ,"S094" ,"S095" , +"S096" ,"S097" ,"S098" ,"S099" ,"S100" ,"S101" ,"S102" ,"S103" , +"S104" ,"S105" ,"S106" ,"S107" ,"S108" ,"S109" ,"S110" ,"S111" , +"S112" ,"S113" ,"S114" ,"S115" ,"S116" ,"S117" ,"S118" ,"S119" , +"S120" ,"S121" ,"S122" ,"S123" ,"S124" ,"S125" ,"S126" ,"S127" , +"S128" ,"S129" ,"S130" ,"S131" ,"S132" ,"S133" ,"S134" ,"S135" , +"S136" ,"S137" ,"S138" ,"S139" ,"S140" ,"S141" ,"S142" ,"S143" , +"S144" ,"S145" ,"S146" ,"S147" ,"S148" ,"S149" ,"S150" ,"S151" , +"S152" ,"S153" ,"S154" ,"S155" ,"S156" ,"S157" ,"S158" ,"S159" , +"S160" ,"S161" ,"S162" ,"S163" ,"S164" ,"S165" ,"S166" ,"S167" , +"S168" ,"S169" ,"S170" ,"S171" ,"S172" ,"S173" ,"S174" ,"S175" , +"S176" ,"S177" ,"S178" ,"S179" ,"S180" ,"S181" ,"S182" ,"S183" , +"S184" ,"S185" ,"S186" ,"S187" ,"S188" ,"S189" ,"S190" ,"S191" , +"S192" ,"S193" ,"S194" ,"S195" ,"S196" ,"S197" ,"S198" ,"S199" , +"S200" ,"S201" ,"S202" ,"S203" ,"S204" ,"S205" ,"S206" ,"S207" , +"S208" ,"S209" ,"S210" ,"S211" ,"S212" ,"S213" ,"S214" ,"S215" , +"S216" ,"S217" ,"S218" ,"S219" ,"S220" ,"S221" ,"S222" ,"S223" , +"S224" ,"S225" ,"S226" ,"S227" ,"S228" ,"S229" ,"S230" ,"S231" , +"S232" ,"S233" ,"S234" ,"S235" ,"S236" ,"S237" ,"S238" ,"S239" , +"S240" ,"S241" ,"S242" ,"S243" ,"S244" ,"S245" ,"S246" ,"S247" , +"S248" ,"S249" ,"S250" ,"S251" ,"S252" ,"S253" ,"S254" ,"S255" , +}; + +static const char *sreg2str (uint8_t reg) { -if (reg <TOTAL_PER_THREAD_REGS ) { -return hexagon_regnames[reg]; +#ifndef CONFIG_USER_ONLY +if (reg <NUM_SREGS ) { +return hexagon_sregnames[reg]; }else { -return "???" ; +return generic_sreg_names[reg]; } +#else +return generic_sreg_names[reg]; +#endif } -static const char *creg2str (unsigned int reg) +/* +* Used when there is some sort of error and we can't figure out the real +* control register name +*/ +static const char *const generic_creg_names[256 ] = { +"C000" ,"C001" ,"C002" ,"C003" ,"C004" ,"C005" ,"C006" ,"C007" , +"C008" ,"C009" ,"C010" ,"C011" ,"C012" ,"C013" ,"C014" ,"C015" , +"C016" ,"C017" ,"C018" ,"C019" ,"C020" ,"C021" ,"C022" ,"C023" , +"C024" ,"C025" ,"C026" ,"C027" ,"C028" ,"C029" ,"C030" ,"C031" , +"C032" ,"C033" ,"C034" ,"C035" ,"C036" ,"C037" ,"C038" ,"C039" , +"C040" ,"C041" ,"C042" ,"C043" ,"C044" ,"C045" ,"C046" ,"C047" , +"C048" ,"C049" ,"C050" ,"C051" ,"C052" ,"C053" ,"C054" ,"C055" , +"C056" ,"C057" ,"C058" ,"C059" ,"C060" ,"C061" ,"C062" ,"C063" , +"C064" ,"C065" ,"C066" ,"C067" ,"C068" ,"C069" ,"C070" ,"C071" , +"C072" ,"C073" ,"C074" ,"C075" ,"C076" ,"C077" ,"C078" ,"C079" , +"C080" ,"C081" ,"C082" ,"C083" ,"C084" ,"C085" ,"C086" ,"C087" , +"C088" ,"C089" ,"C090" ,"C091" ,"C092" ,"C093" ,"C094" ,"C095" , +"C096" ,"C097" ,"C098" ,"C099" ,"C100" ,"C101" ,"C102" ,"C103" , +"C104" ,"C105" ,"C106" ,"C107" ,"C108" ,"C109" ,"C110" ,"C111" , +"C112" ,"C113" ,"C114" ,"C115" ,"C116" ,"C117" ,"C118" ,"C119" , +"C120" ,"C121" ,"C122" ,"C123" ,"C124" ,"C125" ,"C126" ,"C127" , +"C128" ,"C129" ,"C130" ,"C131" ,"C132" ,"C133" ,"C134" ,"C135" , +"C136" ,"C137" ,"C138" ,"C139" ,"C140" ,"C141" ,"C142" ,"C143" , +"C144" ,"C145" ,"C146" ,"C147" ,"C148" ,"C149" ,"C150" ,"C151" , +"C152" ,"C153" ,"C154" ,"C155" ,"C156" ,"C157" ,"C158" ,"C159" , +"C160" ,"C161" ,"C162" ,"C163" ,"C164" ,"C165" ,"C166" ,"C167" , +"C168" ,"C169" ,"C170" ,"C171" ,"C172" ,"C173" ,"C174" ,"C175" , +"C176" ,"C177" ,"C178" ,"C179" ,"C180" ,"C181" ,"C182" ,"C183" , +"C184" ,"C185" ,"C186" ,"C187" ,"C188" ,"C189" ,"C190" ,"C191" , +"C192" ,"C193" ,"C194" ,"C195" ,"C196" ,"C197" ,"C198" ,"C199" , +"C200" ,"C201" ,"C202" ,"C203" ,"C204" ,"C205" ,"C206" ,"C207" , +"C208" ,"C209" ,"C210" ,"C211" ,"C212" ,"C213" ,"C214" ,"C215" , +"C216" ,"C217" ,"C218" ,"C219" ,"C220" ,"C221" ,"C222" ,"C223" , +"C224" ,"C225" ,"C226" ,"C227" ,"C228" ,"C229" ,"C230" ,"C231" , +"C232" ,"C233" ,"C234" ,"C235" ,"C236" ,"C237" ,"C238" ,"C239" , +"C240" ,"C241" ,"C242" ,"C243" ,"C244" ,"C245" ,"C246" ,"C247" , +"C248" ,"C249" ,"C250" ,"C251" ,"C252" ,"C253" ,"C254" ,"C255" , +}; + +static const char *creg2str (uint8_t reg) { -return sreg2str (reg +HEX_REG_SA0 ); +uint8_t gpr = reg +HEX_REG_SA0 ; +if (gpr <TOTAL_PER_THREAD_REGS ) { +return hexagon_regnames[gpr]; + }else { +return generic_creg_names[reg]; + } }static void snprintinsn (GString *buf,Insn *insn)
target/hexagon/gen_printinsn.py +8 -6
@@ -28,13 +28,14 @@ ## Generate data for printing each instruction (format string + operands) ## def regprinter(m): - str = m.group(1) - str += ":".join(["%d"] * len(m.group(2))) - str += m.group(3) if ("S" in m.group(1)) and (len(m.group(2)) == 1): - str += "/%s" + str = "%s" elif ("C" in m.group(1)) and (len(m.group(2)) == 1): - str += "/%s" + str = "%s" + else: + str = m.group(1) + str += ":".join(["%d"] * len(m.group(2))) + str += m.group(3) return str
@@ -142,11 +143,12 @@ def main(): else: regno = ri if len(b) == 1: - f.write(f", insn->regno[{regno}]") if "S" in a: f.write(f", sreg2str(insn->regno[{regno}])") elif "C" in a: f.write(f", creg2str(insn->regno[{regno}])") + else: + f.write(f", insn->regno[{regno}]") elif len(b) == 2: f.write(f", insn->regno[{regno}] + 1" f", insn->regno[{regno}]") else:
Signature · 1 line
2.34.1
[PULL 35/41] target/hexagon: add v68 HVX IEEE float compare insns
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
Add HVX IEEE floating-point compare instructions:
- V6_vgthf, V6_vgtsf: greater-than compare
- V6_vgthf_and, V6_vgtsf_and: greater-than with predicate-and
- V6_vgthf_or, V6_vgtsf_or: greater-than with predicate-or
- V6_vgthf_xor, V6_vgtsf_xor: greater-than with predicate-xor
--- target/hexagon/mmvec/hvx_ieee_fp.h | 4 ++ target/hexagon/mmvec/macros.h | 5 +- target/hexagon/mmvec/hvx_ieee_fp.c | 48 +++++++++++++++ target/hexagon/imported/mmvec/encode_ext.def | 10 ++++ target/hexagon/imported/mmvec/ext.idef | 61 ++++++++++++++++++++ 5 files changed, 127 insertions(+), 1 deletion(-)
target/hexagon/mmvec/hvx_ieee_fp.h +4 -0
@@ -25,4 +25,8 @@ float16 qf_min_hf(float16 a1, float16 a2, float_status *fp_status);int32_t conv_w_sf (float32 a,float_status *fp_status);int16_t conv_h_hf (float16 a,float_status *fp_status); +/* IEEE - FP compare instructions */ +uint32_t cmpgt_sf (float32 a1,float32 a2,float_status *fp_status); +uint16_t cmpgt_hf (float16 a1,float16 a2,float_status *fp_status); +#endif
target/hexagon/mmvec/macros.h +4 -1
@@ -354,6 +354,9 @@do { \COE = (sextract32 (VAL ,24 +2 *POS ,2 ) <<8 ) | \extract32 (VAL ,POS *8 ,8 ); \ - }while (0 ); + } while (0) + +#define fCMPGT_SF (A ,B ) cmpgt_sf(A, B, &env->hvx_fp_status) +#define fCMPGT_HF (A ,B ) cmpgt_hf(A, B, &env->hvx_fp_status)#endif
target/hexagon/mmvec/hvx_ieee_fp.c +48 -0
51 lines not on this page · raw message
target/hexagon/imported/mmvec/encode_ext.def +10 -0
@@ -858,4 +858,14 @@ DEF_ENC(V6_vconv_w_sf,"00011110--0--101PP1uuuuu001ddddd") DEF_ENC(V6_vconv_hf_h,"00011110--0--101PP1uuuuu100ddddd") DEF_ENC(V6_vconv_h_hf,"00011110--0--101PP1uuuuu010ddddd") +/* IEEE FP compare instructions */ +DEF_ENC(V6_vgtsf,"00011100100vvvvvPP1uuuuu011100dd") +DEF_ENC(V6_vgthf,"00011100100vvvvvPP1uuuuu011101dd") +DEF_ENC(V6_vgtsf_and,"00011100100vvvvvPP1uuuuu110010xx") +DEF_ENC(V6_vgthf_and,"00011100100vvvvvPP1uuuuu110011xx") +DEF_ENC(V6_vgtsf_or,"00011100100vvvvvPP1uuuuu001100xx") +DEF_ENC(V6_vgthf_or,"00011100100vvvvvPP1uuuuu001101xx") +DEF_ENC(V6_vgtsf_xor,"00011100100vvvvvPP1uuuuu111010xx") +DEF_ENC(V6_vgthf_xor,"00011100100vvvvvPP1uuuuu111011xx") + #endif /* NO MMVEC */
target/hexagon/imported/mmvec/ext.idef +61 -0
67 lines not on this page · raw message
Signature · 1 line
2.34.1
[PULL 36/41] target/hexagon: add v73 HVX IEEE bfloat16 insns
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
Add HVX IEEE bfloat16 (bf16) instructions:
Arithmetic operations:
- V6_vadd_sf_bf, V6_vsub_sf_bf: add/sub bf16 widening to sf output
- V6_vmpy_sf_bf: multiply bf16 widening to sf output
- V6_vmpy_sf_bf_acc: multiply-accumulate bf16 widening to sf output
Min/Max operations:
- V6_vmin_bf, V6_vmax_bf: bf16 min/max
Comparison operations:
- V6_vgtbf: greater-than compare
- V6_vgtbf_and, V6_vgtbf_or, V6_vgtbf_xor: predicate variants
Conversion operations:
- V6_vcvt_bf_sf: convert sf to bf16
--- target/hexagon/mmvec/hvx_ieee_fp.h | 37 ++++++++++++ target/hexagon/mmvec/macros.h | 4 ++ target/hexagon/mmvec/mmvec.h | 1 + target/hexagon/imported/mmvec/encode_ext.def | 15 +++++ target/hexagon/imported/mmvec/ext.idef | 62 ++++++++++++++++++++ 5 files changed, 119 insertions(+)
target/hexagon/mmvec/hvx_ieee_fp.h +37 -0
@@ -9,8 +9,11 @@#include "fpu/softfloat.h" +#define FP32_DEF_NAN 0x7FFFFFFF +#define f16_to_f32 (A ) float16_to_float32((A), true, &env->hvx_fp_status)#define f32_to_f16 (A ) float32_to_float16((A), true, &env->hvx_fp_status) +#define bf16_to_f32 (A ) bfloat16_to_float32(A, &env->hvx_fp_status)float32 fp_mult_sf_hf (float16 a1,float16 a2,float_status *fp_status); float32 fp_vdmpy(float16 a1, float16 a2, float16 a3, float16 a4,
@@ -29,4 +32,38 @@ int16_t conv_h_hf(float16 a, float_status *fp_status);uint32_t cmpgt_sf (float32 a1,float32 a2,float_status *fp_status);uint16_t cmpgt_hf (float16 a1,float16 a2,float_status *fp_status); +/* IEEE BFloat instructions */ + +#define fp_mult_sf_bf (A ,B ) \ + float32_mul(bf16_to_f32(A), bf16_to_f32(B), &env->hvx_fp_status) + +#define fp_add_sf_bf (A ,B ) \ + float32_add(bf16_to_f32(A), bf16_to_f32(B), &env->hvx_fp_status) + +#define fp_sub_sf_bf (A ,B ) \ + float32_sub(bf16_to_f32(A), bf16_to_f32(B), &env->hvx_fp_status) + +#define fp_mult_sf_bf_acc (f1, f2, f3) \ + float32_muladd(bf16_to_f32(f1), bf16_to_f32(f2), f3, 0, &env->hvx_fp_status) + +static inline bfloat16 f32_to_bf16 (float32 A ,float_status *fp_status) +{ +uint32_t rslt =A ; +if ((rslt &0x1FFFF ) ==0x08000 ) { +/* do not round up if exactly .5 and even already */ + }else if ((rslt &0x8000 ) ==0x8000 ) { + rslt +=0x8000 ;/* rounding to nearest number */ + } + rslt =float32_is_any_nan (A ) ?FP32_DEF_NAN : rslt; +return float32_to_bfloat16 (rslt, fp_status); +} + +#define fp_min_bf (A ,B ) \ + f32_to_bf16(float32_min(bf16_to_f32(A), bf16_to_f32(B), &env->hvx_fp_status), \ + &env->hvx_fp_status); + +#define fp_max_bf (A ,B ) \ + f32_to_bf16(float32_max(bf16_to_f32(A), bf16_to_f32(B), &env->hvx_fp_status), \ + &env->hvx_fp_status); +#endif
target/hexagon/mmvec/macros.h +4 -0
@@ -25,6 +25,9 @@#include "accel/tcg/probe.h" #include "mmvec/hvx_ieee_fp.h" +#define fBFLOAT () +#define fCVI_VX_NO_TMP_LD () +#ifndef QEMU_GENERATE #define VdV (*(MMVector *restrict)(VdV_void))#define VsV (*(MMVector *restrict)(VsV_void))
@@ -358,5 +361,6 @@#define fCMPGT_SF (A ,B ) cmpgt_sf(A, B, &env->hvx_fp_status)#define fCMPGT_HF (A ,B ) cmpgt_hf(A, B, &env->hvx_fp_status) +#define fCMPGT_BF (A ,B ) fCMPGT_SF((uint32_t)(A) << 16, (uint32_t)(B) << 16)#endif
target/hexagon/mmvec/mmvec.h +1 -0
@@ -43,6 +43,7 @@ typedef union {int8_t b[MAX_VEC_SIZE_BYTES /1 ];float32 sf[MAX_VEC_SIZE_BYTES /4 ];float16 hf[MAX_VEC_SIZE_BYTES /2 ]; +bfloat16 bf[MAX_VEC_SIZE_BYTES /2 ]; } MMVector; typedef union {
target/hexagon/imported/mmvec/encode_ext.def +15 -0
@@ -868,4 +868,19 @@ DEF_ENC(V6_vgthf_or,"00011100100vvvvvPP1uuuuu001101xx") DEF_ENC(V6_vgtsf_xor,"00011100100vvvvvPP1uuuuu111010xx") DEF_ENC(V6_vgthf_xor,"00011100100vvvvvPP1uuuuu111011xx") +/* BFLOAT instructions */ +DEF_ENC(V6_vmpy_sf_bf,"00011101010vvvvvPP1uuuuu100ddddd") +DEF_ENC(V6_vmpy_sf_bf_acc,"00011101000vvvvvPP1uuuuu000xxxxx") +DEF_ENC(V6_vadd_sf_bf,"00011101010vvvvvPP1uuuuu110ddddd") +DEF_ENC(V6_vsub_sf_bf,"00011101010vvvvvPP1uuuuu101ddddd") +DEF_ENC(V6_vmax_bf,"00011101010vvvvvPP1uuuuu111ddddd") +DEF_ENC(V6_vmin_bf,"00011101010vvvvvPP1uuuuu000ddddd") +DEF_ENC(V6_vcvt_bf_sf,"00011101010vvvvvPP1uuuuu011ddddd") + +/* BFLOAT compare instructions */ +DEF_ENC(V6_vgtbf,"00011100100vvvvvPP1uuuuu011110dd") +DEF_ENC(V6_vgtbf_and,"00011100100vvvvvPP1uuuuu110100xx") +DEF_ENC(V6_vgtbf_or,"00011100100vvvvvPP1uuuuu001110xx") +DEF_ENC(V6_vgtbf_xor,"00011100100vvvvvPP1uuuuu111100xx") + #endif /* NO MMVEC */
target/hexagon/imported/mmvec/ext.idef +62 -0
76 lines not on this page · raw message
Signature · 1 line
2.34.1
[PULL 02/41] hw/hexagon: move VTCM to the common machine state
In reply to Brian CainThe VTCM is described by the config table, so every machine can set it up the same way.
--- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/virt.h | 1 - hw/hexagon/hex-subsys.c | 8 ++++++++ hw/hexagon/virt.c | 5 ----- 4 files changed, 9 insertions(+), 6 deletions(-)
include/hw/hexagon/hexagon.h +1 -0
@@ -156,6 +156,7 @@ struct HexagonCommonMachineState {MemoryRegion ram;MemoryRegion cfgtable_rom; + MemoryRegion vtcm; };#endif
include/hw/hexagon/virt.h +0 -1
@@ -17,7 +17,6 @@ struct HexagonVirtMachineState {int fdt_size;MemoryRegion *sys;MemoryRegion tcm; -MemoryRegion vtcm;MemoryRegion bios;Clock *apb_clk; };
hw/hexagon/hex-subsys.c +8 -0
@@ -29,4 +29,12 @@ void hex_subsys_create(HexagonCommonMachineState *hms,rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable,sizeof (m_cfg->cfgtable), m_cfg->cfgbase, &address_space_memory); + +if (m_cfg->cfgtable.vtcm_size_kb >0 ) { +memory_region_init_ram (&hms->vtcm,NULL ,"vtcm.ram" , + m_cfg->cfgtable.vtcm_size_kb *1024 , + &error_fatal); +memory_region_add_subregion (sysmem, m_cfg->cfgtable.vtcm_base <<16 , + &hms->vtcm); + } }
hw/hexagon/virt.c +0 -5
@@ -75,11 +75,6 @@ static void fdt_add_hvx(HexagonVirtMachineState *vms,const MachineState *ms =MACHINE (vms);uint32_t vtcm_size_bytes = m_cfg->cfgtable.vtcm_size_kb *1024 ;if (vtcm_size_bytes >0 ) { -memory_region_init_ram (&vms->vtcm,NULL ,"vtcm.ram" , vtcm_size_bytes, - &error_fatal); -memory_region_add_subregion (vms->sys, m_cfg->cfgtable.vtcm_base <<16 , - &vms->vtcm); -qemu_fdt_add_subnode (ms->fdt,"/soc/vtcm" );qemu_fdt_setprop_string (ms->fdt,"/soc/vtcm" ,"compatible" ,"qcom,hexagon_vtcm" );
Signature · 1 line
2.34.1
[PULL 08/41] hw/hexagon: extract get_reg_value/set_reg_value stubs in globalreg
In reply to Brian CainRoute the globalreg read/write accessors through new get_reg_value()/set_reg_value() helpers instead of touching s->regs[reg] directly.
This will be exploited by a subsequent patch that redirects VID/VID1 accesses to the L2VIC.
--- hw/hexagon/hexagon_globalreg.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
hw/hexagon/hexagon_globalreg.c +18 -5
@@ -135,6 +135,17 @@ static inline uint32_t apply_write_mask(uint32_t new_val, uint32_t cur_val,return new_val; } +static uint32_t get_reg_value (HexagonGlobalRegState *s,uint32_t reg) +{ +return s->regs[reg]; +} + +static void set_reg_value (HexagonGlobalRegState *s,uint32_t reg, +uint32_t value) +{ + s->regs[reg] = value; +} +uint32_t hexagon_globalreg_read (HexagonGlobalRegState *s,uint32_t reg,uint32_t htid) {
@@ -146,7 +157,7 @@ uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg,g_assert (reg <NUM_SREGS );g_assert (reg >=HEX_SREG_GLB_START ); - value = s->regs[reg]; + value =get_reg_value (s, reg);trace_hexagon_globalreg_read (htid,get_sreg_name (reg), value);return value;
@@ -160,7 +171,7 @@ void hexagon_globalreg_write(HexagonGlobalRegState *s, uint32_t reg, }g_assert (reg <NUM_SREGS );g_assert (reg >=HEX_SREG_GLB_START ); - s->regs[reg] = value; +set_reg_value (s, reg, value);trace_hexagon_globalreg_write (htid,get_sreg_name (reg), value); }
@@ -168,6 +179,7 @@ uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s, uint32_t reg, uint32_t value) {uint32_t reg_mask; +uint32_t cur_val;if (!s) {return value;
@@ -175,9 +187,10 @@ uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s, uint32_t reg,g_assert (reg <NUM_SREGS );g_assert (reg >=HEX_SREG_GLB_START ); reg_mask = global_sreg_immut_masks[reg]; + cur_val =get_reg_value (s, reg);return reg_mask ==IMMUTABLE ? - s->regs[reg] : -apply_write_mask (value, s->regs[reg], reg_mask); + cur_val : +apply_write_mask (value, cur_val, reg_mask); } void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg,
@@ -186,7 +199,7 @@ void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg,if (!s) {return ; } - s->regs[reg] =hexagon_globalreg_masked_value (s, reg, value); +set_reg_value (s, reg,hexagon_globalreg_masked_value (s, reg, value)); }uint64_t hexagon_globalreg_get_pcycle_base (HexagonGlobalRegState *s)
Signature · 1 line
2.34.1
[PULL 09/41] hw/hexagon: connect l2vic device
In reply to Brian CainAdd the l2vic to the shared hex-subsys so both machine models pick it up. Map its register banks, wire the interrupt lines to CPU[0] and link each vCPU, globalregs.
--- include/hw/hexagon/hex-subsys.h | 5 ++-- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_globalreg.h | 4 +++ hw/hexagon/hex-subsys.c | 38 +++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 2 +- hw/hexagon/hexagon_globalreg.c | 25 +++++++++++++++++ hw/hexagon/virt.c | 2 +- 7 files changed, 72 insertions(+), 5 deletions(-)
include/hw/hexagon/hex-subsys.h +3 -2
@@ -18,7 +18,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms,/* * Parent a CPU into the subsystem's cluster and wire its links. Call for * every CPU before hex_subsys_realize_cluster(), then realize each CPU with -* hex_subsys_realize_cpu(). +* hex_subsys_realize_cpu(). CPU[0] receives the L2VIC outputs. */ void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu);
@@ -26,6 +26,7 @@ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu);void hex_subsys_realize_cluster (HexagonCommonMachineState *hms);/* Realize a CPU previously parented via hex_subsys_add_cpu(). */ -void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu); +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu, +bool boot_cpu);#endif /* HW_HEXAGON_HEX_SUBSYS_H */
include/hw/hexagon/hexagon.h +1 -0
@@ -158,6 +158,7 @@ struct HexagonCommonMachineState {MemoryRegion cfgtable_rom;MemoryRegion vtcm;DeviceState *cluster; +DeviceState *l2vic;DeviceState *glob_regs;DeviceState *tlb; };
include/hw/hexagon/hexagon_globalreg.h +4 -0
@@ -10,6 +10,7 @@#include "hw/core/qdev.h" #include "hw/core/sysbus.h" +#include "hw/intc/hex-l2vic.h" #include "qom/object.h" #include "target/hexagon/cpu.h"
@@ -22,6 +23,9 @@ struct HexagonGlobalRegState {/* Array of system registers */ uint32_t regs[NUM_SREGS ]; +/* L2VIC interface used to back the VID/VID1 registers */ +HexL2VicInterface *l2vic; +/* Global performance cycle counter base */ uint64_t g_pcycle_base;
hw/hexagon/hex-subsys.c +37 -1
@@ -10,6 +10,7 @@#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/intc/hex-l2vic.h" #include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h"
@@ -17,6 +18,31 @@#include "hw/core/sysbus.h" #include "system/address-spaces.h" +#define HEX_L2VIC_CPU_IRQS 8 + +static DeviceState *l2vic_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +DeviceState *l2vic =qdev_new (TYPE_HEX_L2VIC ); + +object_property_add_child (OBJECT (hms),"l2vic" ,OBJECT (l2vic)); +sysbus_realize_and_unref (SYS_BUS_DEVICE (l2vic), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (l2vic),0 , m_cfg->l2vic_base); +sysbus_mmio_map (SYS_BUS_DEVICE (l2vic),1 , + m_cfg->cfgtable.fastl2vic_base <<16 ); + +return l2vic; +} + +static void l2vic_connect_cpu (DeviceState *l2vic,DeviceState *cpu) +{ +int i; + +for (i =0 ; i <HEX_L2VIC_CPU_IRQS ; i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (l2vic), i,qdev_get_gpio_in (cpu, i)); + } +} +static DeviceState *globalreg_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev)
@@ -26,6 +52,8 @@ static DeviceState *globalreg_create(HexagonCommonMachineState *hms,object_property_add_child (OBJECT (hms),"global-regs" ,OBJECT (glob_regs));qdev_prop_set_uint64 (glob_regs,"config-table-addr" , m_cfg->cfgbase);qdev_prop_set_uint32 (glob_regs,"dsp-rev" , rev); +object_property_set_link (OBJECT (glob_regs),"l2vic" ,OBJECT (hms->l2vic), + &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs), &error_fatal);return glob_regs;
@@ -81,6 +109,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, } hms->cluster =cluster_create (hms); + hms->l2vic =l2vic_create (hms, m_cfg); hms->glob_regs =globalreg_create (hms, m_cfg, rev); hms->tlb =tlb_create (hms, m_cfg); }
@@ -92,6 +121,8 @@ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu) OBJECT(hms->glob_regs), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (hms->tlb), &error_fatal); +object_property_set_link (OBJECT (cpu),"l2vic" ,OBJECT (hms->l2vic), + &error_fatal); }void hex_subsys_realize_cluster (HexagonCommonMachineState *hms)
@@ -105,7 +136,12 @@ void hex_subsys_realize_cluster(HexagonCommonMachineState *hms)qdev_realize_and_unref (hms->cluster,NULL , &error_fatal); } -void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu, +bool boot_cpu) {qdev_realize_and_unref (cpu,NULL , &error_fatal); + +if (boot_cpu) { +l2vic_connect_cpu (hms->l2vic, cpu); + } }
hw/hexagon/hexagon_dsp.c +1 -1
@@ -139,7 +139,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,hex_subsys_realize_cluster (hms);for (int i =0 ; i < machine->smp.cpus; i++) { -hex_subsys_realize_cpu (hms,DEVICE (cpus[i])); +hex_subsys_realize_cpu (hms,DEVICE (cpus[i]), (i ==0 )); } }
hw/hexagon/hexagon_globalreg.c +25 -0
@@ -11,6 +11,7 @@#include "hw/core/qdev-properties.h" #include "hw/core/sysbus.h" #include "hw/core/resettable.h" +#include "hw/intc/hex-l2vic.h" #include "migration/vmstate.h" #include "qom/object.h" #include "target/hexagon/cpu.h"
@@ -135,8 +136,16 @@ static inline uint32_t apply_write_mask(uint32_t new_val, uint32_t cur_val,return new_val; } +static inline bool is_vid_reg (uint32_t reg) +{ +return reg ==HEX_SREG_VID || reg ==HEX_SREG_VID1 ; +} +static uint32_t get_reg_value (HexagonGlobalRegState *s,uint32_t reg) { +if (is_vid_reg (reg)) { +return l2vic_read_vid (s->l2vic, reg ==HEX_SREG_VID ?0 :1 ); + }return s->regs[reg]; }
@@ -144,6 +153,9 @@ static void set_reg_value(HexagonGlobalRegState *s, uint32_t reg, uint32_t value) { s->regs[reg] = value; +if (is_vid_reg (reg)) { +l2vic_update_vid (s->l2vic, reg ==HEX_SREG_VID ?0 :1 , value); + } } uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg,
@@ -269,6 +281,16 @@ static void hexagon_globalreg_reset_hold(Object *obj, ResetType type)do_hexagon_globalreg_reset (s); } +static void hexagon_globalreg_realize (DeviceState *dev,Error **errp) +{ +HexagonGlobalRegState *s =HEXAGON_GLOBALREG (dev); + +if (!s->l2vic) { +error_setg (errp,"hexagon_globalreg: 'l2vic' link property not set" ); +return ; + } +} +static const VMStateDescription vmstate_hexagon_globalreg = { .name ="hexagon_globalreg" , .version_id =1 ,
@@ -288,6 +310,8 @@ static const VMStateDescription vmstate_hexagon_globalreg = { };static const Property hexagon_globalreg_properties[] = { +DEFINE_PROP_LINK ("l2vic" , HexagonGlobalRegState, l2vic, + TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *),DEFINE_PROP_UINT32 ("boot-evb" , HexagonGlobalRegState, boot_evb,0x0 ),DEFINE_PROP_UINT64 ("config-table-addr" , HexagonGlobalRegState, config_table_addr,0xffffffffULL ),
@@ -308,6 +332,7 @@ static void hexagon_globalreg_class_init(ObjectClass *klass, const void *data)ResettableClass *rc =RESETTABLE_CLASS (klass); rc->phases.hold = hexagon_globalreg_reset_hold; + dc->realize = hexagon_globalreg_realize; dc->vmsd = &vmstate_hexagon_globalreg; dc->user_creatable = false;device_class_set_props (dc, hexagon_globalreg_properties);
hw/hexagon/virt.c +1 -1
@@ -270,7 +270,7 @@ static void virt_init(MachineState *ms)hex_subsys_realize_cluster (&vms->parent_obj);for (int i =0 ; i < ms->smp.cpus; i++) { -hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpus[i])); +hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpus[i]), (i ==0 )); }fdt_add_cpu_nodes (vms);
Signature · 1 line
2.34.1
[PULL 29/41] hexagon: group cpu configurations in their own struct
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
This will be used in a follow up commit.
--- target/hexagon/cpu.h | 10 +++------- target/hexagon/cpu_bits.h | 7 +++++++ target/hexagon/cpu.c | 14 +++++++------- target/hexagon/translate.c | 6 +++--- 4 files changed, 20 insertions(+), 17 deletions(-)
target/hexagon/cpu.h +3 -7
@@ -186,15 +186,13 @@ typedef struct HexagonCPUClass {const HexagonCPUDef *hex_def; } HexagonCPUClass; +#include "cpu_bits.h" +struct ArchCPU {CPUState parent_obj;CPUHexagonState env; - -bool lldb_compat; -target_ulong lldb_stack_adjust; -bool short_circuit; -bool ieee_fp_extension; +HexagonCPUConfig cfg;#ifndef CONFIG_USER_ONLY HexagonTLBState *tlb;uint32_t boot_addr;
@@ -204,8 +202,6 @@ struct ArchCPU {#endif }; -#include "cpu_bits.h" - FIELD(TB_FLAGS, IS_TIGHT_LOOP, 0, 1) FIELD(TB_FLAGS, MMU_INDEX, 1, 3)FIELD (TB_FLAGS ,PCYCLE_ENABLED ,4 ,1 )
target/hexagon/cpu_bits.h +7 -0
@@ -21,6 +21,13 @@#include "qemu/bitops.h" #include "cpu-qom.h" +typedef struct HexagonCPUConfig { +bool lldb_compat; +uint32_t lldb_stack_adjust; +bool short_circuit; +bool ieee_fp_extension; +}HexagonCPUConfig ; +#define PCALIGN 4#define PCALIGN_MASK (PCALIGN - 1)
target/hexagon/cpu.c +7 -7
@@ -71,11 +71,11 @@ static const Property hexagon_cpu_properties[] = { TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *), DEFINE_PROP_UINT32("htid", HexagonCPU, htid, 0), #endif - DEFINE_PROP_BOOL("lldb-compat", HexagonCPU, lldb_compat, false), - DEFINE_PROP_UNSIGNED("lldb-stack-adjust", HexagonCPU, lldb_stack_adjust, 0, - qdev_prop_uint32, target_ulong), - DEFINE_PROP_BOOL("short-circuit", HexagonCPU, short_circuit, true), - DEFINE_PROP_BOOL("ieee-fp", HexagonCPU, ieee_fp_extension, true), + DEFINE_PROP_BOOL("lldb-compat", HexagonCPU, cfg.lldb_compat, false), + DEFINE_PROP_UNSIGNED("lldb-stack-adjust", HexagonCPU, cfg.lldb_stack_adjust, + 0, qdev_prop_uint32, target_ulong), + DEFINE_PROP_BOOL("short-circuit", HexagonCPU, cfg.short_circuit, true), + DEFINE_PROP_BOOL("ieee-fp", HexagonCPU, cfg.ieee_fp_extension, true), }; const char * const hexagon_regnames[TOTAL_PER_THREAD_REGS] = {
@@ -127,7 +127,7 @@ const char * const hexagon_gregnames[] = {static target_ulong adjust_stack_ptrs (CPUHexagonState *env,target_ulong addr) {HexagonCPU *cpu =env_archcpu (env); -target_ulong stack_adjust = cpu->lldb_stack_adjust; +target_ulong stack_adjust = cpu->cfg.lldb_stack_adjust;target_ulong stack_start = env->stack_start;target_ulong stack_size =0x10000 ;
@@ -239,7 +239,7 @@ static void hexagon_dump(CPUHexagonState *env, FILE *f, int flags) {HexagonCPU *cpu =env_archcpu (env); -if (cpu->lldb_compat) { +if (cpu->cfg.lldb_compat) {/* * When comparing with LLDB, it doesn't step through single-cycle * hardware loops the same way. So, we just skip them here
target/hexagon/translate.c +3 -3
@@ -1209,9 +1209,9 @@ static void hexagon_tr_init_disas_context(DisasContextBase *dcbase, ctx->num_hvx_insns =0 ; ctx->branch_cond =TCG_COND_NEVER ; ctx->is_tight_loop =FIELD_EX32 (hex_flags,TB_FLAGS ,IS_TIGHT_LOOP ); - ctx->short_circuit = hex_cpu->short_circuit; + ctx->short_circuit = hex_cpu->cfg.short_circuit; ctx->hex_def =HEXAGON_CPU_GET_CLASS (hex_cpu)->hex_def; - ctx->ieee_fp_extension = hex_cpu->ieee_fp_extension; + ctx->ieee_fp_extension = hex_cpu->cfg.ieee_fp_extension;#ifndef CONFIG_USER_ONLY ctx->num_cycles =0 ; ctx->pcycle_enabled =FIELD_EX32 (hex_flags,TB_FLAGS ,PCYCLE_ENABLED );
@@ -1268,7 +1268,7 @@ static void hexagon_tr_translate_packet(DisasContextBase *dcbase, CPUState *cpu)* so end the TLB after every packet. */ HexagonCPU *hex_cpu =env_archcpu (env); -if (hex_cpu->lldb_compat &&qemu_loglevel_mask (CPU_LOG_TB_CPU )) { +if (hex_cpu->cfg.lldb_compat &&qemu_loglevel_mask (CPU_LOG_TB_CPU )) { ctx->base.is_jmp =DISAS_TOO_MANY ; } }
Signature · 1 line
2.34.1
[PULL 15/41] hw/timer: Add QCT QTimer device model
In reply to Brian CainImplement the QCT QTimer generic timer device used by Hexagon DSP systems.
--- MAINTAINERS | 2 + include/hw/timer/qct-qtimer.h | 43 +++ hw/timer/qct-qtimer.c | 667 ++++++++++++++++++++++++++++++++++ hw/timer/Kconfig | 3 + hw/timer/meson.build | 2 + hw/timer/trace-events | 5 + 6 files changed, 722 insertions(+) create mode 100644 include/hw/timer/qct-qtimer.h create mode 100644 hw/timer/qct-qtimer.c
MAINTAINERS +2 -0
@@ -253,6 +253,8 @@ F: target/hexagon/ F: hw/intc/hex-l2vic.c F: include/hw/intc/hex-l2vic.h F: tests/qtest/l2vic-test.c +F: hw/timer/qct-qtimer.c +F: include/hw/timer/qct-qtimer.h X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
include/hw/timer/qct-qtimer.h new file +43 -0
43 lines not on this page · raw message
hw/timer/qct-qtimer.c new file +667 -0
667 lines not on this page · raw message
hw/timer/Kconfig +3 -0
@@ -65,3 +65,6 @@ config STELLARIS_GPTM config AVR_TIMER16 bool + +config HEX_QTIMER + bool
hw/timer/meson.build +2 -0
@@ -34,3 +34,5 @@ specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_timer.c')) system_ss.add(when: 'CONFIG_SIFIVE_PWM', if_true: files('sifive_pwm.c')) system_ss.add(when: 'CONFIG_AVR_TIMER16', if_true: files('avr_timer16.c')) + +system_ss.add(when: 'CONFIG_HEX_QTIMER', if_true: files('qct-qtimer.c'))
hw/timer/trace-events +5 -0
@@ -128,3 +128,8 @@ imx_epit_get_freq(uint32_t freq) "ptimer frequency is %u" imx_epit_read(const char *name, uint32_t value) "(%s) = 0x%08x" imx_epit_write(const char *name, uint64_t value) "(%s, value = 0x%08" PRIx64 ")" imx_epit_cmp(uint32_t sr) "sr was %d" + +# qct-qtimer.c +qtimer_interrupt(void) "qtimer interrupt line updated" +qtimer_read(uint64_t offset) "offset 0x%" PRIx64 +qtimer_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value 0x%" PRIx64
Signature · 1 line
2.34.1
[PULL 16/41] hw/hexagon: connect qtimer device
In reply to Brian CainAdd the QTimer to the shared hex-subsys so both machine models pick it up. Map its view region, wire its interrupt lines into l2vic, and link it to the globalreg device backing HEX_SREG_TIMERLO/TIMERHI.
--- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_globalreg.h | 4 ++++ hw/hexagon/hex-subsys.c | 28 ++++++++++++++++++++++++++ hw/hexagon/hexagon_globalreg.c | 17 ++++++++++++++++ hw/hexagon/Kconfig | 1 + 5 files changed, 51 insertions(+)
include/hw/hexagon/hexagon.h +1 -0
@@ -159,6 +159,7 @@ struct HexagonCommonMachineState {MemoryRegion vtcm;DeviceState *cluster;DeviceState *l2vic; +DeviceState *qtimer;DeviceState *glob_regs;DeviceState *tlb; };
include/hw/hexagon/hexagon_globalreg.h +4 -0
@@ -11,6 +11,7 @@#include "hw/core/qdev.h" #include "hw/core/sysbus.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "qom/object.h" #include "target/hexagon/cpu.h"
@@ -26,6 +27,9 @@ struct HexagonGlobalRegState {/* L2VIC interface used to back the VID/VID1 registers */ HexL2VicInterface *l2vic; +/* QTimer interface used to back the TIMERLO/TIMERHI registers */ +QctQtimerInterface *qtimer; +/* Global performance cycle counter base */ uint64_t g_pcycle_base;
hw/hexagon/hex-subsys.c +28 -0
@@ -11,6 +11,7 @@#include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h"
@@ -20,6 +21,11 @@#define HEX_L2VIC_CPU_IRQS 8 +/* Number of QTimer frames instantiated for every Hexagon machine. */ +#define HEX_QTIMER_NR_FRAMES 3 + +#define HEX_QTIMER_L2VIC_IRQ_BASE 2 +static DeviceState *l2vic_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg) {
@@ -43,6 +49,25 @@ static void l2vic_connect_cpu(DeviceState *l2vic, DeviceState *cpu) } } +static DeviceState *qtimer_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +DeviceState *qtimer =qdev_new (TYPE_QCT_QTIMER ); + +object_property_add_child (OBJECT (hms),"qtimer" ,OBJECT (qtimer)); +qdev_prop_set_uint32 (qtimer,"nr_frames" ,HEX_QTIMER_NR_FRAMES ); +sysbus_realize_and_unref (SYS_BUS_DEVICE (qtimer), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (qtimer),0 , m_cfg->csr_base); +sysbus_mmio_map (SYS_BUS_DEVICE (qtimer),1 , m_cfg->qtmr_region); +for (unsigned int i =0 ; i <HEX_QTIMER_NR_FRAMES ; i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (qtimer), i, +qdev_get_gpio_in (hms->l2vic, +HEX_QTIMER_L2VIC_IRQ_BASE + i)); + } + +return qtimer; +} +static DeviceState *globalreg_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev)
@@ -54,6 +79,8 @@ static DeviceState *globalreg_create(HexagonCommonMachineState *hms,qdev_prop_set_uint32 (glob_regs,"dsp-rev" , rev);object_property_set_link (OBJECT (glob_regs),"l2vic" ,OBJECT (hms->l2vic), &error_fatal); +object_property_set_link (OBJECT (glob_regs),"qtimer" ,OBJECT (hms->qtimer), + &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs), &error_fatal);return glob_regs;
@@ -110,6 +137,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, hms->cluster =cluster_create (hms); hms->l2vic =l2vic_create (hms, m_cfg); + hms->qtimer =qtimer_create (hms, m_cfg); hms->glob_regs =globalreg_create (hms, m_cfg, rev); hms->tlb =tlb_create (hms, m_cfg); }
hw/hexagon/hexagon_globalreg.c +17 -0
@@ -12,6 +12,7 @@#include "hw/core/sysbus.h" #include "hw/core/resettable.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "migration/vmstate.h" #include "qom/object.h" #include "target/hexagon/cpu.h"
@@ -141,11 +142,21 @@ static inline bool is_vid_reg(uint32_t reg)return reg ==HEX_SREG_VID || reg ==HEX_SREG_VID1 ; } +static inline bool is_timer_reg (uint32_t reg) +{ +return reg ==HEX_SREG_TIMERLO || reg ==HEX_SREG_TIMERHI ; +} +static uint32_t get_reg_value (HexagonGlobalRegState *s,uint32_t reg) {if (is_vid_reg (reg)) {return l2vic_read_vid (s->l2vic, reg ==HEX_SREG_VID ?0 :1 ); } +if (is_timer_reg (reg)) { +return reg ==HEX_SREG_TIMERLO ? +qct_qtimer_get_timer_lo (s->qtimer) : +qct_qtimer_get_timer_hi (s->qtimer); + }return s->regs[reg]; }
@@ -289,6 +300,10 @@ static void hexagon_globalreg_realize(DeviceState *dev, Error **errp)error_setg (errp,"hexagon_globalreg: 'l2vic' link property not set" );return ; } +if (!s->qtimer) { +error_setg (errp,"hexagon_globalreg: 'qtimer' link property not set" ); +return ; + } }static const VMStateDescription vmstate_hexagon_globalreg = {
@@ -312,6 +327,8 @@ static const VMStateDescription vmstate_hexagon_globalreg = {static const Property hexagon_globalreg_properties[] = {DEFINE_PROP_LINK ("l2vic" , HexagonGlobalRegState, l2vic, TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *), +DEFINE_PROP_LINK ("qtimer" , HexagonGlobalRegState, qtimer, + TYPE_QCT_QTIMER_INTERFACE, QctQtimerInterface *),DEFINE_PROP_UINT32 ("boot-evb" , HexagonGlobalRegState, boot_evb,0x0 ),DEFINE_PROP_UINT64 ("config-table-addr" , HexagonGlobalRegState, config_table_addr,0xffffffffULL ),
hw/hexagon/Kconfig +1 -0
@@ -4,6 +4,7 @@ config HEX_DSP depends on HEXAGON select CPU_CLUSTER select HEX_L2VIC + select HEX_QTIMER config HEX_VIRT bool
Signature · 1 line
2.34.1
[PULL 11/41] hw/hexagon/virt: add l2vic interrupt-controller and virtio-mmio FDT nodes
In reply to Brian CainExpose l2vic as a device-tree interrupt-controller node and reference it via interrupt-parent, so guest kernels can discover the virtio-mmio transports.
--- hw/hexagon/virt.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-)
hw/hexagon/virt.c +41 -2
@@ -75,6 +75,30 @@ static void create_fdt(HexagonVirtMachineState *vms)qemu_fdt_setprop (fdt,"/chosen" ,"rng-seed" , rng_seed,sizeof (rng_seed)); } +static int32_t fdt_add_l2vic (HexagonVirtMachineState *vms, +const struct hexagon_machine_config *m_cfg) +{ +MachineState *ms =MACHINE (vms); +int32_t l2vic_phandle =qemu_fdt_alloc_phandle (ms->fdt); +char *nodename =g_strdup_printf ("/soc/interrupt-controller@%x" , + m_cfg->l2vic_base); +const char compat[] ="qcom,h2-pic\0hvm-pic" ; + +qemu_fdt_setprop_cell (ms->fdt,"/soc" ,"interrupt-parent" , l2vic_phandle); + +qemu_fdt_add_subnode (ms->fdt, nodename); +qemu_fdt_setprop_cell (ms->fdt, nodename,"#address-cells" ,0x0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"#interrupt-cells" ,0x1 ); +qemu_fdt_setprop (ms->fdt, nodename,"compatible" , compat,sizeof (compat)); +qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , + m_cfg->l2vic_base, m_cfg->l2vic_size); +qemu_fdt_setprop (ms->fdt, nodename,"interrupt-controller" ,NULL ,0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"phandle" , l2vic_phandle); + +g_free (nodename); +return l2vic_phandle; +} +static void fdt_add_hvx (HexagonVirtMachineState *vms,const struct hexagon_machine_config *m_cfg) {
@@ -175,13 +199,16 @@ static void fdt_add_cpu_nodes(const HexagonVirtMachineState *vms) } } -static void create_virtio_devices (HexagonVirtMachineState *vms) +static void create_virtio_devices (HexagonVirtMachineState *vms, +int32_t l2vic_phandle) { +MachineState *ms =MACHINE (vms);hwaddr size = base_memmap[VIRT_MMIO ].size;for (int i =0 ; i <VIRTIO_DEV_COUNT ; i++) {int irq =VIRTIO_IRQ_BASE + i;hwaddr base = base_memmap[VIRT_MMIO ].base + i * size; +char *nodename =g_strdup_printf ("/soc/virtio_mmio@%" PRIx64, base);DeviceState *dev =qdev_new ("virtio-mmio" );SysBusDevice *s =SYS_BUS_DEVICE (dev);
@@ -192,6 +219,16 @@ static void create_virtio_devices(HexagonVirtMachineState *vms)sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->parent_obj.l2vic, irq)); vms->virtio_mmio[i] = dev; + +qemu_fdt_add_subnode (ms->fdt, nodename); +qemu_fdt_setprop_string (ms->fdt, nodename,"compatible" , +"virtio,mmio" ); +qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , base, size); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupts" , irq); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + l2vic_phandle); + +g_free (nodename); } }
@@ -251,6 +288,7 @@ static void virt_init(MachineState *ms)HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms);const struct hexagon_machine_config *m_cfg = &v68n_1024;int32_t clk_phandle; +int32_t l2vic_phandle;create_fdt (vms);qemu_fdt_setprop_string (ms->fdt,"/chosen" ,"bootargs" , ms->kernel_cmdline);
@@ -272,7 +310,8 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); -create_virtio_devices (vms); + l2vic_phandle =fdt_add_l2vic (vms, m_cfg); +create_virtio_devices (vms, l2vic_phandle); g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, ms->smp.cpus);
Signature · 1 line
2.34.1
[PULL 14/41] tests/functional/hexagon: add arch_tests functional test
In reply to Brian CainAdd the test_int_steering case from hexagon-arch-tests.
--- tests/functional/hexagon/test_arch_tests.py | 6 ++++++ 1 file changed, 6 insertions(+)
tests/functional/hexagon/test_arch_tests.py +6 -0
@@ -52,6 +52,12 @@ def test_guest_mode(self) -> None: """ self.run_uart_test("test_guest_mode") + def test_int_steering(self) -> None: + """Tests interrupt steering via priority-based routing to + specific threads using STID priority and iassignw. + """ + self.run_uart_test("test_int_steering") + if __name__ == "__main__": QemuSystemTest.main()
Signature · 1 line
2.34.1
[PULL 31/41] target/hexagon: add v68 HVX IEEE float arithmetic insns
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
Add HVX IEEE floating-point arithmetic instructions:
- vmpy_sf_sf, vmpy_sf_hf, vmpy_hf_hf: multiply operations
- vdmpy_sf_hf: dot-product multiply
- vmpy_sf_hf_acc, vmpy_hf_hf_acc, vdmpy_sf_hf_acc: multiply-accumulate
- vadd_sf_sf, vsub_sf_sf, vadd_sf_hf, vsub_sf_hf: add/sub with sf output
- vadd_hf_hf, vsub_hf_hf: add/sub with hf output
--- target/hexagon/cpu.h | 1 + target/hexagon/mmvec/hvx_ieee_fp.h | 18 ++++ target/hexagon/mmvec/macros.h | 1 + target/hexagon/mmvec/mmvec.h | 2 + target/hexagon/attribs_def.h.inc | 4 + target/hexagon/arch.c | 8 ++ target/hexagon/cpu.c | 3 + target/hexagon/mmvec/hvx_ieee_fp.c | 21 ++++ target/hexagon/hex_common.py | 1 + target/hexagon/imported/mmvec/encode_ext.def | 18 ++++ target/hexagon/imported/mmvec/ext.idef | 101 +++++++++++++++++++ target/hexagon/meson.build | 1 + 12 files changed, 179 insertions(+) create mode 100644 target/hexagon/mmvec/hvx_ieee_fp.h create mode 100644 target/hexagon/mmvec/hvx_ieee_fp.c
target/hexagon/cpu.h +1 -0
@@ -152,6 +152,7 @@ typedef struct CPUArchState {MemLog mem_log_stores[STORES_MAX ];float_status fp_status; +float_status hvx_fp_status;target_ulong llsc_addr;target_ulong llsc_val;
target/hexagon/mmvec/hvx_ieee_fp.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_HVX_IEEE_H +#define HEXAGON_HVX_IEEE_H + +#include "fpu/softfloat.h" + +#define f16_to_f32 (A ) float16_to_float32((A), true, &env->hvx_fp_status) + +float32 fp_mult_sf_hf (float16 a1,float16 a2,float_status *fp_status); +float32 fp_vdmpy (float16 a1,float16 a2,float16 a3,float16 a4, +float_status *fp_status); + +#endif
target/hexagon/mmvec/macros.h +1 -0
@@ -23,6 +23,7 @@#include "mmvec/system_ext_mmvec.h" #include "accel/tcg/getpc.h" #include "accel/tcg/probe.h" +#include "mmvec/hvx_ieee_fp.h" #ifndef QEMU_GENERATE #define VdV (*(MMVector *restrict)(VdV_void))
target/hexagon/mmvec/mmvec.h +2 -0
@@ -41,6 +41,8 @@ typedef union {int16_t h[MAX_VEC_SIZE_BYTES /2 ];uint8_t ub[MAX_VEC_SIZE_BYTES /1 ];int8_t b[MAX_VEC_SIZE_BYTES /1 ]; +float32 sf[MAX_VEC_SIZE_BYTES /4 ]; +float16 hf[MAX_VEC_SIZE_BYTES /2 ]; } MMVector; typedef union {
target/hexagon/attribs_def.h.inc +4 -0
@@ -198,6 +198,10 @@ DEF_ATTRIB(RESTRICT_LATEPRED, "Predicate can not be used as a .new.", "", "") /* HVX IEEE FP extension attributes */ DEF_ATTRIB(HVX_IEEE_FP, "HVX IEEE FP extension instruction", "", "") +DEF_ATTRIB(HVX_IEEE_FP_ACC, "HVX IEEE FP accumulate instruction", "", "") +DEF_ATTRIB(HVX_IEEE_FP_OUT_16, "HVX IEEE FP 16-bit output", "", "") +DEF_ATTRIB(HVX_IEEE_FP_OUT_32, "HVX IEEE FP 32-bit output", "", "") +DEF_ATTRIB(CVI_VX_NO_TMP_LD, "HVX multiply without tmp load", "", "") /* Keep this as the last attribute: */ DEF_ATTRIB(ZZ_LASTATTRIB, "Last attribute in the file", "", "")
target/hexagon/arch.c +8 -0
@@ -199,6 +199,10 @@ void arch_fpop_start(CPUHexagonState *env)set_float_rounding_mode ( softfloat_roundingmodes[fREAD_REG_FIELD (USR ,USR_FPRND )], &env->fp_status); +/* +* No need to check env->hvx_fp_status, these instructions don't +* raise exceptions nor interact with usr fields. +*/ }#ifdef CONFIG_USER_ONLY
@@ -237,6 +241,10 @@ void arch_fpop_end(CPUHexagonState *env, bool pkt_need_commit)SOFTFLOAT_TEST_FLAG (float_flag_overflow,FPOVFF ,FPOVFE );SOFTFLOAT_TEST_FLAG (float_flag_underflow,FPUNFF ,FPUNFE ); } +/* +* No need to check env->hvx_fp_status, these instructions don't +* raise exceptions nor interact with usr fields. +*/ } int arch_sf_recip_common(float32 *Rs, float32 *Rt, float32 *Rd, int *adjust,
target/hexagon/cpu.c +3 -0
@@ -420,6 +420,9 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)set_float_detect_tininess (float_tininess_before_rounding, &env->fp_status);/* Default NaN value: sign bit set, all frac bits set */ set_float_default_nan_pattern (0b11111111 , &env->fp_status); + +set_default_nan_mode (1 , &env->hvx_fp_status); +set_float_default_nan_pattern (0b01111111 , &env->hvx_fp_status);#ifndef CONFIG_USER_ONLY memset (env->t_sreg,0 ,sizeof (uint32_t ) *NUM_SREGS );memset (env->greg,0 ,sizeof (uint32_t ) *NUM_GREGS );
target/hexagon/mmvec/hvx_ieee_fp.c new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hvx_ieee_fp.h" + +float32 fp_mult_sf_hf (float16 a1,float16 a2,float_status *fp_status) +{ +return float32_mul (float16_to_float32 (a1, true, fp_status), +float16_to_float32 (a2, true, fp_status), fp_status); +} + +float32 fp_vdmpy (float16 a1,float16 a2,float16 a3,float16 a4, +float_status *fp_status) +{ +return float32_add (fp_mult_sf_hf (a1, a3, fp_status), +fp_mult_sf_hf (a2, a4, fp_status), fp_status); +}
target/hexagon/hex_common.py +1 -0
@@ -253,6 +253,7 @@ def need_env(tag): "A_LOAD" in attribdict[tag] or "A_CVI_GATHER" in attribdict[tag] or "A_CVI_SCATTER" in attribdict[tag] or + "A_HVX_IEEE_FP" in attribdict[tag] or "A_IMPLICIT_WRITES_USR" in attribdict[tag] or "A_PRIV" in attribdict[tag] or "J2_trap" in tag)
target/hexagon/imported/mmvec/encode_ext.def +18 -0
@@ -804,5 +804,23 @@ DEF_ENC(V6_vmpyewuh, ICLASS_CJ" 1 111 111 vvvvv PP 0 uuuuu 101 ddddd") DEF_ENC(V6_vmpyowh, ICLASS_CJ" 1 111 111 vvvvv PP 0 uuuuu 111 ddddd") DEF_ENC(V6_vmpyuhvs,"00011111110vvvvvPP1uuuuu111ddddd") +/* IEEE FP multiply instructions */ +DEF_ENC(V6_vmpy_sf_sf,"00011111100vvvvvPP1uuuuu001ddddd") +DEF_ENC(V6_vmpy_sf_hf,"00011111100vvvvvPP1uuuuu010ddddd") +DEF_ENC(V6_vmpy_hf_hf,"00011111100vvvvvPP1uuuuu011ddddd") +DEF_ENC(V6_vdmpy_sf_hf,"00011111101vvvvvPP1uuuuu110ddddd") + +/* IEEE FP multiply-accumulate instructions */ +DEF_ENC(V6_vmpy_sf_hf_acc,"00011100010vvvvvPP1uuuuu001xxxxx") +DEF_ENC(V6_vmpy_hf_hf_acc,"00011100010vvvvvPP1uuuuu010xxxxx") +DEF_ENC(V6_vdmpy_sf_hf_acc,"00011100010vvvvvPP1uuuuu011xxxxx") + +/* IEEE FP add/sub instructions */ +DEF_ENC(V6_vadd_sf_sf,"00011111100vvvvvPP1uuuuu110ddddd") +DEF_ENC(V6_vsub_sf_sf,"00011111100vvvvvPP1uuuuu111ddddd") +DEF_ENC(V6_vadd_sf_hf,"00011111100vvvvvPP1uuuuu100ddddd") +DEF_ENC(V6_vsub_sf_hf,"00011111100vvvvvPP1uuuuu101ddddd") +DEF_ENC(V6_vadd_hf_hf,"00011111101vvvvvPP1uuuuu111ddddd") +DEF_ENC(V6_vsub_hf_hf,"00011111011vvvvvPP1uuuuu000ddddd") #endif /* NO MMVEC */
target/hexagon/imported/mmvec/ext.idef +101 -0
110 lines not on this page · raw message
target/hexagon/meson.build +1 -0
@@ -252,6 +252,7 @@ hexagon_ss.add(files( 'fma_emu.c', 'mmvec/decode_ext_mmvec.c', 'mmvec/system_ext_mmvec.c', + 'mmvec/hvx_ieee_fp.c', )) hexagon_softmmu_ss.add(files(
Signature · 1 line
2.34.1
[PULL 13/41] tests/qtest: add L2VIC qtest
In reply to Brian CainAdd a qtest exercising L2VIC register access and interrupt enable/disable.
--- MAINTAINERS | 1 + tests/qtest/l2vic-test.c | 249 +++++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 3 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/l2vic-test.c
MAINTAINERS +1 -0
@@ -252,6 +252,7 @@ S: Supported F: target/hexagon/ F: hw/intc/hex-l2vic.c F: include/hw/intc/hex-l2vic.h +F: tests/qtest/l2vic-test.c X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
tests/qtest/l2vic-test.c new file +249 -0
249 lines not on this page · raw message
tests/qtest/meson.build +1 -1
@@ -299,7 +299,7 @@ qtests_riscv64 = ['riscv-csr-test'] + \ ['iommu-riscv-test'] : []) + \ (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) -qtests_hexagon = ['boot-serial-test'] +qtests_hexagon = ['boot-serial-test', 'l2vic-test'] qos_test_ss = ss.source_set() qos_test_ss.add(
Signature · 1 line
2.34.1
[PULL 12/41] hw/hexagon/virt: connect pl011 UART interrupt
In reply to Brian CainWire pl011's sysbus IRQ into l2vic at IRQ 15.
--- hw/hexagon/virt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
hw/hexagon/virt.c +8 -2
@@ -39,6 +39,7 @@ enum {* VIRTIO_IRQ_BASE + VIRTIO_DEV_COUNT - 1 */ static const int VIRTIO_IRQ_BASE =16 ; +static const int VIRT_UART0_IRQ =15 ;static const MemMapEntry base_memmap[] = { [VIRT_UART0 ] = {0x10000000 ,0x00000200 },
@@ -143,7 +144,7 @@ static int32_t fdt_add_clocks(const HexagonVirtMachineState *vms) }static void fdt_add_uart (const HexagonVirtMachineState *vms,int uart, -int32_t clk_phandle) +int32_t clk_phandle,int32_t l2vic_phandle) {char *nodename;hwaddr base = base_memmap[uart].base;
@@ -161,6 +162,8 @@ static void fdt_add_uart(const HexagonVirtMachineState *vms, int uart,qdev_connect_clock_in (dev,"clk" , vms->apb_clk);sysbus_realize_and_unref (s, &error_fatal);sysbus_mmio_map (s,0 , base); +sysbus_connect_irq (s,0 , +qdev_get_gpio_in (vms->parent_obj.l2vic,VIRT_UART0_IRQ )); nodename =g_strdup_printf ("/pl011@%" PRIx64, base);qemu_fdt_add_subnode (ms->fdt, nodename);
@@ -168,6 +171,9 @@ static void fdt_add_uart(const HexagonVirtMachineState *vms, int uart,/* Note that we can't use setprop_string because of the embedded NUL */ qemu_fdt_setprop (ms->fdt, nodename,"compatible" , compat,sizeof (compat));qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , base, size); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupts" ,VIRT_UART0_IRQ ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + l2vic_phandle);qemu_fdt_setprop_cells (ms->fdt, nodename,"clocks" , clk_phandle, clk_phandle); qemu_fdt_setprop(ms->fdt, nodename, "clock-names", clocknames,
@@ -342,7 +348,7 @@ static void virt_init(MachineState *ms)fdt_add_cpu_nodes (vms); clk_phandle =fdt_add_clocks (vms); -fdt_add_uart (vms,VIRT_UART0 , clk_phandle); +fdt_add_uart (vms,VIRT_UART0 , clk_phandle, l2vic_phandle);hexagon_load_fdt (vms); }
Signature · 1 line
2.34.1
[PULL 22/41] target/hexagon: add GVec overrides for HVX absolute difference
In reply to Brian Cain--- target/hexagon/gen_tcg_hvx.h | 16 +++++++++ target/hexagon/genptr.h | 4 +++ target/hexagon/helper.h | 5 +++ target/hexagon/genptr.c | 70 ++++++++++++++++++++++++++++++++++++ target/hexagon/op_helper.c | 21 +++++++++++ 5 files changed, 116 insertions(+)
target/hexagon/gen_tcg_hvx.h +16 -0
@@ -326,6 +326,22 @@ static inline void assert_vhist_tmp(DisasContext *ctx)tcg_gen_gvec_mul (MO_16 , VdV_off, VuV_off, VvV_off, \ VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) +#define fGEN_TCG_V6_vabsdiffub (SHORTCODE ) \ + gen_gvec_uabsdiff(MO_8, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vabsdiffuh (SHORTCODE ) \ + gen_gvec_uabsdiff(MO_16, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vabsdiffh (SHORTCODE ) \ + gen_gvec_sabsdiff(MO_16, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + +#define fGEN_TCG_V6_vabsdiffw (SHORTCODE ) \ + gen_gvec_sabsdiff(MO_32, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) +/* Vector shift right - various forms */ #define fGEN_TCG_V6_vasrh (SHORTCODE ) \ do { \
target/hexagon/genptr.h +4 -0
@@ -59,6 +59,10 @@ TCGv gen_get_half(TCGv result, int N, TCGv src, bool sign);void gen_set_half (int N ,TCGv result,TCGv src);void gen_set_half_i64 (int N ,TCGv_i64 result,TCGv src);void probe_noshuf_load (TCGv va,int s,int mi); +void gen_gvec_sabsdiff (unsigned vece,uint32_t dofs,uint32_t aofs, +uint32_t bofs,uint32_t oprsz,uint32_t maxsz); +void gen_gvec_uabsdiff (unsigned vece,uint32_t dofs,uint32_t aofs, +uint32_t bofs,uint32_t oprsz,uint32_t maxsz);extern const target_ulong reg_immut_masks[TOTAL_PER_THREAD_REGS ];
target/hexagon/helper.h +5 -0
@@ -108,6 +108,11 @@ DEF_HELPER_2(probe_pkt_scalar_store_s0, void, env, int) DEF_HELPER_2(probe_hvx_stores, void, env, int) DEF_HELPER_2(probe_pkt_scalar_hvx_stores, void, env, int) +DEF_HELPER_FLAGS_4(gvec_sabsdiff_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_sabsdiff_w, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_uabsdiff_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_uabsdiff_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +#if !defined(CONFIG_USER_ONLY ) DEF_HELPER_3(raise_stack_overflow, void, env, i32, i32)DEF_HELPER_2 (swi, void, env, i32)
target/hexagon/genptr.c +70 -0
76 lines not on this page · raw message
target/hexagon/op_helper.c +21 -0
@@ -35,6 +35,7 @@#include "mmvec/macros.h" #include "op_helper.h" #include "cpu_helper.h" +#include "tcg/tcg-gvec-desc.h" #include "translate.h" #ifndef CONFIG_USER_ONLY #include "hw/hexagon/hexagon_globalreg.h"
@@ -1961,3 +1962,23 @@ void HELPER(pending_interrupt)(CPUHexagonState *env) printf("ERROR: bogus helper: " #tag "\n")#include "helper_funcs_generated.c.inc" + +#define DO_ABSDIFF (NAME ,TYPE ,UTYPE ) \ +void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \ +{ \ + intptr_t i, oprsz = simd_oprsz(desc); \ + UTYPE *d = vd; \ + TYPE *n = vn, *m = vm; \ + \ + for (i = 0; i < oprsz / sizeof(TYPE); i++) { \ + d[i] = n[i] < m[i] ? (UTYPE)m[i] - (UTYPE)n[i] \ + : (UTYPE)n[i] - (UTYPE)m[i]; \ + } \ +} + +DO_ABSDIFF(gvec_sabsdiff_h, int16_t, uint16_t) +DO_ABSDIFF(gvec_sabsdiff_w, int32_t, uint32_t) +DO_ABSDIFF(gvec_uabsdiff_b, uint8_t, uint8_t) +DO_ABSDIFF(gvec_uabsdiff_h, uint16_t, uint16_t) + +#undef DO_ABSDIFF
Signature · 1 line
2.34.1
[PULL 05/41] hw/hexagon: group the CPUs in a cluster
In reply to Brian CainThe CPUs are now grouped in a TYPE_CPU_CLUSTER.
--- include/hw/hexagon/hex-subsys.h | 12 +++++++++++- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 30 +++++++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 11 ++++++++++- hw/hexagon/virt.c | 11 ++++++++++- hw/hexagon/Kconfig | 1 + 6 files changed, 62 insertions(+), 4 deletions(-)
include/hw/hexagon/hex-subsys.h +11 -1
@@ -15,7 +15,17 @@void hex_subsys_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev); -/* Realize a CPU into the subsystem. */ +/* +* Parent a CPU into the subsystem's cluster and wire its links. Call for +* every CPU before hex_subsys_realize_cluster(), then realize each CPU with +* hex_subsys_realize_cpu(). +*/ +void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu); + +/* Realize the CPU cluster, once all CPUs have been parented into it. */ +void hex_subsys_realize_cluster (HexagonCommonMachineState *hms); + +/* Realize a CPU previously parented via hex_subsys_add_cpu(). */ void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu);#endif /* HW_HEXAGON_HEX_SUBSYS_H */
include/hw/hexagon/hexagon.h +1 -0
@@ -157,6 +157,7 @@ struct HexagonCommonMachineState {MemoryRegion ram;MemoryRegion cfgtable_rom;MemoryRegion vtcm; +DeviceState *cluster;DeviceState *glob_regs;DeviceState *tlb; };
hw/hexagon/hex-subsys.c +29 -1
@@ -10,6 +10,7 @@#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev.h"
@@ -42,6 +43,16 @@ static DeviceState *tlb_create(HexagonCommonMachineState *hms,return tlb; } +static DeviceState *cluster_create (HexagonCommonMachineState *hms) +{ +DeviceState *cluster =qdev_new (TYPE_CPU_CLUSTER ); + +object_property_add_child (OBJECT (hms),"cluster" ,OBJECT (cluster)); +qdev_prop_set_uint32 (cluster,"cluster-id" ,0 ); + +return cluster; +} +void hex_subsys_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev) {
@@ -69,15 +80,32 @@ void hex_subsys_create(HexagonCommonMachineState *hms, &hms->vtcm); } + hms->cluster =cluster_create (hms); hms->glob_regs =globalreg_create (hms, m_cfg, rev); hms->tlb =tlb_create (hms, m_cfg); } -void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) +void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) { +object_property_add_child (OBJECT (hms->cluster),"cpu[*]" ,OBJECT (cpu));object_property_set_link (OBJECT (cpu),"global-regs" ,OBJECT (hms->glob_regs), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (hms->tlb), &error_fatal); +} + +void hex_subsys_realize_cluster (HexagonCommonMachineState *hms) +{ +/* +* The cluster must be realized after its CPUs have been parented into it +* (see hex_subsys_add_cpu()) but before any CPU is itself realized, since +* qdev_realize_and_unref() on a CPU latches cluster_index into the TCG +* cflags at that point. +*/ +qdev_realize_and_unref (hms->cluster,NULL , &error_fatal); +} + +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) +{qdev_realize_and_unref (cpu,NULL , &error_fatal); }
hw/hexagon/hexagon_dsp.c +10 -1
@@ -118,6 +118,8 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,hex_subsys_create (hms, m_cfg, rev); + g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, machine->smp.cpus); +for (int i =0 ; i < machine->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (machine->cpu_type));qemu_register_reset (do_cpu_reset, cpu);
@@ -130,7 +132,14 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,if (i ==0 ) {hexagon_init_bootstrap (dms, cpu); } -hex_subsys_realize_cpu (hms,DEVICE (cpu)); +hex_subsys_add_cpu (hms,DEVICE (cpu)); + cpus[i] = cpu; + } + +hex_subsys_realize_cluster (hms); + +for (int i =0 ; i < machine->smp.cpus; i++) { +hex_subsys_realize_cpu (hms,DEVICE (cpus[i])); } }
hw/hexagon/virt.c +10 -1
@@ -246,6 +246,8 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); + g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, ms->smp.cpus); +for (int i =0 ; i < ms->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);
@@ -261,7 +263,14 @@ static void virt_init(MachineState *ms) }qdev_prop_set_uint32 (DEVICE (cpu),"htid" , i);qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 )); -hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpu)); +hex_subsys_add_cpu (&vms->parent_obj,DEVICE (cpu)); + cpus[i] = cpu; + } + +hex_subsys_realize_cluster (&vms->parent_obj); + +for (int i =0 ; i < ms->smp.cpus; i++) { +hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpus[i])); }fdt_add_cpu_nodes (vms);
hw/hexagon/Kconfig +1 -0
@@ -2,6 +2,7 @@ config HEX_DSP bool default y depends on HEXAGON + select CPU_CLUSTER config HEX_VIRT bool
Signature · 1 line
2.34.1
[PULL 23/41] target/hexagon: add GVec overrides for HVX vector average
In reply to Brian Cain--- target/hexagon/gen_tcg_hvx.h | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
target/hexagon/gen_tcg_hvx.h +62 -0
@@ -342,6 +342,68 @@ static inline void assert_vhist_tmp(DisasContext *ctx)gen_gvec_sabsdiff (MO_32 , VdV_off, VuV_off, VvV_off, \ VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) +#define fGEN_TCG_VEC_AVG (VECE ,SHIFT_FN ) \ + do { \ + intptr_t tmpoff = offsetof(CPUHexagonState, vtmp); \ + tcg_gen_gvec_and(MO_64, tmpoff, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + tcg_gen_gvec_xor(MO_64, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + SHIFT_FN(VECE, VdV_off, VdV_off, 1, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + tcg_gen_gvec_add(VECE, VdV_off, tmpoff, VdV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + } while (0) + +#define fGEN_TCG_V6_vavgub (SHORTCODE ) \ + fGEN_TCG_VEC_AVG(MO_8, tcg_gen_gvec_shri) + +#define fGEN_TCG_V6_vavguh (SHORTCODE ) \ + fGEN_TCG_VEC_AVG(MO_16, tcg_gen_gvec_shri) + +#define fGEN_TCG_V6_vavguw (SHORTCODE ) \ + fGEN_TCG_VEC_AVG(MO_32, tcg_gen_gvec_shri) + +#define fGEN_TCG_V6_vavgb (SHORTCODE ) \ + fGEN_TCG_VEC_AVG(MO_8, tcg_gen_gvec_sari) + +#define fGEN_TCG_V6_vavgh (SHORTCODE ) \ + fGEN_TCG_VEC_AVG(MO_16, tcg_gen_gvec_sari) + +#define fGEN_TCG_V6_vavgw (SHORTCODE ) \ + fGEN_TCG_VEC_AVG(MO_32, tcg_gen_gvec_sari) + +#define fGEN_TCG_VEC_AVGRND (VECE ,SHIFT_FN ) \ + do { \ + intptr_t tmpoff = offsetof(CPUHexagonState, vtmp); \ + tcg_gen_gvec_or(MO_64, tmpoff, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + tcg_gen_gvec_xor(MO_64, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + SHIFT_FN(VECE, VdV_off, VdV_off, 1, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + tcg_gen_gvec_sub(VECE, VdV_off, tmpoff, VdV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + } while (0) + +#define fGEN_TCG_V6_vavgubrnd (SHORTCODE ) \ + fGEN_TCG_VEC_AVGRND(MO_8, tcg_gen_gvec_shri) + +#define fGEN_TCG_V6_vavguhrnd (SHORTCODE ) \ + fGEN_TCG_VEC_AVGRND(MO_16, tcg_gen_gvec_shri) + +#define fGEN_TCG_V6_vavguwrnd (SHORTCODE ) \ + fGEN_TCG_VEC_AVGRND(MO_32, tcg_gen_gvec_shri) + +#define fGEN_TCG_V6_vavgbrnd (SHORTCODE ) \ + fGEN_TCG_VEC_AVGRND(MO_8, tcg_gen_gvec_sari) + +#define fGEN_TCG_V6_vavghrnd (SHORTCODE ) \ + fGEN_TCG_VEC_AVGRND(MO_16, tcg_gen_gvec_sari) + +#define fGEN_TCG_V6_vavgwrnd (SHORTCODE ) \ + fGEN_TCG_VEC_AVGRND(MO_32, tcg_gen_gvec_sari) +/* Vector shift right - various forms */ #define fGEN_TCG_V6_vasrh (SHORTCODE ) \ do { \
Signature · 1 line
2.34.1
[PULL 32/41] target/hexagon: add v68 HVX IEEE float min/max insns
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
Add HVX IEEE floating-point min/max instructions:
- vfmin_hf, vfmin_sf: IEEE floating-point minimum
- vfmax_hf, vfmax_sf: IEEE floating-point maximum
- vmax_hf, vmax_sf: qfloat IEEE maximum
- vmin_hf, vmin_sf: qfloat IEEE minimum
The Hexagon qfloat variants are similar to the IEEE-754 ones, but they handle NaN slightly differently. See comment on hvx_ieee_fp.h
--- target/hexagon/mmvec/hvx_ieee_fp.h | 6 +++ target/hexagon/attribs_def.h.inc | 2 + target/hexagon/mmvec/hvx_ieee_fp.c | 50 ++++++++++++++++++++ target/hexagon/hex_common.py | 1 + target/hexagon/imported/mmvec/encode_ext.def | 10 ++++ target/hexagon/imported/mmvec/ext.idef | 36 +++++++++++++- 6 files changed, 104 insertions(+), 1 deletion(-)
target/hexagon/mmvec/hvx_ieee_fp.h +6 -0
@@ -15,4 +15,10 @@ float32 fp_mult_sf_hf(float16 a1, float16 a2, float_status *fp_status);float32 fp_vdmpy (float16 a1,float16 a2,float16 a3,float16 a4,float_status *fp_status); +/* Qfloat min/max treat +NaN as greater than +INF and -NaN as smaller than -INF */ +float32 qf_max_sf (float32 a1,float32 a2,float_status *fp_status); +float32 qf_min_sf (float32 a1,float32 a2,float_status *fp_status); +float16 qf_max_hf (float16 a1,float16 a2,float_status *fp_status); +float16 qf_min_hf (float16 a1,float16 a2,float_status *fp_status); +#endif
target/hexagon/attribs_def.h.inc +2 -0
@@ -84,6 +84,7 @@ DEF_ATTRIB(CVI_SCATTER, "CVI Scatter operation", "", "") DEF_ATTRIB(CVI_SCATTER_RELEASE, "CVI Store Release for scatter", "", "") DEF_ATTRIB(CVI_TMP_DST, "CVI instruction that doesn't write a register", "", "") DEF_ATTRIB(CVI_SLOT23, "Can execute in slot 2 or slot 3 (HVX)", "", "") +DEF_ATTRIB(CVI_VA_2SRC, "Execs on multimedia vector engine; requires two srcs", "", "") DEF_ATTRIB(VTCM_ALLBANK_ACCESS, "Allocates in all VTCM schedulers.", "", "")
@@ -202,6 +203,7 @@ DEF_ATTRIB(HVX_IEEE_FP_ACC, "HVX IEEE FP accumulate instruction", "", "") DEF_ATTRIB(HVX_IEEE_FP_OUT_16, "HVX IEEE FP 16-bit output", "", "") DEF_ATTRIB(HVX_IEEE_FP_OUT_32, "HVX IEEE FP 32-bit output", "", "") DEF_ATTRIB(CVI_VX_NO_TMP_LD, "HVX multiply without tmp load", "", "") +DEF_ATTRIB(HVX_FLT, "This a floating point HVX instruction.", "", "") /* Keep this as the last attribute: */ DEF_ATTRIB(ZZ_LASTATTRIB, "Last attribute in the file", "", "")
target/hexagon/mmvec/hvx_ieee_fp.c +50 -0
53 lines not on this page · raw message
target/hexagon/hex_common.py +1 -0
@@ -254,6 +254,7 @@ def need_env(tag): "A_CVI_GATHER" in attribdict[tag] or "A_CVI_SCATTER" in attribdict[tag] or "A_HVX_IEEE_FP" in attribdict[tag] or + "A_HVX_FLT" in attribdict[tag] or "A_IMPLICIT_WRITES_USR" in attribdict[tag] or "A_PRIV" in attribdict[tag] or "J2_trap" in tag)
target/hexagon/imported/mmvec/encode_ext.def +10 -0
@@ -823,4 +823,14 @@ DEF_ENC(V6_vsub_sf_hf,"00011111100vvvvvPP1uuuuu101ddddd") DEF_ENC(V6_vadd_hf_hf,"00011111101vvvvvPP1uuuuu111ddddd") DEF_ENC(V6_vsub_hf_hf,"00011111011vvvvvPP1uuuuu000ddddd") +/* IEEE FP min/max instructions */ +DEF_ENC(V6_vfmin_hf,"00011100011vvvvvPP1uuuuu000ddddd") +DEF_ENC(V6_vfmin_sf,"00011100011vvvvvPP1uuuuu001ddddd") +DEF_ENC(V6_vfmax_hf,"00011100011vvvvvPP1uuuuu010ddddd") +DEF_ENC(V6_vfmax_sf,"00011100011vvvvvPP1uuuuu011ddddd") +DEF_ENC(V6_vmax_sf,"00011111110vvvvvPP1uuuuu001ddddd") +DEF_ENC(V6_vmin_sf,"00011111110vvvvvPP1uuuuu010ddddd") +DEF_ENC(V6_vmax_hf,"00011111110vvvvvPP1uuuuu011ddddd") +DEF_ENC(V6_vmin_hf,"00011111110vvvvvPP1uuuuu100ddddd") + #endif /* NO MMVEC */
target/hexagon/imported/mmvec/ext.idef +35 -1
@@ -43,7 +43,9 @@ EXTINSN(V6_##TAG, SYNTAX, ATTRIBS(A_EXTENSION,A_CVI,A_CVI_VA), \ DESCR, DO_FOR_EACH_CODE(WIDTH, CODE)) - +#define ITERATOR_INSN_ANY_SLOT_2SRC(WIDTH,TAG,SYNTAX,DESCR,CODE) \ +EXTINSN(V6_##TAG, SYNTAX, ATTRIBS(A_EXTENSION,A_CVI,A_CVI_VA,A_CVI_VA_2SRC,A_HVX_FLT), \ +DESCR, DO_FOR_EACH_CODE(WIDTH, CODE)) #define ITERATOR_INSN2_ANY_SLOT(WIDTH,TAG,SYNTAX,SYNTAX2,DESCR,CODE) \ ITERATOR_INSN_ANY_SLOT(WIDTH,TAG,SYNTAX2,DESCR,CODE)
@@ -3000,6 +3002,38 @@ ITERATOR_INSN_IEEE_FP_DOUBLE_32(32, vsub_sf_hf, VddV.v[1].sf[i] = float32_sub(f16_to_f32(VuV.hf[2*i+1]), f16_to_f32(VvV.hf[2*i+1]), &env->hvx_fp_status)) +#define ITERATOR_INSN_IEEE_FP_16_32_LATE(WIDTH,TAG,SYNTAX,DESCR,CODE) \ +EXTINSN(V6_##TAG, SYNTAX, \ + ATTRIBS(A_EXTENSION,A_HVX_IEEE_FP,A_CVI,A_CVI_VX,A_HVX_IEEE_FP_OUT_16,A_HVX_IEEE_FP_OUT_32), \ + DESCR, DO_FOR_EACH_CODE(WIDTH, CODE)) + +/* IEEE FP min/max instructions */ +ITERATOR_INSN_IEEE_FP_16_32_LATE(16, vfmin_hf, "Vd32.hf=vfmin(Vu32.hf,Vv32.hf)", \ + "Vector IEEE min: hf", VdV.hf[i] = float16_min(VuV.hf[i], VvV.hf[i], \ + &env->hvx_fp_status)) +ITERATOR_INSN_IEEE_FP_16_32_LATE(32, vfmin_sf, "Vd32.sf=vfmin(Vu32.sf,Vv32.sf)", \ + "Vector IEEE min: sf", VdV.sf[i] = float32_min(VuV.sf[i], VvV.sf[i], \ + &env->hvx_fp_status)) +ITERATOR_INSN_IEEE_FP_16_32_LATE(16, vfmax_hf, "Vd32.hf=vfmax(Vu32.hf,Vv32.hf)", \ + "Vector IEEE max: hf", VdV.hf[i] = float16_max(VuV.hf[i], VvV.hf[i], \ + &env->hvx_fp_status)) +ITERATOR_INSN_IEEE_FP_16_32_LATE(32, vfmax_sf, "Vd32.sf=vfmax(Vu32.sf,Vv32.sf)", \ + "Vector IEEE max: sf", VdV.sf[i] = float32_max(VuV.sf[i], VvV.sf[i], \ + &env->hvx_fp_status)) + +ITERATOR_INSN_ANY_SLOT_2SRC(32,vmax_sf,"Vd32.sf=vmax(Vu32.sf,Vv32.sf)", \ + "Vector max of sf input", VdV.sf[i] = qf_max_sf(VuV.sf[i], VvV.sf[i], \ + &env->hvx_fp_status)) +ITERATOR_INSN_ANY_SLOT_2SRC(32,vmin_sf,"Vd32.sf=vmin(Vu32.sf,Vv32.sf)", \ + "Vector min of sf input", VdV.sf[i] = qf_min_sf(VuV.sf[i], VvV.sf[i], \ + &env->hvx_fp_status)) +ITERATOR_INSN_ANY_SLOT_2SRC(16,vmax_hf,"Vd32.hf=vmax(Vu32.hf,Vv32.hf)", \ + "Vector max of hf input", VdV.hf[i] = qf_max_hf(VuV.hf[i], VvV.hf[i], \ + &env->hvx_fp_status)) +ITERATOR_INSN_ANY_SLOT_2SRC(16,vmin_hf,"Vd32.hf=vmin(Vu32.hf,Vv32.hf)", \ + "Vector min of hf input", VdV.hf[i] = qf_min_hf(VuV.hf[i], VvV.hf[i], \ + &env->hvx_fp_status)) + /****************************************************************************** DEBUG Vector/Register Printing ******************************************************************************/
Signature · 1 line
2.34.1
[PULL 03/41] hw/hexagon: move global registers to hex-subsys
In reply to Brian CainBoth machines create the global register device the same way, so let hex-subsys own it and link it to each CPU as it is realized.
--- include/hw/hexagon/hex-subsys.h | 6 +++++- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 29 ++++++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 15 ++------------- hw/hexagon/virt.c | 23 +++++------------------ 5 files changed, 41 insertions(+), 33 deletions(-)
include/hw/hexagon/hex-subsys.h +5 -1
@@ -9,9 +9,13 @@#define HW_HEXAGON_HEX_SUBSYS_H #include "hw/hexagon/hexagon.h" +#include "hw/core/qdev.h" /* Create the subsystem shared by every Hexagon machine. */ void hex_subsys_create (HexagonCommonMachineState *hms, -const struct hexagon_machine_config *m_cfg); +const struct hexagon_machine_config *m_cfg,Rev_t rev); + +/* Realize a CPU into the subsystem. */ +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu);#endif /* HW_HEXAGON_HEX_SUBSYS_H */
include/hw/hexagon/hexagon.h +1 -0
@@ -157,6 +157,7 @@ struct HexagonCommonMachineState {MemoryRegion ram;MemoryRegion cfgtable_rom;MemoryRegion vtcm; + DeviceState *glob_regs; };#endif
hw/hexagon/hex-subsys.c +28 -1
@@ -8,11 +8,29 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/hexagon/hex-subsys.h" +#include "hw/hexagon/hexagon_globalreg.h" #include "hw/core/loader.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/qdev.h" +#include "hw/core/sysbus.h" #include "system/address-spaces.h" +static DeviceState *globalreg_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg, +Rev_t rev) +{ +DeviceState *glob_regs =qdev_new (TYPE_HEXAGON_GLOBALREG ); + +object_property_add_child (OBJECT (hms),"global-regs" ,OBJECT (glob_regs)); +qdev_prop_set_uint64 (glob_regs,"config-table-addr" , m_cfg->cfgbase); +qdev_prop_set_uint32 (glob_regs,"dsp-rev" , rev); +sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs), &error_fatal); + +return glob_regs; +} +void hex_subsys_create (HexagonCommonMachineState *hms, -const struct hexagon_machine_config *m_cfg) +const struct hexagon_machine_config *m_cfg,Rev_t rev) {MachineState *machine =MACHINE (hms);MemoryRegion *sysmem =get_system_memory ();
@@ -37,4 +55,13 @@ void hex_subsys_create(HexagonCommonMachineState *hms,memory_region_add_subregion (sysmem, m_cfg->cfgtable.vtcm_base <<16 , &hms->vtcm); } + + hms->glob_regs =globalreg_create (hms, m_cfg, rev); +} + +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) +{ +object_property_set_link (OBJECT (cpu),"global-regs" , +OBJECT (hms->glob_regs), &error_fatal); +qdev_realize_and_unref (cpu,NULL , &error_fatal); }
hw/hexagon/hexagon_dsp.c +2 -13
@@ -15,7 +15,6 @@#include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "qapi/error.h"
@@ -109,7 +108,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, {HexagonCommonMachineState *hms =HEXAGON_COMMON_MACHINE (machine);HexagonDspMachineState *dms =HEXAGON_DSP_MACHINE (machine); -DeviceState *glob_regs_dev;DeviceState *tlb_dev;memset (&hexagon_binfo,0 ,sizeof (hexagon_binfo));
@@ -120,14 +118,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, machine->enable_graphics =0 ; -hex_subsys_create (hms, m_cfg); - - glob_regs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); -object_property_add_child (OBJECT (machine),"global-regs" , -OBJECT (glob_regs_dev)); -qdev_prop_set_uint64 (glob_regs_dev,"config-table-addr" , m_cfg->cfgbase); -qdev_prop_set_uint32 (glob_regs_dev,"dsp-rev" , rev); -sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs_dev), &error_fatal); +hex_subsys_create (hms, m_cfg, rev); tlb_dev =qdev_new (TYPE_HEXAGON_TLB );object_property_add_child (OBJECT (machine),"tlb" ,OBJECT (tlb_dev));
@@ -147,11 +138,9 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,if (i ==0 ) {hexagon_init_bootstrap (dms, cpu); } -object_property_set_link (OBJECT (cpu),"global-regs" , -OBJECT (glob_regs_dev), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +hex_subsys_realize_cpu (hms,DEVICE (cpu)); } }
hw/hexagon/virt.c +5 -18
@@ -14,7 +14,6 @@#include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h"
@@ -226,9 +225,7 @@ static void virt_init(MachineState *ms) {HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms);const struct hexagon_machine_config *m_cfg = &v68n_1024; -DeviceState *gsregs_dev;DeviceState *tlb_dev; -DeviceState *cpu0;int32_t clk_phandle;create_fdt (vms);
@@ -240,7 +237,7 @@ static void virt_init(MachineState *ms) vms->apb_clk =clock_new (OBJECT (ms),"apb-pclk" );clock_set_hz (vms->apb_clk,24000000 ); -hex_subsys_create (&vms->parent_obj, m_cfg); +hex_subsys_create (&vms->parent_obj, m_cfg, v68_rev);if (m_cfg->l2tcm_size) { memory_region_init_ram(&vms->tcm, NULL, "tcm.ram", m_cfg->l2tcm_size,
@@ -251,42 +248,32 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); - gsregs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); -object_property_add_child (OBJECT (ms),"global-regs" ,OBJECT (gsregs_dev)); -qdev_prop_set_uint64 (gsregs_dev,"config-table-addr" , m_cfg->cfgbase); -qdev_prop_set_uint32 (gsregs_dev,"dsp-rev" , v68_rev); -sysbus_realize_and_unref (SYS_BUS_DEVICE (gsregs_dev), &error_fatal); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB );object_property_add_child (OBJECT (ms),"tlb" ,OBJECT (tlb_dev));qdev_prop_set_uint32 (tlb_dev,"num-entries" , m_cfg->cfgtable.jtlb_size_entries);sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb_dev), &error_fatal); - cpu0 =NULL ;for (int i =0 ; i < ms->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);if (i ==0 ) { - cpu0 =DEVICE (cpu);if (ms->kernel_filename) {uint64_t entry =load_kernel (vms); -qdev_prop_set_uint32 (cpu0,"exec-start-addr" , entry); +qdev_prop_set_uint32 (DEVICE (cpu),"exec-start-addr" , entry); }else if (ms->firmware) {uint64_t entry =load_bios (vms); -qdev_prop_set_uint32 (cpu0,"exec-start-addr" , entry); +qdev_prop_set_uint32 (DEVICE (cpu),"exec-start-addr" , entry); } }qdev_prop_set_uint32 (DEVICE (cpu),"htid" , i);qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 )); -object_property_set_link (OBJECT (cpu),"global-regs" , -OBJECT (gsregs_dev), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); - -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpu)); } +fdt_add_cpu_nodes (vms); clk_phandle =fdt_add_clocks (vms);fdt_add_uart (vms,VIRT_UART0 , clk_phandle);
Signature · 1 line
2.34.1
Re: [PULL 00/41] hexagon queue - disregard
In reply to Brian CainQuoted 11 lines · Brian Cain
The following changes since commit
e8d693e12af9cbb89d724baadfcc08559669e279:tests/qtest: Do not use versioned pc-q35-5.2 machine anymore (2026-08-11 16:12:34 -0400)are available in the Git repository at:
https://github.com/qualcomm/qemu tags/pull-hex-20260811for you to fetch changes up to
87a03d3fb03d4450fdb7b4ef26e6185496555d1c:tests/hexagon: add tests for HVX bfloat (2026-08-11 23:20:45 -0700)
Sorry, Stefan! Disregard this pull req.
I was looking at the wrong test results when I thought this passed.
Quoted 142 lines
----------------------------------------------------------------
Hexagon queueFixes:
*ssub32_saturate,ssub64_saturatefixesFeatures:
* l2vic device
* qtimer device
* HVX-IEEE instructions (v68+)
* HVX GVec overrides for v{avg*,absdiff,sadd,*}----------------------------------------------------------------
Brian Cain (24):
hw/hexagon: add hex-subsys
hw/hexagon: move VTCM to the common machine state hw/hexagon: move global registers to hex-subsys
hw/hexagon: move the TLB to hex-subsys
hw/hexagon: group the CPUs in a cluster
bitops.h: Addfind_first_bit32()
hw/hexagon: extract get_reg_value/set_reg_value stubs in globalreg hw/hexagon: connect l2vic device
hw/hexagon/virt: instantiate virtio-mmio transports hw/hexagon/virt: add l2vic interrupt-controller and virtio-mmio FDT nodes hw/hexagon/virt: connect pl011 UART interrupt
tests/qtest: add L2VIC qtest
tests/functional/hexagon: addarch_testsfunctional test hw/timer: Add QCT QTimer device model
hw/hexagon: connect qtimer device
tests/qtest: add qct-qtimer qtest
tests/functional/hexagon: enable morearch_testscases
host-utils: fix ssub32/64_saturate return type and clamp direction target/hexagon: add GVec overrides for HVX saturating add/sub target/hexagon: add GVec override for HVX vmpyih multiply target/hexagon: add GVec overrides for HVX absolute difference target/hexagon: add GVec overrides for HVX vector average tests/tcg/hexagon: add HVX test forV6_vsubwsatsaturation tests/tcg/hexagon: add HVX tests for vabsdiffMatheus Tavares Bernardino (15):
target/hexagon: fix incorrect/too-permissive HVX encodings target/hexagon/cpu: add HVX IEEE FP extension
hexagon: group cpu configurations in their own struct
hexagon: print info on "-din_asm" for disabled IEEE FP instructions target/hexagon: add v68 HVX IEEE float arithmetic insns target/hexagon: add v68 HVX IEEE float min/max insns target/hexagon: add v68 HVX IEEE float misc insns target/hexagon: add v68 HVX IEEE float conversion insns target/hexagon: add v68 HVX IEEE float compare insns target/hexagon: add v73 HVX IEEE bfloat16 insns tests/hexagon: add tests for v68 HVX IEEE float arithmetics tests/hexagon: add tests for v68 HVX IEEE float min/max tests/hexagon: add tests for v68 HVX IEEE float conversions tests/hexagon: add tests for v68 HVX IEEE float comparisons tests/hexagon: add tests for HVX bfloatSid Manning (1):
hw/intc: Add l2vic interrupt controllerTaylor Simpson (1):
Hexagon (target/hexagon) Clean up disassembly of control and system regsMAINTAINERS | 7 + docs/devel/hexagon-l2vic.rst | 55 +++ docs/devel/index-internals.rst | 1 + include/hw/hexagon/hex-subsys.h | 32 ++ include/hw/hexagon/hexagon.h | 6 + include/hw/hexagon/hexagon_globalreg.h | 8 + include/hw/hexagon/virt.h | 4 +- include/hw/intc/hex-l2vic.h | 61 +++ include/hw/timer/qct-qtimer.h | 43 ++ include/qemu/bitops.h | 30 +- include/qemu/host-utils.h | 24 +- target/hexagon/cpu.h | 12 +- target/hexagon/cpu_bits.h | 12 +- target/hexagon/gen_tcg_hvx.h | 170 +++++++ target/hexagon/genptr.h | 4 + target/hexagon/helper.h | 5 + target/hexagon/mmvec/hvx_ieee_fp.h | 69 +++ target/hexagon/mmvec/macros.h | 10 +- target/hexagon/mmvec/mmvec.h | 3 + target/hexagon/printinsn.h | 2 +- target/hexagon/translate.h | 1 + tests/tcg/hexagon/hex_test.h | 32 ++ tests/tcg/hexagon/hvx_misc.h | 73 +++ target/hexagon/attribs_def.h.inc | 9 + disas/hexagon.c | 4 +- hw/hexagon/hex-subsys.c | 175 +++++++ hw/hexagon/hexagon_dsp.c | 45 +- hw/hexagon/hexagon_globalreg.c | 65 ++- hw/hexagon/virt.c | 130 ++++-- hw/intc/hex-l2vic.c | 556 ++++++++++++++++++++++ hw/timer/qct-qtimer.c | 667 +++++++++++++++++++++++++++ target/hexagon/arch.c | 8 + target/hexagon/cpu.c | 23 +- target/hexagon/decode.c | 4 +- target/hexagon/genptr.c | 70 +++ target/hexagon/mmvec/hvx_ieee_fp.c | 137 ++++++ target/hexagon/op_helper.c | 37 +- target/hexagon/printinsn.c | 108 ++++- target/hexagon/translate.c | 5 +- tests/qtest/l2vic-test.c | 249 ++++++++++ tests/qtest/qct-qtimer-test.c | 385 ++++++++++++++++ tests/tcg/hexagon/fp_hvx.c | 226 +++++++++ tests/tcg/hexagon/fp_hvx_cmp.c | 275 +++++++++++ tests/tcg/hexagon/fp_hvx_cvt.c | 219 +++++++++ tests/tcg/hexagon/fp_hvx_disabled.c | 57 +++ tests/tcg/hexagon/hvx_misc.c | 77 ++++ hw/hexagon/Kconfig | 3 + hw/hexagon/meson.build | 1 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + hw/timer/Kconfig | 3 + hw/timer/meson.build | 2 + hw/timer/trace-events | 5 + target/hexagon/gen_printinsn.py | 14 +- target/hexagon/gen_tcg_funcs.py | 12 + target/hexagon/hex_common.py | 27 ++ target/hexagon/imported/mmvec/encode_ext.def | 126 ++++- target/hexagon/imported/mmvec/ext.idef | 369 ++++++++++++++- target/hexagon/meson.build | 1 + tests/functional/hexagon/test_arch_tests.py | 38 ++ tests/qtest/meson.build | 2 +- tests/tcg/hexagon/Makefile.target | 14 + 63 files changed, 4657 insertions(+), 164 deletions(-)create mode 100644
docs/devel/hexagon-l2vic.rstcreate mode 100644include/hw/hexagon/hex-subsys.hcreate mode 100644include/hw/intc/hex-l2vic.hcreate mode 100644include/hw/timer/qct-qtimer.hcreate mode 100644target/hexagon/mmvec/hvx_ieee_fp.hcreate mode 100644hw/hexagon/hex-subsys.ccreate mode 100644hw/intc/hex-l2vic.c
create mode 100644hw/timer/qct-qtimer.ccreate mode 100644target/hexagon/mmvec/hvx_ieee_fp.ccreate mode 100644tests/qtest/l2vic-test.ccreate mode 100644tests/qtest/qct-qtimer-test.ccreate mode 100644tests/tcg/hexagon/fp_hvx.ccreate mode 100644tests/tcg/hexagon/fp_hvx_cmp.ccreate mode 100644tests/tcg/hexagon/fp_hvx_cvt.ccreate mode 100644tests/tcg/hexagon/fp_hvx_disabled.c
[PULL 33/41] target/hexagon: add v68 HVX IEEE float misc insns
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
Add HVX IEEE floating-point miscellaneous instructions:
- vassign_fp (vfmv): vector move
- vfneg_hf, vfneg_sf: vector floating-point negate
- vabs_hf, vabs_sf: vector absolute value
--- target/hexagon/imported/mmvec/encode_ext.def | 7 +++++++ target/hexagon/imported/mmvec/ext.idef | 12 ++++++++++++ 2 files changed, 19 insertions(+)
target/hexagon/imported/mmvec/encode_ext.def +7 -0
@@ -833,4 +833,11 @@ DEF_ENC(V6_vmin_sf,"00011111110vvvvvPP1uuuuu010ddddd") DEF_ENC(V6_vmax_hf,"00011111110vvvvvPP1uuuuu011ddddd") DEF_ENC(V6_vmin_hf,"00011111110vvvvvPP1uuuuu100ddddd") +/* IEEE FP move, negate, abs instructions */ +DEF_ENC(V6_vassign_fp,"00011110--0-0110PP1uuuuu001ddddd") +DEF_ENC(V6_vfneg_hf,"00011110--0-0110PP1uuuuu010ddddd") +DEF_ENC(V6_vfneg_sf,"00011110--0-0110PP1uuuuu011ddddd") +DEF_ENC(V6_vabs_hf,"00011110--0-0110PP1uuuuu100ddddd") +DEF_ENC(V6_vabs_sf,"00011110--0-0110PP1uuuuu101ddddd") + #endif /* NO MMVEC */
target/hexagon/imported/mmvec/ext.idef +12 -0
@@ -3034,6 +3034,18 @@ ITERATOR_INSN_ANY_SLOT_2SRC(16,vmin_hf,"Vd32.hf=vmin(Vu32.hf,Vv32.hf)", \ "Vector min of hf input", VdV.hf[i] = qf_min_hf(VuV.hf[i], VvV.hf[i], \ &env->hvx_fp_status)) +/* IEEE FP move, negate, abs instructions */ +ITERATOR_INSN_IEEE_FP_16_32_LATE(32, vassign_fp, "Vd32.w=vfmv(Vu32.w)", \ + "Vector IEEE move", VdV.w[i] = VuV.w[i]) +ITERATOR_INSN_IEEE_FP_16_32_LATE(16, vfneg_hf, "Vd32.hf=vfneg(Vu32.hf)", \ + "Vector IEEE neg: hf", VdV.hf[i] = float16_chs(VuV.hf[i])) +ITERATOR_INSN_IEEE_FP_16_32_LATE(32, vfneg_sf, "Vd32.sf=vfneg(Vu32.sf)", \ + "Vector IEEE neg: sf", VdV.sf[i] = float32_chs(VuV.sf[i])) +ITERATOR_INSN_IEEE_FP_16_32_LATE(16, vabs_hf, "Vd32.hf=vabs(Vu32.hf)", \ + "Vector IEEE abs: hf", VdV.hf[i] = float16_abs(VuV.hf[i])) +ITERATOR_INSN_IEEE_FP_16_32_LATE(32, vabs_sf, "Vd32.sf=vabs(Vu32.sf)", \ + "Vector IEEE abs: sf", VdV.sf[i] = float32_abs(VuV.sf[i])) + /****************************************************************************** DEBUG Vector/Register Printing ******************************************************************************/
Signature · 1 line
2.34.1
[PULL 28/41] target/hexagon/cpu: add HVX IEEE FP extension
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
This flag will be used to control the HVX IEEE float instructions, which are only available at some Hexagon cores. When unavailable, the instruction effectively only set the destination registers to 0.
--- target/hexagon/cpu.h | 1 + target/hexagon/translate.h | 1 + target/hexagon/attribs_def.h.inc | 3 +++ target/hexagon/cpu.c | 1 + target/hexagon/translate.c | 1 + target/hexagon/gen_tcg_funcs.py | 12 ++++++++++++ target/hexagon/hex_common.py | 25 +++++++++++++++++++++++++ 7 files changed, 44 insertions(+)
target/hexagon/cpu.h +1 -0
@@ -194,6 +194,7 @@ struct ArchCPU {bool lldb_compat;target_ulong lldb_stack_adjust;bool short_circuit; +bool ieee_fp_extension;#ifndef CONFIG_USER_ONLY HexagonTLBState *tlb;uint32_t boot_addr;
target/hexagon/translate.h +1 -0
@@ -81,6 +81,7 @@ typedef struct DisasContext {target_ulong branch_dest;bool is_tight_loop;bool short_circuit; +bool ieee_fp_extension;bool read_after_write;bool has_hvx_overlap;TCGv new_value[TOTAL_PER_THREAD_REGS ];
target/hexagon/attribs_def.h.inc +3 -0
@@ -196,5 +196,8 @@ DEF_ATTRIB(NOTE_SHIFT_RESOURCE, "Uses the HVX shift resource.", "", "") DEF_ATTRIB(RESTRICT_NOSLOT1_STORE, "Packet must not have slot 1 store", "", "") DEF_ATTRIB(RESTRICT_LATEPRED, "Predicate can not be used as a .new.", "", "") +/* HVX IEEE FP extension attributes */ +DEF_ATTRIB(HVX_IEEE_FP, "HVX IEEE FP extension instruction", "", "") + /* Keep this as the last attribute: */ DEF_ATTRIB(ZZ_LASTATTRIB, "Last attribute in the file", "", "")
target/hexagon/cpu.c +1 -0
@@ -75,6 +75,7 @@ static const Property hexagon_cpu_properties[] = {DEFINE_PROP_UNSIGNED ("lldb-stack-adjust" , HexagonCPU, lldb_stack_adjust,0 , qdev_prop_uint32, target_ulong),DEFINE_PROP_BOOL ("short-circuit" , HexagonCPU, short_circuit, true), + DEFINE_PROP_BOOL("ieee-fp", HexagonCPU, ieee_fp_extension, true), }; const char * const hexagon_regnames[TOTAL_PER_THREAD_REGS] = {
target/hexagon/translate.c +1 -0
@@ -1211,6 +1211,7 @@ static void hexagon_tr_init_disas_context(DisasContextBase *dcbase, ctx->is_tight_loop =FIELD_EX32 (hex_flags,TB_FLAGS ,IS_TIGHT_LOOP ); ctx->short_circuit = hex_cpu->short_circuit; ctx->hex_def =HEXAGON_CPU_GET_CLASS (hex_cpu)->hex_def; + ctx->ieee_fp_extension = hex_cpu->ieee_fp_extension;#ifndef CONFIG_USER_ONLY ctx->num_cycles =0 ; ctx->pcycle_enabled =FIELD_EX32 (hex_flags,TB_FLAGS ,PCYCLE_ENABLED );
target/hexagon/gen_tcg_funcs.py +12 -0
@@ -23,6 +23,15 @@ import hex_common from textwrap import dedent +def gen_disabled_ieee_insn(f, tag, regs): + f.write(" if (!ctx->ieee_fp_extension) {\n") + for regtype, regid in regs: + reg = hex_common.get_register(tag, regtype, regid) + if reg.is_hvx_reg() and reg.is_written(): + reg.gen_zero(f) + f.write(" return;\n") + f.write(" }\n") + ## ## Generate the TCG code to call the helper ## For A2_add: Rd32=add(Rs32,Rt32), { RdV=RsV+RtV;}
@@ -74,6 +83,9 @@ def gen_tcg_func(f, tag, regs, imms): i = 1 if immlett.isupper() else 0 f.write(f" int {hex_common.imm_name(immlett)} = insn->immed[{i}];\n") + if "A_HVX_IEEE_FP" in hex_common.attribdict[tag]: + gen_disabled_ieee_insn(f, tag, regs) + if hex_common.is_idef_parser_enabled(tag): gpr_operands = [ hex_common.get_register(tag, regtype, regid)
target/hexagon/hex_common.py +25 -0
@@ -784,6 +784,11 @@ def decl_tcg(self, f, tag, regno): TCGv_ptr {self.reg_tcg()} = tcg_temp_new_ptr(); tcg_gen_addi_ptr({self.reg_tcg()}, tcg_env, {self.hvx_off()}); """)) + def gen_zero(self, f): + f.write(code_fmt(f"""\ + tcg_gen_gvec_dup_imm(MO_64, {self.hvx_off()}, + sizeof(MMVector), sizeof(MMVector), 0); + """)) def gen_write(self, f, tag): pass def helper_hvx_desc(self, f):
@@ -850,6 +855,11 @@ def decl_tcg(self, f, tag, regno): TCGv_ptr {self.reg_tcg()} = tcg_temp_new_ptr(); tcg_gen_addi_ptr({self.reg_tcg()}, tcg_env, {self.hvx_off()}); """)) + def gen_zero(self, f): + f.write(code_fmt(f"""\ + tcg_gen_gvec_dup_imm(MO_64, {self.hvx_off()}, + sizeof(MMVector), sizeof(MMVector), 0); + """)) def gen_write(self, f, tag): pass def helper_hvx_desc(self, f):
@@ -882,6 +892,11 @@ def decl_tcg(self, f, tag, regno): vreg_src_off(ctx, {self.reg_num}), sizeof(MMVector), sizeof(MMVector)); """)) + def gen_zero(self, f): + f.write(code_fmt(f"""\ + tcg_gen_gvec_dup_imm(MO_64, {self.hvx_off()}, + sizeof(MMVector), sizeof(MMVector), 0); + """)) def gen_write(self, f, tag): f.write(code_fmt(f"""\ gen_vreg_write(ctx, {self.hvx_off()}, {self.reg_num},
@@ -915,6 +930,11 @@ def decl_tcg(self, f, tag, regno): TCGv_ptr {self.reg_tcg()} = tcg_temp_new_ptr(); tcg_gen_addi_ptr({self.reg_tcg()}, tcg_env, {self.hvx_off()}); """)) + def gen_zero(self, f): + f.write(code_fmt(f"""\ + tcg_gen_gvec_dup_imm(MO_64, {self.hvx_off()}, + sizeof(MMVectorPair), sizeof(MMVectorPair), 0); + """)) def gen_write(self, f, tag): pass def helper_hvx_desc(self, f):
@@ -974,6 +994,11 @@ def decl_tcg(self, f, tag, regno): TCGv_ptr {self.reg_tcg()} = tcg_temp_new_ptr(); tcg_gen_addi_ptr({self.reg_tcg()}, tcg_env, {self.hvx_off()}); """)) + def gen_zero(self, f): + f.write(code_fmt(f"""\ + tcg_gen_gvec_dup_imm(MO_64, {self.hvx_off()}, + sizeof(MMVectorPair), sizeof(MMVectorPair), 0); + """)) def gen_write(self, f, tag): f.write(code_fmt(f"""\ gen_vreg_write_pair(ctx, {self.hvx_off()}, {self.reg_num},
Signature · 1 line
2.34.1
[PULL 27/41] target/hexagon: fix incorrect/too-permissive HVX encodings
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
The following encodings have become stricter since v68:
- V6_vunpackob, V6_vunpackoh: ---00 -> --000
- V6_vaddbq/hq/wq, V6_vaddbnq/hnq/wnq: ---01 -> --001
- V6_vsubbq/hq, V6_vsubwq/bnq/hnq/wnq: ---01/---10 -> --001/--010
- V6_vhist, V6_vwhist128/256, V6_vwhist128/256_sat: ---00 -> --000
- V6_vhistq, V6_vwhist128/256q, V6_vwhist128/256q_sat: ---10 -> --010
Pre v68 compilers, by default, already use "0" for the non-specified bit that changed in v68, so unless someone is manually writing the binary encoding, this should not cause any backwards incompatibility with pre-v68 binaries.
--- target/hexagon/imported/mmvec/encode_ext.def | 48 ++++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-)
target/hexagon/imported/mmvec/encode_ext.def +24 -24
@@ -647,36 +647,36 @@ DEF_ENC(V6_vsubububb_sat, ICLASS_CJ" 1 110 101 vvvvv PP 0 uuuuu 101 ddddd") DEF_ENC(V6_vmpyewuh_64, ICLASS_CJ" 1 110 101 vvvvv PP 0 uuuuu 110 ddddd") DEF_FIELDROW_DESC32( ICLASS_CJ" 1 110 --0 ----- PP 1 ----- ----- ---","Vx32=Vu32") -DEF_ENC(V6_vunpackob, ICLASS_CJ" 1 110 --0 ---00 PP 1 uuuuu 000 xxxxx") // -DEF_ENC(V6_vunpackoh, ICLASS_CJ" 1 110 --0 ---00 PP 1 uuuuu 001 xxxxx") // +DEF_ENC(V6_vunpackob, ICLASS_CJ" 1 110 --0 --000 PP 1 uuuuu 000 xxxxx") // +DEF_ENC(V6_vunpackoh, ICLASS_CJ" 1 110 --0 --000 PP 1 uuuuu 001 xxxxx") // //DEF_ENC(V6_vunpackow, ICLASS_CJ" 1 110 --0 ---00 PP 1 uuuuu 010 xxxxx") // -DEF_ENC(V6_vhist, ICLASS_CJ" 1 110 --0 ---00 PP 1 -000- 100 -----") -DEF_ENC(V6_vwhist256, ICLASS_CJ" 1 110 --0 ---00 PP 1 -0010 100 -----") -DEF_ENC(V6_vwhist256_sat, ICLASS_CJ" 1 110 --0 ---00 PP 1 -0011 100 -----") -DEF_ENC(V6_vwhist128, ICLASS_CJ" 1 110 --0 ---00 PP 1 -010- 100 -----") -DEF_ENC(V6_vwhist128m, ICLASS_CJ" 1 110 --0 ---00 PP 1 -011i 100 -----") +DEF_ENC(V6_vhist, ICLASS_CJ" 1 110 --0 --000 PP 1 -000- 100 -----") +DEF_ENC(V6_vwhist256, ICLASS_CJ" 1 110 --0 --000 PP 1 -0010 100 -----") +DEF_ENC(V6_vwhist256_sat, ICLASS_CJ" 1 110 --0 --000 PP 1 -0011 100 -----") +DEF_ENC(V6_vwhist128, ICLASS_CJ" 1 110 --0 --000 PP 1 -010- 100 -----") +DEF_ENC(V6_vwhist128m, ICLASS_CJ" 1 110 --0 --000 PP 1 -011i 100 -----") DEF_FIELDROW_DESC32( ICLASS_CJ" 1 110 --0 ----- PP 1 ----- ----- ---","if (Qv4) Vx32=Vu32") -DEF_ENC(V6_vaddbq, ICLASS_CJ" 1 110 vv0 ---01 PP 1 uuuuu 000 xxxxx") // -DEF_ENC(V6_vaddhq, ICLASS_CJ" 1 110 vv0 ---01 PP 1 uuuuu 001 xxxxx") // -DEF_ENC(V6_vaddwq, ICLASS_CJ" 1 110 vv0 ---01 PP 1 uuuuu 010 xxxxx") // -DEF_ENC(V6_vaddbnq, ICLASS_CJ" 1 110 vv0 ---01 PP 1 uuuuu 011 xxxxx") // -DEF_ENC(V6_vaddhnq, ICLASS_CJ" 1 110 vv0 ---01 PP 1 uuuuu 100 xxxxx") // -DEF_ENC(V6_vaddwnq, ICLASS_CJ" 1 110 vv0 ---01 PP 1 uuuuu 101 xxxxx") // -DEF_ENC(V6_vsubbq, ICLASS_CJ" 1 110 vv0 ---01 PP 1 uuuuu 110 xxxxx") // -DEF_ENC(V6_vsubhq, ICLASS_CJ" 1 110 vv0 ---01 PP 1 uuuuu 111 xxxxx") // +DEF_ENC(V6_vaddbq, ICLASS_CJ" 1 110 vv0 --001 PP 1 uuuuu 000 xxxxx") // +DEF_ENC(V6_vaddhq, ICLASS_CJ" 1 110 vv0 --001 PP 1 uuuuu 001 xxxxx") // +DEF_ENC(V6_vaddwq, ICLASS_CJ" 1 110 vv0 --001 PP 1 uuuuu 010 xxxxx") // +DEF_ENC(V6_vaddbnq, ICLASS_CJ" 1 110 vv0 --001 PP 1 uuuuu 011 xxxxx") // +DEF_ENC(V6_vaddhnq, ICLASS_CJ" 1 110 vv0 --001 PP 1 uuuuu 100 xxxxx") // +DEF_ENC(V6_vaddwnq, ICLASS_CJ" 1 110 vv0 --001 PP 1 uuuuu 101 xxxxx") // +DEF_ENC(V6_vsubbq, ICLASS_CJ" 1 110 vv0 --001 PP 1 uuuuu 110 xxxxx") // +DEF_ENC(V6_vsubhq, ICLASS_CJ" 1 110 vv0 --001 PP 1 uuuuu 111 xxxxx") // -DEF_ENC(V6_vsubwq, ICLASS_CJ" 1 110 vv0 ---10 PP 1 uuuuu 000 xxxxx") // -DEF_ENC(V6_vsubbnq, ICLASS_CJ" 1 110 vv0 ---10 PP 1 uuuuu 001 xxxxx") // -DEF_ENC(V6_vsubhnq, ICLASS_CJ" 1 110 vv0 ---10 PP 1 uuuuu 010 xxxxx") // -DEF_ENC(V6_vsubwnq, ICLASS_CJ" 1 110 vv0 ---10 PP 1 uuuuu 011 xxxxx") // +DEF_ENC(V6_vsubwq, ICLASS_CJ" 1 110 vv0 --010 PP 1 uuuuu 000 xxxxx") // +DEF_ENC(V6_vsubbnq, ICLASS_CJ" 1 110 vv0 --010 PP 1 uuuuu 001 xxxxx") // +DEF_ENC(V6_vsubhnq, ICLASS_CJ" 1 110 vv0 --010 PP 1 uuuuu 010 xxxxx") // +DEF_ENC(V6_vsubwnq, ICLASS_CJ" 1 110 vv0 --010 PP 1 uuuuu 011 xxxxx") // -DEF_ENC(V6_vhistq, ICLASS_CJ" 1 110 vv0 ---10 PP 1 --00- 100 -----") -DEF_ENC(V6_vwhist256q, ICLASS_CJ" 1 110 vv0 ---10 PP 1 --010 100 -----") -DEF_ENC(V6_vwhist256q_sat, ICLASS_CJ" 1 110 vv0 ---10 PP 1 --011 100 -----") -DEF_ENC(V6_vwhist128q, ICLASS_CJ" 1 110 vv0 ---10 PP 1 --10- 100 -----") -DEF_ENC(V6_vwhist128qm, ICLASS_CJ" 1 110 vv0 ---10 PP 1 --11i 100 -----") +DEF_ENC(V6_vhistq, ICLASS_CJ" 1 110 vv0 --010 PP 1 --00- 100 -----") +DEF_ENC(V6_vwhist256q, ICLASS_CJ" 1 110 vv0 --010 PP 1 --010 100 -----") +DEF_ENC(V6_vwhist256q_sat, ICLASS_CJ" 1 110 vv0 --010 PP 1 --011 100 -----") +DEF_ENC(V6_vwhist128q, ICLASS_CJ" 1 110 vv0 --010 PP 1 --10- 100 -----") +DEF_ENC(V6_vwhist128qm, ICLASS_CJ" 1 110 vv0 --010 PP 1 --11i 100 -----") DEF_ENC(V6_vandvqv, ICLASS_CJ" 1 110 vv0 ---11 PP 1 uuuuu 000 ddddd")
Signature · 1 line
2.34.1
[PULL 38/41] tests/hexagon: add tests for v68 HVX IEEE float min/max
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
--- tests/tcg/hexagon/fp_hvx.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
tests/tcg/hexagon/fp_hvx.c +30 -0
@@ -73,6 +73,30 @@ DEF_TEST_OP_2(vsub, SUB_HF, hf, hf);DEF_TEST_OP_2 (vmpy,MULT_SF , sf, sf);DEF_TEST_OP_2 (vmpy,MULT_HF , hf, hf); +#define signbit_fp (X ) \ + (sizeof(X) == bytes_hf ? ((raw_hf(X) & 0x8000) != 0) : \ + ((raw_sf(X) & 0x80000000) != 0)) + +#define STD_MIN (X ,Y ) ((X) < (Y) ? (X) : (Y)) +#define STD_MAX (X ,Y ) ((X) > (Y) ? (X) : (Y)) + +#define MIN (X ,Y ,DEF_NAN ) \ + ((isnan(X) || isnan(Y)) ? DEF_NAN : \ + ((X) != (Y)) ? STD_MIN(X, Y) : (signbit_fp(X) ? (X) : (Y)))/* -0 < +0 */ +#define MAX (X ,Y ,DEF_NAN ) \ + ((isnan(X) || isnan(Y)) ? DEF_NAN : \ + ((X) != (Y)) ? STD_MAX(X, Y) : (signbit_fp(X) ? (Y) : (X)))/* -0 < +0 */ + +#define MIN_HF (X ,Y ) MIN(X, Y, NAN_HF) +#define MAX_HF (X ,Y ) MAX(X, Y, NAN_HF) +#define MIN_SF (X ,Y ) MIN(X, Y, NAN_SF) +#define MAX_SF (X ,Y ) MAX(X, Y, NAN_SF) + +DEF_TEST_OP_2 (vfmin,MIN_SF , sf, sf); +DEF_TEST_OP_2 (vfmax,MAX_SF , sf, sf); +DEF_TEST_OP_2 (vfmin,MIN_HF , hf, hf); +DEF_TEST_OP_2 (vfmax,MAX_HF , hf, hf); +/****************************************************************************** * Other tests *****************************************************************************/
@@ -150,6 +174,12 @@ int main(void)test_new (); +/* min/max */ +test_vfmin_sf_sf (); +test_vfmin_hf_hf (); +test_vfmax_sf_sf (); +test_vfmax_hf_hf (); +puts (err ?"FAIL" :"PASS" );return err ?1 :0 ; }
Signature · 1 line
2.34.1
[PULL 24/41] tests/tcg/hexagon: add HVX test for V6_vsubwsat saturation
In reply to Brian Cain--- tests/tcg/hexagon/hvx_misc.c | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
tests/tcg/hexagon/hvx_misc.c +44 -0
@@ -20,6 +20,8 @@#include <stdbool.h> #include <string.h> #include <limits.h> +#include <hexagon_types.h> +#include <hvx_hexagon_protos.h> int err;
@@ -386,6 +388,47 @@ static void test_vsubuwsat_dv(void)check_output_w (__LINE__,2 ); } +static void test_vsubwsat (void ) +{ +const int32_t x0 =INT32_MIN ; +const int32_t y0 =1 ; +const int32_t x1 =INT32_MAX ; +const int32_t y1 =-1 ; +HVX_Vector v0; +HVX_Vector v1; +HVX_Vector vres; + +/* INT32_MIN - 1 underflows and must saturate to INT32_MIN */ +memset (expect,0x12 ,sizeof (MMVector)); +memset (output,0x34 ,sizeof (MMVector)); + + v0 =Q6_V_vsplat_R (x0); + v1 =Q6_V_vsplat_R (y0); + vres =Q6_Vw_vsub_VwVw_sat (v0, v1); +memcpy (&output[0 ], &vres,sizeof (MMVector)); + +for (int j =0 ; j <MAX_VEC_SIZE_BYTES /4 ; j++) { + expect[0 ].w[j] =INT32_MIN ; + } + +check_output_w (__LINE__,1 ); + +/* INT32_MAX - (-1) overflows and must saturate to INT32_MAX */ +memset (expect,0x12 ,sizeof (MMVector)); +memset (output,0x34 ,sizeof (MMVector)); + + v0 =Q6_V_vsplat_R (x1); + v1 =Q6_V_vsplat_R (y1); + vres =Q6_Vw_vsub_VwVw_sat (v0, v1); +memcpy (&output[0 ], &vres,sizeof (MMVector)); + +for (int j =0 ; j <MAX_VEC_SIZE_BYTES /4 ; j++) { + expect[0 ].w[j] =INT32_MAX ; + } + +check_output_w (__LINE__,1 ); +} +static void test_load_tmp_predicated (void ) {void *p0 = buffer0;
@@ -530,6 +573,7 @@ int main()test_vadduwsat ();test_vsubuwsat_dv (); +test_vsubwsat ();test_load_tmp_predicated ();test_load_cur_predicated ();
Signature · 1 line
2.34.1
[PULL 34/41] target/hexagon: add v68 HVX IEEE float conversion insns
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
Add HVX IEEE floating-point conversion instructions:
- vconv_hf_h, vconv_h_hf, vconv_sf_w, vconv_w_sf: vconv operations
- vcvt_hf_sf, vcvt_sf_hf: float <-> half float conversions
- vcvt_hf_b, vcvt_hf_h, vcvt_hf_ub, vcvt_hf_uh: int to half float
- vcvt_b_hf, vcvt_h_hf, vcvt_ub_hf, vcvt_uh_hf: half float to int
--- target/hexagon/mmvec/hvx_ieee_fp.h | 4 + target/hexagon/mmvec/hvx_ieee_fp.c | 18 ++++ target/hexagon/imported/mmvec/encode_ext.def | 18 ++++ target/hexagon/imported/mmvec/ext.idef | 97 ++++++++++++++++++++ 4 files changed, 137 insertions(+)
target/hexagon/mmvec/hvx_ieee_fp.h +4 -0
@@ -10,6 +10,7 @@#include "fpu/softfloat.h" #define f16_to_f32 (A ) float16_to_float32((A), true, &env->hvx_fp_status) +#define f32_to_f16 (A ) float32_to_float16((A), true, &env->hvx_fp_status)float32 fp_mult_sf_hf (float16 a1,float16 a2,float_status *fp_status); float32 fp_vdmpy(float16 a1, float16 a2, float16 a3, float16 a4,
@@ -21,4 +22,7 @@ float32 qf_min_sf(float32 a1, float32 a2, float_status *fp_status);float16 qf_max_hf (float16 a1,float16 a2,float_status *fp_status);float16 qf_min_hf (float16 a1,float16 a2,float_status *fp_status); +int32_t conv_w_sf (float32 a,float_status *fp_status); +int16_t conv_h_hf (float16 a,float_status *fp_status); +#endif
target/hexagon/mmvec/hvx_ieee_fp.c +18 -0
@@ -69,3 +69,21 @@ float16 qf_min_hf(float16 a1, float16 a2, float_status *fp_status) }return float16_min (a1, a2, fp_status); } + +int32_t conv_w_sf (float32 a,float_status *fp_status) +{ +/* float32_to_int32 converts any NaN to MAX, hexagon looks at the sign. */ +if (float32_is_any_nan (a)) { +return float32_is_neg (a) ?INT32_MIN :INT32_MAX ; + } +return float32_to_int32_round_to_zero (a, fp_status); +} + +int16_t conv_h_hf (float16 a,float_status *fp_status) +{ +/* float16_to_int16 converts any NaN to MAX, hexagon looks at the sign. */ +if (float16_is_any_nan (a)) { +return float16_is_neg (a) ?INT16_MIN :INT16_MAX ; + } +return float16_to_int16_round_to_zero (a, fp_status); +}
target/hexagon/imported/mmvec/encode_ext.def +18 -0
@@ -840,4 +840,22 @@ DEF_ENC(V6_vfneg_sf,"00011110--0-0110PP1uuuuu011ddddd") DEF_ENC(V6_vabs_hf,"00011110--0-0110PP1uuuuu100ddddd") DEF_ENC(V6_vabs_sf,"00011110--0-0110PP1uuuuu101ddddd") +/* IEEE FP vcvt instructions */ +DEF_ENC(V6_vcvt_sf_hf,"00011110--0-0100PP1uuuuu100ddddd") +DEF_ENC(V6_vcvt_hf_sf,"00011111011vvvvvPP1uuuuu001ddddd") +DEF_ENC(V6_vcvt_hf_ub,"00011110--0-0100PP1uuuuu001ddddd") +DEF_ENC(V6_vcvt_hf_b,"00011110--0-0100PP1uuuuu010ddddd") +DEF_ENC(V6_vcvt_hf_uh,"00011110--0-0100PP1uuuuu101ddddd") +DEF_ENC(V6_vcvt_hf_h,"00011110--0-0100PP1uuuuu111ddddd") +DEF_ENC(V6_vcvt_uh_hf,"00011110--0--101PP1uuuuu000ddddd") +DEF_ENC(V6_vcvt_h_hf,"00011110--0-0110PP1uuuuu000ddddd") +DEF_ENC(V6_vcvt_ub_hf,"00011111110vvvvvPP1uuuuu101ddddd") +DEF_ENC(V6_vcvt_b_hf,"00011111110vvvvvPP1uuuuu110ddddd") + +/* IEEE FP vconv instructions */ +DEF_ENC(V6_vconv_sf_w,"00011110--0--101PP1uuuuu011ddddd") +DEF_ENC(V6_vconv_w_sf,"00011110--0--101PP1uuuuu001ddddd") +DEF_ENC(V6_vconv_hf_h,"00011110--0--101PP1uuuuu100ddddd") +DEF_ENC(V6_vconv_h_hf,"00011110--0--101PP1uuuuu010ddddd") + #endif /* NO MMVEC */
target/hexagon/imported/mmvec/ext.idef +97 -0
109 lines not on this page · raw message
Signature · 1 line
2.34.1
[PULL 21/41] target/hexagon: add GVec override for HVX vmpyih multiply
In reply to Brian Cain--- target/hexagon/gen_tcg_hvx.h | 5 +++++ 1 file changed, 5 insertions(+)
target/hexagon/gen_tcg_hvx.h +5 -0
@@ -321,6 +321,11 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_V6_vsubuwsat_dv (SHORTCODE ) \ fGEN_TCG_PAIR_ADDSUB(ussub, MO_32, VddV_off, VuuV_off, VvvV_off) + +#define fGEN_TCG_V6_vmpyih (SHORTCODE ) \ + tcg_gen_gvec_mul(MO_16, VdV_off, VuV_off, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) +/* Vector shift right - various forms */ #define fGEN_TCG_V6_vasrh (SHORTCODE ) \ do { \
Signature · 1 line
2.34.1
[PULL 25/41] tests/tcg/hexagon: add HVX tests for vabsdiff
In reply to Brian CainCover the four vabsdiff variants.
The expected value is computed in int64_t to avoid overflowing the source element type.
--- tests/tcg/hexagon/hvx_misc.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
tests/tcg/hexagon/hvx_misc.c +33 -0
@@ -317,6 +317,34 @@ TEST_VEC_OP2(vand, vand, , d, 8, &) TEST_VEC_OP2(vor, vor, , d, 8, |) TEST_VEC_OP1(vnot, vnot, , d, 8, ~) +#define TEST_VEC_ABSDIFF(NAME, INTRINSIC, SRC_FIELD, DST_FIELD, \ + CHECK_FIELD, FIELDSZ) \ +static inline void test_##NAME(void) \ +{ \ + HVX_Vector v0; \ + HVX_Vector v1; \ + HVX_Vector vres; \ + for (int i = 0; i < BUFSIZE; i++) { \ + memcpy(&v0, &buffer0[i], sizeof(MMVector)); \ + memcpy(&v1, &buffer1[i], sizeof(MMVector)); \ + vres = INTRINSIC(v0, v1); \ + memcpy(&output[i], &vres, sizeof(MMVector)); \ + } \ + for (int i = 0; i < BUFSIZE; i++) { \ + for (int j = 0; j < MAX_VEC_SIZE_BYTES / FIELDSZ; j++) { \ + int64_t diff = (int64_t)buffer0[i].SRC_FIELD[j] - \ + (int64_t)buffer1[i].SRC_FIELD[j]; \ + expect[i].DST_FIELD[j] = diff < 0 ? -diff : diff; \ + } \ + } \ + check_output_##CHECK_FIELD(__LINE__, BUFSIZE); \ +} + +TEST_VEC_ABSDIFF(vabsdiffub, Q6_Vub_vabsdiff_VubVub, ub, ub, b, 1) +TEST_VEC_ABSDIFF(vabsdiffuh, Q6_Vuh_vabsdiff_VuhVuh, uh, uh, h, 2) +TEST_VEC_ABSDIFF(vabsdiffh, Q6_Vuh_vabsdiff_VhVh, h, uh, h, 2) +TEST_VEC_ABSDIFF(vabsdiffw, Q6_Vuw_vabsdiff_VwVw, w, uw, w, 4) + TEST_PRED_OP2(pred_or, or, |, "") TEST_PRED_OP2(pred_or_n, or, |, "!") TEST_PRED_OP2(pred_and, and, &, "")
@@ -575,6 +603,11 @@ int main()test_vsubuwsat_dv ();test_vsubwsat (); +test_vabsdiffub (); +test_vabsdiffuh (); +test_vabsdiffh (); +test_vabsdiffw (); +test_load_tmp_predicated ();test_load_cur_predicated ();
Signature · 1 line
2.34.1
[PULL 41/41] tests/hexagon: add tests for HVX bfloat
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
--- tests/tcg/hexagon/hex_test.h | 13 +++++++++ tests/tcg/hexagon/hvx_misc.h | 30 ++++++++++++++++++++ tests/tcg/hexagon/fp_hvx.c | 41 +++++++++++++++++++++++++++ tests/tcg/hexagon/fp_hvx_cmp.c | 51 ++++++++++++++++++++++++++++++++++ tests/tcg/hexagon/fp_hvx_cvt.c | 31 +++++++++++++++++++++ 5 files changed, 166 insertions(+)
tests/tcg/hexagon/hex_test.h +13 -0
@@ -126,6 +126,19 @@ const uint16_t HF_small_neg = 0x8010;const uint16_t HF_any =0x3c00 ;const uint16_t HF_neg_two =0xc000 ; +const uint16_t BF_INF =0x7f80 ; +const uint16_t BF_INF_neg =0xff80 ; +const uint16_t BF_QNaN =0x7fc0 ; +const uint16_t BF_SNaN =0x7f81 ; +const uint16_t BF_QNaN_neg =0xffc0 ; +const uint16_t BF_SNaN_neg =0xff81 ; +const uint16_t BF_HEX_NaN =0x7fff ; +const uint16_t BF_zero =0x0000 ; +const uint16_t BF_zero_neg =0x8000 ; +const uint16_t BF_one =0x3f80 ; +const uint16_t BF_two =0x4000 ; +const uint16_t BF_four =0x4080 ; +const uint32_t SF_INF =0x7f800000 ;const uint32_t SF_INF_neg =0xff800000 ;const uint32_t SF_QNaN =0x7fc00000 ;
tests/tcg/hexagon/hvx_misc.h +30 -0
@@ -41,6 +41,7 @@ typedef union {uint16_t uh[MAX_VEC_SIZE_BYTES /2 ];uint16_t hf[MAX_VEC_SIZE_BYTES /2 ];/* convenience alias */ int16_t h[MAX_VEC_SIZE_BYTES /2 ]; +uint16_t bf[MAX_VEC_SIZE_BYTES /2 ];uint8_t ub[MAX_VEC_SIZE_BYTES /1 ];int8_t b[MAX_VEC_SIZE_BYTES /1 ]; } MMVector;
@@ -73,6 +74,7 @@ CHECK_OUTPUT_FUNC(uh, 2) CHECK_OUTPUT_FUNC(hf, 2) CHECK_OUTPUT_FUNC(ub, 1) CHECK_OUTPUT_FUNC(b, 1) +CHECK_OUTPUT_FUNC(bf, 2)static inline void init_buffers (void ) {
@@ -97,6 +99,12 @@ static const uint32_t FP_VALUES[] = { };#define FP_VALUES_MAX ARRAY_SIZE(FP_VALUES) +static const uint16_t BF_VALUES [] = { +BF_INF , BF_INF_neg, BF_QNaN, BF_SNaN, BF_QNaN_neg, BF_SNaN_neg, + BF_HEX_NaN, BF_zero, BF_zero_neg, BF_one, BF_two, BF_four, +}; +#define BF_VALUES_MAX ARRAY_SIZE(BF_VALUES) +static inline void init_buffers_fp (void ) { _Static_assert(BUFSIZE * (MAX_VEC_SIZE_BYTES / 4) >
@@ -116,6 +124,25 @@ static inline void init_buffers_fp(void) } } +static inline void init_buffers_bf (void ) +{ +_Static_assert (BUFSIZE * (MAX_VEC_SIZE_BYTES /2 ) > +BF_VALUES_MAX *BF_VALUES_MAX , +"test arrays can't fit all BF_VALUES combinations" ); +int counter1 =0 , counter2 =0 ; +for (int i =0 ; i <BUFSIZE ; i++) { +for (int j =0 ; j <MAX_VEC_SIZE_BYTES /2 ; j++) { + buffer0[i].bf[j] =BF_VALUES [counter1]; + buffer1[i].bf[j] =BF_VALUES [counter2]; + counter2++; +if (counter2 ==BF_VALUES_MAX ) { + counter2 =0 ; + counter1 = (counter1 +1 ) %BF_VALUES_MAX ; + } + } + } +} +#define VEC_OP1 (ASM ,EL ,IN ,OUT ) \ asm("v2 = vmem(%0 + #0)\n\t" \ "v2" #EL " = " #ASM "(v2" #EL ")\n\t" \
@@ -212,10 +239,13 @@ static inline void test_##NAME(bool invert) \#define float_sf (x) ({ typeof(x) _x = (x); *((float *)&(_x)); })#define float_hf (x) ({ typeof(x) _x = (x); *((_Float16 *) &(_x)); }) +#define float_bf (x) ({ uint32_t _u = ((uint32_t)(x)) << 16; *((float *)&(_u)); })#define raw_sf (x) ({ typeof(x) _x = (x); *((uint32_t *)&(_x)); })#define raw_hf (x) ({ typeof(x) _x = (x); *((uint16_t *)&(_x)); }) +#define raw_bf (x) ({ typeof(x) _x = (x); (uint16_t)(*((uint32_t *)&(_x)) >> 16); })#define float_hf_to_sf (x) ((float)x)#define bytes_hf 2#define bytes_sf 4 +#define bytes_bf 2#endif
tests/tcg/hexagon/fp_hvx.c +41 -0
64 lines not on this page · raw message
tests/tcg/hexagon/fp_hvx_cmp.c +51 -0
72 lines not on this page · raw message
tests/tcg/hexagon/fp_hvx_cvt.c +31 -0
@@ -19,6 +19,8 @@ int err;#include "hvx_misc.h" #include "hex_test.h" +#define NAN_BF 0x7FFF +#define TEST_EXP (TO ,FROM ,VAL ,EXP ) do { \ ((MMVector *)&buffer)->FROM[index] = VAL; \ expect[0].TO[index] = EXP; \
@@ -172,6 +174,34 @@ DEF_TEST_VCONV(sf, w, { \TEST_EXP (sf, w,16777219 ,raw_sf ((float )16777220 ));/* rounds UP */ \ }) +#define TEST_EXP_BF (VAL ,EXP ) do { \ + ((MMVector *)&buffers[1])->sf[index] = VAL; \ + ((MMVector *)&buffers[0])->sf[index] = VAL; \ + expect[0].bf[2 * index] = EXP; \ + expect[0].bf[2 * index + 1] = EXP; \ + index++; \ +} while (0) + +static void test_vconv_bf_sf (void ) +{ +HVX_Vector *hvx_output = (HVX_Vector *)&output[0 ]; +HVX_Vector buffers[2 ]; +int index =0 ; +memset (&buffers,0 ,sizeof (buffers)); +memset (expect,0 ,sizeof (expect)); + +TEST_EXP_BF (SF_QNaN,NAN_BF ); +TEST_EXP_BF (SF_SNaN,NAN_BF ); +TEST_EXP_BF (SF_QNaN_neg,NAN_BF ); +TEST_EXP_BF (SF_INF ,BF_INF ); +TEST_EXP_BF (SF_INF_neg, BF_INF_neg); +TEST_EXP_BF (SF_one, BF_one); +TEST_EXP_BF (SF_zero_neg, BF_zero_neg); + + *hvx_output =Q6_Vbf_vcvt_VsfVsf (buffers[0 ], buffers[1 ]); +check_output_hf (__LINE__,1 ); +} +int main (void ) {test_vcvt_uh_hf ();
@@ -182,6 +212,7 @@ int main(void)test_vconv_sf_w ();test_vconv_h_hf ();test_vconv_hf_h (); +test_vconv_bf_sf ();puts (err ?"FAIL" :"PASS" );return err ?1 :0 ;
Signature · 1 line
2.34.1
[PULL 40/41] tests/hexagon: add tests for v68 HVX IEEE float comparisons
In reply to Brian CainFrom: Matheus Tavares Bernardino <[email protected]>
--- tests/tcg/hexagon/hex_test.h | 1 + tests/tcg/hexagon/fp_hvx_cmp.c | 224 ++++++++++++++++++++++++++++++ tests/tcg/hexagon/Makefile.target | 3 + 3 files changed, 228 insertions(+) create mode 100644 tests/tcg/hexagon/fp_hvx_cmp.c
tests/tcg/hexagon/hex_test.h +1 -0
@@ -115,6 +115,7 @@ const uint16_t HF_INF = 0x7c00;const uint16_t HF_INF_neg =0xfc00 ;const uint16_t HF_QNaN =0x7e00 ;const uint16_t HF_SNaN =0x7d00 ; +const uint16_t HF_SNaN_neg =0xfd00 ;const uint16_t HF_QNaN_neg =0xfe00 ;const uint16_t HF_zero =0x0000 ;const uint16_t HF_zero_neg =0x8000 ;
tests/tcg/hexagon/fp_hvx_cmp.c new file +224 -0
224 lines not on this page · raw message
tests/tcg/hexagon/Makefile.target +3 -0
@@ -52,6 +52,7 @@ HEX_TESTS += hvx_misc HEX_TESTS += hvx_histogram HEX_TESTS += fp_hvx HEX_TESTS += fp_hvx_cvt +HEX_TESTS += fp_hvx_cmp HEX_TESTS += fp_hvx_disabled HEX_TESTS += invalid-slots HEX_TESTS += valid-slots
@@ -145,6 +146,8 @@ fp_hvx_disabled: fp_hvx_disabled.c hvx_misc.h hex_test.h fp_hvx_disabled: CFLAGS += -mhvx -mhvx-ieee-fp fp_hvx_cvt: fp_hvx_cvt.c hvx_misc.h hex_test.h fp_hvx_cvt: CFLAGS += -mhvx -mhvx-ieee-fp +fp_hvx_cmp: fp_hvx_cmp.c hvx_misc.h hex_test.h +fp_hvx_cmp: CFLAGS += -mhvx -mhvx-ieee-fp run-fp_hvx_disabled: QEMU_OPTS += -cpu v73,ieee-fp=false
Signature · 1 line
2.34.1