Skip to content

transform: Operation based matching from spec for patching - #95

Merged
kumarak merged 8 commits into
mainfrom
kumarak/patch_operations
Jul 5, 2025
Merged

transform: Operation based matching from spec for patching#95
kumarak merged 8 commits into
mainfrom
kumarak/patch_operations

Conversation

@kumarak

@kumarak kumarak commented Jun 6, 2025

Copy link
Copy Markdown
Collaborator

PR is dependent on #94 and include the changes.

The changes perform operation based matching from the spec and perform patching operation. The Operation matching only support BeforeApply mode at the moment.

An example spec for matching cir.call operation to spo2_lookup can be written as below. It will check for all cir.call operation making a call to symbol_name spo2_lookup and should be called in specific function context with pattern "/.*measurement.*/.

arch: "ARM:LE:32"
patches:
  - name: "apply_before_spo2_lookup_operation"
    match:
      name: "cir.call"
      kind: "operation"
      function_context:
        - name: "/.*measurement.*/"  # Functions containing "measurement"
        - name: "/.*update.*/"       # Functions containing "update"
      operand_matches:
        - index: 0  # First argument to the called function
          name: "var6"
          type: "!cir.float"
      symbol_matches:
        - name: "spo2_lookup"  # The function being called
    patch:
      mode: "ApplyBefore"
      patch_file: "patch_spo2_lookup.c"
      patch_function: "patch::before::spo2_lookup"
      arguments:
        - "var6"
    exclude:
      - ""

@kumarak
kumarak requested a review from xlauko as a code owner June 6, 2025 20:45
@kumarak
kumarak requested review from kaoudis and removed request for xlauko June 6, 2025 20:45
@kumarak
kumarak force-pushed the kumarak/patch_operations branch from d2fa371 to d5ee6b6 Compare June 9, 2025 14:08
@kumarak
kumarak force-pushed the kumarak/patch_operations branch from d5ee6b6 to d059073 Compare June 9, 2025 14:26
@kumarak
kumarak force-pushed the kumarak/patch_operations branch 2 times, most recently from 70e5185 to 88fd963 Compare June 10, 2025 00:58
@kumarak
kumarak force-pushed the kumarak/patch_operations branch 4 times, most recently from 7d27862 to 8c58b68 Compare June 10, 2025 13:56

@kaoudis kaoudis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have some general clarifying questions sprinkled throughout, but please do not consider them blockers.

Comment thread docs/GettingStarted/patch_specifications.md
Comment thread docs/GettingStarted/patch_specifications.md
Comment thread docs/GettingStarted/patch_specifications.md
Comment thread docs/GettingStarted/patch_specifications.md
Comment thread include/patchestry/Passes/PatchSpec.hpp
Comment thread lib/patchestry/Passes/OperationMatcher.cpp
Comment thread lib/patchestry/Passes/OperationMatcher.cpp
Comment thread lib/patchestry/Passes/OperationMatcher.cpp
@kumarak
kumarak force-pushed the kumarak/patch_operations branch from e3e947f to 284e3b8 Compare July 5, 2025 00:26
@kumarak
kumarak merged commit 295132b into main Jul 5, 2025
3 checks passed
@kumarak
kumarak deleted the kumarak/patch_operations branch July 5, 2025 00:46
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