Skip to content

fix(codegen): Correct config_attr position and cmp_modes case in PTO ops#273

Merged
Hzfengsy merged 1 commit intohw-native-sys:mainfrom
lwDavid:main
Feb 26, 2026
Merged

fix(codegen): Correct config_attr position and cmp_modes case in PTO ops#273
Hzfengsy merged 1 commit intohw-native-sys:mainfrom
lwDavid:main

Conversation

@lwDavid
Copy link
Contributor

@lwDavid lwDavid commented Feb 26, 2026

fix(codegen): Correct config_attr position and cmp_modes case in PTO ops

Move config_attr output before type annotations to match expected MLIR
syntax. Lowercase cmp_modes to align with PTO assembly specification.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lwDavid, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the code generation for PTO operations by addressing two specific syntax and specification compliance issues. It ensures that comparison modes are correctly cased for PTO assembly and that configuration attributes are placed appropriately within the generated MLIR code, thereby improving the overall correctness and compatibility of the backend output.

Highlights

  • Comparison Mode Casing: The values in the cmp_modes array were updated from uppercase (e.g., "EQ") to lowercase (e.g., "eq") to ensure alignment with the PTO assembly specification.
  • Configuration Attribute Placement: The output position of the config_attr was moved to appear before type annotations in the generated code, which corrects its placement according to expected MLIR syntax.
Changelog
  • src/backend/910B_PTO/backend_910b_pto_ops.cpp
    • Updated the cmp_modes vector to use lowercase strings for comparison operators.
    • Relocated the config_attr output logic to occur before type annotations in the GenerateInsOutsClause function.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

This PR modifies the backend 910B PTO operations code by converting comparison mode constants to lowercase ("eq", "ne", "lt", etc.) and reordering the emission of config_attr to occur before type annotations instead of after, while removing the duplicate emission block.

Changes

Cohort / File(s) Summary
Backend PTO Operations
src/backend/910B_PTO/backend_910b_pto_ops.cpp
Constants converted from uppercase to lowercase comparison modes. Config_attr emission repositioned in GenerateInsOutsClause to occur before type annotations, with duplicate emission removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Hzfengsy

Poem

🐰 Lowercase letters dance with glee,
Config shifts to where it should be,
Order corrected, duplicates gone,
PTO operations march along,
A rabbit's refactor, small but keen!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main changes: correcting config_attr position and cmp_modes case in PTO ops code generation.
Description check ✅ Passed The description is directly related to the changeset, explaining the specific fixes being made to config_attr positioning and cmp_modes casing.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request correctly addresses the stated objectives by lowercasing cmp_modes to align with the PTO assembly specification and repositioning the config_attr output to match the expected MLIR syntax. These changes appear to be necessary for correctness and consistency with external specifications.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/backend/910B_PTO/backend_910b_pto_ops.cpp`:
- Around line 62-64: The code appends config_attr directly to the last operand
via the output stream oss (if (!config_attr.empty()) { oss << config_attr; }),
which can produce malformed assembly; change the append to include an explicit
leading space (e.g., oss << ' ' << config_attr) so the attribute dictionary is
separated from the previous token—update the conditional that checks config_attr
and the oss write to insert the space before config_attr.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13bb385 and 6779a3d.

📒 Files selected for processing (1)
  • src/backend/910B_PTO/backend_910b_pto_ops.cpp

Comment on lines +62 to +64
if (!config_attr.empty()) {
oss << config_attr;
}
Copy link

@coderabbitai coderabbitai bot Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Missing separator before config_attr can produce malformed assembly.

At Line 63, config_attr is concatenated directly to the last operand (...%arg{...}), which is brittle and can break parsing depending on grammar/tokenization. Add an explicit leading space before the attribute dict.

Proposed fix
-  if (!config_attr.empty()) {
-    oss << config_attr;
-  }
+  if (!config_attr.empty()) {
+    oss << " " << config_attr;
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/backend/910B_PTO/backend_910b_pto_ops.cpp` around lines 62 - 64, The code
appends config_attr directly to the last operand via the output stream oss (if
(!config_attr.empty()) { oss << config_attr; }), which can produce malformed
assembly; change the append to include an explicit leading space (e.g., oss << '
' << config_attr) so the attribute dictionary is separated from the previous
token—update the conditional that checks config_attr and the oss write to insert
the space before config_attr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referenced the documented grammar implementation here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lwDavid, thank you for verifying against the documented grammar implementation. Since you've checked the PTO assembly specification and confirmed the current syntax is correct, I'll defer to your verification.

If you have a link to the relevant grammar documentation handy, feel free to share it for future reference, but it's not necessary.

@lwDavid
Copy link
Contributor Author

lwDavid commented Feb 26, 2026

@Hzfengsy Bug fix. Request review.

@Hzfengsy Hzfengsy merged commit 0f79891 into hw-native-sys:main Feb 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants