Define __builtin_va_list as a built-in type.
[suif.git] / html / suif1_24.html
bloba86d99f08a7f04ff90409ca00a5d4ce2df087389
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.54
4 from suif1.texi on 28 April 1999 -->
6 <TITLE>The SUIF Version 1 Library - Opcodes and Formats</TITLE>
7 <link href="suif1_25.html" rel=Next>
8 <link href="suif1_23.html" rel=Previous>
9 <link href="suif1_toc.html" rel=ToC>
11 </HEAD>
12 <BODY>
13 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_23.html">previous</A>, <A HREF="suif1_25.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
14 <P><HR><P>
17 <H3><A NAME="SEC24" HREF="suif1_toc.html#TOC24">Opcodes and Formats</A></H3>
18 <P>
19 <A NAME="IDX135"></A>
20 <A NAME="IDX136"></A>
22 </P>
23 <P>
24 <A NAME="IDX137"></A>
25 <A NAME="IDX138"></A>
26 <A NAME="IDX139"></A>
27 <A NAME="IDX140"></A>
28 The <CODE>opcode</CODE> and <CODE>set_opcode</CODE> methods may be used to access
29 the opcode field in an instruction. These opcodes are members of the
30 <CODE>if_ops</CODE> enumerated type. The internal names for the opcodes all
31 begin with <CODE>io_</CODE>, but that prefix is omitted in this documentation.
32 The <CODE>if_ops_name</CODE> function takes an opcode and returns a character
33 string holding the opcode name (without the <CODE>io_</CODE> prefix). This is
34 used by the library when it prints out instructions, but you may also
35 call it directly.
37 </P>
38 <P>
39 <A NAME="IDX141"></A>
40 <A NAME="IDX142"></A>
41 <A NAME="IDX143"></A>
42 Each opcode is associated with a particular instruction format. The
43 formats are specified by members of the <CODE>inst_format</CODE> enumeration.
44 The <CODE>format</CODE> method may be used to retrieve the format for a
45 particular instruction. Alternatively, the <CODE>which_format</CODE> function
46 takes an opcode and returns its format without reference to any
47 particular instruction. Each format corresponds to a particular derived
48 instruction class:
50 </P>
51 <DL COMPACT>
53 <DT><CODE>inf_rrr</CODE>
54 <DD>
55 Three operand instructions use the <CODE>in_rrr</CODE> class.
57 <DT><CODE>inf_bj</CODE>
58 <DD>
59 Branch and jump instructions use the <CODE>in_bj</CODE> class.
61 <DT><CODE>inf_ldc</CODE>
62 <DD>
63 The load constant instruction uses the <CODE>in_ldc</CODE> class.
65 <DT><CODE>inf_cal</CODE>
66 <DD>
67 The call instruction uses the <CODE>in_cal</CODE> class.
69 <DT><CODE>inf_array</CODE>
70 <DD>
71 The array instruction uses the <CODE>in_array</CODE> class.
73 <DT><CODE>inf_mbr</CODE>
74 <DD>
75 The multi-way branch instruction uses the <CODE>in_mbr</CODE> class.
77 <DT><CODE>inf_lab</CODE>
78 <DD>
79 The label instruction uses the <CODE>in_lab</CODE> class.
81 <DT><CODE>inf_gen</CODE>
82 <DD>
83 Generic instructions use the <CODE>in_gen</CODE> class.
84 </DL>
86 <P>
87 The <CODE>format</CODE> method is often used in <CODE>switch</CODE> statements for
88 dealing with different kinds of instructions. For example, the
89 following code computes the number of source operands in an instruction
90 (instead of using the <CODE>num_srcs</CODE> method):
92 </P>
94 <PRE>
95 instruction *i;
96 switch (i-&#62;format()) {
97 case inf_rrr: {
98 n += 2;
99 break;
101 case inf_bj: {
102 n += 1;
103 break;
105 case inf_cal: {
106 in_cal *cali = (in_cal *)i;
107 n += 1 + cali-&#62;num_args();
108 break;
110 case inf_array: {
111 in_array *arri = (in_array *)i;
112 n += 2 + 2 * arri-&#62;dims();
113 break;
115 case inf_mbr: {
116 n += 1;
117 break;
119 case inf_gen: {
120 in_gen *geni = (in_gen *)i;
121 n += geni-&#62;num_srcs();
122 break;
124 default: {
125 /* other formats (inf_ldc and inf_lab) have no source operands */
126 break;
129 </PRE>
132 The opcodes and instruction formats are defined in the <TT>`opcodes.h'</TT>
133 and <TT>`opcodes.cc'</TT> files.
135 </P>
137 <P><HR><P>
138 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_23.html">previous</A>, <A HREF="suif1_25.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
139 </BODY>
140 </HTML>