Fixed transformations bugs, upgrade packages, and more.#1292
Merged
Conversation
Add CurrentDisabledTransforms property to BisectorState to record the list of currently disabled transforms. Update ExecuteIteration to set this property before saving state, ensuring the state file accurately reflects the active transform configuration for each iteration.
Eliminated duplicate registration of block transforms with compiler hooks in Initialize(). Also removed per-transform disabled checks in ApplyBlockTransforms() for a more streamlined and consistent transform application process.
Introduced a new "FilePostfix" setting and command-line argument ("-postfix") to allow users to append a custom postfix to the base output filename. Updated the argument map, MOSASettings, and filename resolution logic to support this feature. Added a corresponding constant in the Name class.
Removed legacy NuGet env var and consolidated Mosa.Templates build and packaging into a single dotnet pack step. This modernizes the CI process and simplifies package output management.
Introduce `-postfix` and `-path` command-line arguments for customizing output file names and search paths. Update documentation to describe these options and add `FilePostfix` to the settings table. Add related constants in `Name.cs` and clarify platform argument documentation. Also, append new unit test-related constants.
Update double zero/sign-extend IR transforms to emit the correct extend instruction instead of Move, ensuring proper extension semantics. Comment out certain "useless" ZeroExtend compare transforms in ManualTransforms.cs.
Refactored IntegerOperation1 and IntegerOperation to handle 32-bit and 64-bit instructions in separate branches. Ensured proper casting and masking for 32-bit results and applied correct shift masks. Improves correctness and clarity, especially for edge cases and overflows.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates MOSA’s optimization/transform pipeline and tooling by fixing incorrect “double extension” simplifications in IR optimizations, refining SCCP integer folding for 32-bit correctness, modernizing parts of the Windows packaging workflow, and adding a new output filename postfix setting (plus some QEMU packaging updates and docs).
Changes:
- Fix “double extend” useless transforms to keep the correct
ZeroExtend*/SignExtend*IR op instead of incorrectly collapsing toMove. - Improve SCCP integer operation folding (32-bit masking/casting, shift masking) and simplify transform hook logic in
BaseTransformStage. - Add
-postfix/FilePostfixsetting, update docs, update Avalonia package versions, and update Windows packaging + QEMU tooling assets.
Reviewed changes
Copilot reviewed 27 out of 53 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| Tools/reduce-qemu.bat | Update QEMU installer URL and prune additional DLLs/files from the reduced bundle. |
| Tools/qemu/VERSION | Bump recorded QEMU version. |
| Source/Mosa.Utility.UnitTestBisector/UnitTestBisectorSystem.cs | Persist current disabled transform set into state during iteration execution. |
| Source/Mosa.Utility.UnitTestBisector/BisectorState.cs | Add CurrentDisabledTransforms to persisted bisector state. |
| Source/Mosa.Utility.Configuration/Name.cs | Add FilePostfix setting key constant. |
| Source/Mosa.Utility.Configuration/MOSASettings.cs | Add FilePostfix setting and apply it to derived output filenames. |
| Source/Mosa.Utility.Configuration/CommandLineArguments.cs | Add -postfix CLI argument mapping. |
| Source/Mosa.Tool.Launcher/Mosa.Tool.Launcher.csproj | Bump Avalonia package versions. |
| Source/Mosa.Tool.Explorer.Avalonia/Mosa.Tool.Explorer.Avalonia.csproj | Bump Avalonia package versions. |
| Source/Mosa.Tool.Bootstrap/Mosa.Tool.Bootstrap.csproj | Bump Avalonia package versions. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/ManualTransforms.cs | Disable a few manual transforms pending validation. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend8x64Double.cs | Adjust double-zero-extend optimization to preserve ZeroExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend8x32Double.cs | Adjust double-zero-extend optimization to preserve ZeroExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend32x64Double.cs | Adjust double-zero-extend optimization to preserve ZeroExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend16x64Double.cs | Adjust double-zero-extend optimization to preserve ZeroExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend16x32Double.cs | Adjust double-zero-extend optimization to preserve ZeroExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend8x64Double.cs | Adjust double-sign-extend optimization to preserve SignExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend8x32Double.cs | Adjust double-sign-extend optimization to preserve SignExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend32x64Double.cs | Adjust double-sign-extend optimization to preserve SignExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend16x64Double.cs | Adjust double-sign-extend optimization to preserve SignExtend* semantics. |
| Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend16x32Double.cs | Adjust double-sign-extend optimization to preserve SignExtend* semantics. |
| Source/Mosa.Compiler.Framework/Stages/BaseTransformStage.cs | Remove transform-hook registration/disable checks for block transforms. |
| Source/Mosa.Compiler.Framework/Analysis/SparseConditionalConstantPropagation.cs | Refine integer folding logic (especially 32-bit masking/casting and shift masking). |
| Source/Docs/settings-options.rst | Document FilePostfix setting. |
| Source/Docs/command-line-arguments.rst | Document -postfix and adjust CLI argument listing. |
| Source/Data/IR-Optimizations-Useless.json | Fix useless optimization outputs for “double extension” patterns to preserve correct extend ops. |
| .github/workflows/builds.yml | Switch Mosa.Templates packaging to dotnet pack and remove legacy env var. |
Replaced 'random-combo' with 'random' in bisector docs, CLI, and code. Clarified comments for managed pointer memory transforms. Enabled additional 'Useless' transforms. Fixed Add32 manual transform to check next.Result register for ESP.
Corrected a typo in the batch script by changing `del /S /Q qemu\share\u-boot-sam460.binS` to the correct file name `del /S /Q qemu\share\u-boot-sam460.bin`, ensuring the intended file is deleted. No other changes were made. Update CLI docs formatting; fix typo in reduce-qemu.bat Reordered and clarified command-line argument documentation, including a new "Compiler - Platform" section. Fixed a minor typo in reduce-qemu.bat affecting the u-boot-sam460.bin deletion command.
Only iterate transforms when AllowTransformHooks is true, avoiding unnecessary iteration and improving efficiency. Logic for null-checking and hook registration is unchanged.
Renamed the variable resultOperand to result for improved clarity and consistency within the Transform method. Updated all references accordingly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several important improvements and corrections across the codebase, focusing on IR transformation accuracy, compiler optimization logic, build process updates, and documentation. The main changes are grouped below.
IR Transformations and Optimizations
Corrected double extension IR optimizations to preserve the correct extension operation, replacing previous incorrect simplifications to
Moveinstructions with the appropriateZeroExtendorSignExtendIR instructions in both the JSON optimization definitions and auto-generated transform files. This ensures semantic correctness for cases likeIR.ZeroExtend8x32(IR.ZeroExtend8x32 a)and similar patterns. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]Disabled three manual transforms related to
ZeroExtend8x32Compare32x32and similar patterns, pending further validation, to avoid potential incorrect optimizations.Compiler Analysis and Transform Hook Logic
Refined integer operation handling in
SparseConditionalConstantPropagation.csfor better type correctness, especially for 32-bit operations, and to ensure correct masking and casting for all arithmetic and bitwise operations. [1] [2]Removed unnecessary transform hook registration and checks for block transforms in
BaseTransformStage, simplifying the transform application logic. [1] [2]Build System Updates
dotnet packfor.csprojfiles instead ofnuget pack, and removed the legacy NuGet environment variable, modernizing the package creation process. [1] [2] [3]Documentation
-postfixcommand-line argument and the correspondingFilePostfixsetting, and clarified the usage ofSearchPaths. [1] [2]These changes collectively improve the correctness of IR optimizations, streamline the build process, and enhance documentation for users and developers.