### Run Slothy Examples Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/general.md General command pattern to execute specific assembly optimization examples provided in the Slothy repository. Users can list all available examples by passing the help flag. ```bash python3 example.py --examples={YOUR_EXAMPLE} python3 example.py --help ``` -------------------------------- ### Run SLOTHY Examples Source: https://github.com/slothy-optimizer/slothy/blob/main/README.md Executes example assembly snippets using the SLOTHY optimizer via its Python script. Replace YOUR_EXAMPLE with the desired example name. ```bash python3 example.py --examples={YOUR_EXAMPLE} ``` -------------------------------- ### Execute SLOTHY optimization example Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/index.md Runs a specific assembly optimization example using the Python CLI. This command verifies the installation and invokes the constraint solver to minimize stalls in the provided assembly snippet. ```bash python3 example.py --examples aarch64_simple0_a55 ``` -------------------------------- ### Install Development Requirements Source: https://github.com/slothy-optimizer/slothy/blob/main/README.md Installs the project's dependencies using pip from the requirements.txt file. It's recommended to use a virtual environment for this. ```bash python3 -m venv venv ./venv/bin/python3 -m pip install -r requirements.txt ``` -------------------------------- ### Install SLOTHY via Command Line Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/tutorial/README.md This sequence of commands clones the SLOTHY repository, initializes a Python virtual environment, and installs the required dependencies. It ensures a clean, isolated environment for running the optimizer. ```bash git clone https://github.com/slothy-optimizer/slothy cd slothy python3 -m venv venv source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Example Assembly Code for SLOTHY Source: https://github.com/slothy-optimizer/slothy/blob/main/README.md A minimal example of assembly code that can be optimized by SLOTHY. It defines start and end labels for the optimization process. ```assembly start_label: ldr x0, [x1] ldr x2, [x3] add x4, x0, x2 str x4, [x5] end_label: ``` -------------------------------- ### Install SLOTHY using pip Source: https://github.com/slothy-optimizer/slothy/blob/main/README.md Installs the SLOTHY optimizer package from the Python Package Index (PyPI) using pip. This is the recommended method for most users. ```bash pip install slothy ``` -------------------------------- ### Complete NTT Optimization Example (Python) Source: https://context7.com/slothy-optimizer/slothy/llms.txt A comprehensive example demonstrating the optimization of a Number Theoretic Transform (NTT) implementation for cryptographic applications like Kyber. It involves loading the source, configuring various optimization parameters like software pipelining and register reservation, and then optimizing multiple layers of the NTT. ```python import slothy import slothy.targets.aarch64.aarch64_neon as AArch64_Neon import slothy.targets.aarch64.cortex_a55 as Target_CortexA55 # Create optimizer instance s = slothy.Slothy(AArch64_Neon, Target_CortexA55) s.load_source_from_file("examples/naive/aarch64/kyber/ntt_kyber_123_4567.s") # Configure for loop optimization s.config.sw_pipelining.enabled = True s.config.sw_pipelining.optimize_preamble = True s.config.sw_pipelining.optimize_postamble = True s.config.sw_pipelining.minimize_overlapping = False s.config.inputs_are_outputs = True s.config.variable_size = True s.config.constraints.stalls_first_attempt = 64 # Reserve registers used by calling convention s.config.reserved_regs = [f"x{i}" for i in range(0, 7)] + ["x30", "sp"] # Optimize both NTT layers s.optimize_loop("layer123_start") # Layers 1, 2, 3 s.optimize_loop("layer4567_start") # Layers 4, 5, 6, 7 ``` -------------------------------- ### Configure Input and Output Renaming Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.core.config.md Examples of setting up rename_inputs and rename_outputs dictionaries to control how symbolic and architectural registers are mapped during optimization. ```python config.rename_inputs = {"in": "r0", "arch": "static", "symbolic": "any"} config.rename_outputs = {"other": "any"} ``` -------------------------------- ### GET /slothy/targets/riscv/rv32_64_b_instructions/generate Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.riscv.rv32_64_b_instructions.md Generates all instruction classes for the RV32/64 pseudo instructions. ```APIDOC ## GET /slothy/targets/riscv/rv32_64_b_instructions/generate ### Description Generates all instruction classes for the RV32/64 pseudo instructions, enabling support for the bit manipulation extension set. ### Method GET ### Endpoint /slothy/targets/riscv/rv32_64_b_instructions/generate ### Parameters None ### Request Example {} ### Response #### Success Response (200) - **instructions** (list) - A list of generated instruction classes for the RV32/64-B extension. #### Response Example { "status": "success", "data": ["rol", "ror", "andn", "orn", "xnor", "pack", "packh", "rori", "brev8"] } ``` -------------------------------- ### Verify Development Installation Source: https://github.com/slothy-optimizer/slothy/blob/main/README.md Runs a test script to verify the development installation of SLOTHY. This command executes a specific test case for AArch64 architecture. ```bash python3 test.py --tests aarch64_simple0_a55 ``` -------------------------------- ### Assembly Rescheduling Example Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/tutorial/README.md This snippet shows an example of assembly code before and after optimization by Slothy. The comments indicate the original source and a visual representation of instruction movement. Slothy aims to reduce stalls by rescheduling instructions, potentially renaming registers to enable better interleaving. ```assembly // sqrdmulh v11.8h, v11.8h, v0.h[1] // .......*............ // mls v24.8h, v11.8h, v1.h[0] // ...........*........ // sub v11.8h, v10.8h, v24.8h // .................*.. // add v10.8h, v10.8h, v24.8h // ...............*.... // str q8, [x0], #4*16 // ..............*..... // str q9, [x0, #-3*16] // ................*... // str q10, [x0, #-2*16] // ..................*. // str q11, [x0, #-1*16] // ...................* ``` -------------------------------- ### Verify SLOTHY Installation Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/tutorial/README.md Executes the test suite to verify that the SLOTHY installation is functional. It runs a specific test case to ensure all dependencies and core logic are correctly configured. ```bash python3 test.py --tests simple0_a55 ``` -------------------------------- ### Configure SLOTHY Optimization Parameters Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.core.config.md Example of how to structure the configuration object for the SLOTHY optimizer. This includes settings for LLVM MCA integration, solver timeouts, and heuristic splitting. ```json { "sw_pipelining": { "enabled": true }, "with_llvm_mca": true, "compiler_binary": "/usr/bin/clang", "timeout": 30, "split_heuristic": true, "split_heuristic_factor": 4, "do_address_fixup": true } ``` -------------------------------- ### Stepwise Assembly Performance Profiling Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/tutorial/README.md An example of a performance profiling output generated by the pqax framework. It maps individual assembly instructions to their execution timing, allowing for visual analysis of instruction latency and dependency chains. ```asm ldr q0, [x1, #0] ldr q8, [x0, #0*16] ldr q9, [x0, #1*16] ldr q10, [x0, #2*16] ldr q11, [x0, #3*16] mul v12.8h, v9.8h, v0.h[0] sqrdmulh v9.8h, v9.8h, v0.h[1] mls v12.8h, v9.8h, v1.h[0] sub v9.8h, v8.8h, v12.8h add v8.8h, v8.8h, v12.8h mul v12.8h, v11.8h, v0.h[0] sqrdmulh v11.8h, v11.8h, v0.h[1] mls v12.8h, v11.8h, v1.h[0] sub v11.8h, v10.8h, v12.8h add v10.8h, v10.8h, v12.8h str q8, [x0], #4*16 str q9, [x0, #-3*16] ``` -------------------------------- ### Define ARM v8.1-M MVE Instruction Classes Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v81m.arch_v81m.md Example implementation of instruction classes for ARM v8.1-M, defining patterns and register dependencies for MVE operations. ```python class veor(MVEInstruction): pattern = 'veor.
, , ' inputs = ['Qn', 'Qm'] outputs = ['Qd'] class vstrw(MVEInstruction): pattern = 'vstrw.
, [, ]' inputs = ['Qd', 'Rn'] @classmethod def make(cls, src): pass def write(self): pass class vstrw_with_writeback(MVEInstruction): pattern = 'vstrw.
, [, ]!' inputs = ['Qd'] in_outs = ['Rn'] ``` -------------------------------- ### Define ARMv7-M Instruction Classes Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v7m.arch_v7m.md Example of defining an instruction class for ARMv7-M in Slothy, specifying the pattern, inputs, and outputs. ```python class pkhbt(Armv7mLogical): pattern = 'pkhbt , , ' inputs = ['Ra', 'Rb'] outputs = ['Rd'] class ldr_with_imm(Armv7mLoadInstruction): pattern = 'ldr , [, ]' inputs = ['Ra'] outputs = ['Rd'] @classmethod def make(cls, src): pass def write(self): pass ``` -------------------------------- ### Initialize SLOTHY Optimizer Source: https://context7.com/slothy-optimizer/slothy/llms.txt Demonstrates how to instantiate the Slothy class with specific architecture and microarchitecture models, configure parameters, and perform optimization on a source file. ```python import slothy import slothy.targets.aarch64.aarch64_neon as AArch64_Neon import slothy.targets.aarch64.cortex_a55 as Target_CortexA55 s = slothy.Slothy(AArch64_Neon, Target_CortexA55) s.load_source_from_file("input.s") s.config.variable_size = True s.config.constraints.stalls_first_attempt = 32 s.optimize(start="start_label", end="end_label") s.write_source_to_file("output_optimized.s") ``` -------------------------------- ### Clone SLOTHY Repository for Development Source: https://github.com/slothy-optimizer/slothy/blob/main/README.md Clones the SLOTHY optimizer repository from GitHub. This is necessary for development installations or running provided examples. ```bash git clone https://github.com/slothy-optimizer/slothy.git ``` -------------------------------- ### Complete Slothy Docker Setup Sequence Source: https://github.com/slothy-optimizer/slothy/blob/main/paper/artifact/README.md A consolidated sequence of bash commands to build the Slothy Docker image, verify its creation, run a container, check the running container, and access its shell. This provides a complete workflow for setting up the Slothy environment via Docker. ```bash docker build -f slothy.Dockerfile -t slothy_image . docker image ls docker run --name slothy_container -d -it slothy_image /bin/bash docker container ls docker exec -it slothy_container /bin/bash ``` -------------------------------- ### RISC-V BranchLoop Class: Start and End Loop Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.riscv.riscv.md Implements loop starting and ending logic for RISC-V architecture using the BranchLoop class. The start method emits initial instructions and jump labels, while the end method handles the compare-and-branch instruction, which is part of the loop body in this experimental loop type. ```python class BranchLoop(Loop): """More general loop type that just considers the branch instruction as part of the boundary. This can help to improve performance as the instructions that belong to handling the loop can be considered by SLOTHY as well. NOTE This loop type is still rather experimental. It has a lot of logic inside as it needs to be able to “understand” a variety of different ways to express loops, e.g., how counters get incremented, how registers marking the end of the loop need to be modified in case of software pipelining etc. Example: ```asm loop_lbl: {code} bltu , , loop_lbl ``` where cnt is the loop counter that gets incremented within the loop body. """ def start(loop_cnt, indentation=0, fixup=0, unroll=1, jump_if_empty=None, preamble_code=None, body_code=None, postamble_code=None, register_aliases=None): """Emit starting instruction(s) and jump label for loop""" pass def end(other, indentation=0): """Nothing to do here - the branch instruction is already part of the body""" pass ``` -------------------------------- ### Neoverse N1 Performance Metrics Functions Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.aarch64.neoverse_n1_experimental.md Provides functions to retrieve performance-related metrics for the Neoverse N1 target. This includes functions to add constraints, check for min/max objectives, get latency, get execution units, and get inverse throughput. These functions are crucial for the Slothy optimizer to model CPU behavior accurately. ```python def add_further_constraints(slothy): pass def has_min_max_objective(config): pass def get_min_max_objective(slothy): pass def get_latency(src, out_idx, dst): pass def get_units(src): pass def get_inverse_throughput(src): pass ``` -------------------------------- ### POST /instruction/build Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.aarch64.aarch64_neon.md Attempts to parse a raw assembly string into a specific instruction instance using the instruction factory. ```APIDOC ## POST /instruction/build ### Description Attempts to parse a string as an instance of a target instruction class. This is the primary entry point for converting assembly lines into structured instruction objects. ### Method POST ### Endpoint /instruction/build ### Parameters #### Request Body - **c** (any) - Required - The target instruction class to parse as. - **src** (string) - Required - The raw assembly string to parse. - **mnemonic** (string) - Required - The mnemonic associated with the instruction. ### Request Example { "c": "AArch64Instruction", "src": "add v0.4s, v1.4s, v2.4s", "mnemonic": "add" } ### Response #### Success Response (200) - **instruction** (object) - The parsed instruction instance. #### Response Example { "status": "success", "instruction": { "type": "AArch64Instruction", "mnemonic": "add" } } ``` -------------------------------- ### Use slothy-cli for Assembly Optimization Source: https://context7.com/slothy-optimizer/slothy/llms.txt This section provides examples of using the `slothy-cli` command-line interface for optimizing assembly files. It covers basic optimization, specifying code sections, setting configuration options via flags, enabling LLVM MCA, and activating debug mode. ```bash # Basic optimization slothy-cli Arm_AArch64 Arm_Cortex_A55 input.s -o output.s # Optimize a specific loop slothy-cli Arm_AArch64 Arm_Cortex_A55 input.s -o output.s \ --loop loop_start # Optimize code between start/end labels slothy-cli Arm_AArch64 Arm_Cortex_A55 input.s -o output.s \ --start start_label --end end_label # Set configuration options slothy-cli Arm_AArch64 Arm_Cortex_A55 input.s -o output.s \ -c sw_pipelining.enabled=True \ -c variable_size=True \ -c constraints.stalls_first_attempt=32 \ -c inputs_are_outputs=True \ -c "reserved_regs=[x0,x1,x2,sp,x30]" # Enable LLVM MCA analysis slothy-cli Arm_AArch64 Arm_Cortex_A55 input.s -o output.s \ -c with_llvm_mca=True # Debug mode with verbose output slothy-cli Arm_AArch64 Arm_Cortex_A55 input.s -o output.s --debug # List all configuration options slothy-cli Arm_AArch64 Arm_Cortex_A55 input.s -c ``` -------------------------------- ### Slothy Initialization and Logging Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.helper.md Details on initializing the Slothy optimizer and its logging capabilities. ```APIDOC ## Initialization Initializes the instance - basically setting the formatter to None and the filter list to empty. ### emit(record) ### forward(logger) Send all captured records to the given logger. ### forward_to_file(log_label, filename, lvl=logging.DEBUG) Store all captured records in a file. ``` -------------------------------- ### ADD Instructions Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v7m.arch_v7m.md Instructions for performing addition operations. ```APIDOC ## add ### Description Adds two registers and stores the result in a destination register. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A #### Pattern `add , , ` #### Inputs - `Ra` (register) - `Rb` (register) #### Outputs - `Rd` (register) ``` ```APIDOC ## add_short ### Description Adds a register to itself and stores the result in the same register. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A #### Pattern `add , ` #### Inputs - `Ra` (register) #### In-Outs - `Rd` (register) ``` ```APIDOC ## add_imm ### Description Adds an immediate value to a register and stores the result in a destination register. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A #### Pattern `add , , ` #### Inputs - `Ra` (register) #### Outputs - `Rd` (register) ``` ```APIDOC ## add_imm_short ### Description Adds an immediate value to a register, storing the result in the same register. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A #### Pattern `add , ` #### In-Outs - `Rd` (register) ``` ```APIDOC ## add_shifted ### Description Adds a register to a shifted register and stores the result in a destination register. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A #### Pattern `add , , , ` #### Inputs - `Ra` (register) - `Rb` (register) #### Outputs - `Rd` (register) ``` -------------------------------- ### Get SSA Form Helper (Python) Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.core.heuristics.md A private helper function to get the Static Single Assignment (SSA) form of the code body. This is an internal utility function used within the Slothy optimizer for specific optimization passes. ```python def _get_ssa_form(body, logger, conf): pass ``` -------------------------------- ### GET /slothy/targets/arm_v7m/arch_v7m/RegisterType Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v7m.arch_v7m.md Accesses the RegisterType enum definitions for ARMv7-M. ```APIDOC ## GET /slothy/targets/arm_v7m/arch_v7m/RegisterType ### Description Provides access to the RegisterType enumeration, defining categories such as GPR, FPR, FLAGS, and HINT. ### Method GET ### Endpoint /slothy/targets/arm_v7m/arch_v7m/RegisterType ### Response #### Success Response (200) - **GPR** (integer) - 1 - **FPR** (integer) - 2 - **FLAGS** (integer) - 3 - **HINT** (integer) - 4 #### Response Example { "GPR": 1, "FPR": 2, "FLAGS": 3, "HINT": 4 } ``` -------------------------------- ### ARMv8.1-M Store Instructions Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v81m.arch_v81m.md Provides documentation for various store instructions available in the ARMv8.1-M architecture. ```APIDOC ## Store Instructions (ARMv8.1-M) ### Description This section details various store instructions for the ARMv8.1-M architecture, including double quadword and quadword stores, with options for writeback. ### Store Double Quadword (VST2) #### VST20 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST21 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST20 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST21 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ### Store Quadword (VST4) #### VST40 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST41 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST42 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST43 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST40 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST41 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST42 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VST43 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ``` -------------------------------- ### Optimize Loop API Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.core.slothy.md Optimizes a loop starting at a given label. ```APIDOC ## optimize_loop ### Description Optimize the loop starting at a given label. ### Method POST ### Endpoint /slothy-optimizer/slothy/optimize_loop ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **loop_lbl** (str) - Required - Label of loop to optimize. - **postamble_label** (str) - Optional - Marks end of loop kernel. - **forced_loop_type** (any) - Optional - Forces the loop to be parsed as a certain type. ### Request Example ```json { "loop_lbl": "main_loop", "postamble_label": "loop_end", "forced_loop_type": "type_B" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success of the optimization. #### Response Example ```json { "status": "Loop optimized successfully" } ``` ``` -------------------------------- ### MOV Instructions (Immediate) Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v7m.arch_v7m.md Instructions for moving immediate values into registers. ```APIDOC ## movw_imm ### Description Moves a 16-bit immediate value into a destination register. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A #### Pattern `movw , ` #### Outputs - `Rd` (register) ``` ```APIDOC ## movt_imm ### Description Moves a 16-bit immediate value into the upper half of a destination register. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A #### Pattern `movt , ` #### In-Outs - `Rd` (register) ``` -------------------------------- ### GET /graph/dependencies Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.core.dataflow.md Returns an iterator over all dependencies in the data flow graph. ```APIDOC ## GET /graph/dependencies ### Description Returns an iterator over all dependencies in the data flow graph. Each element represents a dependency between a consumer and a producer. ### Method GET ### Endpoint /graph/dependencies ### Response #### Success Response (200) - **dependencies** (array) - List of tuples (consumer, producer, ty, idx). #### Response Example { "dependencies": [["node_2", "node_1", "in", 0]] } ``` -------------------------------- ### Load Assembly Source Source: https://context7.com/slothy-optimizer/slothy/llms.txt Shows methods for loading assembly code into the optimizer, either from an external file or directly as a raw string. ```python import slothy import slothy.targets.aarch64.aarch64_neon as AArch64_Neon import slothy.targets.aarch64.cortex_a55 as Target_CortexA55 s = slothy.Slothy(AArch64_Neon, Target_CortexA55) s.load_source_from_file("examples/naive/aarch64/kyber/ntt_kyber_123_4567.s") assembly_code = """ start: ldr q0, [x1, #0] ldr q1, [x2, #0] mul v2.8h, v0.8h, v1.h[0] str q2, [x3] end: """ s.load_source_raw(assembly_code) ``` -------------------------------- ### GET /slothy/targets/aarch64/cortex_a72_frontend/units Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.aarch64.cortex_a72_frontend.md Retrieves the execution units associated with a specific instruction. ```APIDOC ## GET /slothy/targets/aarch64/cortex_a72_frontend/get_units ### Description Returns the execution units required by a specific instruction source. ### Method GET ### Endpoint /slothy/targets/aarch64/cortex_a72_frontend/get_units ### Parameters #### Query Parameters - **src** (string) - Required - The instruction source identifier ### Request Example GET /slothy/targets/aarch64/cortex_a72_frontend/get_units?src=LDR ### Response #### Success Response (200) - **units** (array) - List of execution units (e.g., LOAD0, LOAD1) #### Response Example { "units": ["LOAD0", "LOAD1"] } ``` -------------------------------- ### Get Loop Input/Output API Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.core.slothy.md Finds all registers that a loop body depends on. ```APIDOC ## get_loop_input_output ### Description Find all registers that a loop body depends on. ### Method GET ### Endpoint /slothy-optimizer/slothy/get_loop_input_output ### Parameters #### Path Parameters None #### Query Parameters - **loop_lbl** (str) - Required - Label of loop to process. - **forced_loop_type** (any) - Optional - Forces the loop to be parsed as a certain type. ### Request Example ``` GET /slothy-optimizer/slothy/get_loop_input_output?loop_lbl=loop1&forced_loop_type=type_C ``` ### Response #### Success Response (200) - **inputs** (list) - A list of all input registers of the loop. #### Response Example ```json { "inputs": ["reg1", "reg2", "reg3"] } ``` ``` -------------------------------- ### ARM v8.1-M Vector Store Instructions Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v81m.arch_v81m.md Definitions for various VST (Vector Store) instructions, including variants with and without writeback support. ```APIDOC ## POST /slothy/targets/arm_v81m/vst21 ### Description Defines the vst21 instruction for storing vector registers to memory. ### Method POST ### Endpoint /slothy/targets/arm_v81m/vst21 ### Parameters #### Request Body - **pattern** (string) - Required - 'vst21.
{, }, []' - **inputs** (list) - Optional - ['Rn', 'Qd0', 'Qd1'] ### Response #### Success Response (200) - **status** (string) - Instruction object created successfully. ``` ```APIDOC ## POST /slothy/targets/arm_v81m/vst43_with_writeback ### Description Defines the vst43 instruction with memory writeback support. ### Method POST ### Endpoint /slothy/targets/arm_v81m/vst43_with_writeback ### Parameters #### Request Body - **pattern** (string) - Required - 'vst43.
{, , , }, []!' - **inputs** (list) - Optional - ['Qd0', 'Qd1', 'Qd2', 'Qd3'] - **in_outs** (list) - Optional - ['Rn'] ### Response #### Success Response (200) - **status** (string) - Instruction object created successfully. ``` -------------------------------- ### ARMv7m Load/Store Instructions Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v7m.arch_v7m.md Details on load and store operations for ARMv7m architecture. ```APIDOC ## Armv7mLoadInstruction ### Description Represents a load instruction for ARMv7m. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` ```APIDOC ## Armv7mStoreInstruction ### Description Represents a store instruction for ARMv7m. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### GET /slothy/targets/arm_v81m/helium_experimental/get_units Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v81m.helium_experimental.md Retrieves the execution units associated with a specific instruction source. ```APIDOC ## GET /slothy/targets/arm_v81m/helium_experimental/get_units ### Description Returns the execution unit mapping for a given instruction source based on the Helium experimental target definition. ### Method GET ### Endpoint /slothy/targets/arm_v81m/helium_experimental/get_units ### Parameters #### Query Parameters - **src** (object) - Required - The instruction source object. ### Response #### Success Response (200) - **units** (list) - A list of applicable ExecutionUnit enums. #### Response Example { "units": ["SCALAR"] } ``` -------------------------------- ### Basic Slothy Optimization Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/tutorial/README.md This snippet demonstrates the basic usage of the Slothy optimizer to load an assembly file, configure optimization settings, perform optimization, and write the optimized code to a new file. ```APIDOC ## Slothy Basic Optimization ### Description This endpoint demonstrates the basic usage of the Slothy optimizer. It loads an assembly file, configures optimization settings, performs the optimization, and writes the optimized code to a specified output file. ### Method N/A (Python API) ### Endpoint N/A (Python API) ### Parameters N/A ### Request Example ```python import slothy # Load the assembly source file slothy.load_source_from_file("tests/naive/aarch64/aarch64_simple0.s") # Configure Slothy settings slothy.config.variable_size=True slothy.config.constraints.stalls_first_attempt=32 # Perform the optimization slothy.optimize() # Write the optimized source code to a file slothy.write_source_to_file("opt/aarch64_simple0_a55.s") ``` ### Response N/A (Python API) ### Response Example N/A (Python API) ``` -------------------------------- ### GET /slothy/targets/aarch64/cortex_a72_frontend/latency Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.aarch64.cortex_a72_frontend.md Retrieves the latency for a specific instruction within the Cortex-A72 model. ```APIDOC ## GET /slothy/targets/aarch64/cortex_a72_frontend/get_latency ### Description Returns the latency value for a given instruction source, output index, and destination. ### Method GET ### Endpoint /slothy/targets/aarch64/cortex_a72_frontend/get_latency ### Parameters #### Query Parameters - **src** (string) - Required - The instruction source identifier - **out_idx** (integer) - Required - The output index of the instruction - **dst** (string) - Required - The destination register or operand ### Request Example GET /slothy/targets/aarch64/cortex_a72_frontend/get_latency?src=ADD&out_idx=0&dst=X0 ### Response #### Success Response (200) - **latency** (integer) - The calculated latency for the specified instruction parameters #### Response Example { "latency": 1 } ``` -------------------------------- ### ASimdCompare Class Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.aarch64.aarch64_neon.md Documentation for the ASimdCompare class used for SIMD comparison instructions. ```APIDOC ## Class: ASimdCompare ### Description Parent class for all ASIMD (Advanced SIMD) compare instructions in the AArch64 target. ### Methods - cmge: Implements the compare greater than or equal instruction. ### Inheritance - Inherits from base instruction classes within the `slothy.targets.aarch64.aarch64_neon` namespace. ``` -------------------------------- ### GET /targets/aarch64/neoverse_n1_experimental/units Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.aarch64.neoverse_n1_experimental.md Retrieves the execution units associated with a specific instruction source. ```APIDOC ## GET /targets/aarch64/neoverse_n1_experimental/units ### Description Identifies which execution units are used by a specific instruction source. ### Method GET ### Endpoint /targets/aarch64/neoverse_n1_experimental/get_units ### Parameters #### Query Parameters - **src** (string) - Required - The source instruction identifier. ### Request Example GET /targets/aarch64/neoverse_n1_experimental/get_units?src=FADD ### Response #### Success Response (200) - **units** (array) - List of execution units (e.g., VEC0, VEC1). #### Response Example { "units": ["VEC0", "VEC1"] } ``` -------------------------------- ### ARMv8.1-M Load Instructions Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v81m.arch_v81m.md Provides documentation for various load instructions available in the ARMv8.1-M architecture. ```APIDOC ## Load Instructions (ARMv8.1-M) ### Description This section details various load instructions for the ARMv8.1-M architecture, including byte, halfword, word, and doubleword loads, with options for writeback, post-indexing, and gather operations. ### Load Byte (LDRB) #### LDRB with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRB with Post-indexing ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ### Load Halfword (LDRH) #### LDRH ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRH without Immediate Offset ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRH with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRH with Post-indexing ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ### Load Word (LDRW) #### LDRW ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRW without Immediate Offset ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRW with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRW with Post-indexing ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRW Gather ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRW Gather with UXTW ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ### Load Byte Gather (LDRB_GATHER) #### LDRB Gather ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRB Gather with UXTW ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ### Load Halfword Gather (LDRH_GATHER) #### LDRH Gather ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### LDRH Gather with UXTW ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ### Load Double Quadword (VLD2) #### VLD20 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD21 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD20 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD21 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ### Load Quadword (VLD4) #### VLD40 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD41 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD42 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD43 ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD40 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD41 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD42 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A #### VLD43 with Writeback ### Method Various (Specific instruction dependent) ### Endpoint N/A (Instruction level) ### Parameters N/A (Instruction level) ### Request Example N/A ### Response N/A ``` -------------------------------- ### GET /slothy/targets/arm_v81m/helium_experimental/get_latency Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v81m.helium_experimental.md Retrieves the latency for a specific instruction source, output index, and destination. ```APIDOC ## GET /slothy/targets/arm_v81m/helium_experimental/get_latency ### Description Calculates the latency associated with a given instruction source, output index, and destination within the Helium architecture. ### Method GET ### Endpoint /slothy/targets/arm_v81m/helium_experimental/get_latency ### Parameters #### Query Parameters - **src** (object) - Required - The instruction source object. - **out_idx** (integer) - Required - The output index of the instruction. - **dst** (object) - Required - The destination operand. ### Response #### Success Response (200) - **latency** (integer) - The calculated latency value. #### Response Example { "latency": 1 } ``` -------------------------------- ### Model Instruction Characteristics Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/tutorial/README.md Shows how to map specific instructions to their execution units, inverse throughput, and latency using dictionary structures. ```python execution_units = { ( vmull, vadd ): [[ExecutionUnit.VEC0, ExecutionUnit.VEC1]], } inverse_throughput = { ( vmull, vadd ) : 1, } default_latencies = { ( vmull ) : 4, ( vadd ) : 3, } ``` -------------------------------- ### GET /slothy/targets/arm_v7m/arch_v7m/unicorn_reg_by_name Source: https://github.com/slothy-optimizer/slothy/blob/main/docs/source/apidocs/slothy/slothy.targets.arm_v7m.arch_v7m.md Retrieves the numerical identifier for a given register name for use with the Unicorn engine. ```APIDOC ## GET /slothy/targets/arm_v7m/arch_v7m/unicorn_reg_by_name ### Description Converts the string name of a register into the numerical identifier required by the Unicorn engine. ### Method GET ### Endpoint /slothy/targets/arm_v7m/arch_v7m/unicorn_reg_by_name ### Parameters #### Query Parameters - **reg** (string) - Required - The name of the register to look up. ### Request Example { "reg": "r0" } ### Response #### Success Response (200) - **id** (integer) - The numerical identifier for the register. #### Response Example { "id": 1 } ```