New IR_COND node for evaluating conditional expressions (for if/while/for).
[mesa.git] / src / mesa / shader / slang / slang_ir.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.3
4 *
5 * Copyright (C) 2005-2007 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
25 /**
26 * \file slang_ir.h
27 * Mesa GLSL Itermediate Representation tree types and constants.
28 * \author Brian Paul
29 */
30
31
32 #ifndef SLANG_IR_H
33 #define SLANG_IR_H
34
35
36 #include "imports.h"
37 #include "slang_compile.h"
38 #include "mtypes.h"
39
40
41 /**
42 * Intermediate Representation opcode
43 */
44 typedef enum
45 {
46 IR_NOP = 0,
47 IR_SEQ, /* sequence (eval left, then right) */
48 IR_LABEL, /* target of a jump or cjump */
49 IR_JUMP, /* unconditional jump */
50 IR_CJUMP, /* conditional jump */
51 IR_COND, /* conditional expression */
52 IR_CALL, /* call subroutine */
53 IR_MOVE,
54 IR_ADD,
55 IR_SUB,
56 IR_MUL,
57 IR_DIV,
58 IR_DOT4,
59 IR_DOT3,
60 IR_CROSS, /* vec3 cross product */
61 IR_MIN,
62 IR_MAX,
63 IR_SEQUAL, /* Set if not equal */
64 IR_SNEQUAL, /* Set if equal */
65 IR_SGE, /* Set if greater or equal */
66 IR_SGT, /* Set if greater than */
67 IR_POW, /* x^y */
68 IR_EXP, /* e^x */
69 IR_EXP2, /* 2^x */
70 IR_LOG2, /* log base 2 */
71 IR_RSQ, /* 1/sqrt() */
72 IR_RCP, /* recipricol */
73 IR_FLOOR,
74 IR_FRAC,
75 IR_ABS,
76 IR_SIN, /* sine */
77 IR_COS, /* cosine */
78 IR_NOT, /* logical not */
79 IR_VAR, /* variable reference */
80 IR_VAR_DECL,/* var declaration */
81 IR_FLOAT,
82 IR_FIELD,
83 IR_I_TO_F
84 } slang_ir_opcode;
85
86
87 /**
88 * Describes where data storage is allocated.
89 */
90 typedef struct
91 {
92 enum register_file File; /**< PROGRAM_TEMPORARY, PROGRAM_INPUT, etc */
93 GLint Index; /**< -1 means unallocated */
94 GLint Size; /**< number of floats */
95 } slang_ir_storage;
96
97
98 /**
99 * Intermediate Representation (IR) tree node
100 */
101 typedef struct slang_ir_node_
102 {
103 slang_ir_opcode Opcode;
104 struct slang_ir_node_ *Children[2];
105 const char *Comment;
106 const char *Target;
107 GLuint Swizzle;
108 GLuint Writemask; /**< If Op == IR_MOVE */
109 GLfloat Value[4]; /**< If Op == IR_FLOAT */
110 slang_variable *Var;
111 slang_ir_storage *Store;
112 } slang_ir_node;
113
114
115 #endif /* SLANG_IR_H */