xref: /titanic_41/usr/src/cmd/geniconvtbl/iconv_tm.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _ICONV_TM_H
28 #define	_ICONV_TM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 
38 #include <inttypes.h>
39 #include <sys/isa_defs.h>
40 #include <sys/types.h>
41 
42 
43 #if !defined(DEBUG)
44 #define	NDEBUG	/* for assert() */
45 #endif /* DEBUG */
46 
47 
48 #if defined(DEBUG)
49 #define	ENABLE_TRACE
50 #endif /* DEBUG */
51 
52 #define	MAXSEQUENCE	(128)
53 #define	MAXREGID	(256)
54 #define	MAXNAMELENGTH	(255)
55 
56 /*
57  * ITM Identifier
58  */
59 
60 #define	ITM_IDENT_LEN			(4)
61 #define	ITM_IDENT_0			(0x49)
62 #define	ITM_IDENT_1			(0x54)
63 #define	ITM_IDENT_2			(0x4d)
64 #define	ITM_IDENT_3			(0x00)
65 
66 
67 /*
68  * ITM Platform Specification
69  */
70 
71 #define	ITM_SPEC_LEN			(4)
72 #define	ITM_SPEC_0			(0)
73 #define	ITM_SPEC_1			(0)
74 #define	ITM_SPEC_2			(0)
75 #define	ITM_SPEC_3_UNSPECIFIED		(0)
76 #define	ITM_SPEC_3_32_BIG_ENDIAN	(1)
77 #define	ITM_SPEC_3_32_LITTLE_ENDIAN	(2)
78 #define	ITM_SPEC_3_64_BIG_ENDIAN	(3)
79 #define	ITM_SPEC_3_64_LITTLE_ENDIAN	(4)
80 
81 
82 /*
83  * ITM Version
84  */
85 
86 #define	ITM_VER_LEN			(4)
87 #define	ITM_VER_0			(0)
88 #define	ITM_VER_1			(0)
89 #define	ITM_VER_2			(0)
90 #define	ITM_VER_3			(1)
91 
92 
93 /*
94  * PADDING
95  */
96 #define	ITM_PAD_LEN			(4)
97 
98 
99 /*
100  * Generic offset&pointer/data/string
101  */
102 typedef uint32_t	pad_t;
103 typedef ulong_t		itm_type_t;
104 typedef uintptr_t	itm_place2_t;	/* position of data */
105 typedef size_t		itm_size_t;
106 typedef long		itm_num_t;
107 typedef union itm_place_union {
108 	int64_t		itm_64d;	/* positon of real data */
109 	struct {
110 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
111 		pad_t		pad;
112 #endif
113 		itm_place2_t   ptr;
114 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
115 		pad_t		pad;
116 #endif
117 	}itm_place_union_struct;
118 	char			itm_c[8];
119 }	itm_place_t;
120 #define	itm_ptr	itm_place_union_struct.ptr
121 #define	itm_pad	itm_place_union_struct.pad
122 
123 
124 typedef struct {
125 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
126 	pad_t		pad;
127 #endif
128 	itm_size_t	size;		/* size in bytes */
129 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
130 	pad_t		pad;
131 #endif
132 
133 	itm_place_t	place;		/* place of data */
134 } itm_data_t;
135 
136 
137 /*
138  * Generic place table information
139  */
140 
141 typedef struct {
142 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
143 	pad_t		pad1;
144 #endif
145 	itm_size_t	size;		/* size in bytes */
146 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
147 	pad_t		pad1;
148 #endif
149 
150 	itm_place_t	place;		/* place of place table */
151 
152 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
153 	pad_t		pad2;
154 #endif
155 	itm_num_t	number;		/* number of entry */
156 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
157 	pad_t		pad2;
158 #endif
159 } itm_place_tbl_info_t;
160 
161 
162 /*
163  * Generic place table section
164  */
165 
166 typedef struct {
167 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
168 	pad_t		pad1;
169 #endif
170 	itm_size_t	size;		/* size in bytes */
171 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
172 	pad_t		pad1;
173 #endif
174 
175 	itm_place_t	place;		/* place of table section */
176 
177 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
178 	pad_t		pad2;
179 #endif
180 	itm_num_t	number;		/* number of table */
181 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
182 	pad_t		pad2;
183 #endif
184 
185 } itm_section_info_t;
186 
187 
188 /*
189  * Generic table header
190  */
191 
192 #define	ITM_TBL_MASK		(0x000000ffUL)
193 
194 #define	ITM_TBL_NONE		(0x00000000UL)
195 #define	ITM_TBL_ITM		(0x00000001UL)
196 #define	ITM_TBL_DIREC		(0x00000002UL)
197 #define	ITM_TBL_COND		(0x00000003UL)
198 #define	ITM_TBL_MAP		(0x00000004UL)
199 #define	ITM_TBL_OP		(0x00000005UL)
200 #define	ITM_TBL_RANGE		(0x00000006UL)
201 #define	ITM_TBL_ESCAPESEQ	(0x00000007UL)
202 
203 #define	ITM_TBL_NONE_NONE		(ITM_TBL_NONE  | 0x00000000UL)
204 #define	ITM_TBL_DIREC_NONE		(ITM_TBL_DIREC | 0x00000000UL)
205 #define	ITM_TBL_DIREC_RESET		(ITM_TBL_DIREC | 0x00000100UL)
206 #define	ITM_TBL_COND_NONE		(ITM_TBL_COND  | 0x00000000UL)
207 #define	ITM_TBL_MAP_NONE		(ITM_TBL_MAP   | 0x00000000UL)
208 #define	ITM_TBL_MAP_INDEX_FIXED_1_1	(ITM_TBL_MAP   | 0x00000100UL)
209 #define	ITM_TBL_MAP_INDEX_FIXED		(ITM_TBL_MAP   | 0x00000200UL)
210 #define	ITM_TBL_MAP_LOOKUP		(ITM_TBL_MAP   | 0x00000300UL)
211 #define	ITM_TBL_MAP_HASH		(ITM_TBL_MAP   | 0x00000400UL)
212 #define	ITM_TBL_MAP_DENSE_ENC		(ITM_TBL_MAP   | 0x00000500UL)
213 #define	ITM_TBL_MAP_VAR			(ITM_TBL_MAP   | 0x00000600UL)
214 #define	ITM_TBL_OP_NONE			(ITM_TBL_OP    | 0x00000000UL)
215 #define	ITM_TBL_OP_INIT			(ITM_TBL_OP    | 0x00000100UL)
216 #define	ITM_TBL_OP_RESET		(ITM_TBL_OP    | 0x00000200UL)
217 #define	ITM_TBL_RANGE_NONE		(ITM_TBL_RANGE | 0x00000000UL)
218 #define	ITM_TBL_ESCAPESEQ_NONE		(ITM_TBL_ESCAPESEQ | 0x00000000UL)
219 
220 typedef struct {
221 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
222 	pad_t		pad1;
223 #endif
224 	itm_type_t	type;		/* type of table */
225 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
226 	pad_t		pad1;
227 #endif
228 	itm_place_t	name;		/* name of table */
229 
230 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
231 	pad_t		pad2;
232 #endif
233 	itm_size_t	size;		/* size of table */
234 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
235 	pad_t		pad2;
236 #endif
237 
238 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
239 	pad_t		pad3;
240 #endif
241 	itm_num_t	number;		/* number of entry */
242 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
243 	pad_t		pad3;
244 #endif
245 } itm_tbl_hdr_t;
246 
247 
248 /*
249  * Iconv Code Set Translation Module (ITM) header
250  */
251 
252 typedef struct {
253 	unsigned char	ident[ITM_IDENT_LEN];	/* identifier */
254 	unsigned char	spec[ITM_SPEC_LEN];	/* platform specification */
255 	unsigned char	version[ITM_VER_LEN];	/* version */
256 	unsigned char	padding[ITM_PAD_LEN];	/* padding  */
257 
258 
259 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
260 	pad_t		pad1;
261 #endif
262 	itm_size_t	itm_hdr_size;		/* ITM header size */
263 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
264 	pad_t		pad1;
265 #endif
266 
267 	itm_place_t	itm_size;		/* size of ITM (file size) */
268 	itm_data_t	type_id;		/* type identifier */
269 	itm_data_t	interpreter;		/* interpreter */
270 	itm_place_t	op_init_tbl;		/* init operation table */
271 	itm_place_t	op_reset_tbl;		/* reset operation table */
272 	itm_place_t	direc_init_tbl;		/* initial direction table */
273 
274 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
275 	pad_t		pad3;
276 #endif
277 	itm_num_t	reg_num;		/* number of register */
278 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
279 	pad_t		pad3;
280 #endif
281 
282 	itm_place_t	info_hdr;		/* ITM Info header */
283 } itm_hdr_t;
284 
285 
286 /*
287  * ITM Info header
288  */
289 typedef struct {
290 	itm_section_info_t	str_sec;	/* string section */
291 	itm_section_info_t	direc_tbl_sec;	/* direction table section */
292 	itm_section_info_t	cond_tbl_sec;	/* condition table section */
293 	itm_section_info_t	map_tbl_sec;	/* map table section */
294 	itm_section_info_t	op_tbl_sec;	/* operation table section */
295 	itm_section_info_t	range_tbl_sec;	/* range section */
296 	itm_section_info_t	escapeseq_tbl_sec; /* escapeseq section */
297 	itm_section_info_t	data_sec;	/* data section */
298 	itm_section_info_t	name_sec;	/* name section */
299 
300 	itm_place_tbl_info_t	str_plc_tbl;	/* string info */
301 	itm_place_tbl_info_t	direc_plc_tbl;	/* direction table info */
302 	itm_place_tbl_info_t	cond_plc_tbl;	/* condition table info */
303 	itm_place_tbl_info_t	map_plc_tbl;	/* map table info */
304 	itm_place_tbl_info_t	op_plc_tbl;	/* operation table info */
305 	itm_place_tbl_info_t	range_plc_tbl;	/* range info */
306 	itm_place_tbl_info_t	escapeseq_plc_tbl; /* escape info */
307 	itm_place_tbl_info_t	data_plc_tbl;	/* data info */
308 	itm_place_tbl_info_t	name_plc_tbl;	/* name info */
309 	itm_place_tbl_info_t	reg_plc_tbl;	/* register name info */
310 } itm_info_hdr_t;
311 
312 
313 /*
314  * Direction
315  */
316 
317 typedef enum {
318 	ITM_ACTION_NONE,	/* not used */
319 	ITM_ACTION_DIRECTION,	/* direction */
320 	ITM_ACTION_MAP,		/* map */
321 	ITM_ACTION_OPERATION	/* operation */
322 } itm_action_type_t;
323 
324 typedef struct {
325 	itm_place_t		condition;
326 	itm_place_t		action;
327 } itm_direc_t;
328 
329 
330 /*
331  * Condition
332  */
333 
334 typedef enum {
335 	ITM_COND_NONE = 0,	/* not used */
336 	ITM_COND_BETWEEN = 1,	/* input data is inside of ranges */
337 	ITM_COND_EXPR = 2,	/* expression */
338 	ITM_COND_ESCAPESEQ = 3	/* escape sequense */
339 } itm_cond_type_t;
340 
341 typedef struct {
342 	pad_t		pad;
343 	itm_cond_type_t	type;
344 	union {
345 		itm_place_t	place;
346 		itm_data_t	data;
347 	}		operand;
348 } itm_cond_t;
349 
350 typedef struct {
351 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
352 	pad_t		pad;
353 #endif
354 	itm_size_t	len;
355 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
356 	pad_t		pad;
357 #endif
358 } itm_range_hdr_t;
359 
360 typedef struct {
361 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
362 	pad_t		pad1;
363 #endif
364 	itm_size_t	len_min;
365 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
366 	pad_t		pad1;
367 #endif
368 
369 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
370 	pad_t		pad2;
371 #endif
372 	itm_size_t	len_max;
373 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
374 	pad_t		pad2;
375 #endif
376 } itm_escapeseq_hdr_t;
377 
378 
379 /*
380  * Map table: octet-sequence to octet-sequence: index
381  */
382 
383 typedef struct {
384 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
385 	pad_t		pad1;
386 #endif
387 	itm_size_t	source_len;	/* source length */
388 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
389 	pad_t		pad1;
390 #endif
391 
392 
393 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
394 	pad_t		pad2;
395 #endif
396 	itm_size_t	result_len;	/* result length */
397 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
398 	pad_t		pad2;
399 #endif
400 
401 	itm_place_t	start;		/* start offset */
402 	itm_place_t	end;		/* end offset */
403 
404 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
405 	pad_t		pad3_num;
406 #endif
407 	itm_num_t	default_error;
408 /*
409  *		-1:path through
410  *		 0:with default value
411  *		 1:with error table
412  *		 2:without error table
413  */
414 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
415 	pad_t		pad3_num;
416 #endif
417 
418 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
419 	pad_t		pad4_num;
420 #endif
421 	itm_num_t	error_num;
422 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
423 	pad_t		pad4_num;
424 #endif
425 
426 
427 } itm_map_idx_fix_hdr_t;
428 
429 /*
430  * Map table: octet-sequence to octet-sequence: lookup
431  */
432 
433 typedef struct {
434 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
435 	pad_t		pad1;
436 #endif
437 	itm_size_t	source_len;	/* source length */
438 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
439 	pad_t		pad1;
440 #endif
441 
442 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
443 	pad_t		pad2;
444 #endif
445 	itm_size_t	result_len;	/* result length */
446 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
447 	pad_t		pad2;
448 #endif
449 
450 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
451 	pad_t		pad3_num;
452 #endif
453 	itm_num_t	default_error;
454 /*
455  *		-1:path through
456  *		 0:with default value
457  *		 1:with error table
458  *		 2:without error table
459  */
460 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
461 	pad_t		pad3_num;
462 #endif
463 
464 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
465 	pad_t		pad4_num;
466 #endif
467 	itm_num_t	error_num;
468 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
469 	pad_t		pad4_num;
470 #endif
471 } itm_map_lookup_hdr_t;
472 
473 /*
474  * Map table: octet-sequence to octet-sequence: hash
475  */
476 
477 typedef struct {
478 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
479 	pad_t		pad1;
480 #endif
481 	itm_size_t	source_len;	/* source length */
482 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
483 	pad_t		pad1;
484 #endif
485 
486 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
487 	pad_t		pad2;
488 #endif
489 	itm_size_t	result_len;	/* result length */
490 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
491 	pad_t		pad2;
492 #endif
493 
494 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
495 	pad_t		pad3;
496 #endif
497 	itm_size_t	hash_tbl_size;	/* hash table size */
498 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
499 	pad_t		pad3;
500 #endif
501 
502 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
503 	pad_t		pad4;
504 #endif
505 	itm_num_t	hash_tbl_num;	/* hash table entryies */
506 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
507 	pad_t		pad4;
508 #endif
509 
510 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
511 	pad_t		pad5;
512 #endif
513 	itm_size_t	hash_of_size;	/* hash overflow table size */
514 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
515 	pad_t		pad5;
516 #endif
517 
518 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
519 	pad_t		pad6;
520 #endif
521 	itm_num_t	hash_of_num;	/* hash overflow table entryies */
522 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
523 	pad_t		pad6;
524 #endif
525 
526 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
527 	pad_t		pad7_num;
528 #endif
529 	itm_num_t	default_error;
530 /*
531  *		-1:path through
532  *		 0:with default value
533  *		 1:with error table
534  *		 2:without error table
535  */
536 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
537 	pad_t		pad7_num;
538 #endif
539 
540 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
541 	pad_t		pad8_num;
542 #endif
543 	itm_num_t	error_num;
544 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
545 	pad_t		pad8_num;
546 #endif
547 
548 } itm_map_hash_hdr_t;
549 
550 /*
551  * Map table: octet-sequence to octet-sequence: dense encoding
552  */
553 
554 typedef struct {
555 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
556 	pad_t		pad1;
557 #endif
558 	itm_size_t	source_len;	/* source length */
559 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
560 	pad_t		pad1;
561 #endif
562 
563 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
564 	pad_t		pad2;
565 #endif
566 	itm_size_t	result_len;	/* result length */
567 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
568 	pad_t		pad2;
569 #endif
570 
571 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
572 	pad_t		pad3_num;
573 #endif
574 	itm_num_t	default_error;
575 /*
576  *		-1:path through
577  *		 0:with default value
578  *		 1:with error table
579  *		 2:without error table
580  */
581 
582 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
583 	pad_t		pad3_num;
584 #endif
585 
586 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
587 	pad_t		pad4_num;
588 #endif
589 	itm_num_t	error_num;
590 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
591 	pad_t		pad4_num;
592 #endif
593 } itm_map_dense_enc_hdr_t;
594 
595 
596 
597 /*
598  * Operation
599  */
600 
601 typedef enum {	/* Operation Type */
602 	ITM_OP_NONE,		/* not used */
603 	ITM_OP_ERROR,		/* error */
604 	ITM_OP_ERROR_D,		/* error */
605 	ITM_OP_OUT,		/* output */
606 	ITM_OP_OUT_D,		/* output */
607 	ITM_OP_OUT_S,		/* output */
608 	ITM_OP_OUT_R,		/* output */
609 	ITM_OP_OUT_INVD,	/* output */
610 	ITM_OP_DISCARD,		/* discard */
611 	ITM_OP_DISCARD_D,	/* discard */
612 	ITM_OP_EXPR,		/* expression */
613 	ITM_OP_IF,		/* if */
614 	ITM_OP_IF_ELSE,		/* if_else */
615 	ITM_OP_DIRECTION,	/* switch direction */
616 	ITM_OP_MAP,		/* use map */
617 	ITM_OP_OPERATION,	/* invoke operation */
618 	ITM_OP_INIT,		/* invoke init operation */
619 	ITM_OP_RESET,		/* invoke reset operation */
620 	ITM_OP_BREAK,		/* break */
621 	ITM_OP_RETURN,		/* return */
622 	ITM_OP_PRINTCHR,	/* print out argument as character */
623 	ITM_OP_PRINTHD,		/* print out argument as hexadecimal */
624 	ITM_OP_PRINTINT		/* print out argument as integer */
625 } itm_op_type_t;
626 
627 typedef struct {
628 	pad_t				pad;
629 	itm_op_type_t			type;
630 	itm_place_t			name;
631 
632 	union {
633 		itm_place_t		operand[3];
634 		itm_data_t		value;
635 		struct {
636 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
637 			pad_t		pad_num;
638 #endif
639 			itm_num_t	num;
640 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
641 			pad_t		pad_num;
642 #endif
643 		}			itm_op_num;
644 	}		data;
645 } itm_op_t;
646 #define	itm_opnum itm_op_num.num
647 #define	itm_oppad itm_op_num.pad_num
648 
649 /*
650  * Expression
651  */
652 
653 #define	ITM_EXPR_PROTO(type, op0, op1)	ITM_EXPR_##type##_##op0##_##op1
654 #define	ITM_EXPR_BIN(type)			\
655 	ITM_EXPR_PROTO(type, E, E),		\
656 	ITM_EXPR_PROTO(type, E, D),		\
657 	ITM_EXPR_PROTO(type, E, R),		\
658 	ITM_EXPR_PROTO(type, E, INVD),		\
659 	ITM_EXPR_PROTO(type, D, E),		\
660 	ITM_EXPR_PROTO(type, D, D),		\
661 	ITM_EXPR_PROTO(type, D, R),		\
662 	ITM_EXPR_PROTO(type, D, INVD),		\
663 	ITM_EXPR_PROTO(type, R, E),		\
664 	ITM_EXPR_PROTO(type, R, D),		\
665 	ITM_EXPR_PROTO(type, R, R),		\
666 	ITM_EXPR_PROTO(type, R, INVD),		\
667 	ITM_EXPR_PROTO(type, INVD, E),		\
668 	ITM_EXPR_PROTO(type, INVD, D),		\
669 	ITM_EXPR_PROTO(type, INVD, R),		\
670 	ITM_EXPR_PROTO(type, INVD, INVD)
671 
672 #define	ITM_EXPR_PLUS		ITM_EXPR_PLUS_E_E
673 #define	ITM_EXPR_MINUS		ITM_EXPR_MINUS_E_E
674 #define	ITM_EXPR_MUL		ITM_EXPR_MUL_E_E
675 #define	ITM_EXPR_DIV		ITM_EXPR_DIV_E_E
676 #define	ITM_EXPR_MOD		ITM_EXPR_MOD_E_E
677 #define	ITM_EXPR_SHIFT_L	ITM_EXPR_SHIFT_L_E_E
678 #define	ITM_EXPR_SHIFT_R	ITM_EXPR_SHIFT_R_E_E
679 #define	ITM_EXPR_OR		ITM_EXPR_OR_E_E
680 #define	ITM_EXPR_XOR		ITM_EXPR_XOR_E_E
681 #define	ITM_EXPR_AND		ITM_EXPR_AND_E_E
682 #define	ITM_EXPR_EQ		ITM_EXPR_EQ_E_E
683 #define	ITM_EXPR_NE		ITM_EXPR_NE_E_E
684 #define	ITM_EXPR_GT		ITM_EXPR_GT_E_E
685 #define	ITM_EXPR_GE		ITM_EXPR_GE_E_E
686 #define	ITM_EXPR_LT		ITM_EXPR_LT_E_E
687 #define	ITM_EXPR_LE		ITM_EXPR_LE_E_E
688 
689 typedef enum {	/* Expression Type */
690 	ITM_EXPR_NONE,		/* not used */
691 	ITM_EXPR_NOP,		/* not used */
692 	ITM_EXPR_NAME,		/* not used */
693 	ITM_EXPR_INT,		/* integer */
694 	ITM_EXPR_SEQ,		/* byte sequence */
695 	ITM_EXPR_REG,		/* register */
696 	ITM_EXPR_IN_VECTOR,	/* in[expr] */
697 	ITM_EXPR_IN_VECTOR_D,	/* in[DECIMAL] */
698 	ITM_EXPR_OUT,		/* out */
699 	ITM_EXPR_TRUE,		/* true */
700 	ITM_EXPR_FALSE,		/* false */
701 	ITM_EXPR_IN,		/* input data */
702 	ITM_EXPR_UMINUS,	/* unary minus */
703 	ITM_EXPR_BIN(PLUS),	/* A +	B */
704 	ITM_EXPR_BIN(MINUS),	/* A -	B */
705 	ITM_EXPR_BIN(MUL),	/* A *	B */
706 	ITM_EXPR_BIN(DIV),	/* A /	B */
707 	ITM_EXPR_BIN(MOD),	/* A %	B */
708 	ITM_EXPR_BIN(SHIFT_L),	/* A << B */
709 	ITM_EXPR_BIN(SHIFT_R),	/* A >> B */
710 	ITM_EXPR_BIN(OR),	/* A |	B */
711 	ITM_EXPR_BIN(XOR),	/* A ^	B */
712 	ITM_EXPR_BIN(AND),	/* A &	B */
713 	ITM_EXPR_BIN(EQ),	/* A == B */
714 	ITM_EXPR_BIN(NE),	/* A != B */
715 	ITM_EXPR_BIN(GT),	/* A >	B */
716 	ITM_EXPR_BIN(GE),	/* A >= B */
717 	ITM_EXPR_BIN(LT),	/* A <	B */
718 	ITM_EXPR_BIN(LE),	/* A <= B */
719 	ITM_EXPR_NOT,		/*   !A	  */
720 	ITM_EXPR_NEG,		/*   ~A	  */
721 	ITM_EXPR_LOR,		/* A || B */
722 	ITM_EXPR_LAND,		/* A && B */
723 	ITM_EXPR_ASSIGN,	/* A  = B */
724 	ITM_EXPR_OUT_ASSIGN,	/* out = A */
725 	ITM_EXPR_IN_EQ,		/* in == A */
726 	ITM_EXPR_IF,		/* if  */
727 	ITM_EXPR_ELSE		/* else */
728 } itm_expr_type_t;
729 
730 #define	ITM_OPERAND_EXPR	(0)
731 #define	ITM_OPERAND_PLACE	(1)
732 #define	ITM_OPERAND_VALUE	(2)
733 #define	ITM_OPERAND_REGISTER	(3)
734 
735 typedef struct {
736 	pad_t			pad;
737 	itm_expr_type_t		type;
738 	union {
739 		itm_place_t		operand[2];
740 		itm_data_t		value;
741 		struct {
742 #if !defined(_LP64) && !defined(_LITTLE_ENDIAN)
743 			pad_t		pad_num;
744 #endif
745 			itm_num_t	num;
746 #if !defined(_LP64) && defined(_LITTLE_ENDIAN)
747 			pad_t		pad_num;
748 #endif
749 		}			itm_ex_num;
750 	}	data;
751 } itm_expr_t;
752 #define	itm_exnum itm_ex_num.num
753 #define	itm_expad itm_ex_num.pad_num
754 
755 
756 #ifdef	__cplusplus
757 }
758 #endif
759 
760 #endif /* !_ICONV_TM_H */
761