Beautified (indented) compiler source according to gnu coding style
[fw/sdcc] / src / izt / gen_generic.c
1 #include "izt.h"
2 #include "gen.h"
3
4 static void
5 _genLabel (iCode * ic)
6 {
7   iemit ("!tlabeldef", IC_LABEL (ic)->key + 100);
8 }
9
10 static void
11 _genGoto (iCode * ic)
12 {
13   iemit ("jp !tlabel", IC_LABEL (ic)->key + 100);
14 }
15
16 static void
17 _genFunction (iCode * ic)
18 {
19   symbol *sym = OP_SYMBOL (IC_LEFT (ic));
20
21   // Create the function header
22   iemit ("!functionheader", sym->name);
23   iemit ("!functionlabeldef", sym->rname);
24
25   if (sym->stack)
26     {
27       iemit ("!enterx", sym->stack);
28     }
29   else
30     {
31       iemit ("!enter");
32     }
33 }
34
35 static void
36 _genReturn (iCode * ic)
37 {
38   if (IC_LEFT (ic))
39     {
40       // Has a return value.  Load it up.
41       iemit ("; PENDING: call the generic loader to setup the return value.");
42     }
43
44   if (ic->next && ic->next->op == LABEL && IC_LABEL (ic->next) == returnLabel)
45     {
46       // The next label is the return label.  Dont bother emitting a jump.
47     }
48   else
49     {
50       iemit ("jp !tlabel", returnLabel->key + 100);
51     }
52 }
53
54 static EMITTER _base_emitters[] =
55 {
56   {LABEL, _genLabel},
57   {GOTO, _genGoto},
58   {FUNCTION, _genFunction},
59   {RETURN, _genReturn},
60   {0, NULL}
61 };
62
63 void
64 izt_initBaseEmitters (hTab ** into)
65 {
66   izt_addEmittersToHTab (into, _base_emitters);
67 }