Re: [PATCH v2 08/12] target/arm/cpu: remove TARGET_BIG_ENDIAN dependency

2025-04-30 Thread Anton Johansson via
On 30/04/25, Pierrick Bouvier wrote: > Signed-off-by: Pierrick Bouvier > --- > target/arm/cpu.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/target/arm/cpu.c b/target/arm/cpu.c > index 07f279fec8c..37b11e8866f 100644 > --- a/target/arm/cpu.c > +++ b/target/arm/cpu.c

Re: [PATCH 09/13] target/arm/cpu: get endianness from cpu state

2025-04-29 Thread Anton Johansson via
On 29/04/25, Pierrick Bouvier wrote: > Remove TARGET_BIG_ENDIAN dependency. > > Signed-off-by: Pierrick Bouvier > --- > target/arm/cpu.c | 22 +++--- > 1 file changed, 11 insertions(+), 11 deletions(-) > > diff --git a/target/arm/cpu.c b/target/arm/cpu.c > index e7a15ade8b4..85e

Re: [PATCH v3 11/13] physmem: Restrict TCG IOTLB code to TCG accel

2025-04-28 Thread Anton Johansson via
On 28/04/25, Richard Henderson wrote: > On 4/28/25 11:51, Anton Johansson wrote: > > On 24/04/25, Philippe Mathieu-Daudé wrote: > > > Restrict iotlb_to_section(), address_space_translate_for_iotlb() > > > and memory_region_section_get_iotlb() to TCG. Declare them in > > > the new "accel/tcg/iommu.h

Re: [PATCH v3 11/13] physmem: Restrict TCG IOTLB code to TCG accel

2025-04-28 Thread Anton Johansson via
On 24/04/25, Philippe Mathieu-Daudé wrote: > Restrict iotlb_to_section(), address_space_translate_for_iotlb() > and memory_region_section_get_iotlb() to TCG. Declare them in > the new "accel/tcg/iommu.h" header. Declare iotlb_to_section() > using the MemoryRegionSection typedef. > > Signed-off-by:

Re: [PATCH v3 06/13] accel/tcg: Compile tb-maint.c twice

2025-04-28 Thread Anton Johansson via
On 24/04/25, Philippe Mathieu-Daudé wrote: > From: Richard Henderson > > Signed-off-by: Richard Henderson > Message-ID: <20250424011918.599958-16-richard.hender...@linaro.org> > Signed-off-by: Philippe Mathieu-Daudé > --- > accel/tcg/tb-hash.h | 3 +-- > accel/tcg/tb-maint.c | 2 -- > accel

Re: [PATCH v3 05/13] include/exec: Move tb_invalidate_phys_range to translation-block.h

2025-04-28 Thread Anton Johansson via
On 24/04/25, Philippe Mathieu-Daudé wrote: > From: Richard Henderson > > Signed-off-by: Richard Henderson > Reviewed-by: Philippe Mathieu-Daudé > Message-ID: <20250424011918.599958-15-richard.hender...@linaro.org> > Signed-off-by: Philippe Mathieu-Daudé > --- > include/exec/exec-all.h

Re: [PATCH v3 02/13] accel/tcg: Use vaddr in user/page-protection.h

2025-04-28 Thread Anton Johansson via
On 24/04/25, Philippe Mathieu-Daudé wrote: > From: Richard Henderson > > Signed-off-by: Richard Henderson > Message-ID: <20250424011918.599958-14-richard.hender...@linaro.org> > Signed-off-by: Philippe Mathieu-Daudé > --- > include/user/page-protection.h | 17 +--- > accel/tcg/user-exe

Re: [PATCH v3 09/13] accel/tcg: Include 'accel/tcg/getpc.h' in 'exec/helper-proto'

2025-04-28 Thread Anton Johansson via
On 24/04/25, Philippe Mathieu-Daudé wrote: > Most files including "exec/helper-proto.h" call GETPC(). > Include it there (in the common part) instead of the > unspecific "exec/exec-all.h" header. > > Signed-off-by: Philippe Mathieu-Daudé > --- > include/exec/exec-all.h| 1 - > includ

Re: [RFC PATCH-for-10.1 4/4] tcg: Define guest_default_memory_order in TCGCPUOps

2025-04-05 Thread Anton Johansson via
On 21/03/25, Philippe Mathieu-Daudé wrote: > Add the TCGCPUOps::guest_default_memory_order field and have > each target initialize it. > > Use it to set TCGContext::guest_mo in tb_gen_code(), removing > the need for the TCG_GUEST_DEFAULT_MO definition. > > Signed-off-by: Philippe Mathieu-Daudé >

[PATCH v2 1/2] target/hexagon: Replace `prepare` script with meson target

2025-04-02 Thread Anton Johansson via
The purpose of the prepare script is to invoke `cpp` to preprocess input to idef-parser by expanding a few select macros. On macOS `cpp` expands into `clang ... -traditional-cpp` which breaks macro concatenation. Replace `cpp` with `${compiler} -E` and replace the script with a meson custom_targe

[PATCH v2 2/2] target/hexagon: Only indent on linux

2025-04-02 Thread Anton Johansson via
indent on macOS, installed via homebrew, doesn't support -linux. Only run indent on linux hosts. Signed-off-by: Anton Johansson --- target/hexagon/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build index abcf00c

[PATCH v2 0/2] target/hexagon: Fix macOS build

