Repository navigation
refactor(conversion): add StackEffectConversion base for ForthToMemRef patterns - #133
Merged
Merged
Conversation
…f patterns Every stack-in, stack-out pattern repeated a forwarding constructor, the OneToNOpAdaptor alias, the (memref, SP) unpack, and the replaceOpWithMultiple epilogue. StackEffectConversion<ForthOp> owns that plumbing; each pattern now implements rewriteStack and returns the new SP. PopOp and PopFlagOp keep a plain matchAndRewrite because they replace an extra non-stack result, but drop their forwarding constructors. Closes #122.
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.
Closes #122. Follow-up to #17.
What changed
StackEffectConversion<ForthOp>unpacks the converted!forth.stackoperand into(memref, SP), calls a virtualrewriteStack, and replaces the op with{memref, newSP}. Each pattern now holds only its stack logic.Migrated: Constant, Dup, Drop, Swap, Over, Rot, Nip, Tuck, Pick, Roll, Not, ZeroEq, ParamRef, IToF, FToI, GlobalId, PushValue, and the
BinaryArith,UnaryFloat,BinaryCmp,MemoryLoad,MemoryStoreandIntrinsictemplates.PopOpandPopFlagOpstay on plainOpConversionPattern. They also replace an extra non-stack result (the value or thei1flag), which a single-SP hook can't express. They still lose the forwarding constructor.StackOpConversionhas no input stack and is unchanged. The issue proposed the nameStackOpConversionfor the base, but that name already belongs to theforth.stackpattern.Net: 210 insertions, 301 deletions in
ForthToMemRef.cpp.Verification
check-warpforth: 134/134 pass, same as before the change.--convert-forth-to-memrefoutput for everytest/Conversion/ForthToMemRef/*.mlir, plus memref and full-pipeline PTX for every.forthfile undertest/andgpu_test/. That's 236 outputs, and all are byte-identical (diff -rempty).check-clang-tidyreports no new findings. The two existingllvm-prefer-static-over-anonymous-namespaceerrors onpushValueandgetMemElemTypepredate this change.