<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Should m3cg provide enough information for a backend to generate idiomatic C?<br>(What is idiomatic C? e.g. I'm ignoring loop constructs and exception handlinh..)<br><br><br>Should we make it so?<br><br><br>Or be pragmatic and see if anyone gets to that point?<br><br><br>But, look at this another way.<br>Let's say we are keeping the gcc backend.<br><br><br>Isn't it reasonable to have a better experience with stock gdb?<br><br><br>What should m3cg look like then?<br><br><br>Matching up m3front to gcc turns out to be "wierd".<br>As does having a backend generate "C".<br><br><br>In particular, "wierd" because there is a "level mismatch".<br><br><br>m3cg presents a fairly low level view of the program.<br>  It does layout. Global variables are stuffed into what you might call a "struct", with<br>no assigned field names. Field references are done by adding to addresses and casting.<br><br><br>Too low level to provide a "good" gcc tree representation or to generate "normal" C.<br><br><br>One might be able to, by somewhat extraordinary means, make due.<br>That is, specifically one could deduce field references from<br>offsets/sizes. But maybe it is reasonable for load/store<br>to include fields? Maybe in addition to what it provides?<br><br><br>As well, it appears to me, that<br><br><br>given TYPE Enum = {One, Two, Three};<br><br>the m3cg is like:<br><br>declare enum typeidblah<br>declare enum_elt One<br>declare enum_elt Two<br>declare enum_elt Three<br>declare_typename typeidblah Enum<br><br><br>One kind of instead wants more like:<br><br><br>declare enum typeidblah Enum<br>declare enum_elt One => rename it Enum_One<br>declare enum_elt Two ""<br>declare enum_elt Three ""<br><br><br>However I understand that {One, Two, Three} exists<br>as anonymous type independent of the name "Enum".<br><br><br>One could just as well have:<br>given TYPE Enum1 = {One, Two, Three};<br>given TYPE Enum2 = {One, Two, Three};<br><br><br>Enum1 and Enum2 probably have the same typeid, and are just<br>two typenames for the same type.<br><br><br>likewise:<br>given TYPE Enum1 = {One, Two, Three};<br>given TYPE Enum2 = Enum1;<br><br><br>but, pragmatically, in the interest of generating better C,<br>can we pass a name along with declare_enum?<br><br>I ask somewhat rhetorically. I realize there is the answer:<br>  enum Mtypeid { Mtypeid_One, Mtypeid_Two, Mtypeid_Three };<br>  typedef enum Mtypeid Enum1;<br><br><br>Also, enum variables I believe end up as just UINT8, 16, or 32.<br>Loads of enum values I believe end up as just loads of integers.<br>Can we pass along optional enum names with declare_local/declare_param?<br>And optional enum names with load_int?<br>Or add a separate load_enum call?<br><br><br>Really, I understand that the current interface can be pressed to do<br>pretty adequate things. I can infer field references. The way enums work<br>isn't too bad.<br><br><br> - Jay                                      </div></body>
</html>