IP Library Granted Patent US 12,468,514
Granted Patent B2
US 12,468,514 · App. 18/185,894 · Granted Nov 11, 2025

Code processing method and apparatus, and storage medium

Inventors: Yongnian Le (Shanghai, CN); Bo Huang (Shenzhen, CN); Weifeng Hui (Xi'an, CN); Jing Luo (Dongguan, CN)
Assignee: Huawei Technologies Co., Ltd.
G06F8/51G06F8/433
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,468,514
App. No.
18/185,894
Granted
Nov 11, 2025
Kind
B2
Abstract

This application discloses code processing methods, apparatuses, and storage media. An example method includes: obtaining a first code in low-level language and applicable to a source platform; decompiling the obtained first code to obtain an intermediate representation (IR); and then compiling the IR into a second code in low-level language and applicable to a first target platform, where the source platform and the target platform have different instruction sets.

Claims (55)

1 . A method, wherein the method comprises:

obtaining a first code in low-level language and applicable to a source platform;

decompiling the first code to obtain a first intermediate representation (IR) based on a difference between a first single instruction multiple data (SIMD) instruction of the source platform and a second SIMD instruction of a first target platform; and

compiling the first IR into a second code in low-level language and applicable to the first target platform, wherein the source platform and the first target platform have different instruction sets.

2 . The method according to claim 1 , wherein the method further comprises:

decompiling the first code to obtain a second IR corresponding to a second target platform, wherein the first target platform and the second target platform have different instruction sets.

3 . The method according to claim 1 , wherein the method further comprises:

presenting a target platform selection interface; and

determining the first target platform from a plurality of target platforms in response to a selection operation on a target platform through the target platform selection interface.

4 . The method according to claim 1 , wherein the decompiling the first code to obtain a first IR comprises:

obtaining annotation information of the first code, wherein the annotation information comprises one or more of a type, a quantity, or a jump address type of a parameter in the first code; and

decompiling the first code based on the annotation information, to obtain the first IR.

5 . The method according to claim 1 , wherein the decompiling the first code to obtain a first IR comprises:

decompiling the first code to obtain a second IR; and

optimizing the second IR based on the first target platform, to obtain the first IR.

6 . The method according to claim 1 , wherein the method further comprises:

generating prompt information that prompts for a to-be-checked item to be generated based on a difference between the first target platform and the source platform; and

presenting the prompt information.

7 . The method according to claim 1 , wherein the method is applied to a cloud, wherein the first code is obtained from a user, and wherein the method further comprises:

sending the second code to the user.

8 . The method according to claim 1 , wherein the decompiling the first code comprises:

decompiling the first code based on an instruction semantic library corresponding to the source platform.

9 . The method according to claim 8 , wherein the method further comprises:

modifying the instruction semantic library in response to a modification operation on the instruction semantic library.

10 . The method according to claim 1 , wherein the obtaining a first code in low-level language and applicable to a source platform comprises:

obtaining the first code in low-level language and applicable to the source platform and a variable in high-level language; and

the decompiling the first code comprises:

translating the first code into the first IR, wherein the variable is an actual parameter corresponding to a formal parameter comprised in a function of the first IR.

11 . The method according to claim 1 , wherein the first IR comprises a first variable and a second variable, the first variable has a first logical address, the second variable has a second logical address different from the first logical address.

12 . The method according to claim 1 , wherein

the second SIMD instruction of the first target platform is a vectorized instruction configured to perform a same operation on a group of data in parallel.

13 . A computing apparatus, wherein the computing apparatus comprises at least one memory and at least one processor, the at least one memory is coupled to the at least one processor, and the at least one memory stores programming instructions for execution by the at least one processor to cause the computing apparatus to perform operations comprising:

obtaining a first code in low-level language and applicable to a source platform;

decompiling the first code to obtain a first intermediate representation (IR) based on a difference between a first single instruction multiple data (SIMD) instruction of the source platform and a second SIMD instruction of a first target platform; and

compiling the first IR into a second code in low-level language and applicable to the first target platform, wherein the source platform and the first target platform have different instruction sets.

14 . The computing apparatus of claim 13 , wherein the operations further comprise:

decompiling the first code to obtain a second IR corresponding to a second target platform, wherein the first target platform and the second target platform have different instruction sets.

15 . The computing apparatus of claim 13 , wherein the operations further comprise:

presenting a target platform selection interface; and

determining the first target platform from a plurality of target platforms in response to a selection operation on a target platform through the target platform selection interface.

16 . The computing apparatus of claim 13 , wherein the decompiling the first code to obtain a first IR comprises:

obtaining annotation information of the first code, wherein the annotation information comprises one or more of a type, a quantity, or a jump address type of a parameter in the first code; and

decompiling the first code based on the annotation information, to obtain the first IR.

17 . The computing apparatus of claim 13 , wherein the decompiling the first code to obtain a first IR comprises:

decompiling the first code to obtain a second IR; and

optimizing the second IR based on the first target platform, to obtain the first IR.

18 . The computing apparatus of claim 13 , wherein the operations further comprise:

generating prompt information that prompts for a to-be-checked item to be generated based on a difference between the first target platform and the source platform; and

presenting the prompt information.

19 . The computing apparatus of claim 13 , wherein the first code is obtained from a user, and wherein the operations further comprise:

sending the second code to the user.

20 . A non-volatility computer-readable storage medium comprising programming instructions for execution by at least one processor of a computing apparatus to cause the computing apparatus to perform operations comprising:

obtaining a first code in low-level language and applicable to a source platform;

decompiling the first code to obtain a first intermediate representation (IR) based on a difference between a first single instruction multiple data (SIMD) instruction of the source platform and a second SIMD instruction of a first target platform; and

compiling the first IR into a second code in low-level language and applicable to the first target platform, wherein the source platform and the first target platform have different instruction sets.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 2, 2025
From: LE, YONGNIAN; HUI, WEIFENG; LUO, JING
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 072141/0306 →
EMPLOYMENT AGREEMENT Recorded Sep 2, 2025
From: HUANG, BO
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 072811/0706 →
Priority Claims (2)
CN 202010996387.6 · Sep 21, 2020 · national
CN 202011066288.4 · Sep 30, 2020 · national
Continuity (2)
Continuation PCTCN2021117845 · Sep 11, 2021
Related Publication 20230229410A1 · Jul 20, 2023
References Cited (7)
US 10338902B1 · Sevigny · 2019 [cited by examiner]
US 20190227779A1 · Jaeger et al. · 2019 [cited by applicant]
US 20220058007A1 · Deng · 2022 [cited by examiner]
US 20230367569A1 · Kasper · 2023 [cited by examiner]
CN 103235724A · 2013 [cited by applicant]
International Search Report and Written Opinion in International Appln. No. PCT/CN2021/117845, mailed on Dec. 8, 2021, 15 pages (with English translation). [cited by applicant]
Extended European Search Report in European Appln No. 21868568.3, dated Jan. 3, 2024, 11 pages. [cited by applicant]