Compiler Pattern Graph Rule Replacement

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing systems for describing rewrite rules in Domain-Specific Languages (DSLs) do not support creating new rules or transforming existing ones, and often require separate languages for describing the language being developed and the rewrite rules, making it difficult for developers to easily add or change optimizations.

Innovation Solution

A compiler that generates a pattern graph corresponding to an intermediate representation of the source code, using a set of rules with specific replacement rules to replace pattern graphs with replacement graphs, allowing for efficient compilation and optimization of program code, enabling developers to write rules without extra code and supporting extensions to existing DSLs.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Stability of the object's composition

If separate languages are used for describing the language being developed and the rewrite rules, then the language description and optimization rules can be independently managed, but it becomes difficult for developers to easily add or change rewrite rules

Engineering Contradiction:
Improveindependent management of language description and rewrite rulesVSAvoidease of adding or changing rewrite rules
Core Design Contradiction:
Stability of the object's compositionVSEase of operation

Solution Approach 1:

The patent merges the language description and rewrite rules into a single unified language. This allows developers to work with both language definitions and optimization rules using the same syntax and semantics, eliminating the barriers of separate languages while maintaining the ability to independently manage different aspects through modular rule definitions.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The unified language serves multiple functions: it can describe the domain-specific language syntax, define rewrite rules for optimization, and enable dynamic rule creation and transformation. This multi-functional approach allows the same language construct to be used for both language definition and optimization rule specification.

Inventive Principle:
Principle #6Universality (Multi-functionality)

2Reliability

If known systems for describing rewrite rules are used, then rewrite rules can be defined for optimization, but the systems do not support programs creating new rules or transforming existing rules

Engineering Contradiction:
Improverewrite rule definition capabilityVSAvoidsupport for creating new rules or transforming existing rules
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The patent implements a dynamic rule system where rewrite rules are not static definitions but can be created, transformed, and modified at runtime through programmatic operations. The unified language enables meta-programming capabilities that allow the system to dynamically generate new optimization rules or transform existing ones based on analysis of the source code or user requirements.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The unified language acts as an intermediary between the static rewrite rule definitions and the dynamic rule creation/transformation operations. It provides a bridge that allows programs to manipulate rewrite rules through the same language constructs used for defining them, enabling flexible rule evolution while maintaining consistency with the underlying optimization framework.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Reliability

If multiple rewrite rules are used for domain-specific optimizations, then optimization coverage is improved, but the complexity of managing and maintaining these rules increases

Engineering Contradiction:
Improveoptimization coverageVSAvoidcomplexity of managing and maintaining rewrite rules
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent segments rewrite rules into modular, composable units that can be independently defined, analyzed, and maintained. The unified language enables rules to be broken down into smaller transformation steps or patterns that can be combined through composition, making it easier to manage complex optimization logic by dividing it into manageable segments that can be developed and tested independently.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentEP3177990B1Method for compiling a source code
Publication Date: 2021.03.17 HUAWEI TECH CO LTD
  • EP3177990B1 patent drawingFigure 1
  • EP3177990B1 patent drawingFigure 2
  • EP3177990B1 patent drawingFigure 3

AI summary

The invention relates to a method for compiling a source code to a program code, the method comprising: providing (101) a pattern graph based on the source code, the pattern graph corresponding to an intermediate representation of the source code according to a set of rules in a first programming language, wherein the set of rules comprises a specific replacement rule directing a pattern graph to be replaced by a corresponding replacement graph assigned to the pattern graph, replacing (103) the pattern graph by the replacement graph assigned to the pattern graph, and generating (105) the program code based on the replacement graph.