tomlokhorst / language-cil

Manipulating Common Intermediate Language AST in Haskell
Other
20 stars 8 forks source link

Unaligned load/store #1

Closed dmcclean closed 13 years ago

dmcclean commented 13 years ago

Hi Tom, Would you take a commit that added syntax for the unaligned opcode prefix (see Partition III, Section 2.5)?

It would be adding something like:

data Alignment = ByteAligned | DoubleByteAligned | QuadByteAligned

data OpCode = ...
                     | Unaligned Alignment OpCode

and the resulting changes to parsing, pretty-printing, ...

The prefix is only legal before ldind, stind, ldfld, stfld, ldobj, stobj, initblk, cpblk instructions, but there is a similar issue with the tail prefix which is handled in this same way (allow construction of nonsense in Syntax.hs, use error to report construction of nonsense through Build.hs).

tomlokhorst commented 13 years ago

I had to read up on the unaligned prefix, as I've never used it. Your proposed addition looks good, I'd definitely merge a commit for that.

I've never really like that the tail call syntax allowed for nonsensical opcodes, but I guess that's part of the design of CIL itself.

I did add two opcodes for tail calls: Tail (to properly reflect the fact that its a separate opcode in CIL), and Tailcall (for nicer ASTs in Haskell).

tomlokhorst commented 13 years ago

Issue is being resolved in a pull request.