Repository navigation
Leave the code unchanged under -c, and comment every instruction. - #5
Merged
Merged
Conversation
-c writes each instruction's source line above it as a `; Line N:` comment. The comments went into the same list as the code, ahead of the instruction's padding, and the check for a bubble already in place before a branch (padForBranchPreBubble) looks at the previous line. It found the comment instead of the padding and added another nop pair, so -c changed the program: Quake II's textured_triangles got 5 more nop pairs with -c than without, and each of those branches had its comment above the extra nop. Instructions emitted as an upper/lower pair, or with waitq/waitp, got no comment at all (103 of the 1001 instruction lines there). The comments now live in their own list, each with the index of the code line it goes above, and write() interleaves them, so code generation only ever sees code. Each instruction line gets the comments of the source instructions on it, after any padding: both halves of a pair (upper first), an instruction issued with waitq/waitp, and a branch and its delay-slot filler. Only openvcl's own nop/waitq/waitp padding is left without one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
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.
-cwrites each instruction's source line above it as a; Line N:comment. It had two problems:1.
-cchanged the program. The comments went into the same list as the code, ahead of each instruction's padding.padForBranchPreBubblelooks at the previous line to decide whether a branch needs a bubble. Under-cit found the comment instead of the padding that was already there, and added anothernoppair. Quake II'stextured_trianglesgot 5 morenoppairs with-cthan without, and each of those branches' comment sat above the extranop:2. Some instructions had no comment. Instructions emitted as an upper/lower pair, or with
waitq/waitp, got none: 103 of the 1001 instruction lines intextured_triangles.The comments now live in their own list, each with the index of the code line it goes above, and
write()interleaves them. Code generation only ever sees code. Each instruction line gets the comments of the source instructions on it, after any padding: both halves of a pair (upper first), an instruction issued withwaitq/waitp, and a branch and its delay-slot filler. Only openvcl's ownnop/waitq/waitppadding has no comment:The two lines that the experimental
OPENVCL_USE_GENERIC_KERNEL_REWRITEpath pushes directly are left as they are, since that code is being reworked on theoptimizationsbranch.Testing
test/integration/test_emit_source.cpp, 3 new test cases. Each compiles a program with and without-c, then checks that the-coutput without its comments equals the plain output, and that every instruction has a comment above it.-cthe code no longer differs from the plain output in any of them (16 differed before), and every instruction from the source has its comment.🤖 Co-authored by Claude Code