2025-04-02 Thread Anton Johansson via
A default macOS build with xcode cli tools installed lacks the `indent` program needed by the idef-parser postprocess step. If `indent` is installed through homebrew it doesn't support the `-linux` flag. Conditionally run `indent` only on linux hosts. Additionally `cpp` used by the idef-parser pre

Re: [RFC PATCH-for-10.1 0/4] tcg: Move TCG_GUEST_DEFAULT_MO -> TCGCPUOps::guest_default_memory_order

2025-03-26 Thread Anton Johansson via
On 21/03/25, Philippe Mathieu-Daudé wrote: > Hi, > > In this series we replace the TCG_GUEST_DEFAULT_MO definition > from "cpu-param.h" by a 'guest_default_memory_order' field in > TCGCPUOps. > > Since tcg_req_mo() now accesses tcg_ctx, this impact the > cpu_req_mo() calls in accel/tcg/{cputlb,us

Re: [PATCH-for-10.1 0/8] target/mips: Make 'cpu-qom.h' target agnostic

2025-03-26 Thread Anton Johansson via
On 25/03/25, Philippe Mathieu-Daudé wrote: > - Remove the TARGET_MIPS64 use in 'cpu-qom.h' to > make it target agnostic > - Introduce mips_cpu_is_64bit() as a runtime check > for compile time TARGET_MIPS64 definition > - Replace the ldtul_p() gdbstub call by ldn_p() > - Rename few symbols to av

Re: [PATCH 2/2] target/hexagon: Drop `ident` postprocess step

2025-03-26 Thread &#x27;Anton Johansson' via
On 25/03/25, Brian Cain wrote: > > On 3/24/2025 8:53 PM, ltaylorsimp...@gmail.com wrote: > > > > > -Original Message- > > > From: Anton Johansson > > > Sent: Wednesday, March 12, 2025 2:46 PM > > > To: qemu-devel@nongnu.org > > > Cc: a...@rev.ng; ltaylorsimp...@gmail.com; brian.c...@oss.

Re: [PATCH-for-10.1 4/4] tcg: Convert TARGET_SUPPORTS_MTTCG to TCGCPUOps::mttcg_supported field

2025-03-21 Thread Anton Johansson via
On 21/03/25, Philippe Mathieu-Daudé wrote: > Instead of having a compile-time TARGET_SUPPORTS_MTTCG definition, > have each target set the 'mttcg_supported' field in the TCGCPUOps > structure. > > Since so far we only emulate one target architecture at a time, > tcg_init_machine() gets whether MTT

Re: [RFC PATCH-for-10.1 3/4] tcg: Have tcg_req_mo() use runtime TCGContext::guest_mo

2025-03-21 Thread Anton Johansson via
On 21/03/25, Philippe Mathieu-Daudé wrote: > In order to use TCG with multiple targets, replace the > compile time use of TCG_GUEST_DEFAULT_MO by a runtime > access to tcg_ctx->guest_mo. > > Signed-off-by: Philippe Mathieu-Daudé > --- > accel/tcg/internal-target.h | 4 +--- > 1 file changed, 1 i

Re: [PATCH-for-10.1 3/4] tcg: Convert TCGState::mttcg_enabled to TriState

2025-03-21 Thread Anton Johansson via
On 21/03/25, Philippe Mathieu-Daudé wrote: > Use the OnOffAuto type as 3-state. > > Since the TCGState instance is zero-initialized, the > mttcg_enabled is initialzed as AUTO (ON_OFF_AUTO_AUTO). > > In tcg_init_machine(), if mttcg_enabled is still AUTO, > set a default value (effectively inlining

Re: [PATCH-for-10.1 2/4] tcg: Simplify tcg_req_mo() macro

2025-03-21 Thread Anton Johansson via
On 21/03/25, Philippe Mathieu-Daudé wrote: > Now that TCG_GUEST_DEFAULT_MO is always defined, > simplify the tcg_req_mo() macro. > > Signed-off-by: Philippe Mathieu-Daudé > --- > accel/tcg/internal-target.h | 9 + > accel/tcg/tcg-all.c | 3 --- > 2 files changed, 1 insertion(+),

Re: [PATCH-for-10.1 1/4] tcg: Always define TCG_GUEST_DEFAULT_MO

2025-03-21 Thread Anton Johansson via
On 21/03/25, Philippe Mathieu-Daudé wrote: > We only require the TCG_GUEST_DEFAULT_MO for MTTCG-enabled > frontends, otherwise we use a default value of TCG_MO_ALL. > > In order to simplify, require the definition for all targets, > defining it for hexagon, m68k, rx, sh4 and tricore. > > Signed-o

[PATCH 2/2] target/hexagon: Drop `ident` postprocess step

2025-03-12 Thread Anton Johansson via
The indent command is not available on a default mac osx setup with xcode cli tools installed. While it does make idef-parser generated code nicer to debug, it's not crucial and can be dropped. Signed-off-by: Anton Johansson --- target/hexagon/meson.build | 21 ++--- 1 file chan

[PATCH 1/2] target/hexagon: Replace `prepare` script with meson target

2025-03-12 Thread Anton Johansson via
The purpose of the prepare script is to invoke `cpp` to preprocess input to idef-parser by expanding a few select macros. On mac osx `cpp` expands into `clang ... -traditional-cpp` which breaks macro concatenation. Replace `cpp` with `${compiler} -E` and replace the script with a meson custom_tar

[PATCH 0/2] target/hexagon: Fix macOS build

2025-03-12 Thread Anton Johansson via
A default macOS build with xcode cli tools installed lacks the `indent` program needed by the idef-parser postprocess step, remove this step. Additionally `cpp` used by the idef-parser preprocess step expands into `clang ... -traditional-cpp` and doesn't support macro concatenation among other th

Re: [PATCH-for-10.1 0/2] target/hexagon: Remove use of MO_TE definition

2025-03-12 Thread Anton Johansson via
On 12/03/25, Philippe Mathieu-Daudé wrote: > In order to make QEMU core components endian agnostic, > we need to remove the use of the target-specific MO_TE > definition. For Hexagon it is easy as it is equivalent > of MO_LE, since the target is only little-endian. > > Philippe Mathieu-Daudé (2):

Re: [PATCH 6/8] target/hexagon: add build config for softmmu

2025-03-04 Thread Anton Johansson via
On 04/03/25, Philippe Mathieu-Daudé wrote: > > On default macOS I get: > > Program bison found: NO found 2.3 but need: '>=3.0' (/usr/bin/bison) > > Fixed by installing via brew and: > > export PATH=/opt/homebrew/opt/bison/bin:$PATH > > > @@ -401,3 +409,4 @@ analyze_funcs_generated = custom_

Re: [PATCH v3 10/17] hw/arm/xlnx-zynqmp: Use &error_abort for programming errors

2025-02-04 Thread Anton Johansson via
On 04/02/25, Philippe Mathieu-Daudé wrote: > ping for trivial review? > > On 8/11/24 16:43, Philippe Mathieu-Daudé wrote: > > When a property value is static (not provided by QMP or CLI), > > error shouldn't happen, otherwise it is a programming error. > > Therefore simplify and use &error_abort a

[PATCH 1/2] target/hexagon: Use argparse in all python scripts

2024-12-06 Thread Anton Johansson via
QOL commit, all the various gen_* python scripts take a large set arguments where order is implicit. Using argparse we also get decent error messages if a field is missing or too many are added. Signed-off-by: Anton Johansson Reviewed-by: Brian Cain --- target/hexagon/gen_analyze_funcs.py

[PATCH 0/2] Misc Hexagon QOL

2024-12-06 Thread Anton Johansson via
Separate submission of patches 35 and 37 from the helper-to-tcg patchset: https://lore.kernel.org/qemu-devel/20241121014947.18666-1-a...@rev.ng/ Anton Johansson (2): target/hexagon: Use argparse in all python scripts target/hexagon: Make HVX vector args. restrict * target/hexagon/gen_anal

[PATCH 2/2] target/hexagon: Make HVX vector args. restrict *

2024-12-06 Thread Anton Johansson via
Adds restrict qualifier to HVX pointer arguments. This will allow the compiler to produce better optimized code, as input vectors are now assumed not to alias, and no runtime aliasing checks will be required. Signed-off-by: Anton Johansson Reviewed-by: Brian Cain --- target/hexagon/mmvec/macros

Re: [RFC PATCH v1 03/43] accel/tcg: Add gvec size changing operations

2024-12-03 Thread Anton Johansson via
On 03/12/24, Richard Henderson wrote: > On 12/3/24 12:08, Anton Johansson wrote: > > On 22/11/24, Richard Henderson wrote: > > > On 11/20/24 19:49, Anton Johansson wrote: > > > > Adds new functions to the gvec API for truncating, sign- or zero > > > > extending vector elements. Currently implement

Re: [RFC PATCH v1 01/43] Add option to enable/disable helper-to-tcg

2024-12-03 Thread Anton Johansson via
On 22/11/24, Paolo Bonzini wrote: > On 11/22/24 18:30, Richard Henderson wrote: > > On 11/20/24 19:49, Anton Johansson wrote: > > > Adds a meson option for enabling/disabling helper-to-tcg along with a > > > CONFIG_* definition. > > > > > > CONFIG_* will in future commits be used to conditionally

Re: [RFC PATCH v1 08/43] include/helper-to-tcg: Introduce annotate.h

2024-12-03 Thread Anton Johansson via
On 25/11/24, Philippe Mathieu-Daudé wrote: > On 22/11/24 19:12, Richard Henderson wrote: > > On 11/20/24 19:49, Anton Johansson wrote: > > > Wrap __attribute__((annotate(str))) in a macro for convenient > > > function annotations.  Will be used in future commits to tag functions > > > for translati

Re: [RFC PATCH v1 00/43] Introduce helper-to-tcg

2024-12-03 Thread Anton Johansson via
On 25/11/24, Philippe Mathieu-Daudé wrote: > On 21/11/24 02:49, Anton Johansson wrote: > > > create mode 100644 subprojects/helper-to-tcg/README.md > > create mode 100755 subprojects/helper-to-tcg/get-llvm-ir.py > > create mode 100644 subprojects/helper-to-tcg/include/CmdLineOptions.h > >

Re: [RFC PATCH v1 37/43] target/hexagon: Make HVX vector args. restrict *

2024-12-03 Thread Anton Johansson via
On 25/11/24, Paolo Bonzini wrote: > On 11/25/24 12:36, Philippe Mathieu-Daudé wrote: > > > +#define QeV  (*(MMQReg * restrict)(QeV_void)) > > > +#define QdV  (*(MMQReg * restrict)(QdV_void)) > > > +#define QsV  (*(MMQReg * restrict)(QsV_void)) > > > +#define QtV  (*(MMQReg * restric

Re: [RFC PATCH v1 36/43] target/hexagon: Add temporary vector storage

2024-12-03 Thread Anton Johansson via
On 22/11/24, Richard Henderson wrote: > On 11/20/24 19:49, Anton Johansson wrote: > > Temporary vectors in helper-to-tcg generated code are allocated from an > > array of bytes in CPUArchState, specified with --temp-vector-block. > > > > This commits adds such a block of memory to CPUArchState, if

Re: [RFC PATCH v1 34/43] target/hexagon: Add get_tb_mmu_index()

2024-12-03 Thread Anton Johansson via
On 22/11/24, Richard Henderson wrote: > On 11/20/24 19:49, Anton Johansson wrote: > > Adds a functions to return the current mmu index given tb_flags of the > > current translation block. Required by helper-to-tcg in order to > > retrieve the mmu index for memory operations without changing the >

Re: [RFC PATCH v1 28/43] helper-to-tcg: Introduce TcgType.h

2024-12-03 Thread Anton Johansson via
On 22/11/24, Richard Henderson wrote: > On 11/20/24 19:49, Anton Johansson via wrote: > > Adds a struct representing everything a LLVM value might map to in TCG, > > this includes: > > > >* TCGv (IrValue); > >* TCGv_ptr (IrPtr); > >* TCGv_

Re: [RFC PATCH v1 09/43] helper-to-tcg: Introduce get-llvm-ir.py

2024-12-03 Thread Anton Johansson via
On 22/11/24, Richard Henderson wrote: > On 11/20/24 19:49, Anton Johansson wrote: > > Introduces a new python helper script to convert a set of QEMU .c files to > > LLVM IR .ll using clang. Compile flags are found by looking at > > compile_commands.json, and llvm-link is used to link together all

Re: [RFC PATCH v1 05/43] tcg: Add helper function dispatcher and hook tcg_gen_callN

2024-12-03 Thread Anton Johansson via
On 22/11/24, Richard Henderson wrote: > On 11/20/24 19:49, Anton Johansson wrote: > > Adds a function pointer to the TCGContext which may be set by targets via > > the TARGET_HELPER_DISPATCHER macro. The dispatcher is function > > > >(void *func, TCGTemp *ret, int nargs, TCGTemp **args) -> bo

Re: [RFC PATCH v1 04/43] tcg: Add gvec functions for creating consant vectors

2024-12-03 Thread Anton Johansson via
On 22/11/24, Richard Henderson wrote: > On 11/20/24 19:49, Anton Johansson wrote: > > This commit adds a gvec function for copying data from constant array > > given in C to a gvec intptr_t. For each element, a host store of > > each constant is performed, this is not ideal and will inflate TBs fo

Re: [RFC PATCH v1 03/43] accel/tcg: Add gvec size changing operations

2024-12-03 Thread Anton Johansson via
On 22/11/24, Richard Henderson wrote: > On 11/20/24 19:49, Anton Johansson wrote: > > Adds new functions to the gvec API for truncating, sign- or zero > > extending vector elements. Currently implemented as helper functions, > > these may be mapped onto host vector instructions in the future. > >

Re: [RFC PATCH v1 02/43] accel/tcg: Add bitreverse and funnel-shift runtime helper functions

2024-12-03 Thread Anton Johansson via
On 22/11/24, Richard Henderson wrote: > On 11/20/24 19:49, Anton Johansson wrote: > > Adds necessary helper functions for mapping LLVM IR onto TCG. > > Specifically, helpers corresponding to the bitreverse and funnel-shift > > intrinsics in LLVM. > > > > Note: these may be converted to more effici

Re: [PATCH-for-10.0 6/6] accel/tcg: Allow tcg_exec_realizefn() initialize multiple frontends

2024-11-27 Thread Anton Johansson via
On 27/11/24, Philippe Mathieu-Daudé wrote: > Rather than initializing the first random target architecture > and ignore the following ones when a global boolean is set, > use a bitmask allowing different frontend targets to be > initialized. > > Signed-off-by: Philippe Mathieu-Daudé > --- > acce

Re: [PATCH-for-10.0 5/6] accel/tcg: Add TCGCPUOps::arch_id field

2024-11-27 Thread Anton Johansson via
On 27/11/24, Philippe Mathieu-Daudé wrote: > When using multiple TCG frontends concurrently, we need to > be able to discriminate by target architecture. While we > can infer that from the CPUClass, it can be quicker to get > it from a direct field in TCGCPUOps. > > Signed-off-by: Philippe Mathieu

Re: [PATCH-for-10.0 2/6] accel/tcg: Declare local tcg_ops variable in tcg_exec_realizefn()

2024-11-27 Thread Anton Johansson via
On 27/11/24, Philippe Mathieu-Daudé wrote: > Ease reading code by declaring a local 'tcg_ops' variable. > > Signed-off-by: Philippe Mathieu-Daudé > --- > accel/tcg/cpu-exec.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) Reviewed-by: Anton Johansson

Re: [PATCH-for-10.0 1/6] target/ppc: Indent ppc_tcg_ops[] with 4 spaces

2024-11-27 Thread Anton Johansson via
On 27/11/24, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé > Acked-by: Nicholas Piggin > --- > target/ppc/cpu_init.c | 29 ++--- > 1 file changed, 14 insertions(+), 15 deletions(-) Reviewed-by: Anton Johansson

[RFC PATCH v1 37/43] target/hexagon: Make HVX vector args. restrict *

2024-11-20 Thread Anton Johansson via
If pointer arguments to HVX helper functions are not marked restrict *, then LLVM will assume that input vectors may alias and emit runtime checks. Signed-off-by: Anton Johansson --- target/hexagon/mmvec/macros.h | 36 +-- 1 file changed, 18 insertions(+), 18 dele

[RFC PATCH v1 10/43] helper-to-tcg: Add meson.build

2024-11-20 Thread Anton Johansson via
Sets up a barebones meson.build that handles: 1. Exposing command for converting .c files to LLVM IR by looking at compile_commads.json; 2. Finding LLVM and verifying the LLVM version manually by running llvm-config, needed for dealing with multiple LLVM versions in a sane way;

[RFC PATCH v1 08/43] include/helper-to-tcg: Introduce annotate.h

2024-11-20 Thread Anton Johansson via
Wrap __attribute__((annotate(str))) in a macro for convenient function annotations. Will be used in future commits to tag functions for translation by helper-to-tcg, and to specify which helper function arguments correspond to immediate or vector values. Signed-off-by: Anton Johansson --- inclu

[RFC PATCH v1 22/43] helper-to-tcg: PrepareForTcgPass, remove functions w. cycles

2024-11-20 Thread Anton Johansson via
Functions with cycles are removed for two primary reasons: * as a simplifying assumption for register allocation which occurs down the line, and; * if a function contains cycles post-optimization neither unrolling or loop vectorization were beneficial, and the function _might_ be

[RFC PATCH v1 41/43] target/hexagon: Manually call generated HVX instructions

2024-11-20 Thread Anton Johansson via
For HVX instructions that were successfully translated by helper-to-tcg, emit calls to emit_*() "manually" from generate_*(). Recall that scalar instructions translated by helper-to-tcg are automatically called by a hook in tcg_gen_callN. Signed-off-by: Anton Johansson --- target/hexagon/gen_tc

[RFC PATCH v1 09/43] helper-to-tcg: Introduce get-llvm-ir.py

2024-11-20 Thread Anton Johansson via
Introduces a new python helper script to convert a set of QEMU .c files to LLVM IR .ll using clang. Compile flags are found by looking at compile_commands.json, and llvm-link is used to link together all LLVM modules into a single module. Signed-off-by: Anton Johansson --- subprojects/helper-to

[RFC PATCH v1 12/43] helper-to-tcg: Introduce custom LLVM pipeline

2024-11-20 Thread Anton Johansson via
Adds a custom pipeline, similar to LLVM opt, with the goal of taking an input LLVM IR module to an equivalent output .c file implementing functions in TCG. Initial LLVM boilerplate is added until the creation of a ModulePassManager. A custom target derived from x64 is added, to ensure consistent

[RFC PATCH v1 24/43] helper-to-tcg: PrepareForTcgPass, map TCG globals

2024-11-20 Thread Anton Johansson via
The input LLVM module may define an array of cpu_mapping structs, describing the mapping between fields in a specified struct (usually CPUArchState) and TCG globals. Create a map between offsets into the specified struct and TCG globals (name, size, number of elements, stride) by iterating over th

[RFC PATCH v1 42/43] target/hexagon: Only translate w. idef-parser if helper-to-tcg failed

2024-11-20 Thread Anton Johansson via
Only generate input functions to idef-parser for instructions which failed to be translated by helper-to-tcg. Signed-off-by: Anton Johansson --- target/hexagon/gen_idef_parser_funcs.py | 6 ++ 1 file changed, 6 insertions(+) diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hex

[RFC PATCH v1 16/43] helper-to-tcg: PrepareForOptPass, Cull unused functions

2024-11-20 Thread Anton Johansson via
Make an early pass over all functions in the input module and filter out functions with: 1. Invalid return type; 2. No helper-to-tcg annotation. Signed-off-by: Anton Johansson --- .../helper-to-tcg/include/PrepareForOptPass.h | 7 +- .../PrepareForOptPass/PrepareForOptPass.cpp | 93 ++

[RFC PATCH v1 04/43] tcg: Add gvec functions for creating consant vectors

2024-11-20 Thread Anton Johansson via
This commit adds a gvec function for copying data from constant array given in C to a gvec intptr_t. For each element, a host store of each constant is performed, this is not ideal and will inflate TBs for large vectors. Moreover, data will be copied during each run of the generated code impactin

[RFC PATCH v1 40/43] target/hexagon: Emit annotations for helpers

2024-11-20 Thread Anton Johansson via
Adds the following LLVM_ANNOTATE attributes to helper functions generated by Hexagon: 1. "helper-to-tcg", to specify that a given helper functions should be translated, and; 2. "immediate: ..." to make sure immediate arguments to helper functions remain immediates in the emitted TCG

[RFC PATCH v1 13/43] helper-to-tcg: Introduce Error.h

2024-11-20 Thread Anton Johansson via
Simple function for creating Expected<> with nice error messages. Signed-off-by: Anton Johansson --- subprojects/helper-to-tcg/include/Error.h | 40 +++ 1 file changed, 40 insertions(+) create mode 100644 subprojects/helper-to-tcg/include/Error.h diff --git a/subprojects/he

[RFC PATCH v1 17/43] helper-to-tcg: PrepareForOptPass, undef llvm.returnaddress

2024-11-20 Thread Anton Johansson via
Convert llvm.returnaddress arguments to cpu_[ld|st]*() to undef, causing the LLVM optmizer to discard the intrinsics. Needed as llvm.returnadress is not representable in TCG, and usually results from usage of GETPC() in helper functions. Signed-off-by: Anton Johansson --- .../PrepareForOptPass/

[RFC PATCH v1 31/43] helper-to-tcg: Introduce TcgGenPass

2024-11-20 Thread Anton Johansson via
Adds a backend pass, taking previously optimized and canonicalized LLVM IR and for each function: 1. Runs the TcgV register allocator; 2. Iterates over instructions and calls appropriate functions in TcgEmit.h to emit TCG code. Signed-off-by: Anton Johansson --- .../helper-to-tcg/incl

[RFC PATCH v1 14/43] helper-to-tcg: Introduce PrepareForOptPass

2024-11-20 Thread Anton Johansson via
Adds a new LLVM pass that runs early in the pipeline with the goal of preparing the input module for optimization by doing some early culling of functions and information gathering. This commits sets up a new LLVM pass over the IR module and runs it from the pipeline. Signed-off-by: Anton Johanss

[RFC PATCH v1 11/43] helper-to-tcg: Introduce llvm-compat

2024-11-20 Thread Anton Johansson via
Adds a translation unit with the sole purpose of handling inter-LLVM code changes. Instead of littering the code with #ifdefs, most of them will be limited to llvm-compat.[cpp|h] and a saner compat::*() function is exposed in its place. Signed-off-by: Anton Johansson --- subprojects/helper-to-t

[RFC PATCH v1 15/43] helper-to-tcg: PrepareForOptPass, map annotations

2024-11-20 Thread Anton Johansson via
In the LLVM IR module function annotations are stored in one big global array of strings. Traverse this array and parse the data into a format more useful for future passes. A map between Functions * and a list of annotations is exposed. Signed-off-by: Anton Johansson --- .../include/FunctionA

[RFC PATCH v1 33/43] helper-to-tcg: Add end-to-end tests

2024-11-20 Thread Anton Johansson via
Introduces simple end-to-end tests of helper-to-tcg of functions the translator is expected to handle, any translation failure will result in a test failure. More test cases to come. Signed-off-by: Anton Johansson --- subprojects/helper-to-tcg/meson.build | 2 + subprojects/helper-to-

[RFC PATCH v1 34/43] target/hexagon: Add get_tb_mmu_index()

2024-11-20 Thread Anton Johansson via
Adds a functions to return the current mmu index given tb_flags of the current translation block. Required by helper-to-tcg in order to retrieve the mmu index for memory operations without changing the signature of helper functions. Signed-off-by: Anton Johansson --- target/hexagon/cpu.h | 12 +

[RFC PATCH v1 23/43] helper-to-tcg: PrepareForTcgPass, demote phi nodes

2024-11-20 Thread Anton Johansson via
PHI nodes have no clear analogue in TCG, this commits converts them to stack accesses using a built-in LLVM transformation. Signed-off-by: Anton Johansson --- .../PrepareForTcgPass/PrepareForTcgPass.cpp | 24 +++ 1 file changed, 24 insertions(+) diff --git a/subprojects/helpe

[RFC PATCH v1 26/43] helper-to-tcg: PrepareForTcgPass, canonicalize IR

2024-11-20 Thread Anton Johansson via
Iterates over the IR with the goal of converting it to a form closer to TCG, taking care of IR disparencies between LLVM and TCG. This also simplifies the backend by containing the bulk of custom IR transformations, meaning the backend can be as dumb as possible. Signed-off-by: Anton Johansson -

[RFC PATCH v1 01/43] Add option to enable/disable helper-to-tcg

2024-11-20 Thread Anton Johansson via
Adds a meson option for enabling/disabling helper-to-tcg along with a CONFIG_* definition. CONFIG_* will in future commits be used to conditionally include the helper-to-tcg subproject, and to remove unneeded code/memory when helper-to-tcg is not in use. Current meson option is limited to Hexagon

[RFC PATCH v1 30/43] helper-to-tcg: TcgGenPass, introduce TcgEmit.[cpp|h]

2024-11-20 Thread Anton Johansson via
A new translation unit is added with the purpose of containing all code which emits strings of TCG code. The idea is that maintainence of the backend will be simpler if all "tcg_*(*)" strings are contained and wrapped in functions. Signed-off-by: Anton Johansson --- .../helper-to-tcg/include/Cm

[RFC PATCH v1 43/43] target/hexagon: Use helper-to-tcg

2024-11-20 Thread Anton Johansson via
Modifies meson.build to use helper-to-tcg for automatic translation of helper functions. Any helper functions with the "helper-to-tcg" attribute will be automatically translated to TCG. Order of code generation is changed, and helper functions are always generated first, for all instructions. He

[RFC PATCH v1 06/43] tcg: Introduce tcg-global-mappings

2024-11-20 Thread Anton Johansson via
Adds a cpu_mapping struct to describe, in a declarative fashion, the mapping between fields in a struct, and a corresponding TCG global. As such, tcg_global_mem_new() can be automatically called given an array of cpu_mappings. This change is not limited to helper-to-tcg, but will be required in f

[RFC PATCH v1 03/43] accel/tcg: Add gvec size changing operations

2024-11-20 Thread Anton Johansson via
Adds new functions to the gvec API for truncating, sign- or zero extending vector elements. Currently implemented as helper functions, these may be mapped onto host vector instructions in the future. For the time being, allows translation of more complicated vector instructions by helper-to-tcg.

[RFC PATCH v1 28/43] helper-to-tcg: Introduce TcgType.h

2024-11-20 Thread Anton Johansson via
Adds a struct representing everything a LLVM value might map to in TCG, this includes: * TCGv (IrValue); * TCGv_ptr (IrPtr); * TCGv_env (IrEnv); * TCGLabel (IrLabel); * tcg_constant_*() (IrConst); * 123123ull (IrImmediate); * intptr_t gvec_vector (IrPtrToOffset). NOTE: Patch is subj

[RFC PATCH v1 25/43] helper-to-tcg: PrepareForTcgPass, transform GEPs

2024-11-20 Thread Anton Johansson via
getelementpointer (GEP) instructions in LLVM IR represent general pointer arithmetic (struct field access, array indexing, ...). From the perspective of TCG, three distinct cases are important and are transformed into pseudo instructions respectively: * struct accesses whose offset into the str

[RFC PATCH v1 32/43] helper-to-tcg: Add README

2024-11-20 Thread Anton Johansson via
Signed-off-by: Anton Johansson --- subprojects/helper-to-tcg/README.md | 265 1 file changed, 265 insertions(+) create mode 100644 subprojects/helper-to-tcg/README.md diff --git a/subprojects/helper-to-tcg/README.md b/subprojects/helper-to-tcg/README.md new file mo

[RFC PATCH v1 36/43] target/hexagon: Add temporary vector storage

2024-11-20 Thread Anton Johansson via
Temporary vectors in helper-to-tcg generated code are allocated from an array of bytes in CPUArchState, specified with --temp-vector-block. This commits adds such a block of memory to CPUArchState, if CONFIG_HELPER_TO_TCG is set. Signed-off-by: Anton Johansson --- target/hexagon/cpu.h | 4

[RFC PATCH v1 00/43] Introduce helper-to-tcg

2024-11-20 Thread Anton Johansson via
Hi all, this patchset introduces helper-to-tcg, a LLVM based build-time C to TCG translator, as a QEMU subproject. The purpose of this tool is to simplify implementation of instructions in TCG by automatically translating helper functions for a given target to TCG. It may also be used as a standa

[RFC PATCH v1 02/43] accel/tcg: Add bitreverse and funnel-shift runtime helper functions

2024-11-20 Thread Anton Johansson via
Adds necessary helper functions for mapping LLVM IR onto TCG. Specifically, helpers corresponding to the bitreverse and funnel-shift intrinsics in LLVM. Note: these may be converted to more efficient implementations in the future, but for the time being it allows helper-to-tcg to support a wider s

[RFC PATCH v1 20/43] helper-to-tcg: Introduce pseudo instructions

2024-11-20 Thread Anton Johansson via
"pseudo" instructions makes it easy to add custom instructions to LLVM IR in the form of calls to undefined functions. These will be used in future commits to express functionality present in TCG that is missing from LLVM IR (certain vector ops.), or to simplify the backend by collecting similar i

[RFC PATCH v1 35/43] target/hexagon: Use argparse in all python scripts

2024-11-20 Thread Anton Johansson via
QOL commit, all the various gen_* python scripts take a large set arguments where order is implicit. Using argparse we also get decent error messages if a field is missing or too many are added. Signed-off-by: Anton Johansson --- target/hexagon/gen_analyze_funcs.py | 6 +++-- target/hexago

[RFC PATCH v1 38/43] target/hexagon: Use cpu_mapping to map env -> TCG

2024-11-20 Thread Anton Johansson via
Replaces previous calls to tcg_global_mem_new*() with a declarative global array of cpu_mapping structs. This array can be used to initialize all TCG globals with one function call from the target, and may additionally be used from LLVM based tools to map between offsets into a struct and a mapped

[RFC PATCH v1 39/43] target/hexagon: Keep gen_slotval/check_noshuf for helper-to-tcg

2024-11-20 Thread Anton Johansson via
Makes sure gen_slotval() and check_noshuf() remains defined when helper-to-tcg and idef-parser are both used. gen_slotval() is needed for creating a TCGv of the slot value fed to helpers (generated helper-to-tcg code), and check_noshuf() is needed for helper definitions used as input to helper-to-

[RFC PATCH v1 29/43] helper-to-tcg: Introduce TCG register allocation

2024-11-20 Thread Anton Johansson via
Based on the assumption of a cycle free IR, this commit adds a simple register allocator for emitted values in TCG. The goal of this pass is to reduce the number of temporaries required in the output code, which is especially important when dealing with gvec vectors as to not require very large am

[RFC PATCH v1 05/43] tcg: Add helper function dispatcher and hook tcg_gen_callN

2024-11-20 Thread Anton Johansson via
Adds a function pointer to the TCGContext which may be set by targets via the TARGET_HELPER_DISPATCHER macro. The dispatcher is function (void *func, TCGTemp *ret, int nargs, TCGTemp **args) -> bool which allows targets to hook the generation of helper calls in TCG and take over translation.

[RFC PATCH v1 21/43] helper-to-tcg: Introduce PrepareForTcgPass

2024-11-20 Thread Anton Johansson via
Adds a new pass over the LLVM module which runs post-optimization with the end-goal of: * culling functions which aren't worth translating; * canonicalizing the IR to something closer to TCG, and; * extracting information which may be useful in the backend pass. This commits sets up a new LL

[RFC PATCH v1 27/43] helper-to-tcg: PrepareForTcgPass, identity map trivial expressions

2024-11-20 Thread Anton Johansson via
Transformation of the IR, identity mapping trivial expressions which would amount to nothing more than a move when emitted as TCG, but is required in LLVM IR to not break the IR. Trivial expressions are mapped to a @IdentityMap pseudo instruction allowing them to be dealt with in a uniform manner

[RFC PATCH v1 19/43] helper-to-tcg: Pipeline, run optimization pass

2024-11-20 Thread Anton Johansson via
Run a standard LLVM -Os optimization pass, which makes up the bulk of optimizations in helper-to-tcg. Signed-off-by: Anton Johansson --- subprojects/helper-to-tcg/pipeline/Pipeline.cpp | 12 1 file changed, 12 insertions(+) diff --git a/subprojects/helper-to-tcg/pipeline/Pipeline.c

[RFC PATCH v1 18/43] helper-to-tcg: PrepareForOptPass, Remove noinline attribute

2024-11-20 Thread Anton Johansson via
When producing LLVM IR using clang -O0, a noinline attribute is added. Remove this attribute to not inhibit future optimization. Signed-off-by: Anton Johansson --- .../passes/PrepareForOptPass/PrepareForOptPass.cpp | 7 +++ 1 file changed, 7 insertions(+) diff --git a/subprojects/h

[RFC PATCH v1 07/43] tcg: Increase maximum TB size and maximum temporaries

2024-11-20 Thread Anton Johansson via
Doubles amount of space allocated for translation blocks. This is needed, particularly for Hexagon, where a single instruction packet may consist of up to four vector instructions. If each vector instruction then gets expanded into gvec operations that utilize a small host vector size the TB blow

Re: [PATCH 11/19] hw/timer/xilinx_timer: Allow down to 8-bit memory access

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > Allow down to 8-bit access, per the datasheet (reference added > in previous commit): > > "Timer Counter registers are accessed as one of the following types: > • Byte (8 bits) > • Half word (2 bytes) > • Word (4 bytes)" > > Signed-off-by: Phili

Re: [PATCH 10/19] hw/timer/xilinx_timer: Only expect big-endian accesses

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > Per the datasheet (reference added in file header, p.10): > 'Register Data Types and Organization': > > "The XPS Timer/Counter registers are organized as big-endian data." > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/timer/xilinx_timer.c |

Re: [PATCH 09/19] hw/intc/xilinx_intc: Only expect big-endian accesses

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > Per the datasheet (reference added in file header, p.9) > 'Programming Model' -> 'Register Data Types and Organization': > > "The XPS INTC registers are read as big-endian data" > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/intc/xilinx_int

Re: [PATCH 08/19] hw/microblaze: Propagate CPU endianness to microblaze_load_kernel()

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > Pass vCPU endianness as argument so we can load kernels > with different endianness (different from the qemu-system-binary > builtin one). > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/microblaze/boot.h | 4 ++-- > hw/microb

Re: [PATCH 07/19] hw/microblaze: Restrict MemoryRegionOps are implemented as 32-bit

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > All these MemoryRegionOps read() and write() handlers are > implemented expecting 32-bit accesses. Clarify that setting > .impl.min/max_access_size fields. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/char/xilinx_uartlite.c | 4 > hw/intc

Re: [PATCH 05/19] hw/microblaze/s3adsp1800: Declare machine type using DEFINE_TYPES macro

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > Replace DEFINE_MACHINE() by DEFINE_TYPES(), converting the > class_init() handler. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/microblaze/petalogix_s3adsp1800_mmu.c | 17 +++-- > 1 file changed, 15 insertions(+), 2 deletions(-) R

Re: [PATCH 02/19] hw/microblaze: Deprecate big-endian petalogix-ml605 & xlnx-zynqmp-pmu

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > The petalogix-ml605 machine was explicitly added as little-endian only > machine in commit 00914b7d970 ("microblaze: Add PetaLogix ml605 MMU > little-endian ref design"). Mark the big-endian version as deprecated. > > When the xlnx-zynqmp-pmu machine's

Re: [PATCH 01/19] target/microblaze: Rename CPU endianness property as 'little-endian'

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > Rename the 'endian' property as 'little-endian' because the 'ENDI' > bit is set when the endianness is in little order, and unset in > big order. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/microblaze/petalogix_ml605_mmu.c | 2 +- > hw/microb

Re: [PATCH 04/19] hw/microblaze/s3adsp1800: Rename unimplemented MMIO region as xps_gpio

2024-11-05 Thread Anton Johansson via
On 05/11/24, Philippe Mathieu-Daudé wrote: > The machine datasheet mentions the GPIO device as 'xps_gpio'. > Rename it accordingly to easily find its documentation. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/microblaze/petalogix_s3adsp1800_mmu.c | 2 +- > 1 file changed, 1 insertion(+)

Re: [PATCH 1/2] target/hexagon: Rename macros.inc -> macros.h.inc

2024-09-10 Thread Anton Johansson via
On 10/09/24, Philippe Mathieu-Daudé wrote: > Since commits 139c1837db ("meson: rename included C source files > to .c.inc") and 0979ed017f ("meson: rename .inc.h files to .h.inc"), > EMU standard procedure for included header files is to use *.h.inc. > > Besides, since commit 6a0057aa22 ("docs/dev

  1   2   3   4   5   6   >