emit.h
2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright (C) 1998 by the Board of Trustees
* of Leland Stanford Junior University.
* Copyright (C) 1998 Digital Equipment Corporation
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
#ifndef EMIT_H
#define EMIT_H
/*
* this contains the emission macros, but not the
* generic EMIT_INST, which must be defined elsewhere
*/
#define EMIT_FAST
#ifdef EMIT_FAST
#define EMIT_M(_opcode,_ra,_rb,_off) \
EMIT_U(_opcode<<26|(_ra)<<21|(_rb)<<16|((_off)&0xffff))
#define EMIT_OPI(_opcode,_func,_ra,_lit,_rc) \
EMIT_U(_opcode<<26|(_ra)<<21|((_lit)&0xff)<<13|(1<<12)|(_func)<<5|(_rc))
#define EMIT_OP(_opcode,_func,_ra,_rb,_rc) \
EMIT_U(_opcode<<26|(_ra)<<21|(_rb)<<16|(_func)<<5|(_rc))
#else /* EMIT_FAST */
j
#define EMIT_M(_opcode,_ra,_rb,_off) { register union alpha_instruction t; \
ASSERT(_ra<32 && _rb<32 && ((int64)(_off)) >=-32768 && ((int64)(_off)) <32768); \
t.common.opcode = _opcode; \
t.m_format.ra = _ra; \
t.m_format.rb = _rb; \
t.m_format.memory_displacement = (_off); \
EMIT_INSTR(t); }
#define EMIT_OPI(_opcode,_func,_ra,_lit,_rc) { register union alpha_instruction t; \
ASSERT( _lit > -127 && _lit < 128 && _ra<32&&_rc<32); \
t.common.opcode = _opcode; \
t.l_format.function = _func; \
t.l_format.form = 1; \
t.l_format.literal = _lit; \
t.l_format.ra = _ra; \
t.l_format.rc = _rc; \
EMIT_INSTR(t); }
#define EMIT_OP(_opcode,_func,_ra,_rb,_rc) { register union alpha_instruction t; \
t.common.opcode = _opcode; \
t.o_format.function = _func; \
t.o_format.form = 0; \
t.o_format.ra = _ra; \
t.o_format.rb = _rb; \
t.o_format.rc = _rc; \
EMIT_INSTR(t); }
#endif /* EMIT_FAST */
#define EMIT_LDA(_ra,_rb,_off) EMIT_M(op_lda,_ra,_rb,_off)
#define EMIT_STORE(_ra,_rb,_off) EMIT_M(op_stq,_ra,_rb,_off)
#define EMIT_LOAD(_ra,_rb,_off) EMIT_M(op_ldq,_ra,_rb,_off)
#define EMIT_JMP(_ra,_rb,_func,_hint) { register union alpha_instruction t; \
t.common.opcode = op_jsr; \
t.j_format.ra = _ra; \
t.j_format.rb = _rb; \
t.j_format.function = _func; \
t.j_format.hint = _hint; \
EMIT_INSTR(t); }
#define EMIT_ADDI(_ra,_lit,_rc) EMIT_OPI(op_inta,inta_addq,_ra,_lit,_rc)
#define EMIT_MOVE(_src,_dst) EMIT_OP(op_intl,intl_bis,_src,_src,_dst)
#define EMIT_NOP() EMIT_OP(op_intl,intl_bis,REG_ZERO,REG_ZERO,REG_ZERO)
/*
* reload all caller-saved registers after callout
*/
#define EMIT_RELOAD() { \
EMIT_LOAD(DELTAREG_CONSTANTS,DELTAREG_BASE,CONSTANTS_OFF); \
EMIT_LOAD(DELTAREG_CURIQC,DELTAREG_BASE,CURIQC_OFF); \
EMIT_LOAD(DELTAREG_CURDQC,DELTAREG_BASE,CURDQC_OFF); \
}
#define LENGTH_EMIT_RELOAD 3
extern void EmitFunctions(int cache);
extern void *GetEmitFunction(int cache, int callout);
#endif