From: Roy S. <ro...@gm...> - 2009-03-02 19:26:38
Attachments:
cil-embedded.patch.gz
|
Howdy All, I've been playing around with using CIL to rewrite parts of embedded systems code. I keep meaning to clean it up my changes a bit more (see notes below), but decided to stop sitting on the patch and send an initial version out for folks to play with. The patch is for use with the CIL 1.3.6 tarball. Apply it and then take a look at the new README.embedded file for use details. Using CIL with embedded systems required a few changes to account for target specific properties. config.sub: Added msp430 to the set recognized basic_machine types. configure.in: Added avr and msp430 targets. src/machdep.c: Replaced by three target specific files: machdep-native.c (original file), machdep-avr.c, and machdep-msp430.c. The machdep-native.c continues to detect host specific size and alignment settings. The processor specific versions are hard coded to reflect the properties of the embedded targets. src/frontc/cabs2cil.ml: Replaced by three target specific files: cabs2cil-native.ml (original file), cabs2cil-avr.ml, and cabs2cil-msp430.ml. Handling of the GCC mode attributes as performed by cabsTypeAddAttributes within each of these files. The original implementation assumed a 32-bit architecture that could use IInt and IUInt to handle signed and unsigned instances of the __SI__ mode. On embedded processors with a 16-bit int type this must be refined to use ILong and IULong. NOTE: These three implementations of cabs2cil should be merged back into a single cabs2cil.ml that uses information from machdep.ml to select the correct handling of modes at runtime. An example of this can be found in cil.ml which creates theMachine to lookup target specific type byte size and alignment information. Also, the replication of cabs2cil for a few lines of changed code makes the patch MUCH bigger than it needs to be. NOTE: The build processes is currently a little sloppy, with the user having to explicitly create links (or copy over) platform specific machdep and cabs2cil files. A cleaner solution would be to have this done during configuration. I haven't gotten around to that yet. The patch is working great for my work and lets me rewrite code for the AVR and MSP430 targets. Fun times. Hope others find this patch useful and do let me know of any problems. Also, a thanks to Nathan Cooprider for posting his revised version of CIL for the AVR processor in the cXprop project. That revision helped seed the development of this patch. Peace, -Roy |