Claims
- 1. A method for creating a data structure in assembly language that conforms to the semantics of an analogous data structure in a high level language wherein the method transparently adapts the data structure to a selected set of memory alignment constraints, the method comprising the steps of:
defining a set of primitive data types that have a one-to-one correspondence to analogous primitive data types in the high level language such that the definition of each primitive data type is transparently adapted to the selected set of memory alignment constraints; defining a template for the data structure wherein each element of the data structure is either selected from the set of primitive data types or is a substructure that is transparently adapted to the selected set of memory alignment constraints and the data structure length is transparently adapted to the selected set of memory alignment constraints; allocating memory for the data structure based on the template definition such that the allocated memory transparently conforms to the selected set of memory alignment constraints; and creating an initialization record for the data structure that is transparently adapted to the selected set of memory alignment constraints.
- 2. The method of claim 1 wherein the selected set of memory alignment constraints is determined by a memory model selected from a set of memory models supported by a compiler of the high level language, a memory length imposed by the compiler for each primitive data type of the set of primitive data types, and address alignment constraints imposed by the target hardware architecture and the compiler.
- 3. The method of claim 2 wherein the set of memory models is comprised of a large memory model and a small memory model.
- 4. The method of claim 2 wherein the step of defining a set of primitive data types is comprised of selecting a memory length and a memory alignment constraint for each primitive data type in the set of primitive data types as required by the memory model selected from the set of memory models.
- 5. The method of claim 4 wherein the set of primitive data types is comprised of a code pointer and a data pointer.
- 6. The method of claim 2 wherein the step of defining a template comprises defining a first alignment flag uniquely associated with the template such that the value of the first alignment flag indicated whether or not the data structure has a memory alignment constraint.
- 7. The method of claim 6 wherein the step of defining a template further comprises adjusting the length of the template in response to the memory alignment constraint indicated by the first alignment flag wherein the length adjustment comprises inserting a hole at the end of the template.
- 8. The method of claim 7 wherein the step of defining a template further comprises adjusting the length of the template and aligning a substructure of the data structure in response to a second alignment flag uniquely associated with a template of the substructure wherein the length adjustment and memory alignment comprise inserting a hole in the template immediately preceding the beginning of the substructure.
- 9. The method of claim 6 wherein the step of allocating memory is comprised of allocating memory space for the data structure at a memory alignment responsive to the memory alignment constraint indicated by the first alignment flag.
- 10. The method of claim 6 wherein the step of creating an initialization record further comprises transparently detecting holes inserted in the data structure to conform to the selected set of memory alignment constraints and supplying a predetermined fill value for the holes.
- 11. The method of claim 10 wherein the initialization record is comprised of a header and an initial value for each element of the data structure.
- 12. The method of claim 11 wherein the step of creating an initialization record is comprised of:
allocating space in an initialization memory for the header of the initialization record; ensuring that a first initial value of the initialization record is placed in the initialization memory at a memory alignment responsive to the memory alignment constraints indicated by the first alignment flag; allocating a portion of the initialization memory for each element of the data structure such that
if the element is selected from the set of primitive data types, the portion of the initialization memory allocated corresponds to the memory length of the selected primitive data type and the allocated memory space begins at a memory alignment responsive to the selected set of memory alignment constraints, or if the element is a substructure, the portion of the initialization memory allocated corresponds to a length of a template of the substructure and the allocated memory space begins at a memory alignment responsive to a memory alignment constraint indicated by a second alignment flag uniquely associated with the template of the substructure; and placing an initial value for each element of the data structure in the portion of the initialization memory spaced allocated to the element.
- 13. The method of claim 1 wherein the high level language is selected from the group consisting of C, C++, and Java.
- 14. A method for creating a data structure in assembly language that conforms to the semantics of an analogous data structure in a high level language wherein the method transparently adapts the data structure to a selected set of memory alignment constraints determined by a memory model selected from a set of memory models supported by a compiler of the high level language, a memory length imposed by the compiler for each primitive data type of the set of primitive data types, and address alignment constraints imposed by the target hardware architecture and the compiler, the method comprising the steps of:
defining a set of primitive data types that have a one-to-one correspondence to analogous primitive data types in the high level language by selecting a memory length for each primitive data type in the set of primitive data types as required by a memory model selected from the set of memory models; defining a template for the data structure, wherein
a first alignment flag is created and uniquely associated with the template such that the value of the first alignment flag indicates whether or not the data structure has a memory alignment constraint; each element of the data structure is either selected from the set of primitive data types or is a substructure; a length of the template is adjusted in response to the memory alignment constraint indicated by the first alignment flag wherein the length adjustment comprises inserting a hole at the end of the template; and the length of the template is adjusted and a substructure of the data structure is aligned in response to a second alignment flag uniquely associated with a template of the substructure wherein the length adjustment and substructure alignment comprise inserting a hole in the template immediately preceding the beginning of the substructure; allocating memory for the data structure at a memory alignment responsive to the memory alignment constraint indicated by the first alignment flag; and creating an initialization record for the data structure that is transparently adapted to the memory alignment constraint indicated by the first alignment flag and any holes inserted in the data structure to conform to the selected set of memory alignment constraints are given a predetermined fill value.
- 15. The method of claim 14 wherein the initialization record is comprised of a header and an initial value for each element of the data structure and the step of creating an initialization record is comprised of:
allocating space in an initialization memory for the header of the initialization record; ensuring that a first initial value of the initialization record is placed in the initialization memory at a memory alignment responsive to the memory alignment constraint indicated by the first alignment flag; allocating a portion of the initialization memory for each element of the data structure such that: if the element is selected from the set of primitive data types, the portion of the initialization memory allocated corresponds to the memory length of the selected primitive data type and the allocated memory space begins at a memory alignment responsive to the selected set of memory alignment constraints, or
if the element is a substructure, the portion of the initialization memory allocated corresponds to a length of a template of the substructure and the allocated memory space begins at a memory alignment responsive to a memory alignment constraint indicated by a second alignment flag uniquely associated with the template of the substructure; and placing an initial value for each element of the data structure in the portion of the initialization memory allocated to the element.
Parent Case Info
[0001] This application is related to and claims priority under 35 USC §119 (e)(1) to Provisional Application Serial No. 60/277,114, (TI-32563) Portable Technique for Allocation, Initialization and Access of Aggregate Data Type for DSP Architecture With Mixed Memory Granularity filed on Mar. 19, 2001.
Provisional Applications (1)
|
Number |
Date |
Country |
|
60277114 |
Mar 2001 |
US |