2 * Mesa 3-D graphics library
5 * Copyright (C) 2005 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #if !defined SLANG_ASSEMBLE_H
26 #define SLANG_ASSEMBLE_H
28 #include "slang_compile.h"
30 #if defined __cplusplus
34 typedef enum slang_assembly_type_
41 slang_asm_float_deref
,
43 slang_asm_float_multiply
,
44 slang_asm_float_divide
,
45 slang_asm_float_negate
,
47 slang_asm_float_equal
,
48 slang_asm_float_to_int
,
53 slang_asm_int_to_float
,
54 slang_asm_int_to_addr
,
63 slang_asm_addr_multiply
,
65 slang_asm_jump_if_zero
,
68 slang_asm_local_alloc
,
76 } slang_assembly_type
;
78 typedef struct slang_assembly_
80 slang_assembly_type type
;
85 typedef struct slang_assembly_file_
89 } slang_assembly_file
;
91 void slang_assembly_file_construct (slang_assembly_file
*);
92 void slang_assembly_file_destruct (slang_assembly_file
*);
93 int slang_assembly_file_push (slang_assembly_file
*, slang_assembly_type
);
94 int slang_assembly_file_push_label (slang_assembly_file
*, slang_assembly_type
, GLuint
);
95 int slang_assembly_file_push_label2 (slang_assembly_file
*, slang_assembly_type
, GLuint
, GLuint
);
96 int slang_assembly_file_push_literal (slang_assembly_file
*, slang_assembly_type
, GLfloat
);
98 typedef struct slang_assembly_flow_control_
100 unsigned int loop_start
; /* for "continue" statement */
101 unsigned int loop_end
; /* for "break" statement */
102 unsigned int function_end
; /* for "return" statement */
103 } slang_assembly_flow_control
;
105 typedef struct slang_assembly_name_space_
107 struct slang_function_scope_
*funcs
;
108 struct slang_struct_scope_
*structs
;
109 struct slang_variable_scope_
*vars
;
110 } slang_assembly_name_space
;
112 slang_function
*_slang_locate_function (const char *name
, slang_operation
*params
,
113 unsigned int num_params
, slang_assembly_name_space
*space
);
115 int _slang_assemble_function (slang_assembly_file
*, struct slang_function_
*,
116 slang_assembly_name_space
*);
118 typedef struct slang_assembly_stack_info_
120 unsigned int swizzle_mask
;
121 } slang_assembly_stack_info
;
123 int _slang_cleanup_stack (slang_assembly_file
*, slang_operation
*, int ref
,
124 slang_assembly_name_space
*);
126 typedef struct slang_assembly_local_info_
128 unsigned int ret_size
;
129 unsigned int addr_tmp
;
130 unsigned int swizzle_tmp
;
131 } slang_assembly_local_info
;
133 int _slang_assemble_operation (slang_assembly_file
*, struct slang_operation_
*, int reference
,
134 slang_assembly_flow_control
*, slang_assembly_name_space
*, slang_assembly_local_info
*,
135 slang_assembly_stack_info
*);
137 void xxx_first (slang_assembly_file
*);
138 void xxx_prolog (slang_assembly_file
*);