ppc patch queue 2014-03-05
Hi Blue / Aurelien / Anthony / Peter,
This is my current patch queue for ppc. Please pull.
This pull request includes:
- VSX emulation support
- book3s pr/hv selection
- some bug fixes
- qdev stable numbering
- eTSEC emulation
Alex
The following changes since commit f55ea6297cc0224fe4934b90ff5343b620b14669:
block/gluster: Add missing argument to qemu_gluster_init() call (2014-03-04 20:20:57 +0000)
are available in the git repository at:
git://github.com/agraf/qemu.git tags/signed-ppc-for-upstream
for you to fetch changes up to 0f20ba62c35e6a779ba4ea00616192ef2abb6896:
target-ppc: spapr: e500: fix to use cpu_dt_id (2014-03-05 03:07:04 +0100)
----------------------------------------------------------------
Patch queue for ppc - 2014-03-05
This pull request includes:
- VSX emulation support
- book3s pr/hv selection
- some bug fixes
- qdev stable numbering
- eTSEC emulation
----------------------------------------------------------------
Alexander Graf (3):
KVM: Split QEMUMachine typedef into separate header
qdev: Keep global allocation counter per bus
PPC: sPAPR: Only use getpagesize() when we run with kvm
Alexey Kardashevskiy (19):
target-ppc: fix compile error when PPC_DUMP_CPU is enabled
target-ppc: fix LPCR SPR number
target-ppc: remove powerpc 970gx
target-ppc: fix SPR_CTRL/SPR_UCTRL register numbers
target-ppc: remove embedded MMU SPRs from 970, P5+/7/7+/8
target-ppc: remove unsupported SPRs from 970 and P5+
target-ppc: fix Authority Mask Register init value
PPC: KVM: fix "set one register"
spapr-pci: enable adding PHB via -device
target-ppc: disable unsupported modes for SPR_CTRL/SPR_UCTRL
PPC: KVM: store SLB slot number
PPC: KVM: suppress warnings about not supported SPRs
spapr: support only ELF kernel images
moxie: fix load_elf() usage
elf-loader: add more return codes
spapr: print more detailed error message on failed load_elf()
spapr-vlan: flush queue whenever can_receive can go from false to true
target-ppc: add PowerPCCPU::cpu_dt_id
target-ppc: spapr: e500: fix to use cpu_dt_id
Aneesh Kumar K.V (6):
kvm: Add a new machine option kvm-type
target-ppc: Update external_htab even when HTAB is managed by kernel
target-ppc: Fix htab_mask calculation
target-ppc: Fix page table lookup with kvm enabled
target-ppc: Change the hpte store API
target-ppc: Update ppc_hash64_store_hpte to support updating in-kernel htab
Anton Blanchard (1):
target-ppc: dump DAR and DSISR
Cédric Le Goater (2):
mmu-hash64: fix Virtual Page Class Key Protection
target-ppc: add extended opcodes for dcbt/dcbtst
Edgar E. Iglesias (1):
virtex_ml507: Add support for loading initrd images
Fabien Chouteau (1):
Add Enhanced Three-Speed Ethernet Controller (eTSEC)
Greg Kurz (1):
PPC: KVM: add support for LPCR
Laurent Dufour (1):
target-ppc: Introduce hypervisor call H_GET_TCE
Nathan Whitehorn (1):
spapr_vscsi: Fix REPORT_LUNS handling
Peter Maydell (1):
target-ppc/translate.c: Use ULL suffix for 64 bit constants
Tom Musta (93):
target-ppc: Add set_fprf Argument to fload_invalid_op_excp()
target-ppc: General Support for VSX Helpers
target-ppc: Add VSX ISA2.06 xadd/xsub Instructions
target-ppc: Add VSX ISA2.06 xmul Instructions
target-ppc: Add VSX ISA2.06 xdiv Instructions
target-ppc: Add VSX ISA2.06 xre Instructions
target-ppc: Add VSX ISA2.06 xsqrt Instructions
target-ppc: Add VSX ISA2.06 xrsqrte Instructions
target-ppc: Add VSX ISA2.06 xtdiv Instructions
target-ppc: Add VSX ISA2.06 xtsqrt Instructions
target-ppc: Add VSX ISA2.06 Multiply Add Instructions
target-ppc: Add VSX xscmp*dp Instructions
target-ppc: Add VSX xmax/xmin Instructions
target-ppc: Add VSX Vector Compare Instructions
target-ppc: Add VSX Floating Point to Floating Point Conversion Instructions
target-ppc: Add VSX ISA2.06 Integer Conversion Instructions
target-ppc: Add VSX Rounding Instructions
target-ppc: VSX Stage 4: Add VSX 2.07 Flag
target-ppc: VSX Stage 4: Refactor lxsdx
target-ppc: VSX Stage 4: Add lxsiwax, lxsiwzx and lxsspx
target-ppc: VSX Stage 4: Refactor stxsdx
target-ppc: VSX Stage 4: Add stxsiwx and stxsspx
target-ppc: VSX Stage 4: Add xsaddsp and xssubsp
target-ppc: VSX Stage 4: Add xsmulsp
target-ppc: VSX Stage 4: Add xsdivsp
target-ppc: VSX Stage 4: Add xsresp
target-ppc: VSX Stage 4: Add xssqrtsp
target-ppc: VSX Stage 4: add xsrsqrtesp
target-ppc: VSX Stage 4: Add Scalar SP Fused Multiply-Adds
target-ppc: VSX Stage 4: Add xscvsxdsp and xscvuxdsp
target-ppc: VSX Stage 4: Add xxleqv, xxlnand and xxlorc
target-ppc: Move To/From VSR Instructions
target-ppc: Floating Merge Word Instructions
target-ppc: Scalar Round to Single Precision
target-ppc: Scalar Non-Signalling Conversions
target-ppc: Add ISA2.06 bpermd Instruction
target-ppc: Add Flag for ISA2.06 Divide Extended Instructions
target-ppc: Add ISA2.06 divdeu[o] Instructions
target-ppc: Add ISA2.06 divde[o] Instructions
target-ppc: Add ISA 2.06 divweu[o] Instructions
target-ppc: Add ISA 2.06 divwe[o] Instructions
target-ppc: Add Flag for ISA2.06 Atomic Instructions
target-ppc: Add ISA2.06 lbarx, lharx Instructions
target-ppc: Add ISA 2.06 stbcx. and sthcx. Instructions
target-ppc: Add Flag for ISA V2.06 Floating Point Conversion
target-ppc: Add ISA2.06 Float to Integer Instructions
target-ppc: Add ISA 2.06 fcfid[u][s] Instructions
target-ppc: Fix and enable fri[mnpz]
target-ppc: Add Flag for Power ISA V2.06 Floating Point Test Instructions
target-ppc: Add ISA 2.06 ftdiv Instruction
target-ppc: Add ISA 2.06 ftsqrt
target-ppc: Enable frsqrtes on Power7 and Power8
target-ppc: Add ISA2.06 lfiwzx Instruction
target-ppc: Fix xxpermdi When T==A or T==B
target-ppc: Add Flag for bctar
target-ppc: Add Target Address SPR (TAR) to Power8
target-ppc: Add bctar Instruction
target-ppc: Add Flag for ISA 2.07 Load/Store Quadword Instructions
target-ppc: Add is_user_mode Utility Routine
target-ppc: Load Quadword
target-ppc: Store Quadword
target-ppc: Add Load Quadword and Reserve
target-ppc: Add Store Quadword Conditional
target-ppc: Altivec 2.07: Add Instruction Flag
target-ppc: Altivec 2.07: Update AVR Structure
target-ppc: Altivec 2.07: Add GEN_VXFORM3
target-ppc: Altivec 2.07: Add Support for Dual Altivec Instructions
target-ppc: Altivec 2.07: Add Opcode Macro for VX Form Instructions
target-ppc: Altivec 2.07: Add Support for R-Form Dual Instructions
target-ppc: Altivec 2.07: Vector Logical Instructions
target-ppc: Altivec 2.07: Add/Subtract Unsigned Doubleword Modulo
target-ppc: Altivec 2.07: Change VMUL_DO to Support 64-bit Integers
target-ppc: Altivec 2.07: Multiply Even/Odd Word Instructions
target-ppc: Altivec 2.07: vmuluw Instruction
target-ppc: Altivec 2.07: Add Vector Count Leading Zeroes
target-ppc: Altivec 2.07: Vector Population Count Instructions
target-ppc: Altivec 2.07: Vector Min/Max Doubleword Instructions
target-ppc: Altivec 2.07: Pack Doubleword Instructions
target-ppc: Altivec 2.07: Unpack Signed Word Instructions
target-ppc: Altivec 2.07: Vector Merge Instructions
target-ppc: Altivec 2.07: Change Bit Masks to Support 64-bit Rotates and Shifts
target-ppc: Altivec 2.07: Vector Doubleword Rotate and Shift Instructions
target-ppc: Altivec 2.07: Quadword Addition and Subtracation
target-ppc: Altivec 2.07: vbpermq Instruction
target-ppc: Altivec 2.07: Doubleword Compares
target-ppc: Altivec 2.07: Vector Gather Bits by Bytes
target-ppc: Altivec 2.07: Vector Polynomial Multiply Sum
target-ppc: Altivec 2.07: Binary Coded Decimal Instructions
target-ppc: Altivec 2.07: AES Instructions
target-ppc: Altivec 2.07: Vector SHA Sigma Instructions
target-ppc: Altivec 2.07: Vector Permute and Exclusive OR
target-ppc: Fix Compiler Warnings Due to 64-Bit Constants Declared as UL
target-ppc: Use Additional Temporary in stqcx Case
default-configs/ppc-softmmu.mak | 1 + hw/core/loader.c | 30 +- hw/core/qdev.c | 20 +- hw/i386/pc_piix.c | 8 +- hw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +- hw/intc/xics_kvm.c | 10 +- hw/moxie/moxiesim.c | 2 +- hw/net/Makefile.objs | 3 + hw/net/fsl_etsec/etsec.c | 465 +++++++++++++ hw/net/fsl_etsec/etsec.h | 174 +++++ hw/net/fsl_etsec/miim.c | 146 ++++ hw/net/fsl_etsec/registers.c | 295 ++++++++ hw/net/fsl_etsec/registers.h | 320 +++++++++ hw/net/fsl_etsec/rings.c | 650 ++++++++++++++++++ hw/net/spapr_llan.c | 2 + hw/ppc/e500.c | 7 +- hw/ppc/ppc.c | 22 + hw/ppc/spapr.c | 56 +- hw/ppc/spapr_hcall.c | 87 ++- hw/ppc/spapr_iommu.c | 37 + hw/ppc/spapr_pci.c | 15 +- hw/ppc/spapr_rtas.c | 14 +- hw/ppc/virtex_ml507.c | 34 +- hw/s390x/ipl.c | 4 +- hw/scsi/spapr_vscsi.c | 60 ++ include/hw/boards.h | 6 +- include/hw/elf_ops.h | 19 +- include/hw/loader.h | 6 + include/hw/qdev-core.h | 2 + include/hw/xen/xen.h | 3 +- include/qemu/host-utils.h | 28 + include/sysemu/kvm.h | 3 +- include/sysemu/qemumachine.h | 16 + include/sysemu/qtest.h | 3 +- kvm-all.c | 17 +- kvm-stub.c | 3 +- linux-user/main.c | 18 +- qtest.c | 2 +- target-ppc/STATUS | 9 - target-ppc/cpu-models.c | 2 - target-ppc/cpu-models.h | 1 - target-ppc/cpu-qom.h | 2 + target-ppc/cpu.h | 55 +- target-ppc/fpu_helper.c | 1294 +++++++++++++++++++++++++++++++---- target-ppc/helper.h | 207 ++++++ target-ppc/int_helper.c | 1411 +++++++++++++++++++++++++++++++++++++-- target-ppc/kvm.c | 117 +++- target-ppc/kvm_ppc.h | 35 +- target-ppc/machine.c | 11 +- target-ppc/misc_helper.c | 4 +- target-ppc/mmu-hash64.c | 117 +++- target-ppc/mmu-hash64.h | 47 +- target-ppc/mmu_helper.c | 3 +- target-ppc/translate.c | 1268 +++++++++++++++++++++++++++++++---- target-ppc/translate_init.c | 274 ++------ trace-events | 3 + util/host-utils.c | 75 +++ vl.c | 14 +- xen-all.c | 2 +- xen-stub.c | 2 +- 61 files changed, 6818 insertions(+), 740 deletions(-) create mode 100644 hw/net/fsl_etsec/etsec.c create mode 100644 hw/net/fsl_etsec/etsec.h create mode 100644 hw/net/fsl_etsec/miim.c create mode 100644 hw/net/fsl_etsec/registers.c create mode 100644 hw/net/fsl_etsec/registers.h create mode 100644 hw/net/fsl_etsec/rings.c create mode 100644 include/sysemu/qemumachine.h
[Qemu-devel] [PULL 009/130] target-ppc: dump DAR and DSISR
From: Anton Blanchard <[email protected]>
The DAR and DSISR can be very useful when debugging issues, so add them to ppc_cpu_dump_state. We had another bug in this area: all of the v2.06 MMU types were missing.
--- target-ppc/translate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
target-ppc/translate.c +6 -1
@@ -10260,8 +10260,13 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,case POWERPC_MMU_SOFT_74xx:#if defined(TARGET_PPC64 )case POWERPC_MMU_64B : +case POWERPC_MMU_2_06 : +case POWERPC_MMU_2_06a: +case POWERPC_MMU_2_06d:#endif -cpu_fprintf (f," SDR1 " TARGET_FMT_lx"\n" , env->spr[SPR_SDR1 ]); +cpu_fprintf (f," SDR1 " TARGET_FMT_lx" DAR " TARGET_FMT_lx +" DSISR " TARGET_FMT_lx"\n" , env->spr[SPR_SDR1 ], + env->spr[SPR_DAR ], env->spr[SPR_DSISR ]);break ;case POWERPC_MMU_BOOKE206 : cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 010/130] target-ppc: fix Authority Mask Register init value
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
The existing default value (-1) of the AMR register forbids data access to all 32 classes. Since the guest linux does not change this register, we end up with the guest hanging right after switching from the real to protected mode.
This sets the default AMR value to zero what enables data access for all classes.
The only reason for not hitting this bug before is that kvm_arch_put_registers() did not put any SPR to KVM due to missing assignment of @one_reg_id in _spr_register() (which is going to be fixed by a separate patch).
--- target-ppc/translate_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/translate_init.c +1 -1
@@ -1064,7 +1064,7 @@ static void gen_spr_amr (CPUPPCState *env)spr_register_kvm (env,SPR_AMR ,"AMR" ,SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_generic, -KVM_REG_PPC_AMR ,0xffffffffffffffffULL ); +KVM_REG_PPC_AMR ,0 ); spr_register_kvm(env, SPR_UAMOR, "UAMOR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic,
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 001/130] target-ppc: fix compile error when PPC_DUMP_CPU is enabled
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
Since last use of PPC_DUMP_CPU by whoever he/she was, env->tlb became a union and POWERPC CPU class got QOM'ed so defining PPC_DUMP_CPU breaks compile.
This fixes compiler errors.
--- target-ppc/translate_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target-ppc/translate_init.c +3 -2
@@ -8149,9 +8149,10 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) }printf ("PowerPC %-12s : PVR %08x MSR %016" PRIx64"\n" " MMU model : %s\n" , - pcc->name, pcc->pvr, pcc->msr_mask, mmu_model); +object_class_get_name (OBJECT_CLASS (pcc)), + pcc->pvr, pcc->msr_mask, mmu_model);#if !defined(CONFIG_USER_ONLY ) -if (env->tlb !=NULL ) { +if (env->tlb.tlb6) {printf (" %d %s TLB in %d ways\n" , env->nb_tlb, env->id_tlbs ?"splitted" :"merged" , env->nb_ways);
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 002/130] target-ppc: fix LPCR SPR number
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
PowerISA defines LPCR SPR number as 318=0x13E but QEMU uses the value of 316.
This fixes the definition of LPCR SPR.
--- target-ppc/cpu.h | 2 +- target-ppc/translate_init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
target-ppc/cpu.h +1 -1
@@ -1322,12 +1322,12 @@ static inline int cpu_mmu_index (CPUPPCState *env)#define SPR_BOOKE_IAC3 (0x13A)#define SPR_HSRR1 (0x13B)#define SPR_BOOKE_IAC4 (0x13B) -#define SPR_LPCR (0x13C)#define SPR_BOOKE_DAC1 (0x13C)#define SPR_LPIDR (0x13D)#define SPR_DABR2 (0x13D)#define SPR_BOOKE_DAC2 (0x13D)#define SPR_BOOKE_DVC1 (0x13E) +#define SPR_LPCR (0x13E)#define SPR_BOOKE_DVC2 (0x13F)#define SPR_BOOKE_TSR (0x150)#define SPR_BOOKE_TCR (0x154)
target-ppc/translate_init.c +1 -1
@@ -2578,8 +2578,8 @@ static void gen_spr_8xx (CPUPPCState *env)* HRMOR => SPR 313 (Power 2.04 hypv) * HSRR0 => SPR 314 (Power 2.04 hypv) * HSRR1 => SPR 315 (Power 2.04 hypv) -* LPCR => SPR 316 (970) * LPIDR => SPR 317 (970) +* LPCR => SPR 318 (970) * EPR => SPR 702 (Power 2.04 emb) * perf => 768-783 (Power 2.04) * perf => 784-799 (Power 2.04)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 003/130] target-ppc: remove powerpc 970gx
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
The 970GX definition was added in 2007 and it made sense then but this version has never been released to the markets and it does not exist in the real world so there is no point in emulating it.
This removes 970GX.
--- target-ppc/STATUS | 9 ---- target-ppc/cpu-models.c | 2 - target-ppc/cpu-models.h | 1 - target-ppc/translate_init.c | 100 -------------------------------------------- 4 files changed, 112 deletions(-)
target-ppc/STATUS +0 -9
@@ -377,15 +377,6 @@ MMU OK EXCP KO partially implemented Remarks: Should be able to boot but there is no hw platform currently emulated. -PowerPC 970GX: -INSN KO Altivec missing and more -SPR KO -MSR ? -IRQ OK -MMU OK -EXCP KO partially implemented -Remarks: Should be able to boot but there is no hw platform currently emulated. - PowerPC Cell: INSN KO Altivec missing and more SPR KO
target-ppc/cpu-models.c +0 -2
@@ -1156,8 +1156,6 @@ "PowerPC 970FX v3.0 (G5)") POWERPC_DEF("970fx_v3.1", CPU_POWERPC_970FX_v31, 970FX, "PowerPC 970FX v3.1 (G5)") - POWERPC_DEF("970gx", CPU_POWERPC_970GX, 970GX, - "PowerPC 970GX (G5)") POWERPC_DEF("970mp_v1.0", CPU_POWERPC_970MP_v10, 970MP, "PowerPC 970MP v1.0") POWERPC_DEF("970mp_v1.1", CPU_POWERPC_970MP_v11, 970MP,
target-ppc/cpu-models.h +0 -1
@@ -570,7 +570,6 @@ enum { CPU_POWERPC_970FX_v21 =0x003C0201 , CPU_POWERPC_970FX_v30 =0x003C0300 , CPU_POWERPC_970FX_v31 =0x003C0301 , -CPU_POWERPC_970GX =0x00450000 , CPU_POWERPC_970MP_v10 =0x00440100 , CPU_POWERPC_970MP_v11 =0x00440101 , #define CPU_POWERPC_CELL CPU_POWERPC_CELL_v32
target-ppc/translate_init.c +0 -100
106 lines not on this page · raw message
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 005/130] target-ppc: remove embedded MMU SPRs from 970, P5+/7/7+/8
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
PowerISA 2.04+ puts MMUCFG and MMUCSR0 SPRs to "E" (embedded) category so remove it from POWER7/8 class as it is "S" (server) category.
--- target-ppc/translate_init.c | 46 --------------------------------------------- 1 file changed, 46 deletions(-)
target-ppc/translate_init.c +0 -46
@@ -6661,16 +6661,6 @@ static void init_proc_970 (CPUPPCState *env)/* Memory management */ /* XXX: not correct */ gen_low_BATs (env); -/* XXX : not implemented */ -spr_register (env,SPR_MMUCFG ,"MMUCFG" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic,SPR_NOACCESS , -0x00000000 );/* TOFIX */ -/* XXX : not implemented */ -spr_register (env,SPR_MMUCSR0 ,"MMUCSR0" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, -0x00000000 );/* TOFIX */ spr_register(env, SPR_HIOR, "SPR_HIOR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_hior, &spr_write_hior,
@@ -6761,16 +6751,6 @@ static void init_proc_970FX (CPUPPCState *env)/* Memory management */ /* XXX: not correct */ gen_low_BATs (env); -/* XXX : not implemented */ -spr_register (env,SPR_MMUCFG ,"MMUCFG" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic,SPR_NOACCESS , -0x00000000 );/* TOFIX */ -/* XXX : not implemented */ -spr_register (env,SPR_MMUCSR0 ,"MMUCSR0" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, -0x00000000 );/* TOFIX */ spr_register(env, SPR_HIOR, "SPR_HIOR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_hior, &spr_write_hior,
@@ -6873,16 +6853,6 @@ static void init_proc_970MP (CPUPPCState *env)/* Memory management */ /* XXX: not correct */ gen_low_BATs (env); -/* XXX : not implemented */ -spr_register (env,SPR_MMUCFG ,"MMUCFG" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic,SPR_NOACCESS , -0x00000000 );/* TOFIX */ -/* XXX : not implemented */ -spr_register (env,SPR_MMUCSR0 ,"MMUCSR0" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, -0x00000000 );/* TOFIX */ spr_register(env, SPR_HIOR, "SPR_HIOR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_hior, &spr_write_hior,
@@ -6965,16 +6935,6 @@ static void init_proc_power5plus(CPUPPCState *env)/* Memory management */ /* XXX: not correct */ gen_low_BATs (env); -/* XXX : not implemented */ -spr_register (env,SPR_MMUCFG ,"MMUCFG" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic,SPR_NOACCESS , -0x00000000 );/* TOFIX */ -/* XXX : not implemented */ -spr_register (env,SPR_MMUCSR0 ,"MMUCSR0" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, -0x00000000 );/* TOFIX */ spr_register(env, SPR_HIOR, "SPR_HIOR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_hior, &spr_write_hior,
@@ -7077,12 +7037,6 @@ static void init_proc_POWER7 (CPUPPCState *env) &spr_read_generic, &spr_write_generic, KVM_REG_PPC_PMC6, 0x00000000);#endif /* !CONFIG_USER_ONLY */ -/* Memory management */ -/* XXX : not implemented */ -spr_register (env,SPR_MMUCFG ,"MMUCFG" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic,SPR_NOACCESS , -0x00000000 );/* TOFIX */ gen_spr_amr (env);/* XXX : not implemented */ spr_register(env, SPR_CTRL, "SPR_CTRLT",
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 012/130] PPC: KVM: fix "set one register"
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
Due to missing @one_reg_id assignment in _spr_register(), the kvm_get_one_reg/kvm_set_one_reg API has never really been working.
This reenables the API by assigning the @one_reg_id field in the SPR descriptor.
--- target-ppc/translate_init.c | 3 +++ 1 file changed, 3 insertions(+)
target-ppc/translate_init.c +3 -0
@@ -628,6 +628,9 @@ static inline void _spr_register(CPUPPCState *env, int num, spr->oea_read = oea_read; spr->oea_write = oea_write;#endif +#if defined(CONFIG_KVM ) + spr->one_reg_id = one_reg_id, +#endif env->spr[num] = initial_value; }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 011/130] mmu-hash64: fix Virtual Page Class Key Protection
In reply to Alexander GrafFrom: Cédric Le Goater <[email protected]>
commit f80872e21c07edd06eb343eeeefc8af404b518a6 (mmu-hash64: Implement Virtual Page Class Key Protection) added a new page protection mechanism based on page keys and the AMR register to control access.
The AMR register allows or prohibits reads and/or writes on a page depending on the control bits associated to the key. A store or a load is only permitted if the associate bit is 0 (Power ISA), and not 1 as the code is currently doing. This patch modifies ppc_hash64_amr_prot() to correct the protection check.
This issue was unvailed by commit ccfb53ed6360cac0d5f6f7915ca9ae7eed866412 (target-ppc: fix Authority Mask Register init value) which changed the initialisation value of the AMR register to 0.
--- target-ppc/mmu-hash64.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
target-ppc/mmu-hash64.c +12 -4
@@ -278,12 +278,12 @@ static int ppc_hash64_pte_prot(CPUPPCState *env,static int ppc_hash64_amr_prot (CPUPPCState *env,ppc_hash_pte64_t pte) {int key, amrbits; -int prot =PAGE_EXEC ; +int prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ;/* Only recent MMUs implement Virtual Page Class Key Protection */ if (!(env->mmu_model &POWERPC_MMU_AMR )) { -return PAGE_READ |PAGE_WRITE |PAGE_EXEC ; +return prot; } key =HPTE64_R_KEY (pte.pte1);
@@ -292,11 +292,19 @@ static int ppc_hash64_amr_prot(CPUPPCState *env, ppc_hash_pte64_t pte)/* fprintf(stderr, "AMR protection: key=%d AMR=0x%" PRIx64 "\n", key, */ /* env->spr[SPR_AMR]); */ +/* +* A store is permitted if the AMR bit is 0. Remove write +* protection if it is set. +*/ if (amrbits &0x2 ) { - prot |=PAGE_WRITE ; + prot &= ~PAGE_WRITE ; } +/* +* A load is permitted if the AMR bit is 0. Remove read +* protection if it is set. +*/ if (amrbits &0x1 ) { - prot |=PAGE_READ ; + prot &= ~PAGE_READ ; }return prot;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 016/130] target-ppc: disable unsupported modes for SPR_CTRL/SPR_UCTRL
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
The Figure 17 "SPR encodings" of the PowerISA 2.07 describes CTRL SPR as:
priviledged
# spr5-9 spr0-4 name mtspr mfspr len cat
136 00100 01000 CTRL - no 32 S 152 00100 11000 CTRL yes - 32 S
According to this chart, the hypervisor's CTRL (#152) does not support reading, the user-space's CTRL (UCTRL, #136) does not support writing.
This replaces unsupported operations with the default SPR_NOACCESS hook.
--- target-ppc/translate_init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target-ppc/translate_init.c +6 -6
@@ -6739,11 +6739,11 @@ static void init_proc_970FX (CPUPPCState *env) 0x00000000);spr_register (env,SPR_CTRL ,"SPR_CTRL" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, +SPR_NOACCESS , &spr_write_generic,0x00000000 );spr_register (env,SPR_UCTRL ,"SPR_UCTRL" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic,SPR_NOACCESS ,0x00000000 ); spr_register(env, SPR_VRSAVE, "SPR_VRSAVE", &spr_read_generic, &spr_write_generic,
@@ -6909,11 +6909,11 @@ static void init_proc_power5plus(CPUPPCState *env) 0x00000000);spr_register (env,SPR_CTRL ,"SPR_CTRL" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, +SPR_NOACCESS , &spr_write_generic,0x00000000 );spr_register (env,SPR_UCTRL ,"SPR_UCTRL" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic,SPR_NOACCESS ,0x00000000 ); spr_register(env, SPR_VRSAVE, "SPR_VRSAVE", &spr_read_generic, &spr_write_generic,
@@ -7014,11 +7014,11 @@ static void init_proc_POWER7 (CPUPPCState *env)/* XXX : not implemented */ spr_register (env,SPR_CTRL ,"SPR_CTRLT" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, +SPR_NOACCESS , &spr_write_generic,0x80800000 );spr_register (env,SPR_UCTRL ,"SPR_CTRLF" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic,SPR_NOACCESS ,0x80800000 ); spr_register(env, SPR_VRSAVE, "SPR_VRSAVE", &spr_read_generic, &spr_write_generic,
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 006/130] target-ppc: remove unsupported SPRs from 970 and P5+
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
SPR_750FX_HID2 and L2CR are not defined in 970* user manuals nor POWER5 bookIV nor PowerISA 2.04, the numbers assigned to them are not defined either so remove them.
--- target-ppc/translate_init.c | 39 --------------------------------------- 1 file changed, 39 deletions(-)
target-ppc/translate_init.c +0 -39
@@ -6644,20 +6644,10 @@ static void init_proc_970 (CPUPPCState *env) &spr_read_generic, &spr_write_generic, 0x00000000);/* XXX : not implemented */ -spr_register (env,SPR_750FX_HID2 ,"HID2" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, -0x00000000 ); -/* XXX : not implemented */ spr_register (env,SPR_970_HID5 ,"HID5" ,SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_generic,POWERPC970_HID5_INIT ); -/* XXX : not implemented */ -spr_register (env,SPR_L2CR ,"L2CR" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, spr_access_nop, -0x00000000 );/* Memory management */ /* XXX: not correct */ gen_low_BATs (env);
@@ -6734,20 +6724,10 @@ static void init_proc_970FX (CPUPPCState *env) &spr_read_generic, &spr_write_generic, 0x00000000);/* XXX : not implemented */ -spr_register (env,SPR_750FX_HID2 ,"HID2" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, -0x00000000 ); -/* XXX : not implemented */ spr_register (env,SPR_970_HID5 ,"HID5" ,SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_generic,POWERPC970_HID5_INIT ); -/* XXX : not implemented */ -spr_register (env,SPR_L2CR ,"L2CR" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, spr_access_nop, -0x00000000 );/* Memory management */ /* XXX: not correct */ gen_low_BATs (env);
@@ -6836,20 +6816,11 @@ static void init_proc_970MP (CPUPPCState *env) &spr_read_generic, &spr_write_generic, 0x00000000);/* XXX : not implemented */ -spr_register (env,SPR_750FX_HID2 ,"HID2" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, -0x00000000 ); -/* XXX : not implemented */ spr_register (env,SPR_970_HID5 ,"HID5" ,SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_generic,POWERPC970_HID5_INIT );/* XXX : not implemented */ -spr_register (env,SPR_L2CR ,"L2CR" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, spr_access_nop, -0x00000000 );/* Memory management */ /* XXX: not correct */ gen_low_BATs (env);
@@ -6918,20 +6889,10 @@ static void init_proc_power5plus(CPUPPCState *env) &spr_read_generic, &spr_write_generic, 0x00000000);/* XXX : not implemented */ -spr_register (env,SPR_750FX_HID2 ,"HID2" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, -0x00000000 ); -/* XXX : not implemented */ spr_register (env,SPR_970_HID5 ,"HID5" ,SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_generic,POWERPC970_HID5_INIT ); -/* XXX : not implemented */ -spr_register (env,SPR_L2CR ,"L2CR" , -SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, spr_access_nop, -0x00000000 );/* Memory management */ /* XXX: not correct */ gen_low_BATs (env);
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 007/130] KVM: Split QEMUMachine typedef into separate header
In reply to Alexander GrafOlder gcc versions (such as the one in SLES11) get confused when you declare a typedef on the same struct twice.
To work around that limitation, let's extract the QEMUMachine typedef into a separate header file that is guarded by preprocessor duplicate include checks.
This fixes the following type of compile errors for me:
In file included from vl.c:125:
include/hw/xen/xen.h:39: error: redefinition of typedef "QEMUMachine" include/sysemu/kvm.h:155: error: previous declaration of "QEMUMachine" was here
--- include/hw/boards.h | 3 +-- include/hw/xen/xen.h | 1 + include/sysemu/kvm.h | 1 + include/sysemu/qemumachine.h | 16 ++++++++++++++++ include/sysemu/qtest.h | 1 + kvm-stub.c | 1 + 6 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 include/sysemu/qemumachine.h
include/hw/boards.h +1 -2
@@ -4,10 +4,9 @@#define HW_BOARDS_H #include "sysemu/blockdev.h" +#include "sysemu/qemumachine.h" #include "hw/qdev.h" -typedef struct QEMUMachine QEMUMachine ; - typedef struct QEMUMachineInitArgs { const QEMUMachine *machine; ram_addr_t ram_size;
include/hw/xen/xen.h +1 -0
@@ -10,6 +10,7 @@#include "hw/irq.h" #include "qemu-common.h" +#include "sysemu/qemumachine.h" /* xen-machine.c */ enum xen_mode {
include/sysemu/kvm.h +1 -0
@@ -18,6 +18,7 @@#include "config-host.h" #include "qemu/queue.h" #include "qom/cpu.h" +#include "sysemu/qemumachine.h" #ifdef CONFIG_KVM #include <linux/kvm.h>
include/sysemu/qemumachine.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* QEMU Machine typedef +* +* Copyright Alexander Graf <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#ifndef QEMUMACHINE_H +#define QEMUMACHINE_H + +typedef struct QEMUMachine QEMUMachine ; + +#endif /* !QEMUMACHINE_H */
include/sysemu/qtest.h +1 -0
@@ -16,6 +16,7 @@#include "qemu-common.h" #include "qapi/error.h" +#include "sysemu/qemumachine.h" extern bool qtest_allowed;
kvm-stub.c +1 -0
@@ -14,6 +14,7 @@#include "hw/hw.h" #include "cpu.h" #include "sysemu/kvm.h" +#include "sysemu/qemumachine.h" #ifndef CONFIG_USER_ONLY #include "hw/pci/msi.h"
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 019/130] target-ppc: Add VSX ISA2.06 xadd/xsub Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the floating point addition and subtraction instructions defined by V2.06 of the PowerPC ISA: xssubdp, xvsubdp and xvsubsp.
--- target-ppc/fpu_helper.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 9 +++++++++ target-ppc/translate.c | 18 ++++++++++++++++++ 3 files changed, 77 insertions(+)
target-ppc/fpu_helper.c +50 -0
@@ -1758,3 +1758,53 @@ static void putVSR(int n, ppc_vsr_t *vsr, CPUPPCState *env) }#define float64_to_float64 (x, env) x + + +/* VSX_ADD_SUB - VSX floating point add/subract +* name - instruction mnemonic +* op - operation (add or sub) +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* sfprf - set FPRF +*/ +#define VSX_ADD_SUB (name, op, nels, tp, fld, sfprf) \ +void helper_##name(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xa, xb; \ + int i; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + helper_reset_fpstatus(env); \ + \ + for (i = 0; i < nels; i++) { \ + float_status tstat = env->fp_status; \ + set_float_exception_flags(0, &tstat); \ + xt.fld[i] = tp##_##op(xa.fld[i], xb.fld[i], &tstat); \ + env->fp_status.float_exception_flags |= tstat.float_exception_flags; \ + \ + if (unlikely(tstat.float_exception_flags & float_flag_invalid)) { \ + if (tp##_is_infinity(xa.fld[i]) && tp##_is_infinity(xb.fld[i])) {\ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI, sfprf); \ + } else if (tp##_is_signaling_nan(xa.fld[i]) || \ + tp##_is_signaling_nan(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, sfprf); \ + } \ + } \ + \ + if (sfprf) { \ + helper_compute_fprf(env, xt.fld[i], sfprf); \ + } \ + } \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_ADD_SUB(xsadddp, add, 1, float64, f64, 1) +VSX_ADD_SUB(xvadddp, add, 2, float64, f64, 0) +VSX_ADD_SUB(xvaddsp, add, 4, float32, f32, 0) +VSX_ADD_SUB(xssubdp, sub, 1, float64, f64, 1) +VSX_ADD_SUB(xvsubdp, sub, 2, float64, f64, 0) +VSX_ADD_SUB (xvsubsp, sub,4 , float32, f32,0 )
target-ppc/helper.h +9 -0
@@ -251,6 +251,15 @@ DEF_HELPER_4(vcfsx, void, env, avr, avr, i32) DEF_HELPER_4(vctuxs, void, env, avr, avr, i32) DEF_HELPER_4(vctsxs, void, env, avr, avr, i32) +DEF_HELPER_2(xsadddp, void, env, i32) +DEF_HELPER_2(xssubdp, void, env, i32) + +DEF_HELPER_2(xvadddp, void, env, i32) +DEF_HELPER_2(xvsubdp, void, env, i32) + +DEF_HELPER_2(xvaddsp, void, env, i32) +DEF_HELPER_2(xvsubsp, void, env, i32) + DEF_HELPER_2(efscfsi, i32, env, i32) DEF_HELPER_2(efscfui, i32, env, i32)DEF_HELPER_2 (efscfuf, i32, env, i32)
target-ppc/translate.c +18 -0
@@ -7304,6 +7304,15 @@ static void gen_##name(DisasContext * ctx) \tcg_temp_free_i32 (opc); \ } +GEN_VSX_HELPER_2(xsadddp, 0x00, 0x04, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xssubdp, 0x00, 0x05, 0, PPC2_VSX) + +GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvsubdp, 0x00, 0x0D, 0, PPC2_VSX) + +GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvsubsp, 0x00, 0x09, 0, PPC2_VSX) +#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \ { \
@@ -9985,6 +9994,15 @@ GEN_XX2FORM(xvnabssp, 0x12, 0x1A, PPC2_VSX),GEN_XX2FORM (xvnegsp,0x12 ,0x1B ,PPC2_VSX ),GEN_XX3FORM (xvcpsgnsp,0x00 ,0x1A ,PPC2_VSX ), +GEN_XX3FORM (xsadddp,0x00 ,0x04 ,PPC2_VSX ), +GEN_XX3FORM (xssubdp,0x00 ,0x05 ,PPC2_VSX ), + +GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), +GEN_XX3FORM (xvsubdp,0x00 ,0x0D ,PPC2_VSX ), + +GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ), +GEN_XX3FORM (xvsubsp,0x00 ,0x09 ,PPC2_VSX ), + #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \GEN_XX3FORM (name, opc2, opc3, fl2)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 027/130] target-ppc: Add VSX ISA2.06 Multiply Add Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point multiply/add instructions defined by V2.06 of the PowerPC ISA:
- xsmaddadp, xvmaddadp, xvmaddasp - xsmaddmdp, xvmaddmdp, xvmaddmsp - xsmsubadp, xvmsubadp, xvmsubasp - xsmsubmdp, xvmsubmdp, xvmsubmsp
- xsnmaddadp, xvnmaddadp, xvnmaddasp
- xsnmaddmdp, xvnmaddmdp, xvnmaddmsp
- xsnmsubadp, xvnmsubadp, xvnmsubasp
- xsnmsubmdp, xvnmsubmdp, xvnmsubmsp
--- target-ppc/fpu_helper.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 24 ++++++++++++ target-ppc/translate.c | 48 +++++++++++++++++++++++ 3 files changed, 172 insertions(+)
target-ppc/fpu_helper.c +100 -0
@@ -2149,3 +2149,103 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ VSX_TSQRT(xstsqrtdp, 1, float64, f64, -1022, 52) VSX_TSQRT(xvtsqrtdp, 2, float64, f64, -1022, 52)VSX_TSQRT (xvtsqrtsp,4 , float32, f32,-126 ,23 ) + +/* VSX_MADD - VSX floating point muliply/add variations +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* maddflgs - flags for the float*muladd routine that control the +* various forms (madd, msub, nmadd, nmsub) +* afrm - A form (1=A, 0=M) +* sfprf - set FPRF + */ +#define VSX_MADD (op, nels, tp, fld, maddflgs, afrm, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt_in, xa, xb, xt_out; \ + ppc_vsr_t *b, *c; \ + int i; \ + \ + if (afrm) {/* AxB + T */ \ + b = &xb; \ + c = &xt_in; \ + } else { /* AxT + B */ \ + b = &xt_in; \ + c = &xb; \ + } \ + \ +getVSR (xA (opcode), &xa, env); \ +getVSR (xB (opcode), &xb, env); \ +getVSR (xT (opcode), &xt_in, env); \ + \ + xt_out = xt_in; \ + \ +helper_reset_fpstatus (env); \ + \ + for (i = 0; i < nels; i++) { \ + float_status tstat = env->fp_status; \ + set_float_exception_flags(0, &tstat); \ + xt_out.fld[i] = tp##_muladd(xa.fld[i], b->fld[i], c->fld[i], \ + maddflgs, &tstat); \ + env->fp_status.float_exception_flags |= tstat.float_exception_flags; \ + \ + if (unlikely(tstat.float_exception_flags & float_flag_invalid)) { \ + if (tp##_is_signaling_nan(xa.fld[i]) || \ + tp##_is_signaling_nan(b->fld[i]) || \ + tp##_is_signaling_nan(c->fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, sfprf); \ + tstat.float_exception_flags &= ~float_flag_invalid; \ + } \ + if ((tp##_is_infinity(xa.fld[i]) && tp##_is_zero(b->fld[i])) || \ + (tp##_is_zero(xa.fld[i]) && tp##_is_infinity(b->fld[i]))) { \ + xt_out.fld[i] = float64_to_##tp(fload_invalid_op_excp(env, \ + POWERPC_EXCP_FP_VXIMZ, sfprf), &env->fp_status); \ + tstat.float_exception_flags &= ~float_flag_invalid; \ + } \ + if ((tstat.float_exception_flags & float_flag_invalid) && \ + ((tp##_is_infinity(xa.fld[i]) || \ + tp##_is_infinity(b->fld[i])) && \ + tp##_is_infinity(c->fld[i]))) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI, sfprf); \ + } \ + } \ + if (sfprf) { \ + helper_compute_fprf(env, xt_out.fld[i], sfprf); \ + } \ + } \ + putVSR(xT(opcode), &xt_out, env); \ + helper_float_check_status(env); \ +} + +#define MADD_FLGS 0 +#define MSUB_FLGS float_muladd_negate_c +#define NMADD_FLGS float_muladd_negate_result +#define NMSUB_FLGS (float_muladd_negate_c | float_muladd_negate_result) + +VSX_MADD(xsmaddadp, 1, float64, f64, MADD_FLGS, 1, 1) +VSX_MADD(xsmaddmdp, 1, float64, f64, MADD_FLGS, 0, 1) +VSX_MADD(xsmsubadp, 1, float64, f64, MSUB_FLGS, 1, 1) +VSX_MADD(xsmsubmdp, 1, float64, f64, MSUB_FLGS, 0, 1) +VSX_MADD(xsnmaddadp, 1, float64, f64, NMADD_FLGS, 1, 1) +VSX_MADD(xsnmaddmdp, 1, float64, f64, NMADD_FLGS, 0, 1) +VSX_MADD(xsnmsubadp, 1, float64, f64, NMSUB_FLGS, 1, 1) +VSX_MADD(xsnmsubmdp, 1, float64, f64, NMSUB_FLGS, 0, 1) + +VSX_MADD(xvmaddadp, 2, float64, f64, MADD_FLGS, 1, 0) +VSX_MADD(xvmaddmdp, 2, float64, f64, MADD_FLGS, 0, 0) +VSX_MADD(xvmsubadp, 2, float64, f64, MSUB_FLGS, 1, 0) +VSX_MADD(xvmsubmdp, 2, float64, f64, MSUB_FLGS, 0, 0) +VSX_MADD(xvnmaddadp, 2, float64, f64, NMADD_FLGS, 1, 0) +VSX_MADD(xvnmaddmdp, 2, float64, f64, NMADD_FLGS, 0, 0) +VSX_MADD(xvnmsubadp, 2, float64, f64, NMSUB_FLGS, 1, 0) +VSX_MADD(xvnmsubmdp, 2, float64, f64, NMSUB_FLGS, 0, 0) + +VSX_MADD(xvmaddasp, 4, float32, f32, MADD_FLGS, 1, 0) +VSX_MADD(xvmaddmsp, 4, float32, f32, MADD_FLGS, 0, 0) +VSX_MADD(xvmsubasp, 4, float32, f32, MSUB_FLGS, 1, 0) +VSX_MADD(xvmsubmsp, 4, float32, f32, MSUB_FLGS, 0, 0) +VSX_MADD(xvnmaddasp, 4, float32, f32, NMADD_FLGS, 1, 0) +VSX_MADD(xvnmaddmsp, 4, float32, f32, NMADD_FLGS, 0, 0) +VSX_MADD(xvnmsubasp, 4, float32, f32, NMSUB_FLGS, 1, 0) +VSX_MADD(xvnmsubmsp, 4, float32, f32, NMSUB_FLGS, 0, 0)
target-ppc/helper.h +24 -0
@@ -260,6 +260,14 @@ DEF_HELPER_2(xssqrtdp, void, env, i32) DEF_HELPER_2(xsrsqrtedp, void, env, i32) DEF_HELPER_2(xstdivdp, void, env, i32) DEF_HELPER_2(xstsqrtdp, void, env, i32) +DEF_HELPER_2(xsmaddadp, void, env, i32) +DEF_HELPER_2(xsmaddmdp, void, env, i32) +DEF_HELPER_2(xsmsubadp, void, env, i32) +DEF_HELPER_2(xsmsubmdp, void, env, i32) +DEF_HELPER_2(xsnmaddadp, void, env, i32) +DEF_HELPER_2(xsnmaddmdp, void, env, i32) +DEF_HELPER_2(xsnmsubadp, void, env, i32) +DEF_HELPER_2(xsnmsubmdp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
@@ -270,6 +278,14 @@ DEF_HELPER_2(xvsqrtdp, void, env, i32) DEF_HELPER_2(xvrsqrtedp, void, env, i32) DEF_HELPER_2(xvtdivdp, void, env, i32) DEF_HELPER_2(xvtsqrtdp, void, env, i32) +DEF_HELPER_2(xvmaddadp, void, env, i32) +DEF_HELPER_2(xvmaddmdp, void, env, i32) +DEF_HELPER_2(xvmsubadp, void, env, i32) +DEF_HELPER_2(xvmsubmdp, void, env, i32) +DEF_HELPER_2(xvnmaddadp, void, env, i32) +DEF_HELPER_2(xvnmaddmdp, void, env, i32) +DEF_HELPER_2(xvnmsubadp, void, env, i32) +DEF_HELPER_2(xvnmsubmdp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -280,6 +296,14 @@ DEF_HELPER_2(xvsqrtsp, void, env, i32) DEF_HELPER_2(xvrsqrtesp, void, env, i32) DEF_HELPER_2(xvtdivsp, void, env, i32) DEF_HELPER_2(xvtsqrtsp, void, env, i32) +DEF_HELPER_2(xvmaddasp, void, env, i32) +DEF_HELPER_2(xvmaddmsp, void, env, i32) +DEF_HELPER_2(xvmsubasp, void, env, i32) +DEF_HELPER_2(xvmsubmsp, void, env, i32) +DEF_HELPER_2(xvnmaddasp, void, env, i32) +DEF_HELPER_2(xvnmaddmsp, void, env, i32) +DEF_HELPER_2(xvnmsubasp, void, env, i32) +DEF_HELPER_2(xvnmsubmsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +48 -0
84 lines not on this page · raw message
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 014/130] spapr-pci: enable adding PHB via -device
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
Recent changes introduced cannot_instantiate_with_device_add_yet and removed capability of adding yet another PCI host bridge via command line for SPAPR platform (POWERPC64 server).
This brings the capability back and puts SPAPR PHB into "bridge" category.
This is not much use for emulated PHB but it is absolutely required for VFIO as we put an IOMMU group onto a separate PHB on SPAPR.
--- hw/ppc/spapr_pci.c | 2 ++ 1 file changed, 2 insertions(+)
hw/ppc/spapr_pci.c +2 -0
@@ -728,6 +728,8 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data) dc->props = spapr_phb_properties; dc->reset = spapr_phb_reset; dc->vmsd = &vmstate_spapr_pci; +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + dc->cannot_instantiate_with_device_add_yet = false; }static const TypeInfo spapr_phb_info = {
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 021/130] target-ppc: Add VSX ISA2.06 xdiv Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point divide instructions defined by V2.06 of the PowerPC ISA: xsdivdp, xvdivdp, xvdivsp.
--- target-ppc/fpu_helper.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 3 +++ target-ppc/translate.c | 6 ++++++ 3 files changed, 58 insertions(+)
target-ppc/fpu_helper.c +49 -0
@@ -1855,3 +1855,52 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ VSX_MUL(xsmuldp, 1, float64, f64, 1) VSX_MUL(xvmuldp, 2, float64, f64, 0)VSX_MUL (xvmulsp,4 , float32, f32,0 ) + +/* VSX_DIV - VSX floating point divide +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* sfprf - set FPRF + */ +#define VSX_DIV (op, nels, tp, fld, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xa, xb; \ + int i; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + helper_reset_fpstatus(env); \ + \ + for (i = 0; i < nels; i++) { \ + float_status tstat = env->fp_status; \ + set_float_exception_flags(0, &tstat); \ + xt.fld[i] = tp##_div(xa.fld[i], xb.fld[i], &tstat); \ + env->fp_status.float_exception_flags |= tstat.float_exception_flags; \ + \ + if (unlikely(tstat.float_exception_flags & float_flag_invalid)) { \ + if (tp##_is_infinity(xa.fld[i]) && tp##_is_infinity(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXIDI, sfprf); \ + } else if (tp##_is_zero(xa.fld[i]) && \ + tp##_is_zero(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXZDZ, sfprf); \ + } else if (tp##_is_signaling_nan(xa.fld[i]) || \ + tp##_is_signaling_nan(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, sfprf); \ + } \ + } \ + \ + if (sfprf) { \ + helper_compute_fprf(env, xt.fld[i], sfprf); \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_DIV(xsdivdp, 1, float64, f64, 1) +VSX_DIV(xvdivdp, 2, float64, f64, 0) +VSX_DIV (xvdivsp,4 , float32, f32,0 )
target-ppc/helper.h +3 -0
@@ -254,14 +254,17 @@ DEF_HELPER_4(vctsxs, void, env, avr, avr, i32) DEF_HELPER_2(xsadddp, void, env, i32) DEF_HELPER_2(xssubdp, void, env, i32) DEF_HELPER_2(xsmuldp, void, env, i32) +DEF_HELPER_2(xsdivdp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32) DEF_HELPER_2(xvsubdp, void, env, i32) DEF_HELPER_2(xvmuldp, void, env, i32) +DEF_HELPER_2(xvdivdp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32) DEF_HELPER_2(xvsubsp, void, env, i32) DEF_HELPER_2(xvmulsp, void, env, i32) +DEF_HELPER_2(xvdivsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +6 -0
@@ -7307,14 +7307,17 @@ static void gen_##name(DisasContext * ctx) \ GEN_VSX_HELPER_2(xsadddp, 0x00, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xssubdp, 0x00, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsmuldp, 0x00, 0x06, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsdivdp, 0x00, 0x07, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubdp, 0x00, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmuldp, 0x00, 0x0E, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvdivdp, 0x00, 0x0F, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubsp, 0x00, 0x09, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmulsp, 0x00, 0x0A, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvdivsp, 0x00, 0x0B, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10000,14 +10003,17 @@ GEN_XX3FORM(xvcpsgnsp, 0x00, 0x1A, PPC2_VSX),GEN_XX3FORM (xsadddp,0x00 ,0x04 ,PPC2_VSX ),GEN_XX3FORM (xssubdp,0x00 ,0x05 ,PPC2_VSX ),GEN_XX3FORM (xsmuldp,0x00 ,0x06 ,PPC2_VSX ), +GEN_XX3FORM (xsdivdp,0x00 ,0x07 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ),GEN_XX3FORM (xvsubdp,0x00 ,0x0D ,PPC2_VSX ),GEN_XX3FORM (xvmuldp,0x00 ,0x0E ,PPC2_VSX ), +GEN_XX3FORM (xvdivdp,0x00 ,0x0F ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ),GEN_XX3FORM (xvsubsp,0x00 ,0x09 ,PPC2_VSX ),GEN_XX3FORM (xvmulsp,0x00 ,0x0A ,PPC2_VSX ), +GEN_XX3FORM (xvdivsp,0x00 ,0x0B ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 031/130] target-ppc: Add VSX Floating Point to Floating Point Conversion Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX instructions that convert between floating point formats: xscvdpsp, xscvspdp, xvcvdpsp, xvcvspdp.
--- target-ppc/fpu_helper.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 4 ++++ target-ppc/translate.c | 8 ++++++++ 3 files changed, 58 insertions(+)
target-ppc/fpu_helper.c +46 -0
@@ -2384,3 +2384,49 @@ VSX_CMP(xvcmpgtdp, 2, float64, f64, lt, 1) VSX_CMP(xvcmpeqsp, 4, float32, f32, eq, 0) VSX_CMP(xvcmpgesp, 4, float32, f32, le, 1) VSX_CMP(xvcmpgtsp, 4, float32, f32, lt, 1) + +#if defined(HOST_WORDS_BIGENDIAN ) +#define JOFFSET 0 +#else +#define JOFFSET 1 +#endif + +/* VSX_CVT_FP_TO_FP - VSX floating point/floating point conversion +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* stp - source type (float32 or float64) +* ttp - target type (float32 or float64) +* sfld - source vsr_t field +* tfld - target vsr_t field (f32 or f64) +* sfprf - set FPRF +*/ +#define VSX_CVT_FP_TO_FP (op, nels, stp, ttp, sfld, tfld, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xb; \ + int i; \ + \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + \ + for (i = 0; i < nels; i++) { \ + int j = 2*i + JOFFSET; \ + xt.tfld = stp##_to_##ttp(xb.sfld, &env->fp_status); \ + if (unlikely(stp##_is_signaling_nan(xb.sfld))) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0); \ + xt.tfld = ttp##_snan_to_qnan(xt.tfld); \ + } \ + if (sfprf) { \ + helper_compute_fprf(env, ttp##_to_float64(xt.tfld, \ + &env->fp_status), sfprf); \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_CVT_FP_TO_FP(xscvdpsp, 1, float64, float32, f64[i], f32[j], 1) +VSX_CVT_FP_TO_FP(xscvspdp, 1, float32, float64, f32[j], f64[i], 1) +VSX_CVT_FP_TO_FP(xvcvdpsp, 2, float64, float32, f64[i], f32[j], 0) +VSX_CVT_FP_TO_FP (xvcvspdp,2 , float32, float64, f32[j], f64[i],0 )
target-ppc/helper.h +4 -0
@@ -272,6 +272,8 @@ DEF_HELPER_2(xscmpodp, void, env, i32) DEF_HELPER_2(xscmpudp, void, env, i32) DEF_HELPER_2(xsmaxdp, void, env, i32) DEF_HELPER_2(xsmindp, void, env, i32) +DEF_HELPER_2(xscvdpsp, void, env, i32) +DEF_HELPER_2(xscvspdp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
@@ -295,6 +297,7 @@ DEF_HELPER_2(xvmindp, void, env, i32) DEF_HELPER_2(xvcmpeqdp, void, env, i32) DEF_HELPER_2(xvcmpgedp, void, env, i32) DEF_HELPER_2(xvcmpgtdp, void, env, i32) +DEF_HELPER_2(xvcvdpsp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -318,6 +321,7 @@ DEF_HELPER_2(xvminsp, void, env, i32) DEF_HELPER_2(xvcmpeqsp, void, env, i32) DEF_HELPER_2(xvcmpgesp, void, env, i32) DEF_HELPER_2(xvcmpgtsp, void, env, i32) +DEF_HELPER_2(xvcvspdp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +8 -0
@@ -7325,6 +7325,8 @@ GEN_VSX_HELPER_2(xscmpodp, 0x0C, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscmpudp, 0x0C, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsmaxdp, 0x00, 0x14, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsmindp, 0x00, 0x15, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xscvdpsp, 0x12, 0x10, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xscvspdp, 0x12, 0x14, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -7348,6 +7350,7 @@ GEN_VSX_HELPER_2(xvmindp, 0x00, 0x1D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpeqdp, 0x0C, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpgtdp, 0x0C, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpgedp, 0x0C, 0x0E, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcvdpsp, 0x12, 0x18, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubsp,0x00 ,0x09 ,0 ,PPC2_VSX )
@@ -7371,6 +7374,7 @@ GEN_VSX_HELPER_2(xvminsp, 0x00, 0x19, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpeqsp, 0x0C, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpgtsp, 0x0C, 0x09, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpgesp, 0x0C, 0x0A, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcvspdp, 0x12, 0x1C, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10085,6 +10089,8 @@ GEN_XX2FORM(xscmpodp, 0x0C, 0x05, PPC2_VSX),GEN_XX2FORM (xscmpudp,0x0C ,0x04 ,PPC2_VSX ),GEN_XX3FORM (xsmaxdp,0x00 ,0x14 ,PPC2_VSX ),GEN_XX3FORM (xsmindp,0x00 ,0x15 ,PPC2_VSX ), +GEN_XX2FORM (xscvdpsp,0x12 ,0x10 ,PPC2_VSX ), +GEN_XX2FORM (xscvspdp,0x12 ,0x14 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
@@ -10108,6 +10114,7 @@ GEN_XX3FORM(xvmindp, 0x00, 0x1D, PPC2_VSX),GEN_XX3_RC_FORM (xvcmpeqdp,0x0C ,0x0C ,PPC2_VSX ),GEN_XX3_RC_FORM (xvcmpgtdp,0x0C ,0x0D ,PPC2_VSX ),GEN_XX3_RC_FORM (xvcmpgedp,0x0C ,0x0E ,PPC2_VSX ), +GEN_XX2FORM (xvcvdpsp,0x12 ,0x18 ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ), GEN_XX3FORM(xvsubsp, 0x00, 0x09, PPC2_VSX),
@@ -10131,6 +10138,7 @@ GEN_XX3FORM(xvminsp, 0x00, 0x19, PPC2_VSX),GEN_XX3_RC_FORM (xvcmpeqsp,0x0C ,0x08 ,PPC2_VSX ),GEN_XX3_RC_FORM (xvcmpgtsp,0x0C ,0x09 ,PPC2_VSX ),GEN_XX3_RC_FORM (xvcmpgesp,0x0C ,0x0A ,PPC2_VSX ), +GEN_XX2FORM (xvcvspdp,0x12 ,0x1C ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 013/130] PPC: KVM: add support for LPCR
In reply to Alexander GrafFrom: Greg Kurz <[email protected]>
The LPCR special purpose register was introduced with the PowerPC 970MP family.
This patch initializes LPCR for the following families:
- 970 MP
- POWER5+
- POWER7
- POWER8
--- target-ppc/translate_init.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
target-ppc/translate_init.c +15 -1
@@ -2582,7 +2582,6 @@ static void gen_spr_8xx (CPUPPCState *env)* HSRR0 => SPR 314 (Power 2.04 hypv) * HSRR1 => SPR 315 (Power 2.04 hypv) * LPIDR => SPR 317 (970) -* LPCR => SPR 318 (970) * EPR => SPR 702 (Power 2.04 emb) * perf => 768-783 (Power 2.04) * perf => 784-799 (Power 2.04)
@@ -6831,6 +6830,11 @@ static void init_proc_970MP (CPUPPCState *env)SPR_NOACCESS ,SPR_NOACCESS , &spr_read_hior, &spr_write_hior, 0x00000000); +/* Logical partitionning */ +spr_register_kvm (env,SPR_LPCR ,"LPCR" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic, +KVM_REG_PPC_LPCR ,0x00000000 );#if !defined(CONFIG_USER_ONLY ) env->slb_nr =32 ;#endif
@@ -6915,6 +6919,11 @@ static void init_proc_power5plus(CPUPPCState *env) &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); +/* Logical partitionning */ +spr_register_kvm (env,SPR_LPCR ,"LPCR" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic, +KVM_REG_PPC_LPCR ,0x00000000 );#if !defined(CONFIG_USER_ONLY ) env->slb_nr =64 ;#endif
@@ -7019,6 +7028,11 @@ static void init_proc_POWER7 (CPUPPCState *env) &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); +/* Logical partitionning */ +spr_register_kvm (env,SPR_LPCR ,"LPCR" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic, +KVM_REG_PPC_LPCR ,0x00000000 );#if !defined(CONFIG_USER_ONLY ) env->slb_nr =32 ;#endif
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 025/130] target-ppc: Add VSX ISA2.06 xtdiv Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point test for software divide instructions defined by V2.06 of the PowerPC ISA: xstdivdp, xvtdivdp, and xvtdivsp.
--- target-ppc/fpu_helper.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 3 +++ target-ppc/translate.c | 6 +++++ 3 files changed, 76 insertions(+)
target-ppc/fpu_helper.c +67 -0
@@ -2028,3 +2028,70 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ VSX_RSQRTE(xsrsqrtedp, 1, float64, f64, 1) VSX_RSQRTE(xvrsqrtedp, 2, float64, f64, 0) VSX_RSQRTE(xvrsqrtesp, 4, float32, f32, 0) + +static inline int ppc_float32_get_unbiased_exp (float32 f) +{ +return ((f >>23 ) &0xFF ) -127 ; +} + +static inline int ppc_float64_get_unbiased_exp (float64 f) +{ +return ((f >>52 ) &0x7FF ) -1023 ; +} + +/* VSX_TDIV - VSX floating point test for divide +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* emin - minimum unbiased exponent +* emax - maximum unbiased exponent +* nbits - number of fraction bits +*/ +#define VSX_TDIV (op, nels, tp, fld, emin, emax, nbits) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xa, xb; \ + int i; \ + int fe_flag = 0; \ + int fg_flag = 0; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + \ + for (i = 0; i < nels; i++) { \ + if (unlikely(tp##_is_infinity(xa.fld[i]) || \ + tp##_is_infinity(xb.fld[i]) || \ + tp##_is_zero(xb.fld[i]))) { \ + fe_flag = 1; \ + fg_flag = 1; \ + } else { \ + int e_a = ppc_##tp##_get_unbiased_exp(xa.fld[i]); \ + int e_b = ppc_##tp##_get_unbiased_exp(xb.fld[i]); \ + \ + if (unlikely(tp##_is_any_nan(xa.fld[i]) || \ + tp##_is_any_nan(xb.fld[i]))) { \ + fe_flag = 1; \ + } else if ((e_b <= emin) || (e_b >= (emax-2))) { \ + fe_flag = 1; \ + } else if (!tp##_is_zero(xa.fld[i]) && \ + (((e_a - e_b) >= emax) || \ + ((e_a - e_b) <= (emin+1)) || \ + (e_a <= (emin+nbits)))) { \ + fe_flag = 1; \ + } \ + \ + if (unlikely(tp##_is_zero_or_denormal(xb.fld[i]))) { \ +/* XB is not zero because of the above check and */ \ +/* so must be denormalized. */ \ + fg_flag =1 ; \ + } \ + } \ + } \ + \ + env->crf[BF (opcode)] =0x8 | (fg_flag ?4 :0 ) | (fe_flag ?2 :0 ); \ +} + +VSX_TDIV(xstdivdp, 1, float64, f64, -1022, 1023, 52) +VSX_TDIV(xvtdivdp, 2, float64, f64, -1022, 1023, 52) +VSX_TDIV (xvtdivsp,4 , float32, f32,-126 ,127 ,23 )
target-ppc/helper.h +3 -0
@@ -258,6 +258,7 @@ DEF_HELPER_2(xsdivdp, void, env, i32) DEF_HELPER_2(xsredp, void, env, i32) DEF_HELPER_2(xssqrtdp, void, env, i32) DEF_HELPER_2(xsrsqrtedp, void, env, i32) +DEF_HELPER_2(xstdivdp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
@@ -266,6 +267,7 @@ DEF_HELPER_2(xvdivdp, void, env, i32) DEF_HELPER_2(xvredp, void, env, i32) DEF_HELPER_2(xvsqrtdp, void, env, i32) DEF_HELPER_2(xvrsqrtedp, void, env, i32) +DEF_HELPER_2(xvtdivdp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -274,6 +276,7 @@ DEF_HELPER_2(xvdivsp, void, env, i32) DEF_HELPER_2(xvresp, void, env, i32) DEF_HELPER_2(xvsqrtsp, void, env, i32) DEF_HELPER_2(xvrsqrtesp, void, env, i32) +DEF_HELPER_2(xvtdivsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +6 -0
@@ -7311,6 +7311,7 @@ GEN_VSX_HELPER_2(xsdivdp, 0x00, 0x07, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsredp, 0x14, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xssqrtdp, 0x16, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsrsqrtedp, 0x14, 0x04, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xstdivdp, 0x14, 0x07, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -7319,6 +7320,7 @@ GEN_VSX_HELPER_2(xvdivdp, 0x00, 0x0F, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvredp, 0x14, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsqrtdp, 0x16, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvrsqrtedp, 0x14, 0x0C, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvtdivdp, 0x14, 0x0F, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubsp,0x00 ,0x09 ,0 ,PPC2_VSX )
@@ -7327,6 +7329,7 @@ GEN_VSX_HELPER_2(xvdivsp, 0x00, 0x0B, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvresp, 0x14, 0x09, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsqrtsp, 0x16, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvrsqrtesp, 0x14, 0x08, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvtdivsp, 0x14, 0x0B, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10016,6 +10019,7 @@ GEN_XX3FORM(xsdivdp, 0x00, 0x07, PPC2_VSX),GEN_XX2FORM (xsredp,0x14 ,0x05 ,PPC2_VSX ),GEN_XX2FORM (xssqrtdp,0x16 ,0x04 ,PPC2_VSX ),GEN_XX2FORM (xsrsqrtedp,0x14 ,0x04 ,PPC2_VSX ), +GEN_XX3FORM (xstdivdp,0x14 ,0x07 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
@@ -10024,6 +10028,7 @@ GEN_XX3FORM(xvdivdp, 0x00, 0x0F, PPC2_VSX),GEN_XX2FORM (xvredp,0x14 ,0x0D ,PPC2_VSX ),GEN_XX2FORM (xvsqrtdp,0x16 ,0x0C ,PPC2_VSX ),GEN_XX2FORM (xvrsqrtedp,0x14 ,0x0C ,PPC2_VSX ), +GEN_XX3FORM (xvtdivdp,0x14 ,0x0F ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ), GEN_XX3FORM(xvsubsp, 0x00, 0x09, PPC2_VSX),
@@ -10032,6 +10037,7 @@ GEN_XX3FORM(xvdivsp, 0x00, 0x0B, PPC2_VSX),GEN_XX2FORM (xvresp,0x14 ,0x09 ,PPC2_VSX ),GEN_XX2FORM (xvsqrtsp,0x16 ,0x08 ,PPC2_VSX ),GEN_XX2FORM (xvrsqrtesp,0x14 ,0x08 ,PPC2_VSX ), +GEN_XX3FORM (xvtdivsp,0x14 ,0x0B ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 029/130] target-ppc: Add VSX xmax/xmin Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point maximum and minimum instructions:
- xsmaxdp, xvmaxdp, xvmaxsp
- xsmindp, xvmindp, xvminsp
Because of the Power ISA definitions of maximum and minimum on various boundary cases, the standard softfloat comparison routines (e.g. float64_lt) do not work as well as one might think. Therefore specific routines for comparing 64 and 32 bit floating point numbers are implemented in the PowerPC helper code.
--- target-ppc/fpu_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 6 ++++++ target-ppc/translate.c | 12 ++++++++++++ 3 files changed, 57 insertions(+)
target-ppc/fpu_helper.c +39 -0
@@ -2288,3 +2288,42 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ VSX_SCALAR_CMP(xscmpodp, 1) VSX_SCALAR_CMP(xscmpudp, 0) + +#define float64_snan_to_qnan (x) ((x) | 0x0008000000000000ul) +#define float32_snan_to_qnan (x) ((x) | 0x00400000) + +/* VSX_MAX_MIN - VSX floating point maximum/minimum +* name - instruction mnemonic +* op - operation (max or min) +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +*/ +#define VSX_MAX_MIN (name, op, nels, tp, fld) \ +void helper_##name(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xa, xb; \ + int i; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + \ + for (i = 0; i < nels; i++) { \ + xt.fld[i] = tp##_##op(xa.fld[i], xb.fld[i], &env->fp_status); \ + if (unlikely(tp##_is_signaling_nan(xa.fld[i]) || \ + tp##_is_signaling_nan(xb.fld[i]))) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0); \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_MAX_MIN(xsmaxdp, maxnum, 1, float64, f64) +VSX_MAX_MIN(xvmaxdp, maxnum, 2, float64, f64) +VSX_MAX_MIN(xvmaxsp, maxnum, 4, float32, f32) +VSX_MAX_MIN(xsmindp, minnum, 1, float64, f64) +VSX_MAX_MIN(xvmindp, minnum, 2, float64, f64) +VSX_MAX_MIN (xvminsp, minnum,4 , float32, f32)
target-ppc/helper.h +6 -0
@@ -270,6 +270,8 @@ DEF_HELPER_2(xsnmsubadp, void, env, i32) DEF_HELPER_2(xsnmsubmdp, void, env, i32) DEF_HELPER_2(xscmpodp, void, env, i32) DEF_HELPER_2(xscmpudp, void, env, i32) +DEF_HELPER_2(xsmaxdp, void, env, i32) +DEF_HELPER_2(xsmindp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
@@ -288,6 +290,8 @@ DEF_HELPER_2(xvnmaddadp, void, env, i32) DEF_HELPER_2(xvnmaddmdp, void, env, i32) DEF_HELPER_2(xvnmsubadp, void, env, i32) DEF_HELPER_2(xvnmsubmdp, void, env, i32) +DEF_HELPER_2(xvmaxdp, void, env, i32) +DEF_HELPER_2(xvmindp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -306,6 +310,8 @@ DEF_HELPER_2(xvnmaddasp, void, env, i32) DEF_HELPER_2(xvnmaddmsp, void, env, i32) DEF_HELPER_2(xvnmsubasp, void, env, i32) DEF_HELPER_2(xvnmsubmsp, void, env, i32) +DEF_HELPER_2(xvmaxsp, void, env, i32) +DEF_HELPER_2(xvminsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +12 -0
@@ -7323,6 +7323,8 @@ GEN_VSX_HELPER_2(xsnmsubadp, 0x04, 0x16, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsnmsubmdp, 0x04, 0x17, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscmpodp, 0x0C, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscmpudp, 0x0C, 0x04, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsmaxdp, 0x00, 0x14, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsmindp, 0x00, 0x15, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -7341,6 +7343,8 @@ GEN_VSX_HELPER_2(xvnmaddadp, 0x04, 0x1C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvnmaddmdp, 0x04, 0x1D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvnmsubadp, 0x04, 0x1E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvnmsubmdp, 0x04, 0x1F, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvmaxdp, 0x00, 0x1C, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvmindp, 0x00, 0x1D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubsp,0x00 ,0x09 ,0 ,PPC2_VSX )
@@ -7359,6 +7363,8 @@ GEN_VSX_HELPER_2(xvnmaddasp, 0x04, 0x18, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvnmaddmsp, 0x04, 0x19, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvnmsubasp, 0x04, 0x1A, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvnmsubmsp, 0x04, 0x1B, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvmaxsp, 0x00, 0x18, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvminsp, 0x00, 0x19, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10060,6 +10066,8 @@ GEN_XX3FORM(xsnmsubadp, 0x04, 0x16, PPC2_VSX),GEN_XX3FORM (xsnmsubmdp,0x04 ,0x17 ,PPC2_VSX ),GEN_XX2FORM (xscmpodp,0x0C ,0x05 ,PPC2_VSX ),GEN_XX2FORM (xscmpudp,0x0C ,0x04 ,PPC2_VSX ), +GEN_XX3FORM (xsmaxdp,0x00 ,0x14 ,PPC2_VSX ), +GEN_XX3FORM (xsmindp,0x00 ,0x15 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
@@ -10078,6 +10086,8 @@ GEN_XX3FORM(xvnmaddadp, 0x04, 0x1C, PPC2_VSX),GEN_XX3FORM (xvnmaddmdp,0x04 ,0x1D ,PPC2_VSX ),GEN_XX3FORM (xvnmsubadp,0x04 ,0x1E ,PPC2_VSX ),GEN_XX3FORM (xvnmsubmdp,0x04 ,0x1F ,PPC2_VSX ), +GEN_XX3FORM (xvmaxdp,0x00 ,0x1C ,PPC2_VSX ), +GEN_XX3FORM (xvmindp,0x00 ,0x1D ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ), GEN_XX3FORM(xvsubsp, 0x00, 0x09, PPC2_VSX),
@@ -10096,6 +10106,8 @@ GEN_XX3FORM(xvnmaddasp, 0x04, 0x18, PPC2_VSX),GEN_XX3FORM (xvnmaddmsp,0x04 ,0x19 ,PPC2_VSX ),GEN_XX3FORM (xvnmsubasp,0x04 ,0x1A ,PPC2_VSX ),GEN_XX3FORM (xvnmsubmsp,0x04 ,0x1B ,PPC2_VSX ), +GEN_XX3FORM (xvmaxsp,0x00 ,0x18 ,PPC2_VSX ), +GEN_XX3FORM (xvminsp,0x00 ,0x19 ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 035/130] target-ppc: VSX Stage 4: Refactor lxsdx
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch refactors the lxsdx generator. Resuable code is isolated into a macro. The macro will be used in subsequent patches in this series to implement other scalar load instructions.
--- target-ppc/translate.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
target-ppc/translate.c +17 -14
@@ -7022,20 +7022,23 @@ static inline TCGv_i64 cpu_vsrl(int n) } } -static void gen_lxsdx (DisasContext *ctx) -{ -TCGv EA ; -if (unlikely (!ctx->vsx_enabled)) { -gen_exception (ctx,POWERPC_EXCP_VSXU ); -return ; - } -gen_set_access_type (ctx,ACCESS_INT ); -EA =tcg_temp_new (); -gen_addr_reg_index (ctx,EA ); -gen_qemu_ld64 (ctx,cpu_vsrh (xT (ctx->opcode)),EA ); -/* NOTE: cpu_vsrl is undefined */ -tcg_temp_free (EA ); -} +#define VSX_LOAD_SCALAR (name, operation) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + TCGv EA; \ + if (unlikely(!ctx->vsx_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VSXU); \ + return; \ + } \ + gen_set_access_type(ctx, ACCESS_INT); \ + EA = tcg_temp_new(); \ + gen_addr_reg_index(ctx, EA); \ + gen_qemu_##operation(ctx, cpu_vsrh(xT(ctx->opcode)), EA); \ +/* NOTE: cpu_vsrl is undefined */ \ +tcg_temp_free (EA ); \ +} + +VSX_LOAD_SCALAR(lxsdx, ld64)static void gen_lxvd2x (DisasContext *ctx) {
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 004/130] target-ppc: fix SPR_CTRL/SPR_UCTRL register numbers
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
Assuming that "U" in SPR_UCTRL is for "user", there is inconsistency with 970 user manuals/P5-bookIV/PowerISA204 which define the number as:
priviledged
# spr5-9 spr0-4 name mtspr mfspr len cat
136 00100 01000 CTRL - no 32 S 152 00100 11000 CTRL yes - 32 S
This swaps the numbers. No effect from this change is expected though.
--- target-ppc/cpu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target-ppc/cpu.h +2 -2
@@ -1250,7 +1250,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)#define SPR_MPC_EIE (0x050)#define SPR_MPC_EID (0x051)#define SPR_MPC_NRI (0x052) -#define SPR_CTRL (0x088) +#define SPR_UCTRL (0x088)#define SPR_MPC_CMPA (0x090)#define SPR_MPC_CMPB (0x091)#define SPR_MPC_CMPC (0x092)
@@ -1259,7 +1259,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)#define SPR_MPC_DER (0x095)#define SPR_MPC_COUNTA (0x096)#define SPR_MPC_COUNTB (0x097) -#define SPR_UCTRL (0x098) +#define SPR_CTRL (0x098)#define SPR_MPC_CMPE (0x098)#define SPR_MPC_CMPF (0x099)#define SPR_MPC_CMPG (0x09A)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 015/130] spapr_vscsi: Fix REPORT_LUNS handling
In reply to Alexander GrafFrom: Nathan Whitehorn <[email protected]>
Intercept REPORT_LUNS commands addressed either to SRP LUN 0 or the well-known LUN for REPORT_LUNS commands. This is required to implement the SAM and SPC specifications.
Since SRP implements only a single SCSI target port per connection, the SRP target is required to report all available LUNs in response to a REPORT_LUNS command addressed either to LUN 0 or the well-known LUN. Instead, QEMU was forwarding such requests to the first QEMU SCSI target, with the result that initiators that relied on this feature would only see LUNs on the first QEMU SCSI target.
Behavior for REPORT_LUNS commands addressed to any other LUN is not specified by the standard and so is left unchanged. This preserves behavior under Linux and SLOF, which enumerate possible LUNs by hand and so address no commands either to LUN 0 or the well-known REPORT_LUNS LUN.
--- hw/scsi/spapr_vscsi.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
hw/scsi/spapr_vscsi.c +60 -0
@@ -62,6 +62,8 @@#define SRP_RSP_SENSE_DATA_LEN 18 +#define SRP_REPORT_LUNS_WLUN 0xc10100000000000ULL + typedef union vscsi_crq { struct viosrp_crq s; uint8_t raw[16];
@@ -719,12 +721,70 @@ static void vscsi_inquiry_no_target(VSCSIState *s, vscsi_req *req) } } +static void vscsi_report_luns (VSCSIState *s,vscsi_req *req) +{ +BusChild *kid; +int i, len, n, rc; +uint8_t *resp_data; +bool found_lun0; + + n =0 ; + found_lun0 = false; + QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { +SCSIDevice *dev =SCSI_DEVICE (kid->child); + + n +=8 ; +if (dev->channel ==0 && dev->id ==0 && dev->lun ==0 ) { + found_lun0 = true; + } + } +if (!found_lun0) { + n +=8 ; + } + len = n+8 ; + + resp_data =g_malloc0 (len); +memset (resp_data,0 , len); +stl_be_p (resp_data, n); + i = found_lun0 ?8 :16 ; + QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { +DeviceState *qdev = kid->child; +SCSIDevice *dev =SCSI_DEVICE (qdev); + +if (dev->id ==0 && dev->channel ==0 ) { + resp_data[i] =0 ;/* Use simple LUN for 0 (SAM5 4.7.7.1) */ + }else { + resp_data[i] = (2 <<6 );/* Otherwise LUN addressing (4.7.7.4) */ + } + resp_data[i] |= dev->id; + resp_data[i+1 ] = (dev->channel <<5 ); + resp_data[i+1 ] |= dev->lun; + i +=8 ; + } + +vscsi_preprocess_desc (req); + rc =vscsi_srp_transfer_data (s, req,0 , resp_data, len); +g_free (resp_data); +if (rc <0 ) { +vscsi_makeup_sense (s, req,HARDWARE_ERROR ,0 ,0 ); +vscsi_send_rsp (s, req,CHECK_CONDITION ,0 ,0 ); + }else { +vscsi_send_rsp (s, req,0 , len - rc,0 ); + } +} +static int vscsi_queue_cmd (VSCSIState *s,vscsi_req *req) {union srp_iu *srp = &req->iu.srp;SCSIDevice *sdev;int n, lun; +if ((srp->cmd.lun ==0 ||be64_to_cpu (srp->cmd.lun) ==SRP_REPORT_LUNS_WLUN ) + && srp->cmd.cdb[0 ] ==REPORT_LUNS ) { +vscsi_report_luns (s, req); +return 0 ; + } + sdev =vscsi_device_find (&s->bus,be64_to_cpu (srp->cmd.lun), &lun);if (!sdev) { DPRINTF("VSCSI: Command for lun %08" PRIx64 " with no drive\n",
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 017/130] target-ppc: Add set_fprf Argument to fload_invalid_op_excp()
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
The fload_invalid_op_excp() function sets assorted invalid operation status bits. However, it also implicitly modifies the FPRF field of the PowerPC FPSCR. Many VSX instructions set invalid operation bits but do not alter FPRF. Thus the function is more generally useful if the setting of the FPRF field is made conditional via a parameter.
All invocations of this routine in existing instructions are modified to pass 1 and thus retain their current behavior.
--- target-ppc/fpu_helper.c | 103 ++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 48 deletions(-)
target-ppc/fpu_helper.c +55 -48
@@ -106,7 +106,8 @@ uint32_t helper_compute_fprf(CPUPPCState *env, uint64_t arg, uint32_t set_fprf) }/* Floating-point invalid operations exception */ -static inline uint64_t fload_invalid_op_excp (CPUPPCState *env,int op) +static inline uint64_t fload_invalid_op_excp (CPUPPCState *env,int op, +int set_fpcc) {uint64_t ret =0 ;int ve;
@@ -138,8 +139,10 @@ static inline uint64_t fload_invalid_op_excp(CPUPPCState *env, int op)case POWERPC_EXCP_FP_VXVC :/* Ordered comparison of NaN */ env->fpscr |=1 <<FPSCR_VXVC ; - env->fpscr &= ~(0xF <<FPSCR_FPCC ); - env->fpscr |=0x11 <<FPSCR_FPCC ; +if (set_fpcc) { + env->fpscr &= ~(0xF <<FPSCR_FPCC ); + env->fpscr |=0x11 <<FPSCR_FPCC ; + }/* We must update the target FPR before raising the exception */ if (ve !=0 ) { env->exception_index =POWERPC_EXCP_PROGRAM ;
@@ -158,8 +161,10 @@ static inline uint64_t fload_invalid_op_excp(CPUPPCState *env, int op)if (ve ==0 ) {/* Set the result to quiet NaN */ ret =0x7FF8000000000000ULL ; - env->fpscr &= ~(0xF <<FPSCR_FPCC ); - env->fpscr |=0x11 <<FPSCR_FPCC ; +if (set_fpcc) { + env->fpscr &= ~(0xF <<FPSCR_FPCC ); + env->fpscr |=0x11 <<FPSCR_FPCC ; + } }break ;case POWERPC_EXCP_FP_VXCVI :
@@ -169,8 +174,10 @@ static inline uint64_t fload_invalid_op_excp(CPUPPCState *env, int op)if (ve ==0 ) {/* Set the result to quiet NaN */ ret =0x7FF8000000000000ULL ; - env->fpscr &= ~(0xF <<FPSCR_FPCC ); - env->fpscr |=0x11 <<FPSCR_FPCC ; +if (set_fpcc) { + env->fpscr &= ~(0xF <<FPSCR_FPCC ); + env->fpscr |=0x11 <<FPSCR_FPCC ; + } }break ; }
@@ -505,12 +512,12 @@ uint64_t helper_fadd(CPUPPCState *env, uint64_t arg1, uint64_t arg2)if (unlikely (float64_is_infinity (farg1.d) &&float64_is_infinity (farg2.d) &&float64_is_neg (farg1.d) !=float64_is_neg (farg2.d))) {/* Magnitude subtraction of infinities */ - farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXISI ); + farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXISI ,1 ); }else {if (unlikely (float64_is_signaling_nan (farg1.d) ||float64_is_signaling_nan (farg2.d))) {/* sNaN addition */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } farg1.d =float64_add (farg1.d, farg2.d, &env->fp_status); }
@@ -529,12 +536,12 @@ uint64_t helper_fsub(CPUPPCState *env, uint64_t arg1, uint64_t arg2)if (unlikely (float64_is_infinity (farg1.d) &&float64_is_infinity (farg2.d) &&float64_is_neg (farg1.d) ==float64_is_neg (farg2.d))) {/* Magnitude subtraction of infinities */ - farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXISI ); + farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXISI ,1 ); }else {if (unlikely (float64_is_signaling_nan (farg1.d) ||float64_is_signaling_nan (farg2.d))) {/* sNaN subtraction */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } farg1.d =float64_sub (farg1.d, farg2.d, &env->fp_status); }
@@ -553,12 +560,12 @@ uint64_t helper_fmul(CPUPPCState *env, uint64_t arg1, uint64_t arg2)if (unlikely ((float64_is_infinity (farg1.d) &&float64_is_zero (farg2.d)) || (float64_is_zero (farg1.d) &&float64_is_infinity (farg2.d)))) {/* Multiplication of zero by infinity */ - farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXIMZ ); + farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXIMZ ,1 ); }else {if (unlikely (float64_is_signaling_nan (farg1.d) ||float64_is_signaling_nan (farg2.d))) {/* sNaN multiplication */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } farg1.d =float64_mul (farg1.d, farg2.d, &env->fp_status); }
@@ -577,15 +584,15 @@ uint64_t helper_fdiv(CPUPPCState *env, uint64_t arg1, uint64_t arg2)if (unlikely (float64_is_infinity (farg1.d) &&float64_is_infinity (farg2.d))) {/* Division of infinity by infinity */ - farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXIDI ); + farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXIDI ,1 ); }else if (unlikely (float64_is_zero (farg1.d) &&float64_is_zero (farg2.d))) {/* Division of zero by zero */ - farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXZDZ ); + farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXZDZ ,1 ); }else {if (unlikely (float64_is_signaling_nan (farg1.d) ||float64_is_signaling_nan (farg2.d))) {/* sNaN division */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } farg1.d =float64_div (farg1.d, farg2.d, &env->fp_status); }
@@ -603,11 +610,11 @@ uint64_t helper_fctiw(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN conversion */ farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ); +POWERPC_EXCP_FP_VXCVI ,1 ); }else if (unlikely (float64_is_quiet_nan (farg.d) ||float64_is_infinity (farg.d))) {/* qNan / infinity conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ); + farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); }else { farg.ll =float64_to_int32 (farg.d, &env->fp_status);/* XXX: higher bits are not supposed to be significant.
@@ -628,11 +635,11 @@ uint64_t helper_fctiwz(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN conversion */ farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ); +POWERPC_EXCP_FP_VXCVI ,1 ); }else if (unlikely (float64_is_quiet_nan (farg.d) ||float64_is_infinity (farg.d))) {/* qNan / infinity conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ); + farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); }else { farg.ll =float64_to_int32_round_to_zero (farg.d, &env->fp_status);/* XXX: higher bits are not supposed to be significant.
@@ -663,11 +670,11 @@ uint64_t helper_fctid(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN conversion */ farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ); +POWERPC_EXCP_FP_VXCVI ,1 ); }else if (unlikely (float64_is_quiet_nan (farg.d) ||float64_is_infinity (farg.d))) {/* qNan / infinity conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ); + farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); }else { farg.ll =float64_to_int64 (farg.d, &env->fp_status); }
@@ -684,11 +691,11 @@ uint64_t helper_fctidz(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN conversion */ farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ); +POWERPC_EXCP_FP_VXCVI ,1 ); }else if (unlikely (float64_is_quiet_nan (farg.d) ||float64_is_infinity (farg.d))) {/* qNan / infinity conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ); + farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); }else { farg.ll =float64_to_int64_round_to_zero (farg.d, &env->fp_status); }
@@ -707,11 +714,11 @@ static inline uint64_t do_fri(CPUPPCState *env, uint64_t arg,if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN round */ farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ); +POWERPC_EXCP_FP_VXCVI ,1 ); }else if (unlikely (float64_is_quiet_nan (farg.d) ||float64_is_infinity (farg.d))) {/* qNan / infinity round */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ); + farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); }else {set_float_rounding_mode (rounding_mode, &env->fp_status); farg.ll =float64_round_to_int (farg.d, &env->fp_status);
@@ -754,13 +761,13 @@ uint64_t helper_fmadd(CPUPPCState *env, uint64_t arg1, uint64_t arg2,if (unlikely ((float64_is_infinity (farg1.d) &&float64_is_zero (farg2.d)) || (float64_is_zero (farg1.d) &&float64_is_infinity (farg2.d)))) {/* Multiplication of zero by infinity */ - farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXIMZ ); + farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXIMZ ,1 ); }else {if (unlikely (float64_is_signaling_nan (farg1.d) ||float64_is_signaling_nan (farg2.d) ||float64_is_signaling_nan (farg3.d))) {/* sNaN operation */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); }/* This is the way the PowerPC specification defines it */ float128 ft0_128, ft1_128;
@@ -772,7 +779,7 @@ uint64_t helper_fmadd(CPUPPCState *env, uint64_t arg1, uint64_t arg2, float64_is_infinity(farg3.d) && float128_is_neg(ft0_128) != float64_is_neg(farg3.d))) { /* Magnitude subtraction of infinities */ - farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI); + farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI, 1); } else { ft1_128 =float64_to_float128 (farg3.d, &env->fp_status); ft0_128 =float128_add (ft0_128, ft1_128, &env->fp_status);
@@ -797,13 +804,13 @@ uint64_t helper_fmsub(CPUPPCState *env, uint64_t arg1, uint64_t arg2, (float64_is_zero(farg1.d) && float64_is_infinity(farg2.d)))) { /* Multiplication of zero by infinity */ - farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ); + farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1); } else {if (unlikely (float64_is_signaling_nan (farg1.d) ||float64_is_signaling_nan (farg2.d) ||float64_is_signaling_nan (farg3.d))) {/* sNaN operation */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); }/* This is the way the PowerPC specification defines it */ float128 ft0_128, ft1_128;
@@ -815,7 +822,7 @@ uint64_t helper_fmsub(CPUPPCState *env, uint64_t arg1, uint64_t arg2, float64_is_infinity(farg3.d) && float128_is_neg(ft0_128) == float64_is_neg(farg3.d))) { /* Magnitude subtraction of infinities */ - farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI); + farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI, 1); } else { ft1_128 =float64_to_float128 (farg3.d, &env->fp_status); ft0_128 =float128_sub (ft0_128, ft1_128, &env->fp_status);
@@ -838,13 +845,13 @@ uint64_t helper_fnmadd(CPUPPCState *env, uint64_t arg1, uint64_t arg2,if (unlikely ((float64_is_infinity (farg1.d) &&float64_is_zero (farg2.d)) || (float64_is_zero (farg1.d) &&float64_is_infinity (farg2.d)))) {/* Multiplication of zero by infinity */ - farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXIMZ ); + farg1.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXIMZ ,1 ); }else {if (unlikely (float64_is_signaling_nan (farg1.d) ||float64_is_signaling_nan (farg2.d) ||float64_is_signaling_nan (farg3.d))) {/* sNaN operation */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); }/* This is the way the PowerPC specification defines it */ float128 ft0_128, ft1_128;
@@ -856,7 +863,7 @@ uint64_t helper_fnmadd(CPUPPCState *env, uint64_t arg1, uint64_t arg2, float64_is_infinity(farg3.d) && float128_is_neg(ft0_128) != float64_is_neg(farg3.d))) { /* Magnitude subtraction of infinities */ - farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI); + farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI, 1); } else { ft1_128 =float64_to_float128 (farg3.d, &env->fp_status); ft0_128 =float128_add (ft0_128, ft1_128, &env->fp_status);
@@ -883,13 +890,13 @@ uint64_t helper_fnmsub(CPUPPCState *env, uint64_t arg1, uint64_t arg2, (float64_is_zero(farg1.d) && float64_is_infinity(farg2.d)))) { /* Multiplication of zero by infinity */ - farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ); + farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1); } else {if (unlikely (float64_is_signaling_nan (farg1.d) ||float64_is_signaling_nan (farg2.d) ||float64_is_signaling_nan (farg3.d))) {/* sNaN operation */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); }/* This is the way the PowerPC specification defines it */ float128 ft0_128, ft1_128;
@@ -901,7 +908,7 @@ uint64_t helper_fnmsub(CPUPPCState *env, uint64_t arg1, uint64_t arg2, float64_is_infinity(farg3.d) && float128_is_neg(ft0_128) == float64_is_neg(farg3.d))) { /* Magnitude subtraction of infinities */ - farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI); + farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI, 1); } else { ft1_128 =float64_to_float128 (farg3.d, &env->fp_status); ft0_128 =float128_sub (ft0_128, ft1_128, &env->fp_status);
@@ -924,7 +931,7 @@ uint64_t helper_frsp(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN square root */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } f32 =float64_to_float32 (farg.d, &env->fp_status); farg.d =float32_to_float64 (f32, &env->fp_status);
@@ -941,11 +948,11 @@ uint64_t helper_fsqrt(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_neg (farg.d) && !float64_is_zero (farg.d))) {/* Square root of a negative nonzero number */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSQRT ); + farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSQRT ,1 ); }else {if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN square root */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } farg.d =float64_sqrt (farg.d, &env->fp_status); }
@@ -961,7 +968,7 @@ uint64_t helper_fre(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN reciprocal */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } farg.d =float64_div (float64_one, farg.d, &env->fp_status);return farg.d;
@@ -977,7 +984,7 @@ uint64_t helper_fres(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN reciprocal */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } farg.d =float64_div (float64_one, farg.d, &env->fp_status); f32 =float64_to_float32 (farg.d, &env->fp_status);
@@ -996,11 +1003,11 @@ uint64_t helper_frsqrte(CPUPPCState *env, uint64_t arg)if (unlikely (float64_is_neg (farg.d) && !float64_is_zero (farg.d))) {/* Reciprocal square root of a negative nonzero number */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSQRT ); + farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSQRT ,1 ); }else {if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN reciprocal square root */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } farg.d =float64_sqrt (farg.d, &env->fp_status); farg.d =float64_div (float64_one, farg.d, &env->fp_status);
@@ -1053,7 +1060,7 @@ void helper_fcmpu(CPUPPCState *env, uint64_t arg1, uint64_t arg2, && (float64_is_signaling_nan(farg1.d) || float64_is_signaling_nan(farg2.d)))) {/* sNaN comparison */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); } }
@@ -1085,10 +1092,10 @@ void helper_fcmpo(CPUPPCState *env, uint64_t arg1, uint64_t arg2, float64_is_signaling_nan(farg2.d)) { /* sNaN comparison */ fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN | - POWERPC_EXCP_FP_VXVC); + POWERPC_EXCP_FP_VXVC, 1); } else {/* qNaN comparison */ -fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXVC ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXVC ,1 ); } } }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 020/130] target-ppc: Add VSX ISA2.06 xmul Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point multiply instructions defined by V2.06 of the PowerPC ISA: xsmuldp, xvmuldp, xvmulsp.
--- target-ppc/fpu_helper.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 3 +++ target-ppc/translate.c | 6 ++++++ 3 files changed, 56 insertions(+)
target-ppc/fpu_helper.c +47 -0
@@ -1808,3 +1808,50 @@ VSX_ADD_SUB(xvaddsp, add, 4, float32, f32, 0) VSX_ADD_SUB(xssubdp, sub, 1, float64, f64, 1) VSX_ADD_SUB(xvsubdp, sub, 2, float64, f64, 0)VSX_ADD_SUB (xvsubsp, sub,4 , float32, f32,0 ) + +/* VSX_MUL - VSX floating point multiply +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* sfprf - set FPRF + */ +#define VSX_MUL (op, nels, tp, fld, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xa, xb; \ + int i; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + helper_reset_fpstatus(env); \ + \ + for (i = 0; i < nels; i++) { \ + float_status tstat = env->fp_status; \ + set_float_exception_flags(0, &tstat); \ + xt.fld[i] = tp##_mul(xa.fld[i], xb.fld[i], &tstat); \ + env->fp_status.float_exception_flags |= tstat.float_exception_flags; \ + \ + if (unlikely(tstat.float_exception_flags & float_flag_invalid)) { \ + if ((tp##_is_infinity(xa.fld[i]) && tp##_is_zero(xb.fld[i])) || \ + (tp##_is_infinity(xb.fld[i]) && tp##_is_zero(xa.fld[i]))) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, sfprf); \ + } else if (tp##_is_signaling_nan(xa.fld[i]) || \ + tp##_is_signaling_nan(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, sfprf); \ + } \ + } \ + \ + if (sfprf) { \ + helper_compute_fprf(env, xt.fld[i], sfprf); \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_MUL(xsmuldp, 1, float64, f64, 1) +VSX_MUL(xvmuldp, 2, float64, f64, 0) +VSX_MUL (xvmulsp,4 , float32, f32,0 )
target-ppc/helper.h +3 -0
@@ -253,12 +253,15 @@ DEF_HELPER_4(vctsxs, void, env, avr, avr, i32) DEF_HELPER_2(xsadddp, void, env, i32) DEF_HELPER_2(xssubdp, void, env, i32) +DEF_HELPER_2(xsmuldp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32) DEF_HELPER_2(xvsubdp, void, env, i32) +DEF_HELPER_2(xvmuldp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32) DEF_HELPER_2(xvsubsp, void, env, i32) +DEF_HELPER_2(xvmulsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +6 -0
@@ -7306,12 +7306,15 @@ static void gen_##name(DisasContext * ctx) \ GEN_VSX_HELPER_2(xsadddp, 0x00, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xssubdp, 0x00, 0x05, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsmuldp, 0x00, 0x06, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubdp, 0x00, 0x0D, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvmuldp, 0x00, 0x0E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubsp, 0x00, 0x09, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvmulsp, 0x00, 0x0A, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -9996,12 +9999,15 @@ GEN_XX3FORM(xvcpsgnsp, 0x00, 0x1A, PPC2_VSX),GEN_XX3FORM (xsadddp,0x00 ,0x04 ,PPC2_VSX ),GEN_XX3FORM (xssubdp,0x00 ,0x05 ,PPC2_VSX ), +GEN_XX3FORM (xsmuldp,0x00 ,0x06 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ),GEN_XX3FORM (xvsubdp,0x00 ,0x0D ,PPC2_VSX ), +GEN_XX3FORM (xvmuldp,0x00 ,0x0E ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ),GEN_XX3FORM (xvsubsp,0x00 ,0x09 ,PPC2_VSX ), +GEN_XX3FORM (xvmulsp,0x00 ,0x0A ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 023/130] target-ppc: Add VSX ISA2.06 xsqrt Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point square root instructions defined by V2.06 of the PowerPC ISA: xssqrtdp, xvsqrtdp, xvsqrtsp.
--- target-ppc/fpu_helper.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 3 +++ target-ppc/translate.c | 6 ++++++ 3 files changed, 53 insertions(+)
target-ppc/fpu_helper.c +44 -0
@@ -1939,3 +1939,47 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ VSX_RE(xsredp, 1, float64, f64, 1) VSX_RE(xvredp, 2, float64, f64, 0)VSX_RE (xvresp,4 , float32, f32,0 ) + +/* VSX_SQRT - VSX floating point square root +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* sfprf - set FPRF + */ +#define VSX_SQRT (op, nels, tp, fld, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xb; \ + int i; \ + \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + helper_reset_fpstatus(env); \ + \ + for (i = 0; i < nels; i++) { \ + float_status tstat = env->fp_status; \ + set_float_exception_flags(0, &tstat); \ + xt.fld[i] = tp##_sqrt(xb.fld[i], &tstat); \ + env->fp_status.float_exception_flags |= tstat.float_exception_flags; \ + \ + if (unlikely(tstat.float_exception_flags & float_flag_invalid)) { \ + if (tp##_is_neg(xb.fld[i]) && !tp##_is_zero(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, sfprf); \ + } else if (tp##_is_signaling_nan(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, sfprf); \ + } \ + } \ + \ + if (sfprf) { \ + helper_compute_fprf(env, xt.fld[i], sfprf); \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_SQRT(xssqrtdp, 1, float64, f64, 1) +VSX_SQRT(xvsqrtdp, 2, float64, f64, 0) +VSX_SQRT (xvsqrtsp,4 , float32, f32,0 )
target-ppc/helper.h +3 -0
@@ -256,18 +256,21 @@ DEF_HELPER_2(xssubdp, void, env, i32) DEF_HELPER_2(xsmuldp, void, env, i32) DEF_HELPER_2(xsdivdp, void, env, i32) DEF_HELPER_2(xsredp, void, env, i32) +DEF_HELPER_2(xssqrtdp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32) DEF_HELPER_2(xvsubdp, void, env, i32) DEF_HELPER_2(xvmuldp, void, env, i32) DEF_HELPER_2(xvdivdp, void, env, i32) DEF_HELPER_2(xvredp, void, env, i32) +DEF_HELPER_2(xvsqrtdp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32) DEF_HELPER_2(xvsubsp, void, env, i32) DEF_HELPER_2(xvmulsp, void, env, i32) DEF_HELPER_2(xvdivsp, void, env, i32) DEF_HELPER_2(xvresp, void, env, i32) +DEF_HELPER_2(xvsqrtsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +6 -0
@@ -7309,18 +7309,21 @@ GEN_VSX_HELPER_2(xssubdp, 0x00, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsmuldp, 0x00, 0x06, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsdivdp, 0x00, 0x07, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsredp, 0x14, 0x05, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xssqrtdp, 0x16, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubdp, 0x00, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmuldp, 0x00, 0x0E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvdivdp, 0x00, 0x0F, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvredp, 0x14, 0x0D, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvsqrtdp, 0x16, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubsp, 0x00, 0x09, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmulsp, 0x00, 0x0A, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvdivsp, 0x00, 0x0B, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvresp, 0x14, 0x09, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvsqrtsp, 0x16, 0x08, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10008,18 +10011,21 @@ GEN_XX3FORM(xssubdp, 0x00, 0x05, PPC2_VSX),GEN_XX3FORM (xsmuldp,0x00 ,0x06 ,PPC2_VSX ),GEN_XX3FORM (xsdivdp,0x00 ,0x07 ,PPC2_VSX ),GEN_XX2FORM (xsredp,0x14 ,0x05 ,PPC2_VSX ), +GEN_XX2FORM (xssqrtdp,0x16 ,0x04 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ),GEN_XX3FORM (xvsubdp,0x00 ,0x0D ,PPC2_VSX ),GEN_XX3FORM (xvmuldp,0x00 ,0x0E ,PPC2_VSX ),GEN_XX3FORM (xvdivdp,0x00 ,0x0F ,PPC2_VSX ),GEN_XX2FORM (xvredp,0x14 ,0x0D ,PPC2_VSX ), +GEN_XX2FORM (xvsqrtdp,0x16 ,0x0C ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ),GEN_XX3FORM (xvsubsp,0x00 ,0x09 ,PPC2_VSX ),GEN_XX3FORM (xvmulsp,0x00 ,0x0A ,PPC2_VSX ),GEN_XX3FORM (xvdivsp,0x00 ,0x0B ,PPC2_VSX ),GEN_XX2FORM (xvresp,0x14 ,0x09 ,PPC2_VSX ), +GEN_XX2FORM (xvsqrtsp,0x16 ,0x08 ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 032/130] target-ppc: Add VSX ISA2.06 Integer Conversion Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Integer Conversion instructions defined by V2.06 of the PowerPC ISA:
- xscvdpsxds, xscvdpsxws, xscvdpuxds, xscvdpuxws
- xvcvdpsxds, xvcvdpsxws, xvcvdpuxds, xvcvdpuxws
- xvcvspsxds, xvcvspsxws, xvcvspuxds, xvcvspuxws
- xscvsxddp, xscvuxddp
- xvcvsxddp, xscvsxwdp, xvcvuxddp, xvcvuxwdp
- xvcvsxdsp, xscvsxwsp, xvcvuxdsp, xvcvuxwsp
--- target-ppc/fpu_helper.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 22 ++++++++++ target-ppc/translate.c | 44 ++++++++++++++++++++ 3 files changed, 173 insertions(+)
target-ppc/fpu_helper.c +107 -0
@@ -2430,3 +2430,110 @@ VSX_CVT_FP_TO_FP(xscvdpsp, 1, float64, float32, f64[i], f32[j], 1) VSX_CVT_FP_TO_FP(xscvspdp, 1, float32, float64, f32[j], f64[i], 1) VSX_CVT_FP_TO_FP(xvcvdpsp, 2, float64, float32, f64[i], f32[j], 0)VSX_CVT_FP_TO_FP (xvcvspdp,2 , float32, float64, f32[j], f64[i],0 ) + +/* VSX_CVT_FP_TO_INT - VSX floating point to integer conversion +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* stp - source type (float32 or float64) +* ttp - target type (int32, uint32, int64 or uint64) +* sfld - source vsr_t field +* tfld - target vsr_t field +* jdef - definition of the j index (i or 2*i) +* rnan - resulting NaN + */ +#define VSX_CVT_FP_TO_INT (op, nels, stp, ttp, sfld, tfld, jdef, rnan) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xb; \ + int i; \ + \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + \ + for (i = 0; i < nels; i++) { \ + int j = jdef; \ + if (unlikely(stp##_is_any_nan(xb.sfld))) { \ + if (stp##_is_signaling_nan(xb.sfld)) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0); \ + } \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI, 0); \ + xt.tfld = rnan; \ + } else { \ + xt.tfld = stp##_to_##ttp(xb.sfld, &env->fp_status); \ + if (env->fp_status.float_exception_flags & float_flag_invalid) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI, 0); \ + } \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_CVT_FP_TO_INT (xscvdpsxds,1 , float64, int64, f64[j], u64[i], i, \ + 0x8000000000000000ul) +VSX_CVT_FP_TO_INT (xscvdpsxws,1 , float64, int32, f64[i], u32[j], \ + 2*i + JOFFSET, 0x80000000l) +VSX_CVT_FP_TO_INT(xscvdpuxds, 1, float64, uint64, f64[j], u64[i], i, 0ul) +VSX_CVT_FP_TO_INT (xscvdpuxws,1 , float64, uint32, f64[i], u32[j], \ + 2*i + JOFFSET, 0) +VSX_CVT_FP_TO_INT (xvcvdpsxds,2 , float64, int64, f64[j], u64[i], i, \ + 0x8000000000000000ul) +VSX_CVT_FP_TO_INT (xvcvdpsxws,2 , float64, int32, f64[i], u32[j], \ + 2*i + JOFFSET, 0x80000000l) +VSX_CVT_FP_TO_INT(xvcvdpuxds, 2, float64, uint64, f64[j], u64[i], i, 0ul) +VSX_CVT_FP_TO_INT (xvcvdpuxws,2 , float64, uint32, f64[i], u32[j], \ + 2*i + JOFFSET, 0) +VSX_CVT_FP_TO_INT (xvcvspsxds,2 , float32, int64, f32[j], u64[i], \ + 2*i + JOFFSET, 0x8000000000000000ul) +VSX_CVT_FP_TO_INT (xvcvspsxws,4 , float32, int32, f32[j], u32[j], i, \ + 0x80000000l) +VSX_CVT_FP_TO_INT (xvcvspuxds,2 , float32, uint64, f32[j], u64[i], \ + 2*i + JOFFSET, 0ul) +VSX_CVT_FP_TO_INT (xvcvspuxws,4 , float32, uint32, f32[j], u32[i], i,0 ) + +/* VSX_CVT_INT_TO_FP - VSX integer to floating point conversion +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* stp - source type (int32, uint32, int64 or uint64) +* ttp - target type (float32 or float64) +* sfld - source vsr_t field +* tfld - target vsr_t field +* jdef - definition of the j index (i or 2*i) +* sfprf - set FPRF + */ +#define VSX_CVT_INT_TO_FP (op, nels, stp, ttp, sfld, tfld, jdef, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xb; \ + int i; \ + \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + \ + for (i = 0; i < nels; i++) { \ + int j = jdef; \ + xt.tfld = stp##_to_##ttp(xb.sfld, &env->fp_status); \ + if (sfprf) { \ + helper_compute_fprf(env, xt.tfld, sfprf); \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_CVT_INT_TO_FP(xscvsxddp, 1, int64, float64, u64[j], f64[i], i, 1) +VSX_CVT_INT_TO_FP(xscvuxddp, 1, uint64, float64, u64[j], f64[i], i, 1) +VSX_CVT_INT_TO_FP(xvcvsxddp, 2, int64, float64, u64[j], f64[i], i, 0) +VSX_CVT_INT_TO_FP(xvcvuxddp, 2, uint64, float64, u64[j], f64[i], i, 0) +VSX_CVT_INT_TO_FP (xvcvsxwdp,2 , int32, float64, u32[j], f64[i], \ + 2*i + JOFFSET, 0) +VSX_CVT_INT_TO_FP (xvcvuxwdp,2 , uint64, float64, u32[j], f64[i], \ + 2*i + JOFFSET, 0) +VSX_CVT_INT_TO_FP (xvcvsxdsp,2 , int64, float32, u64[i], f32[j], \ + 2*i + JOFFSET, 0) +VSX_CVT_INT_TO_FP (xvcvuxdsp,2 , uint64, float32, u64[i], f32[j], \ + 2*i + JOFFSET, 0) +VSX_CVT_INT_TO_FP(xvcvsxwsp, 4, int32, float32, u32[j], f32[i], i, 0) +VSX_CVT_INT_TO_FP (xvcvuxwsp,4 , uint32, float32, u32[j], f32[i], i,0 )
target-ppc/helper.h +22 -0
@@ -274,6 +274,12 @@ DEF_HELPER_2(xsmaxdp, void, env, i32) DEF_HELPER_2(xsmindp, void, env, i32) DEF_HELPER_2(xscvdpsp, void, env, i32) DEF_HELPER_2(xscvspdp, void, env, i32) +DEF_HELPER_2(xscvdpsxds, void, env, i32) +DEF_HELPER_2(xscvdpsxws, void, env, i32) +DEF_HELPER_2(xscvdpuxds, void, env, i32) +DEF_HELPER_2(xscvdpuxws, void, env, i32) +DEF_HELPER_2(xscvsxddp, void, env, i32) +DEF_HELPER_2(xscvuxddp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
@@ -298,6 +304,14 @@ DEF_HELPER_2(xvcmpeqdp, void, env, i32) DEF_HELPER_2(xvcmpgedp, void, env, i32) DEF_HELPER_2(xvcmpgtdp, void, env, i32) DEF_HELPER_2(xvcvdpsp, void, env, i32) +DEF_HELPER_2(xvcvdpsxds, void, env, i32) +DEF_HELPER_2(xvcvdpsxws, void, env, i32) +DEF_HELPER_2(xvcvdpuxds, void, env, i32) +DEF_HELPER_2(xvcvdpuxws, void, env, i32) +DEF_HELPER_2(xvcvsxddp, void, env, i32) +DEF_HELPER_2(xvcvuxddp, void, env, i32) +DEF_HELPER_2(xvcvsxwdp, void, env, i32) +DEF_HELPER_2(xvcvuxwdp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -322,6 +336,14 @@ DEF_HELPER_2(xvcmpeqsp, void, env, i32) DEF_HELPER_2(xvcmpgesp, void, env, i32) DEF_HELPER_2(xvcmpgtsp, void, env, i32) DEF_HELPER_2(xvcvspdp, void, env, i32) +DEF_HELPER_2(xvcvspsxds, void, env, i32) +DEF_HELPER_2(xvcvspsxws, void, env, i32) +DEF_HELPER_2(xvcvspuxds, void, env, i32) +DEF_HELPER_2(xvcvspuxws, void, env, i32) +DEF_HELPER_2(xvcvsxdsp, void, env, i32) +DEF_HELPER_2(xvcvuxdsp, void, env, i32) +DEF_HELPER_2(xvcvsxwsp, void, env, i32) +DEF_HELPER_2(xvcvuxwsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +44 -0
80 lines not on this page · raw message
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 024/130] target-ppc: Add VSX ISA2.06 xrsqrte Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point reciprocal square root estimate instructions defined by V2.06 of the PowerPC ISA: xsrsqrtedp, xvrsqrtedp, xvrsqrtesp.
--- target-ppc/fpu_helper.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 3 +++ target-ppc/translate.c | 6 ++++++ 3 files changed, 54 insertions(+)
target-ppc/fpu_helper.c +45 -0
@@ -1983,3 +1983,48 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ VSX_SQRT(xssqrtdp, 1, float64, f64, 1) VSX_SQRT(xvsqrtdp, 2, float64, f64, 0)VSX_SQRT (xvsqrtsp,4 , float32, f32,0 ) + +/* VSX_RSQRTE - VSX floating point reciprocal square root estimate +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* sfprf - set FPRF + */ +#define VSX_RSQRTE (op, nels, tp, fld, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xb; \ + int i; \ + \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + helper_reset_fpstatus(env); \ + \ + for (i = 0; i < nels; i++) { \ + float_status tstat = env->fp_status; \ + set_float_exception_flags(0, &tstat); \ + xt.fld[i] = tp##_sqrt(xb.fld[i], &tstat); \ + xt.fld[i] = tp##_div(tp##_one, xt.fld[i], &tstat); \ + env->fp_status.float_exception_flags |= tstat.float_exception_flags; \ + \ + if (unlikely(tstat.float_exception_flags & float_flag_invalid)) { \ + if (tp##_is_neg(xb.fld[i]) && !tp##_is_zero(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, sfprf); \ + } else if (tp##_is_signaling_nan(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, sfprf); \ + } \ + } \ + \ + if (sfprf) { \ + helper_compute_fprf(env, xt.fld[i], sfprf); \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_RSQRTE(xsrsqrtedp, 1, float64, f64, 1) +VSX_RSQRTE(xvrsqrtedp, 2, float64, f64, 0) +VSX_RSQRTE (xvrsqrtesp,4 , float32, f32,0 )
target-ppc/helper.h +3 -0
@@ -257,6 +257,7 @@ DEF_HELPER_2(xsmuldp, void, env, i32) DEF_HELPER_2(xsdivdp, void, env, i32) DEF_HELPER_2(xsredp, void, env, i32) DEF_HELPER_2(xssqrtdp, void, env, i32) +DEF_HELPER_2(xsrsqrtedp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
@@ -264,6 +265,7 @@ DEF_HELPER_2(xvmuldp, void, env, i32) DEF_HELPER_2(xvdivdp, void, env, i32) DEF_HELPER_2(xvredp, void, env, i32) DEF_HELPER_2(xvsqrtdp, void, env, i32) +DEF_HELPER_2(xvrsqrtedp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -271,6 +273,7 @@ DEF_HELPER_2(xvmulsp, void, env, i32) DEF_HELPER_2(xvdivsp, void, env, i32) DEF_HELPER_2(xvresp, void, env, i32) DEF_HELPER_2(xvsqrtsp, void, env, i32) +DEF_HELPER_2(xvrsqrtesp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +6 -0
@@ -7310,6 +7310,7 @@ GEN_VSX_HELPER_2(xsmuldp, 0x00, 0x06, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsdivdp, 0x00, 0x07, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsredp, 0x14, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xssqrtdp, 0x16, 0x04, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsrsqrtedp, 0x14, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -7317,6 +7318,7 @@ GEN_VSX_HELPER_2(xvmuldp, 0x00, 0x0E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvdivdp, 0x00, 0x0F, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvredp, 0x14, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsqrtdp, 0x16, 0x0C, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrsqrtedp, 0x14, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubsp,0x00 ,0x09 ,0 ,PPC2_VSX )
@@ -7324,6 +7326,7 @@ GEN_VSX_HELPER_2(xvmulsp, 0x00, 0x0A, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvdivsp, 0x00, 0x0B, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvresp, 0x14, 0x09, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsqrtsp, 0x16, 0x08, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrsqrtesp, 0x14, 0x08, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10012,6 +10015,7 @@ GEN_XX3FORM(xsmuldp, 0x00, 0x06, PPC2_VSX),GEN_XX3FORM (xsdivdp,0x00 ,0x07 ,PPC2_VSX ),GEN_XX2FORM (xsredp,0x14 ,0x05 ,PPC2_VSX ),GEN_XX2FORM (xssqrtdp,0x16 ,0x04 ,PPC2_VSX ), +GEN_XX2FORM (xsrsqrtedp,0x14 ,0x04 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
@@ -10019,6 +10023,7 @@ GEN_XX3FORM(xvmuldp, 0x00, 0x0E, PPC2_VSX),GEN_XX3FORM (xvdivdp,0x00 ,0x0F ,PPC2_VSX ),GEN_XX2FORM (xvredp,0x14 ,0x0D ,PPC2_VSX ),GEN_XX2FORM (xvsqrtdp,0x16 ,0x0C ,PPC2_VSX ), +GEN_XX2FORM (xvrsqrtedp,0x14 ,0x0C ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ), GEN_XX3FORM(xvsubsp, 0x00, 0x09, PPC2_VSX),
@@ -10026,6 +10031,7 @@ GEN_XX3FORM(xvmulsp, 0x00, 0x0A, PPC2_VSX),GEN_XX3FORM (xvdivsp,0x00 ,0x0B ,PPC2_VSX ),GEN_XX2FORM (xvresp,0x14 ,0x09 ,PPC2_VSX ),GEN_XX2FORM (xvsqrtsp,0x16 ,0x08 ,PPC2_VSX ), +GEN_XX2FORM (xvrsqrtesp,0x14 ,0x08 ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 034/130] target-ppc: VSX Stage 4: Add VSX 2.07 Flag
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a flag to identify those VSX instructions that are new to Power ISA V2.07. The flag is added to the Power 8 processor initialization so that the P8 models understand how to decode and emulate instructions in this category.
--- target-ppc/cpu.h | 4 +++- target-ppc/translate_init.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
target-ppc/cpu.h +3 -1
@@ -1875,9 +1875,11 @@ enum {PPC2_DBRX =0x0000000000000010ULL ,/* Book I 2.05 PowerPC specification */ PPC2_ISA205 =0x0000000000000020ULL , +/* VSX additions in ISA 2.07 */ +PPC2_VSX207 =0x0000000000000040ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \ - PPC2_ISA205) + PPC2_ISA205 | PPC2_VSX207) };/*****************************************************************************/
target-ppc/translate_init.c +1 -1
@@ -7144,7 +7144,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC_64B |PPC_ALTIVEC |PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; - pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX ; + pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 008/130] kvm: Add a new machine option kvm-type
In reply to Alexander GrafFrom: "Aneesh Kumar K.V" <[email protected]>
Targets like ppc64 support different types of KVM, one which use hypervisor mode and the other which doesn't. Add a new machine option kvm-type that helps in selecting the respective ones We also add a new QEMUMachine callback get_vm_type that helps in mapping the string representation of kvm type specified.
--- hw/ppc/spapr.c | 20 ++++++++++++++++++++ include/hw/boards.h | 3 +++ include/hw/xen/xen.h | 2 +- include/sysemu/kvm.h | 2 +- include/sysemu/qtest.h | 2 +- kvm-all.c | 17 ++++++++++++++--- kvm-stub.c | 2 +- qtest.c | 2 +- vl.c | 14 +++++++++----- xen-all.c | 2 +- xen-stub.c | 2 +- 11 files changed, 53 insertions(+), 15 deletions(-)
hw/ppc/spapr.c +20 -0
@@ -49,6 +49,7 @@#include "exec/address-spaces.h" #include "hw/usb.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include <libfdt.h>
@@ -1366,6 +1367,24 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)assert (spapr->fdt_skel !=NULL ); } +static int spapr_kvm_type (const char *vm_type) +{ +if (!vm_type) { +return 0 ; + } + +if (!strcmp (vm_type,"HV" )) { +return 1 ; + } + +if (!strcmp (vm_type,"PR" )) { +return 2 ; + } + +error_report ("Unknown kvm-type specified '%s'" , vm_type); +exit (1 ); +} +static QEMUMachine spapr_machine = { .name ="pseries" , .desc ="pSeries Logical Partition (PAPR compliant)" ,
@@ -1376,6 +1395,7 @@ static QEMUMachine spapr_machine = { .max_cpus = MAX_CPUS, .no_parallel = 1, .default_boot_order = NULL, + .kvm_type = spapr_kvm_type, };static void spapr_machine_init (void )
include/hw/boards.h +3 -0
@@ -23,6 +23,8 @@ typedef void QEMUMachineResetFunc(void);typedef void QEMUMachineHotAddCPUFunc (const int64_t id,Error **errp); +typedef int QEMUMachineGetKvmtypeFunc (const char *arg); +struct QEMUMachine {const char *name;const char *alias;
@@ -30,6 +32,7 @@ struct QEMUMachine {QEMUMachineInitFunc *init;QEMUMachineResetFunc *reset;QEMUMachineHotAddCPUFunc *hot_add_cpu; +QEMUMachineGetKvmtypeFunc *kvm_type;BlockInterfaceType block_default_type;int max_cpus; unsigned int no_serial:1,
include/hw/xen/xen.h +1 -1
@@ -37,7 +37,7 @@ void xen_cmos_set_s3_resume(void *opaque, int irq, int level);qemu_irq *xen_interrupt_controller_init (void ); -int xen_init (void ); +int xen_init (QEMUMachine *machine);int xen_hvm_init (MemoryRegion **ram_memory);void xenstore_store_pv_console_info (int i,struct CharDriverState *chr);
include/sysemu/kvm.h +1 -1
@@ -153,7 +153,7 @@ extern KVMState *kvm_state;/* external API */ -int kvm_init (void ); +int kvm_init (QEMUMachine *machine);int kvm_has_sync_mmu (void );int kvm_has_vcpu_events (void );
include/sysemu/qtest.h +1 -1
@@ -27,7 +27,7 @@ static inline bool qtest_enabled(void)bool qtest_driver (void ); -int qtest_init_accel (void ); +int qtest_init_accel (QEMUMachine *machine);void qtest_init (const char *qtest_chrdev,const char *qtest_log,Error **errp);static inline int qtest_available (void )
kvm-all.c +14 -3
@@ -36,6 +36,8 @@#include "qemu/event_notifier.h" #include "trace.h" +#include "hw/boards.h" +/* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD #include <sys/eventfd.h>
@@ -1339,7 +1341,7 @@ static int kvm_max_vcpus(KVMState *s)return (ret) ? ret :kvm_recommended_vcpus (s); } -int kvm_init (void ) +int kvm_init (QEMUMachine *machine) {static const char upgrade_note[] ="Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
@@ -1356,7 +1358,8 @@ int kvm_init(void)KVMState *s;const KVMCapabilityInfo *missing_cap;int ret; -int i; +int i, type =0 ; +const char *kvm_type; s =g_malloc0 (sizeof (KVMState));
@@ -1430,8 +1433,16 @@ int kvm_init(void) nc++; } + kvm_type =qemu_opt_get (qemu_get_machine_opts (),"kvm-type" ); +if (machine->kvm_type) { + type = machine->kvm_type (kvm_type); + }else if (kvm_type) { +fprintf (stderr,"Invalid argument kvm-type=%s\n" , kvm_type); + goto err; + } +do { - ret =kvm_ioctl (s,KVM_CREATE_VM ,0 ); + ret =kvm_ioctl (s,KVM_CREATE_VM , type); }while (ret == -EINTR );if (ret <0 ) {
kvm-stub.c +1 -1
@@ -35,7 +35,7 @@ int kvm_init_vcpu(CPUState *cpu)return -ENOSYS ; } -int kvm_init (void ) +int kvm_init (QEMUMachine *machine) {return -ENOSYS ; }
qtest.c +1 -1
@@ -500,7 +500,7 @@ static void qtest_event(void *opaque, int event) } } -int qtest_init_accel (void ) +int qtest_init_accel (QEMUMachine *machine) {configure_icount ("0" );
vl.c +9 -5
@@ -374,6 +374,10 @@ static QemuOptsList qemu_machine_opts = { .name = "firmware", .type = QEMU_OPT_STRING, .help = "firmware image", + },{ + .name = "kvm-type", + .type = QEMU_OPT_STRING, + .help = "Specifies the KVM virtualization mode (HV, PR)", }, {/* End of list */ } },
@@ -2578,7 +2582,7 @@ static QEMUMachine *machine_parse(const char *name)exit (!name || !is_help_option (name)); } -static int tcg_init (void ) +static int tcg_init (QEMUMachine *machine) {tcg_exec_init (tcg_tb_size *1024 *1024 );return 0 ;
@@ -2588,7 +2592,7 @@ static struct {const char *opt_name;const char *name;int (*available)(void ); -int (*init)(void ); +int (*init)(QEMUMachine *);bool *allowed; } accel_list[] = { { "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed },
@@ -2597,7 +2601,7 @@ static struct { { "qtest", "QTest", qtest_available, qtest_init_accel, &qtest_allowed }, }; -static int configure_accelerator (void ) +static int configure_accelerator (QEMUMachine *machine) {const char *p;char buf[10 ];
@@ -2624,7 +2628,7 @@ static int configure_accelerator(void)continue ; } *(accel_list[i].allowed) = true; - ret = accel_list[i].init (); + ret = accel_list[i].init (machine);if (ret <0 ) { init_failed = true; fprintf(stderr, "failed to initialize %s: %s\n",
@@ -4053,7 +4057,7 @@ int main(int argc, char **argv, char **envp)exit (0 ); } -configure_accelerator (); +configure_accelerator (machine);if (qtest_chrdev) {Error *local_err =NULL ;
xen-all.c +1 -1
@@ -1001,7 +1001,7 @@ static void xen_exit_notifier(Notifier *n, void *data)xs_daemon_close (state->xenstore); } -int xen_init (void ) +int xen_init (QEMUMachine *machine) { xen_xc =xen_xc_interface_open (0 ,0 ,0 );if (xen_xc ==XC_HANDLER_INITIAL_VALUE ) {
xen-stub.c +1 -1
@@ -47,7 +47,7 @@ qemu_irq *xen_interrupt_controller_init(void)return NULL ; } -int xen_init (void ) +int xen_init (QEMUMachine *machine) {return -ENOSYS ; }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 018/130] target-ppc: General Support for VSX Helpers
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds general support that will be used by the VSX helper routines:
- a union describing the various VSR subfields.
- access routines to get and set VSRs
- VSX decoders
- a general routine to generate a handler that invokes a VSX helper.
--- target-ppc/fpu_helper.c | 41 +++++++++++++++++++++++++++++++++++++++++ target-ppc/translate.c | 14 ++++++++++++++ 2 files changed, 55 insertions(+)
target-ppc/fpu_helper.c +41 -0
@@ -1717,3 +1717,44 @@ uint32_t helper_efdcmpeq(CPUPPCState *env, uint64_t op1, uint64_t op2)/* XXX: TODO: test special values (NaN, infinites, ...) */ return helper_efdtsteq (env, op1, op2); } + +#define DECODE_SPLIT (opcode, shift1, nb1, shift2, nb2) \ + (((((opcode) >> (shift1)) & ((1 << (nb1)) - 1)) << nb2) | \ + (((opcode) >> (shift2)) & ((1 << (nb2)) - 1))) + +#define xT (opcode) DECODE_SPLIT(opcode, 0, 1, 21, 5) +#define xA (opcode) DECODE_SPLIT(opcode, 2, 1, 16, 5) +#define xB (opcode) DECODE_SPLIT(opcode, 1, 1, 11, 5) +#define xC (opcode) DECODE_SPLIT(opcode, 3, 1, 6, 5) +#define BF (opcode) (((opcode) >> (31-8)) & 7) + +typedef union _ppc_vsr_t { +uint64_t u64[2 ]; +uint32_t u32[4 ]; +float32 f32[4 ]; +float64 f64[2 ]; +}ppc_vsr_t ; + +static void getVSR (int n,ppc_vsr_t *vsr,CPUPPCState *env) +{ +if (n <32 ) { + vsr->f64[0 ] = env->fpr[n]; + vsr->u64[1 ] = env->vsr[n]; + }else { + vsr->u64[0 ] = env->avr[n-32 ].u64[0 ]; + vsr->u64[1 ] = env->avr[n-32 ].u64[1 ]; + } +} + +static void putVSR (int n,ppc_vsr_t *vsr,CPUPPCState *env) +{ +if (n <32 ) { + env->fpr[n] = vsr->f64[0 ]; + env->vsr[n] = vsr->u64[1 ]; + }else { + env->avr[n-32 ].u64[0 ] = vsr->u64[0 ]; + env->avr[n-32 ].u64[1 ] = vsr->u64[1 ]; + } +} + +#define float64_to_float64 (x, env) x
target-ppc/translate.c +14 -0
@@ -7289,6 +7289,20 @@ VSX_VECTOR_MOVE(xvnabssp, OP_NABS, SGN_MASK_SP) VSX_VECTOR_MOVE(xvnegsp, OP_NEG, SGN_MASK_SP) VSX_VECTOR_MOVE(xvcpsgnsp, OP_CPSGN, SGN_MASK_SP) +#define GEN_VSX_HELPER_2 (name, op1, op2, inval, type) \ +static void gen_##name(DisasContext * ctx) \ +{ \ + TCGv_i32 opc; \ + if (unlikely(!ctx->vsx_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VSXU); \ + return; \ + } \ +/* NIP cannot be restored if the memory exception comes from an helper */ \ +gen_update_nip (ctx, ctx->nip -4 ); \ + opc =tcg_const_i32 (ctx->opcode); \ + gen_helper_##name(cpu_env, opc); \ + tcg_temp_free_i32(opc); \ +}#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 026/130] target-ppc: Add VSX ISA2.06 xtsqrt Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point test for software square root instructions defined by V2.06 of the PowerPC ISA: xstsqrtdp, xvtsqrtdp, xvtsqrtsp.
--- target-ppc/fpu_helper.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 3 +++ target-ppc/translate.c | 6 ++++++ 3 files changed, 63 insertions(+)
target-ppc/fpu_helper.c +54 -0
@@ -2095,3 +2095,57 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ VSX_TDIV(xstdivdp, 1, float64, f64, -1022, 1023, 52) VSX_TDIV(xvtdivdp, 2, float64, f64, -1022, 1023, 52)VSX_TDIV (xvtdivsp,4 , float32, f32,-126 ,127 ,23 ) + +/* VSX_TSQRT - VSX floating point test for square root +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* emin - minimum unbiased exponent +* emax - maximum unbiased exponent +* nbits - number of fraction bits + */ +#define VSX_TSQRT (op, nels, tp, fld, emin, nbits) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xa, xb; \ + int i; \ + int fe_flag = 0; \ + int fg_flag = 0; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + \ + for (i = 0; i < nels; i++) { \ + if (unlikely(tp##_is_infinity(xb.fld[i]) || \ + tp##_is_zero(xb.fld[i]))) { \ + fe_flag = 1; \ + fg_flag = 1; \ + } else { \ + int e_b = ppc_##tp##_get_unbiased_exp(xb.fld[i]); \ + \ + if (unlikely(tp##_is_any_nan(xb.fld[i]))) { \ + fe_flag = 1; \ + } else if (unlikely(tp##_is_zero(xb.fld[i]))) { \ + fe_flag = 1; \ + } else if (unlikely(tp##_is_neg(xb.fld[i]))) { \ + fe_flag = 1; \ + } else if (!tp##_is_zero(xb.fld[i]) && \ + (e_b <= (emin+nbits))) { \ + fe_flag = 1; \ + } \ + \ + if (unlikely(tp##_is_zero_or_denormal(xb.fld[i]))) { \ +/* XB is not zero because of the above check and */ \ +/* therefore must be denormalized. */ \ + fg_flag =1 ; \ + } \ + } \ + } \ + \ + env->crf[BF (opcode)] =0x8 | (fg_flag ?4 :0 ) | (fe_flag ?2 :0 ); \ +} + +VSX_TSQRT(xstsqrtdp, 1, float64, f64, -1022, 52) +VSX_TSQRT(xvtsqrtdp, 2, float64, f64, -1022, 52) +VSX_TSQRT (xvtsqrtsp,4 , float32, f32,-126 ,23 )
target-ppc/helper.h +3 -0
@@ -259,6 +259,7 @@ DEF_HELPER_2(xsredp, void, env, i32) DEF_HELPER_2(xssqrtdp, void, env, i32) DEF_HELPER_2(xsrsqrtedp, void, env, i32) DEF_HELPER_2(xstdivdp, void, env, i32) +DEF_HELPER_2(xstsqrtdp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
@@ -268,6 +269,7 @@ DEF_HELPER_2(xvredp, void, env, i32) DEF_HELPER_2(xvsqrtdp, void, env, i32) DEF_HELPER_2(xvrsqrtedp, void, env, i32) DEF_HELPER_2(xvtdivdp, void, env, i32) +DEF_HELPER_2(xvtsqrtdp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -277,6 +279,7 @@ DEF_HELPER_2(xvresp, void, env, i32) DEF_HELPER_2(xvsqrtsp, void, env, i32) DEF_HELPER_2(xvrsqrtesp, void, env, i32) DEF_HELPER_2(xvtdivsp, void, env, i32) +DEF_HELPER_2(xvtsqrtsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +6 -0
@@ -7312,6 +7312,7 @@ GEN_VSX_HELPER_2(xsredp, 0x14, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xssqrtdp, 0x16, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsrsqrtedp, 0x14, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xstdivdp, 0x14, 0x07, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xstsqrtdp, 0x14, 0x06, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -7321,6 +7322,7 @@ GEN_VSX_HELPER_2(xvredp, 0x14, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsqrtdp, 0x16, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvrsqrtedp, 0x14, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvtdivdp, 0x14, 0x0F, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvtsqrtdp, 0x14, 0x0E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubsp,0x00 ,0x09 ,0 ,PPC2_VSX )
@@ -7330,6 +7332,7 @@ GEN_VSX_HELPER_2(xvresp, 0x14, 0x09, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsqrtsp, 0x16, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvrsqrtesp, 0x14, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvtdivsp, 0x14, 0x0B, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvtsqrtsp, 0x14, 0x0A, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10020,6 +10023,7 @@ GEN_XX2FORM(xsredp, 0x14, 0x05, PPC2_VSX),GEN_XX2FORM (xssqrtdp,0x16 ,0x04 ,PPC2_VSX ),GEN_XX2FORM (xsrsqrtedp,0x14 ,0x04 ,PPC2_VSX ),GEN_XX3FORM (xstdivdp,0x14 ,0x07 ,PPC2_VSX ), +GEN_XX2FORM (xstsqrtdp,0x14 ,0x06 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
@@ -10029,6 +10033,7 @@ GEN_XX2FORM(xvredp, 0x14, 0x0D, PPC2_VSX),GEN_XX2FORM (xvsqrtdp,0x16 ,0x0C ,PPC2_VSX ),GEN_XX2FORM (xvrsqrtedp,0x14 ,0x0C ,PPC2_VSX ),GEN_XX3FORM (xvtdivdp,0x14 ,0x0F ,PPC2_VSX ), +GEN_XX2FORM (xvtsqrtdp,0x14 ,0x0E ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ), GEN_XX3FORM(xvsubsp, 0x00, 0x09, PPC2_VSX),
@@ -10038,6 +10043,7 @@ GEN_XX2FORM(xvresp, 0x14, 0x09, PPC2_VSX),GEN_XX2FORM (xvsqrtsp,0x16 ,0x08 ,PPC2_VSX ),GEN_XX2FORM (xvrsqrtesp,0x14 ,0x08 ,PPC2_VSX ),GEN_XX3FORM (xvtdivsp,0x14 ,0x0B ,PPC2_VSX ), +GEN_XX2FORM (xvtsqrtsp,0x14 ,0x0A ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 036/130] target-ppc: VSX Stage 4: Add lxsiwax, lxsiwzx and lxsspx
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the scalar load instructions introduced in ISA V2.07:
- Load VSX Scalar as Integer Word Algebraic Indexd (lxsiwax)
- Load VSX Scalar as Integer Word and Zero Indexed (lxsiwzx)
- Load VSX Scalar Single-Precision Indexed (lxsspx)
--- target-ppc/translate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
target-ppc/translate.c +14 -0
@@ -2585,6 +2585,14 @@ static inline void gen_qemu_ld32s(DisasContext *ctx, TCGv arg1, TCGv arg2)tcg_gen_qemu_ld32s (arg1, arg2, ctx->mem_idx); } +static void gen_qemu_ld32s_i64 (DisasContext *ctx,TCGv_i64 val,TCGv addr) +{ +TCGv tmp =tcg_temp_new (); +gen_qemu_ld32s (ctx, tmp, addr); +tcg_gen_ext_tl_i64 (val, tmp); +tcg_temp_free (tmp); +} +static inline void gen_qemu_ld64 (DisasContext *ctx,TCGv_i64 arg1,TCGv arg2) {tcg_gen_qemu_ld64 (arg1, arg2, ctx->mem_idx);
@@ -7039,6 +7047,9 @@ static void gen_##name(DisasContext *ctx) \ } VSX_LOAD_SCALAR(lxsdx, ld64) +VSX_LOAD_SCALAR(lxsiwax, ld32s_i64) +VSX_LOAD_SCALAR(lxsiwzx, ld32u_i64) +VSX_LOAD_SCALAR(lxsspx, ld32fs)static void gen_lxvd2x (DisasContext *ctx) {
@@ -10044,6 +10055,9 @@ GEN_VAFORM_PAIRED(vsel, vperm, 21),GEN_VAFORM_PAIRED (vmaddfp, vnmsubfp,23 ),GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ), +GEN_HANDLER_E (lxsiwax,0x1F ,0x0C ,0x02 ,0 ,PPC_NONE ,PPC2_VSX207 ), +GEN_HANDLER_E (lxsiwzx,0x1F ,0x0C ,0x00 ,0 ,PPC_NONE ,PPC2_VSX207 ), +GEN_HANDLER_E (lxsspx,0x1F ,0x0C ,0x10 ,0 ,PPC_NONE ,PPC2_VSX207 ),GEN_HANDLER_E (lxvd2x,0x1F ,0x0C ,0x1A ,0 ,PPC_NONE ,PPC2_VSX ),GEN_HANDLER_E (lxvdsx,0x1F ,0x0C ,0x0A ,0 ,PPC_NONE ,PPC2_VSX ), GEN_HANDLER_E(lxvw4x, 0x1F, 0x0C, 0x18, 0, PPC_NONE, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 037/130] target-ppc: VSX Stage 4: Refactor stxsdx
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch refactors the stxsdx instruction. Reusable code is extracted into a macro which will be used in subsequent patches in this series.
--- target-ppc/translate.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
target-ppc/translate.c +15 -12
@@ -7112,20 +7112,23 @@ static void gen_lxvw4x(DisasContext *ctx)tcg_temp_free_i64 (tmp); } -static void gen_stxsdx (DisasContext *ctx) -{ -TCGv EA ; -if (unlikely (!ctx->vsx_enabled)) { -gen_exception (ctx,POWERPC_EXCP_VSXU ); -return ; - } -gen_set_access_type (ctx,ACCESS_INT ); -EA =tcg_temp_new (); -gen_addr_reg_index (ctx,EA ); -gen_qemu_st64 (ctx,cpu_vsrh (xS (ctx->opcode)),EA ); -tcg_temp_free (EA ); +#define VSX_STORE_SCALAR (name, operation) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + TCGv EA; \ + if (unlikely(!ctx->vsx_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VSXU); \ + return; \ + } \ + gen_set_access_type(ctx, ACCESS_INT); \ + EA = tcg_temp_new(); \ + gen_addr_reg_index(ctx, EA); \ + gen_qemu_##operation(ctx, cpu_vsrh(xS(ctx->opcode)), EA); \ + tcg_temp_free(EA); \ } +VSX_STORE_SCALAR(stxsdx, st64) +static void gen_stxvd2x (DisasContext *ctx) {TCGv EA ;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 038/130] target-ppc: VSX Stage 4: Add stxsiwx and stxsspx
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds two store scalar instructions:
- Store VSX Scalar as Integer Word Indexed (stxsiwx)
- Store VSX Scalar Single-Precision Indexed (stxsspx)
--- target-ppc/translate.c | 4 ++++ 1 file changed, 4 insertions(+)
target-ppc/translate.c +4 -0
@@ -7128,6 +7128,8 @@ static void gen_##name(DisasContext *ctx) \ } VSX_STORE_SCALAR(stxsdx, st64) +VSX_STORE_SCALAR(stxsiwx, st32_i64) +VSX_STORE_SCALAR(stxsspx, st32fs)static void gen_stxvd2x (DisasContext *ctx) {
@@ -10066,6 +10068,8 @@ GEN_HANDLER_E(lxvdsx, 0x1F, 0x0C, 0x0A, 0, PPC_NONE, PPC2_VSX),GEN_HANDLER_E (lxvw4x,0x1F ,0x0C ,0x18 ,0 ,PPC_NONE ,PPC2_VSX ),GEN_HANDLER_E (stxsdx,0x1F ,0xC ,0x16 ,0 ,PPC_NONE ,PPC2_VSX ), +GEN_HANDLER_E (stxsiwx,0x1F ,0xC ,0x04 ,0 ,PPC_NONE ,PPC2_VSX207 ), +GEN_HANDLER_E (stxsspx,0x1F ,0xC ,0x14 ,0 ,PPC_NONE ,PPC2_VSX207 ),GEN_HANDLER_E (stxvd2x,0x1F ,0xC ,0x1E ,0 ,PPC_NONE ,PPC2_VSX ), GEN_HANDLER_E(stxvw4x, 0x1F, 0xC, 0x1C, 0, PPC_NONE, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 028/130] target-ppc: Add VSX xscmp*dp Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX scalar floating point compare ordered and unordered instructions.
--- target-ppc/fpu_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 2 ++ target-ppc/translate.c | 4 ++++ 3 files changed, 45 insertions(+)
target-ppc/fpu_helper.c +39 -0
@@ -2249,3 +2249,42 @@ VSX_MADD(xvnmaddasp, 4, float32, f32, NMADD_FLGS, 1, 0) VSX_MADD(xvnmaddmsp, 4, float32, f32, NMADD_FLGS, 0, 0) VSX_MADD(xvnmsubasp, 4, float32, f32, NMSUB_FLGS, 1, 0) VSX_MADD(xvnmsubmsp, 4, float32, f32, NMSUB_FLGS, 0, 0) + +#define VSX_SCALAR_CMP (op, ordered) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xa, xb; \ + uint32_t cc = 0; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + \ + if (unlikely(float64_is_any_nan(xa.f64[0]) || \ + float64_is_any_nan(xb.f64[0]))) { \ + if (float64_is_signaling_nan(xa.f64[0]) || \ + float64_is_signaling_nan(xb.f64[0])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0); \ + } \ + if (ordered) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXVC, 0); \ + } \ + cc = 1; \ + } else { \ + if (float64_lt(xa.f64[0], xb.f64[0], &env->fp_status)) { \ + cc = 8; \ + } else if (!float64_le(xa.f64[0], xb.f64[0], &env->fp_status)) { \ + cc = 4; \ + } else { \ + cc = 2; \ + } \ + } \ + \ + env->fpscr &= ~(0x0F << FPSCR_FPRF); \ + env->fpscr |= cc << FPSCR_FPRF; \ + env->crf[BF(opcode)] = cc; \ + \ + helper_float_check_status(env); \ +} + +VSX_SCALAR_CMP(xscmpodp, 1) +VSX_SCALAR_CMP (xscmpudp,0 )
target-ppc/helper.h +2 -0
@@ -268,6 +268,8 @@ DEF_HELPER_2(xsnmaddadp, void, env, i32) DEF_HELPER_2(xsnmaddmdp, void, env, i32) DEF_HELPER_2(xsnmsubadp, void, env, i32) DEF_HELPER_2(xsnmsubmdp, void, env, i32) +DEF_HELPER_2(xscmpodp, void, env, i32) +DEF_HELPER_2(xscmpudp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
target-ppc/translate.c +4 -0
@@ -7321,6 +7321,8 @@ GEN_VSX_HELPER_2(xsnmaddadp, 0x04, 0x14, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsnmaddmdp, 0x04, 0x15, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsnmsubadp, 0x04, 0x16, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsnmsubmdp, 0x04, 0x17, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xscmpodp, 0x0C, 0x05, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xscmpudp, 0x0C, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -10056,6 +10058,8 @@ GEN_XX3FORM(xsnmaddadp, 0x04, 0x14, PPC2_VSX),GEN_XX3FORM (xsnmaddmdp,0x04 ,0x15 ,PPC2_VSX ),GEN_XX3FORM (xsnmsubadp,0x04 ,0x16 ,PPC2_VSX ),GEN_XX3FORM (xsnmsubmdp,0x04 ,0x17 ,PPC2_VSX ), +GEN_XX2FORM (xscmpodp,0x0C ,0x05 ,PPC2_VSX ), +GEN_XX2FORM (xscmpudp,0x0C ,0x04 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 033/130] target-ppc: Add VSX Rounding Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Round to Floating Point Integer instructions:
- xsrdpi, xsrdpic, xsrdpim, xsrdpip, xsrdpiz
- xvrdpi, xvrdpic, xvrdpim, xvrdpip, xvrdpiz
- xvrspi, xvrspic, xvrspim, xvrspip, xvrspiz
--- target-ppc/fpu_helper.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 15 +++++++++++ target-ppc/translate.c | 30 ++++++++++++++++++++++ 3 files changed, 113 insertions(+)
target-ppc/fpu_helper.c +68 -0
@@ -2537,3 +2537,71 @@ VSX_CVT_INT_TO_FP(xvcvuxdsp, 2, uint64, float32, u64[i], f32[j], \ 2*i + JOFFSET, 0) VSX_CVT_INT_TO_FP(xvcvsxwsp, 4, int32, float32, u32[j], f32[i], i, 0)VSX_CVT_INT_TO_FP (xvcvuxwsp,4 , uint32, float32, u32[j], f32[i], i,0 ) + +/* For "use current rounding mode", define a value that will not be one of +* the existing rounding model enums. + */ +#define FLOAT_ROUND_CURRENT (float_round_nearest_even + float_round_down + \ + float_round_up + float_round_to_zero) + +/* VSX_ROUND - VSX floating point round +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* rmode - rounding mode +* sfprf - set FPRF +*/ +#define VSX_ROUND (op, nels, tp, fld, rmode, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xb; \ + int i; \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + \ + if (rmode != FLOAT_ROUND_CURRENT) { \ + set_float_rounding_mode(rmode, &env->fp_status); \ + } \ + \ + for (i = 0; i < nels; i++) { \ + if (unlikely(tp##_is_signaling_nan(xb.fld[i]))) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0); \ + xt.fld[i] = tp##_snan_to_qnan(xb.fld[i]); \ + } else { \ + xt.fld[i] = tp##_round_to_int(xb.fld[i], &env->fp_status); \ + } \ + if (sfprf) { \ + helper_compute_fprf(env, xt.fld[i], sfprf); \ + } \ + } \ + \ +/* If this is not a "use current rounding mode" instruction, \ +* then inhibit setting of the XX bit and restore rounding \ +* mode from FPSCR */ \ +if (rmode !=FLOAT_ROUND_CURRENT ) { \ +fpscr_set_rounding_mode (env); \ + env->fp_status.float_exception_flags &= ~float_flag_inexact; \ + } \ + \ +putVSR (xT (opcode), &xt, env); \ +helper_float_check_status (env); \ +} + +VSX_ROUND(xsrdpi, 1, float64, f64, float_round_nearest_even, 1) +VSX_ROUND(xsrdpic, 1, float64, f64, FLOAT_ROUND_CURRENT, 1) +VSX_ROUND(xsrdpim, 1, float64, f64, float_round_down, 1) +VSX_ROUND(xsrdpip, 1, float64, f64, float_round_up, 1) +VSX_ROUND(xsrdpiz, 1, float64, f64, float_round_to_zero, 1) + +VSX_ROUND(xvrdpi, 2, float64, f64, float_round_nearest_even, 0) +VSX_ROUND(xvrdpic, 2, float64, f64, FLOAT_ROUND_CURRENT, 0) +VSX_ROUND(xvrdpim, 2, float64, f64, float_round_down, 0) +VSX_ROUND(xvrdpip, 2, float64, f64, float_round_up, 0) +VSX_ROUND(xvrdpiz, 2, float64, f64, float_round_to_zero, 0) + +VSX_ROUND(xvrspi, 4, float32, f32, float_round_nearest_even, 0) +VSX_ROUND(xvrspic, 4, float32, f32, FLOAT_ROUND_CURRENT, 0) +VSX_ROUND(xvrspim, 4, float32, f32, float_round_down, 0) +VSX_ROUND(xvrspip, 4, float32, f32, float_round_up, 0) +VSX_ROUND (xvrspiz,4 , float32, f32, float_round_to_zero,0 )
target-ppc/helper.h +15 -0
@@ -280,6 +280,11 @@ DEF_HELPER_2(xscvdpuxds, void, env, i32) DEF_HELPER_2(xscvdpuxws, void, env, i32) DEF_HELPER_2(xscvsxddp, void, env, i32) DEF_HELPER_2(xscvuxddp, void, env, i32) +DEF_HELPER_2(xsrdpi, void, env, i32) +DEF_HELPER_2(xsrdpic, void, env, i32) +DEF_HELPER_2(xsrdpim, void, env, i32) +DEF_HELPER_2(xsrdpip, void, env, i32) +DEF_HELPER_2(xsrdpiz, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
@@ -312,6 +317,11 @@ DEF_HELPER_2(xvcvsxddp, void, env, i32) DEF_HELPER_2(xvcvuxddp, void, env, i32) DEF_HELPER_2(xvcvsxwdp, void, env, i32) DEF_HELPER_2(xvcvuxwdp, void, env, i32) +DEF_HELPER_2(xvrdpi, void, env, i32) +DEF_HELPER_2(xvrdpic, void, env, i32) +DEF_HELPER_2(xvrdpim, void, env, i32) +DEF_HELPER_2(xvrdpip, void, env, i32) +DEF_HELPER_2(xvrdpiz, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -344,6 +354,11 @@ DEF_HELPER_2(xvcvsxdsp, void, env, i32) DEF_HELPER_2(xvcvuxdsp, void, env, i32) DEF_HELPER_2(xvcvsxwsp, void, env, i32) DEF_HELPER_2(xvcvuxwsp, void, env, i32) +DEF_HELPER_2(xvrspi, void, env, i32) +DEF_HELPER_2(xvrspic, void, env, i32) +DEF_HELPER_2(xvrspim, void, env, i32) +DEF_HELPER_2(xvrspip, void, env, i32) +DEF_HELPER_2(xvrspiz, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +30 -0
@@ -7333,6 +7333,11 @@ GEN_VSX_HELPER_2(xscvdpuxds, 0x10, 0x14, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscvdpuxws, 0x10, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscvsxddp, 0x10, 0x17, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscvuxddp, 0x10, 0x16, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsrdpi, 0x12, 0x04, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsrdpic, 0x16, 0x06, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsrdpim, 0x12, 0x07, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsrdpip, 0x12, 0x06, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsrdpiz, 0x12, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -7365,6 +7370,11 @@ GEN_VSX_HELPER_2(xvcvsxddp, 0x10, 0x1F, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvuxddp, 0x10, 0x1E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvsxwdp, 0x10, 0x0F, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvuxwdp, 0x10, 0x0E, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrdpi, 0x12, 0x0C, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrdpic, 0x16, 0x0E, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrdpim, 0x12, 0x0F, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrdpip, 0x12, 0x0E, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrdpiz, 0x12, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubsp,0x00 ,0x09 ,0 ,PPC2_VSX )
@@ -7397,6 +7407,11 @@ GEN_VSX_HELPER_2(xvcvsxdsp, 0x10, 0x1B, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvuxdsp, 0x10, 0x1A, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvsxwsp, 0x10, 0x0B, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvuxwsp, 0x10, 0x0A, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrspi, 0x12, 0x08, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrspic, 0x16, 0x0A, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrspim, 0x12, 0x0B, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrspip, 0x12, 0x0A, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvrspiz, 0x12, 0x09, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10119,6 +10134,11 @@ GEN_XX2FORM(xscvdpuxds, 0x10, 0x14, PPC2_VSX),GEN_XX2FORM (xscvdpuxws,0x10 ,0x04 ,PPC2_VSX ),GEN_XX2FORM (xscvsxddp,0x10 ,0x17 ,PPC2_VSX ),GEN_XX2FORM (xscvuxddp,0x10 ,0x16 ,PPC2_VSX ), +GEN_XX2FORM (xsrdpi,0x12 ,0x04 ,PPC2_VSX ), +GEN_XX2FORM (xsrdpic,0x16 ,0x06 ,PPC2_VSX ), +GEN_XX2FORM (xsrdpim,0x12 ,0x07 ,PPC2_VSX ), +GEN_XX2FORM (xsrdpip,0x12 ,0x06 ,PPC2_VSX ), +GEN_XX2FORM (xsrdpiz,0x12 ,0x05 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
@@ -10151,6 +10171,11 @@ GEN_XX2FORM(xvcvsxddp, 0x10, 0x1F, PPC2_VSX),GEN_XX2FORM (xvcvuxddp,0x10 ,0x1E ,PPC2_VSX ),GEN_XX2FORM (xvcvsxwdp,0x10 ,0x0F ,PPC2_VSX ),GEN_XX2FORM (xvcvuxwdp,0x10 ,0x0E ,PPC2_VSX ), +GEN_XX2FORM (xvrdpi,0x12 ,0x0C ,PPC2_VSX ), +GEN_XX2FORM (xvrdpic,0x16 ,0x0E ,PPC2_VSX ), +GEN_XX2FORM (xvrdpim,0x12 ,0x0F ,PPC2_VSX ), +GEN_XX2FORM (xvrdpip,0x12 ,0x0E ,PPC2_VSX ), +GEN_XX2FORM (xvrdpiz,0x12 ,0x0D ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ), GEN_XX3FORM(xvsubsp, 0x00, 0x09, PPC2_VSX),
@@ -10183,6 +10208,11 @@ GEN_XX2FORM(xvcvsxdsp, 0x10, 0x1B, PPC2_VSX),GEN_XX2FORM (xvcvuxdsp,0x10 ,0x1A ,PPC2_VSX ),GEN_XX2FORM (xvcvsxwsp,0x10 ,0x0B ,PPC2_VSX ),GEN_XX2FORM (xvcvuxwsp,0x10 ,0x0A ,PPC2_VSX ), +GEN_XX2FORM (xvrspi,0x12 ,0x08 ,PPC2_VSX ), +GEN_XX2FORM (xvrspic,0x16 ,0x0A ,PPC2_VSX ), +GEN_XX2FORM (xvrspim,0x12 ,0x0B ,PPC2_VSX ), +GEN_XX2FORM (xvrspip,0x12 ,0x0A ,PPC2_VSX ), +GEN_XX2FORM (xvrspiz,0x12 ,0x09 ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 039/130] target-ppc: VSX Stage 4: Add xsaddsp and xssubsp
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Scalar Add Single-Precision (xsaddsp) and VSX Scalar Subtract Single-Precision (xssubsp) instructions.
The existing VSX_ADD_SUB macro is modified to support the rounding of the (intermediate) result to single-precision.
--- target-ppc/fpu_helper.c | 20 +++++++++++++------- target-ppc/helper.h | 3 +++ target-ppc/translate.c | 6 ++++++ 3 files changed, 22 insertions(+), 7 deletions(-)
target-ppc/fpu_helper.c +13 -7
@@ -1768,7 +1768,7 @@ static void putVSR(int n, ppc_vsr_t *vsr, CPUPPCState *env)* fld - vsr_t field (f32 or f64) * sfprf - set FPRF */ -#define VSX_ADD_SUB (name, op, nels, tp, fld, sfprf) \ +#define VSX_ADD_SUB (name, op, nels, tp, fld, sfprf, r2sp) \ void helper_##name(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt, xa, xb; \
@@ -1794,6 +1794,10 @@ void helper_##name(CPUPPCState *env, uint32_t opcode) \ } \ } \ \ +if (r2sp) { \ + xt.fld[i] =helper_frsp (env, xt.fld[i]); \ + } \ + \if (sfprf) { \helper_compute_fprf (env, xt.fld[i], sfprf); \ } \
@@ -1802,12 +1806,14 @@ void helper_##name(CPUPPCState *env, uint32_t opcode) \helper_float_check_status (env); \ } -VSX_ADD_SUB(xsadddp, add, 1, float64, f64, 1) -VSX_ADD_SUB(xvadddp, add, 2, float64, f64, 0) -VSX_ADD_SUB(xvaddsp, add, 4, float32, f32, 0) -VSX_ADD_SUB(xssubdp, sub, 1, float64, f64, 1) -VSX_ADD_SUB(xvsubdp, sub, 2, float64, f64, 0) -VSX_ADD_SUB (xvsubsp, sub,4 , float32, f32,0 ) +VSX_ADD_SUB(xsadddp, add, 1, float64, f64, 1, 0) +VSX_ADD_SUB(xsaddsp, add, 1, float64, f64, 1, 1) +VSX_ADD_SUB(xvadddp, add, 2, float64, f64, 0, 0) +VSX_ADD_SUB(xvaddsp, add, 4, float32, f32, 0, 0) +VSX_ADD_SUB(xssubdp, sub, 1, float64, f64, 1, 0) +VSX_ADD_SUB(xssubsp, sub, 1, float64, f64, 1, 1) +VSX_ADD_SUB(xvsubdp, sub, 2, float64, f64, 0, 0) +VSX_ADD_SUB (xvsubsp, sub,4 , float32, f32,0 ,0 )/* VSX_MUL - VSX floating point multiply * op - instruction mnemonic
target-ppc/helper.h +3 -0
@@ -286,6 +286,9 @@ DEF_HELPER_2(xsrdpim, void, env, i32) DEF_HELPER_2(xsrdpip, void, env, i32) DEF_HELPER_2(xsrdpiz, void, env, i32) +DEF_HELPER_2(xsaddsp, void, env, i32) +DEF_HELPER_2(xssubsp, void, env, i32) + DEF_HELPER_2(xvadddp, void, env, i32) DEF_HELPER_2(xvsubdp, void, env, i32)DEF_HELPER_2 (xvmuldp, void, env, i32)
target-ppc/translate.c +6 -0
@@ -7358,6 +7358,9 @@ GEN_VSX_HELPER_2(xsrdpim, 0x12, 0x07, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsrdpip, 0x12, 0x06, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsrdpiz, 0x12, 0x05, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsaddsp, 0x00, 0x00, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xssubsp, 0x00, 0x01, 0, PPC2_VSX207) + GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubdp, 0x00, 0x0D, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvmuldp,0x00 ,0x0E ,0 ,PPC2_VSX )
@@ -10164,6 +10167,9 @@ GEN_XX2FORM(xsrdpim, 0x12, 0x07, PPC2_VSX),GEN_XX2FORM (xsrdpip,0x12 ,0x06 ,PPC2_VSX ),GEN_XX2FORM (xsrdpiz,0x12 ,0x05 ,PPC2_VSX ), +GEN_XX3FORM (xsaddsp,0x00 ,0x00 ,PPC2_VSX207 ), +GEN_XX3FORM (xssubsp,0x00 ,0x01 ,PPC2_VSX207 ), +GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ),GEN_XX3FORM (xvsubdp,0x00 ,0x0D ,PPC2_VSX ), GEN_XX3FORM(xvmuldp, 0x00, 0x0E, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 040/130] target-ppc: VSX Stage 4: Add xsmulsp
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Scalar Multiply Single-Precision (xsmulsp) instruction.
The existing VSX_MUL macro is modified to support rounding of the intermediate result to single precision.
--- target-ppc/fpu_helper.c | 13 +++++++++---- target-ppc/helper.h | 1 + target-ppc/translate.c | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-)
target-ppc/fpu_helper.c +9 -4
@@ -1822,7 +1822,7 @@ VSX_ADD_SUB(xvsubsp, sub, 4, float32, f32, 0, 0)* fld - vsr_t field (f32 or f64) * sfprf - set FPRF */ -#define VSX_MUL (op, nels, tp, fld, sfprf) \ +#define VSX_MUL (op, nels, tp, fld, sfprf, r2sp) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt, xa, xb; \
@@ -1849,6 +1849,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ } \ } \ \ +if (r2sp) { \ + xt.fld[i] =helper_frsp (env, xt.fld[i]); \ + } \ + \if (sfprf) { \helper_compute_fprf (env, xt.fld[i], sfprf); \ } \
@@ -1858,9 +1862,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \helper_float_check_status (env); \ } -VSX_MUL(xsmuldp, 1, float64, f64, 1) -VSX_MUL(xvmuldp, 2, float64, f64, 0) -VSX_MUL (xvmulsp,4 , float32, f32,0 ) +VSX_MUL(xsmuldp, 1, float64, f64, 1, 0) +VSX_MUL(xsmulsp, 1, float64, f64, 1, 1) +VSX_MUL(xvmuldp, 2, float64, f64, 0, 0) +VSX_MUL (xvmulsp,4 , float32, f32,0 ,0 )/* VSX_DIV - VSX floating point divide * op - instruction mnemonic
target-ppc/helper.h +1 -0
@@ -288,6 +288,7 @@ DEF_HELPER_2(xsrdpiz, void, env, i32) DEF_HELPER_2(xsaddsp, void, env, i32) DEF_HELPER_2(xssubsp, void, env, i32) +DEF_HELPER_2(xsmulsp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
target-ppc/translate.c +2 -0
@@ -7360,6 +7360,7 @@ GEN_VSX_HELPER_2(xsrdpiz, 0x12, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsaddsp, 0x00, 0x00, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xssubsp, 0x00, 0x01, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsmulsp, 0x00, 0x02, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -10169,6 +10170,7 @@ GEN_XX2FORM(xsrdpiz, 0x12, 0x05, PPC2_VSX),GEN_XX3FORM (xsaddsp,0x00 ,0x00 ,PPC2_VSX207 ),GEN_XX3FORM (xssubsp,0x00 ,0x01 ,PPC2_VSX207 ), +GEN_XX3FORM (xsmulsp,0x00 ,0x02 ,PPC2_VSX207 ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 042/130] target-ppc: VSX Stage 4: Add xsresp
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Scalar Reciprocal Estimate Single Precision (xsresp) instruction.
The existing VSX_RE macro is modified to support rounding of the intermediate double precision result to single precision.
--- target-ppc/fpu_helper.c | 14 ++++++++++---- target-ppc/helper.h | 1 + target-ppc/translate.c | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-)
target-ppc/fpu_helper.c +10 -4
@@ -1928,7 +1928,7 @@ VSX_DIV(xvdivsp, 4, float32, f32, 0, 0)* fld - vsr_t field (f32 or f64) * sfprf - set FPRF */ -#define VSX_RE (op, nels, tp, fld, sfprf) \ +#define VSX_RE (op, nels, tp, fld, sfprf, r2sp) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt, xb; \
@@ -1943,6 +1943,11 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN , sfprf); \ } \ xt.fld[i] = tp##_div(tp##_one, xb.fld[i], &env->fp_status); \ + \ +if (r2sp) { \ + xt.fld[i] =helper_frsp (env, xt.fld[i]); \ + } \ + \if (sfprf) { \helper_compute_fprf (env, xt.fld[0 ], sfprf); \ } \
@@ -1952,9 +1957,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \helper_float_check_status (env); \ } -VSX_RE(xsredp, 1, float64, f64, 1) -VSX_RE(xvredp, 2, float64, f64, 0) -VSX_RE (xvresp,4 , float32, f32,0 ) +VSX_RE(xsredp, 1, float64, f64, 1, 0) +VSX_RE(xsresp, 1, float64, f64, 1, 1) +VSX_RE(xvredp, 2, float64, f64, 0, 0) +VSX_RE (xvresp,4 , float32, f32,0 ,0 )/* VSX_SQRT - VSX floating point square root * op - instruction mnemonic
target-ppc/helper.h +1 -0
@@ -290,6 +290,7 @@ DEF_HELPER_2(xsaddsp, void, env, i32) DEF_HELPER_2(xssubsp, void, env, i32) DEF_HELPER_2(xsmulsp, void, env, i32) DEF_HELPER_2(xsdivsp, void, env, i32) +DEF_HELPER_2(xsresp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
target-ppc/translate.c +2 -0
@@ -7362,6 +7362,7 @@ GEN_VSX_HELPER_2(xsaddsp, 0x00, 0x00, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xssubsp, 0x00, 0x01, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsmulsp, 0x00, 0x02, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsdivsp, 0x00, 0x03, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsresp, 0x14, 0x01, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -10173,6 +10174,7 @@ GEN_XX3FORM(xsaddsp, 0x00, 0x00, PPC2_VSX207),GEN_XX3FORM (xssubsp,0x00 ,0x01 ,PPC2_VSX207 ),GEN_XX3FORM (xsmulsp,0x00 ,0x02 ,PPC2_VSX207 ),GEN_XX3FORM (xsdivsp,0x00 ,0x03 ,PPC2_VSX207 ), +GEN_XX2FORM (xsresp,0x14 ,0x01 ,PPC2_VSX207 ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 022/130] target-ppc: Add VSX ISA2.06 xre Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point reciprocal estimate instructions defined by V2.06 of the PowerPC ISA: xsredp, xvredp, xvresp.
--- target-ppc/fpu_helper.c | 35 +++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 3 +++ target-ppc/translate.c | 6 ++++++ 3 files changed, 44 insertions(+)
target-ppc/fpu_helper.c +35 -0
@@ -1904,3 +1904,38 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ VSX_DIV(xsdivdp, 1, float64, f64, 1) VSX_DIV(xvdivdp, 2, float64, f64, 0)VSX_DIV (xvdivsp,4 , float32, f32,0 ) + +/* VSX_RE - VSX floating point reciprocal estimate +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* sfprf - set FPRF + */ +#define VSX_RE (op, nels, tp, fld, sfprf) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xb; \ + int i; \ + \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + helper_reset_fpstatus(env); \ + \ + for (i = 0; i < nels; i++) { \ + if (unlikely(tp##_is_signaling_nan(xb.fld[i]))) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, sfprf); \ + } \ + xt.fld[i] = tp##_div(tp##_one, xb.fld[i], &env->fp_status); \ + if (sfprf) { \ + helper_compute_fprf(env, xt.fld[0], sfprf); \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_RE(xsredp, 1, float64, f64, 1) +VSX_RE(xvredp, 2, float64, f64, 0) +VSX_RE (xvresp,4 , float32, f32,0 )
target-ppc/helper.h +3 -0
@@ -255,16 +255,19 @@ DEF_HELPER_2(xsadddp, void, env, i32) DEF_HELPER_2(xssubdp, void, env, i32) DEF_HELPER_2(xsmuldp, void, env, i32) DEF_HELPER_2(xsdivdp, void, env, i32) +DEF_HELPER_2(xsredp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32) DEF_HELPER_2(xvsubdp, void, env, i32) DEF_HELPER_2(xvmuldp, void, env, i32) DEF_HELPER_2(xvdivdp, void, env, i32) +DEF_HELPER_2(xvredp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32) DEF_HELPER_2(xvsubsp, void, env, i32) DEF_HELPER_2(xvmulsp, void, env, i32) DEF_HELPER_2(xvdivsp, void, env, i32) +DEF_HELPER_2(xvresp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +6 -0
@@ -7308,16 +7308,19 @@ GEN_VSX_HELPER_2(xsadddp, 0x00, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xssubdp, 0x00, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsmuldp, 0x00, 0x06, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsdivdp, 0x00, 0x07, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xsredp, 0x14, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubdp, 0x00, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmuldp, 0x00, 0x0E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvdivdp, 0x00, 0x0F, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvredp, 0x14, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvsubsp, 0x00, 0x09, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmulsp, 0x00, 0x0A, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvdivsp, 0x00, 0x0B, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvresp, 0x14, 0x09, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10004,16 +10007,19 @@ GEN_XX3FORM(xsadddp, 0x00, 0x04, PPC2_VSX),GEN_XX3FORM (xssubdp,0x00 ,0x05 ,PPC2_VSX ),GEN_XX3FORM (xsmuldp,0x00 ,0x06 ,PPC2_VSX ),GEN_XX3FORM (xsdivdp,0x00 ,0x07 ,PPC2_VSX ), +GEN_XX2FORM (xsredp,0x14 ,0x05 ,PPC2_VSX ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ),GEN_XX3FORM (xvsubdp,0x00 ,0x0D ,PPC2_VSX ),GEN_XX3FORM (xvmuldp,0x00 ,0x0E ,PPC2_VSX ),GEN_XX3FORM (xvdivdp,0x00 ,0x0F ,PPC2_VSX ), +GEN_XX2FORM (xvredp,0x14 ,0x0D ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ),GEN_XX3FORM (xvsubsp,0x00 ,0x09 ,PPC2_VSX ),GEN_XX3FORM (xvmulsp,0x00 ,0x0A ,PPC2_VSX ),GEN_XX3FORM (xvdivsp,0x00 ,0x0B ,PPC2_VSX ), +GEN_XX2FORM (xvresp,0x14 ,0x09 ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 030/130] target-ppc: Add VSX Vector Compare Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX floating point compare vector instructions:
- xvcmpeqdp[.], xvcmpgedp[.], xvcmpgtdp[.]
- xvcmpeqsp[.], xvcmpgesp[.], xvcmpgtsp[.]
--- target-ppc/fpu_helper.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 6 ++++++ target-ppc/translate.c | 23 ++++++++++++++++++++ 3 files changed, 86 insertions(+)
target-ppc/fpu_helper.c +57 -0
@@ -2327,3 +2327,60 @@ VSX_MAX_MIN(xvmaxsp, maxnum, 4, float32, f32) VSX_MAX_MIN(xsmindp, minnum, 1, float64, f64) VSX_MAX_MIN(xvmindp, minnum, 2, float64, f64)VSX_MAX_MIN (xvminsp, minnum,4 , float32, f32) + +/* VSX_CMP - VSX floating point compare +* op - instruction mnemonic +* nels - number of elements (1, 2 or 4) +* tp - type (float32 or float64) +* fld - vsr_t field (f32 or f64) +* cmp - comparison operation +* svxvc - set VXVC bit + */ +#define VSX_CMP (op, nels, tp, fld, cmp, svxvc) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xa, xb; \ + int i; \ + int all_true = 1; \ + int all_false = 1; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + \ + for (i = 0; i < nels; i++) { \ + if (unlikely(tp##_is_any_nan(xa.fld[i]) || \ + tp##_is_any_nan(xb.fld[i]))) { \ + if (tp##_is_signaling_nan(xa.fld[i]) || \ + tp##_is_signaling_nan(xb.fld[i])) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0); \ + } \ + if (svxvc) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXVC, 0); \ + } \ + xt.fld[i] = 0; \ + all_true = 0; \ + } else { \ + if (tp##_##cmp(xb.fld[i], xa.fld[i], &env->fp_status) == 1) { \ + xt.fld[i] = -1; \ + all_false = 0; \ + } else { \ + xt.fld[i] = 0; \ + all_true = 0; \ + } \ + } \ + } \ + \ + putVSR(xT(opcode), &xt, env); \ + if ((opcode >> (31-21)) & 1) { \ + env->crf[6] = (all_true ? 0x8 : 0) | (all_false ? 0x2 : 0); \ + } \ + helper_float_check_status(env); \ + } + +VSX_CMP(xvcmpeqdp, 2, float64, f64, eq, 0) +VSX_CMP(xvcmpgedp, 2, float64, f64, le, 1) +VSX_CMP(xvcmpgtdp, 2, float64, f64, lt, 1) +VSX_CMP(xvcmpeqsp, 4, float32, f32, eq, 0) +VSX_CMP(xvcmpgesp, 4, float32, f32, le, 1) +VSX_CMP (xvcmpgtsp,4 , float32, f32, lt,1 )
target-ppc/helper.h +6 -0
@@ -292,6 +292,9 @@ DEF_HELPER_2(xvnmsubadp, void, env, i32) DEF_HELPER_2(xvnmsubmdp, void, env, i32) DEF_HELPER_2(xvmaxdp, void, env, i32) DEF_HELPER_2(xvmindp, void, env, i32) +DEF_HELPER_2(xvcmpeqdp, void, env, i32) +DEF_HELPER_2(xvcmpgedp, void, env, i32) +DEF_HELPER_2(xvcmpgtdp, void, env, i32) DEF_HELPER_2(xvaddsp, void, env, i32)DEF_HELPER_2 (xvsubsp, void, env, i32)
@@ -312,6 +315,9 @@ DEF_HELPER_2(xvnmsubasp, void, env, i32) DEF_HELPER_2(xvnmsubmsp, void, env, i32) DEF_HELPER_2(xvmaxsp, void, env, i32) DEF_HELPER_2(xvminsp, void, env, i32) +DEF_HELPER_2(xvcmpeqsp, void, env, i32) +DEF_HELPER_2(xvcmpgesp, void, env, i32) +DEF_HELPER_2(xvcmpgtsp, void, env, i32) DEF_HELPER_2(efscfsi, i32, env, i32)DEF_HELPER_2 (efscfui, i32, env, i32)
target-ppc/translate.c +23 -0
@@ -7345,6 +7345,9 @@ GEN_VSX_HELPER_2(xvnmsubadp, 0x04, 0x1E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvnmsubmdp, 0x04, 0x1F, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmaxdp, 0x00, 0x1C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmindp, 0x00, 0x1D, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcmpeqdp, 0x0C, 0x0C, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcmpgtdp, 0x0C, 0x0D, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcmpgedp, 0x0C, 0x0E, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubsp,0x00 ,0x09 ,0 ,PPC2_VSX )
@@ -7365,6 +7368,9 @@ GEN_VSX_HELPER_2(xvnmsubasp, 0x04, 0x1A, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvnmsubmsp, 0x04, 0x1B, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvmaxsp, 0x00, 0x18, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvminsp, 0x00, 0x19, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcmpeqsp, 0x0C, 0x08, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcmpgtsp, 0x0C, 0x09, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcmpgesp, 0x0C, 0x0A, 0, PPC2_VSX)#define VSX_LOGICAL (name, tcg_op) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10014,6 +10020,17 @@ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2), \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 2, opc3, 0, PPC_NONE, fl2), \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 3, opc3, 0, PPC_NONE, fl2) +#undef GEN_XX3_RC_FORM +#define GEN_XX3_RC_FORM (name, opc2, opc3, fl2) \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x00, opc3 | 0x00, 0, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x01, opc3 | 0x00, 0, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x02, opc3 | 0x00, 0, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x03, opc3 | 0x00, 0, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x00, opc3 | 0x10, 0, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x01, opc3 | 0x10, 0, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x02, opc3 | 0x10, 0, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x03, opc3 | 0x10, 0, PPC_NONE, fl2) +#undef GEN_XX3FORM_DM#define GEN_XX3FORM_DM (name, opc2, opc3) \ GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x00, opc3|0x00, 0, PPC_NONE, PPC2_VSX),\
@@ -10088,6 +10105,9 @@ GEN_XX3FORM(xvnmsubadp, 0x04, 0x1E, PPC2_VSX),GEN_XX3FORM (xvnmsubmdp,0x04 ,0x1F ,PPC2_VSX ),GEN_XX3FORM (xvmaxdp,0x00 ,0x1C ,PPC2_VSX ),GEN_XX3FORM (xvmindp,0x00 ,0x1D ,PPC2_VSX ), +GEN_XX3_RC_FORM (xvcmpeqdp,0x0C ,0x0C ,PPC2_VSX ), +GEN_XX3_RC_FORM (xvcmpgtdp,0x0C ,0x0D ,PPC2_VSX ), +GEN_XX3_RC_FORM (xvcmpgedp,0x0C ,0x0E ,PPC2_VSX ),GEN_XX3FORM (xvaddsp,0x00 ,0x08 ,PPC2_VSX ), GEN_XX3FORM(xvsubsp, 0x00, 0x09, PPC2_VSX),
@@ -10108,6 +10128,9 @@ GEN_XX3FORM(xvnmsubasp, 0x04, 0x1A, PPC2_VSX),GEN_XX3FORM (xvnmsubmsp,0x04 ,0x1B ,PPC2_VSX ),GEN_XX3FORM (xvmaxsp,0x00 ,0x18 ,PPC2_VSX ),GEN_XX3FORM (xvminsp,0x00 ,0x19 ,PPC2_VSX ), +GEN_XX3_RC_FORM (xvcmpeqsp,0x0C ,0x08 ,PPC2_VSX ), +GEN_XX3_RC_FORM (xvcmpgtsp,0x0C ,0x09 ,PPC2_VSX ), +GEN_XX3_RC_FORM (xvcmpgesp,0x0C ,0x0A ,PPC2_VSX ), #undef VSX_LOGICAL #define VSX_LOGICAL(name, opc2, opc3, fl2) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 041/130] target-ppc: VSX Stage 4: Add xsdivsp
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Scalar Divide Single Precision (xsdivsp) instruction.
The existing VSX_DIV macro is modified to support rounding of the intermediate double precision result to single precision.
--- target-ppc/fpu_helper.c | 13 +++++++++---- target-ppc/helper.h | 1 + target-ppc/translate.c | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-)
target-ppc/fpu_helper.c +9 -4
@@ -1874,7 +1874,7 @@ VSX_MUL(xvmulsp, 4, float32, f32, 0, 0)* fld - vsr_t field (f32 or f64) * sfprf - set FPRF */ -#define VSX_DIV (op, nels, tp, fld, sfprf) \ +#define VSX_DIV (op, nels, tp, fld, sfprf, r2sp) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt, xa, xb; \
@@ -1903,6 +1903,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ } \ } \ \ +if (r2sp) { \ + xt.fld[i] =helper_frsp (env, xt.fld[i]); \ + } \ + \if (sfprf) { \helper_compute_fprf (env, xt.fld[i], sfprf); \ } \
@@ -1912,9 +1916,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \helper_float_check_status (env); \ } -VSX_DIV(xsdivdp, 1, float64, f64, 1) -VSX_DIV(xvdivdp, 2, float64, f64, 0) -VSX_DIV (xvdivsp,4 , float32, f32,0 ) +VSX_DIV(xsdivdp, 1, float64, f64, 1, 0) +VSX_DIV(xsdivsp, 1, float64, f64, 1, 1) +VSX_DIV(xvdivdp, 2, float64, f64, 0, 0) +VSX_DIV (xvdivsp,4 , float32, f32,0 ,0 )/* VSX_RE - VSX floating point reciprocal estimate * op - instruction mnemonic
target-ppc/helper.h +1 -0
@@ -289,6 +289,7 @@ DEF_HELPER_2(xsrdpiz, void, env, i32) DEF_HELPER_2(xsaddsp, void, env, i32) DEF_HELPER_2(xssubsp, void, env, i32) DEF_HELPER_2(xsmulsp, void, env, i32) +DEF_HELPER_2(xsdivsp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
target-ppc/translate.c +2 -0
@@ -7361,6 +7361,7 @@ GEN_VSX_HELPER_2(xsrdpiz, 0x12, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsaddsp, 0x00, 0x00, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xssubsp, 0x00, 0x01, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsmulsp, 0x00, 0x02, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsdivsp, 0x00, 0x03, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -10171,6 +10172,7 @@ GEN_XX2FORM(xsrdpiz, 0x12, 0x05, PPC2_VSX),GEN_XX3FORM (xsaddsp,0x00 ,0x00 ,PPC2_VSX207 ),GEN_XX3FORM (xssubsp,0x00 ,0x01 ,PPC2_VSX207 ),GEN_XX3FORM (xsmulsp,0x00 ,0x02 ,PPC2_VSX207 ), +GEN_XX3FORM (xsdivsp,0x00 ,0x03 ,PPC2_VSX207 ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 043/130] target-ppc: VSX Stage 4: Add xssqrtsp
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Scalar Square Root Single Precision (xssqrtsp) instruction.
The existing VSX_SQRT() macro is modified to support rounding of the intermediate double-precision result to single-precision.
--- target-ppc/fpu_helper.c | 13 +++++++++---- target-ppc/helper.h | 1 + target-ppc/translate.c | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-)
target-ppc/fpu_helper.c +9 -4
@@ -1969,7 +1969,7 @@ VSX_RE(xvresp, 4, float32, f32, 0, 0)* fld - vsr_t field (f32 or f64) * sfprf - set FPRF */ -#define VSX_SQRT (op, nels, tp, fld, sfprf) \ +#define VSX_SQRT (op, nels, tp, fld, sfprf, r2sp) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt, xb; \
@@ -1993,6 +1993,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ } \ } \ \ +if (r2sp) { \ + xt.fld[i] =helper_frsp (env, xt.fld[i]); \ + } \ + \if (sfprf) { \helper_compute_fprf (env, xt.fld[i], sfprf); \ } \
@@ -2002,9 +2006,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \helper_float_check_status (env); \ } -VSX_SQRT(xssqrtdp, 1, float64, f64, 1) -VSX_SQRT(xvsqrtdp, 2, float64, f64, 0) -VSX_SQRT (xvsqrtsp,4 , float32, f32,0 ) +VSX_SQRT(xssqrtdp, 1, float64, f64, 1, 0) +VSX_SQRT(xssqrtsp, 1, float64, f64, 1, 1) +VSX_SQRT(xvsqrtdp, 2, float64, f64, 0, 0) +VSX_SQRT (xvsqrtsp,4 , float32, f32,0 ,0 )/* VSX_RSQRTE - VSX floating point reciprocal square root estimate * op - instruction mnemonic
target-ppc/helper.h +1 -0
@@ -291,6 +291,7 @@ DEF_HELPER_2(xssubsp, void, env, i32) DEF_HELPER_2(xsmulsp, void, env, i32) DEF_HELPER_2(xsdivsp, void, env, i32) DEF_HELPER_2(xsresp, void, env, i32) +DEF_HELPER_2(xssqrtsp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
target-ppc/translate.c +2 -0
@@ -7363,6 +7363,7 @@ GEN_VSX_HELPER_2(xssubsp, 0x00, 0x01, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsmulsp, 0x00, 0x02, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsdivsp, 0x00, 0x03, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsresp, 0x14, 0x01, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xssqrtsp, 0x16, 0x00, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -10175,6 +10176,7 @@ GEN_XX3FORM(xssubsp, 0x00, 0x01, PPC2_VSX207),GEN_XX3FORM (xsmulsp,0x00 ,0x02 ,PPC2_VSX207 ),GEN_XX3FORM (xsdivsp,0x00 ,0x03 ,PPC2_VSX207 ),GEN_XX2FORM (xsresp,0x14 ,0x01 ,PPC2_VSX207 ), +GEN_XX2FORM (xssqrtsp,0x16 ,0x00 ,PPC2_VSX207 ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 045/130] target-ppc: VSX Stage 4: Add Scalar SP Fused Multiply-Adds
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Single Precision VSX Scalar Fused Multiply-Add
instructions: xsmaddasp, xsmaddmsp, xssubasp, xssubmsp, xsnmaddasp, xsnmaddmsp, xsnmsubasp, xsnmsubmsp.
The existing VSX_MADD() macro is modified to support rounding of the intermediate double precision result to single precision.
--- target-ppc/fpu_helper.c | 82 ++++++++++++++++++++++++++++++++----------------- target-ppc/helper.h | 8 +++++ target-ppc/translate.c | 16 ++++++++++ 3 files changed, 77 insertions(+), 29 deletions(-)
target-ppc/fpu_helper.c +53 -29
@@ -2192,7 +2192,7 @@ VSX_TSQRT(xvtsqrtsp, 4, float32, f32, -126, 23)* afrm - A form (1=A, 0=M) * sfprf - set FPRF */ -#define VSX_MADD (op, nels, tp, fld, maddflgs, afrm, sfprf) \ +#define VSX_MADD (op, nels, tp, fld, maddflgs, afrm, sfprf, r2sp) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt_in, xa, xb, xt_out; \
@@ -2218,8 +2218,18 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \for (i =0 ; i < nels; i++) { \float_status tstat = env->fp_status; \set_float_exception_flags (0 , &tstat); \ - xt_out.fld[i] = tp##_muladd(xa.fld[i], b->fld[i], c->fld[i], \ - maddflgs, &tstat); \ +if (r2sp && (tstat.float_rounding_mode == float_round_nearest_even)) {\ +/* Avoid double rounding errors by rounding the intermediate */ \ +/* result to odd. */ \ +set_float_rounding_mode (float_round_to_zero, &tstat); \ + xt_out.fld[i] = tp##_muladd(xa.fld[i], b->fld[i], c->fld[i], \ + maddflgs, &tstat); \ + xt_out.fld[i] |= (get_float_exception_flags (&tstat) & \ + float_flag_inexact) !=0 ; \ + }else { \ + xt_out.fld[i] = tp##_muladd(xa.fld[i], b->fld[i], c->fld[i], \ + maddflgs, &tstat); \ + } \ env->fp_status.float_exception_flags |= tstat.float_exception_flags; \ \if (unlikely (tstat.float_exception_flags & float_flag_invalid)) { \
@@ -2242,6 +2252,11 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXISI , sfprf); \ } \ } \ + \ +if (r2sp) { \ + xt_out.fld[i] =helper_frsp (env, xt_out.fld[i]); \ + } \ + \if (sfprf) { \helper_compute_fprf (env, xt_out.fld[i], sfprf); \ } \
@@ -2255,32 +2270,41 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \#define NMADD_FLGS float_muladd_negate_result#define NMSUB_FLGS (float_muladd_negate_c | float_muladd_negate_result) -VSX_MADD(xsmaddadp, 1, float64, f64, MADD_FLGS, 1, 1) -VSX_MADD(xsmaddmdp, 1, float64, f64, MADD_FLGS, 0, 1) -VSX_MADD(xsmsubadp, 1, float64, f64, MSUB_FLGS, 1, 1) -VSX_MADD(xsmsubmdp, 1, float64, f64, MSUB_FLGS, 0, 1) -VSX_MADD(xsnmaddadp, 1, float64, f64, NMADD_FLGS, 1, 1) -VSX_MADD(xsnmaddmdp, 1, float64, f64, NMADD_FLGS, 0, 1) -VSX_MADD(xsnmsubadp, 1, float64, f64, NMSUB_FLGS, 1, 1) -VSX_MADD(xsnmsubmdp, 1, float64, f64, NMSUB_FLGS, 0, 1) - -VSX_MADD(xvmaddadp, 2, float64, f64, MADD_FLGS, 1, 0) -VSX_MADD(xvmaddmdp, 2, float64, f64, MADD_FLGS, 0, 0) -VSX_MADD(xvmsubadp, 2, float64, f64, MSUB_FLGS, 1, 0) -VSX_MADD(xvmsubmdp, 2, float64, f64, MSUB_FLGS, 0, 0) -VSX_MADD(xvnmaddadp, 2, float64, f64, NMADD_FLGS, 1, 0) -VSX_MADD(xvnmaddmdp, 2, float64, f64, NMADD_FLGS, 0, 0) -VSX_MADD(xvnmsubadp, 2, float64, f64, NMSUB_FLGS, 1, 0) -VSX_MADD(xvnmsubmdp, 2, float64, f64, NMSUB_FLGS, 0, 0) - -VSX_MADD(xvmaddasp, 4, float32, f32, MADD_FLGS, 1, 0) -VSX_MADD(xvmaddmsp, 4, float32, f32, MADD_FLGS, 0, 0) -VSX_MADD(xvmsubasp, 4, float32, f32, MSUB_FLGS, 1, 0) -VSX_MADD(xvmsubmsp, 4, float32, f32, MSUB_FLGS, 0, 0) -VSX_MADD(xvnmaddasp, 4, float32, f32, NMADD_FLGS, 1, 0) -VSX_MADD(xvnmaddmsp, 4, float32, f32, NMADD_FLGS, 0, 0) -VSX_MADD(xvnmsubasp, 4, float32, f32, NMSUB_FLGS, 1, 0) -VSX_MADD(xvnmsubmsp, 4, float32, f32, NMSUB_FLGS, 0, 0) +VSX_MADD(xsmaddadp, 1, float64, f64, MADD_FLGS, 1, 1, 0) +VSX_MADD(xsmaddmdp, 1, float64, f64, MADD_FLGS, 0, 1, 0) +VSX_MADD(xsmsubadp, 1, float64, f64, MSUB_FLGS, 1, 1, 0) +VSX_MADD(xsmsubmdp, 1, float64, f64, MSUB_FLGS, 0, 1, 0) +VSX_MADD(xsnmaddadp, 1, float64, f64, NMADD_FLGS, 1, 1, 0) +VSX_MADD(xsnmaddmdp, 1, float64, f64, NMADD_FLGS, 0, 1, 0) +VSX_MADD(xsnmsubadp, 1, float64, f64, NMSUB_FLGS, 1, 1, 0) +VSX_MADD(xsnmsubmdp, 1, float64, f64, NMSUB_FLGS, 0, 1, 0) + +VSX_MADD(xsmaddasp, 1, float64, f64, MADD_FLGS, 1, 1, 1) +VSX_MADD(xsmaddmsp, 1, float64, f64, MADD_FLGS, 0, 1, 1) +VSX_MADD(xsmsubasp, 1, float64, f64, MSUB_FLGS, 1, 1, 1) +VSX_MADD(xsmsubmsp, 1, float64, f64, MSUB_FLGS, 0, 1, 1) +VSX_MADD(xsnmaddasp, 1, float64, f64, NMADD_FLGS, 1, 1, 1) +VSX_MADD(xsnmaddmsp, 1, float64, f64, NMADD_FLGS, 0, 1, 1) +VSX_MADD(xsnmsubasp, 1, float64, f64, NMSUB_FLGS, 1, 1, 1) +VSX_MADD(xsnmsubmsp, 1, float64, f64, NMSUB_FLGS, 0, 1, 1) + +VSX_MADD(xvmaddadp, 2, float64, f64, MADD_FLGS, 1, 0, 0) +VSX_MADD(xvmaddmdp, 2, float64, f64, MADD_FLGS, 0, 0, 0) +VSX_MADD(xvmsubadp, 2, float64, f64, MSUB_FLGS, 1, 0, 0) +VSX_MADD(xvmsubmdp, 2, float64, f64, MSUB_FLGS, 0, 0, 0) +VSX_MADD(xvnmaddadp, 2, float64, f64, NMADD_FLGS, 1, 0, 0) +VSX_MADD(xvnmaddmdp, 2, float64, f64, NMADD_FLGS, 0, 0, 0) +VSX_MADD(xvnmsubadp, 2, float64, f64, NMSUB_FLGS, 1, 0, 0) +VSX_MADD(xvnmsubmdp, 2, float64, f64, NMSUB_FLGS, 0, 0, 0) + +VSX_MADD(xvmaddasp, 4, float32, f32, MADD_FLGS, 1, 0, 0) +VSX_MADD(xvmaddmsp, 4, float32, f32, MADD_FLGS, 0, 0, 0) +VSX_MADD(xvmsubasp, 4, float32, f32, MSUB_FLGS, 1, 0, 0) +VSX_MADD(xvmsubmsp, 4, float32, f32, MSUB_FLGS, 0, 0, 0) +VSX_MADD(xvnmaddasp, 4, float32, f32, NMADD_FLGS, 1, 0, 0) +VSX_MADD(xvnmaddmsp, 4, float32, f32, NMADD_FLGS, 0, 0, 0) +VSX_MADD(xvnmsubasp, 4, float32, f32, NMSUB_FLGS, 1, 0, 0) +VSX_MADD(xvnmsubmsp, 4, float32, f32, NMSUB_FLGS, 0, 0, 0)#define VSX_SCALAR_CMP (op, ordered) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \
target-ppc/helper.h +8 -0
@@ -293,6 +293,14 @@ DEF_HELPER_2(xsdivsp, void, env, i32) DEF_HELPER_2(xsresp, void, env, i32) DEF_HELPER_2(xssqrtsp, void, env, i32) DEF_HELPER_2(xsrsqrtesp, void, env, i32) +DEF_HELPER_2(xsmaddasp, void, env, i32) +DEF_HELPER_2(xsmaddmsp, void, env, i32) +DEF_HELPER_2(xsmsubasp, void, env, i32) +DEF_HELPER_2(xsmsubmsp, void, env, i32) +DEF_HELPER_2(xsnmaddasp, void, env, i32) +DEF_HELPER_2(xsnmaddmsp, void, env, i32) +DEF_HELPER_2(xsnmsubasp, void, env, i32) +DEF_HELPER_2(xsnmsubmsp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
target-ppc/translate.c +16 -0
@@ -7365,6 +7365,14 @@ GEN_VSX_HELPER_2(xsdivsp, 0x00, 0x03, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsresp, 0x14, 0x01, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xssqrtsp, 0x16, 0x00, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsrsqrtesp, 0x14, 0x00, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsmaddasp, 0x04, 0x00, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsmaddmsp, 0x04, 0x01, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsmsubasp, 0x04, 0x02, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsmsubmsp, 0x04, 0x03, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsnmaddasp, 0x04, 0x10, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsnmaddmsp, 0x04, 0x11, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsnmsubasp, 0x04, 0x12, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsnmsubmsp, 0x04, 0x13, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -10179,6 +10187,14 @@ GEN_XX3FORM(xsdivsp, 0x00, 0x03, PPC2_VSX207),GEN_XX2FORM (xsresp,0x14 ,0x01 ,PPC2_VSX207 ),GEN_XX2FORM (xssqrtsp,0x16 ,0x00 ,PPC2_VSX207 ),GEN_XX2FORM (xsrsqrtesp,0x14 ,0x00 ,PPC2_VSX207 ), +GEN_XX3FORM (xsmaddasp,0x04 ,0x00 ,PPC2_VSX207 ), +GEN_XX3FORM (xsmaddmsp,0x04 ,0x01 ,PPC2_VSX207 ), +GEN_XX3FORM (xsmsubasp,0x04 ,0x02 ,PPC2_VSX207 ), +GEN_XX3FORM (xsmsubmsp,0x04 ,0x03 ,PPC2_VSX207 ), +GEN_XX3FORM (xsnmaddasp,0x04 ,0x10 ,PPC2_VSX207 ), +GEN_XX3FORM (xsnmaddmsp,0x04 ,0x11 ,PPC2_VSX207 ), +GEN_XX3FORM (xsnmsubasp,0x04 ,0x12 ,PPC2_VSX207 ), +GEN_XX3FORM (xsnmsubmsp,0x04 ,0x13 ,PPC2_VSX207 ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 049/130] target-ppc: Floating Merge Word Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Floating Merge Even Word (fmrgew) and Floating Merge Odd Word (fmrgow) instructions.
--- target-ppc/translate.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
target-ppc/translate.c +28 -0
@@ -2294,6 +2294,32 @@ static void gen_fcpsgn(DisasContext *ctx)gen_compute_fprf (cpu_fpr[rD (ctx->opcode)],0 ,Rc (ctx->opcode) !=0 ); } +static void gen_fmrgew (DisasContext *ctx) +{ +TCGv_i64 b0; +if (unlikely (!ctx->fpu_enabled)) { +gen_exception (ctx,POWERPC_EXCP_FPU ); +return ; + } + b0 =tcg_temp_new_i64 (); +tcg_gen_shri_i64 (b0, cpu_fpr[rB (ctx->opcode)],32 ); +tcg_gen_deposit_i64 (cpu_fpr[rD (ctx->opcode)], cpu_fpr[rA (ctx->opcode)], + b0,0 ,32 ); +tcg_temp_free_i64 (b0); +} + +static void gen_fmrgow (DisasContext *ctx) +{ +if (unlikely (!ctx->fpu_enabled)) { +gen_exception (ctx,POWERPC_EXCP_FPU ); +return ; + } +tcg_gen_deposit_i64 (cpu_fpr[rD (ctx->opcode)], + cpu_fpr[rB (ctx->opcode)], + cpu_fpr[rA (ctx->opcode)], +32 ,32 ); +} +/*** Floating-Point status & ctrl register ***/ /* mcrfs */
@@ -9414,6 +9440,8 @@ GEN_HANDLER(fmr, 0x3F, 0x08, 0x02, 0x001F0000, PPC_FLOAT),GEN_HANDLER (fnabs,0x3F ,0x08 ,0x04 ,0x001F0000 ,PPC_FLOAT ),GEN_HANDLER (fneg,0x3F ,0x08 ,0x01 ,0x001F0000 ,PPC_FLOAT ),GEN_HANDLER_E (fcpsgn,0x3F ,0x08 ,0x00 ,0x00000000 ,PPC_NONE ,PPC2_ISA205 ), +GEN_HANDLER_E (fmrgew,0x3F ,0x06 ,0x1E ,0x00000001 ,PPC_NONE ,PPC2_VSX207 ), +GEN_HANDLER_E (fmrgow,0x3F ,0x06 ,0x1A ,0x00000001 ,PPC_NONE ,PPC2_VSX207 ),GEN_HANDLER (mcrfs,0x3F ,0x00 ,0x02 ,0x0063F801 ,PPC_FLOAT ),GEN_HANDLER (mffs,0x3F ,0x07 ,0x12 ,0x001FF800 ,PPC_FLOAT ), GEN_HANDLER(mtfsb0, 0x3F, 0x06, 0x02, 0x001FF800, PPC_FLOAT),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 046/130] target-ppc: VSX Stage 4: Add xscvsxdsp and xscvuxdsp
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Scalar Convert Unsigned Integer Doubleword to Floating Point Format and Round to Single Precision (xscvuxdsp) and VSX Scalar Convert Signed Integer Douglbeword to Floating Point Format and Round to Single Precision (xscvsxdsp) instructions.
The existing integer to floating point conversion macro (VSX_CVT_INT_TO_FP) is modified to support the rounding of the intermediate floating point result to single precision.
--- target-ppc/fpu_helper.c | 27 ++++++++++++++++----------- target-ppc/helper.h | 2 ++ target-ppc/translate.c | 4 ++++ 3 files changed, 22 insertions(+), 11 deletions(-)
target-ppc/fpu_helper.c +16 -11
@@ -2558,7 +2558,7 @@ VSX_CVT_FP_TO_INT(xvcvspuxws, 4, float32, uint32, f32[j], u32[i], i, 0)* jdef - definition of the j index (i or 2*i) * sfprf - set FPRF */ -#define VSX_CVT_INT_TO_FP (op, nels, stp, ttp, sfld, tfld, jdef, sfprf) \ +#define VSX_CVT_INT_TO_FP (op, nels, stp, ttp, sfld, tfld, jdef, sfprf, r2sp) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt, xb; \
@@ -2570,6 +2570,9 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \for (i =0 ; i < nels; i++) { \int j = jdef; \ xt.tfld = stp##_to_##ttp(xb.sfld, &env->fp_status); \ + if (r2sp) { \ + xt.tfld = helper_frsp(env, xt.tfld); \ + } \ if (sfprf) { \ helper_compute_fprf(env, xt.tfld, sfprf); \ } \
@@ -2579,20 +2582,22 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \helper_float_check_status (env); \ } -VSX_CVT_INT_TO_FP(xscvsxddp, 1, int64, float64, u64[j], f64[i], i, 1) -VSX_CVT_INT_TO_FP(xscvuxddp, 1, uint64, float64, u64[j], f64[i], i, 1) -VSX_CVT_INT_TO_FP(xvcvsxddp, 2, int64, float64, u64[j], f64[i], i, 0) -VSX_CVT_INT_TO_FP(xvcvuxddp, 2, uint64, float64, u64[j], f64[i], i, 0) +VSX_CVT_INT_TO_FP(xscvsxddp, 1, int64, float64, u64[j], f64[i], i, 1, 0) +VSX_CVT_INT_TO_FP(xscvuxddp, 1, uint64, float64, u64[j], f64[i], i, 1, 0) +VSX_CVT_INT_TO_FP(xscvsxdsp, 1, int64, float64, u64[j], f64[i], i, 1, 1) +VSX_CVT_INT_TO_FP(xscvuxdsp, 1, uint64, float64, u64[j], f64[i], i, 1, 1) +VSX_CVT_INT_TO_FP(xvcvsxddp, 2, int64, float64, u64[j], f64[i], i, 0, 0) +VSX_CVT_INT_TO_FP(xvcvuxddp, 2, uint64, float64, u64[j], f64[i], i, 0, 0)VSX_CVT_INT_TO_FP (xvcvsxwdp,2 , int32, float64, u32[j], f64[i], \ - 2*i + JOFFSET, 0) + 2*i + JOFFSET, 0, 0)VSX_CVT_INT_TO_FP (xvcvuxwdp,2 , uint64, float64, u32[j], f64[i], \ - 2*i + JOFFSET, 0) + 2*i + JOFFSET, 0, 0)VSX_CVT_INT_TO_FP (xvcvsxdsp,2 , int64, float32, u64[i], f32[j], \ - 2*i + JOFFSET, 0) + 2*i + JOFFSET, 0, 0)VSX_CVT_INT_TO_FP (xvcvuxdsp,2 , uint64, float32, u64[i], f32[j], \ - 2*i + JOFFSET, 0) -VSX_CVT_INT_TO_FP(xvcvsxwsp, 4, int32, float32, u32[j], f32[i], i, 0) -VSX_CVT_INT_TO_FP (xvcvuxwsp,4 , uint32, float32, u32[j], f32[i], i,0 ) + 2*i + JOFFSET, 0, 0) +VSX_CVT_INT_TO_FP(xvcvsxwsp, 4, int32, float32, u32[j], f32[i], i, 0, 0) +VSX_CVT_INT_TO_FP (xvcvuxwsp,4 , uint32, float32, u32[j], f32[i], i,0 ,0 )/* For "use current rounding mode", define a value that will not be one of * the existing rounding model enums.
target-ppc/helper.h +2 -0
@@ -279,6 +279,8 @@ DEF_HELPER_2(xscvdpsxws, void, env, i32) DEF_HELPER_2(xscvdpuxds, void, env, i32) DEF_HELPER_2(xscvdpuxws, void, env, i32) DEF_HELPER_2(xscvsxddp, void, env, i32) +DEF_HELPER_2(xscvuxdsp, void, env, i32) +DEF_HELPER_2(xscvsxdsp, void, env, i32) DEF_HELPER_2(xscvuxddp, void, env, i32) DEF_HELPER_2(xsrdpi, void, env, i32)DEF_HELPER_2 (xsrdpic, void, env, i32)
target-ppc/translate.c +4 -0
@@ -7373,6 +7373,8 @@ GEN_VSX_HELPER_2(xsnmaddasp, 0x04, 0x10, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsnmaddmsp, 0x04, 0x11, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsnmsubasp, 0x04, 0x12, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsnmsubmsp, 0x04, 0x13, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xscvsxdsp, 0x10, 0x13, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xscvuxdsp, 0x10, 0x12, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -10195,6 +10197,8 @@ GEN_XX3FORM(xsnmaddasp, 0x04, 0x10, PPC2_VSX207),GEN_XX3FORM (xsnmaddmsp,0x04 ,0x11 ,PPC2_VSX207 ),GEN_XX3FORM (xsnmsubasp,0x04 ,0x12 ,PPC2_VSX207 ),GEN_XX3FORM (xsnmsubmsp,0x04 ,0x13 ,PPC2_VSX207 ), +GEN_XX2FORM (xscvsxdsp,0x10 ,0x13 ,PPC2_VSX207 ), +GEN_XX2FORM (xscvuxdsp,0x10 ,0x12 ,PPC2_VSX207 ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 047/130] target-ppc: VSX Stage 4: Add xxleqv, xxlnand and xxlorc
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patchs adds the VSX Logical instructions that are new with ISA V2.07:
- VSX Logical Equivalence (xxleqv)
- VSX Logical NAND (xxlnand)
- VSX Logical ORC (xxlorc)
--- target-ppc/translate.c | 6 ++++++ 1 file changed, 6 insertions(+)
target-ppc/translate.c +6 -0
@@ -7468,6 +7468,9 @@ VSX_LOGICAL(xxlandc, tcg_gen_andc_i64) VSX_LOGICAL(xxlor, tcg_gen_or_i64) VSX_LOGICAL(xxlxor, tcg_gen_xor_i64) VSX_LOGICAL(xxlnor, tcg_gen_nor_i64) +VSX_LOGICAL(xxleqv, tcg_gen_eqv_i64) +VSX_LOGICAL(xxlnand, tcg_gen_nand_i64) +VSX_LOGICAL(xxlorc, tcg_gen_orc_i64)#define VSX_XXMRG (name, high) \ static void glue(gen_, name)(DisasContext * ctx) \
@@ -10283,6 +10286,9 @@ VSX_LOGICAL(xxlandc, 0x8, 0x11, PPC2_VSX),VSX_LOGICAL (xxlor,0x8 ,0x12 ,PPC2_VSX ),VSX_LOGICAL (xxlxor,0x8 ,0x13 ,PPC2_VSX ),VSX_LOGICAL (xxlnor,0x8 ,0x14 ,PPC2_VSX ), +VSX_LOGICAL (xxleqv,0x8 ,0x17 ,PPC2_VSX207 ), +VSX_LOGICAL (xxlnand,0x8 ,0x16 ,PPC2_VSX207 ), +VSX_LOGICAL (xxlorc,0x8 ,0x15 ,PPC2_VSX207 ),GEN_XX3FORM (xxmrghw,0x08 ,0x02 ,PPC2_VSX ),GEN_XX3FORM (xxmrglw,0x08 ,0x06 ,PPC2_VSX ), GEN_XX2FORM(xxspltw, 0x08, 0x0A, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 048/130] target-ppc: Move To/From VSR Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Move To VSR instructions (mfvsrd, mfvsrwz) and Move From VSR instructions (mtvsrd, mtvsrwa, mtvsrwz). These instructions are unusual in that they are considered a floating point instruction if the indexed VSR is in the first half of the array (0-31) but they are considered vector instructions if the indexed VSR is in the second half of the array (32-63).
--- target-ppc/translate.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
target-ppc/translate.c +59 -0
@@ -7175,6 +7175,57 @@ static void gen_stxvw4x(DisasContext *ctx)tcg_temp_free_i64 (tmp); } +#define MV_VSRW (name, tcgop1, tcgop2, target, source) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + if (xS(ctx->opcode) < 32) { \ + if (unlikely(!ctx->fpu_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_FPU); \ + return; \ + } \ + } else { \ + if (unlikely(!ctx->altivec_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VPU); \ + return; \ + } \ + } \ + TCGv_i64 tmp = tcg_temp_new_i64(); \ + tcg_gen_##tcgop1(tmp, source); \ + tcg_gen_##tcgop2(target, tmp); \ + tcg_temp_free_i64(tmp); \ +} + + +MV_VSRW (mfvsrwz, ext32u_i64, trunc_i64_tl, cpu_gpr[rA (ctx->opcode)], \ + cpu_vsrh(xS(ctx->opcode))) +MV_VSRW (mtvsrwa, extu_tl_i64, ext32s_i64,cpu_vsrh (xT (ctx->opcode)), \ + cpu_gpr[rA(ctx->opcode)]) +MV_VSRW (mtvsrwz, extu_tl_i64, ext32u_i64,cpu_vsrh (xT (ctx->opcode)), \ + cpu_gpr[rA(ctx->opcode)]) + +#if defined(TARGET_PPC64 ) +#define MV_VSRD (name, target, source) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + if (xS(ctx->opcode) < 32) { \ + if (unlikely(!ctx->fpu_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_FPU); \ + return; \ + } \ + } else { \ + if (unlikely(!ctx->altivec_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VPU); \ + return; \ + } \ + } \ + tcg_gen_mov_i64(target, source); \ +} + +MV_VSRD(mfvsrd, cpu_gpr[rA(ctx->opcode)], cpu_vsrh(xS(ctx->opcode))) +MV_VSRD(mtvsrd, cpu_vsrh(xT(ctx->opcode)), cpu_gpr[rA(ctx->opcode)]) + +#endif +static void gen_xxpermdi (DisasContext *ctx) {if (unlikely (!ctx->vsx_enabled)) {
@@ -10094,6 +10145,14 @@ GEN_HANDLER_E(stxsspx, 0x1F, 0xC, 0x14, 0, PPC_NONE, PPC2_VSX207), GEN_HANDLER_E(stxvd2x, 0x1F, 0xC, 0x1E, 0, PPC_NONE, PPC2_VSX), GEN_HANDLER_E(stxvw4x, 0x1F, 0xC, 0x1C, 0, PPC_NONE, PPC2_VSX), +GEN_HANDLER_E(mfvsrwz, 0x1F, 0x13, 0x03, 0x0000F800, PPC_NONE, PPC2_VSX207), +GEN_HANDLER_E(mtvsrwa, 0x1F, 0x13, 0x06, 0x0000F800, PPC_NONE, PPC2_VSX207), +GEN_HANDLER_E(mtvsrwz, 0x1F, 0x13, 0x07, 0x0000F800, PPC_NONE, PPC2_VSX207), +#if defined(TARGET_PPC64 ) +GEN_HANDLER_E(mfvsrd, 0x1F, 0x13, 0x01, 0x0000F800, PPC_NONE, PPC2_VSX207), +GEN_HANDLER_E(mtvsrd, 0x1F, 0x13, 0x05, 0x0000F800, PPC_NONE, PPC2_VSX207), +#endif +#undef GEN_XX2FORM#define GEN_XX2FORM (name, opc2, opc3, fl2) \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0, PPC_NONE, fl2), \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 053/130] target-ppc: Add Flag for ISA2.06 Divide Extended Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a flag for the Divide Extended instructions that were introduced in Power ISA V2.06B. The flag is added to the Power7 and Power8 models.
--- target-ppc/cpu.h | 5 ++++- target-ppc/translate_init.c | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-)
target-ppc/cpu.h +4 -1
@@ -1879,9 +1879,12 @@ enum {PPC2_VSX207 =0x0000000000000040ULL ,/* ISA 2.06B bpermd */ PPC2_PERM_ISA206 =0x0000000000000080ULL , +/* ISA 2.06B divide extended variants */ +PPC2_DIVE_ISA206 =0x0000000000000100ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \ - PPC2_ISA205 | PPC2_VSX207 | PPC2_PERM_ISA206) +PPC2_ISA205 |PPC2_VSX207 |PPC2_PERM_ISA206 | \ + PPC2_DIVE_ISA206) };/*****************************************************************************/
target-ppc/translate_init.c +3 -3
@@ -7069,7 +7069,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 | -PPC2_PERM_ISA206 ; +PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 ; pcc->msr_mask =0x800000000284FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7108,7 +7108,7 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 | -PPC2_PERM_ISA206 ; +PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 ; pcc->msr_mask =0x800000000204FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7147,7 +7147,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX | -PPC2_PERM_ISA206 ; +PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 056/130] target-ppc: Add ISA 2.06 divweu[o] Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch addes the Unsigned Divide Word Extended instructions which were introduced in Power ISA 2.06B.
--- target-ppc/helper.h | 1 + target-ppc/int_helper.c | 31 +++++++++++++++++++++++++++++++ target-ppc/translate.c | 5 +++++ 3 files changed, 37 insertions(+)
target-ppc/helper.h +1 -0
@@ -34,6 +34,7 @@ DEF_HELPER_3(mulldo, i64, env, i64, i64) DEF_HELPER_4(divdeu, i64, env, i64, i64, i32) DEF_HELPER_4(divde, i64, env, i64, i64, i32)#endif +DEF_HELPER_4(divweu, tl, env, tl, tl, i32) DEF_HELPER_FLAGS_1(cntlzw, TCG_CALL_NO_RWG_SE, tl, tl)DEF_HELPER_FLAGS_1 (popcntb,TCG_CALL_NO_RWG_SE , tl, tl)
target-ppc/int_helper.c +31 -0
@@ -41,6 +41,37 @@ uint64_t helper_mulldo(CPUPPCState *env, uint64_t arg1, uint64_t arg2) }#endif +target_ulong helper_divweu (CPUPPCState *env,target_ulong ra,target_ulong rb, +uint32_t oe) +{ +uint64_t rt =0 ; +int overflow =0 ; + +uint64_t dividend = (uint64_t )ra <<32 ; +uint64_t divisor = (uint32_t )rb; + +if (unlikely (divisor ==0 )) { + overflow =1 ; + }else { + rt = dividend / divisor; + overflow = rt >UINT32_MAX ; + } + +if (unlikely (overflow)) { + rt =0 ;/* Undefined */ + } + +if (oe) { +if (unlikely (overflow)) { + env->so = env->ov =1 ; + }else { + env->ov =0 ; + } + } + +return (target_ulong )rt; +} +#if defined(TARGET_PPC64 )uint64_t helper_divdeu (CPUPPCState *env,uint64_t ra,uint64_t rb,uint32_t oe)
target-ppc/translate.c +5 -0
@@ -998,6 +998,9 @@ static void gen_##name(DisasContext *ctx) \ } \ } +GEN_DIVE (divweu, divweu,0 ); +GEN_DIVE (divweuo, divweu,1 ); +#if defined(TARGET_PPC64 )static inline void gen_op_arith_divd (DisasContext *ctx,TCGv ret,TCGv arg1,TCGv arg2,int sign,int compute_ov)
@@ -9716,6 +9719,8 @@ GEN_INT_ARITH_DIVW(divwu, 0x0E, 0, 0),GEN_INT_ARITH_DIVW (divwuo,0x1E ,0 ,1 ),GEN_INT_ARITH_DIVW (divw,0x0F ,1 ,0 ),GEN_INT_ARITH_DIVW (divwo,0x1F ,1 ,1 ), +GEN_HANDLER_E (divweu,0x1F ,0x0B ,0x0C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), +GEN_HANDLER_E (divweuo,0x1F ,0x0B ,0x1C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), #if defined(TARGET_PPC64) #undef GEN_INT_ARITH_DIVD
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 057/130] target-ppc: Add ISA 2.06 divwe[o] Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch addes the signed Divide Word Extended instructions which were introduced in Power ISA 2.06B.
--- target-ppc/helper.h | 1 + target-ppc/int_helper.c | 32 ++++++++++++++++++++++++++++++++ target-ppc/translate.c | 4 ++++ 3 files changed, 37 insertions(+)
target-ppc/helper.h +1 -0
@@ -35,6 +35,7 @@ DEF_HELPER_4(divdeu, i64, env, i64, i64, i32) DEF_HELPER_4(divde, i64, env, i64, i64, i32)#endif DEF_HELPER_4(divweu, tl, env, tl, tl, i32) +DEF_HELPER_4(divwe, tl, env, tl, tl, i32) DEF_HELPER_FLAGS_1(cntlzw, TCG_CALL_NO_RWG_SE, tl, tl)DEF_HELPER_FLAGS_1 (popcntb,TCG_CALL_NO_RWG_SE , tl, tl)
target-ppc/int_helper.c +32 -0
@@ -72,6 +72,38 @@ target_ulong helper_divweu(CPUPPCState *env, target_ulong ra, target_ulong rb,return (target_ulong )rt; } +target_ulong helper_divwe (CPUPPCState *env,target_ulong ra,target_ulong rb, +uint32_t oe) +{ +int64_t rt =0 ; +int overflow =0 ; + +int64_t dividend = (int64_t )ra <<32 ; +int64_t divisor = (int64_t )((int32_t )rb); + +if (unlikely ((divisor ==0 ) || + ((divisor ==-1ull ) && (dividend ==INT64_MIN )))) { + overflow =1 ; + }else { + rt = dividend / divisor; + overflow = rt != (int32_t )rt; + } + +if (unlikely (overflow)) { + rt =0 ;/* Undefined */ + } + +if (oe) { +if (unlikely (overflow)) { + env->so = env->ov =1 ; + }else { + env->ov =0 ; + } + } + +return (target_ulong )rt; +} +#if defined(TARGET_PPC64 )uint64_t helper_divdeu (CPUPPCState *env,uint64_t ra,uint64_t rb,uint32_t oe)
target-ppc/translate.c +4 -0
@@ -1000,6 +1000,8 @@ static void gen_##name(DisasContext *ctx) \GEN_DIVE (divweu, divweu,0 );GEN_DIVE (divweuo, divweu,1 ); +GEN_DIVE (divwe, divwe,0 ); +GEN_DIVE (divweo, divwe,1 );#if defined(TARGET_PPC64 ) static inline void gen_op_arith_divd(DisasContext *ctx, TCGv ret, TCGv arg1,
@@ -9719,6 +9721,8 @@ GEN_INT_ARITH_DIVW(divwu, 0x0E, 0, 0),GEN_INT_ARITH_DIVW (divwuo,0x1E ,0 ,1 ),GEN_INT_ARITH_DIVW (divw,0x0F ,1 ,0 ),GEN_INT_ARITH_DIVW (divwo,0x1F ,1 ,1 ), +GEN_HANDLER_E (divwe,0x1F ,0x0B ,0x0D ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), +GEN_HANDLER_E (divweo,0x1F ,0x0B ,0x1D ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ),GEN_HANDLER_E (divweu,0x1F ,0x0B ,0x0C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), GEN_HANDLER_E(divweuo, 0x1F, 0x0B, 0x1C, 0, PPC_NONE, PPC2_DIVE_ISA206),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 044/130] target-ppc: VSX Stage 4: add xsrsqrtesp
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Scalar Reciprocal Square Root Estimate Single Precision (xsrsqrtesp) instruction.
The existing VSX_RSQRTE() macro is modified to support rounding of the intermediate double-precision result to single precision.
--- target-ppc/fpu_helper.c | 13 +++++++++---- target-ppc/helper.h | 1 + target-ppc/translate.c | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-)
target-ppc/fpu_helper.c +9 -4
@@ -2018,7 +2018,7 @@ VSX_SQRT(xvsqrtsp, 4, float32, f32, 0, 0)* fld - vsr_t field (f32 or f64) * sfprf - set FPRF */ -#define VSX_RSQRTE (op, nels, tp, fld, sfprf) \ +#define VSX_RSQRTE (op, nels, tp, fld, sfprf, r2sp) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt, xb; \
@@ -2043,6 +2043,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ } \ } \ \ +if (r2sp) { \ + xt.fld[i] =helper_frsp (env, xt.fld[i]); \ + } \ + \if (sfprf) { \helper_compute_fprf (env, xt.fld[i], sfprf); \ } \
@@ -2052,9 +2056,10 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \helper_float_check_status (env); \ } -VSX_RSQRTE(xsrsqrtedp, 1, float64, f64, 1) -VSX_RSQRTE(xvrsqrtedp, 2, float64, f64, 0) -VSX_RSQRTE(xvrsqrtesp, 4, float32, f32, 0) +VSX_RSQRTE(xsrsqrtedp, 1, float64, f64, 1, 0) +VSX_RSQRTE(xsrsqrtesp, 1, float64, f64, 1, 1) +VSX_RSQRTE(xvrsqrtedp, 2, float64, f64, 0, 0) +VSX_RSQRTE(xvrsqrtesp, 4, float32, f32, 0, 0)static inline int ppc_float32_get_unbiased_exp (float32 f) {
target-ppc/helper.h +1 -0
@@ -292,6 +292,7 @@ DEF_HELPER_2(xsmulsp, void, env, i32) DEF_HELPER_2(xsdivsp, void, env, i32) DEF_HELPER_2(xsresp, void, env, i32) DEF_HELPER_2(xssqrtsp, void, env, i32) +DEF_HELPER_2(xsrsqrtesp, void, env, i32) DEF_HELPER_2(xvadddp, void, env, i32)DEF_HELPER_2 (xvsubdp, void, env, i32)
target-ppc/translate.c +2 -0
@@ -7364,6 +7364,7 @@ GEN_VSX_HELPER_2(xsmulsp, 0x00, 0x02, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsdivsp, 0x00, 0x03, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsresp, 0x14, 0x01, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xssqrtsp, 0x16, 0x00, 0, PPC2_VSX207) +GEN_VSX_HELPER_2(xsrsqrtesp, 0x14, 0x00, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvsubdp,0x00 ,0x0D ,0 ,PPC2_VSX )
@@ -10177,6 +10178,7 @@ GEN_XX3FORM(xsmulsp, 0x00, 0x02, PPC2_VSX207),GEN_XX3FORM (xsdivsp,0x00 ,0x03 ,PPC2_VSX207 ),GEN_XX2FORM (xsresp,0x14 ,0x01 ,PPC2_VSX207 ),GEN_XX2FORM (xssqrtsp,0x16 ,0x00 ,PPC2_VSX207 ), +GEN_XX2FORM (xsrsqrtesp,0x14 ,0x00 ,PPC2_VSX207 ),GEN_XX3FORM (xvadddp,0x00 ,0x0C ,PPC2_VSX ), GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 050/130] target-ppc: Scalar Round to Single Precision
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the VSX Scalar Round to Single Precision (xsrsp) instruction.
--- target-ppc/fpu_helper.c | 11 +++++++++++ target-ppc/helper.h | 1 + target-ppc/translate.c | 17 +++++++++++++++++ 3 files changed, 29 insertions(+)
target-ppc/fpu_helper.c +11 -0
@@ -2666,3 +2666,14 @@ VSX_ROUND(xvrspic, 4, float32, f32, FLOAT_ROUND_CURRENT, 0) VSX_ROUND(xvrspim, 4, float32, f32, float_round_down, 0) VSX_ROUND(xvrspip, 4, float32, f32, float_round_up, 0) VSX_ROUND(xvrspiz, 4, float32, f32, float_round_to_zero, 0) + +uint64_t helper_xsrsp (CPUPPCState *env,uint64_t xb) +{ +helper_reset_fpstatus (env); + +uint64_t xt =helper_frsp (env, xb); + +helper_compute_fprf (env, xt,1 ); +helper_float_check_status (env); +return xt; +}
target-ppc/helper.h +1 -0
@@ -293,6 +293,7 @@ DEF_HELPER_2(xssubsp, void, env, i32) DEF_HELPER_2(xsmulsp, void, env, i32) DEF_HELPER_2(xsdivsp, void, env, i32) DEF_HELPER_2(xsresp, void, env, i32) +DEF_HELPER_2(xsrsp, i64, env, i64) DEF_HELPER_2(xssqrtsp, void, env, i32) DEF_HELPER_2(xsrsqrtesp, void, env, i32)DEF_HELPER_2 (xsmaddasp, void, env, i32)
target-ppc/translate.c +17 -0
@@ -7400,6 +7400,21 @@ static void gen_##name(DisasContext * ctx) \tcg_temp_free_i32 (opc); \ } +#define GEN_VSX_HELPER_XT_XB_ENV (name, op1, op2, inval, type) \ +static void gen_##name(DisasContext * ctx) \ +{ \ + if (unlikely(!ctx->vsx_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VSXU); \ + return; \ + } \ +/* NIP cannot be restored if the exception comes */ \ +/* from a helper. */ \ +gen_update_nip (ctx, ctx->nip -4 ); \ + \ + gen_helper_##name(cpu_vsrh(xT(ctx->opcode)), cpu_env, \ + cpu_vsrh(xB(ctx->opcode))); \ +} + GEN_VSX_HELPER_2(xsadddp, 0x00, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xssubdp, 0x00, 0x05, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xsmuldp,0x00 ,0x06 ,0 ,PPC2_VSX )
@@ -7434,6 +7449,7 @@ GEN_VSX_HELPER_2(xsrdpic, 0x16, 0x06, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsrdpim, 0x12, 0x07, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsrdpip, 0x12, 0x06, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsrdpiz, 0x12, 0x05, 0, PPC2_VSX) +GEN_VSX_HELPER_XT_XB_ENV(xsrsp, 0x12, 0x11, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xsaddsp, 0x00, 0x00, 0, PPC2_VSX207)GEN_VSX_HELPER_2 (xssubsp,0x00 ,0x01 ,0 ,PPC2_VSX207 )
@@ -10277,6 +10293,7 @@ GEN_XX3FORM(xssubsp, 0x00, 0x01, PPC2_VSX207),GEN_XX3FORM (xsmulsp,0x00 ,0x02 ,PPC2_VSX207 ),GEN_XX3FORM (xsdivsp,0x00 ,0x03 ,PPC2_VSX207 ),GEN_XX2FORM (xsresp,0x14 ,0x01 ,PPC2_VSX207 ), +GEN_XX2FORM (xsrsp,0x12 ,0x11 ,PPC2_VSX207 ),GEN_XX2FORM (xssqrtsp,0x16 ,0x00 ,PPC2_VSX207 ),GEN_XX2FORM (xsrsqrtesp,0x14 ,0x00 ,PPC2_VSX207 ), GEN_XX3FORM(xsmaddasp, 0x04, 0x00, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 052/130] target-ppc: Add ISA2.06 bpermd Instruction
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Bit Permute Doubleword (bpermd) instruction, which was introduced in Power ISA 2.06 as part of the base 64-bit architecture.
--- target-ppc/cpu.h | 4 +++- target-ppc/helper.h | 1 + target-ppc/int_helper.c | 20 ++++++++++++++++++++ target-ppc/translate.c | 10 ++++++++++ target-ppc/translate_init.c | 11 +++++++---- 5 files changed, 41 insertions(+), 5 deletions(-)
target-ppc/cpu.h +3 -1
@@ -1877,9 +1877,11 @@ enum {PPC2_ISA205 =0x0000000000000020ULL ,/* VSX additions in ISA 2.07 */ PPC2_VSX207 =0x0000000000000040ULL , +/* ISA 2.06B bpermd */ +PPC2_PERM_ISA206 =0x0000000000000080ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \ - PPC2_ISA205 | PPC2_VSX207) + PPC2_ISA205 | PPC2_VSX207 | PPC2_PERM_ISA206) };/*****************************************************************************/
target-ppc/helper.h +1 -0
@@ -41,6 +41,7 @@ DEF_HELPER_3(sraw, tl, env, tl, tl)#if defined(TARGET_PPC64 ) DEF_HELPER_FLAGS_1(cntlzd, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(popcntd, TCG_CALL_NO_RWG_SE, tl, tl) +DEF_HELPER_FLAGS_2(bpermd, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_3(srad, tl, env, tl, tl)#endif
target-ppc/int_helper.c +20 -0
@@ -53,6 +53,26 @@ target_ulong helper_cntlzd(target_ulong t) }#endif +#if defined(TARGET_PPC64 ) + +uint64_t helper_bpermd (uint64_t rs,uint64_t rb) +{ +int i; +uint64_t ra =0 ; + +for (i =0 ; i <8 ; i++) { +int index = (rs >> (i*8 )) &0xFF ; +if (index <64 ) { +if (rb & (1ull << (63 -index))) { + ra |=1 << i; + } + } + } +return ra; +} + +#endif +target_ulong helper_cmpb (target_ulong rs,target_ulong rb) {target_ulong mask =0xff ;
target-ppc/translate.c +10 -0
@@ -1525,6 +1525,15 @@ static void gen_prtyd(DisasContext *ctx)#endif #if defined(TARGET_PPC64 ) +/* bpermd */ +static void gen_bpermd (DisasContext *ctx) +{ +gen_helper_bpermd (cpu_gpr[rA (ctx->opcode)], + cpu_gpr[rS (ctx->opcode)], cpu_gpr[rB (ctx->opcode)]); +} +#endif + +#if defined(TARGET_PPC64 )/* extsw & extsw. */ GEN_LOGICAL1 (extsw, tcg_gen_ext32s_tl,0x1E ,PPC_64B );
@@ -9433,6 +9442,7 @@ GEN_HANDLER_E(prtyw, 0x1F, 0x1A, 0x04, 0x0000F801, PPC_NONE, PPC2_ISA205),GEN_HANDLER (popcntd,0x1F ,0x1A ,0x0F ,0x0000F801 ,PPC_POPCNTWD ),GEN_HANDLER (cntlzd,0x1F ,0x1A ,0x01 ,0x00000000 ,PPC_64B ),GEN_HANDLER_E (prtyd,0x1F ,0x1A ,0x05 ,0x0000F801 ,PPC_NONE ,PPC2_ISA205 ), +GEN_HANDLER_E (bpermd,0x1F ,0x1C ,0x07 ,0x00000001 ,PPC_NONE ,PPC2_PERM_ISA206 ), #endifGEN_HANDLER (rlwimi,0x14 ,0xFF ,0xFF ,0x00000000 ,PPC_INTEGER ), GEN_HANDLER(rlwinm, 0x15, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
target-ppc/translate_init.c +7 -4
@@ -4722,7 +4722,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data)PPC_FLOAT_STFIWX |PPC_WAIT |PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD ; - pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL ; + pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 ; pcc->msr_mask =0x000000009402FB36ULL ; pcc->mmu_model =POWERPC_MMU_BOOKE206 ; pcc->excp_model =POWERPC_EXCP_BOOKE ;
@@ -7068,7 +7068,8 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)PPC_64B |PPC_ALTIVEC |PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; - pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 ; + pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 | +PPC2_PERM_ISA206 ; pcc->msr_mask =0x800000000284FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7106,7 +7107,8 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)PPC_64B |PPC_ALTIVEC |PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; - pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 ; + pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 | +PPC2_PERM_ISA206 ; pcc->msr_mask =0x800000000204FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7144,7 +7146,8 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC_64B |PPC_ALTIVEC |PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; - pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX ; + pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX | +PPC2_PERM_ISA206 ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 055/130] target-ppc: Add ISA2.06 divde[o] Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Divide Doubleword Extended instructions. The implementation builds on the unsigned helper provided in the previous patch.
--- include/qemu/host-utils.h | 14 ++++++++++++++ target-ppc/helper.h | 1 + target-ppc/int_helper.c | 23 +++++++++++++++++++++++ target-ppc/translate.c | 5 ++++- util/host-utils.c | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 1 deletion(-)
include/qemu/host-utils.h +14 -0
@@ -57,10 +57,24 @@ static inline int divu128(uint64_t *plow, uint64_t *phigh, uint64_t divisor) return result > UINT64_MAX; } } + +static inline int divs128 (int64_t *plow,int64_t *phigh,int64_t divisor) +{ +if (divisor ==0 ) { +return 1 ; + }else { +__int128_t dividend = ((__int128_t)*phigh <<64 ) | *plow; +__int128_t result = dividend / divisor; + *plow = result; + *phigh = dividend % divisor; +return result != *plow; + } +}#else void muls64 (uint64_t *phigh,uint64_t *plow,int64_t a,int64_t b);void mulu64 (uint64_t *phigh,uint64_t *plow,uint64_t a,uint64_t b);int divu128 (uint64_t *plow,uint64_t *phigh,uint64_t divisor); +int divs128 (int64_t *plow,int64_t *phigh,int64_t divisor);#endif /**
target-ppc/helper.h +1 -0
@@ -32,6 +32,7 @@ DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)#if defined(TARGET_PPC64 ) DEF_HELPER_3(mulldo, i64, env, i64, i64) DEF_HELPER_4(divdeu, i64, env, i64, i64, i32) +DEF_HELPER_4(divde, i64, env, i64, i64, i32)#endif DEF_HELPER_FLAGS_1 (cntlzw,TCG_CALL_NO_RWG_SE , tl, tl)
target-ppc/int_helper.c +23 -0
@@ -65,6 +65,29 @@ uint64_t helper_divdeu(CPUPPCState *env, uint64_t ra, uint64_t rb, uint32_t oe) return rt; } +uint64_t helper_divde (CPUPPCState *env,uint64_t rau,uint64_t rbu,uint32_t oe) +{ +int64_t rt =0 ; +int64_t ra = (int64_t )rau; +int64_t rb = (int64_t )rbu; +int overflow =divs128 (&rt, &ra, rb); + +if (unlikely (overflow)) { + rt =0 ;/* Undefined */ + } + +if (oe) { + +if (unlikely (overflow)) { + env->so = env->ov =1 ; + }else { + env->ov =0 ; + } + } + +return rt; +} +#endif
target-ppc/translate.c +4 -1
@@ -1049,7 +1049,8 @@ GEN_INT_ARITH_DIVD(divdo, 0x1F, 1, 1);GEN_DIVE (divdeu, divdeu,0 );GEN_DIVE (divdeuo, divdeu,1 ); - +GEN_DIVE (divde, divde,0 ); +GEN_DIVE (divdeo, divde,1 );#endif /* mulhw mulhw. */
@@ -9727,6 +9728,8 @@ GEN_INT_ARITH_DIVD(divdo, 0x1F, 1, 1),GEN_HANDLER_E (divdeu,0x1F ,0x09 ,0x0C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ),GEN_HANDLER_E (divdeuo,0x1F ,0x09 ,0x1C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), +GEN_HANDLER_E (divde,0x1F ,0x09 ,0x0D ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), +GEN_HANDLER_E (divdeo,0x1F ,0x09 ,0x1D ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), #undef GEN_INT_ARITH_MUL_HELPER #define GEN_INT_ARITH_MUL_HELPER(name, opc3) \
util/host-utils.c +37 -0
@@ -124,4 +124,41 @@ int divu128(uint64_t *plow, uint64_t *phigh, uint64_t divisor) return 0; } } + +int divs128 (int64_t *plow,int64_t *phigh,int64_t divisor) +{ +int sgn_dvdnd = *phigh <0 ; +int sgn_divsr = divisor <0 ; +int overflow =0 ; + +if (sgn_dvdnd) { + *plow = ~(*plow); + *phigh = ~(*phigh); +if (*plow == (int64_t )-1 ) { + *plow =0 ; + (*phigh)++; + }else { + (*plow)++; + } + } + +if (sgn_divsr) { + divisor =0 - divisor; + } + + overflow =divu128 ((uint64_t *)plow, (uint64_t *)phigh, (uint64_t )divisor); + +if (sgn_dvdnd ^ sgn_divsr) { + *plow =0 - *plow; + } + +if (!overflow) { +if ((*plow <0 ) ^ (sgn_dvdnd ^ sgn_divsr)) { + overflow =1 ; + } + } + +return overflow; +} +#endif /* !CONFIG_INT128 */
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 058/130] target-ppc: Add Flag for ISA2.06 Atomic Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a flag for the atomic instructions introduced in Power ISA V2.06B.
--- target-ppc/cpu.h | 5 ++++- target-ppc/translate_init.c | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-)
target-ppc/cpu.h +4 -1
@@ -1881,10 +1881,13 @@ enum {PPC2_PERM_ISA206 =0x0000000000000080ULL ,/* ISA 2.06B divide extended variants */ PPC2_DIVE_ISA206 =0x0000000000000100ULL , +/* ISA 2.06B larx/stcx. instructions */ +PPC2_ATOMIC_ISA206 =0x0000000000000200ULL , + #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \PPC2_ISA205 |PPC2_VSX207 |PPC2_PERM_ISA206 | \ - PPC2_DIVE_ISA206) + PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206) };/*****************************************************************************/
target-ppc/translate_init.c +6 -3
@@ -7069,7 +7069,8 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 | -PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 ; +PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | +PPC2_ATOMIC_ISA206 ; pcc->msr_mask =0x800000000284FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7108,7 +7109,8 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 | -PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 ; +PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | +PPC2_ATOMIC_ISA206 ; pcc->msr_mask =0x800000000204FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7147,7 +7149,8 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX | -PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 ; +PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | +PPC2_ATOMIC_ISA206 ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 051/130] target-ppc: Scalar Non-Signalling Conversions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the non-signalling scalar conversion instructions:
- VSX Scalar Convert Single Precision to Double Precision Non-Signalling (xscvspdpn)
- VSX Scalar Convert Double Precision to Single Precision Non-Signalling (xscvdpspn)
--- target-ppc/fpu_helper.c | 16 ++++++++++++++++ target-ppc/helper.h | 2 ++ target-ppc/translate.c | 4 ++++ 3 files changed, 22 insertions(+)
target-ppc/fpu_helper.c +16 -0
@@ -2487,6 +2487,22 @@ VSX_CVT_FP_TO_FP(xscvspdp, 1, float32, float64, f32[j], f64[i], 1) VSX_CVT_FP_TO_FP(xvcvdpsp, 2, float64, float32, f64[i], f32[j], 0) VSX_CVT_FP_TO_FP(xvcvspdp, 2, float32, float64, f32[j], f64[i], 0) +uint64_t helper_xscvdpspn (CPUPPCState *env,uint64_t xb) +{ +float_status tstat = env->fp_status; +set_float_exception_flags (0 , &tstat); + +return (uint64_t )float64_to_float32 (xb, &tstat) <<32 ; +} + +uint64_t helper_xscvspdpn (CPUPPCState *env,uint64_t xb) +{ +float_status tstat = env->fp_status; +set_float_exception_flags (0 , &tstat); + +return float32_to_float64 (xb >>32 , &tstat); +} +/* VSX_CVT_FP_TO_INT - VSX floating point to integer conversion * op - instruction mnemonic * nels - number of elements (1, 2 or 4)
target-ppc/helper.h +2 -0
@@ -273,7 +273,9 @@ DEF_HELPER_2(xscmpudp, void, env, i32) DEF_HELPER_2(xsmaxdp, void, env, i32) DEF_HELPER_2(xsmindp, void, env, i32) DEF_HELPER_2(xscvdpsp, void, env, i32) +DEF_HELPER_2(xscvdpspn, i64, env, i64) DEF_HELPER_2(xscvspdp, void, env, i32) +DEF_HELPER_2(xscvspdpn, i64, env, i64) DEF_HELPER_2(xscvdpsxds, void, env, i32) DEF_HELPER_2(xscvdpsxws, void, env, i32)DEF_HELPER_2 (xscvdpuxds, void, env, i32)
target-ppc/translate.c +4 -0
@@ -7437,7 +7437,9 @@ GEN_VSX_HELPER_2(xscmpudp, 0x0C, 0x04, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsmaxdp, 0x00, 0x14, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsmindp, 0x00, 0x15, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscvdpsp, 0x12, 0x10, 0, PPC2_VSX) +GEN_VSX_HELPER_XT_XB_ENV(xscvdpspn, 0x16, 0x10, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xscvspdp, 0x12, 0x14, 0, PPC2_VSX) +GEN_VSX_HELPER_XT_XB_ENV(xscvspdpn, 0x16, 0x14, 0, PPC2_VSX207) GEN_VSX_HELPER_2(xscvdpsxds, 0x10, 0x15, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscvdpsxws, 0x10, 0x05, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xscvdpuxds,0x10 ,0x14 ,0 ,PPC2_VSX )
@@ -10275,7 +10277,9 @@ GEN_XX2FORM(xscmpudp, 0x0C, 0x04, PPC2_VSX),GEN_XX3FORM (xsmaxdp,0x00 ,0x14 ,PPC2_VSX ),GEN_XX3FORM (xsmindp,0x00 ,0x15 ,PPC2_VSX ),GEN_XX2FORM (xscvdpsp,0x12 ,0x10 ,PPC2_VSX ), +GEN_XX2FORM (xscvdpspn,0x16 ,0x10 ,PPC2_VSX207 ),GEN_XX2FORM (xscvspdp,0x12 ,0x14 ,PPC2_VSX ), +GEN_XX2FORM (xscvspdpn,0x16 ,0x14 ,PPC2_VSX207 ),GEN_XX2FORM (xscvdpsxds,0x10 ,0x15 ,PPC2_VSX ),GEN_XX2FORM (xscvdpsxws,0x10 ,0x05 ,PPC2_VSX ), GEN_XX2FORM(xscvdpuxds, 0x10, 0x14, PPC2_VSX),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 054/130] target-ppc: Add ISA2.06 divdeu[o] Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Divide Doubleword Extended Unsigned instructions. This instruction requires dividing a 128-bit value by a 64 bit value. Since 128 bit integer division is not supported in TCG, a helper is used. An architecture independent 128-bit division routine is added to host-utils.
--- include/qemu/host-utils.h | 14 ++++++++++++++ target-ppc/helper.h | 1 + target-ppc/int_helper.c | 27 +++++++++++++++++++++++++++ target-ppc/translate.c | 21 +++++++++++++++++++++ util/host-utils.c | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+)
include/qemu/host-utils.h +14 -0
@@ -44,9 +44,23 @@ static inline void muls64(uint64_t *plow, uint64_t *phigh, *plow = r; *phigh = r >> 64; } + +static inline int divu128 (uint64_t *plow,uint64_t *phigh,uint64_t divisor) +{ +if (divisor ==0 ) { +return 1 ; + }else { +__uint128_t dividend = ((__uint128_t)*phigh <<64 ) | *plow; +__uint128_t result = dividend / divisor; + *plow = result; + *phigh = dividend % divisor; +return result >UINT64_MAX ; + } +}#else void muls64 (uint64_t *phigh,uint64_t *plow,int64_t a,int64_t b);void mulu64 (uint64_t *phigh,uint64_t *plow,uint64_t a,uint64_t b); +int divu128 (uint64_t *plow,uint64_t *phigh,uint64_t divisor);#endif /**
target-ppc/helper.h +1 -0
@@ -31,6 +31,7 @@ DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)#if defined(TARGET_PPC64 ) DEF_HELPER_3(mulldo, i64, env, i64, i64) +DEF_HELPER_4(divdeu, i64, env, i64, i64, i32)#endif DEF_HELPER_FLAGS_1 (cntlzw,TCG_CALL_NO_RWG_SE , tl, tl)
target-ppc/int_helper.c +27 -0
@@ -41,6 +41,33 @@ uint64_t helper_mulldo(CPUPPCState *env, uint64_t arg1, uint64_t arg2) }#endif +#if defined(TARGET_PPC64 ) + +uint64_t helper_divdeu (CPUPPCState *env,uint64_t ra,uint64_t rb,uint32_t oe) +{ +uint64_t rt =0 ; +int overflow =0 ; + + overflow =divu128 (&rt, &ra, rb); + +if (unlikely (overflow)) { + rt =0 ;/* Undefined */ + } + +if (oe) { +if (unlikely (overflow)) { + env->so = env->ov =1 ; + }else { + env->ov =0 ; + } + } + +return rt; +} + +#endif + +target_ulong helper_cntlzw (target_ulong t) {return clz32 (t);
target-ppc/translate.c +21 -0
@@ -984,6 +984,20 @@ GEN_INT_ARITH_DIVW(divwuo, 0x1E, 0, 1);/* divw divw. divwo divwo. */ GEN_INT_ARITH_DIVW (divw,0x0F ,1 ,0 );GEN_INT_ARITH_DIVW (divwo,0x1F ,1 ,1 ); + +/* div[wd]eu[o][.] */ +#define GEN_DIVE (name, hlpr, compute_ov) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + TCGv_i32 t0 = tcg_const_i32(compute_ov); \ + gen_helper_##hlpr(cpu_gpr[rD(ctx->opcode)], cpu_env, \ + cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], t0); \ + tcg_temp_free_i32(t0); \ + if (unlikely(Rc(ctx->opcode) != 0)) { \ + gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); \ + } \ +} +#if defined(TARGET_PPC64 )static inline void gen_op_arith_divd (DisasContext *ctx,TCGv ret,TCGv arg1,TCGv arg2,int sign,int compute_ov)
@@ -1032,6 +1046,10 @@ GEN_INT_ARITH_DIVD(divduo, 0x1E, 0, 1);/* divw divw. divwo divwo. */ GEN_INT_ARITH_DIVD (divd,0x0F ,1 ,0 );GEN_INT_ARITH_DIVD (divdo,0x1F ,1 ,1 ); + +GEN_DIVE (divdeu, divdeu,0 ); +GEN_DIVE (divdeuo, divdeu,1 ); +#endif /* mulhw mulhw. */
@@ -9707,6 +9725,9 @@ GEN_INT_ARITH_DIVD(divduo, 0x1E, 0, 1),GEN_INT_ARITH_DIVD (divd,0x0F ,1 ,0 ),GEN_INT_ARITH_DIVD (divdo,0x1F ,1 ,1 ), +GEN_HANDLER_E (divdeu,0x1F ,0x09 ,0x0C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), +GEN_HANDLER_E (divdeuo,0x1F ,0x09 ,0x1C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), + #undef GEN_INT_ARITH_MUL_HELPER #define GEN_INT_ARITH_MUL_HELPER(name, opc3) \GEN_HANDLER (name,0x1F ,0x09 , opc3,0x00000000 ,PPC_64B )
util/host-utils.c +38 -0
@@ -86,4 +86,42 @@ void muls64 (uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b) } *phigh = rh; } + +/* Unsigned 128x64 division. Returns 1 if overflow (divide by zero or */ +/* quotient exceeds 64 bits). Otherwise returns quotient via plow and */ +/* remainder via phigh. */ +int divu128 (uint64_t *plow,uint64_t *phigh,uint64_t divisor) +{ +uint64_t dhi = *phigh; +uint64_t dlo = *plow; +unsigned i; +uint64_t carry =0 ; + +if (divisor ==0 ) { +return 1 ; + }else if (dhi ==0 ) { + *plow = dlo / divisor; + *phigh = dlo % divisor; +return 0 ; + }else if (dhi > divisor) { +return 1 ; + }else { + +for (i =0 ; i <64 ; i++) { + carry = dhi >>63 ; + dhi = (dhi <<1 ) | (dlo >>63 ); +if (carry || (dhi >= divisor)) { + dhi -= divisor; + carry =1 ; + }else { + carry =0 ; + } + dlo = (dlo <<1 ) | carry; + } + + *plow = dlo; + *phigh = dhi; +return 0 ; + } +}#endif /* !CONFIG_INT128 */
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 061/130] target-ppc: Add Flag for ISA V2.06 Floating Point Conversion
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a flag for the floating point conversion instructions introduced in Power ISA 2.06B.
--- target-ppc/cpu.h | 5 ++++- target-ppc/translate_init.c | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-)
target-ppc/cpu.h +4 -1
@@ -1883,11 +1883,14 @@ enum {PPC2_DIVE_ISA206 =0x0000000000000100ULL ,/* ISA 2.06B larx/stcx. instructions */ PPC2_ATOMIC_ISA206 =0x0000000000000200ULL , +/* ISA 2.06B floating point integer conversion */ +PPC2_FP_CVT_ISA206 =0x0000000000000400ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \PPC2_ISA205 |PPC2_VSX207 |PPC2_PERM_ISA206 | \ - PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206) +PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 | \ + PPC2_FP_CVT_ISA206) };/*****************************************************************************/
target-ppc/translate_init.c +3 -3
@@ -7070,7 +7070,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | -PPC2_ATOMIC_ISA206 ; +PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 ; pcc->msr_mask =0x800000000284FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7110,7 +7110,7 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | -PPC2_ATOMIC_ISA206 ; +PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 ; pcc->msr_mask =0x800000000204FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7150,7 +7150,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | -PPC2_ATOMIC_ISA206 ; +PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 068/130] target-ppc: Enable frsqrtes on Power7 and Power8
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
The frsqrtes instruction was introduced prior to ISA 2.06 and is support on both the Power7 and Power8 processors. However, this instruction is handled as illegal in the current QEMU emulation machines. This patch enables the existing implemention of frsqrtes in the P7 and P8 machines.
--- target-ppc/translate_init.c | 3 +++ 1 file changed, 3 insertions(+)
target-ppc/translate_init.c +3 -0
@@ -7061,6 +7061,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) pcc->insns_flags =PPC_INSNS_BASE |PPC_ISEL |PPC_STRING |PPC_MFTB |PPC_FLOAT |PPC_FLOAT_FSEL |PPC_FLOAT_FRES |PPC_FLOAT_FSQRT |PPC_FLOAT_FRSQRTE | +PPC_FLOAT_FRSQRTES |PPC_FLOAT_STFIWX |PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
@@ -7103,6 +7104,7 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data) pcc->insns_flags =PPC_INSNS_BASE |PPC_ISEL |PPC_STRING |PPC_MFTB |PPC_FLOAT |PPC_FLOAT_FSEL |PPC_FLOAT_FRES |PPC_FLOAT_FSQRT |PPC_FLOAT_FRSQRTE | +PPC_FLOAT_FRSQRTES |PPC_FLOAT_STFIWX |PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
@@ -7145,6 +7147,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) pcc->insns_flags =PPC_INSNS_BASE |PPC_STRING |PPC_MFTB |PPC_FLOAT |PPC_FLOAT_FSEL |PPC_FLOAT_FRES |PPC_FLOAT_FSQRT |PPC_FLOAT_FRSQRTE | +PPC_FLOAT_FRSQRTES |PPC_FLOAT_STFIWX |PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 069/130] target-ppc: Add ISA2.06 lfiwzx Instruction
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Load Floating Point as Integer Word and Zero Indexed (lfiwzx) instruction which was introduced in Power ISA 2.06.
--- target-ppc/translate.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
target-ppc/translate.c +15 -0
@@ -3508,6 +3508,20 @@ static void gen_lfiwax(DisasContext *ctx)tcg_temp_free (t0); } +/* lfiwzx */ +static void gen_lfiwzx (DisasContext *ctx) +{ +TCGv EA ; +if (unlikely (!ctx->fpu_enabled)) { +gen_exception (ctx,POWERPC_EXCP_FPU ); +return ; + } +gen_set_access_type (ctx,ACCESS_FLOAT ); +EA =tcg_temp_new (); +gen_addr_reg_index (ctx,EA ); +gen_qemu_ld32u_i64 (ctx, cpu_fpr[rD (ctx->opcode)],EA ); +tcg_temp_free (EA ); +}/*** Floating-point store ***/ #define GEN_STF (name, stop, opc, type) \ static void glue(gen_, name)(DisasContext *ctx) \
@@ -9984,6 +9998,7 @@ GEN_LDXF(name, ldop, 0x17, op | 0x00, type) GEN_LDFS(lfd, ld64, 0x12, PPC_FLOAT) GEN_LDFS(lfs, ld32fs, 0x10, PPC_FLOAT)GEN_HANDLER_E (lfiwax,0x1f ,0x17 ,0x1a ,0x00000001 ,PPC_NONE ,PPC2_ISA205 ), +GEN_HANDLER_E (lfiwzx,0x1f ,0x17 ,0x1b ,0x1 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ),GEN_HANDLER_E (lfdp,0x39 ,0xFF ,0xFF ,0x00200003 ,PPC_NONE ,PPC2_ISA205 ), GEN_HANDLER_E(lfdpx, 0x1F, 0x17, 0x18, 0x00200001, PPC_NONE, PPC2_ISA205),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 064/130] target-ppc: Fix and enable fri[mnpz]
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
The fri* series of instructions was introduced prior to ISA 2.06 and is supported on Power7 and Power8 hardware. However, the instruction is still considered illegal in the P7 and P8 QEMU emulation models. This patch enables these instructions for the P7 and P8 machines.
Also, the existing helper is modified to correctly handle some of the boundary cases (NaNs and the inexact flag).
--- target-ppc/fpu_helper.c | 18 +++++++++++------- target-ppc/translate_init.c | 3 +++ 2 files changed, 14 insertions(+), 7 deletions(-)
target-ppc/fpu_helper.c +11 -7
@@ -669,24 +669,28 @@ static inline uint64_t do_fri(CPUPPCState *env, uint64_t arg,if (unlikely (float64_is_signaling_nan (farg.d))) {/* sNaN round */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ,1 ); - }else if (unlikely (float64_is_quiet_nan (farg.d) || -float64_is_infinity (farg.d))) { -/* qNan / infinity round */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); +fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN ,1 ); + farg.ll = arg |0x0008000000000000ul ; }else { +int inexact =get_float_exception_flags (&env->fp_status) & + float_flag_inexact;set_float_rounding_mode (rounding_mode, &env->fp_status); farg.ll =float64_round_to_int (farg.d, &env->fp_status);/* Restore rounding mode from FPSCR */ fpscr_set_rounding_mode (env); + +/* fri* does not set FPSCR[XX] */ +if (!inexact) { + env->fp_status.float_exception_flags &= ~float_flag_inexact; + } } +helper_float_check_status (env);return farg.ll; }uint64_t helper_frin (CPUPPCState *env,uint64_t arg) { -return do_fri (env, arg, float_round_nearest_even); +return do_fri (env, arg, float_round_ties_away); }uint64_t helper_friz (CPUPPCState *env,uint64_t arg)
target-ppc/translate_init.c +3 -0
@@ -7062,6 +7062,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)PPC_FLOAT |PPC_FLOAT_FSEL |PPC_FLOAT_FRES |PPC_FLOAT_FSQRT |PPC_FLOAT_FRSQRTE |PPC_FLOAT_STFIWX | +PPC_FLOAT_EXT |PPC_CACHE |PPC_CACHE_ICBI |PPC_CACHE_DCBZ |PPC_MEM_SYNC |PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
@@ -7102,6 +7103,7 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)PPC_FLOAT |PPC_FLOAT_FSEL |PPC_FLOAT_FRES |PPC_FLOAT_FSQRT |PPC_FLOAT_FRSQRTE |PPC_FLOAT_STFIWX | +PPC_FLOAT_EXT |PPC_CACHE |PPC_CACHE_ICBI |PPC_CACHE_DCBZ |PPC_MEM_SYNC |PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
@@ -7142,6 +7144,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC_FLOAT |PPC_FLOAT_FSEL |PPC_FLOAT_FRES |PPC_FLOAT_FSQRT |PPC_FLOAT_FRSQRTE |PPC_FLOAT_STFIWX | +PPC_FLOAT_EXT |PPC_CACHE |PPC_CACHE_ICBI |PPC_CACHE_DCBZ |PPC_MEM_SYNC |PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 065/130] target-ppc: Add Flag for Power ISA V2.06 Floating Point Test Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a flag for Floating Point Test instructions that were introduced in Power ISA V2.06B.
--- target-ppc/cpu.h | 4 +++- target-ppc/translate_init.c | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-)
target-ppc/cpu.h +3 -1
@@ -1885,12 +1885,14 @@ enum {PPC2_ATOMIC_ISA206 =0x0000000000000200ULL ,/* ISA 2.06B floating point integer conversion */ PPC2_FP_CVT_ISA206 =0x0000000000000400ULL , +/* ISA 2.06B floating point test instructions */ +PPC2_FP_TST_ISA206 =0x0000000000000800ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \PPC2_ISA205 |PPC2_VSX207 |PPC2_PERM_ISA206 | \PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 | \ - PPC2_FP_CVT_ISA206) + PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206) };/*****************************************************************************/
target-ppc/translate_init.c +6 -3
@@ -7071,7 +7071,8 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | -PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 ; +PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 | +PPC2_FP_TST_ISA206 ; pcc->msr_mask =0x800000000284FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7112,7 +7113,8 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | -PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 ; +PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 | +PPC2_FP_TST_ISA206 ; pcc->msr_mask =0x800000000204FF37ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
@@ -7153,7 +7155,8 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 | -PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 ; +PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 | +PPC2_FP_TST_ISA206 ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 067/130] target-ppc: Add ISA 2.06 ftsqrt
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Floating Point Test for Square Root instruction which was introduced in Power ISA 2.06.
--- target-ppc/fpu_helper.c | 31 +++++++++++++++++++++++++++++++ target-ppc/helper.h | 1 + target-ppc/translate.c | 10 ++++++++++ 3 files changed, 42 insertions(+)
target-ppc/fpu_helper.c +31 -0
@@ -1039,6 +1039,37 @@ uint32_t helper_ftdiv(uint64_t fra, uint64_t frb)return 0x8 | (fg_flag ?4 :0 ) | (fe_flag ?2 :0 ); } +uint32_t helper_ftsqrt (uint64_t frb) +{ +int fe_flag =0 ; +int fg_flag =0 ; + +if (unlikely (float64_is_infinity (frb) ||float64_is_zero (frb))) { + fe_flag =1 ; + fg_flag =1 ; + }else { +int e_b =ppc_float64_get_unbiased_exp (frb); + +if (unlikely (float64_is_any_nan (frb))) { + fe_flag =1 ; + }else if (unlikely (float64_is_zero (frb))) { + fe_flag =1 ; + }else if (unlikely (float64_is_neg (frb))) { + fe_flag =1 ; + }else if (!float64_is_zero (frb) && (e_b <= (-1022 +52 ))) { + fe_flag =1 ; + } + +if (unlikely (float64_is_zero_or_denormal (frb))) { +/* XB is not zero because of the above check and */ +/* therefore must be denormalized. */ + fg_flag =1 ; + } + } + +return 0x8 | (fg_flag ?4 :0 ) | (fe_flag ?2 :0 ); +} +void helper_fcmpu (CPUPPCState *env,uint64_t arg1,uint64_t arg2,uint32_t crfD) {
target-ppc/helper.h +1 -0
@@ -100,6 +100,7 @@ DEF_HELPER_2(frsqrte, i64, env, i64) DEF_HELPER_4(fsel, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_2(ftdiv, TCG_CALL_NO_RWG_SE, i32, i64, i64) +DEF_HELPER_FLAGS_1(ftsqrt, TCG_CALL_NO_RWG_SE, i32, i64)#define dh_alias_avr ptr#define dh_ctype_avr ppc_avr_t *
target-ppc/translate.c +10 -0
@@ -2248,6 +2248,15 @@ static void gen_ftdiv(DisasContext *ctx) cpu_fpr[rB(ctx->opcode)]); } +static void gen_ftsqrt (DisasContext *ctx) +{ +if (unlikely (!ctx->fpu_enabled)) { +gen_exception (ctx,POWERPC_EXCP_FPU ); +return ; + } +gen_helper_ftsqrt (cpu_crf[crfD (ctx->opcode)], cpu_fpr[rB (ctx->opcode)]); +} +/*** Floating-Point compare ***/
@@ -9869,6 +9878,7 @@ GEN_FLOAT_ACB(msub, 0x1C, 1, PPC_FLOAT),GEN_FLOAT_ACB (nmadd,0x1F ,1 ,PPC_FLOAT ),GEN_FLOAT_ACB (nmsub,0x1E ,1 ,PPC_FLOAT ),GEN_HANDLER_E (ftdiv,0x3F ,0x00 ,0x04 ,1 ,PPC_NONE ,PPC2_FP_TST_ISA206 ), +GEN_HANDLER_E (ftsqrt,0x3F ,0x00 ,0x05 ,1 ,PPC_NONE ,PPC2_FP_TST_ISA206 ),GEN_FLOAT_B (ctiw,0x0E ,0x00 ,0 ,PPC_FLOAT ),GEN_HANDLER_E (fctiwu,0x3F ,0x0E ,0x04 ,0 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ), GEN_FLOAT_B(ctiwz, 0x0F, 0x00, 0, PPC_FLOAT),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 070/130] PPC: KVM: store SLB slot number
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
When ppc_store_slb() is called from kvm_arch_get_registers(), it stores a SLB in CPUPPCState::slb[slot]. However it drops the slot number from ESID so when kvm_arch_put_registers() puts SLBs back to KVM, they do not have correct "index" field anymore. This broke migration with LPCR_AIR enabled as now the guest is handling interrupts in virtual mode and unable to reconstruct correct SLBs anymore.
This adds "index" field for valid SLBs when putting them to KVM.
--- target-ppc/kvm.c | 3 +++ 1 file changed, 3 insertions(+)
target-ppc/kvm.c +3 -0
@@ -820,6 +820,9 @@ int kvm_arch_put_registers(CPUState *cs, int level)#ifdef TARGET_PPC64 for (i =0 ; i <ARRAY_SIZE (env->slb); i++) { sregs.u.s.ppc64.slb[i].slbe = env->slb[i].esid; +if (env->slb[i].esid &SLB_ESID_V ) { + sregs.u.s.ppc64.slb[i].slbe |= i; + } sregs.u.s.ppc64.slb[i].slbv = env->slb[i].vsid; }#endif
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 071/130] virtex_ml507: Add support for loading initrd images
In reply to Alexander GrafFrom: "Edgar E. Iglesias" <[email protected]>
--- hw/ppc/virtex_ml507.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
hw/ppc/virtex_ml507.c +33 -1
@@ -174,6 +174,19 @@ static int xilinx_load_device_tree(hwaddr addr,if (!fdt) {return 0 ; } + + r =qemu_fdt_setprop_cell (fdt,"/chosen" ,"linux,initrd-start" , + initrd_base); +if (r <0 ) { +error_report ("couldn't set /chosen/linux,initrd-start" ); + } + + r =qemu_fdt_setprop_cell (fdt,"/chosen" ,"linux,initrd-end" , + (initrd_base + initrd_size)); +if (r <0 ) { +error_report ("couldn't set /chosen/linux,initrd-end" ); + } + r =qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , kernel_cmdline);if (r <0 )fprintf (stderr,"couldn't set /chosen/bootargs\n" );
@@ -187,6 +200,8 @@ static void virtex_init(QEMUMachineInitArgs *args)const char *cpu_model = args->cpu_model;const char *kernel_filename = args->kernel_filename;const char *kernel_cmdline = args->kernel_cmdline; +hwaddr initrd_base =0 ; +int initrd_size =0 ;MemoryRegion *address_space_mem =get_system_memory ();DeviceState *dev;PowerPCCPU *cpu;
@@ -259,10 +274,27 @@ static void virtex_init(QEMUMachineInitArgs *args) boot_info.ima_size = kernel_size; +/* Load initrd. */ +if (args->initrd_filename) { + initrd_base = high =ROUND_UP (high,4 ); + initrd_size =load_image_targphys (args->initrd_filename, + high, ram_size - high); + +if (initrd_size <0 ) { +error_report ("couldn't load ram disk '%s'" , + args->initrd_filename); +exit (1 ); + } + high =ROUND_UP (high + initrd_size,4 ); + } +/* Provide a device-tree. */ boot_info.fdt = high + (8192 *2 ); boot_info.fdt &= ~8191 ; -xilinx_load_device_tree (boot_info.fdt, ram_size,0 ,0 , kernel_cmdline); + +xilinx_load_device_tree (boot_info.fdt, ram_size, + initrd_base, initrd_size, + kernel_cmdline); } env->load_info = &boot_info; }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 060/130] target-ppc: Add ISA 2.06 stbcx. and sthcx. Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the byte and halfword variants of the Store Conditional
instructions. A common macro is introduced and the existing implementations
of stwcx. and stdcx. are refactored to use this macro.
--- target-ppc/translate.c | 91 ++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 47 deletions(-)
target-ppc/translate.c +44 -47
@@ -3231,8 +3231,8 @@ LARX(lwarx, 4, ld32u);#if defined(CONFIG_USER_ONLY ) -static void gen_conditional_store (DisasContext *ctx,TCGv EA , -int reg,int size) +static void gen_conditional_store (DisasContext *ctx,TCGv EA , +int reg,int size) {TCGv t0 =tcg_temp_new ();uint32_t save_exception = ctx->exception;
@@ -3246,62 +3246,57 @@ static void gen_conditional_store (DisasContext *ctx, TCGv EA,gen_exception (ctx,POWERPC_EXCP_STCX ); ctx->exception = save_exception; } -#endif - -/* stwcx. */ -static void gen_stwcx_ (DisasContext *ctx) -{ -TCGv t0; -gen_set_access_type (ctx,ACCESS_RES ); - t0 =tcg_temp_local_new (); -gen_addr_reg_index (ctx, t0); -gen_check_align (ctx, t0,0x03 ); -#if defined(CONFIG_USER_ONLY ) -gen_conditional_store (ctx, t0,rS (ctx->opcode),4 );#else - { -int l1; +static void gen_conditional_store (DisasContext *ctx,TCGv EA , +int reg,int size) +{ +int l1; -tcg_gen_trunc_tl_i32 (cpu_crf[0 ], cpu_so); - l1 =gen_new_label (); -tcg_gen_brcond_tl (TCG_COND_NE , t0, cpu_reserve, l1); -tcg_gen_ori_i32 (cpu_crf[0 ], cpu_crf[0 ],1 <<CRF_EQ ); -gen_qemu_st32 (ctx, cpu_gpr[rS (ctx->opcode)], t0); -gen_set_label (l1); -tcg_gen_movi_tl (cpu_reserve,-1 ); +tcg_gen_trunc_tl_i32 (cpu_crf[0 ], cpu_so); + l1 =gen_new_label (); +tcg_gen_brcond_tl (TCG_COND_NE ,EA , cpu_reserve, l1); +tcg_gen_ori_i32 (cpu_crf[0 ], cpu_crf[0 ],1 <<CRF_EQ ); +#if defined(TARGET_PPC64 ) +if (size ==8 ) { +gen_qemu_st64 (ctx, cpu_gpr[reg],EA ); + } else +#endif +if (size ==4 ) { +gen_qemu_st32 (ctx, cpu_gpr[reg],EA ); + }else if (size ==2 ) { +gen_qemu_st16 (ctx, cpu_gpr[reg],EA ); + }else { +gen_qemu_st8 (ctx, cpu_gpr[reg],EA ); } +gen_set_label (l1); +tcg_gen_movi_tl (cpu_reserve,-1 ); +}#endif -tcg_temp_free (t0); + +#define STCX (name, len) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + TCGv t0; \ + gen_set_access_type(ctx, ACCESS_RES); \ + t0 = tcg_temp_local_new(); \ + gen_addr_reg_index(ctx, t0); \ + if (len > 1) { \ + gen_check_align(ctx, t0, (len)-1); \ + } \ + gen_conditional_store(ctx, t0, rS(ctx->opcode), len); \ + tcg_temp_free(t0); \ } +STCX (stbcx_,1 ); +STCX (sthcx_,2 ); +STCX (stwcx_,4 ); +#if defined(TARGET_PPC64 )/* ldarx */ LARX (ldarx,8 , ld64);/* stdcx. */ -static void gen_stdcx_ (DisasContext *ctx) -{ -TCGv t0; -gen_set_access_type (ctx,ACCESS_RES ); - t0 =tcg_temp_local_new (); -gen_addr_reg_index (ctx, t0); -gen_check_align (ctx, t0,0x07 ); -#if defined(CONFIG_USER_ONLY ) -gen_conditional_store (ctx, t0,rS (ctx->opcode),8 ); -#else - { -int l1; -tcg_gen_trunc_tl_i32 (cpu_crf[0 ], cpu_so); - l1 =gen_new_label (); -tcg_gen_brcond_tl (TCG_COND_NE , t0, cpu_reserve, l1); -tcg_gen_ori_i32 (cpu_crf[0 ], cpu_crf[0 ],1 <<CRF_EQ ); -gen_qemu_st64 (ctx, cpu_gpr[rS (ctx->opcode)], t0); -gen_set_label (l1); -tcg_gen_movi_tl (cpu_reserve,-1 ); - } -#endif -tcg_temp_free (t0); -} +STCX (stdcx_,8 );#endif /* defined(TARGET_PPC64) */ /* sync */
@@ -9512,6 +9507,8 @@ GEN_HANDLER(isync, 0x13, 0x16, 0x04, 0x03FFF801, PPC_MEM), GEN_HANDLER_E(lbarx, 0x1F, 0x14, 0x01, 0, PPC_NONE, PPC2_ATOMIC_ISA206), GEN_HANDLER_E(lharx, 0x1F, 0x14, 0x03, 0, PPC_NONE, PPC2_ATOMIC_ISA206), GEN_HANDLER(lwarx, 0x1F, 0x14, 0x00, 0x00000000, PPC_RES), +GEN_HANDLER_E(stbcx_, 0x1F, 0x16, 0x15, 0, PPC_NONE, PPC2_ATOMIC_ISA206), +GEN_HANDLER_E(sthcx_, 0x1F, 0x16, 0x16, 0, PPC_NONE, PPC2_ATOMIC_ISA206), GEN_HANDLER2(stwcx_, "stwcx.", 0x1F, 0x16, 0x04, 0x00000000, PPC_RES),#if defined(TARGET_PPC64 ) GEN_HANDLER(ldarx, 0x1F, 0x14, 0x02, 0x00000000, PPC_64B),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 072/130] PPC: KVM: suppress warnings about not supported SPRs
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
PR KVM lacks support of many SPRs in set/get one register API but it does really break PR KVM. So convert them to switchable traces for now.
--- target-ppc/kvm.c | 7 +++---- trace-events | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-)
target-ppc/kvm.c +3 -4
@@ -36,6 +36,7 @@#include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "sysemu/watchdog.h" +#include "trace.h" //#define DEBUG_KVM
@@ -480,8 +481,7 @@ static void kvm_get_one_spr(CPUState *cs, uint64_t id, int spr) ret =kvm_vcpu_ioctl (cs,KVM_GET_ONE_REG , ®);if (ret !=0 ) { -fprintf (stderr,"Warning: Unable to retrieve SPR %d from KVM: %s\n" , - spr,strerror (errno)); +trace_kvm_failed_spr_get (spr,strerror (errno)); }else {switch (id &KVM_REG_SIZE_MASK ) {case KVM_REG_SIZE_U32 :
@@ -529,8 +529,7 @@ static void kvm_put_one_spr(CPUState *cs, uint64_t id, int spr) ret =kvm_vcpu_ioctl (cs,KVM_SET_ONE_REG , ®);if (ret !=0 ) { -fprintf (stderr,"Warning: Unable to set SPR %d to KVM: %s\n" , - spr,strerror (errno)); +trace_kvm_failed_spr_set (spr,strerror (errno)); } }
trace-events +2 -0
@@ -1176,6 +1176,8 @@ kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p" kvm_vcpu_ioctl(int cpu_index, int type, void *arg) "cpu_index %d, type 0x%x, arg %p" kvm_run_exit(int cpu_index, uint32_t reason) "cpu_index %d, reason %d" kvm_device_ioctl(int fd, int type, void *arg) "dev fd %d, type 0x%x, arg %p" +kvm_failed_spr_set(int str, const char *msg) "Warning: Unable to set SPR %d to KVM: %s" +kvm_failed_spr_get(int str, const char *msg) "Warning: Unable to retrieve SPR %d from KVM: %s" # memory.c memory_region_ops_read(void *mr, uint64_t addr, uint64_t value, unsigned size) "mr %p addr %#"PRIx64" value %#"PRIx64" size %u"
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 063/130] target-ppc: Add ISA 2.06 fcfid[u][s] Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the fcfids, fcfidu and fcfidus instructions which were introduced in Power ISA 2.06B. A common macro is provided to eliminate repetitious code, and the existing fcfid instruction is refactored to use this macro.
--- target-ppc/fpu_helper.c | 28 +++++++++++++++++++--------- target-ppc/helper.h | 3 +++ target-ppc/translate.c | 9 +++++++++ 3 files changed, 31 insertions(+), 9 deletions(-)
target-ppc/fpu_helper.c +19 -9
@@ -637,16 +637,26 @@ FPU_FCTI(fctiduz, uint64_round_to_zero, 0x0000000000000000)#endif #if defined(TARGET_PPC64 ) -/* fcfid - fcfid. */ -uint64_t helper_fcfid (CPUPPCState *env,uint64_t arg) -{ -CPU_DoubleU farg; - - farg.d =int64_to_float64 (arg, &env->fp_status); -return farg.ll; -} - +#define FPU_FCFI (op, cvtr, is_single) \ +uint64_t helper_##op(CPUPPCState *env, uint64_t arg) \ +{ \ + CPU_DoubleU farg; \ + \ + if (is_single) { \ + float32 tmp = cvtr(arg, &env->fp_status); \ + farg.d = float32_to_float64(tmp, &env->fp_status); \ + } else { \ + farg.d = cvtr(arg, &env->fp_status); \ + } \ + helper_float_check_status(env); \ + return farg.ll; \ +} + +FPU_FCFI(fcfid, int64_to_float64, 0) +FPU_FCFI(fcfids, int64_to_float32, 1) +FPU_FCFI(fcfidu, uint64_to_float64, 0) +FPU_FCFI(fcfidus, uint64_to_float32, 1)#endif
target-ppc/helper.h +3 -0
@@ -71,6 +71,9 @@ DEF_HELPER_2(fctiwz, i64, env, i64) DEF_HELPER_2(fctiwuz, i64, env, i64)#if defined(TARGET_PPC64 ) DEF_HELPER_2(fcfid, i64, env, i64) +DEF_HELPER_2(fcfidu, i64, env, i64) +DEF_HELPER_2(fcfids, i64, env, i64) +DEF_HELPER_2(fcfidus, i64, env, i64) DEF_HELPER_2(fctid, i64, env, i64) DEF_HELPER_2(fctidu, i64, env, i64)DEF_HELPER_2 (fctidz, i64, env, i64)
target-ppc/translate.c +9 -0
@@ -2213,6 +2213,12 @@ GEN_FLOAT_B(rsp, 0x0C, 0x00, 1, PPC_FLOAT);#if defined(TARGET_PPC64 )/* fcfid */ GEN_FLOAT_B (cfid,0x0E ,0x1A ,1 ,PPC_64B ); +/* fcfids */ +GEN_FLOAT_B (cfids,0x0E ,0x1A ,0 ,PPC2_FP_CVT_ISA206 ); +/* fcfidu */ +GEN_FLOAT_B (cfidu,0x0E ,0x1E ,0 ,PPC2_FP_CVT_ISA206 ); +/* fcfidus */ +GEN_FLOAT_B (cfidus,0x0E ,0x1E ,0 ,PPC2_FP_CVT_ISA206 );/* fctid */ GEN_FLOAT_B (ctid,0x0E ,0x19 ,0 ,PPC_64B );/* fctidu */
@@ -9857,6 +9863,9 @@ GEN_HANDLER_E(fctiwuz, 0x3F, 0x0F, 0x04, 0, PPC_NONE, PPC2_FP_CVT_ISA206), GEN_FLOAT_B(rsp, 0x0C, 0x00, 1, PPC_FLOAT),#if defined(TARGET_PPC64 )GEN_FLOAT_B (cfid,0x0E ,0x1A ,1 ,PPC_64B ), +GEN_HANDLER_E (fcfids,0x3B ,0x0E ,0x1A ,0 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ), +GEN_HANDLER_E (fcfidu,0x3F ,0x0E ,0x1E ,0 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ), +GEN_HANDLER_E (fcfidus,0x3B ,0x0E ,0x1E ,0 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ),GEN_FLOAT_B (ctid,0x0E ,0x19 ,0 ,PPC_64B ),GEN_HANDLER_E (fctidu,0x3F ,0x0E ,0x1D ,0 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ), GEN_FLOAT_B(ctidz, 0x0F, 0x19, 0, PPC_64B),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 066/130] target-ppc: Add ISA 2.06 ftdiv Instruction
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Floating Point Test for Divide instruction which was introduced in Power ISA 2.06B.
--- target-ppc/fpu_helper.c | 56 ++++++++++++++++++++++++++++++++++++++++--------- target-ppc/helper.h | 2 ++ target-ppc/translate.c | 13 ++++++++++++ 3 files changed, 61 insertions(+), 10 deletions(-)
target-ppc/fpu_helper.c +46 -10
@@ -50,6 +50,16 @@ static inline int isden(float64 d)return ((u.ll >>52 ) &0x7FF ) ==0 ; } +static inline int ppc_float32_get_unbiased_exp (float32 f) +{ +return ((f >>23 ) &0xFF ) -127 ; +} + +static inline int ppc_float64_get_unbiased_exp (float64 f) +{ +return ((f >>52 ) &0x7FF ) -1023 ; +} +uint32_t helper_compute_fprf (CPUPPCState *env,uint64_t arg,uint32_t set_fprf) {CPU_DoubleU farg;
@@ -993,6 +1003,42 @@ uint64_t helper_fsel(CPUPPCState *env, uint64_t arg1, uint64_t arg2, } } +uint32_t helper_ftdiv (uint64_t fra,uint64_t frb) +{ +int fe_flag =0 ; +int fg_flag =0 ; + +if (unlikely (float64_is_infinity (fra) || +float64_is_infinity (frb) || +float64_is_zero (frb))) { + fe_flag =1 ; + fg_flag =1 ; + }else { +int e_a =ppc_float64_get_unbiased_exp (fra); +int e_b =ppc_float64_get_unbiased_exp (frb); + +if (unlikely (float64_is_any_nan (fra) || +float64_is_any_nan (frb))) { + fe_flag =1 ; + }else if ((e_b <=-1022 ) || (e_b >=1021 )) { + fe_flag =1 ; + }else if (!float64_is_zero (fra) && + (((e_a - e_b) >=1023 ) || + ((e_a - e_b) <=-1021 ) || + (e_a <=-970 ))) { + fe_flag =1 ; + } + +if (unlikely (float64_is_zero_or_denormal (frb))) { +/* XB is not zero because of the above check and */ +/* so must be denormalized. */ + fg_flag =1 ; + } + } + +return 0x8 | (fg_flag ?4 :0 ) | (fe_flag ?2 :0 ); +} +void helper_fcmpu (CPUPPCState *env,uint64_t arg1,uint64_t arg2,uint32_t crfD) {
@@ -2021,16 +2067,6 @@ VSX_RSQRTE(xsrsqrtesp, 1, float64, f64, 1, 1) VSX_RSQRTE(xvrsqrtedp, 2, float64, f64, 0, 0)VSX_RSQRTE (xvrsqrtesp,4 , float32, f32,0 ,0 ) -static inline int ppc_float32_get_unbiased_exp (float32 f) -{ -return ((f >>23 ) &0xFF ) -127 ; -} - -static inline int ppc_float64_get_unbiased_exp (float64 f) -{ -return ((f >>52 ) &0x7FF ) -1023 ; -} -/* VSX_TDIV - VSX floating point test for divide * op - instruction mnemonic * nels - number of elements (1, 2 or 4)
target-ppc/helper.h +2 -0
@@ -99,6 +99,8 @@ DEF_HELPER_2(fres, i64, env, i64) DEF_HELPER_2(frsqrte, i64, env, i64) DEF_HELPER_4(fsel, i64, env, i64, i64, i64) +DEF_HELPER_FLAGS_2(ftdiv, TCG_CALL_NO_RWG_SE, i32, i64, i64) +#define dh_alias_avr ptr#define dh_ctype_avr ppc_avr_t *#define dh_is_signed_avr dh_is_signed_ptr
target-ppc/translate.c +13 -0
@@ -2238,6 +2238,18 @@ GEN_FLOAT_B(rip, 0x08, 0x0E, 1, PPC_FLOAT_EXT);/* frim */ GEN_FLOAT_B (rim,0x08 ,0x0F ,1 ,PPC_FLOAT_EXT ); +static void gen_ftdiv (DisasContext *ctx) +{ +if (unlikely (!ctx->fpu_enabled)) { +gen_exception (ctx,POWERPC_EXCP_FPU ); +return ; + } +gen_helper_ftdiv (cpu_crf[crfD (ctx->opcode)], cpu_fpr[rA (ctx->opcode)], + cpu_fpr[rB (ctx->opcode)]); +} + + +/*** Floating-Point compare ***/ /* fcmpo */
@@ -9856,6 +9868,7 @@ GEN_FLOAT_ACB(madd, 0x1D, 1, PPC_FLOAT),GEN_FLOAT_ACB (msub,0x1C ,1 ,PPC_FLOAT ),GEN_FLOAT_ACB (nmadd,0x1F ,1 ,PPC_FLOAT ),GEN_FLOAT_ACB (nmsub,0x1E ,1 ,PPC_FLOAT ), +GEN_HANDLER_E (ftdiv,0x3F ,0x00 ,0x04 ,1 ,PPC_NONE ,PPC2_FP_TST_ISA206 ),GEN_FLOAT_B (ctiw,0x0E ,0x00 ,0 ,PPC_FLOAT ),GEN_HANDLER_E (fctiwu,0x3F ,0x0E ,0x04 ,0 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ), GEN_FLOAT_B(ctiwz, 0x0F, 0x00, 0, PPC_FLOAT),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 074/130] spapr: support only ELF kernel images
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
Currently everybody uses ELF kernel images with "-kernel" option on pseries machine but QEMU still tries to boot from an image even it fails to recognize it is ELF. This produces undefined behaviour if the user tries a kernel image compiled for another architecture.
This removes support of raw kernel images.
--- hw/ppc/spapr.c | 5 ----- 1 file changed, 5 deletions(-)
hw/ppc/spapr.c +0 -5
@@ -1313,11 +1313,6 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args) kernel_le = kernel_size >0 ; }if (kernel_size <0 ) { - kernel_size =load_image_targphys (kernel_filename, -KERNEL_LOAD_ADDR , - load_limit -KERNEL_LOAD_ADDR ); - } -if (kernel_size <0 ) {fprintf (stderr,"qemu: could not load kernel '%s'\n" , kernel_filename);exit (1 );
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 077/130] spapr: print more detailed error message on failed load_elf()
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
This makes use of new error codes which load_elf() can return and prints more informative error message.
--- hw/ppc/spapr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/ppc/spapr.c +3 -3
@@ -1306,15 +1306,15 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args) kernel_size =load_elf (kernel_filename, translate_kernel_address,NULL ,NULL , &lowaddr,NULL ,1 ,ELF_MACHINE ,0 ); -if (kernel_size <0 ) { +if (kernel_size ==ELF_LOAD_WRONG_ENDIAN ) { kernel_size =load_elf (kernel_filename, translate_kernel_address,NULL ,NULL , &lowaddr,NULL ,0 ,ELF_MACHINE ,0 ); kernel_le = kernel_size >0 ; }if (kernel_size <0 ) { -fprintf (stderr,"qemu: could not load kernel '%s'\n" , - kernel_filename); +fprintf (stderr,"qemu: error loading %s: %s\n" , + kernel_filename,load_elf_strerror (kernel_size));exit (1 ); }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 059/130] target-ppc: Add ISA2.06 lbarx, lharx Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the byte and halfword variants of the Load and
Reserve instructions. Since there is much commonality among
all forms of Load and Reserve, a macro is provided and the existing implementations of lwarx and ldarx are refactoried to use this macro.
--- target-ppc/translate.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-)
target-ppc/translate.c +24 -26
@@ -3207,21 +3207,29 @@ static void gen_isync(DisasContext *ctx)gen_stop_exception (ctx); } -/* lwarx */ -static void gen_lwarx (DisasContext *ctx) -{ -TCGv t0; -TCGv gpr = cpu_gpr[rD (ctx->opcode)]; -gen_set_access_type (ctx,ACCESS_RES ); - t0 =tcg_temp_local_new (); -gen_addr_reg_index (ctx, t0); -gen_check_align (ctx, t0,0x03 ); -gen_qemu_ld32u (ctx, gpr, t0); -tcg_gen_mov_tl (cpu_reserve, t0); -tcg_gen_st_tl (gpr, cpu_env, offsetof(CPUPPCState , reserve_val)); -tcg_temp_free (t0); +#define LARX (name, len, loadop) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + TCGv t0; \ + TCGv gpr = cpu_gpr[rD(ctx->opcode)]; \ + gen_set_access_type(ctx, ACCESS_RES); \ + t0 = tcg_temp_local_new(); \ + gen_addr_reg_index(ctx, t0); \ + if ((len) > 1) { \ + gen_check_align(ctx, t0, (len)-1); \ + } \ + gen_qemu_##loadop(ctx, gpr, t0); \ + tcg_gen_mov_tl(cpu_reserve, t0); \ + tcg_gen_st_tl(gpr, cpu_env, offsetof(CPUPPCState, reserve_val)); \ + tcg_temp_free(t0); \ } +/* lwarx */ +LARX (lbarx,1 , ld8u); +LARX (lharx,2 , ld16u); +LARX (lwarx,4 , ld32u); + +#if defined(CONFIG_USER_ONLY )static void gen_conditional_store (DisasContext *ctx,TCGv EA ,int reg,int size)
@@ -3268,19 +3276,7 @@ static void gen_stwcx_(DisasContext *ctx)#if defined(TARGET_PPC64 )/* ldarx */ -static void gen_ldarx (DisasContext *ctx) -{ -TCGv t0; -TCGv gpr = cpu_gpr[rD (ctx->opcode)]; -gen_set_access_type (ctx,ACCESS_RES ); - t0 =tcg_temp_local_new (); -gen_addr_reg_index (ctx, t0); -gen_check_align (ctx, t0,0x07 ); -gen_qemu_ld64 (ctx, gpr, t0); -tcg_gen_mov_tl (cpu_reserve, t0); -tcg_gen_st_tl (gpr, cpu_env, offsetof(CPUPPCState , reserve_val)); -tcg_temp_free (t0); -} +LARX (ldarx,8 , ld64);/* stdcx. */ static void gen_stdcx_ (DisasContext *ctx)
@@ -9513,6 +9509,8 @@ GEN_HANDLER(stswi, 0x1F, 0x15, 0x16, 0x00000001, PPC_STRING),GEN_HANDLER (stswx,0x1F ,0x15 ,0x14 ,0x00000001 ,PPC_STRING ),GEN_HANDLER (eieio,0x1F ,0x16 ,0x1A ,0x03FFF801 ,PPC_MEM_EIEIO ),GEN_HANDLER (isync,0x13 ,0x16 ,0x04 ,0x03FFF801 ,PPC_MEM ), +GEN_HANDLER_E (lbarx,0x1F ,0x14 ,0x01 ,0 ,PPC_NONE ,PPC2_ATOMIC_ISA206 ), +GEN_HANDLER_E (lharx,0x1F ,0x14 ,0x03 ,0 ,PPC_NONE ,PPC2_ATOMIC_ISA206 ),GEN_HANDLER (lwarx,0x1F ,0x14 ,0x00 ,0x00000000 ,PPC_RES ),GEN_HANDLER2 (stwcx_,"stwcx." ,0x1F ,0x16 ,0x04 ,0x00000000 ,PPC_RES ), #if defined(TARGET_PPC64)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 062/130] target-ppc: Add ISA2.06 Float to Integer Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the four floating point to integer conversion instructions introduced by Power ISA V2.06:
- Floating Convert to Integer Word Unsigned (fctiwu)
- Floating Convert to Integer Word Unsigned with Round Toward Zero (fctiwuz)
- Floating Convert to Integer Doubleword Unsigned (fctidu)
- Floating Convert to Integer Doubleword Unsigned with Round Toward Zero (fctiduz)
A common macro is developed to eliminate repetitious code. Existing instructions are also refactoried to use this macro (fctiw, fctiwz, fctid, fctidz).
--- target-ppc/fpu_helper.c | 120 +++++++++++++----------------------------------- target-ppc/helper.h | 4 ++ target-ppc/translate.c | 12 +++++ 3 files changed, 49 insertions(+), 87 deletions(-)
target-ppc/fpu_helper.c +33 -87
@@ -600,55 +600,41 @@ uint64_t helper_fdiv(CPUPPCState *env, uint64_t arg1, uint64_t arg2)return farg1.ll; } -/* fctiw - fctiw. */ -uint64_t helper_fctiw (CPUPPCState *env,uint64_t arg) -{ -CPU_DoubleU farg; - - farg.ll = arg; - -if (unlikely (float64_is_signaling_nan (farg.d))) { -/* sNaN conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ,1 ); - }else if (unlikely (float64_is_quiet_nan (farg.d) || -float64_is_infinity (farg.d))) { -/* qNan / infinity conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); - }else { - farg.ll =float64_to_int32 (farg.d, &env->fp_status); -/* XXX: higher bits are not supposed to be significant. -* to make tests easier, return the same as a real PowerPC 750 -*/ - farg.ll |=0xFFF80000ULL <<32 ; - } -return farg.ll; -} - -/* fctiwz - fctiwz. */ -uint64_t helper_fctiwz (CPUPPCState *env,uint64_t arg) -{ -CPU_DoubleU farg; - farg.ll = arg; +#define FPU_FCTI (op, cvt, nanval) \ +uint64_t helper_##op(CPUPPCState *env, uint64_t arg) \ +{ \ + CPU_DoubleU farg; \ + \ + farg.ll = arg; \ + farg.ll = float64_to_##cvt(farg.d, &env->fp_status); \ + \ + if (unlikely(env->fp_status.float_exception_flags)) { \ + if (float64_is_any_nan(arg)) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI, 1); \ + if (float64_is_signaling_nan(arg)) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); \ + } \ + farg.ll = nanval; \ + } else if (env->fp_status.float_exception_flags & \ + float_flag_invalid) { \ + fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI, 1); \ + } \ + helper_float_check_status(env); \ + } \ + return farg.ll; \ + } -if (unlikely (float64_is_signaling_nan (farg.d))) { -/* sNaN conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ,1 ); - }else if (unlikely (float64_is_quiet_nan (farg.d) || -float64_is_infinity (farg.d))) { -/* qNan / infinity conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); - }else { - farg.ll =float64_to_int32_round_to_zero (farg.d, &env->fp_status); -/* XXX: higher bits are not supposed to be significant. -* to make tests easier, return the same as a real PowerPC 750 -*/ - farg.ll |=0xFFF80000ULL <<32 ; - } -return farg.ll; -} +FPU_FCTI(fctiw, int32, 0x80000000) +FPU_FCTI(fctiwz, int32_round_to_zero, 0x80000000) +FPU_FCTI(fctiwu, uint32, 0x00000000) +FPU_FCTI(fctiwuz, uint32_round_to_zero, 0x00000000) +#if defined(TARGET_PPC64 ) +FPU_FCTI(fctid, int64, 0x8000000000000000) +FPU_FCTI(fctidz, int64_round_to_zero, 0x8000000000000000) +FPU_FCTI(fctidu, uint64, 0x0000000000000000) +FPU_FCTI(fctiduz, uint64_round_to_zero, 0x0000000000000000) +#endif #if defined(TARGET_PPC64 )/* fcfid - fcfid. */
@@ -660,47 +646,7 @@ uint64_t helper_fcfid(CPUPPCState *env, uint64_t arg) return farg.ll; } -/* fctid - fctid. */ -uint64_t helper_fctid (CPUPPCState *env,uint64_t arg) -{ -CPU_DoubleU farg; - farg.ll = arg; - -if (unlikely (float64_is_signaling_nan (farg.d))) { -/* sNaN conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ,1 ); - }else if (unlikely (float64_is_quiet_nan (farg.d) || -float64_is_infinity (farg.d))) { -/* qNan / infinity conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); - }else { - farg.ll =float64_to_int64 (farg.d, &env->fp_status); - } -return farg.ll; -} - -/* fctidz - fctidz. */ -uint64_t helper_fctidz (CPUPPCState *env,uint64_t arg) -{ -CPU_DoubleU farg; - - farg.ll = arg; - -if (unlikely (float64_is_signaling_nan (farg.d))) { -/* sNaN conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXSNAN | -POWERPC_EXCP_FP_VXCVI ,1 ); - }else if (unlikely (float64_is_quiet_nan (farg.d) || -float64_is_infinity (farg.d))) { -/* qNan / infinity conversion */ - farg.ll =fload_invalid_op_excp (env,POWERPC_EXCP_FP_VXCVI ,1 ); - }else { - farg.ll =float64_to_int64_round_to_zero (farg.d, &env->fp_status); - } -return farg.ll; -}#endif
target-ppc/helper.h +4 -0
@@ -66,11 +66,15 @@ DEF_HELPER_4(fcmpo, void, env, i64, i64, i32) DEF_HELPER_4(fcmpu, void, env, i64, i64, i32) DEF_HELPER_2(fctiw, i64, env, i64) +DEF_HELPER_2(fctiwu, i64, env, i64) DEF_HELPER_2(fctiwz, i64, env, i64) +DEF_HELPER_2(fctiwuz, i64, env, i64)#if defined(TARGET_PPC64 ) DEF_HELPER_2(fcfid, i64, env, i64) DEF_HELPER_2(fctid, i64, env, i64) +DEF_HELPER_2(fctidu, i64, env, i64) DEF_HELPER_2(fctidz, i64, env, i64) +DEF_HELPER_2(fctiduz, i64, env, i64)#endif DEF_HELPER_2(frsp, i64, env, i64)DEF_HELPER_2 (frin, i64, env, i64)
target-ppc/translate.c +12 -0
@@ -2202,8 +2202,12 @@ GEN_FLOAT_ACB(nmsub, 0x1E, 1, PPC_FLOAT);/*** Floating-Point round & convert ***/ /* fctiw */ GEN_FLOAT_B (ctiw,0x0E ,0x00 ,0 ,PPC_FLOAT ); +/* fctiwu */ +GEN_FLOAT_B (ctiwu,0x0E ,0x04 ,0 ,PPC2_FP_CVT_ISA206 );/* fctiwz */ GEN_FLOAT_B (ctiwz,0x0F ,0x00 ,0 ,PPC_FLOAT ); +/* fctiwuz */ +GEN_FLOAT_B (ctiwuz,0x0F ,0x04 ,0 ,PPC2_FP_CVT_ISA206 );/* frsp */ GEN_FLOAT_B (rsp,0x0C ,0x00 ,1 ,PPC_FLOAT );#if defined(TARGET_PPC64 )
@@ -2211,8 +2215,12 @@ GEN_FLOAT_B(rsp, 0x0C, 0x00, 1, PPC_FLOAT);GEN_FLOAT_B (cfid,0x0E ,0x1A ,1 ,PPC_64B );/* fctid */ GEN_FLOAT_B (ctid,0x0E ,0x19 ,0 ,PPC_64B ); +/* fctidu */ +GEN_FLOAT_B (ctidu,0x0E ,0x1D ,0 ,PPC2_FP_CVT_ISA206 );/* fctidz */ GEN_FLOAT_B (ctidz,0x0F ,0x19 ,0 ,PPC_64B ); +/* fctidu */ +GEN_FLOAT_B (ctiduz,0x0F ,0x1D ,0 ,PPC2_FP_CVT_ISA206 );#endif /* frin */
@@ -9843,12 +9851,16 @@ GEN_FLOAT_ACB(msub, 0x1C, 1, PPC_FLOAT), GEN_FLOAT_ACB(nmadd, 0x1F, 1, PPC_FLOAT), GEN_FLOAT_ACB(nmsub, 0x1E, 1, PPC_FLOAT), GEN_FLOAT_B(ctiw, 0x0E, 0x00, 0, PPC_FLOAT), +GEN_HANDLER_E(fctiwu, 0x3F, 0x0E, 0x04, 0, PPC_NONE, PPC2_FP_CVT_ISA206), GEN_FLOAT_B(ctiwz, 0x0F, 0x00, 0, PPC_FLOAT), +GEN_HANDLER_E(fctiwuz, 0x3F, 0x0F, 0x04, 0, PPC_NONE, PPC2_FP_CVT_ISA206), GEN_FLOAT_B(rsp, 0x0C, 0x00, 1, PPC_FLOAT),#if defined(TARGET_PPC64 )GEN_FLOAT_B (cfid,0x0E ,0x1A ,1 ,PPC_64B ),GEN_FLOAT_B (ctid,0x0E ,0x19 ,0 ,PPC_64B ), +GEN_HANDLER_E (fctidu,0x3F ,0x0E ,0x1D ,0 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ),GEN_FLOAT_B (ctidz,0x0F ,0x19 ,0 ,PPC_64B ), +GEN_HANDLER_E (fctiduz,0x3F ,0x0F ,0x1D ,0 ,PPC_NONE ,PPC2_FP_CVT_ISA206 ), #endifGEN_FLOAT_B (rin,0x08 ,0x0C ,1 ,PPC_FLOAT_EXT ), GEN_FLOAT_B(riz, 0x08, 0x0D, 1, PPC_FLOAT_EXT),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 075/130] moxie: fix load_elf() usage
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
At the moment in the case of error, load_elf() returns -1 so load_kernel() will not signal error at all.
--- hw/moxie/moxiesim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/moxie/moxiesim.c +1 -1
@@ -55,7 +55,7 @@ static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params) &entry, &kernel_low, &kernel_high,1 , ELF_MACHINE, 0); -if (!kernel_size) { +if (kernel_size <=0 ) {fprintf (stderr,"qemu: could not load kernel '%s'\n" , loader_params->kernel_filename);exit (1 );
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 076/130] elf-loader: add more return codes
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
The existing load_elf() just returns -1 if it fails to load ELF. However it could be smarter than this and tell more about the failure such as wrong endianness or incompatible platform.
This adds additional return codes for wrong architecture, wrong endianness and if the image is not ELF at all.
This adds a load_elf_strerror() helper to convert return codes into string messages.
This fixes handling of what load_elf() returns for s390x, other callers just check the return value for <0 and this remains unchanged.
--- hw/core/loader.c | 30 ++++++++++++++++++++++++------ hw/s390x/ipl.c | 4 ++-- include/hw/elf_ops.h | 19 ++++++++++++++----- include/hw/loader.h | 6 ++++++ 4 files changed, 46 insertions(+), 13 deletions(-)
hw/core/loader.c +24 -6
@@ -284,12 +284,30 @@ static void *load_at(int fd, int offset, int size)#define SZ 64#include "hw/elf_ops.h" +const char *load_elf_strerror (int error) +{ +switch (error) { +case 0 : +return "No error" ; +case ELF_LOAD_FAILED : +return "Failed to load ELF" ; +case ELF_LOAD_NOT_ELF : +return "The image is not ELF" ; +case ELF_LOAD_WRONG_ARCH : +return "The image is from incompatible architecture" ; +case ELF_LOAD_WRONG_ENDIAN : +return "The image has incorrect endianness" ; +default : +return "Unknown error" ; + } +} +/* return < 0 if error, otherwise the number of bytes loaded in memory */ int load_elf (const char *filename,uint64_t (*translate_fn)(void *,uint64_t ),void *translate_opaque,uint64_t *pentry,uint64_t *lowaddr,uint64_t *highaddr,int big_endian,int elf_machine,int clear_lsb) { -int fd, data_order, target_data_order, must_swab, ret; +int fd, data_order, target_data_order, must_swab, ret =ELF_LOAD_FAILED ;uint8_t e_ident[EI_NIDENT ]; fd =open (filename,O_RDONLY |O_BINARY );
@@ -302,8 +320,10 @@ int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t),if (e_ident[0 ] !=ELFMAG0 || e_ident[1 ] !=ELFMAG1 || e_ident[2 ] !=ELFMAG2 || - e_ident[3 ] !=ELFMAG3 ) + e_ident[3 ] !=ELFMAG3 ) { + ret =ELF_LOAD_NOT_ELF ; goto fail; + }#ifdef HOST_WORDS_BIGENDIAN data_order =ELFDATA2MSB ;#else
@@ -317,6 +337,7 @@ int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t), }if (target_data_order != e_ident[EI_DATA ]) { + ret =ELF_LOAD_WRONG_ENDIAN ; goto fail; }
@@ -329,12 +350,9 @@ int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t), pentry, lowaddr, highaddr, elf_machine, clear_lsb); } -close (fd); -return ret; - fail:close (fd); -return -1 ; +return ret; }static void bswap_uboot_header (uboot_image_header_t *hdr)
hw/s390x/ipl.c +2 -2
@@ -98,10 +98,10 @@ static int s390_ipl_init(SysBusDevice *dev)uint64_t pentry =KERN_IMAGE_START ; kernel_size =load_elf (ipl->kernel,NULL ,NULL , &pentry,NULL ,NULL ,1 ,ELF_MACHINE ,0 ); -if (kernel_size ==-1 ) { +if (kernel_size <0 ) { kernel_size =load_image_targphys (ipl->kernel,0 , ram_size); } -if (kernel_size ==-1 ) { +if (kernel_size <0 ) {fprintf (stderr,"could not load kernel '%s'\n" , ipl->kernel);return -1 ; }
include/hw/elf_ops.h +14 -5
@@ -201,6 +201,7 @@ static int glue(load_elf, SZ)(const char *name, int fd,uint64_t addr, low = (uint64_t )-1 , high =0 ;uint8_t *data =NULL ;char label[128 ]; +int ret =ELF_LOAD_FAILED ;if (read (fd, &ehdr,sizeof (ehdr)) !=sizeof (ehdr)) goto fail;
@@ -211,22 +212,30 @@ static int glue(load_elf, SZ)(const char *name, int fd,switch (elf_machine) {case EM_PPC64 :if (EM_PPC64 != ehdr.e_machine) -if (EM_PPC != ehdr.e_machine) +if (EM_PPC != ehdr.e_machine) { + ret =ELF_LOAD_WRONG_ARCH ; goto fail; + }break ;case EM_X86_64 :if (EM_X86_64 != ehdr.e_machine) -if (EM_386 != ehdr.e_machine) +if (EM_386 != ehdr.e_machine) { + ret =ELF_LOAD_WRONG_ARCH ; goto fail; + }break ;case EM_MICROBLAZE :if (EM_MICROBLAZE != ehdr.e_machine) -if (EM_MICROBLAZE_OLD != ehdr.e_machine) +if (EM_MICROBLAZE_OLD != ehdr.e_machine) { + ret =ELF_LOAD_WRONG_ARCH ; goto fail; + }break ;default : -if (elf_machine != ehdr.e_machine) +if (elf_machine != ehdr.e_machine) { + ret =ELF_LOAD_WRONG_ARCH ; goto fail; + } }if (pentry)
@@ -305,5 +314,5 @@ static int glue(load_elf, SZ)(const char *name, int fd, fail:g_free (data);g_free (phdr); -return -1 ; +return ret; }
include/hw/loader.h +6 -0
@@ -15,6 +15,12 @@ int get_image_size(const char *filename);int load_image (const char *filename,uint8_t *addr);/* deprecated */ int load_image_targphys (const char *filename,hwaddr ,uint64_t max_sz); + +#define ELF_LOAD_FAILED -1 +#define ELF_LOAD_NOT_ELF -2 +#define ELF_LOAD_WRONG_ARCH -3 +#define ELF_LOAD_WRONG_ENDIAN -4 +const char *load_elf_strerror (int error); int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr, int big_endian, int elf_machine,
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 080/130] target-ppc: add extended opcodes for dcbt/dcbtst
In reply to Alexander GrafFrom: Cédric Le Goater <[email protected]>
The latest glibc provides a memrchr routine using an extended opcode of the 'dcbt' instruction :
00000000000a7cc0 <memrchr>:
a7cc0: 11 00 4c 3c addis r2,r12,17 a7cc4: b8 f8 42 38 addi r2,r2,-1864 a7cc8: 14 2a e3 7c add r7,r3,r5 a7ccc: d0 00 07 7c neg r0,r7 a7cd0: ff ff e7 38 addi r7,r7,-1 a7cd4: 78 1b 6a 7c mr r10,r3 a7cd8: 24 06 e6 78 rldicr r6,r7,0,56 a7cdc: 60 00 20 39 li r9,96 a7ce0: 2c 32 09 7e dcbtt r9,r6
....
which breaks grep, and other commands, in TCG mode :
invalid bits: 02000000 for opcode: 1f - 16 - 08 (7e09322c) 00003fff799feca0
This patch adds the extended opcodes for dcbt/dcbtst as no-ops just like the 'dcbt' instruction.
--- target-ppc/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target-ppc/translate.c +2 -2
@@ -9596,8 +9596,8 @@ GEN_HANDLER(mtspr, 0x1F, 0x13, 0x0E, 0x00000001, PPC_MISC),GEN_HANDLER (dcbf,0x1F ,0x16 ,0x02 ,0x03C00001 ,PPC_CACHE ),GEN_HANDLER (dcbi,0x1F ,0x16 ,0x0E ,0x03E00001 ,PPC_CACHE ),GEN_HANDLER (dcbst,0x1F ,0x16 ,0x01 ,0x03E00001 ,PPC_CACHE ), -GEN_HANDLER (dcbt,0x1F ,0x16 ,0x08 ,0x02000001 ,PPC_CACHE ), -GEN_HANDLER (dcbtst,0x1F ,0x16 ,0x07 ,0x02000001 ,PPC_CACHE ), +GEN_HANDLER (dcbt,0x1F ,0x16 ,0x08 ,0x00000001 ,PPC_CACHE ), +GEN_HANDLER (dcbtst,0x1F ,0x16 ,0x07 ,0x00000001 ,PPC_CACHE ),GEN_HANDLER (dcbz,0x1F ,0x16 ,0x1F ,0x03C00001 ,PPC_CACHE_DCBZ ),GEN_HANDLER (dst,0x1F ,0x16 ,0x0A ,0x01800001 ,PPC_ALTIVEC ), GEN_HANDLER(dstst, 0x1F, 0x16, 0x0B, 0x02000001, PPC_ALTIVEC),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 081/130] target-ppc: Fix xxpermdi When T==A or T==B
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
The existing implementation of xxpermdi is defective if the target VSR is also a source VSR. This patch fixes the defect in this case but also preserves the simpler, two TCG operation implementation when the target is not once of the two sources.
--- target-ppc/translate.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-)
target-ppc/translate.c +33 -8
@@ -7332,15 +7332,40 @@ static void gen_xxpermdi(DisasContext *ctx)return ; } -if ((DM (ctx->opcode) &2 ) ==0 ) { -tcg_gen_mov_i64 (cpu_vsrh (xT (ctx->opcode)),cpu_vsrh (xA (ctx->opcode))); - }else { -tcg_gen_mov_i64 (cpu_vsrh (xT (ctx->opcode)),cpu_vsrl (xA (ctx->opcode))); - } -if ((DM (ctx->opcode) &1 ) ==0 ) { -tcg_gen_mov_i64 (cpu_vsrl (xT (ctx->opcode)),cpu_vsrh (xB (ctx->opcode))); +if (unlikely ((xT (ctx->opcode) ==xA (ctx->opcode)) || + (xT (ctx->opcode) ==xB (ctx->opcode)))) { +TCGv_i64 xh, xl; + + xh =tcg_temp_new_i64 (); + xl =tcg_temp_new_i64 (); + +if ((DM (ctx->opcode) &2 ) ==0 ) { +tcg_gen_mov_i64 (xh,cpu_vsrh (xA (ctx->opcode))); + }else { +tcg_gen_mov_i64 (xh,cpu_vsrl (xA (ctx->opcode))); + } +if ((DM (ctx->opcode) &1 ) ==0 ) { +tcg_gen_mov_i64 (xl,cpu_vsrh (xB (ctx->opcode))); + }else { +tcg_gen_mov_i64 (xl,cpu_vsrl (xB (ctx->opcode))); + } + +tcg_gen_mov_i64 (cpu_vsrh (xT (ctx->opcode)), xh); +tcg_gen_mov_i64 (cpu_vsrl (xT (ctx->opcode)), xl); + +tcg_temp_free_i64 (xh); +tcg_temp_free_i64 (xl); }else { -tcg_gen_mov_i64 (cpu_vsrl (xT (ctx->opcode)),cpu_vsrl (xB (ctx->opcode))); +if ((DM (ctx->opcode) &2 ) ==0 ) { +tcg_gen_mov_i64 (cpu_vsrh (xT (ctx->opcode)),cpu_vsrh (xA (ctx->opcode))); + }else { +tcg_gen_mov_i64 (cpu_vsrh (xT (ctx->opcode)),cpu_vsrl (xA (ctx->opcode))); + } +if ((DM (ctx->opcode) &1 ) ==0 ) { +tcg_gen_mov_i64 (cpu_vsrl (xT (ctx->opcode)),cpu_vsrh (xB (ctx->opcode))); + }else { +tcg_gen_mov_i64 (cpu_vsrl (xT (ctx->opcode)),cpu_vsrl (xB (ctx->opcode))); + } } }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 078/130] target-ppc: Update external_htab even when HTAB is managed by kernel
In reply to Alexander GrafFrom: "Aneesh Kumar K.V" <[email protected]>
We will use this in later patches to make sure we use the right load functions when copying hpte entries.
--- hw/ppc/spapr.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/ppc/spapr.c +7 -0
@@ -741,6 +741,13 @@ static void spapr_cpu_reset(void *opaque) env->spr[SPR_HIOR ] =0 ; env->external_htab = (uint8_t *)spapr->htab; +if (kvm_enabled () && !env->external_htab) { +/* +* HV KVM, set external_htab to 1 so our ppc_hash64_load_hpte* +* functions do the right thing. +*/ + env->external_htab = (void *)1 ; + } env->htab_base =-1 ; env->htab_mask =HTAB_SIZE (spapr) -1 ; env->spr[SPR_SDR1] = (target_ulong)(uintptr_t)spapr->htab |
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 079/130] qdev: Keep global allocation counter per bus
In reply to Alexander GrafWhen we have 2 separate qdev devices that both create a qbus of the same type without specifying a bus name or device name, we end up with two buses of the same name, such as ide.0 on the Mac machines:
dev: macio-ide, id ""
bus: ide.0
type IDE
dev: macio-ide, id ""
bus: ide.0
type IDEIf we now spawn a device that connects to a ide.0 the last created bus gets the device, with the first created bus inaccessible to the command line.
After some discussion on IRC we concluded that the best quick fix way forward for this is to make automated bus-class type based allocation count a global counter. That's what this patch implements. With this we instead get
dev: macio-ide, id ""
bus: ide.1
type IDE
dev: macio-ide, id ""
bus: ide.0
type IDEon the example mentioned above.
This also means that if you did -device ...,bus=ide.0 you got a device on the first bus (the last created one) before this patch and get that device on the second one (the first created one) now. Breaks migration unless you change bus=ide.0 to bus=ide.1 on the destination.
This is intended and makes the bus enumeration work as expected.
As per review request follows a list of otherwise affected boards and the reasoning for the conclusion that they are ok:
target machine bus id times ------ ------- ------ -----
aarch64 n800 i2c-bus.0 2 aarch64 n810 i2c-bus.0 2 arm n800 i2c-bus.0 2 arm n810 i2c-bus.0 2
-> Devices are only created explicitly on one of the two buses, using
s->mpu->i2c[0], so no change to the guest.
aarch64 vexpress-a15 virtio-mmio-bus.0 4 aarch64 vexpress-a9 virtio-mmio-bus.0 4 aarch64 virt virtio-mmio-bus.0 32 arm vexpress-a15 virtio-mmio-bus.0 4 arm vexpress-a9 virtio-mmio-bus.0 4 arm virt virtio-mmio-bus.0 32
-> Makes -device bus= work for all virtio-mmio buses. Breaks
migration. Workaround for migration from old to new: specify virtio-mmio-bus.4 or .32 respectively rather than .0 on the destination.
aarch64 xilinx-zynq-a9 usb-bus.0 2 arm xilinx-zynq-a9 usb-bus.0 2 mips64el fulong2e usb-bus.0 2
-> Normal USB operation not affected. Migration driver needs command
line to use the other bus.
i386 isapc ide.0 2 x86_64 isapc ide.0 2 mips mips ide.0 2 mips64 mips ide.0 2 mips64el mips ide.0 2 mipsel mips ide.0 2 ppc g3beige ide.0 2 ppc mac99 ide.0 2 ppc prep ide.0 2 ppc64 g3beige ide.0 2 ppc64 mac99 ide.0 2 ppc64 prep ide.0 2
-> Makes -device bus= work for all IDE buses. Breaks migration.
Workaround for migration from old to new: specify ide.1 rather than ide.0 on the destination.
--- hw/core/qdev.c | 20 +++++++++++++------- hw/i386/pc_piix.c | 8 +++++++- include/hw/qdev-core.h | 2 ++ 3 files changed, 22 insertions(+), 8 deletions(-)
hw/core/qdev.c +13 -7
@@ -440,27 +440,33 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id)static void qbus_realize (BusState *bus,DeviceState *parent,const char *name) {const char *typename =object_get_typename (OBJECT (bus)); +BusClass *bc;char *buf; -int i,len; +int i, len, bus_id; bus->parent = parent;if (name) { bus->name =g_strdup (name); }else if (bus->parent && bus->parent->id) { -/* parent device has id -> use it for bus name */ +/* parent device has id -> use it plus parent-bus-id for bus name */ + bus_id = bus->parent->num_child_bus; + len =strlen (bus->parent->id) +16 ; buf =g_malloc (len); -snprintf (buf, len,"%s.%d" , bus->parent->id, bus->parent->num_child_bus); +snprintf (buf, len,"%s.%d" , bus->parent->id, bus_id); bus->name = buf; }else { -/* no id -> use lowercase bus type for bus name */ +/* no id -> use lowercase bus type plus global bus-id for bus name */ + bc =BUS_GET_CLASS (bus); + bus_id = bc->automatic_ids++; + len =strlen (typename) +16 ; buf =g_malloc (len); - len =snprintf (buf, len,"%s.%d" , typename, - bus->parent ? bus->parent->num_child_bus :0 ); -for (i =0 ; i < len; i++) + len =snprintf (buf, len,"%s.%d" , typename, bus_id); +for (i =0 ; i < len; i++) { buf[i] =qemu_tolower (buf[i]); + } bus->name = buf; }
hw/i386/pc_piix.c +7 -1
@@ -221,10 +221,16 @@ static void pc_init1(QEMUMachineInitArgs *args, }else {for (i =0 ; i <MAX_IDE_BUS ; i++) {ISADevice *dev; +char busname[] ="ide.0" ; dev =isa_ide_init (isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i +1 ]); - idebus[i] =qdev_get_child_bus (DEVICE (dev),"ide.0" ); +/* +* The ide bus name is ide.0 for the first bus and ide.1 for the +* second one. +*/ + busname[4 ] ='0' + i; + idebus[i] =qdev_get_child_bus (DEVICE (dev), busname); } }
include/hw/qdev-core.h +2 -0
@@ -176,6 +176,8 @@ struct BusClass {void (*reset)(BusState *bus);/* maximum devices allowed on the bus, 0: no limit. */ int max_dev; +/* number of automatically allocated bus ids (e.g. ide.0) */ +int automatic_ids; }; typedef struct BusChild {
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 082/130] target-ppc: Add Flag for bctar
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a flag for the bctar instruction. This instruction is being introduced via Power ISA 2.07.
Also, the flag is added to the Power8 machine model since the P8 processor supports this instruction.
--- target-ppc/cpu.h | 6 ++++-- target-ppc/translate_init.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)
target-ppc/cpu.h +4 -2
@@ -1887,12 +1887,14 @@ enum {PPC2_FP_CVT_ISA206 =0x0000000000000400ULL ,/* ISA 2.06B floating point test instructions */ PPC2_FP_TST_ISA206 =0x0000000000000800ULL , - +/* ISA 2.07 bctar instruction */ +PPC2_BCTAR_ISA207 =0x0000000000001000ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \PPC2_ISA205 |PPC2_VSX207 |PPC2_PERM_ISA206 | \PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 | \ - PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206) +PPC2_FP_CVT_ISA206 |PPC2_FP_TST_ISA206 | \ + PPC2_BCTAR_ISA207) };/*****************************************************************************/
target-ppc/translate_init.c +1 -1
@@ -7159,7 +7159,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 | -PPC2_FP_TST_ISA206 ; +PPC2_FP_TST_ISA206 |PPC2_BCTAR_ISA207 ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 083/130] target-ppc: Add Target Address SPR (TAR) to Power8
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds support for the Target Address Register (TAR) to the Power8 model.
Because supported SPRs are typically identified in an init_proc_*() function and because the Power8 model is currently just using the init_proc_POWER7() function, a new init_proc_POWER8() function is added and plugged into the P8 model.
--- target-ppc/cpu.h | 1 + target-ppc/translate_init.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
target-ppc/cpu.h +1 -0
@@ -1508,6 +1508,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)#define SPR_RCPU_L2U_RA2 (0x32A)#define SPR_MPC_MD_DBRAM1 (0x32A)#define SPR_RCPU_L2U_RA3 (0x32B) +#define SPR_TAR (0x32F)#define SPR_440_INV0 (0x370)#define SPR_440_INV1 (0x371)#define SPR_440_INV2 (0x372)
target-ppc/translate_init.c +13 -1
@@ -7133,6 +7133,18 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data) pcc->l1_icache_size =0x8000 ; } +static void init_proc_POWER8 (CPUPPCState *env) +{ +/* inherit P7 */ +init_proc_POWER7 (env); + +/* P8 supports the TAR */ +spr_register (env,SPR_TAR ,"TAR" , + &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic, +0x00000000 ); +} +POWERPC_FAMILY (POWER8 )(ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);
@@ -7142,7 +7154,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) dc->desc ="POWER8" ; pcc->pvr =CPU_POWERPC_POWER8_BASE ; pcc->pvr_mask =CPU_POWERPC_POWER8_MASK ; - pcc->init_proc = init_proc_POWER7; + pcc->init_proc = init_proc_POWER8; pcc->check_pow = check_pow_nocheck; pcc->insns_flags =PPC_INSNS_BASE |PPC_STRING |PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 084/130] target-ppc: Add bctar Instruction
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Branch Conditional to Address Register (bctar) instruction.
--- target-ppc/translate.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
target-ppc/translate.c +10 -1
@@ -3745,6 +3745,7 @@ static void gen_b(DisasContext *ctx)#define BCOND_IM 0#define BCOND_LR 1#define BCOND_CTR 2 +#define BCOND_TAR 3static inline void gen_bcond (DisasContext *ctx,int type) {
@@ -3753,10 +3754,12 @@ static inline void gen_bcond(DisasContext *ctx, int type)TCGv target; ctx->exception =POWERPC_EXCP_BRANCH ; -if (type ==BCOND_LR || type ==BCOND_CTR ) { +if (type ==BCOND_LR || type ==BCOND_CTR || type ==BCOND_TAR ) { target =tcg_temp_local_new ();if (type ==BCOND_CTR )tcg_gen_mov_tl (target, cpu_ctr); +else if (type ==BCOND_TAR ) +gen_load_spr (target,SPR_TAR );else tcg_gen_mov_tl (target, cpu_lr); }else {
@@ -3838,6 +3841,11 @@ static void gen_bclr(DisasContext *ctx)gen_bcond (ctx,BCOND_LR ); } +static void gen_bctar (DisasContext *ctx) +{ +gen_bcond (ctx,BCOND_TAR ); +} +/*** Condition register logical ***/ #define GEN_CRLOGIC (name, tcg_op, opc) \ static void glue(gen_, name)(DisasContext *ctx) \
@@ -9594,6 +9602,7 @@ GEN_HANDLER(b, 0x12, 0xFF, 0xFF, 0x00000000, PPC_FLOW),GEN_HANDLER (bc,0x10 ,0xFF ,0xFF ,0x00000000 ,PPC_FLOW ),GEN_HANDLER (bcctr,0x13 ,0x10 ,0x10 ,0x00000000 ,PPC_FLOW ),GEN_HANDLER (bclr,0x13 ,0x10 ,0x00 ,0x00000000 ,PPC_FLOW ), +GEN_HANDLER_E (bctar,0x13 ,0x10 ,0x11 ,0 ,PPC_NONE ,PPC2_BCTAR_ISA207 ),GEN_HANDLER (mcrf,0x13 ,0x00 ,0xFF ,0x00000001 ,PPC_INTEGER ),GEN_HANDLER (rfi,0x13 ,0x12 ,0x01 ,0x03FF8001 ,PPC_FLOW ), #if defined(TARGET_PPC64)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 085/130] target-ppc: Add Flag for ISA 2.07 Load/Store Quadword Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a flag to identify the load/store quadword instructions that are introduced with Power ISA 2.07.
The flag is added to the Power8 model since P8 supports these instructions.
--- target-ppc/cpu.h | 4 +++- target-ppc/translate_init.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-)
target-ppc/cpu.h +3 -1
@@ -1890,12 +1890,14 @@ enum {PPC2_FP_TST_ISA206 =0x0000000000000800ULL ,/* ISA 2.07 bctar instruction */ PPC2_BCTAR_ISA207 =0x0000000000001000ULL , +/* ISA 2.07 load/store quadword */ +PPC2_LSQ_ISA207 =0x0000000000002000ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \PPC2_ISA205 |PPC2_VSX207 |PPC2_PERM_ISA206 | \PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 | \PPC2_FP_CVT_ISA206 |PPC2_FP_TST_ISA206 | \ - PPC2_BCTAR_ISA207) + PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207) };/*****************************************************************************/
target-ppc/translate_init.c +2 -1
@@ -7171,7 +7171,8 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) pcc->insns_flags2 =PPC2_VSX |PPC2_VSX207 |PPC2_DFP |PPC2_DBRX |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 | -PPC2_FP_TST_ISA206 |PPC2_BCTAR_ISA207 ; +PPC2_FP_TST_ISA206 |PPC2_BCTAR_ISA207 | +PPC2_LSQ_ISA207 ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 086/130] target-ppc: Add is_user_mode Utility Routine
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a boolean function is_user_mode that can be re-used in translation code that is sensitive to the MSR[PR] (user-mode) state.
--- target-ppc/translate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
target-ppc/translate.c +14 -0
@@ -622,6 +622,20 @@ static opc_handler_t invalid_handler = { .handler = gen_invalid, }; +#if defined(TARGET_PPC64 ) +/* NOTE: as this time, the only use of is_user_mode() is in 64 bit code. And */ +/* so the function is wrapped in the standard 64-bit ifdef in order to */ +/* avoid compiler warnings in 32-bit implementations. */ +static bool is_user_mode (DisasContext *ctx) +{ +#if defined(CONFIG_USER_ONLY ) +return true; +#else +return ctx->mem_idx ==0 ; +#endif +} +#endif +/*** Integer comparison ***/ static inline void gen_op_cmp (TCGv arg0,TCGv arg1,int s,int crf)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 073/130] Add Enhanced Three-Speed Ethernet Controller (eTSEC)
In reply to Alexander GrafFrom: Fabien Chouteau <[email protected]>
This implementation doesn't include ring priority, TCP/IP Off-Load, QoS.
--- default-configs/ppc-softmmu.mak | 1 + hw/net/Makefile.objs | 3 + hw/net/fsl_etsec/etsec.c | 465 ++++++++++++++++++++++++++++ hw/net/fsl_etsec/etsec.h | 174 +++++++++++ hw/net/fsl_etsec/miim.c | 146 +++++++++ hw/net/fsl_etsec/registers.c | 295 ++++++++++++++++++ hw/net/fsl_etsec/registers.h | 320 ++++++++++++++++++++ hw/net/fsl_etsec/rings.c | 650 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 2054 insertions(+) create mode 100644 hw/net/fsl_etsec/etsec.c create mode 100644 hw/net/fsl_etsec/etsec.h create mode 100644 hw/net/fsl_etsec/miim.c create mode 100644 hw/net/fsl_etsec/registers.c create mode 100644 hw/net/fsl_etsec/registers.h create mode 100644 hw/net/fsl_etsec/rings.c
default-configs/ppc-softmmu.mak +1 -0
@@ -47,4 +47,5 @@ CONFIG_E500=y CONFIG_OPENPIC_KVM=$(and $(CONFIG_E500),$(CONFIG_KVM)) # For PReP CONFIG_MC146818RTC=y +CONFIG_ETSEC=y CONFIG_ISA_TESTDEV=y
hw/net/Makefile.objs +3 -0
@@ -32,3 +32,6 @@ obj-$(CONFIG_XILINX_ETHLITE) += xilinx_ethlite.o obj-$(CONFIG_VIRTIO) += virtio-net.o obj-y += vhost_net.o + +obj-$(CONFIG_ETSEC) += fsl_etsec/etsec.o fsl_etsec/registers.o \ + fsl_etsec/rings.o fsl_etsec/miim.o
hw/net/fsl_etsec/etsec.c new file +465 -0
465 lines not on this page · raw message
hw/net/fsl_etsec/etsec.h new file +174 -0
174 lines not on this page · raw message
hw/net/fsl_etsec/miim.c new file +146 -0
146 lines not on this page · raw message
hw/net/fsl_etsec/registers.c new file +295 -0
295 lines not on this page · raw message
hw/net/fsl_etsec/registers.h new file +320 -0
320 lines not on this page · raw message
hw/net/fsl_etsec/rings.c new file +650 -0
650 lines not on this page · raw message
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 087/130] target-ppc: Load Quadword
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Book I (user space) Load Quadword (lq) instruction. This instruction was introduced into Book I in Power ISA V2.07. Previous versions of the architecture supported this as a privileged instruction. Previous versions of the architecture also did not support Little Endian mode.
Note that this patch also adds the PPC_64BX flag to the Power8 model, which enables the lq instruction.
--- target-ppc/translate.c | 36 ++++++++++++++++++++++-------------- target-ppc/translate_init.c | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-)
target-ppc/translate.c +22 -14
@@ -2872,36 +2872,44 @@ static void gen_ld(DisasContext *ctx)/* lq */ static void gen_lq (DisasContext *ctx) { -#if defined(CONFIG_USER_ONLY ) -gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC ); -#else int ra, rd;TCGv EA ; -/* Restore CPU state */ -if (unlikely (ctx->mem_idx ==0 )) { +/* lq is a legal user mode instruction starting in ISA 2.07 */ +bool legal_in_user_mode = (ctx->insns_flags2 &PPC2_LSQ_ISA207 ) !=0 ; +bool le_is_supported = (ctx->insns_flags2 &PPC2_LSQ_ISA207 ) !=0 ; + +if (!legal_in_user_mode &&is_user_mode (ctx)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; } + +if (!le_is_supported && ctx->le_mode) { +gen_exception_err (ctx,POWERPC_EXCP_ALIGN ,POWERPC_EXCP_ALIGN_LE ); +return ; + } + ra =rA (ctx->opcode); rd =rD (ctx->opcode);if (unlikely ((rd &1 ) || rd == ra)) {gen_inval_exception (ctx,POWERPC_EXCP_INVAL_INVAL );return ; } -if (unlikely (ctx->le_mode)) { -/* Little-endian mode is not handled */ -gen_exception_err (ctx,POWERPC_EXCP_ALIGN ,POWERPC_EXCP_ALIGN_LE ); -return ; - } +gen_set_access_type (ctx,ACCESS_INT );EA =tcg_temp_new ();gen_addr_imm_index (ctx,EA ,0x0F ); -gen_qemu_ld64 (ctx, cpu_gpr[rd],EA ); -gen_addr_add (ctx,EA ,EA ,8 ); -gen_qemu_ld64 (ctx, cpu_gpr[rd+1 ],EA ); + +if (unlikely (ctx->le_mode)) { +gen_qemu_ld64 (ctx, cpu_gpr[rd+1 ],EA ); +gen_addr_add (ctx,EA ,EA ,8 ); +gen_qemu_ld64 (ctx, cpu_gpr[rd],EA ); + }else { +gen_qemu_ld64 (ctx, cpu_gpr[rd],EA ); +gen_addr_add (ctx,EA ,EA ,8 ); +gen_qemu_ld64 (ctx, cpu_gpr[rd+1 ],EA ); + }tcg_temp_free (EA ); -#endif }#endif
target-ppc/translate_init.c +1 -1
@@ -7165,7 +7165,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC_CACHE |PPC_CACHE_ICBI |PPC_CACHE_DCBZ |PPC_MEM_SYNC |PPC_MEM_EIEIO |PPC_MEM_TLBIE |PPC_MEM_TLBSYNC | -PPC_64B |PPC_ALTIVEC | +PPC_64B |PPC_64BX |PPC_ALTIVEC |PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX |
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 088/130] target-ppc: Store Quadword
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds support for the Store Quadword instruction in user mode. Prior to Power ISA 2.07, stq was legal only in privileged mode. Support for Little Endian mode is also new in ISA 2.07.
--- target-ppc/translate.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
target-ppc/translate.c +23 -16
@@ -2995,34 +2995,41 @@ static void gen_std(DisasContext *ctx)TCGv EA ; rs =rS (ctx->opcode); -if ((ctx->opcode &0x3 ) ==0x2 ) { -#if defined(CONFIG_USER_ONLY ) -gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC ); -#else -/* stq */ -if (unlikely (ctx->mem_idx ==0 )) { +if ((ctx->opcode &0x3 ) ==0x2 ) {/* stq */ + +bool legal_in_user_mode = (ctx->insns_flags2 &PPC2_LSQ_ISA207 ) !=0 ; +bool le_is_supported = (ctx->insns_flags2 &PPC2_LSQ_ISA207 ) !=0 ; + +if (!legal_in_user_mode &&is_user_mode (ctx)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; } -if (unlikely (rs &1 )) { -gen_inval_exception (ctx,POWERPC_EXCP_INVAL_INVAL ); + +if (!le_is_supported && ctx->le_mode) { +gen_exception_err (ctx,POWERPC_EXCP_ALIGN ,POWERPC_EXCP_ALIGN_LE );return ; } -if (unlikely (ctx->le_mode)) { -/* Little-endian mode is not handled */ -gen_exception_err (ctx,POWERPC_EXCP_ALIGN ,POWERPC_EXCP_ALIGN_LE ); + +if (unlikely (rs &1 )) { +gen_inval_exception (ctx,POWERPC_EXCP_INVAL_INVAL );return ; }gen_set_access_type (ctx,ACCESS_INT );EA =tcg_temp_new ();gen_addr_imm_index (ctx,EA ,0x03 ); -gen_qemu_st64 (ctx, cpu_gpr[rs],EA ); -gen_addr_add (ctx,EA ,EA ,8 ); -gen_qemu_st64 (ctx, cpu_gpr[rs+1 ],EA ); + +if (unlikely (ctx->le_mode)) { +gen_qemu_st64 (ctx, cpu_gpr[rs+1 ],EA ); +gen_addr_add (ctx,EA ,EA ,8 ); +gen_qemu_st64 (ctx, cpu_gpr[rs],EA ); + }else { +gen_qemu_st64 (ctx, cpu_gpr[rs],EA ); +gen_addr_add (ctx,EA ,EA ,8 ); +gen_qemu_st64 (ctx, cpu_gpr[rs+1 ],EA ); + }tcg_temp_free (EA ); -#endif }else { -/* std / stdu */ +/* std / stdu*/ if (Rc (ctx->opcode)) {if (unlikely (rA (ctx->opcode) ==0 )) {gen_inval_exception (ctx,POWERPC_EXCP_INVAL_INVAL );
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 089/130] target-ppc: Add Load Quadword and Reserve
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Load Quadword and Reserve (lqarx) instruction, which is new in Power ISA 2.07.
--- target-ppc/cpu.h | 1 + target-ppc/translate.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
target-ppc/cpu.h +1 -0
@@ -926,6 +926,7 @@ struct CPUPPCState {target_ulong reserve_addr;/* Reservation value */ target_ulong reserve_val; +target_ulong reserve_val2;/* Reservation store address */ target_ulong reserve_ea;/* Reserved store source register and size */
target-ppc/translate.c +37 -0
@@ -3359,6 +3359,42 @@ STCX(stwcx_, 4);/* ldarx */ LARX (ldarx,8 , ld64); +/* lqarx */ +static void gen_lqarx (DisasContext *ctx) +{ +TCGv EA ; +int rd =rD (ctx->opcode); +TCGv gpr1, gpr2; + +if (unlikely ((rd &1 ) || (rd ==rA (ctx->opcode)) || + (rd ==rB (ctx->opcode)))) { +gen_inval_exception (ctx,POWERPC_EXCP_INVAL_INVAL ); +return ; + } + +gen_set_access_type (ctx,ACCESS_RES ); +EA =tcg_temp_local_new (); +gen_addr_reg_index (ctx,EA ); +gen_check_align (ctx,EA ,15 ); +if (unlikely (ctx->le_mode)) { + gpr1 = cpu_gpr[rd+1 ]; + gpr2 = cpu_gpr[rd]; + }else { + gpr1 = cpu_gpr[rd]; + gpr2 = cpu_gpr[rd+1 ]; + } +gen_qemu_ld64 (ctx, gpr1,EA ); +tcg_gen_mov_tl (cpu_reserve,EA ); + +gen_addr_add (ctx,EA ,EA ,8 ); +gen_qemu_ld64 (ctx, gpr2,EA ); + +tcg_gen_st_tl (gpr1, cpu_env, offsetof(CPUPPCState , reserve_val)); +tcg_gen_st_tl (gpr2, cpu_env, offsetof(CPUPPCState , reserve_val2)); + +tcg_temp_free (EA ); +} +/* stdcx. */ STCX (stdcx_,8 );#endif /* defined(TARGET_PPC64) */
@@ -9623,6 +9659,7 @@ GEN_HANDLER_E(sthcx_, 0x1F, 0x16, 0x16, 0, PPC_NONE, PPC2_ATOMIC_ISA206), GEN_HANDLER2(stwcx_, "stwcx.", 0x1F, 0x16, 0x04, 0x00000000, PPC_RES),#if defined(TARGET_PPC64 )GEN_HANDLER (ldarx,0x1F ,0x14 ,0x02 ,0x00000000 ,PPC_64B ), +GEN_HANDLER_E (lqarx,0x1F ,0x14 ,0x08 ,0 ,PPC_NONE ,PPC2_LSQ_ISA207 ),GEN_HANDLER2 (stdcx_,"stdcx." ,0x1F ,0x16 ,0x06 ,0x00000000 ,PPC_64B ), #endif GEN_HANDLER(sync, 0x1F, 0x16, 0x12, 0x039FF801, PPC_MEM_SYNC),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 090/130] target-ppc: Add Store Quadword Conditional
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Store Quadword Conditionl (stqcx.) instruction which is introduced in Power ISA 2.07.
--- linux-user/main.c | 18 +++++++++++++++++- target-ppc/translate.c | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-)
linux-user/main.c +17 -1
@@ -1492,7 +1492,7 @@ static int do_store_exclusive(CPUPPCState *env) {target_ulong addr;target_ulong page_addr; -target_ulong val; + target_ulong val, val2 __attribute__((unused));int flags;int segv =0 ;
@@ -1515,6 +1515,13 @@ static int do_store_exclusive(CPUPPCState *env)case 4 : segv =get_user_u32 (val, addr);break ;#if defined(TARGET_PPC64 )case 8 : segv =get_user_u64 (val, addr);break ; +case 16 : { + segv =get_user_u64 (val, addr); +if (!segv) { + segv =get_user_u64 (val2, addr +8 ); + } +break ; + }#endif default :abort (); }
@@ -1526,6 +1533,15 @@ static int do_store_exclusive(CPUPPCState *env)case 4 : segv =put_user_u32 (val, addr);break ;#if defined(TARGET_PPC64 )case 8 : segv =put_user_u64 (val, addr);break ; +case 16 : { +if (val2 == env->reserve_val2) { + segv =put_user_u64 (val, addr); +if (!segv) { + segv =put_user_u64 (val2, addr +8 ); + } + } +break ; + }#endif default :abort (); }
target-ppc/translate.c +21 -0
@@ -3329,6 +3329,20 @@ static void gen_conditional_store(DisasContext *ctx, TCGv EA,gen_qemu_st32 (ctx, cpu_gpr[reg],EA ); }else if (size ==2 ) {gen_qemu_st16 (ctx, cpu_gpr[reg],EA ); +#if defined(TARGET_PPC64 ) + } else if (size == 16) { +TCGv gpr1, gpr2; +if (unlikely (ctx->le_mode)) { + gpr1 = cpu_gpr[reg+1 ]; + gpr2 = cpu_gpr[reg]; + }else { + gpr1 = cpu_gpr[reg]; + gpr2 = cpu_gpr[reg+1 ]; + } +gen_qemu_st64 (ctx, gpr1,EA ); +gen_addr_add (ctx,EA ,EA ,8 ); +gen_qemu_st64 (ctx, gpr2,EA ); +#endif }else {gen_qemu_st8 (ctx, cpu_gpr[reg],EA ); }
@@ -3341,6 +3355,11 @@ static void gen_conditional_store(DisasContext *ctx, TCGv EA, static void gen_##name(DisasContext *ctx) \ { \ TCGv t0; \ + if (unlikely((len == 16) && (rD(ctx->opcode) & 1))) { \ + gen_inval_exception(ctx, \ + POWERPC_EXCP_INVAL_INVAL); \ + return; \ + } \ gen_set_access_type(ctx, ACCESS_RES); \ t0 = tcg_temp_local_new(); \ gen_addr_reg_index(ctx, t0); \
@@ -3397,6 +3416,7 @@ static void gen_lqarx(DisasContext *ctx)/* stdcx. */ STCX (stdcx_,8 ); +STCX (stqcx_,16 );#endif /* defined(TARGET_PPC64) */ /* sync */
@@ -9661,6 +9681,7 @@ GEN_HANDLER2(stwcx_, "stwcx.", 0x1F, 0x16, 0x04, 0x00000000, PPC_RES),GEN_HANDLER (ldarx,0x1F ,0x14 ,0x02 ,0x00000000 ,PPC_64B ),GEN_HANDLER_E (lqarx,0x1F ,0x14 ,0x08 ,0 ,PPC_NONE ,PPC2_LSQ_ISA207 ),GEN_HANDLER2 (stdcx_,"stdcx." ,0x1F ,0x16 ,0x06 ,0x00000000 ,PPC_64B ), +GEN_HANDLER_E (stqcx_,0x1F ,0x16 ,0x05 ,0 ,PPC_NONE ,PPC2_LSQ_ISA207 ), #endifGEN_HANDLER (sync,0x1F ,0x16 ,0x12 ,0x039FF801 ,PPC_MEM_SYNC ), GEN_HANDLER(wait, 0x1F, 0x1E, 0x01, 0x03FFF801, PPC_WAIT),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 091/130] target-ppc: Altivec 2.07: Add Instruction Flag
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a flag that will be used to tag the Altivec instructions introduced in Power ISA Version 2.07.
The flag is added to Power8 model since P8 supports these instructions.
--- target-ppc/cpu.h | 5 ++++- target-ppc/translate_init.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
target-ppc/cpu.h +4 -1
@@ -1893,12 +1893,15 @@ enum {PPC2_BCTAR_ISA207 =0x0000000000001000ULL ,/* ISA 2.07 load/store quadword */ PPC2_LSQ_ISA207 =0x0000000000002000ULL , +/* ISA 2.07 Altivec */ +PPC2_ALTIVEC_207 =0x0000000000004000ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \PPC2_ISA205 |PPC2_VSX207 |PPC2_PERM_ISA206 | \PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 | \PPC2_FP_CVT_ISA206 |PPC2_FP_TST_ISA206 | \ - PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207) +PPC2_BCTAR_ISA207 |PPC2_LSQ_ISA207 | \ + PPC2_ALTIVEC_207) };/*****************************************************************************/
target-ppc/translate_init.c +1 -1
@@ -7172,7 +7172,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 |PPC2_FP_TST_ISA206 |PPC2_BCTAR_ISA207 | -PPC2_LSQ_ISA207 ; +PPC2_LSQ_ISA207 |PPC2_ALTIVEC_207 ; pcc->msr_mask =0x800000000284FF36ULL ; pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 092/130] target-ppc: Altivec 2.07: Update AVR Structure
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch updates the ppc_avr_t data structure to include elements for signed 64-bit integers and (conditionally) unsigned 128 bit integers. These elements will be in instructions models later on in this patch series.
--- target-ppc/cpu.h | 4 ++++ 1 file changed, 4 insertions(+)
target-ppc/cpu.h +4 -0
@@ -352,6 +352,10 @@ union ppc_avr_t {int16_t s16[8 ];int32_t s32[4 ];uint64_t u64[2 ]; +int64_t s64[2 ]; +#ifdef CONFIG_INT128 +__uint128_t u128; +#endif };#if !defined(CONFIG_USER_ONLY )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 095/130] target-ppc: Altivec 2.07: Add Opcode Macro for VX Form Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds a macro to insert an entry into the opcode table for Altivec Power ISA Version 2.07 instructions. The macro is similar to the GEN_VXFORM macro except that it tags the entry with the PPC2_ALTIVEC_207 flag rather than PPC_ALTIVEC.
--- target-ppc/translate.c | 5 +++++ 1 file changed, 5 insertions(+)
target-ppc/translate.c +5 -0
@@ -10280,6 +10280,11 @@ GEN_VX_LOGICAL(vnor, tcg_gen_nor_i64, 2, 20),#undef GEN_VXFORM#define GEN_VXFORM (name, opc2, opc3) \ GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC) + +#undef GEN_VXFORM_207 +#define GEN_VXFORM_207 (name, opc2, opc3) \ +GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207) +#undef GEN_VXFORM_DUAL#define GEN_VXFORM_DUAL (name0, name1, opc2, opc3, type0, type1) \ GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, type0, type1)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 097/130] target-ppc: Altivec 2.07: Vector Logical Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Logical Instructions that are introduced in Power ISA Version 2.07: veqv, vnand and vorc.
--- target-ppc/translate.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
target-ppc/translate.c +11 -0
@@ -6852,6 +6852,9 @@ GEN_VX_LOGICAL(vandc, tcg_gen_andc_i64, 2, 17);GEN_VX_LOGICAL (vor, tcg_gen_or_i64,2 ,18 );GEN_VX_LOGICAL (vxor, tcg_gen_xor_i64,2 ,19 );GEN_VX_LOGICAL (vnor, tcg_gen_nor_i64,2 ,20 ); +GEN_VX_LOGICAL (veqv, tcg_gen_eqv_i64,2 ,26 ); +GEN_VX_LOGICAL (vnand, tcg_gen_nand_i64,2 ,22 ); +GEN_VX_LOGICAL (vorc, tcg_gen_orc_i64,2 ,21 );#define GEN_VXFORM (name, opc2, opc3) \ static void glue(gen_, name)(DisasContext *ctx) \
@@ -10301,11 +10304,19 @@ GEN_VR_STVE(wx, 0x07, 0x06),#undef GEN_VX_LOGICAL#define GEN_VX_LOGICAL (name, tcg_op, opc2, opc3) \ GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC) + +#undef GEN_VX_LOGICAL_207 +#define GEN_VX_LOGICAL_207 (name, tcg_op, opc2, opc3) \ +GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VX_LOGICAL (vand, tcg_gen_and_i64,2 ,16 ),GEN_VX_LOGICAL (vandc, tcg_gen_andc_i64,2 ,17 ),GEN_VX_LOGICAL (vor, tcg_gen_or_i64,2 ,18 ),GEN_VX_LOGICAL (vxor, tcg_gen_xor_i64,2 ,19 ),GEN_VX_LOGICAL (vnor, tcg_gen_nor_i64,2 ,20 ), +GEN_VX_LOGICAL_207 (veqv, tcg_gen_eqv_i64,2 ,26 ), +GEN_VX_LOGICAL_207 (vnand, tcg_gen_nand_i64,2 ,22 ), +GEN_VX_LOGICAL_207 (vorc, tcg_gen_orc_i64,2 ,21 ), #undef GEN_VXFORM #define GEN_VXFORM(name, opc2, opc3) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 093/130] target-ppc: Altivec 2.07: Add GEN_VXFORM3
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds generator macro for Altivec instructions that have 3 source AVR operands. The macro is similar to the 2 operand form.
--- target-ppc/translate.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
target-ppc/translate.c +19 -0
@@ -6885,6 +6885,25 @@ static void glue(gen_, name)(DisasContext *ctx) \tcg_temp_free_ptr (rd); \ } +#define GEN_VXFORM3 (name, opc2, opc3) \ +static void glue(gen_, name)(DisasContext *ctx) \ +{ \ + TCGv_ptr ra, rb, rc, rd; \ + if (unlikely(!ctx->altivec_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VPU); \ + return; \ + } \ + ra = gen_avr_ptr(rA(ctx->opcode)); \ + rb = gen_avr_ptr(rB(ctx->opcode)); \ + rc = gen_avr_ptr(rC(ctx->opcode)); \ + rd = gen_avr_ptr(rD(ctx->opcode)); \ + gen_helper_##name(rd, ra, rb, rc); \ + tcg_temp_free_ptr(ra); \ + tcg_temp_free_ptr(rb); \ + tcg_temp_free_ptr(rc); \ + tcg_temp_free_ptr(rd); \ +} +GEN_VXFORM (vaddubm,0 ,0 );GEN_VXFORM (vadduhm,0 ,1 );GEN_VXFORM (vadduwm,0 ,2 );
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 094/130] target-ppc: Altivec 2.07: Add Support for Dual Altivec Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
Some Alitvec instructions introduced in Power ISA Version 2.07 use bit 31 (aka the "Rc" bit) as an opcode bit. However, QEMU for PowerPC uses bits 0-5 and 21-30 for opcodes and not bit 31.
This patch introduces macros that will handle this situation by injecting an auxiliary handler which decodes bit 31 in invokes one of two standard handlers. Since the instructions are not, in general, from the same version of the ISA, two sets of PPC_*/PPC2_* instruction tags are supported.
--- target-ppc/translate.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
target-ppc/translate.c +24 -0
@@ -6904,6 +6904,26 @@ static void glue(gen_, name)(DisasContext *ctx) \tcg_temp_free_ptr (rd); \ } +/* +* Support for Altivec instruction pairs that use bit 31 (Rc) as +* an opcode bit. In general, these pairs come from different +* versions of the ISA, so we must also support a pair of flags for +* each instruction. +*/ +#define GEN_VXFORM_DUAL (name0, flg0, flg2_0, name1, flg1, flg2_1) \ +static void glue(gen_, name0##_##name1)(DisasContext *ctx) \ +{ \ + if ((Rc(ctx->opcode) == 0) && \ + ((ctx->insns_flags & flg0) || (ctx->insns_flags2 & flg2_0))) { \ + gen_##name0(ctx); \ + } else if ((Rc(ctx->opcode) == 1) && \ + ((ctx->insns_flags & flg1) || (ctx->insns_flags2 & flg2_1))) { \ + gen_##name1(ctx); \ + } else { \ + gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \ + } \ +} +GEN_VXFORM (vaddubm,0 ,0 );GEN_VXFORM (vadduhm,0 ,1 );GEN_VXFORM (vadduwm,0 ,2 );
@@ -10260,6 +10280,10 @@ GEN_VX_LOGICAL(vnor, tcg_gen_nor_i64, 2, 20),#undef GEN_VXFORM#define GEN_VXFORM (name, opc2, opc3) \ GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC) +#undef GEN_VXFORM_DUAL +#define GEN_VXFORM_DUAL (name0, name1, opc2, opc3, type0, type1) \ +GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, type0, type1) +GEN_VXFORM (vaddubm,0 ,0 ),GEN_VXFORM (vadduhm,0 ,1 ), GEN_VXFORM(vadduwm, 0, 2),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 096/130] target-ppc: Altivec 2.07: Add Support for R-Form Dual Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
Some Alitvec instructions introduced in Power ISA Version 2.07 use bit 31 (aka the "Rc" bit) as an opcode but also use bit 21 as an actual Rc bit. QEMU for PowerPC typically uses bits 0-5 and 21-30 for opcodes.
This patch introduces a generator macro that injects an auxiliary handler which decodes both bits 21 and 31 and invokes one of four standard handlers. Since the instructions are not, in general, from the same version of the ISA, two sets of PPC_*/PPC2_* flags are supported.
This patch also introduces a macro to insert two entries into the opcode table -- one for bit 21 equal to 0 and one for bit 21 equal to 1.
--- target-ppc/translate.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
target-ppc/translate.c +35 -0
@@ -387,6 +387,8 @@ EXTRACT_HELPER(opc2, 1, 5);EXTRACT_HELPER (opc3,6 ,5 );/* Update Cr0 flags */ EXTRACT_HELPER (Rc,0 ,1 ); +/* Update Cr6 flags (Altivec) */ +EXTRACT_HELPER (Rc21,10 ,1 );/* Destination */ EXTRACT_HELPER (rD,21 ,5 );/* Source */
@@ -7032,6 +7034,34 @@ static void glue(gen_, name)(DisasContext *ctx) \ GEN_VXRFORM1(name, name, #name, opc2, opc3) \ GEN_VXRFORM1(name##_dot, name##_, #name ".", opc2, (opc3 | (0x1 << 4))) +/* +* Support for Altivec instructions that use bit 31 (Rc) as an opcode +* bit but also use bit 21 as an actual Rc bit. In general, thse pairs +* come from different versions of the ISA, so we must also support a +* pair of flags for each instruction. +*/ +#define GEN_VXRFORM_DUAL (name0, flg0, flg2_0, name1, flg1, flg2_1) \ +static void glue(gen_, name0##_##name1)(DisasContext *ctx) \ +{ \ + if ((Rc(ctx->opcode) == 0) && \ + ((ctx->insns_flags & flg0) || (ctx->insns_flags2 & flg2_0))) { \ + if (Rc21(ctx->opcode) == 0) { \ + gen_##name0(ctx); \ + } else { \ + gen_##name0##_(ctx); \ + } \ + } else if ((Rc(ctx->opcode) == 1) && \ + ((ctx->insns_flags & flg1) || (ctx->insns_flags2 & flg2_1))) { \ + if (Rc21(ctx->opcode) == 0) { \ + gen_##name1(ctx); \ + } else { \ + gen_##name1##_(ctx); \ + } \ + } else { \ + gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \ + } \ +} + GEN_VXRFORM(vcmpequb, 3, 0) GEN_VXRFORM(vcmpequh, 3, 1)GEN_VXRFORM (vcmpequw,3 ,2 )
@@ -10289,6 +10319,11 @@ GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207)#define GEN_VXFORM_DUAL (name0, name1, opc2, opc3, type0, type1) \ GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, type0, type1) +#undef GEN_VXRFORM_DUAL +#define GEN_VXRFORM_DUAL (name0, name1, opc2, opc3, tp0, tp1) \ +GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, tp0, tp1), \ +GEN_HANDLER_E(name0##_##name1, 0x4, opc2, (opc3 | 0x10), 0x00000000, tp0, tp1), +GEN_VXFORM (vaddubm,0 ,0 ),GEN_VXFORM (vadduhm,0 ,1 ), GEN_VXFORM(vadduwm, 0, 2),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 098/130] target-ppc: Altivec 2.07: Add/Subtract Unsigned Doubleword Modulo
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds two Altivec unsigned doublword modulo instructions that are introduced in Power ISA Version V2.07:
- vaddudm : Vector Add Unsigned Doubleword Modulo
- vsubudm : Vector Subtrace Unsigned Doubleword Modulo
--- target-ppc/helper.h | 2 ++ target-ppc/int_helper.c | 1 + target-ppc/translate.c | 4 ++++ 3 files changed, 7 insertions(+)
target-ppc/helper.h +2 -0
@@ -109,9 +109,11 @@ DEF_HELPER_FLAGS_1(ftsqrt, TCG_CALL_NO_RWG_SE, i32, i64) DEF_HELPER_3(vaddubm, void, avr, avr, avr) DEF_HELPER_3(vadduhm, void, avr, avr, avr) DEF_HELPER_3(vadduwm, void, avr, avr, avr) +DEF_HELPER_3(vaddudm, void, avr, avr, avr) DEF_HELPER_3(vsububm, void, avr, avr, avr) DEF_HELPER_3(vsubuhm, void, avr, avr, avr) DEF_HELPER_3(vsubuwm, void, avr, avr, avr) +DEF_HELPER_3(vsubudm, void, avr, avr, avr) DEF_HELPER_3(vavgub, void, avr, avr, avr) DEF_HELPER_3(vavguh, void, avr, avr, avr)DEF_HELPER_3 (vavguw, void, avr, avr, avr)
target-ppc/int_helper.c +1 -0
@@ -504,6 +504,7 @@ void helper_vaddcuw(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) VARITH(ubm, u8) VARITH(uhm, u16) VARITH(uwm, u32) +VARITH(udm, u64)#undef VARITH_DO#undef VARITH
target-ppc/translate.c +4 -0
@@ -6932,9 +6932,11 @@ static void glue(gen_, name0##_##name1)(DisasContext *ctx) \GEN_VXFORM (vaddubm,0 ,0 );GEN_VXFORM (vadduhm,0 ,1 );GEN_VXFORM (vadduwm,0 ,2 ); +GEN_VXFORM (vaddudm,0 ,3 );GEN_VXFORM (vsububm,0 ,16 );GEN_VXFORM (vsubuhm,0 ,17 );GEN_VXFORM (vsubuwm,0 ,18 ); +GEN_VXFORM (vsubudm,0 ,19 );GEN_VXFORM (vmaxub,1 ,0 );GEN_VXFORM (vmaxuh,1 ,1 );GEN_VXFORM (vmaxuw,1 ,2 );
@@ -10338,9 +10340,11 @@ GEN_HANDLER_E(name0##_##name1, 0x4, opc2, (opc3 | 0x10), 0x00000000, tp0, tp1),GEN_VXFORM (vaddubm,0 ,0 ),GEN_VXFORM (vadduhm,0 ,1 ),GEN_VXFORM (vadduwm,0 ,2 ), +GEN_VXFORM_207 (vaddudm,0 ,3 ),GEN_VXFORM (vsububm,0 ,16 ),GEN_VXFORM (vsubuhm,0 ,17 ),GEN_VXFORM (vsubuwm,0 ,18 ), +GEN_VXFORM_207 (vsubudm,0 ,19 ),GEN_VXFORM (vmaxub,1 ,0 ),GEN_VXFORM (vmaxuh,1 ,1 ), GEN_VXFORM(vmaxuw, 1, 2),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 099/130] target-ppc: Altivec 2.07: Change VMUL_DO to Support 64-bit Integers
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This VMUL_DO macro provides support for the various vmule* and vmulo* instructions. These instructions multiply vector elements, producing products that are one size larger; e.g. vmuleub multiplies unsigned 8-bit elements and produces a 16 bit unsigned element.
The existing macro works correctly for the existing instructions (8-bit, and 16-bit source elements) but does not work correctly for 32-bit source elements.
This patch adds an explicit cast to the multiplicands, forcing them to be of the target element type. This is required for the forthcoming patches that add the vmul[eo][us]w instructions.
--- target-ppc/int_helper.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
target-ppc/int_helper.c +14 -12
@@ -983,28 +983,30 @@ void helper_vmsumuhs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, } } -#define VMUL_DO (name, mul_element, prod_element, evenp) \ +#define VMUL_DO (name, mul_element, prod_element, cast, evenp) \ void helper_v##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ { \ int i; \ \ VECTOR_FOR_INORDER_I(i, prod_element) { \ if (evenp) { \ - r->prod_element[i] = a->mul_element[i * 2 + HI_IDX] * \ - b->mul_element[i * 2 + HI_IDX]; \ + r->prod_element[i] = \ + (cast)a->mul_element[i * 2 + HI_IDX] * \ + (cast)b->mul_element[i * 2 + HI_IDX]; \ } else { \ - r->prod_element[i] = a->mul_element[i * 2 + LO_IDX] * \ - b->mul_element[i * 2 + LO_IDX]; \ + r->prod_element[i] = \ + (cast)a->mul_element[i * 2 + LO_IDX] * \ + (cast)b->mul_element[i * 2 + LO_IDX]; \ } \ } \ } -#define VMUL (suffix, mul_element, prod_element) \ - VMUL_DO(mule##suffix, mul_element, prod_element, 1) \ - VMUL_DO(mulo##suffix, mul_element, prod_element, 0) -VMUL(sb, s8, s16) -VMUL(sh, s16, s32) -VMUL(ub, u8, u16) -VMUL(uh, u16, u32) +#define VMUL (suffix, mul_element, prod_element, cast) \ + VMUL_DO(mule##suffix, mul_element, prod_element, cast, 1) \ + VMUL_DO(mulo##suffix, mul_element, prod_element, cast, 0) +VMUL(sb, s8, s16, int16_t) +VMUL(sh, s16, s32, int32_t) +VMUL(ub, u8, u16, uint16_t) +VMUL(uh, u16, u32, uint32_t)#undef VMUL_DO#undef VMUL
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 100/130] target-ppc: Altivec 2.07: Multiply Even/Odd Word Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Multilpy Even/Odd Word instructions that are introduced in Power ISA Version 2.07:
- Vector Multiply Even Unsigned Word (vmuleuw)
- Vector Multiply Even Signed Word (vmulesw)
- Vector Multiply Odd Unsigned Word (vmulouw)
- Vector Multiply Odd Signed Word (vmulosw)
--- target-ppc/helper.h | 4 ++++ target-ppc/int_helper.c | 2 ++ target-ppc/translate.c | 8 ++++++++ 3 files changed, 14 insertions(+)
target-ppc/helper.h +4 -0
@@ -166,12 +166,16 @@ DEF_HELPER_3(vmrghh, void, avr, avr, avr) DEF_HELPER_3(vmrghw, void, avr, avr, avr) DEF_HELPER_3(vmulesb, void, avr, avr, avr) DEF_HELPER_3(vmulesh, void, avr, avr, avr) +DEF_HELPER_3(vmulesw, void, avr, avr, avr) DEF_HELPER_3(vmuleub, void, avr, avr, avr) DEF_HELPER_3(vmuleuh, void, avr, avr, avr) +DEF_HELPER_3(vmuleuw, void, avr, avr, avr) DEF_HELPER_3(vmulosb, void, avr, avr, avr) DEF_HELPER_3(vmulosh, void, avr, avr, avr) +DEF_HELPER_3(vmulosw, void, avr, avr, avr) DEF_HELPER_3(vmuloub, void, avr, avr, avr) DEF_HELPER_3(vmulouh, void, avr, avr, avr) +DEF_HELPER_3(vmulouw, void, avr, avr, avr) DEF_HELPER_3(vsrab, void, avr, avr, avr) DEF_HELPER_3(vsrah, void, avr, avr, avr)DEF_HELPER_3 (vsraw, void, avr, avr, avr)
target-ppc/int_helper.c +2 -0
@@ -1005,8 +1005,10 @@ void helper_vmsumuhs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, VMUL_DO(mulo##suffix, mul_element, prod_element, cast, 0) VMUL(sb, s8, s16, int16_t) VMUL(sh, s16, s32, int32_t) +VMUL(sw, s32, s64, int64_t) VMUL(ub, u8, u16, uint16_t) VMUL(uh, u16, u32, uint32_t) +VMUL(uw, u32, u64, uint64_t)#undef VMUL_DO#undef VMUL
target-ppc/translate.c +8 -0
@@ -6963,12 +6963,16 @@ GEN_VXFORM(vmrglh, 6, 5);GEN_VXFORM (vmrglw,6 ,6 );GEN_VXFORM (vmuloub,4 ,0 );GEN_VXFORM (vmulouh,4 ,1 ); +GEN_VXFORM (vmulouw,4 ,2 );GEN_VXFORM (vmulosb,4 ,4 );GEN_VXFORM (vmulosh,4 ,5 ); +GEN_VXFORM (vmulosw,4 ,6 );GEN_VXFORM (vmuleub,4 ,8 );GEN_VXFORM (vmuleuh,4 ,9 ); +GEN_VXFORM (vmuleuw,4 ,10 );GEN_VXFORM (vmulesb,4 ,12 );GEN_VXFORM (vmulesh,4 ,13 ); +GEN_VXFORM (vmulesw,4 ,14 );GEN_VXFORM (vslb,2 ,4 );GEN_VXFORM (vslh,2 ,5 );GEN_VXFORM (vslw,2 ,6 );
@@ -10371,12 +10375,16 @@ GEN_VXFORM(vmrglh, 6, 5),GEN_VXFORM (vmrglw,6 ,6 ),GEN_VXFORM (vmuloub,4 ,0 ),GEN_VXFORM (vmulouh,4 ,1 ), +GEN_VXFORM_207 (vmulouw,4 ,2 ),GEN_VXFORM (vmulosb,4 ,4 ),GEN_VXFORM (vmulosh,4 ,5 ), +GEN_VXFORM_207 (vmulosw,4 ,6 ),GEN_VXFORM (vmuleub,4 ,8 ),GEN_VXFORM (vmuleuh,4 ,9 ), +GEN_VXFORM_207 (vmuleuw,4 ,10 ),GEN_VXFORM (vmulesb,4 ,12 ),GEN_VXFORM (vmulesh,4 ,13 ), +GEN_VXFORM_207 (vmulesw,4 ,14 ),GEN_VXFORM (vslb,2 ,4 ),GEN_VXFORM (vslh,2 ,5 ), GEN_VXFORM(vslw, 2, 6),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 101/130] target-ppc: Altivec 2.07: vmuluw Instruction
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Multiply Unsigned Word Modulo (vmuluwm) instruction.
The existing VARITH_DO macro is re-used to (trivially) instantiate the helper code.
Since bits 21-31 of any vmuluwm instruction is 137, the instruction is coded as a dual to vmulouw (bits 21-31 = 136).
--- target-ppc/helper.h | 1 + target-ppc/int_helper.c | 1 + target-ppc/translate.c | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-)
target-ppc/helper.h +1 -0
@@ -176,6 +176,7 @@ DEF_HELPER_3(vmulosw, void, avr, avr, avr) DEF_HELPER_3(vmuloub, void, avr, avr, avr) DEF_HELPER_3(vmulouh, void, avr, avr, avr) DEF_HELPER_3(vmulouw, void, avr, avr, avr) +DEF_HELPER_3(vmuluwm, void, avr, avr, avr) DEF_HELPER_3(vsrab, void, avr, avr, avr) DEF_HELPER_3(vsrah, void, avr, avr, avr)DEF_HELPER_3 (vsraw, void, avr, avr, avr)
target-ppc/int_helper.c +1 -0
@@ -505,6 +505,7 @@ VARITH(ubm, u8) VARITH(uhm, u16) VARITH(uwm, u32) VARITH(udm, u64) +VARITH_DO(muluwm, *, u32)#undef VARITH_DO#undef VARITH
target-ppc/translate.c +4 -1
@@ -6964,6 +6964,9 @@ GEN_VXFORM(vmrglw, 6, 6);GEN_VXFORM (vmuloub,4 ,0 );GEN_VXFORM (vmulouh,4 ,1 );GEN_VXFORM (vmulouw,4 ,2 ); +GEN_VXFORM (vmuluwm,4 ,2 ); +GEN_VXFORM_DUAL (vmulouw,PPC_ALTIVEC ,PPC_NONE , + vmuluwm, PPC_NONE, PPC2_ALTIVEC_207)GEN_VXFORM (vmulosb,4 ,4 );GEN_VXFORM (vmulosh,4 ,5 );GEN_VXFORM (vmulosw,4 ,6 );
@@ -10375,7 +10378,7 @@ GEN_VXFORM(vmrglh, 6, 5),GEN_VXFORM (vmrglw,6 ,6 ),GEN_VXFORM (vmuloub,4 ,0 ),GEN_VXFORM (vmulouh,4 ,1 ), -GEN_VXFORM_207 (vmulouw,4 ,2 ), +GEN_VXFORM_DUAL (vmulouw, vmuluwm,4 ,2 ,PPC_ALTIVEC ,PPC_NONE ),GEN_VXFORM (vmulosb,4 ,4 ),GEN_VXFORM (vmulosh,4 ,5 ), GEN_VXFORM_207(vmulosw, 4, 6),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 102/130] target-ppc: Altivec 2.07: Add Vector Count Leading Zeroes
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Count Leading Zeroes instructions introduced in Power ISA Version 2.07 - vclzb, vclzh, vclzw and vclzd.
--- target-ppc/helper.h | 5 +++++ target-ppc/int_helper.c | 29 +++++++++++++++++++++++++++++ target-ppc/translate.c | 9 +++++++++ 3 files changed, 43 insertions(+)
target-ppc/helper.h +5 -0
@@ -273,6 +273,11 @@ DEF_HELPER_4(vcfsx, void, env, avr, avr, i32) DEF_HELPER_4(vctuxs, void, env, avr, avr, i32) DEF_HELPER_4(vctsxs, void, env, avr, avr, i32) +DEF_HELPER_2(vclzb, void, avr, avr) +DEF_HELPER_2(vclzh, void, avr, avr) +DEF_HELPER_2(vclzw, void, avr, avr) +DEF_HELPER_2(vclzd, void, avr, avr) + DEF_HELPER_2(xsadddp, void, env, i32) DEF_HELPER_2(xssubdp, void, env, i32)DEF_HELPER_2 (xsmuldp, void, env, i32)
target-ppc/int_helper.c +29 -0
@@ -1524,6 +1524,35 @@ VUPK(lsh, s32, s16, UPKLO)#undef UPKHI#undef UPKLO +#define VGENERIC_DO (name, element) \ + void helper_v##name(ppc_avr_t *r, ppc_avr_t *b) \ + { \ + int i; \ + \ + VECTOR_FOR_INORDER_I(i, element) { \ + r->element[i] = name(b->element[i]); \ + } \ + } + +#define clzb (v) ((v) ? clz32((uint32_t)(v) << 24) : 8) +#define clzh (v) ((v) ? clz32((uint32_t)(v) << 16) : 16) +#define clzw (v) clz32((v)) +#define clzd (v) clz64((v)) + +VGENERIC_DO(clzb, u8) +VGENERIC_DO(clzh, u16) +VGENERIC_DO(clzw, u32) +VGENERIC_DO(clzd, u64) + +#undef clzb +#undef clzh +#undef clzw +#undef clzd + + +#undef VGENERIC_DO + +#undef VECTOR_FOR_INORDER_I#undef HI_IDX#undef LO_IDX
target-ppc/translate.c +9 -0
@@ -7283,6 +7283,10 @@ GEN_VAFORM_PAIRED(vmsumshm, vmsumshs, 20) GEN_VAFORM_PAIRED(vsel, vperm, 21) GEN_VAFORM_PAIRED(vmaddfp, vnmsubfp, 23) +GEN_VXFORM_NOA(vclzb, 1, 28) +GEN_VXFORM_NOA(vclzh, 1, 29) +GEN_VXFORM_NOA(vclzw, 1, 30) +GEN_VXFORM_NOA (vclzd,1 ,31 ) /*** VSX extension ***/static inline TCGv_i64 cpu_vsrh (int n)
@@ -10504,6 +10508,11 @@ GEN_VAFORM_PAIRED(vmsumshm, vmsumshs, 20),GEN_VAFORM_PAIRED (vsel, vperm,21 ),GEN_VAFORM_PAIRED (vmaddfp, vnmsubfp,23 ), +GEN_VXFORM_207 (vclzb,1 ,28 ), +GEN_VXFORM_207 (vclzh,1 ,29 ), +GEN_VXFORM_207 (vclzw,1 ,30 ), +GEN_VXFORM_207 (vclzd,1 ,31 ), +GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ),GEN_HANDLER_E (lxsiwax,0x1F ,0x0C ,0x02 ,0 ,PPC_NONE ,PPC2_VSX207 ), GEN_HANDLER_E(lxsiwzx, 0x1F, 0x0C, 0x00, 0, PPC_NONE, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 104/130] target-ppc: Altivec 2.07: Vector Min/Max Doubleword Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Minimum and Maximum Doubleword instructions that are introduced in Power ISA Version 2.07.
--- target-ppc/helper.h | 4 ++++ target-ppc/int_helper.c | 2 ++ target-ppc/translate.c | 8 ++++++++ 3 files changed, 14 insertions(+)
target-ppc/helper.h +4 -0
@@ -123,15 +123,19 @@ DEF_HELPER_3(vavgsw, void, avr, avr, avr) DEF_HELPER_3(vminsb, void, avr, avr, avr) DEF_HELPER_3(vminsh, void, avr, avr, avr) DEF_HELPER_3(vminsw, void, avr, avr, avr) +DEF_HELPER_3(vminsd, void, avr, avr, avr) DEF_HELPER_3(vmaxsb, void, avr, avr, avr) DEF_HELPER_3(vmaxsh, void, avr, avr, avr) DEF_HELPER_3(vmaxsw, void, avr, avr, avr) +DEF_HELPER_3(vmaxsd, void, avr, avr, avr) DEF_HELPER_3(vminub, void, avr, avr, avr) DEF_HELPER_3(vminuh, void, avr, avr, avr) DEF_HELPER_3(vminuw, void, avr, avr, avr) +DEF_HELPER_3(vminud, void, avr, avr, avr) DEF_HELPER_3(vmaxub, void, avr, avr, avr) DEF_HELPER_3(vmaxuh, void, avr, avr, avr) DEF_HELPER_3(vmaxuw, void, avr, avr, avr) +DEF_HELPER_3(vmaxud, void, avr, avr, avr) DEF_HELPER_4(vcmpequb, void, env, avr, avr, avr) DEF_HELPER_4(vcmpequh, void, env, avr, avr, avr)DEF_HELPER_4 (vcmpequw, void, env, avr, avr, avr)
target-ppc/int_helper.c +2 -0
@@ -824,9 +824,11 @@ void helper_vmhraddshs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, VMINMAX(sb, s8) VMINMAX(sh, s16) VMINMAX(sw, s32) +VMINMAX(sd, s64) VMINMAX(ub, u8) VMINMAX(uh, u16) VMINMAX(uw, u32) +VMINMAX(ud, u64)#undef VMINMAX_DO#undef VMINMAX
target-ppc/translate.c +8 -0
@@ -6940,15 +6940,19 @@ GEN_VXFORM(vsubudm, 0, 19);GEN_VXFORM (vmaxub,1 ,0 );GEN_VXFORM (vmaxuh,1 ,1 );GEN_VXFORM (vmaxuw,1 ,2 ); +GEN_VXFORM (vmaxud,1 ,3 );GEN_VXFORM (vmaxsb,1 ,4 );GEN_VXFORM (vmaxsh,1 ,5 );GEN_VXFORM (vmaxsw,1 ,6 ); +GEN_VXFORM (vmaxsd,1 ,7 );GEN_VXFORM (vminub,1 ,8 );GEN_VXFORM (vminuh,1 ,9 );GEN_VXFORM (vminuw,1 ,10 ); +GEN_VXFORM (vminud,1 ,11 );GEN_VXFORM (vminsb,1 ,12 );GEN_VXFORM (vminsh,1 ,13 );GEN_VXFORM (vminsw,1 ,14 ); +GEN_VXFORM (vminsd,1 ,15 );GEN_VXFORM (vavgub,1 ,16 );GEN_VXFORM (vavguh,1 ,17 );GEN_VXFORM (vavguw,1 ,18 );
@@ -10372,15 +10376,19 @@ GEN_VXFORM_207(vsubudm, 0, 19),GEN_VXFORM (vmaxub,1 ,0 ),GEN_VXFORM (vmaxuh,1 ,1 ),GEN_VXFORM (vmaxuw,1 ,2 ), +GEN_VXFORM_207 (vmaxud,1 ,3 ),GEN_VXFORM (vmaxsb,1 ,4 ),GEN_VXFORM (vmaxsh,1 ,5 ),GEN_VXFORM (vmaxsw,1 ,6 ), +GEN_VXFORM_207 (vmaxsd,1 ,7 ),GEN_VXFORM (vminub,1 ,8 ),GEN_VXFORM (vminuh,1 ,9 ),GEN_VXFORM (vminuw,1 ,10 ), +GEN_VXFORM_207 (vminud,1 ,11 ),GEN_VXFORM (vminsb,1 ,12 ),GEN_VXFORM (vminsh,1 ,13 ),GEN_VXFORM (vminsw,1 ,14 ), +GEN_VXFORM_207 (vminsd,1 ,15 ),GEN_VXFORM (vavgub,1 ,16 ),GEN_VXFORM (vavguh,1 ,17 ), GEN_VXFORM(vavguw, 1, 18),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 106/130] target-ppc: Altivec 2.07: Unpack Signed Word Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Unpack Signed Word instructions introduced in Power ISA Version 2.07:
- Vector Unpack High Signed Word (vupkusw)
- Vector Unpack Low Signed Word (vupklsw)
--- target-ppc/helper.h | 2 ++ target-ppc/int_helper.c | 2 ++ target-ppc/translate.c | 4 ++++ 3 files changed, 8 insertions(+)
target-ppc/helper.h +2 -0
@@ -224,8 +224,10 @@ DEF_HELPER_2(vupkhpx, void, avr, avr) DEF_HELPER_2(vupklpx, void, avr, avr) DEF_HELPER_2(vupkhsb, void, avr, avr) DEF_HELPER_2(vupkhsh, void, avr, avr) +DEF_HELPER_2(vupkhsw, void, avr, avr) DEF_HELPER_2(vupklsb, void, avr, avr) DEF_HELPER_2(vupklsh, void, avr, avr) +DEF_HELPER_2(vupklsw, void, avr, avr) DEF_HELPER_5(vmsumubm, void, env, avr, avr, avr, avr) DEF_HELPER_5(vmsummbm, void, env, avr, avr, avr, avr)DEF_HELPER_5 (vsel, void, env, avr, avr, avr, avr)
target-ppc/int_helper.c +2 -0
@@ -1524,8 +1524,10 @@ VUPKPX(hpx, UPKHI) } VUPK(hsb, s16, s8, UPKHI) VUPK(hsh, s32, s16, UPKHI) +VUPK(hsw, s64, s32, UPKHI) VUPK(lsb, s16, s8, UPKLO) VUPK(lsh, s32, s16, UPKLO) +VUPK(lsw, s64, s32, UPKLO)#undef VUPK#undef UPKHI#undef UPKLO
target-ppc/translate.c +4 -0
@@ -7149,8 +7149,10 @@ static void glue(gen_, name)(DisasContext *ctx) \GEN_VXFORM_NOA (vupkhsb,7 ,8 );GEN_VXFORM_NOA (vupkhsh,7 ,9 ); +GEN_VXFORM_NOA (vupkhsw,7 ,25 );GEN_VXFORM_NOA (vupklsb,7 ,10 );GEN_VXFORM_NOA (vupklsh,7 ,11 ); +GEN_VXFORM_NOA (vupklsw,7 ,27 );GEN_VXFORM_NOA (vupkhpx,7 ,13 );GEN_VXFORM_NOA (vupklpx,7 ,15 );GEN_VXFORM_NOA_ENV (vrefp,5 ,4 );
@@ -10503,8 +10505,10 @@ GEN_VXFORM_SIMM(vspltisw, 6, 14), GEN_HANDLER(name, 0x04, opc2, opc3, 0x001f0000, PPC_ALTIVEC)GEN_VXFORM_NOA (vupkhsb,7 ,8 ),GEN_VXFORM_NOA (vupkhsh,7 ,9 ), +GEN_VXFORM_207 (vupkhsw,7 ,25 ),GEN_VXFORM_NOA (vupklsb,7 ,10 ),GEN_VXFORM_NOA (vupklsh,7 ,11 ), +GEN_VXFORM_207 (vupklsw,7 ,27 ),GEN_VXFORM_NOA (vupkhpx,7 ,13 ),GEN_VXFORM_NOA (vupklpx,7 ,15 ), GEN_VXFORM_NOA(vrefp, 5, 4),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 107/130] target-ppc: Altivec 2.07: Vector Merge Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Merge Even Word (vmrgew) and Vector Merge Odd Word (vmrgow) instructions introduced in Power ISA Version 2.07.
--- target-ppc/translate.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
target-ppc/translate.c +37 -0
@@ -6965,6 +6965,41 @@ GEN_VXFORM(vmrghw, 6, 2);GEN_VXFORM (vmrglb,6 ,4 );GEN_VXFORM (vmrglh,6 ,5 );GEN_VXFORM (vmrglw,6 ,6 ); + +static void gen_vmrgew (DisasContext *ctx) +{ +TCGv_i64 tmp; +int VT ,VA ,VB ; +if (unlikely (!ctx->altivec_enabled)) { +gen_exception (ctx,POWERPC_EXCP_VPU ); +return ; + } +VT =rD (ctx->opcode); +VA =rA (ctx->opcode); +VB =rB (ctx->opcode); + tmp =tcg_temp_new_i64 (); +tcg_gen_shri_i64 (tmp, cpu_avrh[VB ],32 ); +tcg_gen_deposit_i64 (cpu_avrh[VT ], cpu_avrh[VA ], tmp,0 ,32 ); +tcg_gen_shri_i64 (tmp, cpu_avrl[VB ],32 ); +tcg_gen_deposit_i64 (cpu_avrl[VT ], cpu_avrl[VA ], tmp,0 ,32 ); +tcg_temp_free_i64 (tmp); +} + +static void gen_vmrgow (DisasContext *ctx) +{ +int VT ,VA ,VB ; +if (unlikely (!ctx->altivec_enabled)) { +gen_exception (ctx,POWERPC_EXCP_VPU ); +return ; + } +VT =rD (ctx->opcode); +VA =rA (ctx->opcode); +VB =rB (ctx->opcode); + +tcg_gen_deposit_i64 (cpu_avrh[VT ], cpu_avrh[VB ], cpu_avrh[VA ],32 ,32 ); +tcg_gen_deposit_i64 (cpu_avrl[VT ], cpu_avrl[VB ], cpu_avrl[VA ],32 ,32 ); +} +GEN_VXFORM (vmuloub,4 ,0 );GEN_VXFORM (vmulouh,4 ,1 );GEN_VXFORM (vmulouw,4 ,2 );
@@ -10407,6 +10442,8 @@ GEN_VXFORM(vmrghw, 6, 2),GEN_VXFORM (vmrglb,6 ,4 ),GEN_VXFORM (vmrglh,6 ,5 ),GEN_VXFORM (vmrglw,6 ,6 ), +GEN_VXFORM_207 (vmrgew,6 ,30 ), +GEN_VXFORM_207 (vmrgow,6 ,26 ),GEN_VXFORM (vmuloub,4 ,0 ),GEN_VXFORM (vmulouh,4 ,1 ), GEN_VXFORM_DUAL(vmulouw, vmuluwm, 4, 2, PPC_ALTIVEC, PPC_NONE),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 103/130] target-ppc: Altivec 2.07: Vector Population Count Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Population Count instructions introduced in Power ISA Version 2.07: vpopcntb, vpopcnth, vpopcntw and vpopcntd.
--- target-ppc/helper.h | 4 ++++ target-ppc/int_helper.c | 14 ++++++++++++++ target-ppc/translate.c | 22 ++++++++++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-)
target-ppc/helper.h +4 -0
@@ -277,6 +277,10 @@ DEF_HELPER_2(vclzb, void, avr, avr) DEF_HELPER_2(vclzh, void, avr, avr) DEF_HELPER_2(vclzw, void, avr, avr) DEF_HELPER_2(vclzd, void, avr, avr) +DEF_HELPER_2(vpopcntb, void, avr, avr) +DEF_HELPER_2(vpopcnth, void, avr, avr) +DEF_HELPER_2(vpopcntw, void, avr, avr) +DEF_HELPER_2(vpopcntd, void, avr, avr) DEF_HELPER_2(xsadddp, void, env, i32)DEF_HELPER_2 (xssubdp, void, env, i32)
target-ppc/int_helper.c +14 -0
@@ -1549,6 +1549,20 @@ VGENERIC_DO(clzd, u64)#undef clzw#undef clzd +#define popcntb (v) ctpop8(v) +#define popcnth (v) ctpop16(v) +#define popcntw (v) ctpop32(v) +#define popcntd (v) ctpop64(v) + +VGENERIC_DO(popcntb, u8) +VGENERIC_DO(popcnth, u16) +VGENERIC_DO(popcntw, u32) +VGENERIC_DO(popcntd, u64) + +#undef popcntb +#undef popcnth +#undef popcntw +#undef popcntd#undef VGENERIC_DO
target-ppc/translate.c +18 -4
@@ -7287,6 +7287,19 @@ GEN_VXFORM_NOA(vclzb, 1, 28) GEN_VXFORM_NOA(vclzh, 1, 29) GEN_VXFORM_NOA(vclzw, 1, 30) GEN_VXFORM_NOA(vclzd, 1, 31) +GEN_VXFORM_NOA(vpopcntb, 1, 28) +GEN_VXFORM_NOA(vpopcnth, 1, 29) +GEN_VXFORM_NOA(vpopcntw, 1, 30) +GEN_VXFORM_NOA(vpopcntd, 1, 31) +GEN_VXFORM_DUAL (vclzb,PPC_NONE ,PPC2_ALTIVEC_207 , \ + vpopcntb, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VXFORM_DUAL (vclzh,PPC_NONE ,PPC2_ALTIVEC_207 , \ + vpopcnth, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VXFORM_DUAL (vclzw,PPC_NONE ,PPC2_ALTIVEC_207 , \ + vpopcntw, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VXFORM_DUAL (vclzd,PPC_NONE ,PPC2_ALTIVEC_207 , \ + vpopcntd,PPC_NONE ,PPC2_ALTIVEC_207 ) + /*** VSX extension ***/static inline TCGv_i64 cpu_vsrh (int n)
@@ -10508,10 +10521,11 @@ GEN_VAFORM_PAIRED(vmsumshm, vmsumshs, 20),GEN_VAFORM_PAIRED (vsel, vperm,21 ),GEN_VAFORM_PAIRED (vmaddfp, vnmsubfp,23 ), -GEN_VXFORM_207 (vclzb,1 ,28 ), -GEN_VXFORM_207 (vclzh,1 ,29 ), -GEN_VXFORM_207 (vclzw,1 ,30 ), -GEN_VXFORM_207 (vclzd,1 ,31 ), +GEN_VXFORM_DUAL (vclzb, vpopcntb,1 ,28 ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_VXFORM_DUAL (vclzh, vpopcnth,1 ,29 ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_VXFORM_DUAL (vclzw, vpopcntw,1 ,30 ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_VXFORM_DUAL (vclzd, vpopcntd,1 ,31 ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ), GEN_HANDLER_E(lxsiwax, 0x1F, 0x0C, 0x02, 0, PPC_NONE, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 105/130] target-ppc: Altivec 2.07: Pack Doubleword Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Pack Doubleword instructions introduced in Power ISA Version 2.07:
- Vector Pack Signed Doubleword Signed Saturate (vpksdss)
- Vector Pack Signed Doubleword Unsigned Saturate (vpksdus)
- Vector Pack Unsigned Doubleword Unsigned Modulo (vpkudum)
- Vector Pack Unsigned Doubleword Unsigned Saturate (vpkudus)
--- target-ppc/helper.h | 4 ++++ target-ppc/int_helper.c | 4 ++++ target-ppc/translate.c | 8 ++++++++ 3 files changed, 16 insertions(+)
target-ppc/helper.h +4 -0
@@ -234,10 +234,14 @@ DEF_HELPER_4(vpkshss, void, env, avr, avr, avr) DEF_HELPER_4(vpkshus, void, env, avr, avr, avr) DEF_HELPER_4(vpkswss, void, env, avr, avr, avr) DEF_HELPER_4(vpkswus, void, env, avr, avr, avr) +DEF_HELPER_4(vpksdss, void, env, avr, avr, avr) +DEF_HELPER_4(vpksdus, void, env, avr, avr, avr) DEF_HELPER_4(vpkuhus, void, env, avr, avr, avr) DEF_HELPER_4(vpkuwus, void, env, avr, avr, avr) +DEF_HELPER_4(vpkudus, void, env, avr, avr, avr) DEF_HELPER_4(vpkuhum, void, env, avr, avr, avr) DEF_HELPER_4(vpkuwum, void, env, avr, avr, avr) +DEF_HELPER_4(vpkudum, void, env, avr, avr, avr) DEF_HELPER_3(vpkpx, void, avr, avr, avr) DEF_HELPER_5(vmhaddshs, void, env, avr, avr, avr, avr)DEF_HELPER_5 (vmhraddshs, void, env, avr, avr, avr, avr)
target-ppc/int_helper.c +4 -0
@@ -1089,10 +1089,14 @@ VPK(shss, s16, s8, cvtshsb, 1) VPK(shus, s16, u8, cvtshub, 1) VPK(swss, s32, s16, cvtswsh, 1) VPK(swus, s32, u16, cvtswuh, 1) +VPK(sdss, s64, s32, cvtsdsw, 1) +VPK(sdus, s64, u32, cvtsduw, 1) VPK(uhus, u16, u8, cvtuhub, 1) VPK(uwus, u32, u16, cvtuwuh, 1) +VPK(udus, u64, u32, cvtuduw, 1) VPK(uhum, u16, u8, I, 0) VPK(uwum, u32, u16, I, 0) +VPK(udum, u64, u32, I, 0)#undef I#undef VPK#undef PKBIG
target-ppc/translate.c +8 -0
@@ -7012,12 +7012,16 @@ GEN_VXFORM(vsl, 2, 7);GEN_VXFORM (vsr,2 ,11 );GEN_VXFORM_ENV (vpkuhum,7 ,0 );GEN_VXFORM_ENV (vpkuwum,7 ,1 ); +GEN_VXFORM_ENV (vpkudum,7 ,17 );GEN_VXFORM_ENV (vpkuhus,7 ,2 );GEN_VXFORM_ENV (vpkuwus,7 ,3 ); +GEN_VXFORM_ENV (vpkudus,7 ,19 );GEN_VXFORM_ENV (vpkshus,7 ,4 );GEN_VXFORM_ENV (vpkswus,7 ,5 ); +GEN_VXFORM_ENV (vpksdus,7 ,21 );GEN_VXFORM_ENV (vpkshss,7 ,6 );GEN_VXFORM_ENV (vpkswss,7 ,7 ); +GEN_VXFORM_ENV (vpksdss,7 ,23 );GEN_VXFORM (vpkpx,7 ,12 );GEN_VXFORM_ENV (vsum4ubs,4 ,24 );GEN_VXFORM_ENV (vsum4sbs,4 ,28 );
@@ -10445,12 +10449,16 @@ GEN_VXFORM(vsl, 2, 7),GEN_VXFORM (vsr,2 ,11 ),GEN_VXFORM (vpkuhum,7 ,0 ),GEN_VXFORM (vpkuwum,7 ,1 ), +GEN_VXFORM_207 (vpkudum,7 ,17 ),GEN_VXFORM (vpkuhus,7 ,2 ),GEN_VXFORM (vpkuwus,7 ,3 ), +GEN_VXFORM_207 (vpkudus,7 ,19 ),GEN_VXFORM (vpkshus,7 ,4 ),GEN_VXFORM (vpkswus,7 ,5 ), +GEN_VXFORM_207 (vpksdus,7 ,21 ),GEN_VXFORM (vpkshss,7 ,6 ),GEN_VXFORM (vpkswss,7 ,7 ), +GEN_VXFORM_207 (vpksdss,7 ,23 ),GEN_VXFORM (vpkpx,7 ,12 ),GEN_VXFORM (vsum4ubs,4 ,24 ), GEN_VXFORM(vsum4sbs, 4, 28),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 108/130] target-ppc: Altivec 2.07: Change Bit Masks to Support 64-bit Rotates and Shifts
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
Existing code in the VROTATE, VSL and VSR macros for the Altivec rotate and shift helpers uses a formula to compute a bit mask used to extract the rotate/shift amount from the VRB register. What is desired is:
mask = (1 << (3 + log2(sizeof(element)))) - 1
but what is implemented is:
mask = (1 << (3 + (sizeof(element)/2))) - 1
This produces correct answers when "element" is uint8_t, uint16_t or uint_32t. But it breaks down when element is uint64_t.
This patch corrects the situation. Since the mask is known at compile time, the macros are changed to simply accept the mask as an argument.
Subsequent patches in this series will add double-word variants of rotates and shifts and thus take advantage of this fix.
--- target-ppc/int_helper.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-)
target-ppc/int_helper.c +15 -25
@@ -1128,23 +1128,20 @@ VRFI(p, float_round_up) VRFI(z, float_round_to_zero)#undef VRFI -#define VROTATE (suffix, element) \ +#define VROTATE (suffix, element, mask) \ void helper_vrl##suffix(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ { \ int i; \ \ for (i = 0; i < ARRAY_SIZE(r->element); i++) { \ - unsigned int mask = ((1 << \ - (3 + (sizeof(a->element[0]) >> 1))) \ - - 1); \ unsigned int shift = b->element[i] & mask; \ r->element[i] = (a->element[i] << shift) | \ (a->element[i] >> (sizeof(a->element[0]) * 8 - shift)); \ } \ } -VROTATE(b, u8) -VROTATE(h, u16) -VROTATE(w, u32) +VROTATE(b, u8, 0x7) +VROTATE(h, u16, 0xF) +VROTATE(w, u32, 0x1F)#undef VROTATEvoid helper_vrsqrtefp (CPUPPCState *env,ppc_avr_t *r,ppc_avr_t *b)
@@ -1225,23 +1222,20 @@ VSHIFT(r, RIGHT)#undef LEFT#undef RIGHT -#define VSL (suffix, element) \ +#define VSL (suffix, element, mask) \ void helper_vsl##suffix(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ { \ int i; \ \ for (i = 0; i < ARRAY_SIZE(r->element); i++) { \ - unsigned int mask = ((1 << \ - (3 + (sizeof(a->element[0]) >> 1))) \ - - 1); \ unsigned int shift = b->element[i] & mask; \ \ r->element[i] = a->element[i] << shift; \ } \ } -VSL(b, u8) -VSL(h, u16) -VSL(w, u32) +VSL(b, u8, 0x7) +VSL(h, u16, 0x0F) +VSL(w, u32, 0x1F)#undef VSLvoid helper_vsldoi (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b,uint32_t shift)
@@ -1325,26 +1319,22 @@ VSPLTI(h, s16, int16_t) VSPLTI(w, s32, int32_t)#undef VSPLTI -#define VSR (suffix, element) \ +#define VSR (suffix, element, mask) \ void helper_vsr##suffix(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ { \ int i; \ \ for (i = 0; i < ARRAY_SIZE(r->element); i++) { \ - unsigned int mask = ((1 << \ - (3 + (sizeof(a->element[0]) >> 1))) \ - - 1); \ unsigned int shift = b->element[i] & mask; \ - \ r->element[i] = a->element[i] >> shift; \ } \ } -VSR(ab, s8) -VSR(ah, s16) -VSR(aw, s32) -VSR(b, u8) -VSR(h, u16) -VSR(w, u32) +VSR(ab, s8, 0x7) +VSR(ah, s16, 0xF) +VSR(aw, s32, 0x1F) +VSR(b, u8, 0x7) +VSR(h, u16, 0xF) +VSR(w, u32, 0x1F)#undef VSRvoid helper_vsro (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 109/130] target-ppc: Altivec 2.07: Vector Doubleword Rotate and Shift Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the vector doublword rotate and shift instructions introduced in Power ISA Version 2.07:
- Vector Rotate Left Doubleword instruction (vrld)
- Vector Shift Left Doubleword (vsld)
- Vector Shift Right Doubleword (vsrd)
- Vector Shift Right Algegbraic Doubleword (vsrad)
--- target-ppc/helper.h | 4 ++++ target-ppc/int_helper.c | 4 ++++ target-ppc/translate.c | 8 ++++++++ 3 files changed, 16 insertions(+)
target-ppc/helper.h +4 -0
@@ -184,12 +184,15 @@ DEF_HELPER_3(vmuluwm, void, avr, avr, avr) DEF_HELPER_3(vsrab, void, avr, avr, avr) DEF_HELPER_3(vsrah, void, avr, avr, avr) DEF_HELPER_3(vsraw, void, avr, avr, avr) +DEF_HELPER_3(vsrad, void, avr, avr, avr) DEF_HELPER_3(vsrb, void, avr, avr, avr) DEF_HELPER_3(vsrh, void, avr, avr, avr) DEF_HELPER_3(vsrw, void, avr, avr, avr) +DEF_HELPER_3(vsrd, void, avr, avr, avr) DEF_HELPER_3(vslb, void, avr, avr, avr) DEF_HELPER_3(vslh, void, avr, avr, avr) DEF_HELPER_3(vslw, void, avr, avr, avr) +DEF_HELPER_3(vsld, void, avr, avr, avr) DEF_HELPER_3(vslo, void, avr, avr, avr) DEF_HELPER_3(vsro, void, avr, avr, avr)DEF_HELPER_3 (vaddcuw, void, avr, avr, avr)
@@ -211,6 +214,7 @@ DEF_HELPER_4(vsubuws, void, env, avr, avr, avr) DEF_HELPER_3(vrlb, void, avr, avr, avr) DEF_HELPER_3(vrlh, void, avr, avr, avr) DEF_HELPER_3(vrlw, void, avr, avr, avr) +DEF_HELPER_3(vrld, void, avr, avr, avr) DEF_HELPER_3(vsl, void, avr, avr, avr) DEF_HELPER_3(vsr, void, avr, avr, avr)DEF_HELPER_4 (vsldoi, void, avr, avr, avr, i32)
target-ppc/int_helper.c +4 -0
@@ -1142,6 +1142,7 @@ VRFI(z, float_round_to_zero) VROTATE(b, u8, 0x7) VROTATE(h, u16, 0xF) VROTATE(w, u32, 0x1F) +VROTATE(d, u64, 0x3F)#undef VROTATEvoid helper_vrsqrtefp (CPUPPCState *env,ppc_avr_t *r,ppc_avr_t *b)
@@ -1236,6 +1237,7 @@ VSHIFT(r, RIGHT) VSL(b, u8, 0x7) VSL(h, u16, 0x0F) VSL(w, u32, 0x1F) +VSL(d, u64, 0x3F)#undef VSLvoid helper_vsldoi (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b,uint32_t shift)
@@ -1332,9 +1334,11 @@ VSPLTI(w, s32, int32_t) VSR(ab, s8, 0x7) VSR(ah, s16, 0xF) VSR(aw, s32, 0x1F) +VSR(ad, s64, 0x3F) VSR(b, u8, 0x7) VSR(h, u16, 0xF) VSR(w, u32, 0x1F) +VSR(d, u64, 0x3F)#undef VSRvoid helper_vsro (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b)
target-ppc/translate.c +8 -0
@@ -7018,12 +7018,15 @@ GEN_VXFORM(vmulesw, 4, 14);GEN_VXFORM (vslb,2 ,4 );GEN_VXFORM (vslh,2 ,5 );GEN_VXFORM (vslw,2 ,6 ); +GEN_VXFORM (vsld,2 ,23 );GEN_VXFORM (vsrb,2 ,8 );GEN_VXFORM (vsrh,2 ,9 );GEN_VXFORM (vsrw,2 ,10 ); +GEN_VXFORM (vsrd,2 ,27 );GEN_VXFORM (vsrab,2 ,12 );GEN_VXFORM (vsrah,2 ,13 );GEN_VXFORM (vsraw,2 ,14 ); +GEN_VXFORM (vsrad,2 ,15 );GEN_VXFORM (vslo,6 ,16 );GEN_VXFORM (vsro,6 ,17 );GEN_VXFORM (vaddcuw,0 ,6 );
@@ -7043,6 +7046,7 @@ GEN_VXFORM_ENV(vsubsws, 0, 30);GEN_VXFORM (vrlb,2 ,0 );GEN_VXFORM (vrlh,2 ,1 );GEN_VXFORM (vrlw,2 ,2 ); +GEN_VXFORM (vrld,2 ,3 );GEN_VXFORM (vsl,2 ,7 );GEN_VXFORM (vsr,2 ,11 );GEN_VXFORM_ENV (vpkuhum,7 ,0 );
@@ -10459,12 +10463,15 @@ GEN_VXFORM_207(vmulesw, 4, 14),GEN_VXFORM (vslb,2 ,4 ),GEN_VXFORM (vslh,2 ,5 ),GEN_VXFORM (vslw,2 ,6 ), +GEN_VXFORM_207 (vsld,2 ,23 ),GEN_VXFORM (vsrb,2 ,8 ),GEN_VXFORM (vsrh,2 ,9 ),GEN_VXFORM (vsrw,2 ,10 ), +GEN_VXFORM_207 (vsrd,2 ,27 ),GEN_VXFORM (vsrab,2 ,12 ),GEN_VXFORM (vsrah,2 ,13 ),GEN_VXFORM (vsraw,2 ,14 ), +GEN_VXFORM_207 (vsrad,2 ,15 ),GEN_VXFORM (vslo,6 ,16 ),GEN_VXFORM (vsro,6 ,17 ), GEN_VXFORM(vaddcuw, 0, 6),
@@ -10484,6 +10491,7 @@ GEN_VXFORM(vsubsws, 0, 30),GEN_VXFORM (vrlb,2 ,0 ),GEN_VXFORM (vrlh,2 ,1 ),GEN_VXFORM (vrlw,2 ,2 ), +GEN_VXFORM_207 (vrld,2 ,3 ),GEN_VXFORM (vsl,2 ,7 ),GEN_VXFORM (vsr,2 ,11 ), GEN_VXFORM(vpkuhum, 7, 0),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 110/130] target-ppc: Altivec 2.07: Quadword Addition and Subtracation
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Quadword Addition and Subtraction instructions introduced in Power ISA Version 2.07:
- Vector Add Unsigned Quadword Modulo (vadduqm)
- Vector Add & Write Carry Unsigned Quadword (vaddcuq)
- Vector Add Extended Unsigned Quadword (vaddeuqm)
- Vector Add Extended & Write Carry Unsigned Quadword (vaddecuq)
- Vector Subtract Unsigned Quadword Modulo (vsubuqm)
- Vector Subtract & Write Carry Unsigned Quadword (vsubcuq)
- Vector Subtract Extended Unsigned Quadword (vsubeuqm)
- Vector Subtract Extended & Write Carry Unsigned Quadword (vsubecuq)
--- target-ppc/helper.h | 8 +++ target-ppc/int_helper.c | 185 ++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/translate.c | 18 +++++ 3 files changed, 211 insertions(+)
target-ppc/helper.h +8 -0
@@ -211,6 +211,14 @@ DEF_HELPER_4(vadduws, void, env, avr, avr, avr) DEF_HELPER_4(vsububs, void, env, avr, avr, avr) DEF_HELPER_4(vsubuhs, void, env, avr, avr, avr) DEF_HELPER_4(vsubuws, void, env, avr, avr, avr) +DEF_HELPER_3(vadduqm, void, avr, avr, avr) +DEF_HELPER_4(vaddecuq, void, avr, avr, avr, avr) +DEF_HELPER_4(vaddeuqm, void, avr, avr, avr, avr) +DEF_HELPER_3(vaddcuq, void, avr, avr, avr) +DEF_HELPER_3(vsubuqm, void, avr, avr, avr) +DEF_HELPER_4(vsubecuq, void, avr, avr, avr, avr) +DEF_HELPER_4(vsubeuqm, void, avr, avr, avr, avr) +DEF_HELPER_3(vsubcuq, void, avr, avr, avr) DEF_HELPER_3(vrlb, void, avr, avr, avr) DEF_HELPER_3(vrlh, void, avr, avr, avr)DEF_HELPER_3 (vrlw, void, avr, avr, avr)
target-ppc/int_helper.c +185 -0
191 lines not on this page · raw message
target-ppc/translate.c +18 -0
@@ -7043,6 +7043,18 @@ GEN_VXFORM_ENV(vsubuws, 0, 26);GEN_VXFORM_ENV (vsubsbs,0 ,28 );GEN_VXFORM_ENV (vsubshs,0 ,29 );GEN_VXFORM_ENV (vsubsws,0 ,30 ); +GEN_VXFORM (vadduqm,0 ,4 ); +GEN_VXFORM (vaddcuq,0 ,5 ); +GEN_VXFORM3 (vaddeuqm,30 ,0 ); +GEN_VXFORM3 (vaddecuq,30 ,0 ); +GEN_VXFORM_DUAL (vaddeuqm,PPC_NONE ,PPC2_ALTIVEC_207 , \ + vaddecuq, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VXFORM (vsubuqm,0 ,20 ); +GEN_VXFORM (vsubcuq,0 ,21 ); +GEN_VXFORM3 (vsubeuqm,31 ,0 ); +GEN_VXFORM3 (vsubecuq,31 ,0 ); +GEN_VXFORM_DUAL (vsubeuqm,PPC_NONE ,PPC2_ALTIVEC_207 , \ + vsubecuq, PPC_NONE, PPC2_ALTIVEC_207)GEN_VXFORM (vrlb,2 ,0 );GEN_VXFORM (vrlh,2 ,1 );GEN_VXFORM (vrlw,2 ,2 );
@@ -10488,6 +10500,12 @@ GEN_VXFORM(vsubuws, 0, 26),GEN_VXFORM (vsubsbs,0 ,28 ),GEN_VXFORM (vsubshs,0 ,29 ),GEN_VXFORM (vsubsws,0 ,30 ), +GEN_VXFORM_207 (vadduqm,0 ,4 ), +GEN_VXFORM_207 (vaddcuq,0 ,5 ), +GEN_VXFORM_DUAL (vaddeuqm, vaddecuq,30 ,0xFF ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_VXFORM_207 (vsubuqm,0 ,20 ), +GEN_VXFORM_207 (vsubcuq,0 ,21 ), +GEN_VXFORM_DUAL (vsubeuqm, vsubecuq,31 ,0xFF ,PPC_NONE ,PPC2_ALTIVEC_207 ),GEN_VXFORM (vrlb,2 ,0 ),GEN_VXFORM (vrlh,2 ,1 ), GEN_VXFORM(vrlw, 2, 2),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 111/130] target-ppc: Altivec 2.07: vbpermq Instruction
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Bit Permute Quadword (vbpermq) instruction introduced in Power ISA Version 2.07.
--- target-ppc/helper.h | 1 + target-ppc/int_helper.c | 31 +++++++++++++++++++++++++++++++ target-ppc/translate.c | 2 ++ 3 files changed, 34 insertions(+)
target-ppc/helper.h +1 -0
@@ -303,6 +303,7 @@ DEF_HELPER_2(vpopcntb, void, avr, avr) DEF_HELPER_2(vpopcnth, void, avr, avr) DEF_HELPER_2(vpopcntw, void, avr, avr) DEF_HELPER_2(vpopcntd, void, avr, avr) +DEF_HELPER_3(vbpermq, void, avr, avr, avr) DEF_HELPER_2(xsadddp, void, env, i32)DEF_HELPER_2 (xssubdp, void, env, i32)
target-ppc/int_helper.c +31 -0
@@ -1039,6 +1039,37 @@ void helper_vperm(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, }#if defined(HOST_WORDS_BIGENDIAN ) +#define VBPERMQ_INDEX (avr, i) ((avr)->u8[(i)]) +#define VBPERMQ_DW (index) (((index) & 0x40) != 0) +#else +#define VBPERMQ_INDEX (avr, i) ((avr)->u8[15-(i)]) +#define VBPERMQ_DW (index) (((index) & 0x40) == 0) +#endif + +void helper_vbpermq (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b) +{ +int i; +uint64_t perm =0 ; + + VECTOR_FOR_INORDER_I(i, u8) { +int index =VBPERMQ_INDEX (b, i); + +if (index <128 ) { +uint64_t mask = (1ull << (63 -(index &0x3F ))); +if (a->u64[VBPERMQ_DW (index)] & mask) { + perm |= (0x8000 >> i); + } + } + } + + r->u64[HI_IDX ] = perm; + r->u64[LO_IDX ] =0 ; +} + +#undef VBPERMQ_INDEX +#undef VBPERMQ_DW + +#if defined(HOST_WORDS_BIGENDIAN )#define PKBIG 1#else #define PKBIG 0
target-ppc/translate.c +2 -0
@@ -7360,6 +7360,7 @@ GEN_VXFORM_DUAL(vclzw, PPC_NONE, PPC2_ALTIVEC_207, \ vpopcntw, PPC_NONE, PPC2_ALTIVEC_207) GEN_VXFORM_DUAL(vclzd, PPC_NONE, PPC2_ALTIVEC_207, \ vpopcntd, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VXFORM (vbpermq,6 ,21 );/*** VSX extension ***/
@@ -10609,6 +10610,7 @@ GEN_VXFORM_DUAL(vclzh, vpopcnth, 1, 29, PPC_NONE, PPC2_ALTIVEC_207),GEN_VXFORM_DUAL (vclzw, vpopcntw,1 ,30 ,PPC_NONE ,PPC2_ALTIVEC_207 ),GEN_VXFORM_DUAL (vclzd, vpopcntd,1 ,31 ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_VXFORM_207 (vbpermq,6 ,21 ),GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ), GEN_HANDLER_E(lxsiwax, 0x1F, 0x0C, 0x02, 0, PPC_NONE, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 112/130] target-ppc: Altivec 2.07: Doubleword Compares
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Compare Doubleword instructions introduced by Power ISA Version 2.07:
- Vector Compare Equal to Unsigned Doubleword (vcmpequd)
- Vector Compare Greater Than Signed Doubleword (vcmpgtsd)
- Vector Compare Greater Than Unsigned Doubleword (vcmpgtud)
These instructions are encoded with bit 31 set to 1 and so are duals with vcmpeqfp, vcmpgtfp and vcmpbfp respectively.
The helper macro for integer compares is enhanced to account for 64-bit operands.
--- target-ppc/helper.h | 6 ++++++ target-ppc/int_helper.c | 14 ++++++++++---- target-ppc/translate.c | 16 +++++++++++++--- 3 files changed, 29 insertions(+), 7 deletions(-)
target-ppc/helper.h +6 -0
@@ -139,12 +139,15 @@ DEF_HELPER_3(vmaxud, void, avr, avr, avr) DEF_HELPER_4(vcmpequb, void, env, avr, avr, avr) DEF_HELPER_4(vcmpequh, void, env, avr, avr, avr) DEF_HELPER_4(vcmpequw, void, env, avr, avr, avr) +DEF_HELPER_4(vcmpequd, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtub, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtuh, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtuw, void, env, avr, avr, avr) +DEF_HELPER_4(vcmpgtud, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtsb, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtsh, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtsw, void, env, avr, avr, avr) +DEF_HELPER_4(vcmpgtsd, void, env, avr, avr, avr) DEF_HELPER_4(vcmpeqfp, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgefp, void, env, avr, avr, avr)DEF_HELPER_4 (vcmpgtfp, void, env, avr, avr, avr)
@@ -152,12 +155,15 @@ DEF_HELPER_4(vcmpbfp, void, env, avr, avr, avr) DEF_HELPER_4(vcmpequb_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpequh_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpequw_dot, void, env, avr, avr, avr) +DEF_HELPER_4(vcmpequd_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtub_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtuh_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtuw_dot, void, env, avr, avr, avr) +DEF_HELPER_4(vcmpgtud_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtsb_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtsh_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgtsw_dot, void, env, avr, avr, avr) +DEF_HELPER_4(vcmpgtsd_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpeqfp_dot, void, env, avr, avr, avr) DEF_HELPER_4(vcmpgefp_dot, void, env, avr, avr, avr)DEF_HELPER_4 (vcmpgtfp_dot, void, env, avr, avr, avr)
target-ppc/int_helper.c +10 -4
@@ -626,15 +626,18 @@ VCF(sx, int32_to_float32, s32) void helper_vcmp##suffix(CPUPPCState *env, ppc_avr_t *r, \ ppc_avr_t *a, ppc_avr_t *b) \ { \ - uint32_t ones = (uint32_t)-1; \ - uint32_t all = ones; \ - uint32_t none = 0; \ + uint64_t ones = (uint64_t)-1; \ + uint64_t all = ones; \ + uint64_t none = 0; \ int i; \ \ for (i = 0; i < ARRAY_SIZE(r->element); i++) { \ - uint32_t result = (a->element[i] compare b->element[i] ? \ + uint64_t result = (a->element[i] compare b->element[i] ? \ ones : 0x0); \ switch (sizeof(a->element[0])) { \ + case 8: \ + r->u64[i] = result; \ + break; \ case 4: \ r->u32[i] = result; \ break; \
@@ -658,12 +661,15 @@ VCF(sx, int32_to_float32, s32) VCMP(equb, ==, u8) VCMP(equh, ==, u16) VCMP(equw, ==, u32) +VCMP(equd, ==, u64) VCMP(gtub, >, u8) VCMP(gtuh, >, u16) VCMP(gtuw, >, u32) +VCMP(gtud, >, u64) VCMP(gtsb, >, s8) VCMP(gtsh, >, s16) VCMP(gtsw, >, s32) +VCMP(gtsd, >, s64)#undef VCMP_DO#undef VCMP
target-ppc/translate.c +13 -3
@@ -7136,17 +7136,27 @@ static void glue(gen_, name0##_##name1)(DisasContext *ctx) \ GEN_VXRFORM(vcmpequb, 3, 0) GEN_VXRFORM(vcmpequh, 3, 1) GEN_VXRFORM(vcmpequw, 3, 2) +GEN_VXRFORM(vcmpequd, 3, 3) GEN_VXRFORM(vcmpgtsb, 3, 12) GEN_VXRFORM(vcmpgtsh, 3, 13) GEN_VXRFORM(vcmpgtsw, 3, 14) +GEN_VXRFORM(vcmpgtsd, 3, 15) GEN_VXRFORM(vcmpgtub, 3, 8) GEN_VXRFORM(vcmpgtuh, 3, 9) GEN_VXRFORM(vcmpgtuw, 3, 10) +GEN_VXRFORM(vcmpgtud, 3, 11) GEN_VXRFORM(vcmpeqfp, 3, 3) GEN_VXRFORM(vcmpgefp, 3, 7) GEN_VXRFORM(vcmpgtfp, 3, 11) GEN_VXRFORM(vcmpbfp, 3, 15) +GEN_VXRFORM_DUAL (vcmpeqfp,PPC_ALTIVEC ,PPC_NONE , \ + vcmpequd, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VXRFORM_DUAL (vcmpbfp,PPC_ALTIVEC ,PPC_NONE , \ + vcmpgtsd, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VXRFORM_DUAL (vcmpgtfp,PPC_ALTIVEC ,PPC_NONE , \ + vcmpgtud, PPC_NONE, PPC2_ALTIVEC_207) +#define GEN_VXFORM_SIMM (name, opc2, opc3) \ static void glue(gen_, name)(DisasContext *ctx) \ { \
@@ -10552,10 +10562,10 @@ GEN_VXRFORM(vcmpgtsw, 3, 14) GEN_VXRFORM(vcmpgtub, 3, 8) GEN_VXRFORM(vcmpgtuh, 3, 9) GEN_VXRFORM(vcmpgtuw, 3, 10) -GEN_VXRFORM(vcmpeqfp, 3, 3) +GEN_VXRFORM_DUAL(vcmpeqfp, vcmpequd, 3, 3, PPC_ALTIVEC, PPC_NONE) GEN_VXRFORM(vcmpgefp, 3, 7) -GEN_VXRFORM(vcmpgtfp, 3, 11) -GEN_VXRFORM(vcmpbfp, 3, 15) +GEN_VXRFORM_DUAL(vcmpgtfp, vcmpgtud, 3, 11, PPC_ALTIVEC, PPC_NONE) +GEN_VXRFORM_DUAL(vcmpbfp, vcmpgtsd, 3, 15, PPC_ALTIVEC, PPC_NONE)#undef GEN_VXFORM_SIMM#define GEN_VXFORM_SIMM (name, opc2, opc3) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 114/130] target-ppc: Altivec 2.07: Vector Polynomial Multiply Sum
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vectory Polynomial Multiply Sum instructions introduced in Power ISA Version 2.07:
- Vectory Polynomial Multiply Sum Byte (vpmsumb)
- Vectory Polynomial Multiply Sum Halfword (vpmsumh)
- Vectory Polynomial Multiply Sum Word (vpmsumw)
- Vectory Polynomial Multiply Sum Doubleword (vpmsumd)
--- target-ppc/helper.h | 4 +++ target-ppc/int_helper.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/translate.c | 8 ++++++ 3 files changed, 82 insertions(+)
target-ppc/helper.h +4 -0
@@ -311,6 +311,10 @@ DEF_HELPER_2(vpopcntw, void, avr, avr) DEF_HELPER_2(vpopcntd, void, avr, avr) DEF_HELPER_3(vbpermq, void, avr, avr, avr) DEF_HELPER_2(vgbbd, void, avr, avr) +DEF_HELPER_3(vpmsumb, void, avr, avr, avr) +DEF_HELPER_3(vpmsumh, void, avr, avr, avr) +DEF_HELPER_3(vpmsumw, void, avr, avr, avr) +DEF_HELPER_3(vpmsumd, void, avr, avr, avr) DEF_HELPER_2(xsadddp, void, env, i32)DEF_HELPER_2 (xssubdp, void, env, i32)
target-ppc/int_helper.c +70 -0
76 lines not on this page · raw message
target-ppc/translate.c +8 -0
@@ -7372,6 +7372,10 @@ GEN_VXFORM_DUAL(vclzd, PPC_NONE, PPC2_ALTIVEC_207, \ vpopcntd, PPC_NONE, PPC2_ALTIVEC_207) GEN_VXFORM(vbpermq, 6, 21);GEN_VXFORM_NOA (vgbbd,6 ,20 ); +GEN_VXFORM(vpmsumb, 4, 16) +GEN_VXFORM(vpmsumh, 4, 17) +GEN_VXFORM(vpmsumw, 4, 18) +GEN_VXFORM (vpmsumd,4 ,19 )/*** VSX extension ***/
@@ -10623,6 +10627,10 @@ GEN_VXFORM_DUAL(vclzd, vpopcntd, 1, 31, PPC_NONE, PPC2_ALTIVEC_207),GEN_VXFORM_207 (vbpermq,6 ,21 ),GEN_VXFORM_207 (vgbbd,6 ,20 ), +GEN_VXFORM_207 (vpmsumb,4 ,16 ), +GEN_VXFORM_207 (vpmsumh,4 ,17 ), +GEN_VXFORM_207 (vpmsumw,4 ,18 ), +GEN_VXFORM_207 (vpmsumd,4 ,19 ),GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ), GEN_HANDLER_E(lxsiwax, 0x1F, 0x0C, 0x02, 0, PPC_NONE, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 120/130] target-ppc/translate.c: Use ULL suffix for 64 bit constants
In reply to Alexander GrafFrom: Peter Maydell <[email protected]>
64 bit constants need the "ULL" suffix, not just "UL", because on 32 bit platforms 'long' is not large enough and this will cause a compiler warning.
--- target-ppc/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target-ppc/translate.c +2 -2
@@ -7727,8 +7727,8 @@ static void gen_xxpermdi(DisasContext *ctx)#define OP_NABS 2#define OP_NEG 3#define OP_CPSGN 4 -#define SGN_MASK_DP 0x8000000000000000ul -#define SGN_MASK_SP 0x8000000080000000ul +#define SGN_MASK_DP 0x8000000000000000ull +#define SGN_MASK_SP 0x8000000080000000ull#define VSX_SCALAR_MOVE (name, op, sgn_mask) \ static void glue(gen_, name)(DisasContext * ctx) \
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 115/130] target-ppc: Altivec 2.07: Binary Coded Decimal Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch add the Binary Coded Decimal instructions bcdadd. and bcdsub.
--- target-ppc/helper.h | 3 + target-ppc/int_helper.c | 201 ++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/translate.c | 45 ++++++++++- 3 files changed, 245 insertions(+), 4 deletions(-)
target-ppc/helper.h +3 -0
@@ -316,6 +316,9 @@ DEF_HELPER_3(vpmsumh, void, avr, avr, avr) DEF_HELPER_3(vpmsumw, void, avr, avr, avr) DEF_HELPER_3(vpmsumd, void, avr, avr, avr) +DEF_HELPER_4(bcdadd, i32, avr, avr, avr, i32) +DEF_HELPER_4(bcdsub, i32, avr, avr, avr, i32) + DEF_HELPER_2(xsadddp, void, env, i32) DEF_HELPER_2(xssubdp, void, env, i32)DEF_HELPER_2 (xsmuldp, void, env, i32)
target-ppc/int_helper.c +201 -0
207 lines not on this page · raw message
target-ppc/translate.c +41 -4
63 lines not on this page · raw message
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 118/130] target-ppc: Altivec 2.07: Vector Permute and Exclusive OR
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Permuate and Exclusive OR (vpermxor) instruction introduced in Power ISA Version 2.07.
--- target-ppc/helper.h | 1 + target-ppc/int_helper.c | 14 ++++++++++++++ target-ppc/translate.c | 7 ++++++- 3 files changed, 21 insertions(+), 1 deletion(-)
target-ppc/helper.h +1 -0
@@ -323,6 +323,7 @@ DEF_HELPER_3(vncipher, void, avr, avr, avr) DEF_HELPER_3(vncipherlast, void, avr, avr, avr) DEF_HELPER_3(vshasigmaw, void, avr, avr, i32) DEF_HELPER_3(vshasigmad, void, avr, avr, i32) +DEF_HELPER_4(vpermxor, void, avr, avr, avr, avr) DEF_HELPER_4(bcdadd, i32, avr, avr, avr, i32)DEF_HELPER_4 (bcdsub, i32, avr, avr, avr, i32)
target-ppc/int_helper.c +14 -0
@@ -2700,6 +2700,20 @@ void helper_vshasigmad(ppc_avr_t *r, ppc_avr_t *a, uint32_t st_six)#undef ROTRu64#undef EL_IDX +void helper_vpermxor (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b,ppc_avr_t *c) +{ +int i; + VECTOR_FOR_INORDER_I(i, u8) { +int indexA = c->u8[i] >>4 ; +int indexB = c->u8[i] &0xF ; +#if defined(HOST_WORDS_BIGENDIAN ) + r->u8[i] = a->u8[indexA] ^ b->u8[indexB]; +#else + r->u8[i] = a->u8[15 -indexA] ^ b->u8[15 -indexB]; +#endif + } +} +#undef VECTOR_FOR_INORDER_I#undef HI_IDX#undef LO_IDX
target-ppc/translate.c +6 -1
@@ -7459,6 +7459,10 @@ static void gen_##op(DisasContext *ctx) \ VSHASIGMA(vshasigmaw) VSHASIGMA(vshasigmad) +GEN_VXFORM3(vpermxor, 22, 0xFF) +GEN_VXFORM_DUAL(vsldoi, PPC_ALTIVEC, PPC_NONE, + vpermxor, PPC_NONE, PPC2_ALTIVEC_207) + /*** VSX extension ***/ static inline TCGv_i64 cpu_vsrh(int n)
@@ -10111,7 +10115,6 @@ GEN_HANDLER(lvsl, 0x1f, 0x06, 0x00, 0x00000001, PPC_ALTIVEC),GEN_HANDLER (lvsr,0x1f ,0x06 ,0x01 ,0x00000001 ,PPC_ALTIVEC ),GEN_HANDLER (mfvscr,0x04 ,0x2 ,0x18 ,0x001ff800 ,PPC_ALTIVEC ),GEN_HANDLER (mtvscr,0x04 ,0x2 ,0x19 ,0x03ff0000 ,PPC_ALTIVEC ), -GEN_HANDLER (vsldoi,0x04 ,0x16 ,0xFF ,0x00000400 ,PPC_ALTIVEC ),GEN_HANDLER (vmladduhm,0x04 ,0x11 ,0xFF ,0x00000000 ,PPC_ALTIVEC ),GEN_HANDLER2 (evsel0,"evsel" ,0x04 ,0x1c ,0x09 ,0x00000000 ,PPC_SPE ), GEN_HANDLER2(evsel1, "evsel", 0x04, 0x1d, 0x09, 0x00000000, PPC_SPE),
@@ -10722,6 +10725,8 @@ GEN_VXFORM_DUAL(vncipher, vncipherlast, 4, 21, PPC_NONE, PPC2_ALTIVEC_207),GEN_VXFORM_207 (vshasigmaw,1 ,26 ),GEN_VXFORM_207 (vshasigmad,1 ,27 ), +GEN_VXFORM_DUAL (vsldoi, vpermxor,22 ,0xFF ,PPC_ALTIVEC ,PPC_NONE ), +GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ),GEN_HANDLER_E (lxsiwax,0x1F ,0x0C ,0x02 ,0 ,PPC_NONE ,PPC2_VSX207 ), GEN_HANDLER_E(lxsiwzx, 0x1F, 0x0C, 0x00, 0, PPC_NONE, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 119/130] spapr-vlan: flush queue whenever can_receive can go from false to true
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
When the guests adds buffers to receive queue, the network device should flush its queue of pending packets. This is done with qemu_flush_queued_packets.
This adds a call to qemu_flush_queued_packets() which wakes up the main loop and let QEMU update the network device status which now is "can receive". The patch basically does the same thing as e8b4c68 does.
--- hw/net/spapr_llan.c | 2 ++ 1 file changed, 2 insertions(+)
hw/net/spapr_llan.c +2 -0
@@ -405,6 +405,8 @@ static target_ulong h_add_logical_lan_buffer(PowerPCCPU *cpu, dev->rx_bufs++; +qemu_flush_queued_packets (qemu_get_queue (dev->nic)); +DPRINTF ("h_add_logical_lan_buffer(): Added buf ptr=%d rx_bufs=%d" " bd=0x%016llx\n" , dev->add_buf_ptr, dev->rx_bufs, (unsigned long long )buf);
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 113/130] target-ppc: Altivec 2.07: Vector Gather Bits by Bytes
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector Gather Bits by Bytes Doubleword (vgbbd) instruction which is introduced in Power ISA Version 2.07.
--- target-ppc/helper.h | 1 + target-ppc/int_helper.c | 276 ++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/translate.c | 2 + 3 files changed, 279 insertions(+)
target-ppc/helper.h +1 -0
@@ -310,6 +310,7 @@ DEF_HELPER_2(vpopcnth, void, avr, avr) DEF_HELPER_2(vpopcntw, void, avr, avr) DEF_HELPER_2(vpopcntd, void, avr, avr) DEF_HELPER_3(vbpermq, void, avr, avr, avr) +DEF_HELPER_2(vgbbd, void, avr, avr) DEF_HELPER_2(xsadddp, void, env, i32)DEF_HELPER_2 (xssubdp, void, env, i32)
target-ppc/int_helper.c +276 -0
282 lines not on this page · raw message
target-ppc/translate.c +2 -0
@@ -7371,6 +7371,7 @@ GEN_VXFORM_DUAL(vclzw, PPC_NONE, PPC2_ALTIVEC_207, \GEN_VXFORM_DUAL (vclzd,PPC_NONE ,PPC2_ALTIVEC_207 , \ vpopcntd, PPC_NONE, PPC2_ALTIVEC_207)GEN_VXFORM (vbpermq,6 ,21 ); +GEN_VXFORM_NOA (vgbbd,6 ,20 );/*** VSX extension ***/
@@ -10621,6 +10622,7 @@ GEN_VXFORM_DUAL(vclzw, vpopcntw, 1, 30, PPC_NONE, PPC2_ALTIVEC_207),GEN_VXFORM_DUAL (vclzd, vpopcntd,1 ,31 ,PPC_NONE ,PPC2_ALTIVEC_207 ),GEN_VXFORM_207 (vbpermq,6 ,21 ), +GEN_VXFORM_207 (vgbbd,6 ,20 ),GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ), GEN_HANDLER_E(lxsiwax, 0x1F, 0x0C, 0x02, 0, PPC_NONE, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 116/130] target-ppc: Altivec 2.07: AES Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector AES instructions introduced in Power ISA Version 2.07:
- Vector AES Cipher (vcipher)
- Vector AES Cipher Last (vcipherlast)
- Vector AES Inverse Cipher (vncipher)
- Vector AES Inverse Cipher Last (vncipherlast)
- Vector AES SubBytes (vsbox)
Note that the implementation of vncipher deviates from the RTL in ISA V2.07. However it does match the verbal description in the third paragraph. The RTL will be fixed in ISA V2.07B. The implementation here has been tested against actual P8 hardware.
--- target-ppc/helper.h | 6 ++ target-ppc/int_helper.c | 280 ++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/translate.c | 29 +++++ 3 files changed, 315 insertions(+)
target-ppc/helper.h +6 -0
@@ -316,6 +316,12 @@ DEF_HELPER_3(vpmsumh, void, avr, avr, avr) DEF_HELPER_3(vpmsumw, void, avr, avr, avr) DEF_HELPER_3(vpmsumd, void, avr, avr, avr) +DEF_HELPER_2(vsbox, void, avr, avr) +DEF_HELPER_3(vcipher, void, avr, avr, avr) +DEF_HELPER_3(vcipherlast, void, avr, avr, avr) +DEF_HELPER_3(vncipher, void, avr, avr, avr) +DEF_HELPER_3(vncipherlast, void, avr, avr, avr) + DEF_HELPER_4(bcdadd, i32, avr, avr, avr, i32)DEF_HELPER_4 (bcdsub, i32, avr, avr, avr, i32)
target-ppc/int_helper.c +280 -0
286 lines not on this page · raw message
target-ppc/translate.c +29 -0
@@ -7414,6 +7414,30 @@ GEN_VXFORM_DUAL(vsubuhm, PPC_ALTIVEC, PPC_NONE, \GEN_VXFORM_DUAL (vsubuhs,PPC_ALTIVEC ,PPC_NONE , \ bcdsub, PPC_NONE, PPC2_ALTIVEC_207) +static void gen_vsbox (DisasContext *ctx) +{ +TCGv_ptr ra, rd; +if (unlikely (!ctx->altivec_enabled)) { +gen_exception (ctx,POWERPC_EXCP_VPU ); +return ; + } + ra =gen_avr_ptr (rA (ctx->opcode)); + rd =gen_avr_ptr (rD (ctx->opcode)); +gen_helper_vsbox (rd, ra); +tcg_temp_free_ptr (ra); +tcg_temp_free_ptr (rd); +} + +GEN_VXFORM(vcipher, 4, 20) +GEN_VXFORM(vcipherlast, 4, 20) +GEN_VXFORM(vncipher, 4, 21) +GEN_VXFORM(vncipherlast, 4, 21) + +GEN_VXFORM_DUAL (vcipher,PPC_NONE ,PPC2_ALTIVEC_207 , + vcipherlast, PPC_NONE, PPC2_ALTIVEC_207) +GEN_VXFORM_DUAL (vncipher,PPC_NONE ,PPC2_ALTIVEC_207 , + vncipherlast,PPC_NONE ,PPC2_ALTIVEC_207 ) + /*** VSX extension ***/static inline TCGv_i64 cpu_vsrh (int n)
@@ -10669,6 +10693,11 @@ GEN_VXFORM_207(vpmsumh, 4, 17),GEN_VXFORM_207 (vpmsumw,4 ,18 ),GEN_VXFORM_207 (vpmsumd,4 ,19 ), +GEN_VXFORM_207 (vsbox,4 ,23 ), + +GEN_VXFORM_DUAL (vcipher, vcipherlast,4 ,20 ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_VXFORM_DUAL (vncipher, vncipherlast,4 ,21 ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ),GEN_HANDLER_E (lxsiwax,0x1F ,0x0C ,0x02 ,0 ,PPC_NONE ,PPC2_VSX207 ), GEN_HANDLER_E(lxsiwzx, 0x1F, 0x0C, 0x00, 0, PPC_NONE, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 117/130] target-ppc: Altivec 2.07: Vector SHA Sigma Instructions
In reply to Alexander GrafFrom: Tom Musta <[email protected]>
This patch adds the Vector SHA Sigma instructions introduced in Power ISA Version 2.07:
- Vector SHA-512 Sigma Doubleword (vshasigmad)
- Vector SHA-256 Sigma Word (vshasigmaw)
--- target-ppc/helper.h | 2 ++ target-ppc/int_helper.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/translate.c | 24 +++++++++++++++ 3 files changed, 108 insertions(+)
target-ppc/helper.h +2 -0
@@ -321,6 +321,8 @@ DEF_HELPER_3(vcipher, void, avr, avr, avr) DEF_HELPER_3(vcipherlast, void, avr, avr, avr) DEF_HELPER_3(vncipher, void, avr, avr, avr) DEF_HELPER_3(vncipherlast, void, avr, avr, avr) +DEF_HELPER_3(vshasigmaw, void, avr, avr, i32) +DEF_HELPER_3(vshasigmad, void, avr, avr, i32) DEF_HELPER_4(bcdadd, i32, avr, avr, avr, i32)DEF_HELPER_4 (bcdsub, i32, avr, avr, avr, i32)
target-ppc/int_helper.c +82 -0
88 lines not on this page · raw message
target-ppc/translate.c +24 -0
@@ -7438,6 +7438,27 @@ GEN_VXFORM_DUAL(vcipher, PPC_NONE, PPC2_ALTIVEC_207,GEN_VXFORM_DUAL (vncipher,PPC_NONE ,PPC2_ALTIVEC_207 , vncipherlast, PPC_NONE, PPC2_ALTIVEC_207) +#define VSHASIGMA (op) \ +static void gen_##op(DisasContext *ctx) \ +{ \ + TCGv_ptr ra, rd; \ + TCGv_i32 st_six; \ + if (unlikely(!ctx->altivec_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VPU); \ + return; \ + } \ + ra = gen_avr_ptr(rA(ctx->opcode)); \ + rd = gen_avr_ptr(rD(ctx->opcode)); \ + st_six = tcg_const_i32(rB(ctx->opcode)); \ + gen_helper_##op(rd, ra, st_six); \ + tcg_temp_free_ptr(ra); \ + tcg_temp_free_ptr(rd); \ + tcg_temp_free_i32(st_six); \ +} + +VSHASIGMA(vshasigmaw) +VSHASIGMA(vshasigmad) + /*** VSX extension ***/ static inline TCGv_i64 cpu_vsrh(int n)
@@ -10698,6 +10719,9 @@ GEN_VXFORM_207(vsbox, 4, 23),GEN_VXFORM_DUAL (vcipher, vcipherlast,4 ,20 ,PPC_NONE ,PPC2_ALTIVEC_207 ),GEN_VXFORM_DUAL (vncipher, vncipherlast,4 ,21 ,PPC_NONE ,PPC2_ALTIVEC_207 ), +GEN_VXFORM_207 (vshasigmaw,1 ,26 ), +GEN_VXFORM_207 (vshasigmad,1 ,27 ), +GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ),GEN_HANDLER_E (lxsiwax,0x1F ,0x0C ,0x02 ,0 ,PPC_NONE ,PPC2_VSX207 ), GEN_HANDLER_E(lxsiwzx, 0x1F, 0x0C, 0x00, 0, PPC_NONE, PPC2_VSX207),
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 121/130] PPC: sPAPR: Only use getpagesize() when we run with kvm
In reply to Alexander GrafWe currently size the msi window trap page according to the host's page size so that we poke a working hole into a memory slot in case we overlap.
However, this is only ever necessary with KVM active. Without KVM, we should rather try to be host platform agnostic and use a constant size: 4k.
This fixes a build breakage on win32 hosts.
--- hw/ppc/spapr_pci.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
hw/ppc/spapr_pci.c +12 -1
@@ -469,6 +469,8 @@ static const MemoryRegionOps spapr_msi_ops = {void spapr_pci_msi_init (sPAPREnvironment *spapr,hwaddr addr) { +uint64_t window_size =4096 ; +/* * As MSI/MSIX interrupts trigger by writing at MSI/MSIX vectors, * we need to allocate some memory to catch those writes coming
@@ -476,10 +478,19 @@ void spapr_pci_msi_init(sPAPREnvironment *spapr, hwaddr addr)* As MSIMessage:addr is going to be the same and MSIMessage:data * is going to be a VIRQ number, 4 bytes of the MSI MR will only * be used. +* +* For KVM we want to ensure that this memory is a full page so that +* our memory slot is of page size granularity. */ +#ifdef CONFIG_KVM +if (kvm_enabled ()) { + window_size =getpagesize (); + } +#endif + spapr->msi_win_addr = addr;memory_region_init_io (&spapr->msiwindow,NULL , &spapr_msi_ops, spapr, -"msi" ,getpagesize ()); +"msi" , window_size);memory_region_add_subregion (get_system_memory (), spapr->msi_win_addr, &spapr->msiwindow); }
Signature · 1 line
1.8.1.4