Added missing file.
[tinycc/k1w1.git] / i386-gen.h
blob66ce6ddc19f2ea1d44e23b186e65680b0a898985
1 /*
2 * X86 code generator for TCC
3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef __I386_GEN_H__
21 #define __I386_GEN_H__
23 /* number of available registers */
24 #define NB_REGS 4
26 /* a register can belong to several classes. The classes must be
27 sorted from more general to more precise (see gv2() code which does
28 assumptions on it). */
29 #define RC_INT 0x0001 /* generic integer register */
30 #define RC_FLOAT 0x0002 /* generic float register */
31 #define RC_EAX 0x0004
32 #define RC_ST0 0x0008
33 #define RC_ECX 0x0010
34 #define RC_EDX 0x0020
35 #define RC_IRET RC_EAX /* function return: integer register */
36 #define RC_LRET RC_EDX /* function return: second integer register */
37 #define RC_FRET RC_ST0 /* function return: float register */
39 /* pointer size, in bytes */
40 #define PTR_SIZE 4
42 /* long double size and alignment, in bytes */
43 #define LDOUBLE_SIZE 12
44 #define LDOUBLE_ALIGN 4
45 /* maximum alignment (for aligned attribute support) */
46 #define MAX_ALIGN 8
48 /******************************************************/
49 /* ELF defines */
51 #define EM_TCC_TARGET EM_386
53 /* relocation type for 32 bit data relocation */
54 #define R_DATA_32 R_386_32
55 #define R_DATA_PTR R_386_32
56 #define R_JMP_SLOT R_386_JMP_SLOT
57 #define R_COPY R_386_COPY
59 #define ELF_START_ADDR 0x08048000
61 /* pretty names for the registers */
62 enum {
63 TREG_EAX = 0,
64 TREG_ECX,
65 TREG_EDX,
66 TREG_ST0,
69 extern const int reg_classes[];
71 /* return registers for function */
72 #define REG_IRET TREG_EAX /* single word int return register */
73 #define REG_LRET TREG_EDX /* second word return register (for long long) */
74 #define REG_FRET TREG_ST0 /* float return register */
76 /* defined if function parameters must be evaluated in reverse order */
77 #define INVERT_FUNC_PARAMS
79 /* defined if structures are passed as pointers. Otherwise structures
80 are directly pushed on stack. */
81 //#define FUNC_STRUCT_PARAM_AS_PTR
83 void g(int c);
84 void o(unsigned int c);
85 void gen_le32(int c);
86 void store(int r, SValue *v);
87 void load(int r, SValue *sv);
88 void gsym(int t);
89 void gfunc_call(int nb_args);
90 void gen_opi(int op);
91 void gen_opf(int op);
92 void gen_cvt_itof(int t);
93 void gen_cvt_ftoi(int t);
94 int gjmp(int t);
95 void gjmp_addr(int a);
96 void gsym_addr(int t, int a);
97 void ggoto(void);
98 void gfunc_prolog(CType *func_type);
99 int gtst(int inv, int t);
100 void gfunc_epilog(void);
101 void gen_cvt_ftof(int t);
103 /* psym is used to put an instruction with a data field which is a
104 reference to a symbol. It is in fact the same as oad ! */
105 #define psym oad
107 /* instruction + 4 bytes data. Return the address of the data */
108 int oad(int c, int s);
110 #endif /* __I386_GEN_H__ */