Method and Apparatus for Automatically Converting Numeric Data to a Processor Efficient Format for Performing Arithmetic Operations
Abstract
A compiler (or interpreter) detects source language instructions performing arithmetic operations using a fixed point format (preferably packed decimal). Where the operation can be performed without loss of precision or violation of other constraints of the source language, the compiler automatically converts the operands to a floating point format (preferably Decimal Floating Point (DFP)) having hardware support, and re-converts results to the original fixed point format. Preferably, the compiler may combine multiple operations and instructions in an expression tree, analyze the tree, and selectively convert where possible. The compiler preferably performs a heuristic cost judgment in determining whether to use a particular conversion.
Claims
exact text as granted — not AI-modified1 . A method for producing computer programming code, comprising the computer-executed steps of:
receiving source code, said source code containing a plurality of operations, each on a respective at least one operand in a fixed point representation; automatically generating executable code from said source code, said step of automatically generating executable code comprising: (a) automatically making a respective selective determination, for each of a plurality of said operations, whether to execute the respective operation in a floating point representation; (b) with respect to each operation for which said step of automatically making a selective determination determines to execute the respective operation in said floating point representation:
(i) automatically generating code converting the respective at least one operand in said fixed point representation to a corresponding at least one operand in said floating point representation;
(ii) automatically generating code performing a corresponding operation on the corresponding at least one operand in said floating point representation, said corresponding operation on the corresponding at least one operand in said floating point representation corresponding to the respective operation on at least one operand in said fixed point representation; and
(iii) automatically generating code re-converting at least one result of said corresponding operation on the corresponding at least one operand in said floating point representation to said fixed point representation; and
(c) with respect to each operation for which said step of automatically making a selective determination determines not to execute the respective operation in said floating point representation, automatically generating code performing the respective operation on the respective at least one operand in said fixed point representation.
2 . The method for producing computer programming code of claim 1 , wherein said fixed point representation is a packed decimal representation.
3 . The method for producing computer programming code of claim 1 , wherein said floating point representation is a Decimal Floating Point (DFP) representation.
4 . The method for producing computer programming code of claim 4 , wherein said step of automatically generating executable code from said source code comprises automatically traversing an expression tree to identify expressions in said fixed point representation which can be converted to said floating point representation.
5 . The method for producing computer programming code of claim 5 , wherein said step of automatically generating executable code from said source code comprises:
automatically identifying a first subset of said expression tree which can not be converted to said floating point representation; automatically identifying a second subset of said expression tree which can be converted to said floating point representation; and automatically generating code converting expressions to said second subset to said floating point representation, without converting expressions of said first subset to said floating point representation.
6 . The method for producing computer programming code of claim 1 , wherein said step of automatically generating executable code from said source code further comprises the step of automatically choosing said floating point representation from among a plurality of floating point representations of different sizes, said automatically choosing step choosing a smallest sized floating point representation, from among said plurality of floating point representations of different sizes, which is capable of representing said at least one operand, said at least one operation, and said at least one result.
7 . The method for producing computer programming code of claim 1 , wherein said step of automatically generating code performing at least one operation on said at least one operand comprises automatically generating code performing a plurality of successive operations on a plurality of operands, wherein a result of a first of said plurality of operation in said floating point representation is used as an operand of a second of said plurality of successive operations without re-converting to said fixed point representation.
8 . A computer program product for producing computer programming code, comprising:
a plurality of executable instructions recorded on a recordable type media, wherein said instructions, when executed by a digital computing device, cause the device to perform the steps of: receiving source code, said source code containing a plurality of operations, each on a respective at least one operand in a fixed point representation; generating transformed code from said source code, said step of generating transformed code comprising: (a) automatically making a respective selective determination, for each of a plurality of said operations, whether to execute the respective operation in a floating point representation; (b) with respect to each operation for which said step of automatically making a selective determination determines to execute the respective operation in said floating point representation:
(i) generating code converting the respective at least one operand in said fixed point representation to a corresponding at least one operand in said floating point representation;
(ii) generating code performing a corresponding operation on the corresponding at least one operand in said floating point representation, said corresponding operation on the corresponding at least one operand in said floating point representation corresponding to the respective operation on at least one operand in said fixed point representation; and
(iii) generating code re-converting at least one result of said corresponding operation on the corresponding at least one operand in said floating point representation to said fixed point representation; and
(c) with respect to each operation for which said step of automatically making a selective determination determines not to execute the respective operation in said floating point representation, generating code performing the respective operation on the respective at least one operand in said fixed point representation.
9 . The computer program product of claim 8 , wherein said fixed point representation is a packed decimal representation.
10 . The computer program product of claim 8 , wherein said floating point representation is a Decimal Floating Point (DFP) representation.
11 . The computer program product claim 8 , wherein said step of generating transformed code from said source code comprises traversing an expression tree to identify expressions in said fixed point representation which can be converted to said floating point representation.
12 . The computer program product of claim 11 , wherein said step of generating transformed code from said source code comprises:
identifying a first subset of said expression tree which can not be converted to said floating point representation; identifying a second subset of said expression tree which can be converted to said floating point representation; and generating code converting expressions to said second subset to said floating point representation, without converting expressions of said first subset to said floating point representation.
13 . The computer program product of claim 8 , wherein said step of generating transformed code from said source code further comprises the step of choosing said floating point representation from among a plurality of floating point representations of different sizes, said choosing step choosing a smallest sized floating point representation, from among said plurality of floating point representations of different sizes, which is capable of representing said at least one operand, said at least one operation, and said at least one result.
14 . The computer program product of claim 8 , wherein said step of generating code performing at least one operation on said at least one operand comprises generating code performing a plurality of successive operations on a plurality of operands, wherein a result of a first of said plurality of operation in said floating point representation is used as an operand of a second of said plurality of successive operations without re-converting to said fixed point representation.
15 . A computer system for developing computer programming code, comprising:
at least one processor; a memory; a computer programming code generator embodied as a plurality of instructions addressable in said memory and executable on said processor, said computer programming code generator generating transformed code from source code, said source code containing a plurality of operations, each on a respective at least one operand in a fixed point representation; wherein said computer programming code generator automatically makes a respective selective determination, for each of a plurality of said operations, whether to execute the respective operation in a floating point representation, and (a) with respect to each operation for which said computer programming code generator determines to execute the respective operation in said floating point representation, generates transformed code containing:
(i) at least one conversion operation converting the respective at least one operand in said fixed point representation to a corresponding at least one operand in said floating point representation;
(ii) at least one operation on the corresponding at least one operand in said floating point representation which corresponds to the respective operation on at least one operand in said fixed point representation, and
(iii) at least one re-conversion operation re-converting at least one result of the corresponding at least one operation on the corresponding at least one operand in said floating point representation to said fixed point representation; and
(b) with respect to each operation for which said computer programming code generator determines not to execute the respective operation in said floating point representation, generating transformed code performing the respective operation on the respective at least one operand in said fixed point representation.
16 . The computer system of claim 15 , wherein said computer programming code generator is a compiler which generates executable code from said source code.
17 . The computer system of claim 15 , wherein said fixed point representation is a packed decimal representation.
18 . The computer system of claim 15 , wherein said floating point representation is a Decimal Floating Point (DFP) representation.Join the waitlist — get patent alerts
Track US2008148224A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.