Optimization of source code with embedded machine instructions

Data processing: software development – installation – and managem – Software program development tool – Translation of code

Reexamination Certificate

Rate now

  [ 0.00 ] – not rated yet Voters 0   Comments 0

Details

C717S152000

Reexamination Certificate

active

06247174

ABSTRACT:

TECHNICAL FIELD OF THE INVENTION
This invention relates generally to the compilation of computer code performing floating-point arithmetic operations on floating-point registers, and more particularly to enabling, via a new data type, access in source code to the full width of the floating point register representation in the underlying processor.
BACKGROUND OF THE INVENTION
Source-level languages like C and C++ typically do not support constructs that enable access to low-level machine-instructions. Yet many instruction set architectures provide functionally useful machine instructions that cannot readily be accessed from standard source-level constructs.
Typically, programmers, and notably operating system developers, access the functionality afforded by these special (possibly privileged) machine-instructions from source programs by invoking subroutines coded in assembly language, where the machine instructions can be directly specified. This approach suffers from a significant performance drawback in that the overhead of a procedure call/return sequence must be incurred in order to execute the special machine instruction(s). Moreover, the assembly-coded machine instruction sequence cannot be optimized along with the invoking routine.
To overcome the performance limitation with the assembly routine invocation strategy, compilers known in the art, such as the Gnu C compiler (“gcc”), provide some rudimentary high-level language extensions to allow programmers to embed a restricted set of machine instructions directly into their source code. In fact, the 1990 American National Standard for Information Systems—Programming Language C (hereinafter referred to as the “ANSI Standard”) recommends the “asm” keyword as a common extension (though not part of the standard) for embedding machine instructions into source code. The ANSI Standard specifies no details, however, with regard to how this keyword is to be used.
Current schemes that employ this strategy have drawbacks. For instance, gcc employs an arcane specification syntax. Moreover, the gcc optimizer does not have an innate knowledge of the semantics of embedded machine instructions and so the user is required to spell out the optimization restrictions. No semantics checks are performed by the compiler on the embedded instructions and for the most part they are simply “passed through” the compiler and written out to the target assembly file.
Other drawbacks of the inline assembly support in current compilers include:
(a) lack of functionality to allow the user to specify scheduling restrictions associated with embedded machine instructions. This functionality would be particularly advantageous with respect to privileged instructions.
(b) imposition of arbitrary restrictions on the kind of operands that may be specified for the embedded machine instructions, for example:
the compiler may require operands to be simple program variables (where permitting an arbitrary arithmetic expression as an operand would be more advantageous); and
the operands may be unable to refer to machine-specific resources in a syntactically natural manner.
(c) lack of functionality to allow the programmer to access the full range and precision of internal floating-point register representations when embedding floating-point instructions. This functionality would simplify high-precision or high-performance floating-point algorithms.
(d) imposition of restrictions on the ability to inline library procedures that include embedded machine instructions into contexts where such procedures are invoked, thereby curtailing program optimization effectiveness.
In addition, when only a selected subset of the machine opcodes are permitted to be embedded into user programs, it may be cumbersome in current compilers to extend the embedded assembly support for other machine opcodes. In particular, this may require careful modifications to many portions of the compiler source code. An extensible mechanism capable of extending embedded assembly support to other machine opcodes would reduce the number and complexity of source code modifications required.
It would therefore be highly advantageous to develop a compiler with a sophisticated capability for processing machine instructions embedded in high level source code. A “natural” specification syntax would be user friendly, while independent front-end validation would reduce the potential for many programmer errors. Further, it would be advantageous to implement an extensible compiler mechanism that processes source code containing embedded machine instructions where the mechanism is smoothly receptive to programmer-defined parameters indicating the nature and extent of compiler optimization permitted in a given case. A particularly useful application of such an improved compiler would be in coding machine-dependent “library” functions which would otherwise need to be largely written in assembly language and would therefore not be subject to effective compiler optimization, such as inlining.
In summary, there is a need for a compiler mechanism that allows machine instructions to be included in high-level program source code, where the translation and compiler optimization of such instructions offers the following advantageous features to overcome the above-described shortcomings of the current art:
a) a “natural” specification syntax for embedding low-level hardware machine instructions into high-level computer program source code.
b) a mechanism for the compiler front-end to perform syntax and semantic checks on the constructs used to embed machine instructions into program source code in an extensible and uniform manner, that is independent of the specific embedded machine instructions.
c) an extensible mechanism that minimizes the changes required in the compiler to support additional machine instructions.
d) a mechanism for the programmer to indicate the degree of instruction scheduling freedom that may be assumed by the compiler when optimizing high-level programs containing certain types of embedded machine instructions.
e) a mechanism to “inline” library functions containing embedded machine instructions into programs that invoke such library functions, in order to improve the run-time performance of such library function invocations, thereby optimizing overall program execution performance.
Such features would gain yet further advantage and utility in an environment where inline assembly support could gain access to the full width of the floating point registers in the target processor via specification of a corresponding data type in source code.
SUMMARY OF THE INVENTION
These and other objects and features are achieved by one embodiment of the present invention which comprises the following:
1. A general syntax for embedding or “inlining” machine (assembly) instructions into source code. For each machine instruction that is a candidate for source-level inlining, an “intrinsic” (built-in subroutine) is defined. A function prototype is specified for each such intrinsic with enumerated data types used for instruction completers. The function prototype is of the following general form:
opcode_result=_Asm_opcode (opcode_argument_list [,serialization_constraint_specifier])
where _Asm_opcode is the name of the intrinsic function (with the “opcode” portion of the name replaced with the opcode mnemonic). Opcode completers, immediate source operands, and register source operands are specified as arguments to the intrinsic and the register target operand (if applicable) corresponds to the “return value” of the intrinsic.
The data types for register operands are defined to match the requirements of the machine instruction, with the compiler performing the necessary data type conversions on the source arguments and the return value of the “inline-assembly” intrinsics, in much the same way as for any user-defined prototyped function.
Thus, the specification syntax for embedding machine instructions in source code is quite “natural” in that it is very similar to the syntax used for an ordinary fun

LandOfFree

Say what you really think

Search LandOfFree.com for the USA inventors and patents. Rate them and share your experience with other people.

Rating

Optimization of source code with embedded machine instructions does not yet have a rating. At this time, there are no reviews or comments for this patent.

If you have personal experience with Optimization of source code with embedded machine instructions, we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Optimization of source code with embedded machine instructions will most certainly appreciate the feedback.

Rate now

     

Profile ID: LFUS-PAI-O-2468407

  Search
All data on this website is collected from public sources. Our data reflects the most accurate information available at the time of publication.