Update svn merge history.
[sdcc.git] / sdcc / src / SDCCgen.h
blob6a1e76d379e95ac5b739bd85adad88c78f36036f
1 /*-------------------------------------------------------------------------
2 SDCCgen.h - header file for target code generation common functions
4 Copyright (C) 2012, Borut Razem
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 -------------------------------------------------------------------------*/
21 #ifndef SDCCGEN_H
22 #define SDCCGEN_H 1
24 #include <stdarg.h>
26 #include <SDCCicode.h>
28 #define initGenLineElement() memset (&genLine.lineElement, 0, sizeof (lineElem_t))
29 #define labelKey2num(key) ((key) + 100)
31 /* can be inherited by each port */
32 typedef struct asmLineNodeBase
34 int size;
35 bitVect *regsRead;
36 bitVect *regsWritten;
38 asmLineNodeBase;
40 typedef struct lineElem_s
42 char *line;
43 iCode *ic;
44 unsigned int isInline:1;
45 unsigned int isComment:1;
46 unsigned int isDebug:1;
47 unsigned int isLabel:1;
48 unsigned int visited:1;
49 asmLineNodeBase *aln;
51 lineElem_t;
53 typedef struct lineNode_s
55 #ifdef UNNAMED_STRUCT_TAG
56 struct lineElem_s;
57 #else
58 /* exactly the same members as of struct lineElem_s */
59 char *line;
60 iCode *ic;
61 unsigned int isInline:1;
62 unsigned int isComment:1;
63 unsigned int isDebug:1;
64 unsigned int isLabel:1;
65 unsigned int visited:1;
66 asmLineNodeBase *aln;
67 #endif
68 struct lineNode_s *prev;
69 struct lineNode_s *next;
71 lineNode;
73 typedef struct genLine_s
75 /* double linked list of lines */
76 lineNode *lineHead;
77 lineNode *lineCurr;
79 /* global line */
80 lineElem_t lineElement;
81 } genLine_t;
83 extern genLine_t genLine;
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
89 lineNode *newLineNode (const char *line);
90 lineNode *connectLine (lineNode * pl1, lineNode * pl2);
91 void destroy_line_list (void);
92 const char *format_opcode (const char *inst, const char *fmt, va_list ap);
93 void emit_raw (const char *line);
94 void va_emitcode (const char *inst, const char *fmt, va_list ap);
95 void emitcode (const char *inst, const char *fmt, ...);
96 void emitLabel (const symbol * tlbl);
97 void genInline (iCode * ic);
98 void printLine (lineNode *, struct dbuf_s *);
99 iCode *ifxForOp (const operand *op, const iCode *ic);
101 #ifdef __cplusplus
103 #endif
105 #endif