CN105117269B - The optimization method of compiler based on vector interrupt - Google Patents

The optimization method of compiler based on vector interrupt Download PDF

Info

Publication number
CN105117269B
CN105117269B CN201510647971.XA CN201510647971A CN105117269B CN 105117269 B CN105117269 B CN 105117269B CN 201510647971 A CN201510647971 A CN 201510647971A CN 105117269 B CN105117269 B CN 105117269B
Authority
CN
China
Prior art keywords
register
interrupt
function
compiler
service function
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510647971.XA
Other languages
Chinese (zh)
Other versions
CN105117269A (en
Inventor
王勇
肖佐楠
郑茳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
TIANJIN TIANXIN TECHNOLOGY CO LTD
Original Assignee
TIANJIN TIANXIN TECHNOLOGY CO LTD
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by TIANJIN TIANXIN TECHNOLOGY CO LTD filed Critical TIANJIN TIANXIN TECHNOLOGY CO LTD
Priority to CN201510647971.XA priority Critical patent/CN105117269B/en
Publication of CN105117269A publication Critical patent/CN105117269A/en
Application granted granted Critical
Publication of CN105117269B publication Critical patent/CN105117269B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

The present invention provides the optimization methods of the compiler based on vector interrupt, include the following steps:The definition to vectorial interrupt function is completed by pre-processing instruction;Compiler identifies vector interrupt function in the precompile stage, analyzes the service condition of general register in interrupt function;Determine the sequence that the general register for needing to preserve and general register preserve;Determine the interrupt spot for needing to preserve, especially specified register;According to the order restoring register of save register, interrupt spot is restored;Service function is interrupted to return.Interrupt spot is stored in interrupt in service function and carry out by the present invention, in view of interrupting the situation for the general register that service function uses, reduce load/store operations, simplify flow, reduce to jump to and interrupts service function and be related to skip operation twice from service function return is interrupted, to accelerate interrupt function execution efficiency, the speed of processor interrupt response is improved.

Description

The optimization method of compiler based on vector interrupt
Technical field
The invention belongs to Compiler Optimization field, more particularly, to a kind of optimization of the compiler based on vector interrupt Method.
Background technology
Compiler is a kind of computer program, the source code (original language) that it will be write as with certain high-level programming language, conversion At another programming language (object language).Compiler is divided into leading portion, middle-end and rear end from structure, and front end is mainly morphology Analysis, syntactic analysis phase, the assignment tree that front end generates are supplied to middle-end as input as input, and middle-end includes intermediate generation Code generates and optimization intermediate code, and the intermediate code that middle-end generates is supplied to rear end as input, rear end will be intermediate as output Code compilation is at assembly code.
Interruption is the most common mode of processor response peripheral hardware request.Processor response is interrupted, and is substantially in execution Disconnected service function, the program executed when needing to continue to interrupt after interrupting due to processor response, just looks like that interruption does not have Have and occurred equally, needs to preserve interrupt spot before service function so processor breaks in commission, break services in commission Interrupt spot is restored after function.
Vector interrupt, external interrupt control device are underway disconnected by an independent data/address bus for being connected to processor Inform that processor interrupts the address of service function while request.
The general flow of interrupt response is:
(1) enter and interrupt
(2) interrupt spot is preserved
(3) interruption service function is jumped to
(4) it executes and interrupts service function
(5) it is returned from interruption service function
(6) interrupt spot is restored
(7) interrupt spot is returned to
Here it " preserves interrupt spot ", preserves the register of all software-accessibles, be related to a large amount of store operations, " reduction Interrupt spot " restores the register of all software-accessibles, is related to a large amount of load operations, there is no in view of interrupting clothes here Whether used in business function;" jump to and interrupt service function " and " being returned from service function is interrupted " is related to skip operation twice. It more crucially executes when interrupting service function, as function, register progress that needs that compiler can be used preserve It preserves, this point is to repeat to preserve operation with " preserving interrupt spot ", and the general flow of interrupt response is unable to fully embody in vector Disconnected advantage.
Invention content
In view of this, the invention is directed to a kind of optimization method of the compiler based on vector interrupt, to realize It simplifies and preserves load involved in interrupt spot, reduction interrupt spot process, store number while interrupting simplification in flow Reduce the number redirected, to improve the speed of processor interrupt response.
In order to achieve the above objectives, the technical solution of the invention is realized in:
The optimization method of compiler based on vector interrupt, includes the following steps:
(1) definition to vectorial interrupt function is completed by pre-processing instruction;
(2) compiler identifies vector interrupt function in the precompile stage, analyzes the use of general register in interrupt function Situation;
(3) determine that the general register for needing to preserve and general register preserve according to processor type and programming model Sequence;It preserves general register and follows following principle:
(a1) parameter register is used for Transfer Parameters when function call and uses, determined and deposited according to compiler analysis result Whether device preserves, and register preserves out-of-order requirement, and register preserves corresponding with reduction sequence;
(a2) fixed register, determines whether register preserves according to compiler analysis result, and register preserves out-of-order It is required that register preservation is corresponding with reduction sequence;
(a3) register that may span across function is called according to register as defined in the complicated degree of function and programming model the inside Sequentially, compiler selection needs the register for preserving and restoring, and register preserves and the sequence of reduction corresponds to;
(4) interrupt spot for needing to preserve is determined according to the content of processor type, programming model and interruption service function, Especially specified register;
(5) according to the order restoring register of save register, interrupt spot is restored;
(6) it interrupts service function to return, while being also that interrupt spot returns.
Further, keyword definition vector interrupt function is used in the step (1), is parsed convenient for compiler front-end, The keyword includes #pragma, _ _ attribute__.
Further, in the step (2), compiler front-end is known in the precompile stage by morphological analysis, syntactic analysis Other vector interrupt function, the subsequent register assigning process of information guiding obtained by precompile;If interrupting service function It using these registers, is preserved when interrupt spot preserves, otherwise need not be preserved.
Further, compiler refers to the compiling of instruction for interrupting service function ending to interrupt to return in the step (6) It enables.
Further, the step (3), step (4) analysis are interrupted in service function, are analyzed its subfunction, The principle of analysis is as follows:
(b1) compiler, which needs to analyze, interrupts register service condition in service function and its subfunction, until the letter of analysis Until number is there is no subfunction;
(b2) for interrupting service function and its subfunction, analyze parameter general register, fixed general register with And the specified register that high-level language can influence;
(b3) service condition that only may span across the register of function in analysis interruption service function, interrupts the son of service function The service condition that analysis may span across the register of function is not had in function;
(b4) specified register specified when interrupt function defines needs to preserve
Compared with the existing technology, the optimization method of the compiler based on vector interrupt described in the invention has following Advantage:Interrupt spot is stored in interrupt in service function and carry out by the present invention, it is contemplated that interrupt that service function uses general posts The situation of storage reduces load/store operations, simplifies flow, reduces to jump to and interrupts service function and taken from interrupting Business function return is related to skip operation twice, to accelerate interrupt function execution efficiency, improves the speed of processor interrupt response Degree.
Description of the drawings
The attached drawing for constituting the part of the invention is used for providing further understanding the invention, present invention wound The illustrative embodiments and their description made do not constitute the improper restriction to the invention for explaining the invention. In attached drawing:
Fig. 1 is example processor programming model register example;
Fig. 2 is compiler to interrupting service function register analysis process figure;
Dwell vessel original state table when Fig. 3 is analysis register service condition;
Fig. 4 is to analyze the buffer status table used when register service condition;
Fig. 5 is the assembler schematic diagram for compiling out using conventional compiler interrupt service routine for example 1;
Fig. 6 is the assembler schematic diagram for compiling out using the compiler interrupt service routine of optimization for example 1;
Fig. 7 is the assembler schematic diagram for compiling out using conventional compiler interrupt service routine for example 2;
Fig. 8 is the assembler schematic diagram for compiling out using the compiler interrupt service routine of optimization for example 2.
Specific implementation mode
It should be noted that in the absence of conflict, the feature in embodiment and embodiment in the invention can To be combined with each other.
The present invention will be described in detail below with reference to the accompanying drawings and embodiments creates.
Processor programming model register as described in Figure 1, if processor does not have the mechanism that hardware preserves interrupt spot, base It is as follows in the Compiler Optimization method specific implementation mode of interruption:
In commission when disconnected service function, the problem of whether preservation to register according to compiler, register can be divided into Three classes:
(1) all general registers, compiler interrupt register in service function according to analysis and distribute, it is known that interrupt service The general register that the general register and needs used in function preserves.
(2) specified register that high-level language can influence, compiler interrupt the instruction in service function according to analysis, it is known that Interrupt which specified register service function can influence, such as condition register (cr) can then be influenced if there is conditional order The value of condition register.
(3) there was only the specified register that assembler language operates, that is, programmer can be to these in interrupting service function Specified register is operated by compiled form.In this way, compiler, which is not known, interrupts whether service function can influence these registers, And programmer will be appreciated which specified register whether interrupt service function can influence, and therefore, defined by pre-processing instruction When interrupting service function, it should provide control interface, such register such as status register (msr), place for such register Manage device control register (ccr).
Step (1):The definition to vectorial interrupt function by pre-processing instruction completion is needed, it is fixed that following form may be used Adopted vector interrupt function:
__attribute__((interrupt(“msr”)))void ISR(void);
ISR is vector interrupt service function, and can use state register (msr) in interrupting service function.
Step (2):Compiler identifies vector interrupt function in the precompile stage, analyzes general register in interrupt function Service condition.
Step (3):Compiler determines the general register for needing to preserve and general according to processor type and programming model The sequence that register preserves.It preserves general register and follows following principle:
(a1) parameter register is used for Transfer Parameters when function call and uses, determined and deposited according to compiler analysis result Whether device preserves, and register preserves out-of-order requirement, and register preserves corresponding with reduction sequence;
(a2) fixed register, determines whether register preserves according to compiler analysis result, and register preserves out-of-order It is required that register preservation is corresponding with reduction sequence;
(a3) register that may span across function is called according to register as defined in the complicated degree of function and programming model the inside Sequentially, compiler selection needs the register for preserving and restoring, and register preserves and the sequence of reduction corresponds to.
Step (4):According to processor type, it is special that programming model and the content for interrupting service function determine that needs preserve Register.
Method detailed that compiler analyzes register as shown in Fig. 2, in the process, compiler need to subfunction into Row analysis:
(b1) compiler, which needs to analyze, interrupts register service condition in service function and its subfunction, until the letter of analysis Until number is there is no subfunction.
(b2) for interrupting service function and its subfunction, analyze parameter general register, fixed general register with And the specified register that high-level language can influence.
(b3) it only may span across the service condition of the register of function in analysis interruption service function, do not have to analysis in subfunction It may span across the service condition of the register of function.
(b4) specified register specified when interrupt function defines needs to preserve
Between register analysis, dwell vessel original state as shown in Figure 3 is " N ".By interrupting service function and subfunction After analysis, once finding that some register needs to preserve, then remembers " S " (store) in one field mark of Fig. 4 states, otherwise keep initial State " N " is constant, finally to the end of all Functional Analysis after, need to be S " by all labels in interrupt service function Register is preserved.
Step (5):According to the order restoring register of save register, interrupt spot is restored;
After function normal function, before returning to interrupt spot, the register of all preservations is restored in sequence, " S " in corresponding one column of state of the register of reduction is replaced with " N " simultaneously.
Step (6):It interrupts service function to return, while being also that interrupt spot returns.
Example 1:It is sky to interrupt service function, compares the method with the Compiler Optimization of optimization compared to traditional compiler The advantages of traditional method.
First, as shown in figure 5, describing to interrupt the program of execution according to the general flow of interruption, here, " ldu ", table Show the instruction taken out data from memory and update stack pointer;" stu " indicates deposit data to memory and updates the finger of stack pointer It enables;" bl " indicates the instruction of the skip operation with link register;" rfi " indicates the instruction back to interrupt spot;“jump” Indicate jump instruction.
Here generic compiler is only possible to arbitrary function to preserve " may span across function register ", so must be added to use " preserving interrupt spot " of implementation by assembly, " redirect and interrupt service function ", " reduction interrupt spot ", " returning to interrupt spot ".
The program executed is interrupted according to the flow description after Compiler Optimization and interrupts the program executed, if according to as follows Mode defines interruption service function:
__attribute__((interrupt(“msr”))void isr(void);
As shown in figure 5, programmer informs that " msr " (its can be used by interrupting service function when due to definition interruption service function Real interruption service function does not use), so there is the operation for preserving and restoring " msr " in the assembler of compiling out.
Comparing Fig. 5, Fig. 6 and can be seen that can be reduced (1+2+4+10) secondary " store " using the compiler of optimization, including 1 Secondary specified register relevant operation, No. 2 general register relevant operations, 4 subparameter register relevant operations, 10 Cross functions Register relevant operation;(1+2+4+10) secondary " load ", 1 specified register relevant operation, No. 2 general register correlation behaviour Work, 4 subparameter register relevant operations, 10 Cross function register relevant operations reduce by 2 skip operations.
Example 2:It interrupts service function and calls subfunction, compare the method with the Compiler Optimization of optimization compared to traditional The advantages of compiler traditional method.
Service function non-empty is interrupted, needs to use " register of Cross function " in interrupt function, and interrupt service function There are subfunctions.Service function is interrupted in definition as follows:
__attribute__((interrupt())void isr(void);
Compare Fig. 7, Fig. 8 can be seen that can reduce (2+1+2+10) secondary " store ", 2 spies using the compiler of optimization Different register relevant operation, No. 1 general register relevant operation, 2 subparameter register relevant operations, 10 Cross function deposits Device relevant operation;(2+1+2+10) secondary " load ", 2 specified register relevant operations, No. 1 general register relevant operation, 2 times Parameter register relevant operation, 10 Cross function register relevant operations reduce by 2 skip operations.
The foregoing is merely the preferred embodiments of the invention, are not intended to limit the invention creation, all at this Within the spirit and principle of innovation and creation, any modification, equivalent replacement, improvement and so on should be included in the invention Protection domain within.

Claims (5)

1. the optimization method of the compiler based on vector interrupt, it is characterised in that:Include the following steps:
(1) definition to vectorial interrupt function is completed by pre-processing instruction;
(2) compiler identifies vector interrupt function in the precompile stage, analyzes the service condition of general register in interrupt function;
(3) general register and general register preserved according to processor type and programming model determination needs preserves suitable Sequence;
Wherein, it preserves general register and follows following principle:
(a1) parameter register is used for Transfer Parameters when function call and uses, determines that register is according to compiler analysis result No preservation, register preserve out-of-order requirement, and register preserves corresponding with reduction sequence;
(a2) fixed register, determines whether register preserves according to compiler analysis result, and register preserves out-of-order requirement, Register preserves corresponding with reduction sequence;
(a3) register that may span across function calls suitable according to register as defined in the complicated degree of function and programming model the inside Sequence, compiler selection need the register for preserving and restoring, and register preserves and the sequence of reduction corresponds to;
(4) interrupt spot for needing to preserve is determined according to the content of processor type, programming model and interruption service function;
(5) according to the order restoring register of save register, interrupt spot is restored;
(6) it interrupts service function to return, while being also that interrupt spot returns.
2. the optimization method of the compiler according to claim 1 based on vector interrupt, it is characterised in that:The step (1) in use keyword definition vector interrupt function, convenient for compiler front-end parse, the keyword include #pragma, _ _ attribute__。
3. the optimization method of the compiler according to claim 1 based on vector interrupt, it is characterised in that:The step (2) in, compiler front-end identifies vector interrupt function in the precompile stage by morphological analysis, syntactic analysis, passes through precompile The obtained subsequent register assigning process of information guiding;If interrupting service function uses these registers, in interrupt spot It is preserved when preservation, otherwise need not be preserved.
4. the optimization method of the compiler according to claim 1 based on vector interrupt, it is characterised in that:The step (6) compiling of instruction for interrupting service function ending is interrupt return instruction by compiler in.
5. the optimization method of the compiler according to claim 1 based on vector interrupt, it is characterised in that:The step (3), step (4) analysis is interrupted in service function, is analyzed its subfunction, the principle of analysis is as follows:
(b1) compiler, which needs to analyze, interrupts register service condition in service function and its subfunction, until analysis function not Until having subfunction again;
(b2) for interrupting service function and its subfunction, parameter general register, fixed general register and height are analyzed The specified register that grade language can influence;
(b3) service condition that only may span across the register of function in analysis interruption service function, interrupts the subfunction of service function In do not have to analysis may span across function register service condition;
(b4) specified register specified when interrupt function defines needs to preserve.
CN201510647971.XA 2015-10-09 2015-10-09 The optimization method of compiler based on vector interrupt Active CN105117269B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510647971.XA CN105117269B (en) 2015-10-09 2015-10-09 The optimization method of compiler based on vector interrupt

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510647971.XA CN105117269B (en) 2015-10-09 2015-10-09 The optimization method of compiler based on vector interrupt

Publications (2)

Publication Number Publication Date
CN105117269A CN105117269A (en) 2015-12-02
CN105117269B true CN105117269B (en) 2018-07-24

Family

ID=54665270

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510647971.XA Active CN105117269B (en) 2015-10-09 2015-10-09 The optimization method of compiler based on vector interrupt

Country Status (1)

Country Link
CN (1) CN105117269B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101936565B1 (en) * 2016-11-14 2019-01-09 엘에스산전 주식회사 Method for controlling interrupt in inverter
CN112395065A (en) * 2020-11-26 2021-02-23 湖北开特汽车电子电器系统股份有限公司 Interrupt service method and device for starting and loading embedded system
CN114489801A (en) * 2022-02-11 2022-05-13 广州翼辉信息技术有限公司 Method, system and medium for measuring interrupt duration of embedded system with high precision
CN117171053B (en) * 2023-11-01 2024-02-20 睿思芯科(深圳)技术有限公司 Test method, system and related equipment for vectorized programming

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1223402A (en) * 1998-01-12 1999-07-21 日本电气株式会社 Compiler capable of reducing interrupt handling in optimization and its optimization method
US6634023B1 (en) * 1998-06-18 2003-10-14 International Business Machines Corporation Compile method, exception handling method and computer
CN101488100A (en) * 2008-01-15 2009-07-22 上海海尔集成电路有限公司 Interruption system implementing method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1223402A (en) * 1998-01-12 1999-07-21 日本电气株式会社 Compiler capable of reducing interrupt handling in optimization and its optimization method
US6634023B1 (en) * 1998-06-18 2003-10-14 International Business Machines Corporation Compile method, exception handling method and computer
CN101488100A (en) * 2008-01-15 2009-07-22 上海海尔集成电路有限公司 Interruption system implementing method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于ARM9内核的IRQ异常中断编程机制的研究;姚宏昕等;《计算机工程与设计》;20091231;第30卷(第12期);2848-2851 *
嵌入式操作系统中断现场保护的优化策略;钱贾敏等;《微计算机信息》;20041130;第20卷(第11期);83-84 *

Also Published As

Publication number Publication date
CN105117269A (en) 2015-12-02

Similar Documents

Publication Publication Date Title
CN103348323B (en) Method and system for performance objective program in computer systems
CN103858099B (en) The method and system applied for execution, the circuit with machine instruction
CN105117269B (en) The optimization method of compiler based on vector interrupt
US6973644B2 (en) Program interpreter
US7873948B2 (en) Method and system for split-compiling a hybrid language program
EP0806725B1 (en) Method and apparatus for early insertion of assembler code for optimization
US8201140B2 (en) System and method for creating and using graphical object instances in a statechart environment
US9672133B2 (en) Systems and methods for debugging applications using dual code generation
US20150268940A1 (en) Automatic loop vectorization using hardware transactional memory
Fisher Control structures for programming languages
US7827542B2 (en) Compiler apparatus
US8341613B2 (en) Reducing stack space consumption via head-call optimization
US5854933A (en) Method for optimizing a computer program by moving certain load and store instructions out of a loop
CN110865814B (en) Compiler implementation method and system supporting heterogeneous computing core architecture
CN109829313A (en) A kind of method and device programming defence SGX side-channel attack based on code reuse
Lakshminarayana et al. Incorporating speculative execution into scheduling of control-flow-intensive designs
CN115809063A (en) Storage process compiling method, system, electronic equipment and storage medium
US20130086565A1 (en) Low-level function selection using vector-width
JP2006196002A (en) Software tool including modeling of asynchronous program flow
CN104750533A (en) C program compiling method and C program compiler
US5778232A (en) Automatic compiler restructuring of COBOL programs into a proc per paragraph model
US11204767B2 (en) Context switching locations for compiler-assisted context switching
US11429358B2 (en) Representing asynchronous state machine in intermediate code
US10949209B2 (en) Techniques for scheduling instructions in compiling source code
CN102360306A (en) Method for extracting and optimizing information of cyclic data flow charts in high-level language codes

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant