2 #ifndef _ORC_POWERPC_H_
3 #define _ORC_POWERPC_H_
5 #include <orc/orcprogram.h>
8 POWERPC_R0 = ORC_GP_REG_BASE,
40 POWERPC_V0 = ORC_VEC_REG_BASE,
74 const char * powerpc_get_regname(int i);
75 int powerpc_regnum (int i);
77 void powerpc_emit(OrcCompiler *compiler, unsigned int insn);
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);
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);
95 void powerpc_emit_srawi (OrcCompiler *compiler, int regd, int rega, int shift,
97 void powerpc_emit_655510 (OrcCompiler *compiler, int major, int d, int a,
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,
103 void powerpc_emit_VA (OrcCompiler *compiler, const char *name, unsigned int insn, int d, int a, int b,
105 void powerpc_emit_VA_acb (OrcCompiler *compiler, const char *name, unsigned int insn, int d, int a, int b,
107 void powerpc_emit_VX (OrcCompiler *compiler, unsigned int insn, int d, int a,
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,
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);
126 #define powerpc_emit_vandc(p,a,b,c) powerpc_emit_VX_2 (p, "vandc", 0x10000444, a, b, c)
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)
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)
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)
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)
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)
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)
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)
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)
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)
169 #define powerpc_emit_vperm(p,a,b,c,d) powerpc_emit_VA (p, "vperm", 0x1000002b, a, b, c, d)