Initial commit to Gerrit
[profile/ivi/orc.git] / orc / orcpowerpc.h
1
2 #ifndef _ORC_POWERPC_H_
3 #define _ORC_POWERPC_H_
4
5 #include <orc/orcprogram.h>
6
7 enum {
8   POWERPC_R0 = ORC_GP_REG_BASE,
9   POWERPC_R1,
10   POWERPC_R2,
11   POWERPC_R3,
12   POWERPC_R4,
13   POWERPC_R5,
14   POWERPC_R6,
15   POWERPC_R7,
16   POWERPC_R8,
17   POWERPC_R9,
18   POWERPC_R10,
19   POWERPC_R11,
20   POWERPC_R12,
21   POWERPC_R13,
22   POWERPC_R14,
23   POWERPC_R15,
24   POWERPC_R16,
25   POWERPC_R17,
26   POWERPC_R18,
27   POWERPC_R19,
28   POWERPC_R20,
29   POWERPC_R21,
30   POWERPC_R22,
31   POWERPC_R23,
32   POWERPC_R24,
33   POWERPC_R25,
34   POWERPC_R26,
35   POWERPC_R27,
36   POWERPC_R28,
37   POWERPC_R29,
38   POWERPC_R30,
39   POWERPC_R31,
40   POWERPC_V0 = ORC_VEC_REG_BASE,
41   POWERPC_V1,
42   POWERPC_V2,
43   POWERPC_V3,
44   POWERPC_V4,
45   POWERPC_V5,
46   POWERPC_V6,
47   POWERPC_V7,
48   POWERPC_V8,
49   POWERPC_V9,
50   POWERPC_V10,
51   POWERPC_V11,
52   POWERPC_V12,
53   POWERPC_V13,
54   POWERPC_V14,
55   POWERPC_V15,
56   POWERPC_V16,
57   POWERPC_V17,
58   POWERPC_V18,
59   POWERPC_V19,
60   POWERPC_V20,
61   POWERPC_V21,
62   POWERPC_V22,
63   POWERPC_V23,
64   POWERPC_V24,
65   POWERPC_V25,
66   POWERPC_V26,
67   POWERPC_V27,
68   POWERPC_V28,
69   POWERPC_V29,
70   POWERPC_V30,
71   POWERPC_V31
72 };
73
74 const char * powerpc_get_regname(int i);
75 int powerpc_regnum (int i);
76
77 void powerpc_emit(OrcCompiler *compiler, unsigned int insn);
78
79 void powerpc_emit_add (OrcCompiler *compiler, int regd, int rega, int regb);
80 void powerpc_emit_addi_rec (OrcCompiler *compiler, int regd, int rega, int imm);
81 void powerpc_emit_addi (OrcCompiler *compiler, int regd, int rega, int imm);
82 void powerpc_emit_lwz (OrcCompiler *compiler, int regd, int rega, int imm);
83 void powerpc_emit_stw (OrcCompiler *compiler, int regs, int rega, int offset);
84 void powerpc_emit_stwu (OrcCompiler *compiler, int regs, int rega, int offset);
85
86 void powerpc_emit_ret (OrcCompiler *compiler);
87 void powerpc_emit_b (OrcCompiler *compiler, int label);
88 void powerpc_emit_beq (OrcCompiler *compiler, int label);
89 void powerpc_emit_bne (OrcCompiler *compiler, int label);
90 void powerpc_emit_label (OrcCompiler *compiler, int label);
91 void powerpc_add_fixup (OrcCompiler *compiler, int type, unsigned char *ptr, int label);
92 void powerpc_do_fixups (OrcCompiler *compiler);
93 void orc_powerpc_flush_cache (OrcCode *code);
94
95 void powerpc_emit_srawi (OrcCompiler *compiler, int regd, int rega, int shift,
96     int record);
97 void powerpc_emit_655510 (OrcCompiler *compiler, int major, int d, int a,
98     int b, int minor);
99 void powerpc_emit_D (OrcCompiler *compiler, const char *name,
100     unsigned int insn, int regd, int rega, int imm);
101 void powerpc_emit_X (OrcCompiler *compiler, unsigned int insn, int d, int a,
102     int b);
103 void powerpc_emit_VA (OrcCompiler *compiler, const char *name, unsigned int insn, int d, int a, int b,
104     int c);
105 void powerpc_emit_VA_acb (OrcCompiler *compiler, const char *name, unsigned int insn, int d, int a, int b,
106     int c);
107 void powerpc_emit_VX (OrcCompiler *compiler, unsigned int insn, int d, int a,
108     int b);
109 void powerpc_emit_VX_b (OrcCompiler *p, const char *name, unsigned int insn, int a);
110 void powerpc_emit_VX_db (OrcCompiler *p, const char *name, unsigned int insn, int d, int b);
111 void powerpc_emit_VX_dbi (OrcCompiler *p, const char *name, unsigned int insn, int d, int b, int imm);
112 void powerpc_emit_VXR (OrcCompiler *compiler, const char *name,
113     unsigned int insn, int d, int a, int b, int record);
114 void powerpc_emit_VX_2 (OrcCompiler *p, const char *name, unsigned int insn,
115     int d, int a, int b);
116 void powerpc_emit_VX_3 (OrcCompiler *p, const char *name, unsigned int insn,
117     int d, int a, int b, int c);
118 void powerpc_emit_VX_3_reg (OrcCompiler *p, const char *name, unsigned int insn,
119     int d, int a, int b, int c);
120 void powerpc_emit_VX_4 (OrcCompiler *p, const char *name, unsigned int insn,
121     int d, int a);
122 int powerpc_get_constant (OrcCompiler *p, int type, int value);
123 int powerpc_get_constant_full (OrcCompiler *p, int value0, int value1, int value2, int value3);
124
125 /* instructions */
126 #define powerpc_emit_vandc(p,a,b,c)        powerpc_emit_VX_2 (p, "vandc", 0x10000444, a, b, c)
127
128 #define powerpc_emit_vor(p,a,b,c)          powerpc_emit_VX_2 (p, "vor", 0x10000484, a, b, c)
129 #define powerpc_emit_vxor(p,a,b,c)         powerpc_emit_VX_2 (p, "vxor", 0x100004c4, a, b, c)
130
131 #define powerpc_emit_vmulesb(p,a,b,c)      powerpc_emit_VX_2 (p, "vmulesb", 0x10000308, a, b, c)
132 #define powerpc_emit_vmuleub(p,a,b,c)      powerpc_emit_VX_2 (p, "vmuleub", 0x10000208, a, b, c)
133 #define powerpc_emit_vmulesh(p,a,b,c)      powerpc_emit_VX_2 (p, "vmulesh", 0x10000348, a, b, c)
134 #define powerpc_emit_vmuleuh(p,a,b,c)      powerpc_emit_VX_2 (p, "vmuleuh", 0x10000248, a, b, c)
135
136 #define powerpc_emit_vmrghb(p,a,b,c)       powerpc_emit_VX_2 (p, "vmrghb", 0x1000000c, a, b, c)
137 #define powerpc_emit_vmrghh(p,a,b,c)       powerpc_emit_VX_2 (p, "vmrghh", 0x1000004c, a, b, c)
138
139 #define powerpc_emit_vpkshss(p,a,b,c)      powerpc_emit_VX_2 (p, "vpkshss", 0x1000018e, a, b, c)
140 #define powerpc_emit_vpkshus(p,a,b,c)      powerpc_emit_VX_2 (p, "vpkshus", 0x1000010e, a, b, c)
141 #define powerpc_emit_vpkswss(p,a,b,c)      powerpc_emit_VX_2 (p, "vpkswss", 0x100001ce, a, b, c)
142 #define powerpc_emit_vpkswus(p,a,b,c)      powerpc_emit_VX_2 (p, "vpkswus", 0x1000014e, a, b, c)
143 #define powerpc_emit_vpkuhus(p,a,b,c)      powerpc_emit_VX_2 (p, "vpkuhus", 0x1000008e, a, b, c)
144 #define powerpc_emit_vpkuhum(p,a,b,c)      powerpc_emit_VX_2 (p, "vpkuhum", 0x1000000e, a, b, c)
145 #define powerpc_emit_vpkuwus(p,a,b,c)      powerpc_emit_VX_2 (p, "vpkuwus", 0x100000ce, a, b, c)
146 #define powerpc_emit_vpkuwum(p,a,b,c)      powerpc_emit_VX_2 (p, "vpkuwum", 0x1000004e, a, b, c)
147
148 #define powerpc_emit_vadduhm(p,a,b,c)      powerpc_emit_VX_2 (p, "vadduhm", 0x10000040, a, b, c)
149 #define powerpc_emit_vadduwm(p,a,b,c)      powerpc_emit_VX_2 (p, "vadduwm", 0x10000080, a, b, c)
150 #define powerpc_emit_vsububm(p,a,b,c)      powerpc_emit_VX_2 (p, "vsububm", 0x10000400, a, b, c)
151 #define powerpc_emit_vsum4ubs(p,a,b,c)     powerpc_emit_VX_2 (p, "vsum4ubs", 0x10000608, a, b, c)
152
153 #define powerpc_emit_vmaxub(p,a,b,c)       powerpc_emit_VX_2 (p, "vmaxub", 0x10000002, a, b, c)
154 #define powerpc_emit_vmaxsb(p,a,b,c)       powerpc_emit_VX_2 (p, "vmaxsb", 0x10000102, a, b, c)
155 #define powerpc_emit_vmaxsh(p,a,b,c)       powerpc_emit_VX_2 (p, "vmaxsh", 0x10000142, a, b, c)
156 #define powerpc_emit_vmaxsw(p,a,b,c)       powerpc_emit_VX_2 (p, "vmaxsw", 0x10000182, a, b, c)
157
158 #define powerpc_emit_vminub(p,a,b,c)       powerpc_emit_VX_2 (p, "vminub", 0x10000202, a, b, c)
159 #define powerpc_emit_vminsb(p,a,b,c)       powerpc_emit_VX_2 (p, "vminsb", 0x10000302, a, b, c)
160 #define powerpc_emit_vminsh(p,a,b,c)       powerpc_emit_VX_2 (p, "vminsh", 0x10000342, a, b, c)
161 #define powerpc_emit_vminsw(p,a,b,c)       powerpc_emit_VX_2 (p, "vminsw", 0x10000382, a, b, c)
162
163 #define powerpc_emit_vsldoi(p,a,b,c,d)     powerpc_emit_VX_3 (p, "vsldoi", 0x1000002c | (d<<6), a, b, c, d)
164 #define powerpc_emit_vmladduhm(p,a,b,c,d)  powerpc_emit_VA (p, "vmladduhm", 0x10000022, a, b, c, d)
165
166 #define powerpc_emit_vupkhsb(p,a,b)        powerpc_emit_VX_4 (p, "vupkhsb", 0x1000020e, a, b)
167 #define powerpc_emit_vupkhsh(p,a,b)        powerpc_emit_VX_4 (p, "vupkhsh", 0x1000024e, a, b)
168
169 #define powerpc_emit_vperm(p,a,b,c,d)      powerpc_emit_VA (p, "vperm", 0x1000002b, a, b, c, d)
170
171
172 #endif
173